@likec4/mcp 1.59.1 → 1.59.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/chunks/src.mjs +21 -342
  2. package/dist/cli.mjs +1 -5
  3. package/package.json +22 -21
  4. package/dist/chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -1
  5. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
  6. package/dist/chunks/libs/@hono/mcp.mjs +0 -70
  7. package/dist/chunks/libs/@hono/node-server.mjs +0 -3
  8. package/dist/chunks/libs/@logtape/logtape.mjs +0 -5
  9. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -5
  10. package/dist/chunks/libs/@radix-ui/colors.mjs +0 -1
  11. package/dist/chunks/libs/@ts-graphviz/ast.mjs +0 -3
  12. package/dist/chunks/libs/@ts-graphviz/core.mjs +0 -1
  13. package/dist/chunks/libs/@ungap/structured-clone.mjs +0 -1
  14. package/dist/chunks/libs/character-entities.mjs +0 -2
  15. package/dist/chunks/libs/chevrotain-allstar.mjs +0 -2
  16. package/dist/chunks/libs/chevrotain.mjs +0 -58
  17. package/dist/chunks/libs/chokidar.mjs +0 -3
  18. package/dist/chunks/libs/chroma-js.mjs +0 -15
  19. package/dist/chunks/libs/eventemitter3.mjs +0 -1
  20. package/dist/chunks/libs/graphology-dag.mjs +0 -1
  21. package/dist/chunks/libs/graphology.mjs +0 -1
  22. package/dist/chunks/libs/hast-util-sanitize.mjs +0 -1
  23. package/dist/chunks/libs/hast-util-to-html.mjs +0 -9
  24. package/dist/chunks/libs/hono.mjs +0 -1
  25. package/dist/chunks/libs/immer.mjs +0 -1
  26. package/dist/chunks/libs/khroma.mjs +0 -1
  27. package/dist/chunks/libs/langium.mjs +0 -19
  28. package/dist/chunks/libs/markdown-table.mjs +0 -2
  29. package/dist/chunks/libs/mdast-util-find-and-replace.mjs +0 -1
  30. package/dist/chunks/libs/mdast-util-from-markdown.mjs +0 -3
  31. package/dist/chunks/libs/mdast-util-gfm.mjs +0 -15
  32. package/dist/chunks/libs/mdast-util-to-hast.mjs +0 -11
  33. package/dist/chunks/libs/merge-error-cause.mjs +0 -2
  34. package/dist/chunks/libs/micromark-extension-gfm.mjs +0 -1
  35. package/dist/chunks/libs/mnemonist.mjs +0 -1
  36. package/dist/chunks/libs/nano-spawn.mjs +0 -3
  37. package/dist/chunks/libs/p-queue.mjs +0 -1
  38. package/dist/chunks/libs/pathe.mjs +0 -1
  39. package/dist/chunks/libs/picomatch.mjs +0 -1
  40. package/dist/chunks/libs/pretty-ms.mjs +0 -1
  41. package/dist/chunks/libs/remark-github-blockquote-alert.mjs +0 -3
  42. package/dist/chunks/libs/remark-rehype.mjs +0 -1
  43. package/dist/chunks/libs/remeda.mjs +0 -1
  44. package/dist/chunks/libs/ufo.mjs +0 -1
  45. package/dist/chunks/libs/unified.mjs +0 -1
  46. package/dist/chunks/libs/unstorage.mjs +0 -1
  47. package/dist/chunks/rolldown-runtime.mjs +0 -1
@@ -1,19 +0,0 @@
1
- import{a as t,i as n,n as i,r as o,t as s}from"../rolldown-runtime.mjs";import{n as c,t as u}from"./@chevrotain/regexp-to-ast.mjs";import{a as f,l as p,n as h,o as g,r as _,t as x,u as S}from"./chevrotain.mjs";import{t as T}from"./chevrotain-allstar.mjs";import{CompletionItemKind as ee,CompletionList as te,DidChangeWatchedFilesNotification as ne,Disposable as E,DocumentHighlight as re,Emitter as D,FileChangeType as ie,FoldingRange as ae,FoldingRangeKind as oe,Location as se,LocationLink as ce,Position as le,SemanticTokenModifiers as O,SemanticTokenTypes as k,SemanticTokensBuilder as ue,SymbolKind as de,TextDocumentSyncKind as fe}from"vscode-languageserver";import{DidChangeConfigurationNotification as pe,Emitter as me,TextDocumentSyncKind as he}from"vscode-languageserver-protocol";import*as ge from"node:fs";function isAstNode(t){return typeof t==`object`&&!!t&&typeof t.$type==`string`}function isReference(t){return typeof t==`object`&&!!t&&typeof t.$refText==`string`}function isAstNodeDescription(t){return typeof t==`object`&&!!t&&typeof t.name==`string`&&typeof t.type==`string`&&typeof t.path==`string`}function isLinkingError(t){return typeof t==`object`&&!!t&&isAstNode(t.container)&&isReference(t.reference)&&typeof t.message==`string`}var AbstractAstReflection=class{constructor(){this.subtypes={},this.allSubtypes={}}isInstance(t,n){return isAstNode(t)&&this.isSubtype(t.$type,n)}isSubtype(t,n){if(t===n)return!0;let i=this.subtypes[t];i||=this.subtypes[t]={};let o=i[n];if(o!==void 0)return o;{let o=this.computeIsSubtype(t,n);return i[n]=o,o}}getAllSubTypes(t){let n=this.allSubtypes[t];if(n)return n;{let n=this.getAllTypes(),i=[];for(let o of n)this.isSubtype(o,t)&&i.push(o);return this.allSubtypes[t]=i,i}}};function isCompositeCstNode(t){return typeof t==`object`&&!!t&&Array.isArray(t.content)}function isLeafCstNode(t){return typeof t==`object`&&!!t&&typeof t.tokenType==`object`}function isRootCstNode(t){return isCompositeCstNode(t)&&typeof t.fullText==`string`}const _e=`AbstractRule`,ve=`AbstractType`,ye=`Condition`,be=`TypeDefinition`,xe=`ValueLiteral`,Se=`AbstractElement`;function isAbstractElement(t){return R.isInstance(t,Se)}const Ce=`ArrayLiteral`,we=`ArrayType`;function isArrayType(t){return R.isInstance(t,we)}const Te=`BooleanLiteral`;function isBooleanLiteral(t){return R.isInstance(t,Te)}const Ee=`Conjunction`;function isConjunction(t){return R.isInstance(t,Ee)}const De=`Disjunction`;function isDisjunction(t){return R.isInstance(t,De)}const Oe=`Grammar`,ke=`GrammarImport`,Ae=`InferredType`;function isInferredType(t){return R.isInstance(t,Ae)}const je=`Interface`;function isInterface(t){return R.isInstance(t,je)}const Me=`NamedArgument`,Ne=`Negation`;function isNegation(t){return R.isInstance(t,Ne)}const Pe=`NumberLiteral`,Fe=`Parameter`,A=`ParameterReference`;function isParameterReference(t){return R.isInstance(t,A)}const j=`ParserRule`;function isParserRule(t){return R.isInstance(t,j)}const M=`ReferenceType`;function isReferenceType(t){return R.isInstance(t,M)}const Ie=`ReturnType`;function isReturnType(t){return R.isInstance(t,Ie)}const Le=`SimpleType`;function isSimpleType(t){return R.isInstance(t,Le)}const Re=`StringLiteral`,N=`TerminalRule`;function isTerminalRule(t){return R.isInstance(t,N)}const P=`Type`;function isType(t){return R.isInstance(t,P)}const ze=`TypeAttribute`,F=`UnionType`;function isUnionType(t){return R.isInstance(t,F)}const I=`Action`;function isAction(t){return R.isInstance(t,I)}const Be=`Alternatives`;function isAlternatives(t){return R.isInstance(t,Be)}const Ve=`Assignment`;function isAssignment(t){return R.isInstance(t,Ve)}const He=`CharacterRange`;function isCharacterRange(t){return R.isInstance(t,He)}const Ue=`CrossReference`;function isCrossReference(t){return R.isInstance(t,Ue)}const We=`EndOfFile`;function isEndOfFile(t){return R.isInstance(t,We)}const Ge=`Group`;function isGroup(t){return R.isInstance(t,Ge)}const Ke=`Keyword`;function isKeyword(t){return R.isInstance(t,Ke)}const qe=`NegatedToken`;function isNegatedToken(t){return R.isInstance(t,qe)}const L=`RegexToken`;function isRegexToken(t){return R.isInstance(t,L)}const Je=`RuleCall`;function isRuleCall(t){return R.isInstance(t,Je)}const Ye=`TerminalAlternatives`;function isTerminalAlternatives(t){return R.isInstance(t,Ye)}const Xe=`TerminalGroup`;function isTerminalGroup(t){return R.isInstance(t,Xe)}const Ze=`TerminalRuleCall`;function isTerminalRuleCall(t){return R.isInstance(t,Ze)}const Qe=`UnorderedGroup`;function isUnorderedGroup(t){return R.isInstance(t,Qe)}const $e=`UntilToken`;function isUntilToken(t){return R.isInstance(t,$e)}const et=`Wildcard`;function isWildcard(t){return R.isInstance(t,et)}var LangiumGrammarAstReflection=class extends AbstractAstReflection{getAllTypes(){return[Se,_e,ve,I,Be,Ce,we,Ve,Te,He,ye,Ee,Ue,De,We,Oe,ke,Ge,Ae,je,Ke,Me,qe,Ne,Pe,Fe,A,j,M,L,Ie,Je,Le,Re,Ye,Xe,N,Ze,P,ze,be,F,Qe,$e,xe,et]}computeIsSubtype(t,n){switch(t){case I:case Be:case Ve:case He:case Ue:case We:case Ge:case Ke:case qe:case L:case Je:case Ye:case Xe:case Ze:case Qe:case $e:case et:return this.isSubtype(Se,n);case Ce:case Pe:case Re:return this.isSubtype(xe,n);case we:case M:case Le:case F:return this.isSubtype(be,n);case Te:return this.isSubtype(`Condition`,n)||this.isSubtype(`ValueLiteral`,n);case Ee:case De:case Ne:case A:return this.isSubtype(ye,n);case Ae:case je:case P:return this.isSubtype(ve,n);case j:return this.isSubtype(`AbstractRule`,n)||this.isSubtype(`AbstractType`,n);case N:return this.isSubtype(_e,n);default:return!1}}getReferenceType(t){let n=`${t.container.$type}:${t.property}`;switch(n){case`Action:type`:case`CrossReference:type`:case`Interface:superTypes`:case`ParserRule:returnType`:case`SimpleType:typeRef`:return ve;case`Grammar:hiddenTokens`:case`ParserRule:hiddenTokens`:case`RuleCall:rule`:return _e;case`Grammar:usedGrammars`:return Oe;case`NamedArgument:parameter`:case`ParameterReference:parameter`:return Fe;case`TerminalRuleCall:rule`:return N;default:throw Error(`${n} is not a valid reference id.`)}}getTypeMetaData(t){switch(t){case Se:return{name:Se,properties:[{name:`cardinality`},{name:`lookahead`}]};case Ce:return{name:Ce,properties:[{name:`elements`,defaultValue:[]}]};case we:return{name:we,properties:[{name:`elementType`}]};case Te:return{name:Te,properties:[{name:`true`,defaultValue:!1}]};case Ee:return{name:Ee,properties:[{name:`left`},{name:`right`}]};case De:return{name:De,properties:[{name:`left`},{name:`right`}]};case Oe:return{name:Oe,properties:[{name:`definesHiddenTokens`,defaultValue:!1},{name:`hiddenTokens`,defaultValue:[]},{name:`imports`,defaultValue:[]},{name:`interfaces`,defaultValue:[]},{name:`isDeclared`,defaultValue:!1},{name:`name`},{name:`rules`,defaultValue:[]},{name:`types`,defaultValue:[]},{name:`usedGrammars`,defaultValue:[]}]};case ke:return{name:ke,properties:[{name:`path`}]};case Ae:return{name:Ae,properties:[{name:`name`}]};case je:return{name:je,properties:[{name:`attributes`,defaultValue:[]},{name:`name`},{name:`superTypes`,defaultValue:[]}]};case Me:return{name:Me,properties:[{name:`calledByName`,defaultValue:!1},{name:`parameter`},{name:`value`}]};case Ne:return{name:Ne,properties:[{name:`value`}]};case Pe:return{name:Pe,properties:[{name:`value`}]};case Fe:return{name:Fe,properties:[{name:`name`}]};case A:return{name:A,properties:[{name:`parameter`}]};case j:return{name:j,properties:[{name:`dataType`},{name:`definesHiddenTokens`,defaultValue:!1},{name:`definition`},{name:`entry`,defaultValue:!1},{name:`fragment`,defaultValue:!1},{name:`hiddenTokens`,defaultValue:[]},{name:`inferredType`},{name:`name`},{name:`parameters`,defaultValue:[]},{name:`returnType`},{name:`wildcard`,defaultValue:!1}]};case M:return{name:M,properties:[{name:`referenceType`}]};case Ie:return{name:Ie,properties:[{name:`name`}]};case Le:return{name:Le,properties:[{name:`primitiveType`},{name:`stringType`},{name:`typeRef`}]};case Re:return{name:Re,properties:[{name:`value`}]};case N:return{name:N,properties:[{name:`definition`},{name:`fragment`,defaultValue:!1},{name:`hidden`,defaultValue:!1},{name:`name`},{name:`type`}]};case P:return{name:P,properties:[{name:`name`},{name:`type`}]};case ze:return{name:ze,properties:[{name:`defaultValue`},{name:`isOptional`,defaultValue:!1},{name:`name`},{name:`type`}]};case F:return{name:F,properties:[{name:`types`,defaultValue:[]}]};case I:return{name:I,properties:[{name:`cardinality`},{name:`feature`},{name:`inferredType`},{name:`lookahead`},{name:`operator`},{name:`type`}]};case Be:return{name:Be,properties:[{name:`cardinality`},{name:`elements`,defaultValue:[]},{name:`lookahead`}]};case Ve:return{name:Ve,properties:[{name:`cardinality`},{name:`feature`},{name:`lookahead`},{name:`operator`},{name:`terminal`}]};case He:return{name:He,properties:[{name:`cardinality`},{name:`left`},{name:`lookahead`},{name:`right`}]};case Ue:return{name:Ue,properties:[{name:`cardinality`},{name:`deprecatedSyntax`,defaultValue:!1},{name:`lookahead`},{name:`terminal`},{name:`type`}]};case We:return{name:We,properties:[{name:`cardinality`},{name:`lookahead`}]};case Ge:return{name:Ge,properties:[{name:`cardinality`},{name:`elements`,defaultValue:[]},{name:`guardCondition`},{name:`lookahead`}]};case Ke:return{name:Ke,properties:[{name:`cardinality`},{name:`lookahead`},{name:`value`}]};case qe:return{name:qe,properties:[{name:`cardinality`},{name:`lookahead`},{name:`terminal`}]};case L:return{name:L,properties:[{name:`cardinality`},{name:`lookahead`},{name:`regex`}]};case Je:return{name:Je,properties:[{name:`arguments`,defaultValue:[]},{name:`cardinality`},{name:`lookahead`},{name:`rule`}]};case Ye:return{name:Ye,properties:[{name:`cardinality`},{name:`elements`,defaultValue:[]},{name:`lookahead`}]};case Xe:return{name:Xe,properties:[{name:`cardinality`},{name:`elements`,defaultValue:[]},{name:`lookahead`}]};case Ze:return{name:Ze,properties:[{name:`cardinality`},{name:`lookahead`},{name:`rule`}]};case Qe:return{name:Qe,properties:[{name:`cardinality`},{name:`elements`,defaultValue:[]},{name:`lookahead`}]};case $e:return{name:$e,properties:[{name:`cardinality`},{name:`lookahead`},{name:`terminal`}]};case et:return{name:et,properties:[{name:`cardinality`},{name:`lookahead`}]};default:return{name:t,properties:[]}}}};const R=new LangiumGrammarAstReflection;var z=class StreamImpl{constructor(t,n){this.startFn=t,this.nextFn=n}iterator(){let t={state:this.startFn(),next:()=>this.nextFn(t.state),[Symbol.iterator]:()=>t};return t}[Symbol.iterator](){return this.iterator()}isEmpty(){return!!this.iterator().next().done}count(){let t=this.iterator(),n=0,i=t.next();for(;!i.done;)n++,i=t.next();return n}toArray(){let t=[],n=this.iterator(),i;do i=n.next(),i.value!==void 0&&t.push(i.value);while(!i.done);return t}toSet(){return new Set(this)}toMap(t,n){let i=this.map(i=>[t?t(i):i,n?n(i):i]);return new Map(i)}toString(){return this.join()}concat(t){return new StreamImpl(()=>({first:this.startFn(),firstDone:!1,iterator:t[Symbol.iterator]()}),t=>{let n;if(!t.firstDone){do if(n=this.nextFn(t.first),!n.done)return n;while(!n.done);t.firstDone=!0}do if(n=t.iterator.next(),!n.done)return n;while(!n.done);return B})}join(t=`,`){let n=this.iterator(),i=``,o,s=!1;do o=n.next(),o.done||(s&&(i+=t),i+=toString$1(o.value)),s=!0;while(!o.done);return i}indexOf(t,n=0){let i=this.iterator(),o=0,s=i.next();for(;!s.done;){if(o>=n&&s.value===t)return o;s=i.next(),o++}return-1}every(t){let n=this.iterator(),i=n.next();for(;!i.done;){if(!t(i.value))return!1;i=n.next()}return!0}some(t){let n=this.iterator(),i=n.next();for(;!i.done;){if(t(i.value))return!0;i=n.next()}return!1}forEach(t){let n=this.iterator(),i=0,o=n.next();for(;!o.done;)t(o.value,i),o=n.next(),i++}map(t){return new StreamImpl(this.startFn,n=>{let{done:i,value:o}=this.nextFn(n);return i?B:{done:!1,value:t(o)}})}filter(t){return new StreamImpl(this.startFn,n=>{let i;do if(i=this.nextFn(n),!i.done&&t(i.value))return i;while(!i.done);return B})}nonNullable(){return this.filter(t=>t!=null)}reduce(t,n){let i=this.iterator(),o=n,s=i.next();for(;!s.done;)o=o===void 0?s.value:t(o,s.value),s=i.next();return o}reduceRight(t,n){return this.recursiveReduce(this.iterator(),t,n)}recursiveReduce(t,n,i){let o=t.next();if(o.done)return i;let s=this.recursiveReduce(t,n,i);return s===void 0?o.value:n(s,o.value)}find(t){let n=this.iterator(),i=n.next();for(;!i.done;){if(t(i.value))return i.value;i=n.next()}}findIndex(t){let n=this.iterator(),i=0,o=n.next();for(;!o.done;){if(t(o.value))return i;o=n.next(),i++}return-1}includes(t){let n=this.iterator(),i=n.next();for(;!i.done;){if(i.value===t)return!0;i=n.next()}return!1}flatMap(t){return new StreamImpl(()=>({this:this.startFn()}),n=>{do{if(n.iterator){let t=n.iterator.next();if(t.done)n.iterator=void 0;else return t}let{done:i,value:o}=this.nextFn(n.this);if(!i){let i=t(o);if(isIterable(i))n.iterator=i[Symbol.iterator]();else return{done:!1,value:i}}}while(n.iterator);return B})}flat(t){if(t===void 0&&(t=1),t<=0)return this;let n=t>1?this.flat(t-1):this;return new StreamImpl(()=>({this:n.startFn()}),t=>{do{if(t.iterator){let n=t.iterator.next();if(n.done)t.iterator=void 0;else return n}let{done:i,value:o}=n.nextFn(t.this);if(!i)if(isIterable(o))t.iterator=o[Symbol.iterator]();else return{done:!1,value:o}}while(t.iterator);return B})}head(){let t=this.iterator().next();if(!t.done)return t.value}tail(t=1){return new StreamImpl(()=>{let n=this.startFn();for(let i=0;i<t;i++)if(this.nextFn(n).done)return n;return n},this.nextFn)}limit(t){return new StreamImpl(()=>({size:0,state:this.startFn()}),n=>(n.size++,n.size>t?B:this.nextFn(n.state)))}distinct(t){return new StreamImpl(()=>({set:new Set,internalState:this.startFn()}),n=>{let i;do if(i=this.nextFn(n.internalState),!i.done){let o=t?t(i.value):i.value;if(!n.set.has(o))return n.set.add(o),i}while(!i.done);return B})}exclude(t,n){let i=new Set;for(let o of t){let t=n?n(o):o;i.add(t)}return this.filter(t=>{let o=n?n(t):t;return!i.has(o)})}};function toString$1(t){return typeof t==`string`?t:t===void 0?`undefined`:typeof t.toString==`function`?t.toString():Object.prototype.toString.call(t)}o(toString$1,`toString`);function isIterable(t){return!!t&&typeof t[Symbol.iterator]==`function`}const tt=new z(()=>void 0,()=>B),B=Object.freeze({done:!0,value:void 0});function stream(...t){if(t.length===1){let n=t[0];if(n instanceof z)return n;if(isIterable(n))return new z(()=>n[Symbol.iterator](),t=>t.next());if(typeof n.length==`number`)return new z(()=>({index:0}),t=>t.index<n.length?{done:!1,value:n[t.index++]}:B)}return t.length>1?new z(()=>({collIndex:0,arrIndex:0}),n=>{do{if(n.iterator){let t=n.iterator.next();if(!t.done)return t;n.iterator=void 0}if(n.array){if(n.arrIndex<n.array.length)return{done:!1,value:n.array[n.arrIndex++]};n.array=void 0,n.arrIndex=0}if(n.collIndex<t.length){let i=t[n.collIndex++];isIterable(i)?n.iterator=i[Symbol.iterator]():i&&typeof i.length==`number`&&(n.array=i)}}while(n.iterator||n.array||n.collIndex<t.length);return B}):tt}var TreeStreamImpl=class extends z{constructor(t,n,i){super(()=>({iterators:i?.includeRoot?[[t][Symbol.iterator]()]:[n(t)[Symbol.iterator]()],pruned:!1}),t=>{for(t.pruned&&=(t.iterators.pop(),!1);t.iterators.length>0;){let i=t.iterators[t.iterators.length-1].next();if(i.done)t.iterators.pop();else return t.iterators.push(n(i.value)[Symbol.iterator]()),i}return B})}iterator(){let t={state:this.startFn(),next:()=>this.nextFn(t.state),prune:()=>{t.state.pruned=!0},[Symbol.iterator]:()=>t};return t}},nt;(function(t){function sum(t){return t.reduce((t,n)=>t+n,0)}t.sum=sum;function product(t){return t.reduce((t,n)=>t*n,0)}t.product=product;function min(t){return t.reduce((t,n)=>Math.min(t,n))}t.min=min;function max(t){return t.reduce((t,n)=>Math.max(t,n))}t.max=max})(nt||={});function streamCst(t){return new TreeStreamImpl(t,t=>isCompositeCstNode(t)?t.content:[],{includeRoot:!0})}function flattenCst(t){return streamCst(t).filter(isLeafCstNode)}function isChildNode(t,n){for(;t.container;)if(t=t.container,t===n)return!0;return!1}function tokenToRange(t){return{start:{character:t.startColumn-1,line:t.startLine-1},end:{character:t.endColumn,line:t.endLine-1}}}function toDocumentSegment(t){if(!t)return;let{offset:n,end:i,range:o}=t;return{range:o,offset:n,end:i,length:i-n}}var V;(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`})(V||={});function compareRange(t,n){if(t.end.line<n.start.line||t.end.line===n.start.line&&t.end.character<=n.start.character)return V.Before;if(t.start.line>n.end.line||t.start.line===n.end.line&&t.start.character>=n.end.character)return V.After;let i=t.start.line>n.start.line||t.start.line===n.start.line&&t.start.character>=n.start.character,o=t.end.line<n.end.line||t.end.line===n.end.line&&t.end.character<=n.end.character;return i&&o?V.Inside:i?V.OverlapBack:o?V.OverlapFront:V.Outside}function inRange(t,n){return compareRange(t,n)>V.After}const rt=/^[\w\p{L}]$/u;function findDeclarationNodeAtOffset(t,n,i=rt){if(t){if(n>0){let o=n-t.offset,s=t.text.charAt(o);i.test(s)||n--}return findLeafNodeAtOffset(t,n)}}function findCommentNode(t,n){if(t){let i=getPreviousNode(t,!0);if(i&&isCommentNode(i,n))return i;if(isRootCstNode(t)){let i=t.content.findIndex(t=>!t.hidden);for(let o=i-1;o>=0;o--){let i=t.content[o];if(isCommentNode(i,n))return i}}}}function isCommentNode(t,n){return isLeafCstNode(t)&&n.includes(t.tokenType.name)}function findLeafNodeAtOffset(t,n){if(isLeafCstNode(t))return t;if(isCompositeCstNode(t)){let i=binarySearch(t,n,!1);if(i)return findLeafNodeAtOffset(i,n)}}function findLeafNodeBeforeOffset(t,n){if(isLeafCstNode(t))return t;if(isCompositeCstNode(t)){let i=binarySearch(t,n,!0);if(i)return findLeafNodeBeforeOffset(i,n)}}function binarySearch(t,n,i){let o=0,s=t.content.length-1,c;for(;o<=s;){let u=Math.floor((o+s)/2),f=t.content[u];if(f.offset<=n&&f.end>n)return f;f.end<=n?(c=i?f:void 0,o=u+1):s=u-1}return c}function getPreviousNode(t,n=!0){for(;t.container;){let i=t.container,o=i.content.indexOf(t);for(;o>0;){o--;let t=i.content[o];if(n||!t.hidden)return t}t=i}}function getNextNode(t,n=!0){for(;t.container;){let i=t.container,o=i.content.indexOf(t),s=i.content.length-1;for(;o<s;){o++;let t=i.content[o];if(n||!t.hidden)return t}t=i}}function getInteriorNodes(t,n){let i=getCommonParent(t,n);return i?i.parent.content.slice(i.a+1,i.b):[]}function getCommonParent(t,n){let i=getParentChain(t),o=getParentChain(n),s;for(let t=0;t<i.length&&t<o.length;t++){let n=i[t],c=o[t];if(n.parent===c.parent)s={parent:n.parent,a:n.index,b:c.index};else break}return s}function getParentChain(t){let n=[];for(;t.container;){let i=t.container,o=i.content.indexOf(t);n.push({parent:i,index:o}),t=i}return n.reverse()}var it=i({assignMandatoryProperties:()=>assignMandatoryProperties,copyAstNode:()=>copyAstNode,findLocalReferences:()=>findLocalReferences,findRootNode:()=>findRootNode,getContainerOfType:()=>getContainerOfType,getDocument:()=>getDocument,hasContainerOfType:()=>hasContainerOfType,linkContentToContainer:()=>linkContentToContainer,streamAllContents:()=>streamAllContents,streamAst:()=>streamAst,streamContents:()=>streamContents,streamReferences:()=>streamReferences});function linkContentToContainer(t){for(let[n,i]of Object.entries(t))n.startsWith(`$`)||(Array.isArray(i)?i.forEach((i,o)=>{isAstNode(i)&&(i.$container=t,i.$containerProperty=n,i.$containerIndex=o)}):isAstNode(i)&&(i.$container=t,i.$containerProperty=n))}function getContainerOfType(t,n){let i=t;for(;i;){if(n(i))return i;i=i.$container}}function hasContainerOfType(t,n){let i=t;for(;i;){if(n(i))return!0;i=i.$container}return!1}function getDocument(t){let n=findRootNode(t).$document;if(!n)throw Error(`AST node has no document.`);return n}function findRootNode(t){for(;t.$container;)t=t.$container;return t}function streamContents(t,n){if(!t)throw Error(`Node must be an AstNode.`);let i=n?.range;return new z(()=>({keys:Object.keys(t),keyIndex:0,arrayIndex:0}),n=>{for(;n.keyIndex<n.keys.length;){let o=n.keys[n.keyIndex];if(!o.startsWith(`$`)){let s=t[o];if(isAstNode(s)){if(n.keyIndex++,isAstNodeInRange(s,i))return{done:!1,value:s}}else if(Array.isArray(s)){for(;n.arrayIndex<s.length;){let t=s[n.arrayIndex++];if(isAstNode(t)&&isAstNodeInRange(t,i))return{done:!1,value:t}}n.arrayIndex=0}}n.keyIndex++}return B})}function streamAllContents(t,n){if(!t)throw Error(`Root node must be an AstNode.`);return new TreeStreamImpl(t,t=>streamContents(t,n))}function streamAst(t,n){if(!t)throw Error(`Root node must be an AstNode.`);return n?.range&&!isAstNodeInRange(t,n.range)?new TreeStreamImpl(t,()=>[]):new TreeStreamImpl(t,t=>streamContents(t,n),{includeRoot:!0})}function isAstNodeInRange(t,n){if(!n)return!0;let i=t.$cstNode?.range;return i?inRange(i,n):!1}function streamReferences(t){return new z(()=>({keys:Object.keys(t),keyIndex:0,arrayIndex:0}),n=>{for(;n.keyIndex<n.keys.length;){let i=n.keys[n.keyIndex];if(!i.startsWith(`$`)){let o=t[i];if(isReference(o))return n.keyIndex++,{done:!1,value:{reference:o,container:t,property:i}};if(Array.isArray(o)){for(;n.arrayIndex<o.length;){let s=n.arrayIndex++,c=o[s];if(isReference(c))return{done:!1,value:{reference:c,container:t,property:i,index:s}}}n.arrayIndex=0}}n.keyIndex++}return B})}function findLocalReferences(t,n=getDocument(t).parseResult.value){let i=[];return streamAst(n).forEach(n=>{streamReferences(n).forEach(n=>{n.reference.ref===t&&i.push(n.reference)})}),stream(i)}function assignMandatoryProperties(t,n){let i=t.getTypeMetaData(n.$type),o=n;for(let t of i.properties)t.defaultValue!==void 0&&o[t.name]===void 0&&(o[t.name]=copyDefaultValue(t.defaultValue))}function copyDefaultValue(t){return Array.isArray(t)?[...t.map(copyDefaultValue)]:t}function copyAstNode(t,n){let i={$type:t.$type};for(let[o,s]of Object.entries(t))if(!o.startsWith(`$`))if(isAstNode(s))i[o]=copyAstNode(s,n);else if(isReference(s))i[o]=n(i,o,s.$refNode,s.$refText);else if(Array.isArray(s)){let t=[];for(let c of s)isAstNode(c)?t.push(copyAstNode(c,n)):isReference(c)?t.push(n(i,o,c.$refNode,c.$refText)):t.push(c);i[o]=t}else i[o]=s;return linkContentToContainer(i),i}var ErrorWithLocation=class extends Error{constructor(t,n){super(t?`${n} at ${t.range.start.line}:${t.range.start.character}`:n)}};function assertUnreachable(t){throw Error(`Error! The input value was not handled.`)}const at=/\r?\n/gm,ot=new c;var TerminalRegExpVisitor=class extends u{constructor(){super(...arguments),this.isStarting=!0,this.endRegexpStack=[],this.multiline=!1}get endRegex(){return this.endRegexpStack.join(``)}reset(t){this.multiline=!1,this.regex=t,this.startRegexp=``,this.isStarting=!0,this.endRegexpStack=[]}visitGroup(t){t.quantifier&&(this.isStarting=!1,this.endRegexpStack=[])}visitCharacter(t){let n=String.fromCharCode(t.value);if(!this.multiline&&n===`
2
- `&&(this.multiline=!0),t.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{let t=escapeRegExp(n);this.endRegexpStack.push(t),this.isStarting&&(this.startRegexp+=t)}}visitSet(t){if(!this.multiline){let n=this.regex.substring(t.loc.begin,t.loc.end),i=new RegExp(n);this.multiline=!!`
3
- `.match(i)}if(t.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{let n=this.regex.substring(t.loc.begin,t.loc.end);this.endRegexpStack.push(n),this.isStarting&&(this.startRegexp+=n)}}visitChildren(t){t.type===`Group`&&t.quantifier||super.visitChildren(t)}};const st=new TerminalRegExpVisitor;function isMultilineComment(t){try{return typeof t==`string`&&(t=new RegExp(t)),t=t.toString(),st.reset(t),st.visit(ot.pattern(t)),st.multiline}catch{return!1}}const ct=`\f
4
- \r \v \xA0            \u2028\u2029   `.split(``);function isWhitespace(t){let n=typeof t==`string`?new RegExp(t):t;return ct.some(t=>n.test(t))}function escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function partialMatches(t,n){let i=partialRegExp(t),o=n.match(i);return!!o&&o[0].length>0}function partialRegExp(t){typeof t==`string`&&(t=new RegExp(t));let n=t,i=t.source,o=0;function process(){let t=``,s;function appendRaw(n){t+=i.substr(o,n),o+=n}function appendOptional(n){t+=`(?:`+i.substr(o,n)+`|$)`,o+=n}for(;o<i.length;)switch(i[o]){case`\\`:switch(i[o+1]){case`c`:appendOptional(3);break;case`x`:appendOptional(4);break;case`u`:n.unicode?i[o+2]===`{`?appendOptional(i.indexOf(`}`,o)-o+1):appendOptional(6):appendOptional(2);break;case`p`:case`P`:n.unicode?appendOptional(i.indexOf(`}`,o)-o+1):appendOptional(2);break;case`k`:appendOptional(i.indexOf(`>`,o)-o+1);break;default:appendOptional(2);break}break;case`[`:s=/\[(?:\\.|.)*?\]/g,s.lastIndex=o,s=s.exec(i)||[],appendOptional(s[0].length);break;case`|`:case`^`:case`$`:case`*`:case`+`:case`?`:appendRaw(1);break;case`{`:s=/\{\d+,?\d*\}/g,s.lastIndex=o,s=s.exec(i),s?appendRaw(s[0].length):appendOptional(1);break;case`(`:if(i[o+1]===`?`)switch(i[o+2]){case`:`:t+=`(?:`,o+=3,t+=process()+`|$)`;break;case`=`:t+=`(?=`,o+=3,t+=process()+`)`;break;case`!`:s=o,o+=3,process(),t+=i.substr(s,o-s);break;case`<`:switch(i[o+3]){case`=`:case`!`:s=o,o+=4,process(),t+=i.substr(s,o-s);break;default:appendRaw(i.indexOf(`>`,o)-o+1),t+=process()+`|$)`;break}break}else appendRaw(1),t+=process()+`|$)`;break;case`)`:return++o,t;default:appendOptional(1);break}return t}return new RegExp(process(),t.flags)}var lt=i({findAssignment:()=>findAssignment,findNameAssignment:()=>findNameAssignment,findNodeForKeyword:()=>findNodeForKeyword,findNodeForProperty:()=>findNodeForProperty,findNodesForKeyword:()=>findNodesForKeyword,findNodesForKeywordInternal:()=>findNodesForKeywordInternal,findNodesForProperty:()=>findNodesForProperty,getActionAtElement:()=>getActionAtElement,getActionType:()=>getActionType,getAllReachableRules:()=>getAllReachableRules,getAllRulesUsedForCrossReferences:()=>getAllRulesUsedForCrossReferences,getCrossReferenceTerminal:()=>getCrossReferenceTerminal,getEntryRule:()=>getEntryRule,getExplicitRuleType:()=>getExplicitRuleType,getHiddenRules:()=>getHiddenRules,getRuleType:()=>getRuleType,getRuleTypeName:()=>getRuleTypeName,getTypeName:()=>getTypeName,isArrayCardinality:()=>isArrayCardinality,isArrayOperator:()=>isArrayOperator,isCommentTerminal:()=>isCommentTerminal,isDataType:()=>isDataType,isDataTypeRule:()=>isDataTypeRule,isOptionalCardinality:()=>isOptionalCardinality,terminalRegex:()=>terminalRegex});function getEntryRule(t){return t.rules.find(t=>isParserRule(t)&&t.entry)}function getHiddenRules(t){return t.rules.filter(t=>isTerminalRule(t)&&t.hidden)}function getAllReachableRules(t,n){let i=new Set,o=getEntryRule(t);if(!o)return new Set(t.rules);let s=[o].concat(getHiddenRules(t));for(let t of s)ruleDfs(t,i,n);let c=new Set;for(let n of t.rules)(i.has(n.name)||isTerminalRule(n)&&n.hidden)&&c.add(n);return c}function ruleDfs(t,n,i){n.add(t.name),streamAllContents(t).forEach(t=>{if(isRuleCall(t)||i&&isTerminalRuleCall(t)){let o=t.rule.ref;o&&!n.has(o.name)&&ruleDfs(o,n,i)}})}function getAllRulesUsedForCrossReferences(t){let n=new Set;return streamAllContents(t).forEach(t=>{isCrossReference(t)&&(isParserRule(t.type.ref)&&n.add(t.type.ref),isInferredType(t.type.ref)&&isParserRule(t.type.ref.$container)&&n.add(t.type.ref.$container))}),n}function getCrossReferenceTerminal(t){if(t.terminal)return t.terminal;if(t.type.ref)return findNameAssignment(t.type.ref)?.terminal}function isCommentTerminal(t){return t.hidden&&!isWhitespace(terminalRegex(t))}function findNodesForProperty(t,n){return!t||!n?[]:findNodesForPropertyInternal(t,n,t.astNode,!0)}function findNodeForProperty(t,n,i){if(!t||!n)return;let o=findNodesForPropertyInternal(t,n,t.astNode,!0);if(o.length!==0)return i=i===void 0?0:Math.max(0,Math.min(i,o.length-1)),o[i]}function findNodesForPropertyInternal(t,n,i,o){if(!o){let i=getContainerOfType(t.grammarSource,isAssignment);if(i&&i.feature===n)return[t]}return isCompositeCstNode(t)&&t.astNode===i?t.content.flatMap(t=>findNodesForPropertyInternal(t,n,i,!1)):[]}function findNodesForKeyword(t,n){return t?findNodesForKeywordInternal(t,n,t?.astNode):[]}function findNodeForKeyword(t,n,i){if(!t)return;let o=findNodesForKeywordInternal(t,n,t?.astNode);if(o.length!==0)return i=i===void 0?0:Math.max(0,Math.min(i,o.length-1)),o[i]}function findNodesForKeywordInternal(t,n,i){if(t.astNode!==i)return[];if(isKeyword(t.grammarSource)&&t.grammarSource.value===n)return[t];let o=streamCst(t).iterator(),s,c=[];do if(s=o.next(),!s.done){let t=s.value;t.astNode===i?isKeyword(t.grammarSource)&&t.grammarSource.value===n&&c.push(t):o.prune()}while(!s.done);return c}function findAssignment(t){let n=t.astNode;for(;n===t.container?.astNode;){let n=getContainerOfType(t.grammarSource,isAssignment);if(n)return n;t=t.container}}function findNameAssignment(t){let n=t;return isInferredType(n)&&(isAction(n.$container)?n=n.$container.$container:isParserRule(n.$container)?n=n.$container:assertUnreachable(n.$container)),findNameAssignmentInternal(t,n,new Map)}function findNameAssignmentInternal(t,n,i){function go(n,o){let s;return getContainerOfType(n,isAssignment)||(s=findNameAssignmentInternal(o,o,i)),i.set(t,s),s}if(i.has(t))return i.get(t);i.set(t,void 0);for(let o of streamAllContents(n))if(isAssignment(o)&&o.feature.toLowerCase()===`name`)return i.set(t,o),o;else if(isRuleCall(o)&&isParserRule(o.rule.ref))return go(o,o.rule.ref);else if(isSimpleType(o)&&o.typeRef?.ref)return go(o,o.typeRef.ref)}function getActionAtElement(t){let n=t.$container;if(isGroup(n)){let i=n.elements,o=i.indexOf(t);for(let t=o-1;t>=0;t--){let n=i[t];if(isAction(n))return n;{let n=streamAllContents(i[t]).find(isAction);if(n)return n}}}if(isAbstractElement(n))return getActionAtElement(n)}function isOptionalCardinality(t,n){return t===`?`||t===`*`||isGroup(n)&&!!n.guardCondition}function isArrayCardinality(t){return t===`*`||t===`+`}function isArrayOperator(t){return t===`+=`}function isDataTypeRule(t){return isDataTypeRuleInternal(t,new Set)}function isDataTypeRuleInternal(t,n){if(n.has(t))return!0;n.add(t);for(let i of streamAllContents(t))if(isRuleCall(i)){if(!i.rule.ref||isParserRule(i.rule.ref)&&!isDataTypeRuleInternal(i.rule.ref,n))return!1}else if(isAssignment(i))return!1;else if(isAction(i))return!1;return!!t.definition}function isDataType(t){return isDataTypeInternal(t.type,new Set)}function isDataTypeInternal(t,n){if(n.has(t))return!0;if(n.add(t),isArrayType(t)||isReferenceType(t))return!1;if(isUnionType(t))return t.types.every(t=>isDataTypeInternal(t,n));if(isSimpleType(t)){if(t.primitiveType!==void 0||t.stringType!==void 0)return!0;if(t.typeRef!==void 0){let i=t.typeRef.ref;return isType(i)?isDataTypeInternal(i.type,n):!1}else return!1}else return!1}function getExplicitRuleType(t){if(t.inferredType)return t.inferredType.name;if(t.dataType)return t.dataType;if(t.returnType){let n=t.returnType.ref;if(n&&(isParserRule(n)||isInterface(n)||isType(n)))return n.name}}function getTypeName(t){if(isParserRule(t))return isDataTypeRule(t)?t.name:getExplicitRuleType(t)??t.name;if(isInterface(t)||isType(t)||isReturnType(t))return t.name;if(isAction(t)){let n=getActionType(t);if(n)return n}else if(isInferredType(t))return t.name;throw Error(`Cannot get name of Unknown Type`)}function getActionType(t){if(t.inferredType)return t.inferredType.name;if(t.type?.ref)return getTypeName(t.type.ref)}function getRuleTypeName(t){return isTerminalRule(t)?t.type?.name??`string`:isDataTypeRule(t)?t.name:getExplicitRuleType(t)??t.name}function getRuleType(t){return isTerminalRule(t)?t.type?.name??`string`:getExplicitRuleType(t)??t.name}function terminalRegex(t){let n={s:!1,i:!1,u:!1},i=abstractElementToRegex(t.definition,n),o=Object.entries(n).filter(([,t])=>t).map(([t])=>t).join(``);return new RegExp(i,o)}const ut=`[\\s\\S]`;function abstractElementToRegex(t,n){if(isTerminalAlternatives(t))return terminalAlternativesToRegex(t);if(isTerminalGroup(t))return terminalGroupToRegex(t);if(isCharacterRange(t))return characterRangeToRegex(t);if(isTerminalRuleCall(t)){let n=t.rule.ref;if(!n)throw Error(`Missing rule reference.`);return withCardinality(abstractElementToRegex(n.definition),{cardinality:t.cardinality,lookahead:t.lookahead})}else if(isNegatedToken(t))return negateTokenToRegex(t);else if(isUntilToken(t))return untilTokenToRegex(t);else if(isRegexToken(t)){let i=t.regex.lastIndexOf(`/`),o=t.regex.substring(1,i),s=t.regex.substring(i+1);return n&&(n.i=s.includes(`i`),n.s=s.includes(`s`),n.u=s.includes(`u`)),withCardinality(o,{cardinality:t.cardinality,lookahead:t.lookahead,wrap:!1})}else if(isWildcard(t))return withCardinality(ut,{cardinality:t.cardinality,lookahead:t.lookahead});else throw Error(`Invalid terminal element: ${t?.$type}`)}function terminalAlternativesToRegex(t){return withCardinality(t.elements.map(t=>abstractElementToRegex(t)).join(`|`),{cardinality:t.cardinality,lookahead:t.lookahead})}function terminalGroupToRegex(t){return withCardinality(t.elements.map(t=>abstractElementToRegex(t)).join(``),{cardinality:t.cardinality,lookahead:t.lookahead})}function untilTokenToRegex(t){return withCardinality(`${ut}*?${abstractElementToRegex(t.terminal)}`,{cardinality:t.cardinality,lookahead:t.lookahead})}function negateTokenToRegex(t){return withCardinality(`(?!${abstractElementToRegex(t.terminal)})${ut}*?`,{cardinality:t.cardinality,lookahead:t.lookahead})}function characterRangeToRegex(t){return t.right?withCardinality(`[${keywordToRegex(t.left)}-${keywordToRegex(t.right)}]`,{cardinality:t.cardinality,lookahead:t.lookahead,wrap:!1}):withCardinality(keywordToRegex(t.left),{cardinality:t.cardinality,lookahead:t.lookahead,wrap:!1})}function keywordToRegex(t){return escapeRegExp(t.value)}function withCardinality(t,n){return(n.wrap!==!1||n.lookahead)&&(t=`(${n.lookahead??``}${t})`),n.cardinality?`${t}${n.cardinality}`:t}function findNextFeatures(t,n){let i={stacks:t,tokens:n};return interpretTokens(i),i.stacks.flat().forEach(t=>{t.property=void 0}),findNextFeatureStacks(i.stacks).map(t=>t[t.length-1])}function findNextFeaturesInternal(t){let{next:n,cardinalities:i,visited:o,plus:s}=t,c=[],u=n.feature;if(o.has(u))return[];isGroup(u)||o.add(u);let f,p=u;for(;p.$container;)if(isGroup(p.$container)){f=p.$container;break}else if(isAbstractElement(p.$container))p=p.$container;else break;if(isArrayCardinality(p.cardinality)){let t=findFirstFeaturesInternal({next:{feature:p,type:n.type},cardinalities:i,visited:o,plus:s});for(let n of t)s.add(n.feature);c.push(...t)}if(f){let t=f.elements.indexOf(p);t!==void 0&&t<f.elements.length-1&&c.push(...findNextFeaturesInGroup({feature:f,type:n.type},t+1,i,o,s)),c.every(t=>isOptionalCardinality(t.feature.cardinality,t.feature)||isOptionalCardinality(i.get(t.feature))||s.has(t.feature))&&c.push(...findNextFeaturesInternal({next:{feature:f,type:n.type},cardinalities:i,visited:o,plus:s}))}return c}function findFirstFeatures(t){return isAstNode(t)&&(t={feature:t}),findFirstFeaturesInternal({next:t,cardinalities:new Map,visited:new Set,plus:new Set})}function findFirstFeaturesInternal(t){let{next:n,cardinalities:i,visited:o,plus:s}=t;if(n===void 0)return[];let{feature:c,type:u}=n;if(isGroup(c))return o.has(c)?[]:(o.add(c),findNextFeaturesInGroup(n,0,i,o,s).map(t=>modifyCardinality(t,c.cardinality,i)));if(isAlternatives(c)||isUnorderedGroup(c))return c.elements.flatMap(t=>findFirstFeaturesInternal({next:{feature:t,type:u,property:n.property},cardinalities:i,visited:o,plus:s})).map(t=>modifyCardinality(t,c.cardinality,i));if(isAssignment(c))return findFirstFeaturesInternal({next:{feature:c.terminal,type:u,property:n.property??c.feature},cardinalities:i,visited:o,plus:s}).map(t=>modifyCardinality(t,c.cardinality,i));if(isAction(c))return findNextFeaturesInternal({next:{feature:c,type:getTypeName(c),property:n.property??c.feature},cardinalities:i,visited:o,plus:s});if(isRuleCall(c)&&isParserRule(c.rule.ref)){let t=c.rule.ref;return findFirstFeaturesInternal({next:{feature:t.definition,type:t.fragment||t.dataType?void 0:getExplicitRuleType(t)??t.name,property:n.property},cardinalities:i,visited:o,plus:s}).map(t=>modifyCardinality(t,c.cardinality,i))}else return[n]}function modifyCardinality(t,n,i){return i.set(t.feature,n),t}function findNextFeaturesInGroup(t,n,i,o,s){let c=[],u;for(;n<t.feature.elements.length&&(u={feature:t.feature.elements[n++],type:t.type},c.push(...findFirstFeaturesInternal({next:u,cardinalities:i,visited:o,plus:s})),isOptionalCardinality(u.feature.cardinality??i.get(u.feature),u.feature)););return c}function interpretTokens(t){for(let n of t.tokens)t.stacks=findNextFeatureStacks(t.stacks,n)}function findNextFeatureStacks(t,n){let i=[];for(let o of t)i.push(...interpretStackToken(o,n));return i}function interpretStackToken(t,n){let i=new Map,o=new Set(t.map(t=>t.feature).filter(isPlusFeature)),s=[];for(;t.length>0;){let c=findNextFeaturesInternal({next:t.pop(),cardinalities:i,plus:o,visited:new Set}).filter(t=>!n||featureMatches(t.feature,n));for(let n of c)s.push([...t,n]);if(!c.every(t=>isOptionalCardinality(t.feature.cardinality,t.feature)||isOptionalCardinality(i.get(t.feature))))break}return s}function isPlusFeature(t){if(t.cardinality===`+`)return!0;let n=getContainerOfType(t,isAssignment);return!!(n&&n.cardinality===`+`)}function featureMatches(t,n){if(isKeyword(t))return t.value===n.image;if(isRuleCall(t))return ruleMatches(t.rule.ref,n);if(isCrossReference(t)){let i=getCrossReferenceTerminal(t);if(i)return featureMatches(i,n)}return!1}function ruleMatches(t,n){return isParserRule(t)?findFirstFeatures(t.definition).some(t=>featureMatches(t.feature,n)):isTerminalRule(t)?terminalRegex(t).test(n.image):!1}function mergeCompletionProviderOptions(t){let n=Array.from(new Set(t.flatMap(t=>t?.triggerCharacters??[]))),i=Array.from(new Set(t.flatMap(t=>t?.allCommitCharacters??[])));return{triggerCharacters:n.length>0?n:void 0,allCommitCharacters:i.length>0?i:void 0}}var DefaultCompletionProvider=class{constructor(t){this.scopeProvider=t.references.ScopeProvider,this.grammar=t.Grammar,this.completionParser=t.parser.CompletionParser,this.nameProvider=t.references.NameProvider,this.lexer=t.parser.Lexer,this.nodeKindProvider=t.shared.lsp.NodeKindProvider,this.fuzzyMatcher=t.shared.lsp.FuzzyMatcher,this.grammarConfig=t.parser.GrammarConfig,this.astReflection=t.shared.AstReflection,this.documentationProvider=t.documentation.DocumentationProvider}async getCompletion(t,n,i){let o=[],s=this.buildContexts(t,n.position),acceptor=(t,n)=>{let i=this.fillCompletionItem(t,n);i&&o.push(i)},distinctionFunction=t=>isKeyword(t.feature)?t.feature.value:t.feature,c=[];for(let t of s)if(await Promise.all(stream(t.features).distinct(distinctionFunction).exclude(c).map(n=>this.completionFor(t,n,acceptor))),c.push(...t.features),!this.continueCompletion(o))break;return te.create(this.deduplicateItems(o),!0)}deduplicateItems(t){return stream(t).distinct(t=>`${t.kind}_${t.label}_${t.detail}`).toArray()}findFeaturesAt(t,n){let i=t.getText({start:le.create(0,0),end:t.positionAt(n)}),o=this.completionParser.parse(i),s=o.tokens;if(o.tokenIndex===0){let t=getEntryRule(this.grammar),n=findFirstFeatures({feature:t.definition,type:getExplicitRuleType(t)});return s.length>0?(s.shift(),findNextFeatures(n.map(t=>[t]),s)):n}let c=[...s].splice(o.tokenIndex);return findNextFeatures([o.elementStack.map(t=>({feature:t}))],c)}*buildContexts(t,n){let i=t.parseResult.value.$cstNode;if(!i)return;let o=t.textDocument,s=o.getText(),c=o.offsetAt(n),u={document:t,textDocument:o,offset:c,position:n},f=this.findDataTypeRuleStart(i,c);if(f){let[t,n]=f,s=findLeafNodeBeforeOffset(i,t)?.astNode;yield Object.assign(Object.assign({},u),{node:s,tokenOffset:t,tokenEndOffset:n,features:this.findFeaturesAt(o,t)})}let{nextTokenStart:p,nextTokenEnd:h,previousTokenStart:g,previousTokenEnd:_}=this.backtrackToAnyToken(s,c),x=p;c<=p&&g!==void 0&&(x=g);let S=findLeafNodeBeforeOffset(i,x)?.astNode,T=!0;if(g!==void 0&&_!==void 0&&_===c&&(yield Object.assign(Object.assign({},u),{node:S,tokenOffset:g,tokenEndOffset:_,features:this.findFeaturesAt(o,g)}),T=this.performNextTokenCompletion(t,s.substring(g,_),g,_),T&&(yield Object.assign(Object.assign({},u),{node:S,tokenOffset:_,tokenEndOffset:_,features:this.findFeaturesAt(o,_)}))),S)T&&(yield Object.assign(Object.assign({},u),{node:S,tokenOffset:p,tokenEndOffset:h,features:this.findFeaturesAt(o,p)}));else{let t=getEntryRule(this.grammar);if(!t)throw Error(`Missing entry parser rule`);yield Object.assign(Object.assign({},u),{tokenOffset:p,tokenEndOffset:h,features:findFirstFeatures(t.definition)})}}performNextTokenCompletion(t,n,i,o){return/\P{L}$/u.test(n)}findDataTypeRuleStart(t,n){let i=findDeclarationNodeAtOffset(t,n,this.grammarConfig.nameRegexp),o=!!getContainerOfType(i?.grammarSource,isParserRule)?.dataType;if(o){for(;o;)i=i?.container,o=!!getContainerOfType(i?.grammarSource,isParserRule)?.dataType;if(i)return[i.offset,i.end]}}continueCompletion(t){return t.length===0}backtrackToAnyToken(t,n){let i=this.lexer.tokenize(t).tokens;if(i.length===0)return{nextTokenStart:n,nextTokenEnd:n};let o;for(let t of i){if(t.startOffset>=n)return{nextTokenStart:n,nextTokenEnd:n,previousTokenStart:o?o.startOffset:void 0,previousTokenEnd:o?o.endOffset+1:void 0};if(t.endOffset>=n)return{nextTokenStart:t.startOffset,nextTokenEnd:t.endOffset+1,previousTokenStart:o?o.startOffset:void 0,previousTokenEnd:o?o.endOffset+1:void 0};o=t}return{nextTokenStart:n,nextTokenEnd:n,previousTokenStart:o?o.startOffset:void 0,previousTokenEnd:o?o.endOffset+1:void 0}}completionFor(t,n,i){if(isKeyword(n.feature))return this.completionForKeyword(t,n.feature,i);if(isCrossReference(n.feature)&&t.node)return this.completionForCrossReference(t,n,i)}completionForCrossReference(t,n,i){let o=getContainerOfType(n.feature,isAssignment),s=t.node;if(o&&s){n.type&&(s={$type:n.type,$container:s,$containerProperty:n.property},assignMandatoryProperties(this.astReflection,s));let c={reference:{$refText:``},container:s,property:o.feature};try{for(let n of this.getReferenceCandidates(c,t))i(t,this.createReferenceCompletionItem(n))}catch(t){console.error(t)}}}getReferenceCandidates(t,n){return this.scopeProvider.getScope(t).getAllElements()}createReferenceCompletionItem(t){return{nodeDescription:t,kind:this.nodeKindProvider.getCompletionItemKind(t),documentation:this.getReferenceDocumentation(t),detail:t.type,sortText:`0`}}getReferenceDocumentation(t){if(!t.node)return;let n=this.documentationProvider.getDocumentation(t.node);if(n)return{kind:`markdown`,value:n}}completionForKeyword(t,n,i){this.filterKeyword(t,n)&&i(t,{label:n.value,kind:this.getKeywordCompletionItemKind(n),detail:`Keyword`,sortText:`1`})}getKeywordCompletionItemKind(t){return ee.Keyword}filterKeyword(t,n){return/\p{L}/u.test(n.value)}fillCompletionItem(t,n){let i;if(typeof n.label==`string`)i=n.label;else if(`node`in n){let t=this.nameProvider.getName(n.node);if(!t)return;i=t}else if(`nodeDescription`in n)i=n.nodeDescription.name;else return;let o;o=typeof n.textEdit?.newText==`string`?n.textEdit.newText:typeof n.insertText==`string`?n.insertText:i;let s=n.textEdit??this.buildCompletionTextEdit(t,i,o);if(s)return{additionalTextEdits:n.additionalTextEdits,command:n.command,commitCharacters:n.commitCharacters,data:n.data,detail:n.detail,documentation:n.documentation,filterText:n.filterText,insertText:n.insertText,insertTextFormat:n.insertTextFormat,insertTextMode:n.insertTextMode,kind:n.kind,labelDetails:n.labelDetails,preselect:n.preselect,sortText:n.sortText,tags:n.tags,textEditText:n.textEditText,textEdit:s,label:i}}buildCompletionTextEdit(t,n,i){let o=t.textDocument.getText().substring(t.tokenOffset,t.offset);if(this.fuzzyMatcher.match(o,n))return{newText:i,range:{start:t.textDocument.positionAt(t.tokenOffset),end:t.position}}}},dt;(()=>{var t={975:t=>{function e(t){if(typeof t!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(t))}function r(t,n){for(var i,o=``,s=0,c=-1,u=0,f=0;f<=t.length;++f){if(f<t.length)i=t.charCodeAt(f);else{if(i===47)break;i=47}if(i===47){if(c!==f-1&&u!==1)if(c!==f-1&&u===2){if(o.length<2||s!==2||o.charCodeAt(o.length-1)!==46||o.charCodeAt(o.length-2)!==46){if(o.length>2){var p=o.lastIndexOf(`/`);if(p!==o.length-1){p===-1?(o=``,s=0):s=(o=o.slice(0,p)).length-1-o.lastIndexOf(`/`),c=f,u=0;continue}}else if(o.length===2||o.length===1){o=``,s=0,c=f,u=0;continue}}n&&(o.length>0?o+=`/..`:o=`..`,s=2)}else o.length>0?o+=`/`+t.slice(c+1,f):o=t.slice(c+1,f),s=f-c-1;c=f,u=0}else i===46&&u!==-1?++u:u=-1}return o}var n={resolve:function(){for(var t,n=``,i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s;o>=0?s=arguments[o]:(t===void 0&&(t=process.cwd()),s=t),e(s),s.length!==0&&(n=s+`/`+n,i=s.charCodeAt(0)===47)}return n=r(n,!i),i?n.length>0?`/`+n:`/`:n.length>0?n:`.`},normalize:function(t){if(e(t),t.length===0)return`.`;var n=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return(t=r(t,!n)).length!==0||n||(t=`.`),t.length>0&&i&&(t+=`/`),n?`/`+t:t},isAbsolute:function(t){return e(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return`.`;for(var t,i=0;i<arguments.length;++i){var o=arguments[i];e(o),o.length>0&&(t===void 0?t=o:t+=`/`+o)}return t===void 0?`.`:n.normalize(t)},relative:function(t,i){if(e(t),e(i),t===i||(t=n.resolve(t))===(i=n.resolve(i)))return``;for(var o=1;o<t.length&&t.charCodeAt(o)===47;++o);for(var s=t.length,c=s-o,u=1;u<i.length&&i.charCodeAt(u)===47;++u);for(var f=i.length-u,p=c<f?c:f,h=-1,g=0;g<=p;++g){if(g===p){if(f>p){if(i.charCodeAt(u+g)===47)return i.slice(u+g+1);if(g===0)return i.slice(u+g)}else c>p&&(t.charCodeAt(o+g)===47?h=g:g===0&&(h=0));break}var _=t.charCodeAt(o+g);if(_!==i.charCodeAt(u+g))break;_===47&&(h=g)}var x=``;for(g=o+h+1;g<=s;++g)g!==s&&t.charCodeAt(g)!==47||(x.length===0?x+=`..`:x+=`/..`);return x.length>0?x+i.slice(u+h):(u+=h,i.charCodeAt(u)===47&&++u,i.slice(u))},_makeLong:function(t){return t},dirname:function(t){if(e(t),t.length===0)return`.`;for(var n=t.charCodeAt(0),i=n===47,o=-1,s=!0,c=t.length-1;c>=1;--c)if((n=t.charCodeAt(c))===47){if(!s){o=c;break}}else s=!1;return o===-1?i?`/`:`.`:i&&o===1?`//`:t.slice(0,o)},basename:function(t,n){if(n!==void 0&&typeof n!=`string`)throw TypeError(`"ext" argument must be a string`);e(t);var i,o=0,s=-1,c=!0;if(n!==void 0&&n.length>0&&n.length<=t.length){if(n.length===t.length&&n===t)return``;var u=n.length-1,f=-1;for(i=t.length-1;i>=0;--i){var p=t.charCodeAt(i);if(p===47){if(!c){o=i+1;break}}else f===-1&&(c=!1,f=i+1),u>=0&&(p===n.charCodeAt(u)?--u==-1&&(s=i):(u=-1,s=f))}return o===s?s=f:s===-1&&(s=t.length),t.slice(o,s)}for(i=t.length-1;i>=0;--i)if(t.charCodeAt(i)===47){if(!c){o=i+1;break}}else s===-1&&(c=!1,s=i+1);return s===-1?``:t.slice(o,s)},extname:function(t){e(t);for(var n=-1,i=0,o=-1,s=!0,c=0,u=t.length-1;u>=0;--u){var f=t.charCodeAt(u);if(f!==47)o===-1&&(s=!1,o=u+1),f===46?n===-1?n=u:c!==1&&(c=1):n!==-1&&(c=-1);else if(!s){i=u+1;break}}return n===-1||o===-1||c===0||c===1&&n===o-1&&n===i+1?``:t.slice(n,o)},format:function(t){if(typeof t!=`object`||!t)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof t);return function(t,n){var i=n.dir||n.root,o=n.base||(n.name||``)+(n.ext||``);return i?i===n.root?i+o:i+`/`+o:o}(0,t)},parse:function(t){e(t);var n={root:``,dir:``,base:``,ext:``,name:``};if(t.length===0)return n;var i,o=t.charCodeAt(0),s=o===47;s?(n.root=`/`,i=1):i=0;for(var c=-1,u=0,f=-1,p=!0,h=t.length-1,g=0;h>=i;--h)if((o=t.charCodeAt(h))!==47)f===-1&&(p=!1,f=h+1),o===46?c===-1?c=h:g!==1&&(g=1):c!==-1&&(g=-1);else if(!p){u=h+1;break}return c===-1||f===-1||g===0||g===1&&c===f-1&&c===u+1?f!==-1&&(n.base=n.name=u===0&&s?t.slice(1,f):t.slice(u,f)):(u===0&&s?(n.name=t.slice(1,c),n.base=t.slice(1,f)):(n.name=t.slice(u,c),n.base=t.slice(u,f)),n.ext=t.slice(c,f)),u>0?n.dir=t.slice(0,u-1):s&&(n.dir=`/`),n},sep:`/`,delimiter:`:`,win32:null,posix:null};n.posix=n,t.exports=n}},n={};function r(i){var o=n[i];if(o!==void 0)return o.exports;var s=n[i]={exports:{}};return t[i](s,s.exports,r),s.exports}r.d=(t,n)=>{for(var i in n)r.o(n,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},r.o=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r.r=t=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};let o;r.r(i),r.d(i,{URI:()=>l,Utils:()=>S}),typeof process==`object`?o=process.platform===`win32`:typeof navigator==`object`&&(o=navigator.userAgent.indexOf(`Windows`)>=0);let s=/^\w[\w\d+.-]*$/,c=/^\//,u=/^\/\//;function a(t,n){if(!t.scheme&&n)throw Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${t.authority}", path: "${t.path}", query: "${t.query}", fragment: "${t.fragment}"}`);if(t.scheme&&!s.test(t.scheme))throw Error(`[UriError]: Scheme contains illegal characters.`);if(t.path){if(t.authority){if(!c.test(t.path))throw Error(`[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character`)}else if(u.test(t.path))throw Error(`[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")`)}}let f=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class l{static isUri(t){return t instanceof l||!!t&&typeof t.authority==`string`&&typeof t.fragment==`string`&&typeof t.path==`string`&&typeof t.query==`string`&&typeof t.scheme==`string`&&typeof t.fsPath==`string`&&typeof t.with==`function`&&typeof t.toString==`function`}scheme;authority;path;query;fragment;constructor(t,n,i,o,s,c=!1){typeof t==`object`?(this.scheme=t.scheme||``,this.authority=t.authority||``,this.path=t.path||``,this.query=t.query||``,this.fragment=t.fragment||``):(this.scheme=function(t,n){return t||n?t:`file`}(t,c),this.authority=n||``,this.path=function(t,n){switch(t){case`https`:case`http`:case`file`:n?n[0]!==`/`&&(n=`/`+n):n=`/`}return n}(this.scheme,i||``),this.query=o||``,this.fragment=s||``,a(this,c))}get fsPath(){return v(this,!1)}with(t){if(!t)return this;let{scheme:n,authority:i,path:o,query:s,fragment:c}=t;return n===void 0?n=this.scheme:n===null&&(n=``),i===void 0?i=this.authority:i===null&&(i=``),o===void 0?o=this.path:o===null&&(o=``),s===void 0?s=this.query:s===null&&(s=``),c===void 0?c=this.fragment:c===null&&(c=``),n===this.scheme&&i===this.authority&&o===this.path&&s===this.query&&c===this.fragment?this:new d(n,i,o,s,c)}static parse(t,n=!1){let i=f.exec(t);return i?new d(i[2]||``,w(i[4]||``),w(i[5]||``),w(i[7]||``),w(i[9]||``),n):new d(``,``,``,``,``)}static file(t){let n=``;if(o&&(t=t.replace(/\\/g,`/`)),t[0]===`/`&&t[1]===`/`){let i=t.indexOf(`/`,2);i===-1?(n=t.substring(2),t=`/`):(n=t.substring(2,i),t=t.substring(i)||`/`)}return new d(`file`,n,t,``,``)}static from(t){let n=new d(t.scheme,t.authority,t.path,t.query,t.fragment);return a(n,!0),n}toString(t=!1){return b(this,t)}toJSON(){return this}static revive(t){if(t){if(t instanceof l)return t;{let n=new d(t);return n._formatted=t.external,n._fsPath=t._sep===p?t.fsPath:null,n}}return t}}let p=o?1:void 0;class d extends l{_formatted=null;_fsPath=null;get fsPath(){return this._fsPath||=v(this,!1),this._fsPath}toString(t=!1){return t?b(this,!0):(this._formatted||=b(this,!1),this._formatted)}toJSON(){let t={$mid:1};return this._fsPath&&(t.fsPath=this._fsPath,t._sep=p),this._formatted&&(t.external=this._formatted),this.path&&(t.path=this.path),this.scheme&&(t.scheme=this.scheme),this.authority&&(t.authority=this.authority),this.query&&(t.query=this.query),this.fragment&&(t.fragment=this.fragment),t}}let h={58:`%3A`,47:`%2F`,63:`%3F`,35:`%23`,91:`%5B`,93:`%5D`,64:`%40`,33:`%21`,36:`%24`,38:`%26`,39:`%27`,40:`%28`,41:`%29`,42:`%2A`,43:`%2B`,44:`%2C`,59:`%3B`,61:`%3D`,32:`%20`};function m(t,n,i){let o,s=-1;for(let c=0;c<t.length;c++){let u=t.charCodeAt(c);if(u>=97&&u<=122||u>=65&&u<=90||u>=48&&u<=57||u===45||u===46||u===95||u===126||n&&u===47||i&&u===91||i&&u===93||i&&u===58)s!==-1&&(o+=encodeURIComponent(t.substring(s,c)),s=-1),o!==void 0&&(o+=t.charAt(c));else{o===void 0&&(o=t.substr(0,c));let n=h[u];n===void 0?s===-1&&(s=c):(s!==-1&&(o+=encodeURIComponent(t.substring(s,c)),s=-1),o+=n)}}return s!==-1&&(o+=encodeURIComponent(t.substring(s))),o===void 0?t:o}function y(t){let n;for(let i=0;i<t.length;i++){let o=t.charCodeAt(i);o===35||o===63?(n===void 0&&(n=t.substr(0,i)),n+=h[o]):n!==void 0&&(n+=t[i])}return n===void 0?t:n}function v(t,n){let i;return i=t.authority&&t.path.length>1&&t.scheme===`file`?`//${t.authority}${t.path}`:t.path.charCodeAt(0)===47&&(t.path.charCodeAt(1)>=65&&t.path.charCodeAt(1)<=90||t.path.charCodeAt(1)>=97&&t.path.charCodeAt(1)<=122)&&t.path.charCodeAt(2)===58?n?t.path.substr(1):t.path[1].toLowerCase()+t.path.substr(2):t.path,o&&(i=i.replace(/\//g,`\\`)),i}function b(t,n){let i=n?y:m,o=``,{scheme:s,authority:c,path:u,query:f,fragment:p}=t;if(s&&(o+=s,o+=`:`),(c||s===`file`)&&(o+=`/`,o+=`/`),c){let t=c.indexOf(`@`);if(t!==-1){let n=c.substr(0,t);c=c.substr(t+1),t=n.lastIndexOf(`:`),t===-1?o+=i(n,!1,!1):(o+=i(n.substr(0,t),!1,!1),o+=`:`,o+=i(n.substr(t+1),!1,!0)),o+=`@`}c=c.toLowerCase(),t=c.lastIndexOf(`:`),t===-1?o+=i(c,!1,!0):(o+=i(c.substr(0,t),!1,!0),o+=c.substr(t))}if(u){if(u.length>=3&&u.charCodeAt(0)===47&&u.charCodeAt(2)===58){let t=u.charCodeAt(1);t>=65&&t<=90&&(u=`/${String.fromCharCode(t+32)}:${u.substr(3)}`)}else if(u.length>=2&&u.charCodeAt(1)===58){let t=u.charCodeAt(0);t>=65&&t<=90&&(u=`${String.fromCharCode(t+32)}:${u.substr(2)}`)}o+=i(u,!0,!1)}return f&&(o+=`?`,o+=i(f,!1,!1)),p&&(o+=`#`,o+=n?p:m(p,!1,!1)),o}function C(t){try{return decodeURIComponent(t)}catch{return t.length>3?t.substr(0,3)+C(t.substr(3)):t}}let g=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function w(t){return t.match(g)?t.replace(g,(t=>C(t))):t}var _=r(975);let x=_.posix||_;var S;(function(t){t.joinPath=function(t,...n){return t.with({path:x.join(t.path,...n)})},t.resolvePath=function(t,...n){let i=t.path,o=!1;i[0]!==`/`&&(i=`/`+i,o=!0);let s=x.resolve(i,...n);return o&&s[0]===`/`&&!t.authority&&(s=s.substring(1)),t.with({path:s})},t.dirname=function(t){if(t.path.length===0||t.path===`/`)return t;let n=x.dirname(t.path);return n.length===1&&n.charCodeAt(0)===46&&(n=``),t.with({path:n})},t.basename=function(t){return x.basename(t.path)},t.extname=function(t){return x.extname(t.path)}})(S||={}),dt=i})();const{URI:H,Utils:ft}=dt;var U;(function(t){t.basename=ft.basename,t.dirname=ft.dirname,t.extname=ft.extname,t.joinPath=ft.joinPath,t.resolvePath=ft.resolvePath;let n=typeof process==`object`&&(process==null?void 0:process.platform)===`win32`;function equals(t,n){return t?.toString()===n?.toString()}t.equals=equals;function relative(t,i){let o=typeof t==`string`?H.parse(t).path:t.path,s=typeof i==`string`?H.parse(i).path:i.path,c=o.split(`/`).filter(t=>t.length>0),u=s.split(`/`).filter(t=>t.length>0);if(n){let t=/^[A-Z]:$/;if(c[0]&&t.test(c[0])&&(c[0]=c[0].toLowerCase()),u[0]&&t.test(u[0])&&(u[0]=u[0].toLowerCase()),c[0]!==u[0])return s.substring(1)}let f=0;for(;f<c.length&&c[f]===u[f];f++);return`../`.repeat(c.length-f)+u.slice(f).join(`/`)}t.relative=relative;function normalize(t){return H.parse(t.toString()).toString()}t.normalize=normalize})(U||={});var DefaultDefinitionProvider=class{constructor(t){this.nameProvider=t.references.NameProvider,this.references=t.references.References,this.grammarConfig=t.parser.GrammarConfig}getDefinition(t,n,i){let o=t.parseResult.value;if(o.$cstNode){let i=o.$cstNode,s=findDeclarationNodeAtOffset(i,t.textDocument.offsetAt(n.position),this.grammarConfig.nameRegexp);if(s)return this.collectLocationLinks(s,n)}}collectLocationLinks(t,n){let i=this.findLink(t);if(i)return[ce.create(i.targetDocument.textDocument.uri,(i.target.astNode.$cstNode??i.target).range,i.target.range,i.source.range)]}findLink(t){let n=this.references.findDeclarationNode(t);if(n?.astNode){let i=getDocument(n.astNode);if(n&&i)return{source:t,target:n,targetDocument:i}}}};function createGrammarConfig(t){let n=[],i=t.Grammar;for(let t of i.rules)isTerminalRule(t)&&isCommentTerminal(t)&&isMultilineComment(terminalRegex(t))&&n.push(t.name);return{multilineCommentRules:n,nameRegexp:rt}}var pt;(function(t){function is(t){return typeof t==`string`}t.is=is})(pt||={});var mt;(function(t){function is(t){return typeof t==`string`}t.is=is})(mt||={});var ht;(function(t){t.MIN_VALUE=-2147483648,t.MAX_VALUE=2147483647;function is(n){return typeof n==`number`&&t.MIN_VALUE<=n&&n<=t.MAX_VALUE}t.is=is})(ht||={});var gt;(function(t){t.MIN_VALUE=0,t.MAX_VALUE=2147483647;function is(n){return typeof n==`number`&&t.MIN_VALUE<=n&&n<=t.MAX_VALUE}t.is=is})(gt||={});var W;(function(t){function create(t,n){return t===Number.MAX_VALUE&&(t=gt.MAX_VALUE),n===Number.MAX_VALUE&&(n=gt.MAX_VALUE),{line:t,character:n}}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&q.uinteger(n.line)&&q.uinteger(n.character)}t.is=is})(W||={});var G;(function(t){function create(t,n,i,o){if(q.uinteger(t)&&q.uinteger(n)&&q.uinteger(i)&&q.uinteger(o))return{start:W.create(t,n),end:W.create(i,o)};if(W.is(t)&&W.is(n))return{start:t,end:n};throw Error(`Range#create called with invalid arguments[${t}, ${n}, ${i}, ${o}]`)}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&W.is(n.start)&&W.is(n.end)}t.is=is})(G||={});var _t;(function(t){function create(t,n){return{uri:t,range:n}}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&G.is(n.range)&&(q.string(n.uri)||q.undefined(n.uri))}t.is=is})(_t||={});var vt;(function(t){function create(t,n,i,o){return{targetUri:t,targetRange:n,targetSelectionRange:i,originSelectionRange:o}}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&G.is(n.targetRange)&&q.string(n.targetUri)&&G.is(n.targetSelectionRange)&&(G.is(n.originSelectionRange)||q.undefined(n.originSelectionRange))}t.is=is})(vt||={});var yt;(function(t){function create(t,n,i,o){return{red:t,green:n,blue:i,alpha:o}}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&q.numberRange(n.red,0,1)&&q.numberRange(n.green,0,1)&&q.numberRange(n.blue,0,1)&&q.numberRange(n.alpha,0,1)}t.is=is})(yt||={});var bt;(function(t){function create(t,n){return{range:t,color:n}}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&G.is(n.range)&&yt.is(n.color)}t.is=is})(bt||={});var xt;(function(t){function create(t,n,i){return{label:t,textEdit:n,additionalTextEdits:i}}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&q.string(n.label)&&(q.undefined(n.textEdit)||K.is(n))&&(q.undefined(n.additionalTextEdits)||q.typedArray(n.additionalTextEdits,K.is))}t.is=is})(xt||={});var St;(function(t){t.Comment=`comment`,t.Imports=`imports`,t.Region=`region`})(St||={});var Ct;(function(t){function create(t,n,i,o,s,c){let u={startLine:t,endLine:n};return q.defined(i)&&(u.startCharacter=i),q.defined(o)&&(u.endCharacter=o),q.defined(s)&&(u.kind=s),q.defined(c)&&(u.collapsedText=c),u}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&q.uinteger(n.startLine)&&q.uinteger(n.startLine)&&(q.undefined(n.startCharacter)||q.uinteger(n.startCharacter))&&(q.undefined(n.endCharacter)||q.uinteger(n.endCharacter))&&(q.undefined(n.kind)||q.string(n.kind))}t.is=is})(Ct||={});var wt;(function(t){function create(t,n){return{location:t,message:n}}t.create=create;function is(t){let n=t;return q.defined(n)&&_t.is(n.location)&&q.string(n.message)}t.is=is})(wt||={});var Tt;(function(t){t.Error=1,t.Warning=2,t.Information=3,t.Hint=4})(Tt||={});var Et;(function(t){t.Unnecessary=1,t.Deprecated=2})(Et||={});var Dt;(function(t){function is(t){let n=t;return q.objectLiteral(n)&&q.string(n.href)}t.is=is})(Dt||={});var Ot;(function(t){function create(t,n,i,o,s,c){let u={range:t,message:n};return q.defined(i)&&(u.severity=i),q.defined(o)&&(u.code=o),q.defined(s)&&(u.source=s),q.defined(c)&&(u.relatedInformation=c),u}t.create=create;function is(t){let n=t;return q.defined(n)&&G.is(n.range)&&q.string(n.message)&&(q.number(n.severity)||q.undefined(n.severity))&&(q.integer(n.code)||q.string(n.code)||q.undefined(n.code))&&(q.undefined(n.codeDescription)||q.string(n.codeDescription?.href))&&(q.string(n.source)||q.undefined(n.source))&&(q.undefined(n.relatedInformation)||q.typedArray(n.relatedInformation,wt.is))}t.is=is})(Ot||={});var kt;(function(t){function create(t,n,...i){let o={title:t,command:n};return q.defined(i)&&i.length>0&&(o.arguments=i),o}t.create=create;function is(t){let n=t;return q.defined(n)&&q.string(n.title)&&q.string(n.command)}t.is=is})(kt||={});var K;(function(t){function replace(t,n){return{range:t,newText:n}}t.replace=replace;function insert(t,n){return{range:{start:t,end:t},newText:n}}t.insert=insert;function del(t){return{range:t,newText:``}}t.del=del;function is(t){let n=t;return q.objectLiteral(n)&&q.string(n.newText)&&G.is(n.range)}t.is=is})(K||={});var At;(function(t){function create(t,n,i){let o={label:t};return n!==void 0&&(o.needsConfirmation=n),i!==void 0&&(o.description=i),o}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&q.string(n.label)&&(q.boolean(n.needsConfirmation)||n.needsConfirmation===void 0)&&(q.string(n.description)||n.description===void 0)}t.is=is})(At||={});var jt;(function(t){function is(t){let n=t;return q.string(n)}t.is=is})(jt||={});var Mt;(function(t){function replace(t,n,i){return{range:t,newText:n,annotationId:i}}t.replace=replace;function insert(t,n,i){return{range:{start:t,end:t},newText:n,annotationId:i}}t.insert=insert;function del(t,n){return{range:t,newText:``,annotationId:n}}t.del=del;function is(t){let n=t;return K.is(n)&&(At.is(n.annotationId)||jt.is(n.annotationId))}t.is=is})(Mt||={});var Nt;(function(t){function create(t,n){return{textDocument:t,edits:n}}t.create=create;function is(t){let n=t;return q.defined(n)&&Bt.is(n.textDocument)&&Array.isArray(n.edits)}t.is=is})(Nt||={});var Pt;(function(t){function create(t,n,i){let o={kind:`create`,uri:t};return n!==void 0&&(n.overwrite!==void 0||n.ignoreIfExists!==void 0)&&(o.options=n),i!==void 0&&(o.annotationId=i),o}t.create=create;function is(t){let n=t;return n&&n.kind===`create`&&q.string(n.uri)&&(n.options===void 0||(n.options.overwrite===void 0||q.boolean(n.options.overwrite))&&(n.options.ignoreIfExists===void 0||q.boolean(n.options.ignoreIfExists)))&&(n.annotationId===void 0||jt.is(n.annotationId))}t.is=is})(Pt||={});var Ft;(function(t){function create(t,n,i,o){let s={kind:`rename`,oldUri:t,newUri:n};return i!==void 0&&(i.overwrite!==void 0||i.ignoreIfExists!==void 0)&&(s.options=i),o!==void 0&&(s.annotationId=o),s}t.create=create;function is(t){let n=t;return n&&n.kind===`rename`&&q.string(n.oldUri)&&q.string(n.newUri)&&(n.options===void 0||(n.options.overwrite===void 0||q.boolean(n.options.overwrite))&&(n.options.ignoreIfExists===void 0||q.boolean(n.options.ignoreIfExists)))&&(n.annotationId===void 0||jt.is(n.annotationId))}t.is=is})(Ft||={});var It;(function(t){function create(t,n,i){let o={kind:`delete`,uri:t};return n!==void 0&&(n.recursive!==void 0||n.ignoreIfNotExists!==void 0)&&(o.options=n),i!==void 0&&(o.annotationId=i),o}t.create=create;function is(t){let n=t;return n&&n.kind===`delete`&&q.string(n.uri)&&(n.options===void 0||(n.options.recursive===void 0||q.boolean(n.options.recursive))&&(n.options.ignoreIfNotExists===void 0||q.boolean(n.options.ignoreIfNotExists)))&&(n.annotationId===void 0||jt.is(n.annotationId))}t.is=is})(It||={});var Lt;(function(t){function is(t){let n=t;return n&&(n.changes!==void 0||n.documentChanges!==void 0)&&(n.documentChanges===void 0||n.documentChanges.every(t=>q.string(t.kind)?Pt.is(t)||Ft.is(t)||It.is(t):Nt.is(t)))}t.is=is})(Lt||={});var Rt;(function(t){function create(t){return{uri:t}}t.create=create;function is(t){let n=t;return q.defined(n)&&q.string(n.uri)}t.is=is})(Rt||={});var zt;(function(t){function create(t,n){return{uri:t,version:n}}t.create=create;function is(t){let n=t;return q.defined(n)&&q.string(n.uri)&&q.integer(n.version)}t.is=is})(zt||={});var Bt;(function(t){function create(t,n){return{uri:t,version:n}}t.create=create;function is(t){let n=t;return q.defined(n)&&q.string(n.uri)&&(n.version===null||q.integer(n.version))}t.is=is})(Bt||={});var Vt;(function(t){function create(t,n,i,o){return{uri:t,languageId:n,version:i,text:o}}t.create=create;function is(t){let n=t;return q.defined(n)&&q.string(n.uri)&&q.string(n.languageId)&&q.integer(n.version)&&q.string(n.text)}t.is=is})(Vt||={});var Ht;(function(t){t.PlainText=`plaintext`,t.Markdown=`markdown`;function is(n){let i=n;return i===t.PlainText||i===t.Markdown}t.is=is})(Ht||={});var Ut;(function(t){function is(t){let n=t;return q.objectLiteral(t)&&Ht.is(n.kind)&&q.string(n.value)}t.is=is})(Ut||={});var Wt;(function(t){t.Text=1,t.Method=2,t.Function=3,t.Constructor=4,t.Field=5,t.Variable=6,t.Class=7,t.Interface=8,t.Module=9,t.Property=10,t.Unit=11,t.Value=12,t.Enum=13,t.Keyword=14,t.Snippet=15,t.Color=16,t.File=17,t.Reference=18,t.Folder=19,t.EnumMember=20,t.Constant=21,t.Struct=22,t.Event=23,t.Operator=24,t.TypeParameter=25})(Wt||={});var Gt;(function(t){t.PlainText=1,t.Snippet=2})(Gt||={});var Kt;(function(t){t.Deprecated=1})(Kt||={});var qt;(function(t){function create(t,n,i){return{newText:t,insert:n,replace:i}}t.create=create;function is(t){let n=t;return n&&q.string(n.newText)&&G.is(n.insert)&&G.is(n.replace)}t.is=is})(qt||={});var Jt;(function(t){t.asIs=1,t.adjustIndentation=2})(Jt||={});var Yt;(function(t){function is(t){let n=t;return n&&(q.string(n.detail)||n.detail===void 0)&&(q.string(n.description)||n.description===void 0)}t.is=is})(Yt||={});var Xt;(function(t){function create(t){return{label:t}}t.create=create})(Xt||={});var Zt;(function(t){function create(t,n){return{items:t||[],isIncomplete:!!n}}t.create=create})(Zt||={});var Qt;(function(t){function fromPlainText(t){return t.replace(/[\\`*_{}[\]()#+\-.!]/g,`\\$&`)}t.fromPlainText=fromPlainText;function is(t){let n=t;return q.string(n)||q.objectLiteral(n)&&q.string(n.language)&&q.string(n.value)}t.is=is})(Qt||={});var $t;(function(t){function is(t){let n=t;return!!n&&q.objectLiteral(n)&&(Ut.is(n.contents)||Qt.is(n.contents)||q.typedArray(n.contents,Qt.is))&&(t.range===void 0||G.is(t.range))}t.is=is})($t||={});var en;(function(t){function create(t,n){return n?{label:t,documentation:n}:{label:t}}t.create=create})(en||={});var tn;(function(t){function create(t,n,...i){let o={label:t};return q.defined(n)&&(o.documentation=n),q.defined(i)?o.parameters=i:o.parameters=[],o}t.create=create})(tn||={});var nn;(function(t){t.Text=1,t.Read=2,t.Write=3})(nn||={});var rn;(function(t){function create(t,n){let i={range:t};return q.number(n)&&(i.kind=n),i}t.create=create})(rn||={});var an;(function(t){t.File=1,t.Module=2,t.Namespace=3,t.Package=4,t.Class=5,t.Method=6,t.Property=7,t.Field=8,t.Constructor=9,t.Enum=10,t.Interface=11,t.Function=12,t.Variable=13,t.Constant=14,t.String=15,t.Number=16,t.Boolean=17,t.Array=18,t.Object=19,t.Key=20,t.Null=21,t.EnumMember=22,t.Struct=23,t.Event=24,t.Operator=25,t.TypeParameter=26})(an||={});var on;(function(t){t.Deprecated=1})(on||={});var sn;(function(t){function create(t,n,i,o,s){let c={name:t,kind:n,location:{uri:o,range:i}};return s&&(c.containerName=s),c}t.create=create})(sn||={});var cn;(function(t){function create(t,n,i,o){return o===void 0?{name:t,kind:n,location:{uri:i}}:{name:t,kind:n,location:{uri:i,range:o}}}t.create=create})(cn||={});var ln;(function(t){function create(t,n,i,o,s,c){let u={name:t,detail:n,kind:i,range:o,selectionRange:s};return c!==void 0&&(u.children=c),u}t.create=create;function is(t){let n=t;return n&&q.string(n.name)&&q.number(n.kind)&&G.is(n.range)&&G.is(n.selectionRange)&&(n.detail===void 0||q.string(n.detail))&&(n.deprecated===void 0||q.boolean(n.deprecated))&&(n.children===void 0||Array.isArray(n.children))&&(n.tags===void 0||Array.isArray(n.tags))}t.is=is})(ln||={});var un;(function(t){t.Empty=``,t.QuickFix=`quickfix`,t.Refactor=`refactor`,t.RefactorExtract=`refactor.extract`,t.RefactorInline=`refactor.inline`,t.RefactorRewrite=`refactor.rewrite`,t.Source=`source`,t.SourceOrganizeImports=`source.organizeImports`,t.SourceFixAll=`source.fixAll`})(un||={});var dn;(function(t){t.Invoked=1,t.Automatic=2})(dn||={});var fn;(function(t){function create(t,n,i){let o={diagnostics:t};return n!=null&&(o.only=n),i!=null&&(o.triggerKind=i),o}t.create=create;function is(t){let n=t;return q.defined(n)&&q.typedArray(n.diagnostics,Ot.is)&&(n.only===void 0||q.typedArray(n.only,q.string))&&(n.triggerKind===void 0||n.triggerKind===dn.Invoked||n.triggerKind===dn.Automatic)}t.is=is})(fn||={});var pn;(function(t){function create(t,n,i){let o={title:t},s=!0;return typeof n==`string`?(s=!1,o.kind=n):kt.is(n)?o.command=n:o.edit=n,s&&i!==void 0&&(o.kind=i),o}t.create=create;function is(t){let n=t;return n&&q.string(n.title)&&(n.diagnostics===void 0||q.typedArray(n.diagnostics,Ot.is))&&(n.kind===void 0||q.string(n.kind))&&(n.edit!==void 0||n.command!==void 0)&&(n.command===void 0||kt.is(n.command))&&(n.isPreferred===void 0||q.boolean(n.isPreferred))&&(n.edit===void 0||Lt.is(n.edit))}t.is=is})(pn||={});var mn;(function(t){function create(t,n){let i={range:t};return q.defined(n)&&(i.data=n),i}t.create=create;function is(t){let n=t;return q.defined(n)&&G.is(n.range)&&(q.undefined(n.command)||kt.is(n.command))}t.is=is})(mn||={});var hn;(function(t){function create(t,n){return{tabSize:t,insertSpaces:n}}t.create=create;function is(t){let n=t;return q.defined(n)&&q.uinteger(n.tabSize)&&q.boolean(n.insertSpaces)}t.is=is})(hn||={});var gn;(function(t){function create(t,n,i){return{range:t,target:n,data:i}}t.create=create;function is(t){let n=t;return q.defined(n)&&G.is(n.range)&&(q.undefined(n.target)||q.string(n.target))}t.is=is})(gn||={});var _n;(function(t){function create(t,n){return{range:t,parent:n}}t.create=create;function is(n){let i=n;return q.objectLiteral(i)&&G.is(i.range)&&(i.parent===void 0||t.is(i.parent))}t.is=is})(_n||={});var vn;(function(t){t.namespace=`namespace`,t.type=`type`,t.class=`class`,t.enum=`enum`,t.interface=`interface`,t.struct=`struct`,t.typeParameter=`typeParameter`,t.parameter=`parameter`,t.variable=`variable`,t.property=`property`,t.enumMember=`enumMember`,t.event=`event`,t.function=`function`,t.method=`method`,t.macro=`macro`,t.keyword=`keyword`,t.modifier=`modifier`,t.comment=`comment`,t.string=`string`,t.number=`number`,t.regexp=`regexp`,t.operator=`operator`,t.decorator=`decorator`})(vn||={});var yn;(function(t){t.declaration=`declaration`,t.definition=`definition`,t.readonly=`readonly`,t.static=`static`,t.deprecated=`deprecated`,t.abstract=`abstract`,t.async=`async`,t.modification=`modification`,t.documentation=`documentation`,t.defaultLibrary=`defaultLibrary`})(yn||={});var bn;(function(t){function is(t){let n=t;return q.objectLiteral(n)&&(n.resultId===void 0||typeof n.resultId==`string`)&&Array.isArray(n.data)&&(n.data.length===0||typeof n.data[0]==`number`)}t.is=is})(bn||={});var xn;(function(t){function create(t,n){return{range:t,text:n}}t.create=create;function is(t){let n=t;return n!=null&&G.is(n.range)&&q.string(n.text)}t.is=is})(xn||={});var Sn;(function(t){function create(t,n,i){return{range:t,variableName:n,caseSensitiveLookup:i}}t.create=create;function is(t){let n=t;return n!=null&&G.is(n.range)&&q.boolean(n.caseSensitiveLookup)&&(q.string(n.variableName)||n.variableName===void 0)}t.is=is})(Sn||={});var Cn;(function(t){function create(t,n){return{range:t,expression:n}}t.create=create;function is(t){let n=t;return n!=null&&G.is(n.range)&&(q.string(n.expression)||n.expression===void 0)}t.is=is})(Cn||={});var wn;(function(t){function create(t,n){return{frameId:t,stoppedLocation:n}}t.create=create;function is(t){let n=t;return q.defined(n)&&G.is(t.stoppedLocation)}t.is=is})(wn||={});var Tn;(function(t){t.Type=1,t.Parameter=2;function is(t){return t===1||t===2}t.is=is})(Tn||={});var En;(function(t){function create(t){return{value:t}}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&(n.tooltip===void 0||q.string(n.tooltip)||Ut.is(n.tooltip))&&(n.location===void 0||_t.is(n.location))&&(n.command===void 0||kt.is(n.command))}t.is=is})(En||={});var Dn;(function(t){function create(t,n,i){let o={position:t,label:n};return i!==void 0&&(o.kind=i),o}t.create=create;function is(t){let n=t;return q.objectLiteral(n)&&W.is(n.position)&&(q.string(n.label)||q.typedArray(n.label,En.is))&&(n.kind===void 0||Tn.is(n.kind))&&n.textEdits===void 0||q.typedArray(n.textEdits,K.is)&&(n.tooltip===void 0||q.string(n.tooltip)||Ut.is(n.tooltip))&&(n.paddingLeft===void 0||q.boolean(n.paddingLeft))&&(n.paddingRight===void 0||q.boolean(n.paddingRight))}t.is=is})(Dn||={});var On;(function(t){function createSnippet(t){return{kind:`snippet`,value:t}}t.createSnippet=createSnippet})(On||={});var kn;(function(t){function create(t,n,i,o){return{insertText:t,filterText:n,range:i,command:o}}t.create=create})(kn||={});var An;(function(t){function create(t){return{items:t}}t.create=create})(An||={});var jn;(function(t){t.Invoked=0,t.Automatic=1})(jn||={});var Mn;(function(t){function create(t,n){return{range:t,text:n}}t.create=create})(Mn||={});var Nn;(function(t){function create(t,n){return{triggerKind:t,selectedCompletionInfo:n}}t.create=create})(Nn||={});var Pn;(function(t){function is(t){let n=t;return q.objectLiteral(n)&&mt.is(n.uri)&&q.string(n.name)}t.is=is})(Pn||={});var Fn;(function(t){function create(t,n,i,o){return new FullTextDocument$1(t,n,i,o)}t.create=create;function is(t){let n=t;return!!(q.defined(n)&&q.string(n.uri)&&(q.undefined(n.languageId)||q.string(n.languageId))&&q.uinteger(n.lineCount)&&q.func(n.getText)&&q.func(n.positionAt)&&q.func(n.offsetAt))}t.is=is;function applyEdits(t,n){let i=t.getText(),o=mergeSort(n,(t,n)=>{let i=t.range.start.line-n.range.start.line;return i===0?t.range.start.character-n.range.start.character:i}),s=i.length;for(let n=o.length-1;n>=0;n--){let c=o[n],u=t.offsetAt(c.range.start),f=t.offsetAt(c.range.end);if(f<=s)i=i.substring(0,u)+c.newText+i.substring(f,i.length);else throw Error(`Overlapping edit`);s=u}return i}t.applyEdits=applyEdits;function mergeSort(t,n){if(t.length<=1)return t;let i=t.length/2|0,o=t.slice(0,i),s=t.slice(i);mergeSort(o,n),mergeSort(s,n);let c=0,u=0,f=0;for(;c<o.length&&u<s.length;)n(o[c],s[u])<=0?t[f++]=o[c++]:t[f++]=s[u++];for(;c<o.length;)t[f++]=o[c++];for(;u<s.length;)t[f++]=s[u++];return t}})(Fn||={});var FullTextDocument$1=class{static{o(this,`FullTextDocument`)}constructor(t,n,i,o){this._uri=t,this._languageId=n,this._version=i,this._content=o,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(t){if(t){let n=this.offsetAt(t.start),i=this.offsetAt(t.end);return this._content.substring(n,i)}return this._content}update(t,n){this._content=t.text,this._version=n,this._lineOffsets=void 0}getLineOffsets(){if(this._lineOffsets===void 0){let t=[],n=this._content,i=!0;for(let o=0;o<n.length;o++){i&&=(t.push(o),!1);let s=n.charAt(o);i=s===`\r`||s===`
5
- `,s===`\r`&&o+1<n.length&&n.charAt(o+1)===`
6
- `&&o++}i&&n.length>0&&t.push(n.length),this._lineOffsets=t}return this._lineOffsets}positionAt(t){t=Math.max(Math.min(t,this._content.length),0);let n=this.getLineOffsets(),i=0,o=n.length;if(o===0)return W.create(0,t);for(;i<o;){let s=Math.floor((i+o)/2);n[s]>t?o=s:i=s+1}let s=i-1;return W.create(s,t-n[s])}offsetAt(t){let n=this.getLineOffsets();if(t.line>=n.length)return this._content.length;if(t.line<0)return 0;let i=n[t.line],o=t.line+1<n.length?n[t.line+1]:this._content.length;return Math.max(Math.min(i+t.character,o),i)}get lineCount(){return this.getLineOffsets().length}},q;(function(t){let n=Object.prototype.toString;function defined(t){return t!==void 0}t.defined=defined;function undefined(t){return t===void 0}t.undefined=undefined;function boolean(t){return t===!0||t===!1}t.boolean=boolean;function string(t){return n.call(t)===`[object String]`}t.string=string;function number(t){return n.call(t)===`[object Number]`}t.number=number;function numberRange(t,i,o){return n.call(t)===`[object Number]`&&i<=t&&t<=o}t.numberRange=numberRange;function integer(t){return n.call(t)===`[object Number]`&&-2147483648<=t&&t<=2147483647}t.integer=integer;function uinteger(t){return n.call(t)===`[object Number]`&&0<=t&&t<=2147483647}t.uinteger=uinteger;function func(t){return n.call(t)===`[object Function]`}t.func=func;function objectLiteral(t){return typeof t==`object`&&!!t}t.objectLiteral=objectLiteral;function typedArray(t,n){return Array.isArray(t)&&t.every(n)}t.typedArray=typedArray})(q||={});var CstNodeBuilder=class{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]??this.rootNode}buildRootNode(t){return this.rootNode=new RootCstNodeImpl(t),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(t){let n=new CompositeCstNodeImpl;return n.grammarSource=t,n.root=this.rootNode,this.current.content.push(n),this.nodeStack.push(n),n}buildLeafNode(t,n){let i=new LeafCstNodeImpl(t.startOffset,t.image.length,tokenToRange(t),t.tokenType,!n);return i.grammarSource=n,i.root=this.rootNode,this.current.content.push(i),i}removeNode(t){let n=t.container;if(n){let i=n.content.indexOf(t);i>=0&&n.content.splice(i,1)}}addHiddenNodes(t){let n=[];for(let i of t){let t=new LeafCstNodeImpl(i.startOffset,i.image.length,tokenToRange(i),i.tokenType,!0);t.root=this.rootNode,n.push(t)}let i=this.current,o=!1;if(i.content.length>0){i.content.push(...n);return}for(;i.container;){let t=i.container.content.indexOf(i);if(t>0){i.container.content.splice(t,0,...n),o=!0;break}i=i.container}o||this.rootNode.content.unshift(...n)}construct(t){let n=this.current;typeof t.$type==`string`&&(this.current.astNode=t),t.$cstNode=n;let i=this.nodeStack.pop();i?.content.length===0&&this.removeNode(i)}},AbstractCstNode=class{get parent(){return this.container}get feature(){return this.grammarSource}get hidden(){return!1}get astNode(){let t=typeof this._astNode?.$type==`string`?this._astNode:this.container?.astNode;if(!t)throw Error(`This node has no associated AST element`);return t}set astNode(t){this._astNode=t}get element(){return this.astNode}get text(){return this.root.fullText.substring(this.offset,this.end)}},LeafCstNodeImpl=class extends AbstractCstNode{get offset(){return this._offset}get length(){return this._length}get end(){return this._offset+this._length}get hidden(){return this._hidden}get tokenType(){return this._tokenType}get range(){return this._range}constructor(t,n,i,o,s=!1){super(),this._hidden=s,this._offset=t,this._tokenType=o,this._length=n,this._range=i}},CompositeCstNodeImpl=class extends AbstractCstNode{constructor(){super(...arguments),this.content=new In(this)}get children(){return this.content}get offset(){return this.firstNonHiddenNode?.offset??0}get length(){return this.end-this.offset}get end(){return this.lastNonHiddenNode?.end??0}get range(){let t=this.firstNonHiddenNode,n=this.lastNonHiddenNode;if(t&&n){if(this._rangeCache===void 0){let{range:i}=t,{range:o}=n;this._rangeCache={start:i.start,end:o.end.line<i.start.line?i.start:o.end}}return this._rangeCache}else return{start:W.create(0,0),end:W.create(0,0)}}get firstNonHiddenNode(){for(let t of this.content)if(!t.hidden)return t;return this.content[0]}get lastNonHiddenNode(){for(let t=this.content.length-1;t>=0;t--){let n=this.content[t];if(!n.hidden)return n}return this.content[this.content.length-1]}},In=class CstNodeContainer extends Array{constructor(t){super(),this.parent=t,Object.setPrototypeOf(this,CstNodeContainer.prototype)}push(...t){return this.addParents(t),super.push(...t)}unshift(...t){return this.addParents(t),super.unshift(...t)}splice(t,n,...i){return this.addParents(i),super.splice(t,n,...i)}addParents(t){for(let n of t)n.container=this.parent}},RootCstNodeImpl=class extends CompositeCstNodeImpl{get text(){return this._text.substring(this.offset,this.end)}get fullText(){return this._text}constructor(t){super(),this._text=``,this._text=t??``}};const Ln=Symbol(`Datatype`);function isDataTypeNode(t){return t.$type===Ln}const withRuleSuffix=t=>t.endsWith(`​`)?t:t+`​`;var AbstractLangiumParser=class{constructor(t){this._unorderedGroups=new Map,this.allRules=new Map,this.lexer=t.parser.Lexer;let n=this.lexer.definition,i=t.LanguageMetaData.mode===`production`;this.wrapper=new ChevrotainWrapper(n,Object.assign(Object.assign({},t.parser.ParserConfig),{skipValidations:i,errorMessageProvider:t.parser.ParserErrorMessageProvider}))}alternatives(t,n){this.wrapper.wrapOr(t,n)}optional(t,n){this.wrapper.wrapOption(t,n)}many(t,n){this.wrapper.wrapMany(t,n)}atLeastOne(t,n){this.wrapper.wrapAtLeastOne(t,n)}getRule(t){return this.allRules.get(t)}isRecording(){return this.wrapper.IS_RECORDING}get unorderedGroups(){return this._unorderedGroups}getRuleStack(){return this.wrapper.RULE_STACK}finalize(){this.wrapper.wrapSelfAnalysis()}},LangiumParser=class extends AbstractLangiumParser{get current(){return this.stack[this.stack.length-1]}constructor(t){super(t),this.nodeBuilder=new CstNodeBuilder,this.stack=[],this.assignmentMap=new Map,this.linker=t.references.Linker,this.converter=t.parser.ValueConverter,this.astReflection=t.shared.AstReflection}rule(t,n){let i=this.computeRuleType(t),o=this.wrapper.DEFINE_RULE(withRuleSuffix(t.name),this.startImplementation(i,n).bind(this));return this.allRules.set(t.name,o),t.entry&&(this.mainRule=o),o}computeRuleType(t){if(!t.fragment)return isDataTypeRule(t)?Ln:getExplicitRuleType(t)??t.name}parse(t,n={}){this.nodeBuilder.buildRootNode(t);let i=this.lexerResult=this.lexer.tokenize(t);this.wrapper.input=i.tokens;let o=n.rule?this.allRules.get(n.rule):this.mainRule;if(!o)throw Error(n.rule?`No rule found with name '${n.rule}'`:`No main rule available.`);let s=this.doParse(o);return this.nodeBuilder.addHiddenNodes(i.hidden),this.unorderedGroups.clear(),this.lexerResult=void 0,{value:s,lexerErrors:i.errors,lexerReport:i.report,parserErrors:this.wrapper.errors}}doParse(t){let n=t.call(this.wrapper,{});if(this.stack.length>0&&(n=this.construct()),n===void 0)throw Error(`No result from parser`);if(this.stack.length>0)throw Error(`Parser stack is not empty after parsing`);return n}startImplementation(t,n){return i=>{let o=!this.isRecording()&&t!==void 0;if(o){let n={$type:t};this.stack.push(n),t===Ln&&(n.value=``)}return n(i),o?this.construct():void 0}}extractHiddenTokens(t){let n=this.lexerResult.hidden;if(!n.length)return[];let i=t.startOffset;for(let t=0;t<n.length;t++)if(n[t].startOffset>i)return n.splice(0,t);return n.splice(0,n.length)}consume(t,n,i){let o=this.wrapper.wrapConsume(t,n);if(!this.isRecording()&&this.isValidToken(o)){let t=this.extractHiddenTokens(o);this.nodeBuilder.addHiddenNodes(t);let n=this.nodeBuilder.buildLeafNode(o,i),{assignment:s,isCrossRef:c}=this.getAssignment(i),u=this.current;if(s){let t=isKeyword(i)?o.image:this.converter.convert(o.image,n);this.assign(s.operator,s.feature,t,n,c)}else if(isDataTypeNode(u)){let t=o.image;isKeyword(i)||(t=this.converter.convert(t,n).toString()),u.value+=t}}}isValidToken(t){return!t.isInsertedInRecovery&&!isNaN(t.startOffset)&&typeof t.endOffset==`number`&&!isNaN(t.endOffset)}subrule(t,n,i,o,s){let c;!this.isRecording()&&!i&&(c=this.nodeBuilder.buildCompositeNode(o));let u;try{u=this.wrapper.wrapSubrule(t,n,s)}finally{this.isRecording()||(u===void 0&&!i&&(u=this.construct()),u!==void 0&&c&&c.length>0&&this.performSubruleAssignment(u,o,c))}}performSubruleAssignment(t,n,i){let{assignment:o,isCrossRef:s}=this.getAssignment(n);if(o)this.assign(o.operator,o.feature,t,i,s);else if(!o){let n=this.current;if(isDataTypeNode(n))n.value+=t.toString();else if(typeof t==`object`&&t){let i=this.assignWithoutOverride(t,n);this.stack.pop(),this.stack.push(i)}}}action(t,n){if(!this.isRecording()){let i=this.current;if(n.feature&&n.operator){i=this.construct(),this.nodeBuilder.removeNode(i.$cstNode),this.nodeBuilder.buildCompositeNode(n).content.push(i.$cstNode);let o={$type:t};this.stack.push(o),this.assign(n.operator,n.feature,i,i.$cstNode,!1)}else i.$type=t}}construct(){if(this.isRecording())return;let t=this.current;return linkContentToContainer(t),this.nodeBuilder.construct(t),this.stack.pop(),isDataTypeNode(t)?this.converter.convert(t.value,t.$cstNode):(assignMandatoryProperties(this.astReflection,t),t)}getAssignment(t){if(!this.assignmentMap.has(t)){let n=getContainerOfType(t,isAssignment);this.assignmentMap.set(t,{assignment:n,isCrossRef:n?isCrossReference(n.terminal):!1})}return this.assignmentMap.get(t)}assign(t,n,i,o,s){let c=this.current,u;switch(u=s&&typeof i==`string`?this.linker.buildReference(c,n,o,i):i,t){case`=`:c[n]=u;break;case`?=`:c[n]=!0;break;case`+=`:Array.isArray(c[n])||(c[n]=[]),c[n].push(u)}}assignWithoutOverride(t,n){for(let[i,o]of Object.entries(n)){let n=t[i];n===void 0?t[i]=o:Array.isArray(n)&&Array.isArray(o)&&(o.push(...n),t[i]=o)}let i=t.$cstNode;return i&&(i.astNode=void 0,t.$cstNode=void 0),t}get definitionErrors(){return this.wrapper.definitionErrors}},AbstractParserErrorMessageProvider=class{buildMismatchTokenMessage(t){return f.buildMismatchTokenMessage(t)}buildNotAllInputParsedMessage(t){return f.buildNotAllInputParsedMessage(t)}buildNoViableAltMessage(t){return f.buildNoViableAltMessage(t)}buildEarlyExitMessage(t){return f.buildEarlyExitMessage(t)}},LangiumParserErrorMessageProvider=class extends AbstractParserErrorMessageProvider{buildMismatchTokenMessage({expected:t,actual:n}){return`Expecting ${t.LABEL?"`"+t.LABEL+"`":t.name.endsWith(`:KW`)?`keyword '${t.name.substring(0,t.name.length-3)}'`:`token of type '${t.name}'`} but found \`${n.image}\`.`}buildNotAllInputParsedMessage({firstRedundant:t}){return`Expecting end of file but found \`${t.image}\`.`}},LangiumCompletionParser=class extends AbstractLangiumParser{constructor(){super(...arguments),this.tokens=[],this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}action(){}construct(){}parse(t){this.resetState();let n=this.lexer.tokenize(t,{mode:`partial`});return this.tokens=n.tokens,this.wrapper.input=[...this.tokens],this.mainRule.call(this.wrapper,{}),this.unorderedGroups.clear(),{tokens:this.tokens,elementStack:[...this.lastElementStack],tokenIndex:this.nextTokenIndex}}rule(t,n){let i=this.wrapper.DEFINE_RULE(withRuleSuffix(t.name),this.startImplementation(n).bind(this));return this.allRules.set(t.name,i),t.entry&&(this.mainRule=i),i}resetState(){this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}startImplementation(t){return n=>{let i=this.keepStackSize();try{t(n)}finally{this.resetStackSize(i)}}}removeUnexpectedElements(){this.elementStack.splice(this.stackSize)}keepStackSize(){let t=this.elementStack.length;return this.stackSize=t,t}resetStackSize(t){this.removeUnexpectedElements(),this.stackSize=t}consume(t,n,i){this.wrapper.wrapConsume(t,n),this.isRecording()||(this.lastElementStack=[...this.elementStack,i],this.nextTokenIndex=this.currIdx+1)}subrule(t,n,i,o,s){this.before(o),this.wrapper.wrapSubrule(t,n,s),this.after(o)}before(t){this.isRecording()||this.elementStack.push(t)}after(t){if(!this.isRecording()){let n=this.elementStack.lastIndexOf(t);n>=0&&this.elementStack.splice(n)}}get currIdx(){return this.wrapper.currIdx}};const Rn={recoveryEnabled:!0,nodeLocationTracking:`full`,skipValidations:!0,errorMessageProvider:new LangiumParserErrorMessageProvider};var ChevrotainWrapper=class extends h{constructor(t,n){let i=n&&`maxLookahead`in n;super(t,Object.assign(Object.assign(Object.assign({},Rn),{lookaheadStrategy:i?new _({maxLookahead:n.maxLookahead}):new T({logging:n.skipValidations?()=>{}:void 0})}),n))}get IS_RECORDING(){return this.RECORDING_PHASE}DEFINE_RULE(t,n,i){return this.RULE(t,n,i)}wrapSelfAnalysis(){this.performSelfAnalysis()}wrapConsume(t,n){return this.consume(t,n,void 0)}wrapSubrule(t,n,i){return this.subrule(t,n,{ARGS:[i]})}wrapOr(t,n){this.or(t,n)}wrapOption(t,n){this.option(t,n)}wrapMany(t,n){this.many(t,n)}wrapAtLeastOne(t,n){this.atLeastOne(t,n)}};function createParser(t,n,i){return buildRules({parser:n,tokens:i,ruleNames:new Map},t),n}function buildRules(t,n){let i=getAllReachableRules(n,!1),o=stream(n.rules).filter(isParserRule).filter(t=>i.has(t));for(let n of o){let i=Object.assign(Object.assign({},t),{consume:1,optional:1,subrule:1,many:1,or:1});t.parser.rule(n,buildElement(i,n.definition))}}function buildElement(t,n,i=!1){let method;if(isKeyword(n))method=buildKeyword(t,n);else if(isAction(n))method=buildAction(t,n);else if(isAssignment(n))method=buildElement(t,n.terminal);else if(isCrossReference(n))method=buildCrossReference(t,n);else if(isRuleCall(n))method=buildRuleCall(t,n);else if(isAlternatives(n))method=buildAlternatives(t,n);else if(isUnorderedGroup(n))method=buildUnorderedGroup(t,n);else if(isGroup(n))method=buildGroup(t,n);else if(isEndOfFile(n)){let i=t.consume++;method=()=>t.parser.consume(i,g,n)}else throw new ErrorWithLocation(n.$cstNode,`Unexpected element type: ${n.$type}`);return wrap(t,i?void 0:getGuardCondition(n),method,n.cardinality)}function buildAction(t,n){let i=getTypeName(n);return()=>t.parser.action(i,n)}function buildRuleCall(t,n){let i=n.rule.ref;if(isParserRule(i)){let o=t.subrule++,s=i.fragment,c=n.arguments.length>0?buildRuleCallPredicate(i,n.arguments):()=>({});return u=>t.parser.subrule(o,getRule(t,i),s,n,c(u))}else if(isTerminalRule(i)){let o=t.consume++,s=getToken(t,i.name);return()=>t.parser.consume(o,s,n)}else if(i)assertUnreachable(i);else throw new ErrorWithLocation(n.$cstNode,`Undefined rule: ${n.rule.$refText}`)}function buildRuleCallPredicate(t,n){let i=n.map(t=>buildPredicate(t.value));return n=>{let o={};for(let s=0;s<i.length;s++){let c=t.parameters[s],u=i[s];o[c.name]=u(n)}return o}}function buildPredicate(t){if(isDisjunction(t)){let n=buildPredicate(t.left),i=buildPredicate(t.right);return t=>n(t)||i(t)}else if(isConjunction(t)){let n=buildPredicate(t.left),i=buildPredicate(t.right);return t=>n(t)&&i(t)}else if(isNegation(t)){let n=buildPredicate(t.value);return t=>!n(t)}else if(isParameterReference(t)){let n=t.parameter.ref.name;return t=>t!==void 0&&t[n]===!0}else if(isBooleanLiteral(t)){let n=!!t.true;return()=>n}assertUnreachable(t)}function buildAlternatives(t,n){if(n.elements.length===1)return buildElement(t,n.elements[0]);{let i=[];for(let o of n.elements){let n={ALT:buildElement(t,o,!0)},s=getGuardCondition(o);s&&(n.GATE=buildPredicate(s)),i.push(n)}let o=t.or++;return n=>t.parser.alternatives(o,i.map(t=>{let i={ALT:()=>t.ALT(n)},o=t.GATE;return o&&(i.GATE=()=>o(n)),i}))}}function buildUnorderedGroup(t,n){if(n.elements.length===1)return buildElement(t,n.elements[0]);let i=[];for(let o of n.elements){let n={ALT:buildElement(t,o,!0)},s=getGuardCondition(o);s&&(n.GATE=buildPredicate(s)),i.push(n)}let o=t.or++,idFunc=(t,n)=>`uGroup_${t}_${n.getRuleStack().join(`-`)}`,alternatives=n=>t.parser.alternatives(o,i.map((i,s)=>{let c={ALT:()=>!0},u=t.parser;c.ALT=()=>{if(i.ALT(n),!u.isRecording()){let t=idFunc(o,u);u.unorderedGroups.get(t)||u.unorderedGroups.set(t,[]);let n=u.unorderedGroups.get(t);n?.[s]===void 0&&(n[s]=!0)}};let f=i.GATE;return f?c.GATE=()=>f(n):c.GATE=()=>!u.unorderedGroups.get(idFunc(o,u))?.[s],c})),s=wrap(t,getGuardCondition(n),alternatives,`*`);return n=>{s(n),t.parser.isRecording()||t.parser.unorderedGroups.delete(idFunc(o,t.parser))}}function buildGroup(t,n){let i=n.elements.map(n=>buildElement(t,n));return t=>i.forEach(n=>n(t))}function getGuardCondition(t){if(isGroup(t))return t.guardCondition}function buildCrossReference(t,n,i=n.terminal){if(!i){if(!n.type.ref)throw Error(`Could not resolve reference to type: `+n.type.$refText);let i=findNameAssignment(n.type.ref)?.terminal;if(!i)throw Error(`Could not find name assignment for type: `+getTypeName(n.type.ref));return buildCrossReference(t,n,i)}else if(isRuleCall(i)&&isParserRule(i.rule.ref)){let o=i.rule.ref,s=t.subrule++;return i=>t.parser.subrule(s,getRule(t,o),!1,n,i)}else if(isRuleCall(i)&&isTerminalRule(i.rule.ref)){let o=t.consume++,s=getToken(t,i.rule.ref.name);return()=>t.parser.consume(o,s,n)}else if(isKeyword(i)){let o=t.consume++,s=getToken(t,i.value);return()=>t.parser.consume(o,s,n)}else throw Error(`Could not build cross reference parser`)}function buildKeyword(t,n){let i=t.consume++,o=t.tokens[n.value];if(!o)throw Error(`Could not find token for keyword: `+n.value);return()=>t.parser.consume(i,o,n)}function wrap(t,n,i,o){let s=n&&buildPredicate(n);if(!o)if(s){let n=t.or++;return o=>t.parser.alternatives(n,[{ALT:()=>i(o),GATE:()=>s(o)},{ALT:x(),GATE:()=>!s(o)}])}else return i;if(o===`*`){let n=t.many++;return o=>t.parser.many(n,{DEF:()=>i(o),GATE:s?()=>s(o):void 0})}else if(o===`+`){let n=t.many++;if(s){let o=t.or++;return c=>t.parser.alternatives(o,[{ALT:()=>t.parser.atLeastOne(n,{DEF:()=>i(c)}),GATE:()=>s(c)},{ALT:x(),GATE:()=>!s(c)}])}else return o=>t.parser.atLeastOne(n,{DEF:()=>i(o)})}else if(o===`?`){let n=t.optional++;return o=>t.parser.optional(n,{DEF:()=>i(o),GATE:s?()=>s(o):void 0})}else assertUnreachable(o)}function getRule(t,n){let i=getRuleName(t,n),o=t.parser.getRule(i);if(!o)throw Error(`Rule "${i}" not found."`);return o}function getRuleName(t,n){if(isParserRule(n))return n.name;if(t.ruleNames.has(n))return t.ruleNames.get(n);{let i=n,o=i.$container,s=n.$type;for(;!isParserRule(o);)(isGroup(o)||isAlternatives(o)||isUnorderedGroup(o))&&(s=o.elements.indexOf(i).toString()+`:`+s),i=o,o=o.$container;return s=o.name+`:`+s,t.ruleNames.set(n,s),s}}function getToken(t,n){let i=t.tokens[n];if(!i)throw Error(`Token "${n}" not found."`);return i}function createCompletionParser(t){let n=t.Grammar,i=t.parser.Lexer,o=new LangiumCompletionParser(t);return createParser(n,o,i.definition),o.finalize(),o}function createLangiumParser(t){let n=prepareLangiumParser(t);return n.finalize(),n}function prepareLangiumParser(t){let n=t.Grammar,i=t.parser.Lexer;return createParser(n,new LangiumParser(t),i.definition)}var DefaultTokenBuilder=class{constructor(){this.diagnostics=[]}buildTokens(t,n){let i=stream(getAllReachableRules(t,!1)),o=this.buildTerminalTokens(i),s=this.buildKeywordTokens(i,o,n);return s.push(...o),s}flushLexingReport(t){return{diagnostics:this.popDiagnostics()}}popDiagnostics(){let t=[...this.diagnostics];return this.diagnostics=[],t}buildTerminalTokens(t){return t.filter(isTerminalRule).filter(t=>!t.fragment).map(t=>this.buildTerminalToken(t)).toArray()}buildTerminalToken(t){let n=terminalRegex(t),i=this.requiresCustomPattern(n)?this.regexPatternFunction(n):n,o={name:t.name,PATTERN:i};return typeof i==`function`&&(o.LINE_BREAKS=!0),t.hidden&&(o.GROUP=isWhitespace(n)?p.SKIPPED:`hidden`),o}requiresCustomPattern(t){return t.flags.includes(`u`)||t.flags.includes(`s`)?!0:!!(t.source.includes(`?<=`)||t.source.includes(`?<!`))}regexPatternFunction(t){let n=new RegExp(t,t.flags+`y`);return(t,i)=>(n.lastIndex=i,n.exec(t))}buildKeywordTokens(t,n,i){return t.filter(isParserRule).flatMap(t=>streamAllContents(t).filter(isKeyword)).distinct(t=>t.value).toArray().sort((t,n)=>n.value.length-t.value.length).map(t=>this.buildKeywordToken(t,n,!!i?.caseInsensitive))}buildKeywordToken(t,n,i){let o=this.buildKeywordPattern(t,i),s={name:t.value,PATTERN:o,LONGER_ALT:this.findLongerAlt(t,n)};return typeof o==`function`&&(s.LINE_BREAKS=!0),s}buildKeywordPattern(t,n){return n?new RegExp(escapeRegExp(t.value),`i`):t.value}findLongerAlt(t,n){return n.reduce((n,i)=>{let o=i?.PATTERN;return o?.source&&partialMatches(`^`+o.source+`$`,t.value)&&n.push(i),n},[])}},DefaultValueConverter=class{convert(t,n){let i=n.grammarSource;if(isCrossReference(i)&&(i=getCrossReferenceTerminal(i)),isRuleCall(i)){let o=i.rule.ref;if(!o)throw Error(`This cst node was not parsed by a rule.`);return this.runConverter(o,t,n)}return t}runConverter(t,n,i){switch(t.name.toUpperCase()){case`INT`:return J.convertInt(n);case`STRING`:return J.convertString(n);case`ID`:return J.convertID(n)}switch(getRuleType(t)?.toLowerCase()){case`number`:return J.convertNumber(n);case`boolean`:return J.convertBoolean(n);case`bigint`:return J.convertBigint(n);case`date`:return J.convertDate(n);default:return n}}},J;(function(t){function convertString(t){let n=``;for(let i=1;i<t.length-1;i++){let o=t.charAt(i);if(o===`\\`){let o=t.charAt(++i);n+=convertEscapeCharacter(o)}else n+=o}return n}t.convertString=convertString;function convertEscapeCharacter(t){switch(t){case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
7
- `;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`0`:return`\0`;default:return t}}function convertID(t){return t.charAt(0)===`^`?t.substring(1):t}t.convertID=convertID;function convertInt(t){return parseInt(t)}t.convertInt=convertInt;function convertBigint(t){return BigInt(t)}t.convertBigint=convertBigint;function convertDate(t){return new Date(t)}t.convertDate=convertDate;function convertNumber(t){return Number(t)}t.convertNumber=convertNumber;function convertBoolean(t){return t.toLowerCase()===`true`}t.convertBoolean=convertBoolean})(J||={});var zn=s((t=>{Object.defineProperty(t,"__esModule",{value:!0});let n;function RAL(){if(n===void 0)throw Error(`No runtime abstraction layer installed`);return n}(function(t){function install(t){if(t===void 0)throw Error(`No runtime abstraction layer provided`);n=t}t.install=install})(RAL||={}),t.default=RAL})),Bn=s((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringArray=t.array=t.func=t.error=t.number=t.string=t.boolean=void 0;function boolean(t){return t===!0||t===!1}t.boolean=boolean;function string(t){return typeof t==`string`||t instanceof String}t.string=string;function number(t){return typeof t==`number`||t instanceof Number}t.number=number;function error(t){return t instanceof Error}t.error=error;function func(t){return typeof t==`function`}t.func=func;function array(t){return Array.isArray(t)}t.array=array;function stringArray(t){return array(t)&&t.every(t=>string(t))}t.stringArray=stringArray})),Vn=s((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=t.Event=void 0;let n=zn();var i;(function(t){let n={dispose(){}};t.None=function(){return n}})(i||(t.Event=i={}));var CallbackList=class{add(t,n=null,i){this._callbacks||(this._callbacks=[],this._contexts=[]),this._callbacks.push(t),this._contexts.push(n),Array.isArray(i)&&i.push({dispose:()=>this.remove(t,n)})}remove(t,n=null){if(!this._callbacks)return;let i=!1;for(let o=0,s=this._callbacks.length;o<s;o++)if(this._callbacks[o]===t)if(this._contexts[o]===n){this._callbacks.splice(o,1),this._contexts.splice(o,1);return}else i=!0;if(i)throw Error(`When adding a listener with a context, you should remove it with the same context`)}invoke(...t){if(!this._callbacks)return[];let i=[],o=this._callbacks.slice(0),s=this._contexts.slice(0);for(let c=0,u=o.length;c<u;c++)try{i.push(o[c].apply(s[c],t))}catch(t){(0,n.default)().console.error(t)}return i}isEmpty(){return!this._callbacks||this._callbacks.length===0}dispose(){this._callbacks=void 0,this._contexts=void 0}},o=class Emitter{constructor(t){this._options=t}get event(){return this._event||=(t,n,i)=>{this._callbacks||=new CallbackList,this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty()&&this._options.onFirstListenerAdd(this),this._callbacks.add(t,n);let o={dispose:()=>{this._callbacks&&(this._callbacks.remove(t,n),o.dispose=Emitter._noop,this._options&&this._options.onLastListenerRemove&&this._callbacks.isEmpty()&&this._options.onLastListenerRemove(this))}};return Array.isArray(i)&&i.push(o),o},this._event}fire(t){this._callbacks&&this._callbacks.invoke.call(this._callbacks,t)}dispose(){this._callbacks&&=(this._callbacks.dispose(),void 0)}};t.Emitter=o,o._noop=function(){}})),Hn=s((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationTokenSource=t.CancellationToken=void 0;let n=zn(),i=Bn(),o=Vn();var s;(function(t){t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:o.Event.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:o.Event.None});function is(n){let o=n;return o&&(o===t.None||o===t.Cancelled||i.boolean(o.isCancellationRequested)&&!!o.onCancellationRequested)}t.is=is})(s||(t.CancellationToken=s={}));let c=Object.freeze(function(t,i){let o=(0,n.default)().timer.setTimeout(t.bind(i),0);return{dispose(){o.dispose()}}});var MutableToken=class{constructor(){this._isCancelled=!1}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?c:(this._emitter||=new o.Emitter,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),void 0)}},CancellationTokenSource=class{get token(){return this._token||=new MutableToken,this._token}cancel(){this._token?this._token.cancel():this._token=s.Cancelled}dispose(){this._token?this._token instanceof MutableToken&&this._token.dispose():this._token=s.None}};t.CancellationTokenSource=CancellationTokenSource})),Y=i({});n(Y,t(Hn(),1));function delayNextTick(){return new Promise(t=>{typeof setImmediate>`u`?setTimeout(t,0):setImmediate(t)})}let Un=0;function startCancelableOperation(){return Un=performance.now(),new Y.CancellationTokenSource}const Wn=Symbol(`OperationCancelled`);function isOperationCancelled(t){return t===Wn}async function interruptAndCheck(t){if(t===Y.CancellationToken.None)return;let n=performance.now();if(n-Un>=10&&(Un=n,await delayNextTick(),Un=performance.now()),t.isCancellationRequested)throw Wn}var Deferred=class{constructor(){this.promise=new Promise((t,n)=>{this.resolve=n=>(t(n),this),this.reject=t=>(n(t),this)})}},Gn=class FullTextDocument{constructor(t,n,i,o){this._uri=t,this._languageId=n,this._version=i,this._content=o,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(t){if(t){let n=this.offsetAt(t.start),i=this.offsetAt(t.end);return this._content.substring(n,i)}return this._content}update(t,n){for(let n of t)if(FullTextDocument.isIncremental(n)){let t=getWellformedRange(n.range),i=this.offsetAt(t.start),o=this.offsetAt(t.end);this._content=this._content.substring(0,i)+n.text+this._content.substring(o,this._content.length);let s=Math.max(t.start.line,0),c=Math.max(t.end.line,0),u=this._lineOffsets,f=computeLineOffsets(n.text,!1,i);if(c-s===f.length)for(let t=0,n=f.length;t<n;t++)u[t+s+1]=f[t];else f.length<1e4?u.splice(s+1,c-s,...f):this._lineOffsets=u=u.slice(0,s+1).concat(f,u.slice(c+1));let p=n.text.length-(o-i);if(p!==0)for(let t=s+1+f.length,n=u.length;t<n;t++)u[t]=u[t]+p}else if(FullTextDocument.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw Error(`Unknown change event received`);this._version=n}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=computeLineOffsets(this._content,!0)),this._lineOffsets}positionAt(t){t=Math.max(Math.min(t,this._content.length),0);let n=this.getLineOffsets(),i=0,o=n.length;if(o===0)return{line:0,character:t};for(;i<o;){let s=Math.floor((i+o)/2);n[s]>t?o=s:i=s+1}let s=i-1;return{line:s,character:t-n[s]}}offsetAt(t){let n=this.getLineOffsets();if(t.line>=n.length)return this._content.length;if(t.line<0)return 0;let i=n[t.line],o=t.line+1<n.length?n[t.line+1]:this._content.length;return Math.max(Math.min(i+t.character,o),i)}get lineCount(){return this.getLineOffsets().length}static isIncremental(t){let n=t;return n!=null&&typeof n.text==`string`&&n.range!==void 0&&(n.rangeLength===void 0||typeof n.rangeLength==`number`)}static isFull(t){let n=t;return n!=null&&typeof n.text==`string`&&n.range===void 0&&n.rangeLength===void 0}},Kn;(function(t){function create(t,n,i,o){return new Gn(t,n,i,o)}t.create=create;function update(t,n,i){if(t instanceof Gn)return t.update(n,i),t;throw Error(`TextDocument.update: document must be created by TextDocument.create`)}t.update=update;function applyEdits(t,n){let i=t.getText(),o=mergeSort(n.map(getWellformedEdit),(t,n)=>{let i=t.range.start.line-n.range.start.line;return i===0?t.range.start.character-n.range.start.character:i}),s=0,c=[];for(let n of o){let o=t.offsetAt(n.range.start);if(o<s)throw Error(`Overlapping edit`);o>s&&c.push(i.substring(s,o)),n.newText.length&&c.push(n.newText),s=t.offsetAt(n.range.end)}return c.push(i.substr(s)),c.join(``)}t.applyEdits=applyEdits})(Kn||={});function mergeSort(t,n){if(t.length<=1)return t;let i=t.length/2|0,o=t.slice(0,i),s=t.slice(i);mergeSort(o,n),mergeSort(s,n);let c=0,u=0,f=0;for(;c<o.length&&u<s.length;)n(o[c],s[u])<=0?t[f++]=o[c++]:t[f++]=s[u++];for(;c<o.length;)t[f++]=o[c++];for(;u<s.length;)t[f++]=s[u++];return t}function computeLineOffsets(t,n,i=0){let o=n?[i]:[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);(s===13||s===10)&&(s===13&&n+1<t.length&&t.charCodeAt(n+1)===10&&n++,o.push(i+n+1))}return o}function getWellformedRange(t){let n=t.start,i=t.end;return n.line>i.line||n.line===i.line&&n.character>i.character?{start:i,end:n}:t}function getWellformedEdit(t){let n=getWellformedRange(t.range);return n===t.range?t:{newText:t.newText,range:n}}var X;(function(t){t[t.Changed=0]=`Changed`,t[t.Parsed=1]=`Parsed`,t[t.IndexedContent=2]=`IndexedContent`,t[t.ComputedScopes=3]=`ComputedScopes`,t[t.Linked=4]=`Linked`,t[t.IndexedReferences=5]=`IndexedReferences`,t[t.Validated=6]=`Validated`})(X||={});var DefaultLangiumDocumentFactory=class{constructor(t){this.serviceRegistry=t.ServiceRegistry,this.textDocuments=t.workspace.TextDocuments,this.fileSystemProvider=t.workspace.FileSystemProvider}async fromUri(t,n=Y.CancellationToken.None){let i=await this.fileSystemProvider.readFile(t);return this.createAsync(t,i,n)}fromTextDocument(t,n,i){return n??=H.parse(t.uri),Y.CancellationToken.is(i)?this.createAsync(n,t,i):this.create(n,t,i)}fromString(t,n,i){return Y.CancellationToken.is(i)?this.createAsync(n,t,i):this.create(n,t,i)}fromModel(t,n){return this.create(n,{$model:t})}create(t,n,i){if(typeof n==`string`){let o=this.parse(t,n,i);return this.createLangiumDocument(o,t,void 0,n)}else if(`$model`in n){let i={value:n.$model,parserErrors:[],lexerErrors:[]};return this.createLangiumDocument(i,t)}else{let o=this.parse(t,n.getText(),i);return this.createLangiumDocument(o,t,n)}}async createAsync(t,n,i){if(typeof n==`string`){let o=await this.parseAsync(t,n,i);return this.createLangiumDocument(o,t,void 0,n)}else{let o=await this.parseAsync(t,n.getText(),i);return this.createLangiumDocument(o,t,n)}}createLangiumDocument(t,n,i,o){let s;if(i)s={parseResult:t,uri:n,state:X.Parsed,references:[],textDocument:i};else{let i=this.createTextDocumentGetter(n,o);s={parseResult:t,uri:n,state:X.Parsed,references:[],get textDocument(){return i()}}}return t.value.$document=s,s}async update(t,n){let i=t.parseResult.value.$cstNode?.root.fullText,o=this.textDocuments?.get(t.uri.toString()),s=o?o.getText():await this.fileSystemProvider.readFile(t.uri);if(o)Object.defineProperty(t,"textDocument",{value:o});else{let n=this.createTextDocumentGetter(t.uri,s);Object.defineProperty(t,"textDocument",{get:n})}return i!==s&&(t.parseResult=await this.parseAsync(t.uri,s,n),t.parseResult.value.$document=t),t.state=X.Parsed,t}parse(t,n,i){return this.serviceRegistry.getServices(t).parser.LangiumParser.parse(n,i)}parseAsync(t,n,i){return this.serviceRegistry.getServices(t).parser.AsyncParser.parse(n,i)}createTextDocumentGetter(t,n){let i=this.serviceRegistry,o;return()=>o??=Kn.create(t.toString(),i.getServices(t).LanguageMetaData.languageId,0,n??``)}},DefaultLangiumDocuments=class{constructor(t){this.documentMap=new Map,this.langiumDocumentFactory=t.workspace.LangiumDocumentFactory,this.serviceRegistry=t.ServiceRegistry}get all(){return stream(this.documentMap.values())}addDocument(t){let n=t.uri.toString();if(this.documentMap.has(n))throw Error(`A document with the URI '${n}' is already present.`);this.documentMap.set(n,t)}getDocument(t){let n=t.toString();return this.documentMap.get(n)}async getOrCreateDocument(t,n){let i=this.getDocument(t);return i||(i=await this.langiumDocumentFactory.fromUri(t,n),this.addDocument(i),i)}createDocument(t,n,i){if(i)return this.langiumDocumentFactory.fromString(n,t,i).then(t=>(this.addDocument(t),t));{let i=this.langiumDocumentFactory.fromString(n,t);return this.addDocument(i),i}}hasDocument(t){return this.documentMap.has(t.toString())}invalidateDocument(t){let n=t.toString(),i=this.documentMap.get(n);return i&&(this.serviceRegistry.getServices(t).references.Linker.unlink(i),i.state=X.Changed,i.precomputedScopes=void 0,i.diagnostics=void 0),i}deleteDocument(t){let n=t.toString(),i=this.documentMap.get(n);return i&&(i.state=X.Changed,this.documentMap.delete(n)),i}};const qn=Symbol(`ref_resolving`);var DefaultLinker=class{constructor(t){this.reflection=t.shared.AstReflection,this.langiumDocuments=()=>t.shared.workspace.LangiumDocuments,this.scopeProvider=t.references.ScopeProvider,this.astNodeLocator=t.workspace.AstNodeLocator}async link(t,n=Y.CancellationToken.None){for(let i of streamAst(t.parseResult.value))await interruptAndCheck(n),streamReferences(i).forEach(n=>this.doLink(n,t))}doLink(t,n){let i=t.reference;if(i._ref===void 0){i._ref=qn;try{let n=this.getCandidate(t);isLinkingError(n)?i._ref=n:(i._nodeDescription=n,this.langiumDocuments().hasDocument(n.documentUri)?i._ref=this.loadAstNode(n)??this.createLinkingError(t,n):i._ref=void 0)}catch(n){console.error(`An error occurred while resolving reference to '${i.$refText}':`,n);let o=n.message??String(n);i._ref=Object.assign(Object.assign({},t),{message:`An error occurred while resolving reference to '${i.$refText}': ${o}`})}n.references.push(i)}}unlink(t){for(let n of t.references)delete n._ref,delete n._nodeDescription;t.references=[]}getCandidate(t){return this.scopeProvider.getScope(t).getElement(t.reference.$refText)??this.createLinkingError(t)}buildReference(t,n,i,o){let s=this,c={$refNode:i,$refText:o,get ref(){if(isAstNode(this._ref))return this._ref;if(isAstNodeDescription(this._nodeDescription)){let i=s.loadAstNode(this._nodeDescription);this._ref=i??s.createLinkingError({reference:c,container:t,property:n},this._nodeDescription)}else if(this._ref===void 0){this._ref=qn;let i=findRootNode(t).$document,o=s.getLinkedNode({reference:c,container:t,property:n});if(o.error&&i&&i.state<X.ComputedScopes){this._ref=void 0;return}this._ref=o.node??o.error,this._nodeDescription=o.descr,i?.references.push(this)}else if(this._ref===qn)throw Error(`Cyclic reference resolution detected: ${s.astNodeLocator.getAstNodePath(t)}/${n} (symbol '${o}')`);return isAstNode(this._ref)?this._ref:void 0},get $nodeDescription(){return this._nodeDescription},get error(){return isLinkingError(this._ref)?this._ref:void 0}};return c}getLinkedNode(t){try{let n=this.getCandidate(t);if(isLinkingError(n))return{error:n};let i=this.loadAstNode(n);return i?{node:i,descr:n}:{descr:n,error:this.createLinkingError(t,n)}}catch(n){console.error(`An error occurred while resolving reference to '${t.reference.$refText}':`,n);let i=n.message??String(n);return{error:Object.assign(Object.assign({},t),{message:`An error occurred while resolving reference to '${t.reference.$refText}': ${i}`})}}}loadAstNode(t){if(t.node)return t.node;let n=this.langiumDocuments().getDocument(t.documentUri);if(n)return this.astNodeLocator.getAstNode(n.parseResult.value,t.path)}createLinkingError(t,n){let i=findRootNode(t.container).$document;i&&i.state<X.ComputedScopes&&console.warn(`Attempted reference resolution before document reached ComputedScopes state (${i.uri}).`);let o=this.reflection.getReferenceType(t);return Object.assign(Object.assign({},t),{message:`Could not resolve reference to ${o} named '${t.reference.$refText}'.`,targetDescription:n})}};function isNamed(t){return typeof t.name==`string`}var DefaultNameProvider=class{getName(t){if(isNamed(t))return t.name}getNameNode(t){return findNodeForProperty(t.$cstNode,`name`)}},DefaultReferences=class{constructor(t){this.nameProvider=t.references.NameProvider,this.index=t.shared.workspace.IndexManager,this.nodeLocator=t.workspace.AstNodeLocator}findDeclaration(t){if(t){let n=findAssignment(t),i=t.astNode;if(n&&i){let o=i[n.feature];if(isReference(o))return o.ref;if(Array.isArray(o)){for(let n of o)if(isReference(n)&&n.$refNode&&n.$refNode.offset<=t.offset&&n.$refNode.end>=t.end)return n.ref}}if(i){let n=this.nameProvider.getNameNode(i);if(n&&(n===t||isChildNode(t,n)))return i}}}findDeclarationNode(t){let n=this.findDeclaration(t);if(n?.$cstNode)return this.nameProvider.getNameNode(n)??n.$cstNode}findReferences(t,n){let i=[];if(n.includeDeclaration){let n=this.getReferenceToSelf(t);n&&i.push(n)}let o=this.index.findAllReferences(t,this.nodeLocator.getAstNodePath(t));return n.documentUri&&(o=o.filter(t=>U.equals(t.sourceUri,n.documentUri))),i.push(...o),stream(i)}getReferenceToSelf(t){let n=this.nameProvider.getNameNode(t);if(n){let i=getDocument(t),o=this.nodeLocator.getAstNodePath(t);return{sourceUri:i.uri,sourcePath:o,targetUri:i.uri,targetPath:o,segment:toDocumentSegment(n),local:!0}}}},MultiMap=class{constructor(t){if(this.map=new Map,t)for(let[n,i]of t)this.add(n,i)}get size(){return nt.sum(stream(this.map.values()).map(t=>t.length))}clear(){this.map.clear()}delete(t,n){if(n===void 0)return this.map.delete(t);{let i=this.map.get(t);if(i){let o=i.indexOf(n);if(o>=0)return i.length===1?this.map.delete(t):i.splice(o,1),!0}return!1}}get(t){return this.map.get(t)??[]}has(t,n){if(n===void 0)return this.map.has(t);{let i=this.map.get(t);return i?i.indexOf(n)>=0:!1}}add(t,n){return this.map.has(t)?this.map.get(t).push(n):this.map.set(t,[n]),this}addAll(t,n){return this.map.has(t)?this.map.get(t).push(...n):this.map.set(t,Array.from(n)),this}forEach(t){this.map.forEach((n,i)=>n.forEach(n=>t(n,i,this)))}[Symbol.iterator](){return this.entries().iterator()}entries(){return stream(this.map.entries()).flatMap(([t,n])=>n.map(n=>[t,n]))}keys(){return stream(this.map.keys())}values(){return stream(this.map.values()).flat()}entriesGroupedByKey(){return stream(this.map.entries())}},BiMap=class{get size(){return this.map.size}constructor(t){if(this.map=new Map,this.inverse=new Map,t)for(let[n,i]of t)this.set(n,i)}clear(){this.map.clear(),this.inverse.clear()}set(t,n){return this.map.set(t,n),this.inverse.set(n,t),this}get(t){return this.map.get(t)}getKey(t){return this.inverse.get(t)}delete(t){let n=this.map.get(t);return n===void 0?!1:(this.map.delete(t),this.inverse.delete(n),!0)}},DefaultScopeComputation=class{constructor(t){this.nameProvider=t.references.NameProvider,this.descriptions=t.workspace.AstNodeDescriptionProvider}async computeExports(t,n=Y.CancellationToken.None){return this.computeExportsForNode(t.parseResult.value,t,void 0,n)}async computeExportsForNode(t,n,i=streamContents,o=Y.CancellationToken.None){let s=[];this.exportNode(t,s,n);for(let c of i(t))await interruptAndCheck(o),this.exportNode(c,s,n);return s}exportNode(t,n,i){let o=this.nameProvider.getName(t);o&&n.push(this.descriptions.createDescription(t,o,i))}async computeLocalScopes(t,n=Y.CancellationToken.None){let i=t.parseResult.value,o=new MultiMap;for(let s of streamAllContents(i))await interruptAndCheck(n),this.processNode(s,t,o);return o}processNode(t,n,i){let o=t.$container;if(o){let s=this.nameProvider.getName(t);s&&i.add(o,this.descriptions.createDescription(t,s,n))}}},StreamScope=class{constructor(t,n,i){this.elements=t,this.outerScope=n,this.caseInsensitive=i?.caseInsensitive??!1}getAllElements(){return this.outerScope?this.elements.concat(this.outerScope.getAllElements()):this.elements}getElement(t){let n=this.caseInsensitive?this.elements.find(n=>n.name.toLowerCase()===t.toLowerCase()):this.elements.find(n=>n.name===t);if(n)return n;if(this.outerScope)return this.outerScope.getElement(t)}},MapScope=class{constructor(t,n,i){this.elements=new Map,this.caseInsensitive=i?.caseInsensitive??!1;for(let n of t){let t=this.caseInsensitive?n.name.toLowerCase():n.name;this.elements.set(t,n)}this.outerScope=n}getElement(t){let n=this.caseInsensitive?t.toLowerCase():t,i=this.elements.get(n);if(i)return i;if(this.outerScope)return this.outerScope.getElement(t)}getAllElements(){let t=stream(this.elements.values());return this.outerScope&&(t=t.concat(this.outerScope.getAllElements())),t}};const Jn={getElement(){},getAllElements(){return tt}};var DisposableCache=class{constructor(){this.toDispose=[],this.isDisposed=!1}onDispose(t){this.toDispose.push(t)}dispose(){this.throwIfDisposed(),this.clear(),this.isDisposed=!0,this.toDispose.forEach(t=>t.dispose())}throwIfDisposed(){if(this.isDisposed)throw Error(`This cache has already been disposed`)}},SimpleCache=class extends DisposableCache{constructor(){super(...arguments),this.cache=new Map}has(t){return this.throwIfDisposed(),this.cache.has(t)}set(t,n){this.throwIfDisposed(),this.cache.set(t,n)}get(t,n){if(this.throwIfDisposed(),this.cache.has(t))return this.cache.get(t);if(n){let i=n();return this.cache.set(t,i),i}else return}delete(t){return this.throwIfDisposed(),this.cache.delete(t)}clear(){this.throwIfDisposed(),this.cache.clear()}},ContextCache=class extends DisposableCache{constructor(t){super(),this.cache=new Map,this.converter=t??(t=>t)}has(t,n){return this.throwIfDisposed(),this.cacheForContext(t).has(n)}set(t,n,i){this.throwIfDisposed(),this.cacheForContext(t).set(n,i)}get(t,n,i){this.throwIfDisposed();let o=this.cacheForContext(t);if(o.has(n))return o.get(n);if(i){let t=i();return o.set(n,t),t}else return}delete(t,n){return this.throwIfDisposed(),this.cacheForContext(t).delete(n)}clear(t){if(this.throwIfDisposed(),t){let n=this.converter(t);this.cache.delete(n)}else this.cache.clear()}cacheForContext(t){let n=this.converter(t),i=this.cache.get(n);return i||(i=new Map,this.cache.set(n,i)),i}},WorkspaceCache=class extends SimpleCache{constructor(t,n){super(),n?(this.toDispose.push(t.workspace.DocumentBuilder.onBuildPhase(n,()=>{this.clear()})),this.toDispose.push(t.workspace.DocumentBuilder.onUpdate((t,n)=>{n.length>0&&this.clear()}))):this.toDispose.push(t.workspace.DocumentBuilder.onUpdate(()=>{this.clear()}))}},DefaultScopeProvider=class{constructor(t){this.reflection=t.shared.AstReflection,this.nameProvider=t.references.NameProvider,this.descriptions=t.workspace.AstNodeDescriptionProvider,this.indexManager=t.shared.workspace.IndexManager,this.globalScopeCache=new WorkspaceCache(t.shared)}getScope(t){let n=[],i=this.reflection.getReferenceType(t),o=getDocument(t.container).precomputedScopes;if(o){let s=t.container;do{let t=o.get(s);t.length>0&&n.push(stream(t).filter(t=>this.reflection.isSubtype(t.type,i))),s=s.$container}while(s)}let s=this.getGlobalScope(i,t);for(let t=n.length-1;t>=0;t--)s=this.createScope(n[t],s);return s}createScope(t,n,i){return new StreamScope(stream(t),n,i)}createScopeForNodes(t,n,i){return new StreamScope(stream(t).map(t=>{let n=this.nameProvider.getName(t);if(n)return this.descriptions.createDescription(t,n)}).nonNullable(),n,i)}getGlobalScope(t,n){return this.globalScopeCache.get(t,()=>new MapScope(this.indexManager.allElements(t)))}};function isAstNodeWithComment(t){return typeof t.$comment==`string`}function isIntermediateReference(t){return typeof t==`object`&&!!t&&(`$ref`in t||`$error`in t)}var DefaultJsonSerializer=class{constructor(t){this.ignoreProperties=new Set([`$container`,`$containerProperty`,`$containerIndex`,`$document`,`$cstNode`]),this.langiumDocuments=t.shared.workspace.LangiumDocuments,this.astNodeLocator=t.workspace.AstNodeLocator,this.nameProvider=t.references.NameProvider,this.commentProvider=t.documentation.CommentProvider}serialize(t,n){let i=n??{},o=n?.replacer,defaultReplacer=(t,n)=>this.replacer(t,n,i),s=o?(t,n)=>o(t,n,defaultReplacer):defaultReplacer;try{return this.currentDocument=getDocument(t),JSON.stringify(t,s,n?.space)}finally{this.currentDocument=void 0}}deserialize(t,n){let i=n??{},o=JSON.parse(t);return this.linkNode(o,o,i),o}replacer(t,n,{refText:i,sourceText:o,textRegions:s,comments:c,uriConverter:u}){if(!this.ignoreProperties.has(t))if(isReference(n)){let t=n.ref,o=i?n.$refText:void 0;if(t){let i=getDocument(t),s=``;this.currentDocument&&this.currentDocument!==i&&(s=u?u(i.uri,n):i.uri.toString());let c=this.astNodeLocator.getAstNodePath(t);return{$ref:`${s}#${c}`,$refText:o}}else return{$error:n.error?.message??`Could not resolve reference`,$refText:o}}else if(isAstNode(n)){let i;if(s&&(i=this.addAstNodeRegionWithAssignmentsTo(Object.assign({},n)),(!t||n.$document)&&i?.$textRegion&&(i.$textRegion.documentURI=this.currentDocument?.uri.toString())),o&&!t&&(i??=Object.assign({},n),i.$sourceText=n.$cstNode?.text),c){i??=Object.assign({},n);let t=this.commentProvider.getComment(n);t&&(i.$comment=t.replace(/\r/g,``))}return i??n}else return n}addAstNodeRegionWithAssignmentsTo(t){let createDocumentSegment=t=>({offset:t.offset,end:t.end,length:t.length,range:t.range});if(t.$cstNode){let n=t.$textRegion=createDocumentSegment(t.$cstNode),i=n.assignments={};return Object.keys(t).filter(t=>!t.startsWith(`$`)).forEach(n=>{let o=findNodesForProperty(t.$cstNode,n).map(createDocumentSegment);o.length!==0&&(i[n]=o)}),t}}linkNode(t,n,i,o,s,c){for(let[o,s]of Object.entries(t))if(Array.isArray(s))for(let c=0;c<s.length;c++){let u=s[c];isIntermediateReference(u)?s[c]=this.reviveReference(t,o,n,u,i):isAstNode(u)&&this.linkNode(u,n,i,t,o,c)}else isIntermediateReference(s)?t[o]=this.reviveReference(t,o,n,s,i):isAstNode(s)&&this.linkNode(s,n,i,t,o);let u=t;u.$container=o,u.$containerProperty=s,u.$containerIndex=c}reviveReference(t,n,i,o,s){let c=o.$refText,u=o.$error;if(o.$ref){let t=this.getRefNode(i,o.$ref,s.uriConverter);if(isAstNode(t))return c||=this.nameProvider.getName(t),{$refText:c??``,ref:t};u=t}if(u){let i={$refText:c??``};return i.error={container:t,property:n,message:u,reference:i},i}else return}getRefNode(t,n,i){try{let o=n.indexOf(`#`);if(o===0)return this.astNodeLocator.getAstNode(t,n.substring(1))||`Could not resolve path: `+n;if(o<0){let t=i?i(n):H.parse(n),o=this.langiumDocuments.getDocument(t);return o?o.parseResult.value:`Could not find document for URI: `+n}let s=i?i(n.substring(0,o)):H.parse(n.substring(0,o)),c=this.langiumDocuments.getDocument(s);return c?o===n.length-1?c.parseResult.value:this.astNodeLocator.getAstNode(c.parseResult.value,n.substring(o+1))||`Could not resolve URI: `+n:`Could not find document for URI: `+n}catch(t){return String(t)}}},DefaultServiceRegistry=class{get map(){return this.fileExtensionMap}constructor(t){this.languageIdMap=new Map,this.fileExtensionMap=new Map,this.fileNameMap=new Map,this.textDocuments=t?.workspace.TextDocuments}register(t){let n=t.LanguageMetaData;for(let i of n.fileExtensions)this.fileExtensionMap.has(i)&&console.warn(`The file extension ${i} is used by multiple languages. It is now assigned to '${n.languageId}'.`),this.fileExtensionMap.set(i,t);if(n.fileNames)for(let i of n.fileNames)this.fileNameMap.has(i)&&console.warn(`The file name ${i} is used by multiple languages. It is now assigned to '${n.languageId}'.`),this.fileNameMap.set(i,t);this.languageIdMap.set(n.languageId,t),this.languageIdMap.size===1?this.singleton=t:this.singleton=void 0}getServices(t){if(this.singleton!==void 0)return this.singleton;if(this.languageIdMap.size===0)throw Error("The service registry is empty. Use `register` to register the services of a language.");let n=this.textDocuments?.get(t)?.languageId;if(n!==void 0){let t=this.languageIdMap.get(n);if(t)return t}let i=U.extname(t),o=U.basename(t),s=this.fileNameMap.get(o)??this.fileExtensionMap.get(i);if(!s)throw Error(n?`The service registry contains no services for the extension '${i}' for language '${n}'.`:`The service registry contains no services for the extension '${i}'.`);return s}hasServices(t){try{return this.getServices(t),!0}catch{return!1}}get all(){return Array.from(this.languageIdMap.values())}},Yn;(function(t){t.merge=(t,n)=>_merge(_merge({},t),n)})(Yn||={});function inject(t,n,i,o,s,c,u,f,p){return _inject([t,n,i,o,s,c,u,f,p].reduce(_merge,{}))}const Xn=Symbol(`isProxy`);function eagerLoad(t){if(t&&t[Xn])for(let n of Object.values(t))eagerLoad(n);return t}function _inject(t,n){let i=new Proxy({},{deleteProperty:()=>!1,set:()=>{throw Error(`Cannot set property on injected service container`)},get:(o,s)=>s===Xn||_resolve(o,s,t,n||i),getOwnPropertyDescriptor:(o,s)=>(_resolve(o,s,t,n||i),Object.getOwnPropertyDescriptor(o,s)),has:(n,i)=>i in t,ownKeys:()=>[...Object.getOwnPropertyNames(t)]});return i}const Zn=Symbol();function _resolve(t,n,i,o){if(n in t){if(t[n]instanceof Error)throw Error(`Construction failure. Please make sure that your dependencies are constructable.`,{cause:t[n]});if(t[n]===Zn)throw Error(`Cycle detected. Please make "`+String(n)+`" lazy. Visit https://langium.org/docs/reference/configuration-services/#resolving-cyclic-dependencies`);return t[n]}else if(n in i){let s=i[n];t[n]=Zn;try{t[n]=typeof s==`function`?s(o):_inject(s,o)}catch(i){throw t[n]=i instanceof Error?i:void 0,i}return t[n]}else return}function _merge(t,n){if(n){for(let[i,o]of Object.entries(n))if(o!==void 0){let n=t[i];n!==null&&o!==null&&typeof n==`object`&&typeof o==`object`?t[i]=_merge(n,o):t[i]=o}}return t}var DefaultCommentProvider=class{constructor(t){this.grammarConfig=()=>t.parser.GrammarConfig}getComment(t){return isAstNodeWithComment(t)?t.$comment:findCommentNode(t.$cstNode,this.grammarConfig().multilineCommentRules)?.text}};function parseJSDoc(t,n,i){let o,s;typeof t==`string`?(s=n,o=i):(s=t.range.start,o=n),s||=W.create(0,0);let c=getLines(t),u=normalizeOptions(o);return parseJSDocComment({index:0,tokens:tokenize({lines:c,position:s,options:u}),position:s})}function isJSDoc(t,n){let i=normalizeOptions(n),o=getLines(t);if(o.length===0)return!1;let s=o[0],c=o[o.length-1],u=i.start,f=i.end;return!!u?.exec(s)&&!!f?.exec(c)}function getLines(t){let n=``;return n=typeof t==`string`?t:t.text,n.split(at)}const Qn=/\s*(@([\p{L}][\p{L}\p{N}]*)?)/uy,$n=/\{(@[\p{L}][\p{L}\p{N}]*)(\s*)([^\r\n}]+)?\}/gu;function tokenize(t){let n=[],i=t.position.line,o=t.position.character;for(let s=0;s<t.lines.length;s++){let c=s===0,u=s===t.lines.length-1,f=t.lines[s],p=0;if(c&&t.options.start){let n=t.options.start?.exec(f);n&&(p=n.index+n[0].length)}else{let n=t.options.line?.exec(f);n&&(p=n.index+n[0].length)}if(u){let n=t.options.end?.exec(f);n&&(f=f.substring(0,n.index))}if(f=f.substring(0,lastCharacter(f)),skipWhitespace(f,p)>=f.length){if(n.length>0){let t=W.create(i,o);n.push({type:`break`,content:``,range:G.create(t,t)})}}else{Qn.lastIndex=p;let t=Qn.exec(f);if(t){let s=t[0],c=t[1],u=W.create(i,o+p),h=W.create(i,o+p+s.length);n.push({type:`tag`,content:c,range:G.create(u,h)}),p+=s.length,p=skipWhitespace(f,p)}if(p<f.length){let t=f.substring(p),s=Array.from(t.matchAll($n));n.push(...buildInlineTokens(s,t,i,o+p))}}i++,o=0}return n.length>0&&n[n.length-1].type===`break`?n.slice(0,-1):n}function buildInlineTokens(t,n,i,o){let s=[];if(t.length===0){let t=W.create(i,o),c=W.create(i,o+n.length);s.push({type:`text`,content:n,range:G.create(t,c)})}else{let c=0;for(let u of t){let t=u.index,f=n.substring(c,t);f.length>0&&s.push({type:`text`,content:n.substring(c,t),range:G.create(W.create(i,c+o),W.create(i,t+o))});let p=f.length+1,h=u[1];if(s.push({type:`inline-tag`,content:h,range:G.create(W.create(i,c+p+o),W.create(i,c+p+h.length+o))}),p+=h.length,u.length===4){p+=u[2].length;let t=u[3];s.push({type:`text`,content:t,range:G.create(W.create(i,c+p+o),W.create(i,c+p+t.length+o))})}else s.push({type:`text`,content:``,range:G.create(W.create(i,c+p+o),W.create(i,c+p+o))});c=t+u[0].length}let u=n.substring(c);u.length>0&&s.push({type:`text`,content:u,range:G.create(W.create(i,c+o),W.create(i,c+o+u.length))})}return s}const er=/\S/,tr=/\s*$/;function skipWhitespace(t,n){let i=t.substring(n).match(er);return i?n+i.index:t.length}function lastCharacter(t){let n=t.match(tr);if(n&&typeof n.index==`number`)return n.index}function parseJSDocComment(t){let n=W.create(t.position.line,t.position.character);if(t.tokens.length===0)return new JSDocCommentImpl([],G.create(n,n));let i=[];for(;t.index<t.tokens.length;){let n=parseJSDocElement(t,i[i.length-1]);n&&i.push(n)}let o=i[0]?.range.start??n,s=i[i.length-1]?.range.end??n;return new JSDocCommentImpl(i,G.create(o,s))}function parseJSDocElement(t,n){let i=t.tokens[t.index];if(i.type===`tag`)return parseJSDocTag(t,!1);if(i.type===`text`||i.type===`inline-tag`)return parseJSDocText(t);appendEmptyLine(i,n),t.index++}function appendEmptyLine(t,n){if(n){let i=new JSDocLineImpl(``,t.range);`inlines`in n?n.inlines.push(i):n.content.inlines.push(i)}}function parseJSDocText(t){let n=t.tokens[t.index],i=n,o=n,s=[];for(;n&&n.type!==`break`&&n.type!==`tag`;)s.push(parseJSDocInline(t)),o=n,n=t.tokens[t.index];return new JSDocTextImpl(s,G.create(i.range.start,o.range.end))}function parseJSDocInline(t){return t.tokens[t.index].type===`inline-tag`?parseJSDocTag(t,!0):parseJSDocLine(t)}function parseJSDocTag(t,n){let i=t.tokens[t.index++],o=i.content.substring(1);if(t.tokens[t.index]?.type===`text`)if(n){let s=parseJSDocLine(t);return new JSDocTagImpl(o,new JSDocTextImpl([s],s.range),n,G.create(i.range.start,s.range.end))}else{let s=parseJSDocText(t);return new JSDocTagImpl(o,s,n,G.create(i.range.start,s.range.end))}else{let t=i.range;return new JSDocTagImpl(o,new JSDocTextImpl([],t),n,t)}}function parseJSDocLine(t){let n=t.tokens[t.index++];return new JSDocLineImpl(n.content,n.range)}function normalizeOptions(t){if(!t)return normalizeOptions({start:`/**`,end:`*/`,line:`*`});let{start:n,end:i,line:o}=t;return{start:normalizeOption(n,!0),end:normalizeOption(i,!1),line:normalizeOption(o,!0)}}function normalizeOption(t,n){if(typeof t==`string`||typeof t==`object`){let i=typeof t==`string`?escapeRegExp(t):t.source;return RegExp(n?`^\\s*${i}`:`\\s*${i}\\s*$`)}else return t}var JSDocCommentImpl=class{constructor(t,n){this.elements=t,this.range=n}getTag(t){return this.getAllTags().find(n=>n.name===t)}getTags(t){return this.getAllTags().filter(n=>n.name===t)}getAllTags(){return this.elements.filter(t=>`name`in t)}toString(){let t=``;for(let n of this.elements)if(t.length===0)t=n.toString();else{let i=n.toString();t+=fillNewlines(t)+i}return t.trim()}toMarkdown(t){let n=``;for(let i of this.elements)if(n.length===0)n=i.toMarkdown(t);else{let o=i.toMarkdown(t);n+=fillNewlines(n)+o}return n.trim()}},JSDocTagImpl=class{constructor(t,n,i,o){this.name=t,this.content=n,this.inline=i,this.range=o}toString(){let t=`@${this.name}`,n=this.content.toString();return this.content.inlines.length===1?t=`${t} ${n}`:this.content.inlines.length>1&&(t=`${t}\n${n}`),this.inline?`{${t}}`:t}toMarkdown(t){return(t?.renderTag)?.call(t,this)??this.toMarkdownDefault(t)}toMarkdownDefault(t){let n=this.content.toMarkdown(t);if(this.inline){let i=renderInlineTag(this.name,n,t??{});if(typeof i==`string`)return i}let i=``;t?.tag===`italic`||t?.tag===void 0?i=`*`:t?.tag===`bold`?i=`**`:t?.tag===`bold-italic`&&(i=`***`);let o=`${i}@${this.name}${i}`;return this.content.inlines.length===1?o=`${o} — ${n}`:this.content.inlines.length>1&&(o=`${o}\n${n}`),this.inline?`{${o}}`:o}};function renderInlineTag(t,n,i){if(t===`linkplain`||t===`linkcode`||t===`link`){let o=n.indexOf(` `),s=n;if(o>0){let t=skipWhitespace(n,o);s=n.substring(t),n=n.substring(0,o)}return(t===`linkcode`||t===`link`&&i.link===`code`)&&(s=`\`${s}\``),i.renderLink?.call(i,n,s)??renderLinkDefault(n,s)}}function renderLinkDefault(t,n){try{return H.parse(t,!0),`[${n}](${t})`}catch{return t}}var JSDocTextImpl=class{constructor(t,n){this.inlines=t,this.range=n}toString(){let t=``;for(let n=0;n<this.inlines.length;n++){let i=this.inlines[n],o=this.inlines[n+1];t+=i.toString(),o&&o.range.start.line>i.range.start.line&&(t+=`
8
- `)}return t}toMarkdown(t){let n=``;for(let i=0;i<this.inlines.length;i++){let o=this.inlines[i],s=this.inlines[i+1];n+=o.toMarkdown(t),s&&s.range.start.line>o.range.start.line&&(n+=`
9
- `)}return n}},JSDocLineImpl=class{constructor(t,n){this.text=t,this.range=n}toString(){return this.text}toMarkdown(){return this.text}};function fillNewlines(t){return t.endsWith(`
10
- `)?`
11
- `:`
12
-
13
- `}var JSDocDocumentationProvider=class{constructor(t){this.indexManager=t.shared.workspace.IndexManager,this.commentProvider=t.documentation.CommentProvider}getDocumentation(t){let n=this.commentProvider.getComment(t);if(n&&isJSDoc(n))return parseJSDoc(n).toMarkdown({renderLink:(n,i)=>this.documentationLinkRenderer(t,n,i),renderTag:n=>this.documentationTagRenderer(t,n)})}documentationLinkRenderer(t,n,i){let o=this.findNameInPrecomputedScopes(t,n)??this.findNameInGlobalScope(t,n);if(o&&o.nameSegment){let t=o.nameSegment.range.start.line+1,n=o.nameSegment.range.start.character+1;return`[${i}](${o.documentUri.with({fragment:`L${t},${n}`}).toString()})`}else return}documentationTagRenderer(t,n){}findNameInPrecomputedScopes(t,n){let i=getDocument(t).precomputedScopes;if(!i)return;let o=t;do{let t=i.get(o).find(t=>t.name===n);if(t)return t;o=o.$container}while(o)}findNameInGlobalScope(t,n){return this.indexManager.allElements().find(t=>t.name===n)}},nr=i({});n(nr,t(Vn(),1));var DefaultAsyncParser=class{constructor(t){this.syncParser=t.parser.LangiumParser}parse(t,n){return Promise.resolve(this.syncParser.parse(t))}},DefaultLexerErrorMessageProvider=class{buildUnexpectedCharactersMessage(t,n,i,o,s){return S.buildUnexpectedCharactersMessage(t,n,i,o,s)}buildUnableToPopLexerModeMessage(t){return S.buildUnableToPopLexerModeMessage(t)}};const rr={mode:`full`};var DefaultLexer=class{constructor(t){this.errorMessageProvider=t.parser.LexerErrorMessageProvider,this.tokenBuilder=t.parser.TokenBuilder;let n=this.tokenBuilder.buildTokens(t.Grammar,{caseInsensitive:t.LanguageMetaData.caseInsensitive});this.tokenTypes=this.toTokenTypeDictionary(n);let i=isTokenTypeDictionary(n)?Object.values(n):n,o=t.LanguageMetaData.mode===`production`;this.chevrotainLexer=new p(i,{positionTracking:`full`,skipValidations:o,errorMessageProvider:this.errorMessageProvider})}get definition(){return this.tokenTypes}tokenize(t,n=rr){var i;let o=this.chevrotainLexer.tokenize(t);return{tokens:o.tokens,errors:o.errors,hidden:o.groups.hidden??[],report:(i=this.tokenBuilder).flushLexingReport?.call(i,t)}}toTokenTypeDictionary(t){if(isTokenTypeDictionary(t))return t;let n=isIMultiModeLexerDefinition(t)?Object.values(t.modes).flat():t,i={};return n.forEach(t=>i[t.name]=t),i}};function isTokenTypeArray(t){return Array.isArray(t)&&(t.length===0||`name`in t[0])}function isIMultiModeLexerDefinition(t){return t&&`modes`in t&&`defaultMode`in t}function isTokenTypeDictionary(t){return!isTokenTypeArray(t)&&!isIMultiModeLexerDefinition(t)}var DefaultHydrator=class{constructor(t){this.grammarElementIdMap=new BiMap,this.tokenTypeIdMap=new BiMap,this.grammar=t.Grammar,this.lexer=t.parser.Lexer,this.linker=t.references.Linker}dehydrate(t){return{lexerErrors:t.lexerErrors,lexerReport:t.lexerReport?this.dehydrateLexerReport(t.lexerReport):void 0,parserErrors:t.parserErrors.map(t=>Object.assign(Object.assign({},t),{message:t.message})),value:this.dehydrateAstNode(t.value,this.createDehyrationContext(t.value))}}dehydrateLexerReport(t){return t}createDehyrationContext(t){let n=new Map,i=new Map;for(let i of streamAst(t))n.set(i,{});if(t.$cstNode)for(let n of streamCst(t.$cstNode))i.set(n,{});return{astNodes:n,cstNodes:i}}dehydrateAstNode(t,n){let i=n.astNodes.get(t);i.$type=t.$type,i.$containerIndex=t.$containerIndex,i.$containerProperty=t.$containerProperty,t.$cstNode!==void 0&&(i.$cstNode=this.dehydrateCstNode(t.$cstNode,n));for(let[o,s]of Object.entries(t))if(!o.startsWith(`$`))if(Array.isArray(s)){let t=[];i[o]=t;for(let i of s)isAstNode(i)?t.push(this.dehydrateAstNode(i,n)):isReference(i)?t.push(this.dehydrateReference(i,n)):t.push(i)}else isAstNode(s)?i[o]=this.dehydrateAstNode(s,n):isReference(s)?i[o]=this.dehydrateReference(s,n):s!==void 0&&(i[o]=s);return i}dehydrateReference(t,n){let i={};return i.$refText=t.$refText,t.$refNode&&(i.$refNode=n.cstNodes.get(t.$refNode)),i}dehydrateCstNode(t,n){let i=n.cstNodes.get(t);return isRootCstNode(t)?i.fullText=t.fullText:i.grammarSource=this.getGrammarElementId(t.grammarSource),i.hidden=t.hidden,i.astNode=n.astNodes.get(t.astNode),isCompositeCstNode(t)?i.content=t.content.map(t=>this.dehydrateCstNode(t,n)):isLeafCstNode(t)&&(i.tokenType=t.tokenType.name,i.offset=t.offset,i.length=t.length,i.startLine=t.range.start.line,i.startColumn=t.range.start.character,i.endLine=t.range.end.line,i.endColumn=t.range.end.character),i}hydrate(t){let n=t.value,i=this.createHydrationContext(n);return`$cstNode`in n&&this.hydrateCstNode(n.$cstNode,i),{lexerErrors:t.lexerErrors,lexerReport:t.lexerReport,parserErrors:t.parserErrors,value:this.hydrateAstNode(n,i)}}createHydrationContext(t){let n=new Map,i=new Map;for(let i of streamAst(t))n.set(i,{});let o;if(t.$cstNode)for(let n of streamCst(t.$cstNode)){let t;`fullText`in n?(t=new RootCstNodeImpl(n.fullText),o=t):`content`in n?t=new CompositeCstNodeImpl:`tokenType`in n&&(t=this.hydrateCstLeafNode(n)),t&&(i.set(n,t),t.root=o)}return{astNodes:n,cstNodes:i}}hydrateAstNode(t,n){let i=n.astNodes.get(t);i.$type=t.$type,i.$containerIndex=t.$containerIndex,i.$containerProperty=t.$containerProperty,t.$cstNode&&(i.$cstNode=n.cstNodes.get(t.$cstNode));for(let[o,s]of Object.entries(t))if(!o.startsWith(`$`))if(Array.isArray(s)){let t=[];i[o]=t;for(let c of s)isAstNode(c)?t.push(this.setParent(this.hydrateAstNode(c,n),i)):isReference(c)?t.push(this.hydrateReference(c,i,o,n)):t.push(c)}else isAstNode(s)?i[o]=this.setParent(this.hydrateAstNode(s,n),i):isReference(s)?i[o]=this.hydrateReference(s,i,o,n):s!==void 0&&(i[o]=s);return i}setParent(t,n){return t.$container=n,t}hydrateReference(t,n,i,o){return this.linker.buildReference(n,i,o.cstNodes.get(t.$refNode),t.$refText)}hydrateCstNode(t,n,i=0){let o=n.cstNodes.get(t);if(typeof t.grammarSource==`number`&&(o.grammarSource=this.getGrammarElement(t.grammarSource)),o.astNode=n.astNodes.get(t.astNode),isCompositeCstNode(o))for(let s of t.content){let t=this.hydrateCstNode(s,n,i++);o.content.push(t)}return o}hydrateCstLeafNode(t){let n=this.getTokenType(t.tokenType),i=t.offset,o=t.length,s=t.startLine,c=t.startColumn,u=t.endLine,f=t.endColumn,p=t.hidden;return new LeafCstNodeImpl(i,o,{start:{line:s,character:c},end:{line:u,character:f}},n,p)}getTokenType(t){return this.lexer.definition[t]}getGrammarElementId(t){if(t)return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.get(t)}getGrammarElement(t){return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.getKey(t)}createGrammarElementIdMap(){let t=0;for(let n of streamAst(this.grammar))isAbstractElement(n)&&this.grammarElementIdMap.set(n,t++)}},ir;(function(t){function create(t){return{dispose:async()=>await t()}}t.create=create})(ir||={});var EmptyFileSystemProvider=class{readFile(){throw Error(`No file system is available.`)}async readDirectory(){return[]}};const ar={fileSystemProvider:()=>new EmptyFileSystemProvider},or={Grammar:()=>void 0,LanguageMetaData:()=>({caseInsensitive:!1,fileExtensions:[`.langium`],languageId:`langium`})},sr={AstReflection:()=>new LangiumGrammarAstReflection};function createMinimalGrammarServices(){let t=inject(createDefaultSharedCoreModule(ar),sr),n=inject(createDefaultCoreModule({shared:t}),or);return t.ServiceRegistry.register(n),n}function loadGrammarFromJson(t){let n=createMinimalGrammarServices(),i=n.serializer.JsonSerializer.deserialize(t);return n.shared.workspace.LangiumDocumentFactory.fromModel(i,H.parse(`memory://${i.name??`grammar`}.langium`)),i}var DefaultAstNodeDescriptionProvider=class{constructor(t){this.astNodeLocator=t.workspace.AstNodeLocator,this.nameProvider=t.references.NameProvider}createDescription(t,n,i){let o=i??getDocument(t);n??=this.nameProvider.getName(t);let s=this.astNodeLocator.getAstNodePath(t);if(!n)throw Error(`Node at path ${s} has no name.`);let c,nameSegmentGetter=()=>c??=toDocumentSegment(this.nameProvider.getNameNode(t)??t.$cstNode);return{node:t,name:n,get nameSegment(){return nameSegmentGetter()},selectionSegment:toDocumentSegment(t.$cstNode),type:t.$type,documentUri:o.uri,path:s}}},DefaultReferenceDescriptionProvider=class{constructor(t){this.nodeLocator=t.workspace.AstNodeLocator}async createDescriptions(t,n=Y.CancellationToken.None){let i=[],o=t.parseResult.value;for(let t of streamAst(o))await interruptAndCheck(n),streamReferences(t).filter(t=>!isLinkingError(t)).forEach(t=>{let n=this.createDescription(t);n&&i.push(n)});return i}createDescription(t){let n=t.reference.$nodeDescription,i=t.reference.$refNode;if(!n||!i)return;let o=getDocument(t.container).uri;return{sourceUri:o,sourcePath:this.nodeLocator.getAstNodePath(t.container),targetUri:n.documentUri,targetPath:n.path,segment:toDocumentSegment(i),local:U.equals(n.documentUri,o)}}},DefaultAstNodeLocator=class{constructor(){this.segmentSeparator=`/`,this.indexSeparator=`@`}getAstNodePath(t){if(t.$container){let n=this.getAstNodePath(t.$container),i=this.getPathSegment(t);return n+this.segmentSeparator+i}return``}getPathSegment({$containerProperty:t,$containerIndex:n}){if(!t)throw Error(`Missing '$containerProperty' in AST node.`);return n===void 0?t:t+this.indexSeparator+n}getAstNode(t,n){return n.split(this.segmentSeparator).reduce((t,n)=>{if(!t||n.length===0)return t;let i=n.indexOf(this.indexSeparator);if(i>0){let o=n.substring(0,i),s=parseInt(n.substring(i+1));return t[o]?.[s]}return t[n]},t)}},DefaultConfigurationProvider=class{constructor(t){this._ready=new Deferred,this.settings={},this.workspaceConfig=!1,this.onConfigurationSectionUpdateEmitter=new nr.Emitter,this.serviceRegistry=t.ServiceRegistry}get ready(){return this._ready.promise}initialize(t){this.workspaceConfig=t.capabilities.workspace?.configuration??!1}async initialized(t){if(this.workspaceConfig){if(t.register){let n=this.serviceRegistry.all;t.register({section:n.map(t=>this.toSectionName(t.LanguageMetaData.languageId))})}if(t.fetchConfiguration){let n=this.serviceRegistry.all.map(t=>({section:this.toSectionName(t.LanguageMetaData.languageId)})),i=await t.fetchConfiguration(n);n.forEach((t,n)=>{this.updateSectionConfiguration(t.section,i[n])})}}this._ready.resolve()}updateConfiguration(t){t.settings&&Object.keys(t.settings).forEach(n=>{let i=t.settings[n];this.updateSectionConfiguration(n,i),this.onConfigurationSectionUpdateEmitter.fire({section:n,configuration:i})})}updateSectionConfiguration(t,n){this.settings[t]=n}async getConfiguration(t,n){await this.ready;let i=this.toSectionName(t);if(this.settings[i])return this.settings[i][n]}toSectionName(t){return`${t}`}get onConfigurationSectionUpdate(){return this.onConfigurationSectionUpdateEmitter.event}},DefaultDocumentBuilder=class{constructor(t){this.updateBuildOptions={validation:{categories:[`built-in`,`fast`]}},this.updateListeners=[],this.buildPhaseListeners=new MultiMap,this.documentPhaseListeners=new MultiMap,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=X.Changed,this.langiumDocuments=t.workspace.LangiumDocuments,this.langiumDocumentFactory=t.workspace.LangiumDocumentFactory,this.textDocuments=t.workspace.TextDocuments,this.indexManager=t.workspace.IndexManager,this.serviceRegistry=t.ServiceRegistry}async build(t,n={},i=Y.CancellationToken.None){for(let i of t){let t=i.uri.toString();if(i.state===X.Validated){if(typeof n.validation==`boolean`&&n.validation)i.state=X.IndexedReferences,i.diagnostics=void 0,this.buildState.delete(t);else if(typeof n.validation==`object`){let o=this.buildState.get(t),s=o?.result?.validationChecks;if(s){let c=(n.validation.categories??cr.all).filter(t=>!s.includes(t));c.length>0&&(this.buildState.set(t,{completed:!1,options:{validation:Object.assign(Object.assign({},n.validation),{categories:c})},result:o.result}),i.state=X.IndexedReferences)}}}else this.buildState.delete(t)}this.currentState=X.Changed,await this.emitUpdate(t.map(t=>t.uri),[]),await this.buildDocuments(t,n,i)}async update(t,n,i=Y.CancellationToken.None){this.currentState=X.Changed;for(let t of n)this.langiumDocuments.deleteDocument(t),this.buildState.delete(t.toString()),this.indexManager.remove(t);for(let n of t){if(!this.langiumDocuments.invalidateDocument(n)){let t=this.langiumDocumentFactory.fromModel({$type:`INVALID`},n);t.state=X.Changed,this.langiumDocuments.addDocument(t)}this.buildState.delete(n.toString())}let o=stream(t).concat(n).map(t=>t.toString()).toSet();this.langiumDocuments.all.filter(t=>!o.has(t.uri.toString())&&this.shouldRelink(t,o)).forEach(t=>{this.serviceRegistry.getServices(t.uri).references.Linker.unlink(t),t.state=Math.min(t.state,X.ComputedScopes),t.diagnostics=void 0}),await this.emitUpdate(t,n),await interruptAndCheck(i);let s=this.sortDocuments(this.langiumDocuments.all.filter(t=>t.state<X.Linked||!this.buildState.get(t.uri.toString())?.completed).toArray());await this.buildDocuments(s,this.updateBuildOptions,i)}async emitUpdate(t,n){await Promise.all(this.updateListeners.map(i=>i(t,n)))}sortDocuments(t){let n=0,i=t.length-1;for(;n<i;){for(;n<t.length&&this.hasTextDocument(t[n]);)n++;for(;i>=0&&!this.hasTextDocument(t[i]);)i--;n<i&&([t[n],t[i]]=[t[i],t[n]])}return t}hasTextDocument(t){return!!this.textDocuments?.get(t.uri)}shouldRelink(t,n){return t.references.some(t=>t.error!==void 0)?!0:this.indexManager.isAffected(t,n)}onUpdate(t){return this.updateListeners.push(t),ir.create(()=>{let n=this.updateListeners.indexOf(t);n>=0&&this.updateListeners.splice(n,1)})}async buildDocuments(t,n,i){this.prepareBuild(t,n),await this.runCancelable(t,X.Parsed,i,t=>this.langiumDocumentFactory.update(t,i)),await this.runCancelable(t,X.IndexedContent,i,t=>this.indexManager.updateContent(t,i)),await this.runCancelable(t,X.ComputedScopes,i,async t=>{t.precomputedScopes=await this.serviceRegistry.getServices(t.uri).references.ScopeComputation.computeLocalScopes(t,i)});let o=t.filter(t=>this.shouldLink(t));await this.runCancelable(o,X.Linked,i,t=>this.serviceRegistry.getServices(t.uri).references.Linker.link(t,i)),await this.runCancelable(o,X.IndexedReferences,i,t=>this.indexManager.updateReferences(t,i));let s=t.filter(t=>this.shouldValidate(t));await this.runCancelable(s,X.Validated,i,t=>this.validate(t,i));for(let n of t){let t=this.buildState.get(n.uri.toString());t&&(t.completed=!0)}}prepareBuild(t,n){for(let i of t){let t=i.uri.toString(),o=this.buildState.get(t);(!o||o.completed)&&this.buildState.set(t,{completed:!1,options:n,result:o?.result})}}async runCancelable(t,n,i,o){let s=t.filter(t=>t.state<n);for(let t of s)await interruptAndCheck(i),await o(t),t.state=n,await this.notifyDocumentPhase(t,n,i);let c=t.filter(t=>t.state===n);await this.notifyBuildPhase(c,n,i),this.currentState=n}onBuildPhase(t,n){return this.buildPhaseListeners.add(t,n),ir.create(()=>{this.buildPhaseListeners.delete(t,n)})}onDocumentPhase(t,n){return this.documentPhaseListeners.add(t,n),ir.create(()=>{this.documentPhaseListeners.delete(t,n)})}waitUntil(t,n,i){let o;if(n&&`path`in n?o=n:i=n,i??=Y.CancellationToken.None,o){let n=this.langiumDocuments.getDocument(o);if(n&&n.state>=t)return Promise.resolve(o)}return this.currentState>=t?Promise.resolve(void 0):i.isCancellationRequested?Promise.reject(Wn):new Promise((n,s)=>{let c=this.onBuildPhase(t,()=>{c.dispose(),u.dispose(),n(o?this.langiumDocuments.getDocument(o)?.uri:void 0)}),u=i.onCancellationRequested(()=>{c.dispose(),u.dispose(),s(Wn)})})}async notifyDocumentPhase(t,n,i){let o=this.documentPhaseListeners.get(n).slice();for(let n of o)try{await n(t,i)}catch(t){if(!isOperationCancelled(t))throw t}}async notifyBuildPhase(t,n,i){if(t.length===0)return;let o=this.buildPhaseListeners.get(n).slice();for(let n of o)await interruptAndCheck(i),await n(t,i)}shouldLink(t){return this.getBuildOptions(t).eagerLinking??!0}shouldValidate(t){return!!this.getBuildOptions(t).validation}async validate(t,n){let i=this.serviceRegistry.getServices(t.uri).validation.DocumentValidator,o=this.getBuildOptions(t).validation,s=typeof o==`object`?o:void 0,c=await i.validateDocument(t,s,n);t.diagnostics?t.diagnostics.push(...c):t.diagnostics=c;let u=this.buildState.get(t.uri.toString());if(u){u.result??={};let t=s?.categories??cr.all;u.result.validationChecks?u.result.validationChecks.push(...t):u.result.validationChecks=[...t]}}getBuildOptions(t){return this.buildState.get(t.uri.toString())?.options??{}}},DefaultIndexManager=class{constructor(t){this.symbolIndex=new Map,this.symbolByTypeIndex=new ContextCache,this.referenceIndex=new Map,this.documents=t.workspace.LangiumDocuments,this.serviceRegistry=t.ServiceRegistry,this.astReflection=t.AstReflection}findAllReferences(t,n){let i=getDocument(t).uri,o=[];return this.referenceIndex.forEach(t=>{t.forEach(t=>{U.equals(t.targetUri,i)&&t.targetPath===n&&o.push(t)})}),stream(o)}allElements(t,n){let i=stream(this.symbolIndex.keys());return n&&(i=i.filter(t=>!n||n.has(t))),i.map(n=>this.getFileDescriptions(n,t)).flat()}getFileDescriptions(t,n){return n?this.symbolByTypeIndex.get(t,n,()=>(this.symbolIndex.get(t)??[]).filter(t=>this.astReflection.isSubtype(t.type,n))):this.symbolIndex.get(t)??[]}remove(t){let n=t.toString();this.symbolIndex.delete(n),this.symbolByTypeIndex.clear(n),this.referenceIndex.delete(n)}async updateContent(t,n=Y.CancellationToken.None){let i=await this.serviceRegistry.getServices(t.uri).references.ScopeComputation.computeExports(t,n),o=t.uri.toString();this.symbolIndex.set(o,i),this.symbolByTypeIndex.clear(o)}async updateReferences(t,n=Y.CancellationToken.None){let i=await this.serviceRegistry.getServices(t.uri).workspace.ReferenceDescriptionProvider.createDescriptions(t,n);this.referenceIndex.set(t.uri.toString(),i)}isAffected(t,n){let i=this.referenceIndex.get(t.uri.toString());return i?i.some(t=>!t.local&&n.has(t.targetUri.toString())):!1}},DefaultWorkspaceLock=class{constructor(){this.previousTokenSource=new Y.CancellationTokenSource,this.writeQueue=[],this.readQueue=[],this.done=!0}write(t){this.cancelWrite();let n=startCancelableOperation();return this.previousTokenSource=n,this.enqueue(this.writeQueue,t,n.token)}read(t){return this.enqueue(this.readQueue,t)}enqueue(t,n,i=Y.CancellationToken.None){let o=new Deferred,s={action:n,deferred:o,cancellationToken:i};return t.push(s),this.performNextOperation(),o.promise}async performNextOperation(){if(!this.done)return;let t=[];if(this.writeQueue.length>0)t.push(this.writeQueue.shift());else if(this.readQueue.length>0)t.push(...this.readQueue.splice(0,this.readQueue.length));else return;this.done=!1,await Promise.all(t.map(async({action:t,deferred:n,cancellationToken:i})=>{try{let o=await Promise.resolve().then(()=>t(i));n.resolve(o)}catch(t){isOperationCancelled(t)?n.resolve(void 0):n.reject(t)}})),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}},DefaultWorkspaceManager=class{constructor(t){this.initialBuildOptions={},this._ready=new Deferred,this.serviceRegistry=t.ServiceRegistry,this.langiumDocuments=t.workspace.LangiumDocuments,this.documentBuilder=t.workspace.DocumentBuilder,this.fileSystemProvider=t.workspace.FileSystemProvider,this.mutex=t.workspace.WorkspaceLock}get ready(){return this._ready.promise}get workspaceFolders(){return this.folders}initialize(t){this.folders=t.workspaceFolders??void 0}initialized(t){return this.mutex.write(t=>this.initializeWorkspace(this.folders??[],t))}async initializeWorkspace(t,n=Y.CancellationToken.None){let i=await this.performStartup(t);await interruptAndCheck(n),await this.documentBuilder.build(i,this.initialBuildOptions,n)}async performStartup(t){let n=this.serviceRegistry.all.flatMap(t=>t.LanguageMetaData.fileExtensions),i=this.serviceRegistry.all.flatMap(t=>t.LanguageMetaData.fileNames??[]),o=[],collector=t=>{o.push(t),this.langiumDocuments.hasDocument(t.uri)||this.langiumDocuments.addDocument(t)};return await this.loadAdditionalDocuments(t,collector),await Promise.all(t.map(t=>[t,this.getRootFolder(t)]).map(async t=>this.traverseFolder(...t,{fileExtensions:n,fileNames:i},collector))),this._ready.resolve(),o}loadAdditionalDocuments(t,n){return Promise.resolve()}getRootFolder(t){return H.parse(t.uri)}async traverseFolder(t,n,i,o){let s=await this.fileSystemProvider.readDirectory(n);await Promise.all(s.map(async n=>{this.includeEntry(t,n,i)&&(n.isDirectory?await this.traverseFolder(t,n.uri,i,o):n.isFile&&o(await this.langiumDocuments.getOrCreateDocument(n.uri)))}))}includeEntry(t,n,i){let o=U.basename(n.uri);return o.startsWith(`.`)?!1:n.isDirectory?o!==`node_modules`&&o!==`out`:n.isFile?i.fileExtensions.includes(U.extname(n.uri))||i.fileNames.includes(U.basename(n.uri)):!1}};function diagnosticData(t){return{code:t}}var cr;(function(t){t.all=[`fast`,`slow`,`built-in`]})(cr||={});var ValidationRegistry=class{constructor(t){this.entries=new MultiMap,this.entriesBefore=[],this.entriesAfter=[],this.reflection=t.shared.AstReflection}register(t,n=this,i=`fast`){if(i===`built-in`)throw Error(`The 'built-in' category is reserved for lexer, parser, and linker errors.`);for(let[o,s]of Object.entries(t)){let t=s;if(Array.isArray(t))for(let s of t){let t={check:this.wrapValidationException(s,n),category:i};this.addEntry(o,t)}else if(typeof t==`function`){let s={check:this.wrapValidationException(t,n),category:i};this.addEntry(o,s)}else assertUnreachable(t)}}wrapValidationException(t,n){return async(i,o,s)=>{await this.handleException(()=>t.call(n,i,o,s),`An error occurred during validation`,o,i)}}async handleException(t,n,i,o){try{await t()}catch(t){if(isOperationCancelled(t))throw t;console.error(`${n}:`,t),t instanceof Error&&t.stack&&console.error(t.stack),i(`error`,`${n}: ${t instanceof Error?t.message:String(t)}`,{node:o})}}addEntry(t,n){if(t===`AstNode`){this.entries.add(`AstNode`,n);return}for(let i of this.reflection.getAllSubTypes(t))this.entries.add(i,n)}getChecks(t,n){let i=stream(this.entries.get(t)).concat(this.entries.get(`AstNode`));return n&&(i=i.filter(t=>n.includes(t.category))),i.map(t=>t.check)}registerBeforeDocument(t,n=this){this.entriesBefore.push(this.wrapPreparationException(t,`An error occurred during set-up of the validation`,n))}registerAfterDocument(t,n=this){this.entriesAfter.push(this.wrapPreparationException(t,`An error occurred during tear-down of the validation`,n))}wrapPreparationException(t,n,i){return async(o,s,c,u)=>{await this.handleException(()=>t.call(i,o,s,c,u),n,s,o)}}get checksBefore(){return this.entriesBefore}get checksAfter(){return this.entriesAfter}},DefaultDocumentValidator=class{constructor(t){this.validationRegistry=t.validation.ValidationRegistry,this.metadata=t.LanguageMetaData}async validateDocument(t,n={},i=Y.CancellationToken.None){let o=t.parseResult,s=[];if(await interruptAndCheck(i),(!n.categories||n.categories.includes(`built-in`))&&(this.processLexingErrors(o,s,n),n.stopAfterLexingErrors&&s.some(t=>t.data?.code===Z.LexingError)||(this.processParsingErrors(o,s,n),n.stopAfterParsingErrors&&s.some(t=>t.data?.code===Z.ParsingError))||(this.processLinkingErrors(t,s,n),n.stopAfterLinkingErrors&&s.some(t=>t.data?.code===Z.LinkingError))))return s;try{s.push(...await this.validateAst(o.value,n,i))}catch(t){if(isOperationCancelled(t))throw t;console.error(`An error occurred during validation:`,t)}return await interruptAndCheck(i),s}processLexingErrors(t,n,i){let o=[...t.lexerErrors,...t.lexerReport?.diagnostics??[]];for(let t of o){let i=t.severity??`error`,o={severity:toDiagnosticSeverity(i),range:{start:{line:t.line-1,character:t.column-1},end:{line:t.line-1,character:t.column+t.length-1}},message:t.message,data:toDiagnosticData(i),source:this.getSource()};n.push(o)}}processParsingErrors(t,n,i){for(let i of t.parserErrors){let t;if(isNaN(i.token.startOffset)){if(`previousToken`in i){let n=i.previousToken;if(isNaN(n.startOffset)){let n={line:0,character:0};t={start:n,end:n}}else{let i={line:n.endLine-1,character:n.endColumn};t={start:i,end:i}}}}else t=tokenToRange(i.token);if(t){let o={severity:toDiagnosticSeverity(`error`),range:t,message:i.message,data:diagnosticData(Z.ParsingError),source:this.getSource()};n.push(o)}}}processLinkingErrors(t,n,i){for(let i of t.references){let t=i.error;if(t){let i={node:t.container,property:t.property,index:t.index,data:{code:Z.LinkingError,containerType:t.container.$type,property:t.property,refText:t.reference.$refText}};n.push(this.toDiagnostic(`error`,t.message,i))}}}async validateAst(t,n,i=Y.CancellationToken.None){let o=[],acceptor=(t,n,i)=>{o.push(this.toDiagnostic(t,n,i))};return await this.validateAstBefore(t,n,acceptor,i),await this.validateAstNodes(t,n,acceptor,i),await this.validateAstAfter(t,n,acceptor,i),o}async validateAstBefore(t,n,i,o=Y.CancellationToken.None){let s=this.validationRegistry.checksBefore;for(let c of s)await interruptAndCheck(o),await c(t,i,n.categories??[],o)}async validateAstNodes(t,n,i,o=Y.CancellationToken.None){await Promise.all(streamAst(t).map(async t=>{await interruptAndCheck(o);let s=this.validationRegistry.getChecks(t.$type,n.categories);for(let n of s)await n(t,i,o)}))}async validateAstAfter(t,n,i,o=Y.CancellationToken.None){let s=this.validationRegistry.checksAfter;for(let c of s)await interruptAndCheck(o),await c(t,i,n.categories??[],o)}toDiagnostic(t,n,i){return{message:n,range:getDiagnosticRange(i),severity:toDiagnosticSeverity(t),code:i.code,codeDescription:i.codeDescription,tags:i.tags,relatedInformation:i.relatedInformation,data:i.data,source:this.getSource()}}getSource(){return this.metadata.languageId}};function getDiagnosticRange(t){if(t.range)return t.range;let n;return typeof t.property==`string`?n=findNodeForProperty(t.node.$cstNode,t.property,t.index):typeof t.keyword==`string`&&(n=findNodeForKeyword(t.node.$cstNode,t.keyword,t.index)),n??=t.node.$cstNode,n?n.range:{start:{line:0,character:0},end:{line:0,character:0}}}function toDiagnosticSeverity(t){switch(t){case`error`:return 1;case`warning`:return 2;case`info`:return 3;case`hint`:return 4;default:throw Error(`Invalid diagnostic severity: `+t)}}function toDiagnosticData(t){switch(t){case`error`:return diagnosticData(Z.LexingError);case`warning`:return diagnosticData(Z.LexingWarning);case`info`:return diagnosticData(Z.LexingInfo);case`hint`:return diagnosticData(Z.LexingHint);default:throw Error(`Invalid diagnostic severity: `+t)}}var Z;(function(t){t.LexingError=`lexing-error`,t.LexingWarning=`lexing-warning`,t.LexingInfo=`lexing-info`,t.LexingHint=`lexing-hint`,t.ParsingError=`parsing-error`,t.LinkingError=`linking-error`})(Z||={});function createDefaultCoreModule(t){return{documentation:{CommentProvider:t=>new DefaultCommentProvider(t),DocumentationProvider:t=>new JSDocDocumentationProvider(t)},parser:{AsyncParser:t=>new DefaultAsyncParser(t),GrammarConfig:t=>createGrammarConfig(t),LangiumParser:t=>createLangiumParser(t),CompletionParser:t=>createCompletionParser(t),ValueConverter:()=>new DefaultValueConverter,TokenBuilder:()=>new DefaultTokenBuilder,Lexer:t=>new DefaultLexer(t),ParserErrorMessageProvider:()=>new LangiumParserErrorMessageProvider,LexerErrorMessageProvider:()=>new DefaultLexerErrorMessageProvider},workspace:{AstNodeLocator:()=>new DefaultAstNodeLocator,AstNodeDescriptionProvider:t=>new DefaultAstNodeDescriptionProvider(t),ReferenceDescriptionProvider:t=>new DefaultReferenceDescriptionProvider(t)},references:{Linker:t=>new DefaultLinker(t),NameProvider:()=>new DefaultNameProvider,ScopeProvider:t=>new DefaultScopeProvider(t),ScopeComputation:t=>new DefaultScopeComputation(t),References:t=>new DefaultReferences(t)},serializer:{Hydrator:t=>new DefaultHydrator(t),JsonSerializer:t=>new DefaultJsonSerializer(t)},validation:{DocumentValidator:t=>new DefaultDocumentValidator(t),ValidationRegistry:t=>new ValidationRegistry(t)},shared:()=>t.shared}}function createDefaultSharedCoreModule(t){return{ServiceRegistry:t=>new DefaultServiceRegistry(t),workspace:{LangiumDocuments:t=>new DefaultLangiumDocuments(t),LangiumDocumentFactory:t=>new DefaultLangiumDocumentFactory(t),DocumentBuilder:t=>new DefaultDocumentBuilder(t),IndexManager:t=>new DefaultIndexManager(t),WorkspaceManager:t=>new DefaultWorkspaceManager(t),FileSystemProvider:n=>t.fileSystemProvider(n),WorkspaceLock:()=>new DefaultWorkspaceLock,ConfigurationProvider:t=>new DefaultConfigurationProvider(t)}}}var DefaultDocumentHighlightProvider=class{constructor(t){this.references=t.references.References,this.nameProvider=t.references.NameProvider,this.grammarConfig=t.parser.GrammarConfig}getDocumentHighlight(t,n,i){let o=t.parseResult.value.$cstNode;if(!o)return;let s=findDeclarationNodeAtOffset(o,t.textDocument.offsetAt(n.position),this.grammarConfig.nameRegexp);if(!s)return;let c=this.references.findDeclaration(s);if(c){let n=U.equals(getDocument(c).uri,t.uri),i={documentUri:t.uri,includeDeclaration:n};return this.references.findReferences(c,i).map(t=>this.createDocumentHighlight(t)).toArray()}}createDocumentHighlight(t){return re.create(t.segment.range)}},DefaultDocumentSymbolProvider=class{constructor(t){this.nameProvider=t.references.NameProvider,this.nodeKindProvider=t.shared.lsp.NodeKindProvider}getSymbols(t,n,i){return this.getSymbol(t,t.parseResult.value)}getSymbol(t,n){let i=n.$cstNode,o=this.nameProvider.getNameNode(n);if(o&&i){let s=this.nameProvider.getName(n);return[{kind:this.nodeKindProvider.getSymbolKind(n),name:s||o.text,range:i.range,selectionRange:o.range,children:this.getChildSymbols(t,n)}]}else return this.getChildSymbols(t,n)||[]}getChildSymbols(t,n){let i=[];for(let o of streamContents(n)){let n=this.getSymbol(t,o);i.push(...n)}if(i.length>0)return i}},DefaultDocumentUpdateHandler=class{constructor(t){this.workspaceManager=t.workspace.WorkspaceManager,this.documentBuilder=t.workspace.DocumentBuilder,this.workspaceLock=t.workspace.WorkspaceLock,this.serviceRegistry=t.ServiceRegistry;let n=!1;t.lsp.LanguageServer.onInitialize(t=>{n=!!t.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration}),t.lsp.LanguageServer.onInitialized(i=>{n&&this.registerFileWatcher(t)})}registerFileWatcher(t){let n=[],i=stream(t.ServiceRegistry.all).flatMap(t=>t.LanguageMetaData.fileExtensions).map(t=>t.startsWith(`.`)?t.substring(1):t).distinct().toArray();i.length>0&&n.push({globPattern:i.length===1?`**/*.${i[0]}`:`**/*.{${i.join(`,`)}}`});let o=stream(t.ServiceRegistry.all).flatMap(t=>t.LanguageMetaData.fileNames??[]).distinct().toArray();if(o.length>0&&n.push({globPattern:o.length===1?`**/${o[0]}`:`**/{${o.join(`,`)}}`}),n.length>0){let i=t.lsp.Connection,o={watchers:n};i?.client.register(ne.type,o)}}fireDocumentUpdate(t,n){t=t.filter(t=>this.serviceRegistry.hasServices(t)),this.workspaceManager.ready.then(()=>{this.workspaceLock.write(i=>this.documentBuilder.update(t,n,i))}).catch(t=>{console.error(`Workspace initialization failed. Could not perform document update.`,t)})}didChangeContent(t){this.fireDocumentUpdate([H.parse(t.document.uri)],[])}didChangeWatchedFiles(t){let n=stream(t.changes).filter(t=>t.type!==ie.Deleted).distinct(t=>t.uri).map(t=>H.parse(t.uri)).toArray(),i=stream(t.changes).filter(t=>t.type===ie.Deleted).distinct(t=>t.uri).map(t=>H.parse(t.uri)).toArray();this.fireDocumentUpdate(n,i)}},DefaultFoldingRangeProvider=class{constructor(t){this.commentNames=t.parser.GrammarConfig.multilineCommentRules}getFoldingRanges(t,n,i){let o=[],acceptor=t=>o.push(t);return this.collectFolding(t,acceptor),o}collectFolding(t,n){let i=t.parseResult?.value;if(i){if(this.shouldProcessContent(i)){let o=streamAllContents(i).iterator(),s;do if(s=o.next(),!s.done){let i=s.value;this.shouldProcess(i)&&this.collectObjectFolding(t,i,n),this.shouldProcessContent(i)||o.prune()}while(!s.done)}this.collectCommentFolding(t,i,n)}}shouldProcess(t){return!0}shouldProcessContent(t){return!0}collectObjectFolding(t,n,i){let o=n.$cstNode;if(o){let n=this.toFoldingRange(t,o);n&&i(n)}}collectCommentFolding(t,n,i){let o=n.$cstNode;if(o){for(let n of flattenCst(o))if(this.commentNames.includes(n.tokenType.name)){let o=this.toFoldingRange(t,n,oe.Comment);o&&i(o)}}}toFoldingRange(t,n,i){let o=n.range,s=o.start,c=o.end;if(!(c.line-s.line<2))return this.includeLastFoldingLine(n,i)||(c=t.textDocument.positionAt(t.textDocument.offsetAt({line:c.line,character:0})-1)),ae.create(s.line,c.line,s.character,c.character,i)}includeLastFoldingLine(t,n){if(n===oe.Comment)return!1;let i=t.text,o=i.charAt(i.length-1);return o!==`}`&&o!==`)`&&o!==`]`}},DefaultFuzzyMatcher=class{match(t,n){if(t.length===0)return!0;let i=!1,o,s=0,c=n.length;for(let u=0;u<c;u++){let c=n.charCodeAt(u),f=t.charCodeAt(s);if((c===f||this.toUpperCharCode(c)===this.toUpperCharCode(f))&&(i||=o===void 0||this.isWordTransition(o,c),i&&s++,s===t.length))return!0;o=c}return!1}isWordTransition(t,n){return lr<=t&&t<=ur&&dr<=n&&n<=fr||t===pr&&n!==pr}toUpperCharCode(t){return lr<=t&&t<=ur?t-32:t}};const lr=97,ur=122,dr=65,fr=90,pr=95;var AstNodeHoverProvider=class{constructor(t){this.references=t.references.References,this.grammarConfig=t.parser.GrammarConfig}getHoverContent(t,n){let i=t.parseResult?.value?.$cstNode;if(i){let o=t.textDocument.offsetAt(n.position),s=findDeclarationNodeAtOffset(i,o,this.grammarConfig.nameRegexp);if(s&&s.offset+s.length>o){let t=this.references.findDeclaration(s);if(t)return this.getAstNodeHoverContent(t);if(isKeyword(s.grammarSource))return this.getKeywordHoverContent(s.grammarSource)}}}getKeywordHoverContent(t){let n=isAstNodeWithComment(t)?t.$comment:void 0;if(n||=findCommentNode(t.$cstNode,[`ML_COMMENT`])?.text,n&&isJSDoc(n)){let t=parseJSDoc(n).toMarkdown();if(t)return{contents:{kind:`markdown`,value:t}}}}},MultilineCommentHoverProvider=class extends AstNodeHoverProvider{constructor(t){super(t),this.documentationProvider=t.documentation.DocumentationProvider}getAstNodeHoverContent(t){let n=this.documentationProvider.getDocumentation(t);if(n)return{contents:{kind:`markdown`,value:n}}}};const mr={[k.class]:0,[k.comment]:1,[k.enum]:2,[k.enumMember]:3,[k.event]:4,[k.function]:5,[k.interface]:6,[k.keyword]:7,[k.macro]:8,[k.method]:9,[k.modifier]:10,[k.namespace]:11,[k.number]:12,[k.operator]:13,[k.parameter]:14,[k.property]:15,[k.regexp]:16,[k.string]:17,[k.struct]:18,[k.type]:19,[k.typeParameter]:20,[k.variable]:21,[k.decorator]:22},hr={[O.abstract]:1,[O.async]:2,[O.declaration]:4,[O.defaultLibrary]:8,[O.definition]:16,[O.deprecated]:32,[O.documentation]:64,[O.modification]:128,[O.readonly]:256,[O.static]:512};Object.keys(mr),Object.keys(hr);function mergeSemanticTokenProviderOptions(t){let n=[],i=[],o=!0,s=!0,c=!0;for(let u of t)u&&(u.legend.tokenTypes.forEach((t,i)=>{let o=n[i];if(o&&o!==t)throw Error(`Cannot merge '${o}' and '${t}' token types. They use the same index ${i}.`);n[i]=t}),u.legend.tokenModifiers.forEach((t,n)=>{let o=i[n];if(o&&o!==t)throw Error(`Cannot merge '${o}' and '${t}' token modifier. They use the same index ${n}.`);i[n]=t}),u.full?typeof u.full==`object`&&!u.full.delta&&(s=!1):o=!1,u.range||(c=!1));return{legend:{tokenTypes:n,tokenModifiers:i},full:o&&{delta:s},range:c}}var SemanticTokensBuilder$1=class extends ue{static{o(this,`SemanticTokensBuilder`)}constructor(){super(...arguments),this._tokens=[]}push(t,n,i,o,s){this._tokens.push({line:t,char:n,length:i,tokenType:o,tokenModifiers:s})}build(){return this.applyTokens(),super.build()}buildEdits(){return this.applyTokens(),super.buildEdits()}flush(){this.previousResult(this.id)}applyTokens(){for(let t of this._tokens.sort(this.compareTokens))super.push(t.line,t.char,t.length,t.tokenType,t.tokenModifiers);this._tokens=[]}compareTokens(t,n){return t.line===n.line?t.char-n.char:t.line-n.line}},AbstractSemanticTokenProvider=class{constructor(t){this.tokensBuilders=new Map,t.shared.workspace.TextDocuments.onDidClose(t=>{this.tokensBuilders.delete(t.document.uri)}),t.shared.lsp.LanguageServer.onInitialize(t=>{this.initialize(t.capabilities.textDocument?.semanticTokens)})}initialize(t){this.clientCapabilities=t}get tokenTypes(){return mr}get tokenModifiers(){return hr}get semanticTokensOptions(){return{legend:{tokenTypes:Object.keys(this.tokenTypes),tokenModifiers:Object.keys(this.tokenModifiers)},full:{delta:!0},range:!0}}async semanticHighlight(t,n,i=Y.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=t,this.currentTokensBuilder=this.getDocumentTokensBuilder(t),this.currentTokensBuilder.flush(),await this.computeHighlighting(t,this.createAcceptor(),i),this.currentTokensBuilder.build()}async semanticHighlightRange(t,n,i=Y.CancellationToken.None){return this.currentRange=n.range,this.currentDocument=t,this.currentTokensBuilder=this.getDocumentTokensBuilder(t),this.currentTokensBuilder.flush(),await this.computeHighlighting(t,this.createAcceptor(),i),this.currentTokensBuilder.build()}async semanticHighlightDelta(t,n,i=Y.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=t,this.currentTokensBuilder=this.getDocumentTokensBuilder(t),this.currentTokensBuilder.previousResult(n.previousResultId),await this.computeHighlighting(t,this.createAcceptor(),i),this.currentTokensBuilder.buildEdits()}createAcceptor(){let acceptor=t=>{`line`in t?this.highlightToken({range:{start:{line:t.line,character:t.char},end:{line:t.line,character:t.char+t.length}},type:t.type,modifier:t.modifier}):`range`in t?this.highlightToken(t):`keyword`in t?this.highlightKeyword(t):`property`in t?this.highlightProperty(t):this.highlightNode({node:t.cst,type:t.type,modifier:t.modifier})};return acceptor}getDocumentTokensBuilder(t){let n=this.tokensBuilders.get(t.uri.toString());if(n)return n;let i=new SemanticTokensBuilder$1;return this.tokensBuilders.set(t.uri.toString(),i),i}async computeHighlighting(t,n,i){let o=t.parseResult.value,s=streamAst(o,{range:this.currentRange}).iterator(),c;do if(c=s.next(),!c.done){await interruptAndCheck(i);let t=c.value;this.highlightElement(t,n)===`prune`&&s.prune()}while(!c.done)}highlightToken(t){let{range:n,type:i}=t,o=t.modifier;if(this.currentRange&&!inRange(n,this.currentRange)||!this.currentDocument||!this.currentTokensBuilder)return;let s=this.tokenTypes[i],c=0;if(o!==void 0){typeof o==`string`&&(o=[o]);for(let t of o){let n=this.tokenModifiers[t];c|=n}}let u=n.start.line,f=n.end.line;if(u===f){let t=n.start.character,i=n.end.character-t;this.currentTokensBuilder.push(u,t,i,s,c)}else if(this.clientCapabilities?.multilineTokenSupport){let t=n.start.character,i=this.currentDocument.textDocument.offsetAt(n.start),o=this.currentDocument.textDocument.offsetAt(n.end);this.currentTokensBuilder.push(u,t,o-i,s,c)}else{let t=n.start,i=this.currentDocument.textDocument.offsetAt({line:u+1,character:0});this.currentTokensBuilder.push(t.line,t.character,i-t.character-1,s,c);for(let t=u+1;t<f;t++){let n=i;i=this.currentDocument.textDocument.offsetAt({line:t+1,character:0}),this.currentTokensBuilder.push(t,0,i-n-1,s,c)}this.currentTokensBuilder.push(f,0,n.end.character,s,c)}}highlightProperty(t){let n=[];if(typeof t.index==`number`){let i=findNodeForProperty(t.node.$cstNode,t.property,t.index);i&&n.push(i)}else n.push(...findNodesForProperty(t.node.$cstNode,t.property));let{type:i,modifier:o}=t;for(let t of n)this.highlightNode({node:t,type:i,modifier:o})}highlightKeyword(t){let{node:n,keyword:i,type:o,index:s,modifier:c}=t,u=[];if(typeof s==`number`){let t=findNodeForKeyword(n.$cstNode,i,s);t&&u.push(t)}else u.push(...findNodesForKeyword(n.$cstNode,i));for(let t of u)this.highlightNode({node:t,type:o,modifier:c})}highlightNode(t){let{node:n,type:i,modifier:o}=t,s=n.range;this.highlightToken({range:s,type:i,modifier:o})}},gr;(function(t){function decode(t,n,i){let o=new Map;Object.entries(n).forEach(([t,n])=>o.set(n,t));let s=0,c=0;return sliceIntoChunks(t.data,5).map(t=>{s+=t[0],t[0]!==0&&(c=0),c+=t[1];let n=t[2];return{offset:i.textDocument.offsetAt({line:s,character:c}),tokenType:o.get(t[3]),tokenModifiers:t[4],text:i.textDocument.getText({start:{line:s,character:c},end:{line:s,character:c+n}})}})}t.decode=decode;function sliceIntoChunks(t,n){let i=[];for(let o=0;o<t.length;o+=n){let s=t.slice(o,o+n);i.push(s)}return i}})(gr||={});function mergeSignatureHelpOptions(t){let n=[],i=[];t.forEach(t=>{t?.triggerCharacters&&n.push(...t.triggerCharacters),t?.retriggerCharacters&&i.push(...t.retriggerCharacters)});let o={triggerCharacters:n.length>0?Array.from(new Set(n)).sort():void 0,retriggerCharacters:i.length>0?Array.from(new Set(i)).sort():void 0};return o.triggerCharacters?o:void 0}var DefaultLanguageServer=class{constructor(t){this.onInitializeEmitter=new me,this.onInitializedEmitter=new me,this.services=t}get onInitialize(){return this.onInitializeEmitter.event}get onInitialized(){return this.onInitializedEmitter.event}async initialize(t){return this.eagerLoadServices(),this.fireInitializeOnDefaultServices(t),this.onInitializeEmitter.fire(t),this.onInitializeEmitter.dispose(),this.buildInitializeResult(t)}eagerLoadServices(){eagerLoad(this.services),this.services.ServiceRegistry.all.forEach(t=>eagerLoad(t))}hasService(t){return this.services.ServiceRegistry.all.some(n=>t(n)!==void 0)}buildInitializeResult(t){let n=this.services.lsp.DocumentUpdateHandler,i=this.services.lsp.FileOperationHandler?.fileOperationOptions,o=this.services.ServiceRegistry.all,s=this.hasService(t=>t.lsp?.Formatter),c=o.map(t=>t.lsp?.Formatter?.formatOnTypeOptions).find(t=>!!t),u=this.hasService(t=>t.lsp?.CodeActionProvider),f=this.hasService(t=>t.lsp?.SemanticTokenProvider),p=mergeSemanticTokenProviderOptions(o.map(t=>t.lsp?.SemanticTokenProvider?.semanticTokensOptions)),h=this.services.lsp?.ExecuteCommandHandler?.commands,g=this.hasService(t=>t.lsp?.DocumentLinkProvider),_=mergeSignatureHelpOptions(o.map(t=>t.lsp?.SignatureHelp?.signatureHelpOptions)),x=this.hasService(t=>t.lsp?.TypeProvider),S=this.hasService(t=>t.lsp?.ImplementationProvider),T=this.hasService(t=>t.lsp?.CompletionProvider),ee=mergeCompletionProviderOptions(o.map(t=>t.lsp?.CompletionProvider?.completionOptions)),te=this.hasService(t=>t.lsp?.ReferencesProvider),ne=this.hasService(t=>t.lsp?.DocumentSymbolProvider),E=this.hasService(t=>t.lsp?.DefinitionProvider),re=this.hasService(t=>t.lsp?.DocumentHighlightProvider),D=this.hasService(t=>t.lsp?.FoldingRangeProvider),ie=this.hasService(t=>t.lsp?.HoverProvider),ae=this.hasService(t=>t.lsp?.RenameProvider),oe=this.hasService(t=>t.lsp?.CallHierarchyProvider),se=this.hasService(t=>t.lsp?.TypeHierarchyProvider),ce=this.hasService(t=>t.lsp?.CodeLensProvider),le=this.hasService(t=>t.lsp?.DeclarationProvider),O=this.hasService(t=>t.lsp?.InlayHintProvider),k=this.services.lsp?.WorkspaceSymbolProvider;return{capabilities:{workspace:{workspaceFolders:{supported:!0},fileOperations:i},executeCommandProvider:h&&{commands:h},textDocumentSync:{change:he.Incremental,openClose:!0,save:!!n.didSaveDocument,willSave:!!n.willSaveDocument,willSaveWaitUntil:!!n.willSaveDocumentWaitUntil},completionProvider:T?ee:void 0,referencesProvider:te,documentSymbolProvider:ne,definitionProvider:E,typeDefinitionProvider:x,documentHighlightProvider:re,codeActionProvider:u,documentFormattingProvider:s,documentRangeFormattingProvider:s,documentOnTypeFormattingProvider:c,foldingRangeProvider:D,hoverProvider:ie,renameProvider:ae?{prepareProvider:!0}:void 0,semanticTokensProvider:f?p:void 0,signatureHelpProvider:_,implementationProvider:S,callHierarchyProvider:oe?{}:void 0,typeHierarchyProvider:se?{}:void 0,documentLinkProvider:g?{resolveProvider:!1}:void 0,codeLensProvider:ce?{resolveProvider:!1}:void 0,declarationProvider:le,inlayHintProvider:O?{resolveProvider:!1}:void 0,workspaceSymbolProvider:k?{resolveProvider:!!k.resolveSymbol}:void 0}}}initialized(t){this.fireInitializedOnDefaultServices(t),this.onInitializedEmitter.fire(t),this.onInitializedEmitter.dispose()}fireInitializeOnDefaultServices(t){this.services.workspace.ConfigurationProvider.initialize(t),this.services.workspace.WorkspaceManager.initialize(t)}fireInitializedOnDefaultServices(t){let n=this.services.lsp.Connection,i=n?Object.assign(Object.assign({},t),{register:t=>n.client.register(pe.type,t),fetchConfiguration:t=>n.workspace.getConfiguration(t)}):t;this.services.workspace.ConfigurationProvider.initialized(i).catch(t=>console.error(`Error in ConfigurationProvider initialization:`,t)),this.services.workspace.WorkspaceManager.initialized(t).catch(t=>console.error(`Error in WorkspaceManager initialization:`,t))}},DefaultNodeKindProvider=class{getSymbolKind(t){return de.Field}getCompletionItemKind(t){return ee.Reference}},DefaultReferencesProvider=class{constructor(t){this.nameProvider=t.references.NameProvider,this.references=t.references.References,this.grammarConfig=t.parser.GrammarConfig}findReferences(t,n,i){let o=t.parseResult.value.$cstNode;if(!o)return[];let s=findDeclarationNodeAtOffset(o,t.textDocument.offsetAt(n.position),this.grammarConfig.nameRegexp);return s?this.getReferences(s,n,t):[]}getReferences(t,n,i){let o=[],s=this.references.findDeclaration(t);if(s){let t={includeDeclaration:n.context.includeDeclaration};this.references.findReferences(s,t).forEach(t=>{o.push(se.create(t.sourceUri.toString(),t.segment.range))})}return o}},DefaultRenameProvider=class{constructor(t){this.references=t.references.References,this.nameProvider=t.references.NameProvider,this.grammarConfig=t.parser.GrammarConfig}async rename(t,n,i){let o={},s=t.parseResult.value.$cstNode;if(!s)return;let c=findDeclarationNodeAtOffset(s,t.textDocument.offsetAt(n.position),this.grammarConfig.nameRegexp);if(!c)return;let u=this.references.findDeclaration(c);if(u)return this.references.findReferences(u,{onlyLocal:!1,includeDeclaration:!0}).forEach(t=>{let i=K.replace(t.segment.range,n.newName),s=t.sourceUri.toString();o[s]?o[s].push(i):o[s]=[i]}),{changes:o}}prepareRename(t,n,i){return this.renameNodeRange(t,n.position)}renameNodeRange(t,n){let i=t.parseResult.value.$cstNode,o=t.textDocument.offsetAt(n);if(i&&o){let t=findDeclarationNodeAtOffset(i,o,this.grammarConfig.nameRegexp);if(!t)return;if(this.references.findDeclaration(t)||this.isNameNode(t))return t.range}}isNameNode(t){return t?.astNode&&isNamed(t.astNode)&&t===this.nameProvider.getNameNode(t.astNode)}},DefaultWorkspaceSymbolProvider=class{constructor(t){this.indexManager=t.workspace.IndexManager,this.nodeKindProvider=t.lsp.NodeKindProvider,this.fuzzyMatcher=t.lsp.FuzzyMatcher}async getSymbols(t,n=Y.CancellationToken.None){let i=[],o=t.query.toLowerCase();for(let t of this.indexManager.allElements())if(await interruptAndCheck(n),this.fuzzyMatcher.match(o,t.name)){let n=this.getWorkspaceSymbol(t);n&&i.push(n)}return i}getWorkspaceSymbol(t){let n=t.nameSegment;if(n)return{kind:this.nodeKindProvider.getSymbolKind(t),name:t.name,location:{range:n.range,uri:t.documentUri.toString()}}}},NormalizedTextDocuments=class{constructor(t){this._configuration=t,this._syncedDocuments=new Map,this._onDidChangeContent=new D,this._onDidOpen=new D,this._onDidClose=new D,this._onDidSave=new D,this._onWillSave=new D}get onDidOpen(){return this._onDidOpen.event}get onDidChangeContent(){return this._onDidChangeContent.event}get onWillSave(){return this._onWillSave.event}onWillSaveWaitUntil(t){this._willSaveWaitUntil=t}get onDidSave(){return this._onDidSave.event}get onDidClose(){return this._onDidClose.event}get(t){return this._syncedDocuments.get(U.normalize(t))}set(t){let n=U.normalize(t.uri),i=!0;this._syncedDocuments.has(n)&&(i=!1),this._syncedDocuments.set(n,t);let o=Object.freeze({document:t});return this._onDidOpen.fire(o),this._onDidChangeContent.fire(o),i}delete(t){let n=U.normalize(typeof t==`object`&&`uri`in t?t.uri:t),i=this._syncedDocuments.get(n);i!==void 0&&(this._syncedDocuments.delete(n),this._onDidClose.fire(Object.freeze({document:i})))}all(){return Array.from(this._syncedDocuments.values())}keys(){return Array.from(this._syncedDocuments.keys())}listen(t){t.__textDocumentSync=fe.Incremental;let n=[];return n.push(t.onDidOpenTextDocument(t=>{let n=t.textDocument,i=U.normalize(n.uri),o=this._configuration.create(i,n.languageId,n.version,n.text);this._syncedDocuments.set(i,o);let s=Object.freeze({document:o});this._onDidOpen.fire(s),this._onDidChangeContent.fire(s)})),n.push(t.onDidChangeTextDocument(t=>{let n=t.textDocument,i=t.contentChanges;if(i.length===0)return;let{version:o}=n;if(o==null)throw Error(`Received document change event for ${n.uri} without valid version identifier`);let s=U.normalize(n.uri),c=this._syncedDocuments.get(s);c!==void 0&&(c=this._configuration.update(c,i,o),this._syncedDocuments.set(s,c),this._onDidChangeContent.fire(Object.freeze({document:c})))})),n.push(t.onDidCloseTextDocument(t=>{let n=U.normalize(t.textDocument.uri),i=this._syncedDocuments.get(n);i!==void 0&&(this._syncedDocuments.delete(n),this._onDidClose.fire(Object.freeze({document:i})))})),n.push(t.onWillSaveTextDocument(t=>{let n=this._syncedDocuments.get(U.normalize(t.textDocument.uri));n!==void 0&&this._onWillSave.fire(Object.freeze({document:n,reason:t.reason}))})),n.push(t.onWillSaveTextDocumentWaitUntil((t,n)=>{let i=this._syncedDocuments.get(U.normalize(t.textDocument.uri));return i!==void 0&&this._willSaveWaitUntil?this._willSaveWaitUntil(Object.freeze({document:i,reason:t.reason}),n):[]})),n.push(t.onDidSaveTextDocument(t=>{let n=this._syncedDocuments.get(U.normalize(t.textDocument.uri));n!==void 0&&this._onDidSave.fire(Object.freeze({document:n}))})),E.create(()=>{n.forEach(t=>t.dispose())})}},NormalizedNotebookDocuments=class{constructor(t){this.notebookDocuments=new Map,this.notebookCellMap=new Map,this._onDidOpen=new D,this._onDidSave=new D,this._onDidChange=new D,this._onDidClose=new D,`listen`in t?this._cellTextDocuments=t:this._cellTextDocuments=new NormalizedTextDocuments(t)}get cellTextDocuments(){return this._cellTextDocuments}getCellTextDocument(t){return this._cellTextDocuments.get(t.document)}getNotebookDocument(t){return this.notebookDocuments.get(U.normalize(t))}getNotebookCell(t){let n=this.notebookCellMap.get(U.normalize(t));return n&&n[0]}findNotebookDocumentForCell(t){let n=typeof t==`string`||`scheme`in t?t:t.document,i=this.notebookCellMap.get(U.normalize(n));return i&&i[1]}get onDidOpen(){return this._onDidOpen.event}get onDidSave(){return this._onDidSave.event}get onDidChange(){return this._onDidChange.event}get onDidClose(){return this._onDidClose.event}listen(t){let n=new _r,i=[];return i.push(this.cellTextDocuments.listen(n)),i.push(t.notebooks.synchronization.onDidOpenNotebookDocument(t=>{let i=U.normalize(t.notebookDocument.uri);this.notebookDocuments.set(i,t.notebookDocument);for(let i of t.cellTextDocuments)n.openTextDocument({textDocument:i});this.updateCellMap(t.notebookDocument),this._onDidOpen.fire(t.notebookDocument)})),i.push(t.notebooks.synchronization.onDidChangeNotebookDocument(t=>{let i=U.normalize(t.notebookDocument.uri),o=this.notebookDocuments.get(i);if(o===void 0)return;o.version=t.notebookDocument.version;let s=o.metadata,c=!1,u=t.change;u.metadata!==void 0&&(c=!0,o.metadata=u.metadata);let f=[],p=[],h=[],g=[];if(u.cells!==void 0){let t=u.cells;if(t.structure!==void 0){let i=t.structure.array;if(o.cells.splice(i.start,i.deleteCount,...i.cells===void 0?[]:i.cells),t.structure.didOpen!==void 0)for(let i of t.structure.didOpen)n.openTextDocument({textDocument:i}),f.push(i.uri);if(t.structure.didClose)for(let i of t.structure.didClose)n.closeTextDocument({textDocument:i}),p.push(i.uri)}if(t.data!==void 0){let n=new Map(t.data.map(t=>[t.document,t]));for(let t=0;t<=o.cells.length;t++){let i=n.get(o.cells[t].document);if(i!==void 0){let s=o.cells.splice(t,1,i);if(h.push({old:s[0],new:i}),n.delete(i.document),n.size===0)break}}}if(t.textContent!==void 0)for(let i of t.textContent)n.changeTextDocument({textDocument:i.document,contentChanges:i.changes}),g.push(i.document.uri)}this.updateCellMap(o);let _={notebookDocument:o};c&&(_.metadata={old:s,new:o.metadata});let x=[];for(let t of f)x.push(this.getNotebookCell(t));let S=[];for(let t of p)S.push(this.getNotebookCell(t));let T=[];for(let t of g)T.push(this.getNotebookCell(t));(x.length>0||S.length>0||h.length>0||T.length>0)&&(_.cells={added:x,removed:S,changed:{data:h,textContent:T}}),(_.metadata!==void 0||_.cells!==void 0)&&this._onDidChange.fire(_)})),i.push(t.notebooks.synchronization.onDidSaveNotebookDocument(t=>{let n=this.getNotebookDocument(t.notebookDocument.uri);n!==void 0&&this._onDidSave.fire(n)})),i.push(t.notebooks.synchronization.onDidCloseNotebookDocument(t=>{let i=U.normalize(t.notebookDocument.uri),o=this.notebookDocuments.get(i);if(o!==void 0){this._onDidClose.fire(o);for(let i of t.cellTextDocuments)n.closeTextDocument({textDocument:i});this.notebookDocuments.delete(i);for(let t of o.cells)this.notebookCellMap.delete(t.document)}})),E.create(()=>{i.forEach(t=>t.dispose())})}updateCellMap(t){for(let n of t.cells)this.notebookCellMap.set(n.document,[n,t])}},_r=class CellTextDocumentConnection{onDidOpenTextDocument(t){return this.openHandler=t,E.create(()=>{this.openHandler=void 0})}openTextDocument(t){this.openHandler&&this.openHandler(t)}onDidChangeTextDocument(t){return this.changeHandler=t,E.create(()=>{this.changeHandler=t})}changeTextDocument(t){this.changeHandler&&this.changeHandler(t)}onDidCloseTextDocument(t){return this.closeHandler=t,E.create(()=>{this.closeHandler=void 0})}closeTextDocument(t){this.closeHandler&&this.closeHandler(t)}onWillSaveTextDocument(){return CellTextDocumentConnection.NULL_DISPOSE}onWillSaveTextDocumentWaitUntil(){return CellTextDocumentConnection.NULL_DISPOSE}onDidSaveTextDocument(){return CellTextDocumentConnection.NULL_DISPOSE}};_r.NULL_DISPOSE=Object.freeze({dispose:()=>{}});function createDefaultModule(t){return Yn.merge(createDefaultCoreModule(t),createDefaultLSPModule(t))}function createDefaultLSPModule(t){return{lsp:{CompletionProvider:t=>new DefaultCompletionProvider(t),DocumentSymbolProvider:t=>new DefaultDocumentSymbolProvider(t),HoverProvider:t=>new MultilineCommentHoverProvider(t),FoldingRangeProvider:t=>new DefaultFoldingRangeProvider(t),ReferencesProvider:t=>new DefaultReferencesProvider(t),DefinitionProvider:t=>new DefaultDefinitionProvider(t),DocumentHighlightProvider:t=>new DefaultDocumentHighlightProvider(t),RenameProvider:t=>new DefaultRenameProvider(t)},shared:()=>t.shared}}function createDefaultSharedModule(t){return Yn.merge(createDefaultSharedCoreModule(t),createDefaultSharedLSPModule(t))}function createDefaultSharedLSPModule(t){return{lsp:{Connection:()=>t.connection,LanguageServer:t=>new DefaultLanguageServer(t),DocumentUpdateHandler:t=>new DefaultDocumentUpdateHandler(t),WorkspaceSymbolProvider:t=>new DefaultWorkspaceSymbolProvider(t),NodeKindProvider:()=>new DefaultNodeKindProvider,FuzzyMatcher:()=>new DefaultFuzzyMatcher},workspace:{TextDocuments:()=>new NormalizedTextDocuments(Kn),NotebookDocuments:t=>new NormalizedNotebookDocuments(t.workspace.TextDocuments)}}}var AbstractFormatter=class{constructor(){this.collector=()=>{}}getNodeFormatter(t){return new DefaultNodeFormatter(t,this.collector)}formatDocument(t,n){let i=t.parseResult;return i.lexerErrors.length===0&&i.parserErrors.length===0?this.doDocumentFormat(t,n.options):[]}isFormatRangeErrorFree(t,n){let i=t.parseResult;return i.lexerErrors.length||i.parserErrors.length?Math.min(...i.lexerErrors.map(t=>t.line??Number.MAX_VALUE),...i.parserErrors.map(t=>t.token.startLine??Number.MAX_VALUE))>n.end.line:!0}formatDocumentRange(t,n){return this.isFormatRangeErrorFree(t,n.range)?this.doDocumentFormat(t,n.options,n.range):[]}formatDocumentOnType(t,n){let i={start:{character:0,line:n.position.line},end:n.position};return this.isFormatRangeErrorFree(t,i)?this.doDocumentFormat(t,n.options,i):[]}get formatOnTypeOptions(){}doDocumentFormat(t,n,i){let o=new Map,collector=(t,n,i)=>{let s=this.nodeModeToKey(t,n),c=o.get(s),u=i.options.priority??0,f=c?.options.priority??0;(!c||f<=u)&&o.set(s,i)};this.collector=collector,this.iterateAstFormatting(t,i);let s=this.iterateCstFormatting(t,o,n,i);return this.avoidOverlappingEdits(t.textDocument,s)}avoidOverlappingEdits(t,n){let i=[];for(let o of n){let n=i[i.length-1];for(;n&&t.offsetAt(o.range.start)<t.offsetAt(n.range.end);)i.pop(),n=i[i.length-1];i.push(o)}return i.filter(n=>this.isNecessary(n,t))}iterateAstFormatting(t,n){let i=t.parseResult.value;this.format(i);let o=streamAllContents(i).iterator(),s;do if(s=o.next(),!s.done){let t=s.value;this.insideRange(t.$cstNode.range,n)?this.format(t):o.prune()}while(!s.done)}nodeModeToKey(t,n){return`${t.offset}:${t.end}:${n}`}insideRange(t,n){return!n||t.start.line<=n.start.line&&t.end.line>=n.end.line||t.start.line>=n.start.line&&t.end.line<=n.end.line||t.start.line<=n.end.line&&t.end.line>=n.end.line}isNecessary(t,n){return t.newText!==n.getText(t.range).replace(/\r/g,``)}iterateCstFormatting(t,n,i,o){let s={indentation:0,options:i,document:t.textDocument},c=[],u=this.iterateCstTree(t,s).iterator(),f,p;do if(p=u.next(),!p.done){let t=p.value,i=isLeafCstNode(t),u=this.nodeModeToKey(t,`prepend`),h=n.get(u);if(n.delete(u),h){let n=this.createTextEdit(f,t,h,s);for(let t of n)t&&this.insideRange(t.range,o)&&c.push(t)}let g=this.nodeModeToKey(t,`append`),_=n.get(g);if(n.delete(g),_){let n=getNextNode(t);if(n){let i=this.createTextEdit(t,n,_,s);for(let t of i)t&&this.insideRange(t.range,o)&&c.push(t)}}if(!h&&t.hidden){let n=this.createHiddenTextEdits(f,t,void 0,s);for(let t of n)t&&this.insideRange(t.range,o)&&c.push(t)}i&&(f=t)}while(!p.done);return c}createHiddenTextEdits(t,n,i,o){let s=n.range.start.line;if(t&&t.range.end.line===s)return[];let c=[],u={start:{character:0,line:s},end:n.range.start},f=o.document.getText(u),p=this.findFittingMove(u,i?.moves??[],o),h=this.getExistingIndentationCharacterCount(f,o),g=this.getIndentationCharacterCount(o,p)-h;if(g===0)return[];let _=``;g>0&&(_=(o.options.insertSpaces?` `:` `).repeat(g));let x=n.text.split(`
14
- `);x[0]=f+x[0];for(let t=0;t<x.length;t++){let n=s+t,i={character:0,line:n};if(g>0)c.push({newText:_,range:{start:i,end:i}});else{let o=x[t],s=0;for(;s<o.length;s++){let t=o.charAt(s);if(t!==` `&&t!==` `)break}c.push({newText:``,range:{start:i,end:{line:n,character:Math.min(s,Math.abs(g))}}})}}return c}getExistingIndentationCharacterCount(t,n){let i=` `.repeat(n.options.tabSize);return(n.options.insertSpaces?t.replaceAll(` `,i):t.replaceAll(i,` `)).length}getIndentationCharacterCount(t,n){let i=t.indentation;return n&&n.tabs&&(i+=n.tabs),(t.options.insertSpaces?t.options.tabSize:1)*i}createTextEdit(t,n,i,o){if(n.hidden)return this.createHiddenTextEdits(t,n,i,o);if(t&&(t.range.end.line>n.range.start.line||t.range.end.line===n.range.start.line&&t.range.end.character>n.range.start.character))return[];let s={start:t?.range.end??{character:0,line:0},end:n.range.start},c=this.findFittingMove(s,i.moves,o);if(!c)return[];let u=c.characters,f=c.lines,p=c.tabs,h=o.indentation;o.indentation+=p??0;let g=[];return u===void 0?f===void 0?p!==void 0&&g.push(this.createTabTextEdit(s,!!t,o)):g.push(this.createLineTextEdit(s,f,o,i.options)):t?.hidden||g.push(this.createSpaceTextEdit(s,u,i.options)),isLeafCstNode(n)&&(o.indentation=h),g}createSpaceTextEdit(t,n,i){if(t.start.line===t.end.line){let o=t.end.character-t.start.character;n=this.fitIntoOptions(n,o,i)}return{newText:` `.repeat(n),range:t}}createLineTextEdit(t,n,i,o){let s=t.end.line-t.start.line;n=this.fitIntoOptions(n,s,o);let c=(i.options.insertSpaces?` `.repeat(i.options.tabSize):` `).repeat(i.indentation);return{newText:`${`
15
- `.repeat(n)}${c}`,range:t}}createTabTextEdit(t,n,i){let o=(i.options.insertSpaces?` `.repeat(i.options.tabSize):` `).repeat(i.indentation),s=+!!n,c=Math.max(t.end.line-t.start.line,s);return{newText:`${`
16
- `.repeat(c)}${o}`,range:t}}fitIntoOptions(t,n,i){return i.allowMore?t=Math.max(n,t):i.allowLess&&(t=Math.min(n,t)),t}findFittingMove(t,n,i){if(n.length===0)return;if(n.length===1)return n[0];let o=t.end.line-t.start.line;for(let t of n)if(t.lines!==void 0&&o<=t.lines)return t;else if(t.lines===void 0&&o===0)return t;return n[n.length-1]}iterateCstTree(t,n){let i=t.parseResult.value.$cstNode;return i?new TreeStreamImpl(i,t=>this.iterateCst(t,n)):tt}iterateCst(t,n){if(!isCompositeCstNode(t))return tt;let i=n.indentation;return new z(()=>({index:0}),o=>o.index<t.content.length?{done:!1,value:t.content[o.index++]}:(n.indentation=i,B))}},DefaultNodeFormatter=class{constructor(t,n){this.astNode=t,this.collector=n}node(t){return new Q(t.$cstNode?[t.$cstNode]:[],this.collector)}nodes(...t){let n=[];for(let i of t)i.$cstNode&&n.push(i.$cstNode);return new Q(n,this.collector)}property(t,n){let i=findNodeForProperty(this.astNode.$cstNode,t,n);return new Q(i?[i]:[],this.collector)}properties(...t){let n=[];for(let i of t){let t=findNodesForProperty(this.astNode.$cstNode,i);n.push(...t)}return new Q(n,this.collector)}keyword(t,n){let i=findNodeForKeyword(this.astNode.$cstNode,t,n);return new Q(i?[i]:[],this.collector)}keywords(...t){let n=[];for(let i of t){let t=findNodesForKeyword(this.astNode.$cstNode,i);n.push(...t)}return new Q(n,this.collector)}cst(t){return new Q([...t],this.collector)}interior(t,n){let i=t.nodes,o=n.nodes;if(i.length!==1||o.length!==1)return new Q([],this.collector);let s=i[0],c=o[0];if(s.offset>c.offset){let t=s;s=c,c=t}return new Q(getInteriorNodes(s,c),this.collector)}},Q=class FormattingRegion{constructor(t,n){this.nodes=t,this.collector=n}prepend(t){for(let n of this.nodes)this.collector(n,`prepend`,t);return this}append(t){for(let n of this.nodes)this.collector(n,`append`,t);return this}surround(t){for(let n of this.nodes)this.collector(n,`prepend`,t),this.collector(n,`append`,t);return this}slice(t,n){return new FormattingRegion(this.nodes.slice(t,n),this.collector)}},vr;(function(t){function fit(...t){return{options:{},moves:t.flatMap(t=>t.moves).sort(compareMoves)}}t.fit=fit;function noSpace(t){return spaces(0,t)}t.noSpace=noSpace;function oneSpace(t){return spaces(1,t)}t.oneSpace=oneSpace;function spaces(t,n){return{options:n??{},moves:[{characters:t}]}}t.spaces=spaces;function newLine(t){return newLines(1,t)}t.newLine=newLine;function newLines(t,n){return{options:n??{},moves:[{lines:t}]}}t.newLines=newLines;function indent(t){return{options:t??{},moves:[{tabs:1,lines:1}]}}t.indent=indent;function noIndent(t){return{options:t??{},moves:[{tabs:0}]}}t.noIndent=noIndent;function compareMoves(t,n){let i=t.lines??0,o=n.lines??0,s=t.tabs??0,c=n.tabs??0,u=t.characters??0,f=n.characters??0;return i<o?-1:i>o?1:s<c?-1:s>c?1:u<f?-1:+(u>f)}})(vr||={});var NodeFileSystemProvider=class{constructor(){this.encoding=`utf-8`}readFile(t){return ge.promises.readFile(t.fsPath,this.encoding)}async readDirectory(t){return(await ge.promises.readdir(t.fsPath,{withFileTypes:!0})).map(n=>({dirent:n,isFile:n.isFile(),isDirectory:n.isDirectory(),uri:U.joinPath(t,n.name)}))}};function getSourceRegion(t){if(t){if(`astNode`in t)return getSourceRegionOfAstNode(t);if(Array.isArray(t))return t.reduce(mergeDocumentSegment,void 0);{let n=t;return copyDocumentSegment(n,isCstNode(n)?getDocumentURIOrUndefined(n?.root?.astNode??n?.astNode):void 0)}}}function isCstNode(t){return t!==void 0&&`element`in t&&`text`in t}function getDocumentURIOrUndefined(t){try{return getDocument(t).uri.toString()}catch{return}}function getSourceRegionOfAstNode(t){let{astNode:n,property:i,index:o}=t??{},s=n?.$cstNode??n?.$textRegion;if(n!==void 0&&s!==void 0){if(i===void 0)return copyDocumentSegment(s,getDocumentURI(n));{let getSingleOrCompoundRegion=t=>o!==void 0&&o>-1&&Array.isArray(n[i])?o<t.length?t[o]:void 0:t.reduce(mergeDocumentSegment,void 0);if(s.assignments?.[i]){let t=getSingleOrCompoundRegion(s.assignments[i]);return t&&copyDocumentSegment(t,getDocumentURI(n))}else if(n.$cstNode){let t=getSingleOrCompoundRegion(findNodesForProperty(n.$cstNode,i));return t&&copyDocumentSegment(t,getDocumentURI(n))}else return}}}function getDocumentURI(t){if(t.$cstNode)return(getDocument(t)?.uri)?.toString();if(t.$textRegion)return t.$textRegion.documentURI||new TreeStreamImpl(t,t=>t.$container?[t.$container]:[]).find(t=>t.$textRegion?.documentURI)?.$textRegion?.documentURI}function copyDocumentSegment(t,n){let i={offset:t.offset,end:t.end??t.offset+t.length,length:t.length??t.end-t.offset};return t.range&&(i.range=t.range),n??=t.fileURI,n&&(i.fileURI=n),i}function mergeDocumentSegment(t,n){if(!t)return n&&copyDocumentSegment(n);if(!n)return t&&copyDocumentSegment(t);let i=t.end??t.offset+t.length,o=n.end??n.offset+n.length,s=Math.min(t.offset,n.offset),c=Math.max(i,o),u={offset:s,end:c,length:c-s};if(t.range&&n.range&&(u.range={start:n.range.start.line<t.range.start.line||n.range.start.line===t.range.start.line&&n.range.start.character<t.range.start.character?n.range.start:t.range.start,end:n.range.end.line>t.range.end.line||n.range.end.line===t.range.end.line&&n.range.end.character>t.range.end.character?n.range.end:t.range.end}),t.fileURI||n.fileURI){let i=t.fileURI,o=n.fileURI;u.fileURI=i&&o&&i!==o?`<unmergable text regions of ${i}, ${o}>`:i??o}return u}var Context=class{constructor(t){this.defaultIndentation=` `,this.pendingIndent=!0,this.currentIndents=[],this.recentNonImmediateIndents=[],this.traceData=[],this.lines=[[]],this.length=0,typeof t==`string`?this.defaultIndentation=t:typeof t==`number`&&(this.defaultIndentation=``.padStart(t))}get content(){return this.lines.map(t=>t.join(``)).join(``)}get contentLength(){return this.length}get currentLineNumber(){return this.lines.length-1}get currentLineContent(){return this.lines[this.currentLineNumber].join(``)}get currentPosition(){return{offset:this.contentLength,line:this.currentLineNumber,character:this.currentLineContent.length}}append(t,n){if(t.length>0){let i=n&&this.currentPosition;this.lines[this.currentLineNumber].push(t),this.length+=t.length,i&&this.indentPendingTraceRegions(i)}}indentPendingTraceRegions(t){for(let n=this.traceData.length-1;n>=0;n--){let i=this.traceData[n];i.targetStart&&i.targetStart.offset===t.offset&&(i.targetStart=this.currentPosition)}}increaseIndent(t){this.currentIndents.push(t),t.indentImmediately||this.recentNonImmediateIndents.push(t)}decreaseIndent(){this.currentIndents.pop()}get relevantIndents(){return this.currentIndents.filter(t=>!this.recentNonImmediateIndents.includes(t))}resetCurrentLine(){this.length-=this.lines[this.currentLineNumber].join(``).length,this.lines[this.currentLineNumber]=[],this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}addNewLine(){this.lines.push([]),this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}pushTraceRegion(t){let n=createTraceRegion(t,this.currentPosition,t=>(this.traceData[this.traceData.length-1]?.children)?.push(t));return this.traceData.push(n),n}popTraceRegion(t){let n=this.traceData.pop();return this.assertTrue(n===t,`Trace region mismatch!`),n}getParentTraceSourceFileURI(){for(let t=this.traceData.length-1;t>-1;t--){let n=this.traceData[t].sourceRegion?.fileURI;if(n)return n}}assertTrue(t,n){if(!t)throw Error(n)}};function createTraceRegion(t,n,i){let o={sourceRegion:t,targetRegion:void 0,children:[],targetStart:n,complete:t=>(o.targetRegion={offset:o.targetStart.offset,end:t.offset,length:t.offset-o.targetStart.offset,range:{start:{line:o.targetStart.line,character:o.targetStart.character},end:{line:t.line,character:t.character}}},delete o.targetStart,o.children?.length===0&&delete o.children,o.targetRegion?.length&&i(o),delete o.complete,o)};return o}function processGeneratorNode(t,n){let i=new Context(n),o=i.pushTraceRegion(void 0);processNodeInternal(t,i),i.popTraceRegion(o),o.complete&&o.complete(i.currentPosition);let s=o.children&&o.children.length===1?o.children[0]:void 0,c=s?.targetRegion,u=o.targetRegion;return c&&s.sourceRegion&&c.offset===u.offset&&c.length===u.length?{text:i.content,trace:s}:{text:i.content,trace:o}}function processNodeInternal(t,n){typeof t==`string`?processStringNode(t,n):t instanceof IndentNode?processIndentNode(t,n):t instanceof $?processCompositeNode(t,n):t instanceof NewLineNode&&processNewLineNode(t,n)}function hasContent(t,n){return typeof t==`string`?t.length!==0:t instanceof $?t.contents.some(t=>hasContent(t,n)):t instanceof NewLineNode&&!(t.ifNotEmpty&&n.currentLineContent.length===0)}function processStringNode(t,n){t&&(handlePendingIndent(n,!1),n.append(t))}function handlePendingIndent(t,n){if(t.pendingIndent){let i=``;for(let o of t.relevantIndents.filter(t=>t.indentEmptyLines||!n))i+=o.indentation??t.defaultIndentation;t.append(i,!0),t.pendingIndent=!1}}function processCompositeNode(t,n){let i,o=getSourceRegion(t.tracedSource);o&&(i=n.pushTraceRegion(o));for(let i of t.contents)processNodeInternal(i,n);if(i){n.popTraceRegion(i);let t=n.getParentTraceSourceFileURI();t&&o?.fileURI===t&&delete o.fileURI,i.complete&&i.complete(n.currentPosition)}}function processIndentNode(t,n){if(hasContent(t,n)){t.indentImmediately&&!n.pendingIndent&&n.append(t.indentation??n.defaultIndentation,!0);try{n.increaseIndent(t),processCompositeNode(t,n)}finally{n.decreaseIndent()}}}function processNewLineNode(t,n){t.ifNotEmpty&&!hasNonWhitespace(n.currentLineContent)?n.resetCurrentLine():(handlePendingIndent(n,!0),n.append(t.lineDelimiter),n.addNewLine())}function hasNonWhitespace(t){return t.trimStart()!==``}Object.freeze(`__«SKIP^NEW^LINE^IF^EMPTY»__`);const yr=/\S|$/;function findIndentation(t){let n=t.filter(t=>t.length>0).map(t=>t.search(yr)),i=n.length===0?0:Math.min(...n);return Math.max(0,i)}function expandToNode(t,...n){return composeFinalGeneratorNode(splitTemplateLinesAndMergeWithSubstitutions(t,n,findIndentationAndTemplateStructure(t)))}function expandTracedToNode(t,n,i){return(o,...s)=>traceToNode(t,n,i)(expandToNode(o,...s))}function findIndentationAndTemplateStructure(t){let n=t.join(`_`).split(at),i=n.length>1&&n[0].trim().length===0,o=i&&n.length>1&&n[n.length-1].trim().length===0;if(n.length===1||n.length!==0&&n[0].trim().length!==0||n.length===2&&n[1].trim().length===0)return{indentation:0,omitFirstLine:i,omitLastLine:o,trimLastLine:n.length!==1&&n[n.length-1].trim().length===0};{let t=i?n.slice(1):n;t=o?t.slice(0,t.length-1):t,t=t.filter(t=>t.length!==0);let s=findIndentation(t);return{indentation:s,omitFirstLine:i,omitLastLine:o&&(n[n.length-1].length<s||!n[n.length-1].startsWith(t[0].substring(0,s)))}}}function splitTemplateLinesAndMergeWithSubstitutions(t,n,{indentation:i,omitFirstLine:o,omitLastLine:s,trimLastLine:c}){let u=[];t.forEach((t,s)=>{u.push(...t.split(at).map((t,n)=>n===0||t.length<i?t:t.substring(i)).reduce(s===0?(t,n,i)=>i===0?o?[]:[n]:i===1&&t.length===0?[n]:t.concat(br,n):(t,n,i)=>i===0?[n]:t.concat(br,n),[]).filter(t=>typeof t!=`string`||t.length!==0).concat(isGeneratorNode(n[s])?n[s]:n[s]===void 0?s<n.length?xr:[]:{content:String(n[s])}))});let f=u.length,p=f===0?void 0:u[f-1];return(s||c)&&typeof p==`string`&&p.trim().length===0?o&&f!==1&&u[f-2]===br?u.slice(0,f-2):u.slice(0,f-1):u}const br={isNewLine:!0},xr={isUndefinedSegment:!0},isNewLineMarker=t=>t===br,isUndefinedSegmentMarker=t=>t===xr,isSubstitutionWrapper=t=>t.content!==void 0;function composeFinalGeneratorNode(t){return t.reduce((n,i,o)=>isUndefinedSegmentMarker(i)?n:isNewLineMarker(i)?{node:o!==0&&(isUndefinedSegmentMarker(t[o-1])||isGeneratorNode(t[o-1]))||o>1&&typeof t[o-1]==`string`&&(isUndefinedSegmentMarker(t[o-2])||isGeneratorNode(t[o-2]))?n.node.appendNewLineIfNotEmpty():n.node.appendNewLine()}:(()=>{let s=(o===0||isNewLineMarker(t[o-1]))&&typeof i==`string`&&i.length!==0?``.padStart(i.length-i.trimStart().length):``,c=isSubstitutionWrapper(i)?i.content:i,u;return{node:n.indented?n.node:s.length===0?n.node.append(c):n.node.indent({indentation:s,indentImmediately:!1,indentedChildren:t=>u=t.append(c)}),indented:u??n.indented?.append(c)}})(),{node:new $}).node}const Sr=typeof process>`u`?`
17
- `:process.platform===`win32`?`\r
18
- `:`
19
- `;function isGeneratorNode(t){return t instanceof $||t instanceof IndentNode||t instanceof NewLineNode}function toString(t,n){return isGeneratorNode(t)?processGeneratorNode(t,n).text:String(t)}var $=class CompositeGeneratorNode{constructor(...t){this.contents=[],this.append(...t)}isEmpty(){return this.contents.length===0}trace(t,n,i){if(isAstNode(t)){if(this.tracedSource={astNode:t,property:n,index:i},this.tracedSource.property===void 0&&this.tracedSource.index!==void 0&&this.tracedSource.index>-1)throw Error(`Generation support: 'property' argument must not be 'undefined' if a non-negative value is assigned to 'index' in 'CompositeGeneratorNode.trace(...)'.`)}else this.tracedSource=t;return this}append(...t){for(let n of t)typeof n==`function`?n(this):n&&this.contents.push(n);return this}appendIf(t,...n){return t?this.append(...n):this}appendNewLine(){return this.append(Cr)}appendNewLineIf(t){return t?this.append(Cr):this}appendNewLineIfNotEmpty(){return this.append(wr)}appendNewLineIfNotEmptyIf(t){return t?this.appendNewLineIfNotEmpty():this}appendTemplate(t,...n){return this.append(expandToNode(t,...n))}appendTemplateIf(t){return t?(t,...n)=>this.appendTemplate(t,...n):()=>this}indent(t){let{indentedChildren:n,indentation:i,indentEmptyLines:o,indentImmediately:s}=Array.isArray(t)||typeof t==`function`?{indentedChildren:t}:typeof t==`object`?t:{},c=new IndentNode(i,s,o);return this.contents.push(c),Array.isArray(n)?c.append(...n):n&&c.append(n),this}appendTraced(t,n,i){return o=>this.append(new CompositeGeneratorNode().trace(t,n,i).append(o))}appendTracedIf(t,n,i,o){return t?this.appendTraced(typeof n==`function`?n():n,i,o):()=>this}appendTracedTemplate(t,n,i){return(o,...s)=>this.append(expandTracedToNode(t,n,i)(o,...s))}appendTracedTemplateIf(t,n,i,o){return t?this.appendTracedTemplate(typeof n==`function`?n():n,i,o):()=>this}};function traceToNode(t,n,i){return o=>o instanceof $&&o.tracedSource===void 0?o.trace(t,n,i):new $().trace(t,n,i).append(o)}var IndentNode=class extends ${constructor(t,n=!0,i=!1){super(),this.indentImmediately=!0,this.indentEmptyLines=!1,typeof t==`string`?this.indentation=t:typeof t==`number`&&(this.indentation=``.padStart(t)),this.indentImmediately=n,this.indentEmptyLines=i}},NewLineNode=class{constructor(t,n=!1){this.ifNotEmpty=!1,this.lineDelimiter=t??Sr,this.ifNotEmpty=n}};const Cr=new NewLineNode,wr=new NewLineNode(void 0,!0),defaultToGenerated=t=>t===void 0||typeof t==`string`||isGeneratorNode(t)?t:String(t);function joinToNode(t,n=defaultToGenerated,i={}){let o=typeof n==`function`?n:defaultToGenerated,{filter:s,prefix:c,suffix:u,separator:f,appendNewLineIfNotEmpty:p,skipNewLineAfterLastItem:h}=typeof n==`object`?n:i,g=typeof c==`function`?c:(()=>c),_=typeof u==`function`?u:(()=>u);return reduceWithIsLast(t,(t,n,i,c)=>{if(s&&!s(n,i,c))return t;let u=o(n,i,c);return u===void 0?t:(t??=new $).append(g(n,i,c)).append(u).append(_(n,i,c)).appendIf(!c,f).appendNewLineIfNotEmptyIf(!t.isEmpty()&&!!p&&(!c||!h))})}function reduceWithIsLast(t,n,i){let o=t[Symbol.iterator](),s=o.next(),c=0,u=i;for(;!s.done;){let t=o.next();u=n(u,s.value,c,!!t.done),s=t,c++}return u}export{findNodeForProperty as $,MultiMap as A,Wt as B,ContextCache as C,MapScope as D,Jn as E,Kn as F,yn as G,Gt as H,interruptAndCheck as I,K as J,vn as K,isOperationCancelled as L,isNamed as M,DefaultLangiumDocuments as N,StreamScope as O,X as P,findNodeForKeyword as Q,DefaultValueConverter as R,DefaultScopeProvider as S,WorkspaceCache as T,W as U,Tt as V,G as W,H as X,U as Y,DefaultCompletionProvider as Z,DefaultIndexManager as _,toString as a,hasContainerOfType as at,JSDocDocumentationProvider as b,vr as c,tt as ct,DefaultWorkspaceSymbolProvider as d,isKeyword as dt,findNodesForProperty as et,AbstractSemanticTokenProvider as f,isRuleCall as ft,DefaultWorkspaceManager as g,DefaultDocumentValidator as h,NewLineNode as i,getDocument as it,DefaultNameProvider as j,DefaultScopeComputation as k,createDefaultModule as l,stream as lt,DefaultDocumentHighlightProvider as m,isAstNode as mt,$ as n,it as nt,NodeFileSystemProvider as o,streamAllContents as ot,AstNodeHoverProvider as p,AbstractAstReflection as pt,an as q,Cr as r,getContainerOfType as rt,AbstractFormatter as s,findCommentNode as st,joinToNode as t,lt as tt,createDefaultSharedModule as u,isCrossReference as ut,loadGrammarFromJson as v,SimpleCache as w,inject as x,ir as y,J as z};
@@ -1,2 +0,0 @@
1
- import"../rolldown-runtime.mjs";function defaultStringLength(e){return e.length}function markdownTable(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||defaultStringLength,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=serialize(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=toAlignment(r[d]);else{let e=toAlignment(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
2
- `)}function serialize(e){return e==null?``:String(e)}function toAlignment(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}export{markdownTable as t};
@@ -1 +0,0 @@
1
- import"../rolldown-runtime.mjs";function escapeStringRegexp(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}const convert=(function(e){if(e==null)return ok;if(typeof e==`function`)return castFactory(e);if(typeof e==`object`)return Array.isArray(e)?anyFactory(e):propsFactory(e);if(typeof e==`string`)return typeFactory(e);throw Error(`Expected function, string, or object as test`)});function anyFactory(e){let t=[],n=-1;for(;++n<e.length;)t[n]=convert(e[n]);return castFactory(any);function any(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function propsFactory(e){let t=e;return castFactory(all);function all(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function typeFactory(e){return castFactory(type);function type(t){return t&&t.type===e}}function castFactory(e){return check;function check(t,n,r){return!!(looksLikeANode(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function ok(){return!0}function looksLikeANode(e){return typeof e==`object`&&!!e&&`type`in e}function color(e){return`\x1B[33m`+e+`\x1B[39m`}const e=[];function visitParents(t,n,r,i){let a;typeof n==`function`&&typeof r!=`function`?(i=r,r=n):a=n;let o=convert(a),s=i?-1:1;factory(t,void 0,[])();function factory(t,a,c){let l=t&&typeof t==`object`?t:{};if(typeof l.type==`string`){let e=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(visit,"name",{value:`node (`+color(t.type+(e?`<`+e+`>`:``))+`)`})}return visit;function visit(){let l=e,u,d,f;if((!n||o(t,a,c[c.length-1]||void 0))&&(l=toResult(r(t,c)),l[0]===!1))return l;if(`children`in t&&t.children){let e=t;if(e.children&&l[0]!==`skip`)for(d=(i?e.children.length:-1)+s,f=c.concat(e);d>-1&&d<e.children.length;){let t=e.children[d];if(u=factory(t,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+s}}return l}}}function toResult(t){return Array.isArray(t)?t:typeof t==`number`?[!0,t]:t==null?e:[t]}function findAndReplace(e,t,n){let r=convert((n||{}).ignore||[]),i=toPairs(t),a=-1;for(;++a<i.length;)visitParents(e,`text`,visitor);function visitor(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return handler(e,t)}function handler(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function toPairs(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([toExpression(e[0]),toFunction(e[1])])}return t}function toExpression(e){return typeof e==`string`?new RegExp(escapeStringRegexp(e),`g`):e}function toFunction(e){return typeof e==`function`?e:function(){return e}}export{visitParents as n,convert as r,findAndReplace as t};