@likec4/mcp 1.48.0 → 1.49.0
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.
- package/dist/THIRD-PARTY-LICENSES.md +2417 -0
- package/dist/_chunks/libs/@chevrotain/gast.mjs +1 -1
- package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -2
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +7 -36
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/_chunks/libs/chevrotain.mjs +30 -30
- package/dist/_chunks/libs/is-error-instance.mjs +1 -1
- package/dist/_chunks/libs/khroma.mjs +1 -1
- package/dist/_chunks/libs/langium.mjs +3 -3
- package/dist/_chunks/libs/merge-error-cause.mjs +2 -2
- package/dist/_chunks/libs/mnemonist.mjs +1 -1
- package/dist/_chunks/libs/p-limit.mjs +1 -1
- package/dist/_chunks/libs/pathe.mjs +1 -0
- package/dist/_chunks/libs/remeda.mjs +1 -1
- package/dist/_chunks/libs/safe-stringify.mjs +1 -1
- package/dist/_chunks/libs/ufo.mjs +1 -1
- package/dist/_chunks/rolldown-runtime.mjs +1 -1
- package/dist/index.mjs +73 -67
- package/package.json +15 -15
- package/dist/_chunks/libs/hono.mjs +0 -1
- package/dist/_chunks/libs/nanoid.mjs +0 -1
|
@@ -17,13 +17,13 @@ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../rolldown-runtime.mjs"
|
|
|
17
17
|
`&&(this.multiline=!0),e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{let e=Xi(t);this.endRegexpStack.push(e),this.isStarting&&(this.startRegexp+=e)}}visitSet(e){if(!this.multiline){let t=this.regex.substring(e.loc.begin,e.loc.end),n=new RegExp(t);this.multiline=!!`
|
|
18
18
|
`.match(n)}if(e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{let t=this.regex.substring(e.loc.begin,e.loc.end);this.endRegexpStack.push(t),this.isStarting&&(this.startRegexp+=t)}}visitChildren(e){e.type===`Group`&&e.quantifier||super.visitChildren(e)}};function qi(e){try{return typeof e==`string`&&(e=new RegExp(e)),e=e.toString(),Ki.reset(e),Ki.visit(Gi.pattern(e)),Ki.multiline}catch{return!1}}const Ji=`\f
|
|
19
19
|
\r \v \xA0 \u2028\u2029 `.split(``);function Yi(e){let t=typeof e==`string`?new RegExp(e):e;return Ji.some(e=>t.test(e))}function Xi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Zi(e,t){let n=Qi(e),r=t.match(n);return!!r&&r[0].length>0}function Qi(e){typeof e==`string`&&(e=new RegExp(e));let t=e,n=e.source,r=0;function i(){let e=``,a;function o(t){e+=n.substr(r,t),r+=t}function s(t){e+=`(?:`+n.substr(r,t)+`|$)`,r+=t}for(;r<n.length;)switch(n[r]){case`\\`:switch(n[r+1]){case`c`:s(3);break;case`x`:s(4);break;case`u`:t.unicode?n[r+2]===`{`?s(n.indexOf(`}`,r)-r+1):s(6):s(2);break;case`p`:case`P`:t.unicode?s(n.indexOf(`}`,r)-r+1):s(2);break;case`k`:s(n.indexOf(`>`,r)-r+1);break;default:s(2);break}break;case`[`:a=/\[(?:\\.|.)*?\]/g,a.lastIndex=r,a=a.exec(n)||[],s(a[0].length);break;case`|`:case`^`:case`$`:case`*`:case`+`:case`?`:o(1);break;case`{`:a=/\{\d+,?\d*\}/g,a.lastIndex=r,a=a.exec(n),a?o(a[0].length):s(1);break;case`(`:if(n[r+1]===`?`)switch(n[r+2]){case`:`:e+=`(?:`,r+=3,e+=i()+`|$)`;break;case`=`:e+=`(?=`,r+=3,e+=i()+`)`;break;case`!`:a=r,r+=3,i(),e+=n.substr(a,r-a);break;case`<`:switch(n[r+3]){case`=`:case`!`:a=r,r+=4,i(),e+=n.substr(a,r-a);break;default:o(n.indexOf(`>`,r)-r+1),e+=i()+`|$)`;break}break}else o(1),e+=i()+`|$)`;break;case`)`:return++r,e;default:s(1);break}return e}return new RegExp(i(),e.flags)}var $i=i({findAssignment:()=>pa,findNameAssignment:()=>ma,findNodeForKeyword:()=>da,findNodeForProperty:()=>ca,findNodesForKeyword:()=>ua,findNodesForKeywordInternal:()=>fa,findNodesForProperty:()=>sa,getActionAtElement:()=>ga,getActionType:()=>Ea,getAllReachableRules:()=>na,getAllRulesUsedForCrossReferences:()=>ia,getCrossReferenceTerminal:()=>aa,getEntryRule:()=>ea,getExplicitRuleType:()=>wa,getHiddenRules:()=>ta,getRuleType:()=>Oa,getRuleTypeName:()=>Da,getTypeName:()=>Ta,isArrayCardinality:()=>va,isArrayOperator:()=>ya,isCommentTerminal:()=>oa,isDataType:()=>Sa,isDataTypeRule:()=>ba,isOptionalCardinality:()=>_a,terminalRegex:()=>ka});function ea(e){return e.rules.find(e=>U(e)&&e.entry)}function ta(e){return e.rules.filter(e=>hr(e)&&e.hidden)}function na(e,t){let n=new Set,r=ea(e);if(!r)return new Set(e.rules);let i=[r].concat(ta(e));for(let e of i)ra(e,n,t);let a=new Set;for(let t of e.rules)(n.has(t.name)||hr(t)&&t.hidden)&&a.add(t);return a}function ra(e,t,n){t.add(e.name),Pi(e).forEach(e=>{if(Hr(e)||n&&Jr(e)){let r=e.rule.ref;r&&!t.has(r.name)&&ra(r,t,n)}})}function ia(e){let t=new Set;return Pi(e).forEach(e=>{Ar(e)&&(U(e.type.ref)&&t.add(e.type.ref),Xn(e.type.ref)&&U(e.type.ref.$container)&&t.add(e.type.ref.$container))}),t}function aa(e){if(e.terminal)return e.terminal;if(e.type.ref)return ma(e.type.ref)?.terminal}function oa(e){return e.hidden&&!Yi(ka(e))}function sa(e,t){return!e||!t?[]:la(e,t,e.astNode,!0)}function ca(e,t,n){if(!e||!t)return;let r=la(e,t,e.astNode,!0);if(r.length!==0)return n=n===void 0?0:Math.max(0,Math.min(n,r.length-1)),r[n]}function la(e,t,n,r){if(!r){let n=Ai(e.grammarSource,Er);if(n&&n.feature===t)return[e]}return On(e)&&e.astNode===n?e.content.flatMap(e=>la(e,t,n,!1)):[]}function ua(e,t){return e?fa(e,t,e?.astNode):[]}function da(e,t,n){if(!e)return;let r=fa(e,t,e?.astNode);if(r.length!==0)return n=n===void 0?0:Math.max(0,Math.min(n,r.length-1)),r[n]}function fa(e,t,n){if(e.astNode!==n)return[];if(Ir(e.grammarSource)&&e.grammarSource.value===t)return[e];let r=ci(e).iterator(),i,a=[];do if(i=r.next(),!i.done){let e=i.value;e.astNode===n?Ir(e.grammarSource)&&e.grammarSource.value===t&&a.push(e):r.prune()}while(!i.done);return a}function pa(e){let t=e.astNode;for(;t===e.container?.astNode;){let t=Ai(e.grammarSource,Er);if(t)return t;e=e.container}}function ma(e){let t=e;return Xn(t)&&(Sr(t.$container)?t=t.$container.$container:U(t.$container)?t=t.$container:Ui(t.$container)),ha(e,t,new Map)}function ha(e,t,n){function r(t,r){let i;return Ai(t,Er)||(i=ha(r,r,n)),n.set(e,i),i}if(n.has(e))return n.get(e);n.set(e,void 0);for(let i of Pi(t))if(Er(i)&&i.feature.toLowerCase()===`name`)return n.set(e,i),i;else if(Hr(i)&&U(i.rule.ref))return r(i,i.rule.ref);else if(fr(i)&&i.typeRef?.ref)return r(i,i.typeRef.ref)}function ga(e){let t=e.$container;if(Pr(t)){let n=t.elements,r=n.indexOf(e);for(let e=r-1;e>=0;e--){let t=n[e];if(Sr(t))return t;{let t=Pi(n[e]).find(Sr);if(t)return t}}}if(Ln(t))return ga(t)}function _a(e,t){return e===`?`||e===`*`||Pr(t)&&!!t.guardCondition}function va(e){return e===`*`||e===`+`}function ya(e){return e===`+=`}function ba(e){return xa(e,new Set)}function xa(e,t){if(t.has(e))return!0;t.add(e);for(let n of Pi(e))if(Hr(n)){if(!n.rule.ref||U(n.rule.ref)&&!xa(n.rule.ref,t))return!1}else if(Er(n))return!1;else if(Sr(n))return!1;return!!e.definition}function Sa(e){return Ca(e.type,new Set)}function Ca(e,t){if(t.has(e))return!0;if(t.add(e),Bn(e)||cr(e))return!1;if(br(e))return e.types.every(e=>Ca(e,t));if(fr(e)){if(e.primitiveType!==void 0||e.stringType!==void 0)return!0;if(e.typeRef!==void 0){let n=e.typeRef.ref;return _r(n)?Ca(n.type,t):!1}else return!1}else return!1}function wa(e){if(e.inferredType)return e.inferredType.name;if(e.dataType)return e.dataType;if(e.returnType){let t=e.returnType.ref;if(t&&(U(t)||Qn(t)||_r(t)))return t.name}}function Ta(e){if(U(e))return ba(e)?e.name:wa(e)??e.name;if(Qn(e)||_r(e)||ur(e))return e.name;if(Sr(e)){let t=Ea(e);if(t)return t}else if(Xn(e))return e.name;throw Error(`Cannot get name of Unknown Type`)}function Ea(e){if(e.inferredType)return e.inferredType.name;if(e.type?.ref)return Ta(e.type.ref)}function Da(e){return hr(e)?e.type?.name??`string`:ba(e)?e.name:wa(e)??e.name}function Oa(e){return hr(e)?e.type?.name??`string`:wa(e)??e.name}function ka(e){let t={s:!1,i:!1,u:!1},n=ja(e.definition,t),r=Object.entries(t).filter(([,e])=>e).map(([e])=>e).join(``);return new RegExp(n,r)}const Aa=`[\\s\\S]`;function ja(e,t){if(Wr(e))return Ma(e);if(Kr(e))return Na(e);if(Or(e))return Ia(e);if(Jr(e)){let t=e.rule.ref;if(!t)throw Error(`Missing rule reference.`);return Ra(ja(t.definition),{cardinality:e.cardinality,lookahead:e.lookahead})}else if(Rr(e))return Fa(e);else if(Qr(e))return Pa(e);else if(Br(e)){let n=e.regex.lastIndexOf(`/`),r=e.regex.substring(1,n),i=e.regex.substring(n+1);return t&&(t.i=i.includes(`i`),t.s=i.includes(`s`),t.u=i.includes(`u`)),Ra(r,{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1})}else if(ei(e))return Ra(Aa,{cardinality:e.cardinality,lookahead:e.lookahead});else throw Error(`Invalid terminal element: ${e?.$type}`)}function Ma(e){return Ra(e.elements.map(e=>ja(e)).join(`|`),{cardinality:e.cardinality,lookahead:e.lookahead})}function Na(e){return Ra(e.elements.map(e=>ja(e)).join(``),{cardinality:e.cardinality,lookahead:e.lookahead})}function Pa(e){return Ra(`${Aa}*?${ja(e.terminal)}`,{cardinality:e.cardinality,lookahead:e.lookahead})}function Fa(e){return Ra(`(?!${ja(e.terminal)})${Aa}*?`,{cardinality:e.cardinality,lookahead:e.lookahead})}function Ia(e){return e.right?Ra(`[${La(e.left)}-${La(e.right)}]`,{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1}):Ra(La(e.left),{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1})}function La(e){return Xi(e.value)}function Ra(e,t){return(t.wrap!==!1||t.lookahead)&&(e=`(${t.lookahead??``}${e})`),t.cardinality?`${e}${t.cardinality}`:e}function za(e,t){let n={stacks:e,tokens:t};return Ga(n),n.stacks.flat().forEach(e=>{e.property=void 0}),Ka(n.stacks).map(e=>e[e.length-1])}function Ba(e){let{next:t,cardinalities:n,visited:r,plus:i}=e,a=[],o=t.feature;if(r.has(o))return[];Pr(o)||r.add(o);let s,c=o;for(;c.$container;)if(Pr(c.$container)){s=c.$container;break}else if(Ln(c.$container))c=c.$container;else break;if(va(c.cardinality)){let e=Ha({next:{feature:c,type:t.type},cardinalities:n,visited:r,plus:i});for(let t of e)i.add(t.feature);a.push(...e)}if(s){let e=s.elements.indexOf(c);e!==void 0&&e<s.elements.length-1&&a.push(...Wa({feature:s,type:t.type},e+1,n,r,i)),a.every(e=>_a(e.feature.cardinality,e.feature)||_a(n.get(e.feature))||i.has(e.feature))&&a.push(...Ba({next:{feature:s,type:t.type},cardinalities:n,visited:r,plus:i}))}return a}function Va(e){return H(e)&&(e={feature:e}),Ha({next:e,cardinalities:new Map,visited:new Set,plus:new Set})}function Ha(e){let{next:t,cardinalities:n,visited:r,plus:i}=e;if(t===void 0)return[];let{feature:a,type:o}=t;if(Pr(a))return r.has(a)?[]:(r.add(a),Wa(t,0,n,r,i).map(e=>Ua(e,a.cardinality,n)));if(wr(a)||Xr(a))return a.elements.flatMap(e=>Ha({next:{feature:e,type:o,property:t.property},cardinalities:n,visited:r,plus:i})).map(e=>Ua(e,a.cardinality,n));if(Er(a))return Ha({next:{feature:a.terminal,type:o,property:t.property??a.feature},cardinalities:n,visited:r,plus:i}).map(e=>Ua(e,a.cardinality,n));if(Sr(a))return Ba({next:{feature:a,type:Ta(a),property:t.property??a.feature},cardinalities:n,visited:r,plus:i});if(Hr(a)&&U(a.rule.ref)){let e=a.rule.ref;return Ha({next:{feature:e.definition,type:e.fragment||e.dataType?void 0:wa(e)??e.name,property:t.property},cardinalities:n,visited:r,plus:i}).map(e=>Ua(e,a.cardinality,n))}else return[t]}function Ua(e,t,n){return n.set(e.feature,t),e}function Wa(e,t,n,r,i){let a=[],o;for(;t<e.feature.elements.length&&(o={feature:e.feature.elements[t++],type:e.type},a.push(...Ha({next:o,cardinalities:n,visited:r,plus:i})),_a(o.feature.cardinality??n.get(o.feature),o.feature)););return a}function Ga(e){for(let t of e.tokens)e.stacks=Ka(e.stacks,t)}function Ka(e,t){let n=[];for(let r of e)n.push(...qa(r,t));return n}function qa(e,t){let n=new Map,r=new Set(e.map(e=>e.feature).filter(Ja)),i=[];for(;e.length>0;){let a=Ba({next:e.pop(),cardinalities:n,plus:r,visited:new Set}).filter(e=>t?Ya(e.feature,t):!0);for(let t of a)i.push([...e,t]);if(!a.every(e=>_a(e.feature.cardinality,e.feature)||_a(n.get(e.feature))))break}return i}function Ja(e){if(e.cardinality===`+`)return!0;let t=Ai(e,Er);return!!(t&&t.cardinality===`+`)}function Ya(e,t){if(Ir(e))return e.value===t.image;if(Hr(e))return Xa(e.rule.ref,t);if(Ar(e)){let n=aa(e);if(n)return Ya(n,t)}return!1}function Xa(e,t){return U(e)?Va(e.definition).some(e=>Ya(e.feature,t)):hr(e)?ka(e).test(t.image):!1}var J=Cn();function Za(e){let t=Array.from(new Set(e.flatMap(e=>e?.triggerCharacters??[]))),n=Array.from(new Set(e.flatMap(e=>e?.allCommitCharacters??[])));return{triggerCharacters:t.length>0?t:void 0,allCommitCharacters:n.length>0?n:void 0}}var Qa=class{constructor(e){this.scopeProvider=e.references.ScopeProvider,this.grammar=e.Grammar,this.completionParser=e.parser.CompletionParser,this.nameProvider=e.references.NameProvider,this.lexer=e.parser.Lexer,this.nodeKindProvider=e.shared.lsp.NodeKindProvider,this.fuzzyMatcher=e.shared.lsp.FuzzyMatcher,this.grammarConfig=e.parser.GrammarConfig,this.astReflection=e.shared.AstReflection,this.documentationProvider=e.documentation.DocumentationProvider}async getCompletion(e,t,n){let r=[],i=this.buildContexts(e,t.position),a=(e,t)=>{let n=this.fillCompletionItem(e,t);n&&r.push(n)},o=e=>Ir(e.feature)?e.feature.value:e.feature,s=[];for(let e of i)if(await Promise.all(K(e.features).distinct(o).exclude(s).map(t=>this.completionFor(e,t,a))),s.push(...e.features),!this.continueCompletion(r))break;return J.CompletionList.create(this.deduplicateItems(r),!0)}deduplicateItems(e){return K(e).distinct(e=>`${e.kind}_${e.label}_${e.detail}`).toArray()}findFeaturesAt(e,t){let n=e.getText({start:J.Position.create(0,0),end:e.positionAt(t)}),r=this.completionParser.parse(n),i=r.tokens;if(r.tokenIndex===0){let e=ea(this.grammar),t=Va({feature:e.definition,type:wa(e)});return i.length>0?(i.shift(),za(t.map(e=>[e]),i)):t}let a=[...i].splice(r.tokenIndex);return za([r.elementStack.map(e=>({feature:e}))],a)}*buildContexts(e,t){let n=e.parseResult.value.$cstNode;if(!n)return;let r=e.textDocument,i=r.getText(),a=r.offsetAt(t),o={document:e,textDocument:r,offset:a,position:t},s=this.findDataTypeRuleStart(n,a);if(s){let[e,t]=s,i=xi(n,e)?.astNode;yield Object.assign(Object.assign({},o),{node:i,tokenOffset:e,tokenEndOffset:t,features:this.findFeaturesAt(r,e)})}let{nextTokenStart:c,nextTokenEnd:l,previousTokenStart:u,previousTokenEnd:d}=this.backtrackToAnyToken(i,a),f=c;a<=c&&u!==void 0&&(f=u);let p=xi(n,f)?.astNode,m=!0;if(u!==void 0&&d!==void 0&&d===a&&(yield Object.assign(Object.assign({},o),{node:p,tokenOffset:u,tokenEndOffset:d,features:this.findFeaturesAt(r,u)}),m=this.performNextTokenCompletion(e,i.substring(u,d),u,d),m&&(yield Object.assign(Object.assign({},o),{node:p,tokenOffset:d,tokenEndOffset:d,features:this.findFeaturesAt(r,d)}))),p)m&&(yield Object.assign(Object.assign({},o),{node:p,tokenOffset:c,tokenEndOffset:l,features:this.findFeaturesAt(r,c)}));else{let e=ea(this.grammar);if(!e)throw Error(`Missing entry parser rule`);yield Object.assign(Object.assign({},o),{tokenOffset:c,tokenEndOffset:l,features:Va(e.definition)})}}performNextTokenCompletion(e,t,n,r){return/\P{L}$/u.test(t)}findDataTypeRuleStart(e,t){let n=_i(e,t,this.grammarConfig.nameRegexp),r=!!Ai(n?.grammarSource,U)?.dataType;if(r){for(;r;)n=n?.container,r=!!Ai(n?.grammarSource,U)?.dataType;if(n)return[n.offset,n.end]}}continueCompletion(e){return e.length===0}backtrackToAnyToken(e,t){let n=this.lexer.tokenize(e).tokens;if(n.length===0)return{nextTokenStart:t,nextTokenEnd:t};let r;for(let e of n){if(e.startOffset>=t)return{nextTokenStart:t,nextTokenEnd:t,previousTokenStart:r?r.startOffset:void 0,previousTokenEnd:r?r.endOffset+1:void 0};if(e.endOffset>=t)return{nextTokenStart:e.startOffset,nextTokenEnd:e.endOffset+1,previousTokenStart:r?r.startOffset:void 0,previousTokenEnd:r?r.endOffset+1:void 0};r=e}return{nextTokenStart:t,nextTokenEnd:t,previousTokenStart:r?r.startOffset:void 0,previousTokenEnd:r?r.endOffset+1:void 0}}completionFor(e,t,n){if(Ir(t.feature))return this.completionForKeyword(e,t.feature,n);if(Ar(t.feature)&&e.node)return this.completionForCrossReference(e,t,n)}completionForCrossReference(e,t,n){let r=Ai(t.feature,Er),i=e.node;if(r&&i){t.type&&(i={$type:t.type,$container:i,$containerProperty:t.property},zi(this.astReflection,i));let a={reference:{$refText:``},container:i,property:r.feature};try{for(let t of this.getReferenceCandidates(a,e))n(e,this.createReferenceCompletionItem(t))}catch(e){console.error(e)}}}getReferenceCandidates(e,t){return this.scopeProvider.getScope(e).getAllElements()}createReferenceCompletionItem(e){return{nodeDescription:e,kind:this.nodeKindProvider.getCompletionItemKind(e),documentation:this.getReferenceDocumentation(e),detail:e.type,sortText:`0`}}getReferenceDocumentation(e){if(!e.node)return;let t=this.documentationProvider.getDocumentation(e.node);if(t)return{kind:`markdown`,value:t}}completionForKeyword(e,t,n){this.filterKeyword(e,t)&&n(e,{label:t.value,kind:this.getKeywordCompletionItemKind(t),detail:`Keyword`,sortText:`1`})}getKeywordCompletionItemKind(e){return J.CompletionItemKind.Keyword}filterKeyword(e,t){return/\p{L}/u.test(t.value)}fillCompletionItem(e,t){let n;if(typeof t.label==`string`)n=t.label;else if(`node`in t){let e=this.nameProvider.getName(t.node);if(!e)return;n=e}else if(`nodeDescription`in t)n=t.nodeDescription.name;else return;let r;r=typeof t.textEdit?.newText==`string`?t.textEdit.newText:typeof t.insertText==`string`?t.insertText:n;let i=t.textEdit??this.buildCompletionTextEdit(e,n,r);if(i)return{additionalTextEdits:t.additionalTextEdits,command:t.command,commitCharacters:t.commitCharacters,data:t.data,detail:t.detail,documentation:t.documentation,filterText:t.filterText,insertText:t.insertText,insertTextFormat:t.insertTextFormat,insertTextMode:t.insertTextMode,kind:t.kind,labelDetails:t.labelDetails,preselect:t.preselect,sortText:t.sortText,tags:t.tags,textEditText:t.textEditText,textEdit:i,label:n}}buildCompletionTextEdit(e,t,n){let r=e.textDocument.getText().substring(e.tokenOffset,e.offset);if(this.fuzzyMatcher.match(r,t))return{newText:n,range:{start:e.textDocument.positionAt(e.tokenOffset),end:e.position}}}},$a;(()=>{var e={975:e=>{function t(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}function n(e,t){for(var n,r=``,i=0,a=-1,o=0,s=0;s<=e.length;++s){if(s<e.length)n=e.charCodeAt(s);else{if(n===47)break;n=47}if(n===47){if(!(a===s-1||o===1))if(a!==s-1&&o===2){if(r.length<2||i!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){var c=r.lastIndexOf(`/`);if(c!==r.length-1){c===-1?(r=``,i=0):i=(r=r.slice(0,c)).length-1-r.lastIndexOf(`/`),a=s,o=0;continue}}else if(r.length===2||r.length===1){r=``,i=0,a=s,o=0;continue}}t&&(r.length>0?r+=`/..`:r=`..`,i=2)}else r.length>0?r+=`/`+e.slice(a+1,s):r=e.slice(a+1,s),i=s-a-1;a=s,o=0}else n===46&&o!==-1?++o:o=-1}return r}var r={resolve:function(){for(var e,r=``,i=!1,a=arguments.length-1;a>=-1&&!i;a--){var o;a>=0?o=arguments[a]:(e===void 0&&(e=process.cwd()),o=e),t(o),o.length!==0&&(r=o+`/`+r,i=o.charCodeAt(0)===47)}return r=n(r,!i),i?r.length>0?`/`+r:`/`:r.length>0?r:`.`},normalize:function(e){if(t(e),e.length===0)return`.`;var r=e.charCodeAt(0)===47,i=e.charCodeAt(e.length-1)===47;return(e=n(e,!r)).length!==0||r||(e=`.`),e.length>0&&i&&(e+=`/`),r?`/`+e:e},isAbsolute:function(e){return t(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return`.`;for(var e,n=0;n<arguments.length;++n){var i=arguments[n];t(i),i.length>0&&(e===void 0?e=i:e+=`/`+i)}return e===void 0?`.`:r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n||(e=r.resolve(e))===(n=r.resolve(n)))return``;for(var i=1;i<e.length&&e.charCodeAt(i)===47;++i);for(var a=e.length,o=a-i,s=1;s<n.length&&n.charCodeAt(s)===47;++s);for(var c=n.length-s,l=o<c?o:c,u=-1,d=0;d<=l;++d){if(d===l){if(c>l){if(n.charCodeAt(s+d)===47)return n.slice(s+d+1);if(d===0)return n.slice(s+d)}else o>l&&(e.charCodeAt(i+d)===47?u=d:d===0&&(u=0));break}var f=e.charCodeAt(i+d);if(f!==n.charCodeAt(s+d))break;f===47&&(u=d)}var p=``;for(d=i+u+1;d<=a;++d)d!==a&&e.charCodeAt(d)!==47||(p.length===0?p+=`..`:p+=`/..`);return p.length>0?p+n.slice(s+u):(s+=u,n.charCodeAt(s)===47&&++s,n.slice(s))},_makeLong:function(e){return e},dirname:function(e){if(t(e),e.length===0)return`.`;for(var n=e.charCodeAt(0),r=n===47,i=-1,a=!0,o=e.length-1;o>=1;--o)if((n=e.charCodeAt(o))===47){if(!a){i=o;break}}else a=!1;return i===-1?r?`/`:`.`:r&&i===1?`//`:e.slice(0,i)},basename:function(e,n){if(n!==void 0&&typeof n!=`string`)throw TypeError(`"ext" argument must be a string`);t(e);var r,i=0,a=-1,o=!0;if(n!==void 0&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return``;var s=n.length-1,c=-1;for(r=e.length-1;r>=0;--r){var l=e.charCodeAt(r);if(l===47){if(!o){i=r+1;break}}else c===-1&&(o=!1,c=r+1),s>=0&&(l===n.charCodeAt(s)?--s==-1&&(a=r):(s=-1,a=c))}return i===a?a=c:a===-1&&(a=e.length),e.slice(i,a)}for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===47){if(!o){i=r+1;break}}else a===-1&&(o=!1,a=r+1);return a===-1?``:e.slice(i,a)},extname:function(e){t(e);for(var n=-1,r=0,i=-1,a=!0,o=0,s=e.length-1;s>=0;--s){var c=e.charCodeAt(s);if(c!==47)i===-1&&(a=!1,i=s+1),c===46?n===-1?n=s:o!==1&&(o=1):n!==-1&&(o=-1);else if(!a){r=s+1;break}}return n===-1||i===-1||o===0||o===1&&n===i-1&&n===r+1?``:e.slice(n,i)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+`/`+r:r}(0,e)},parse:function(e){t(e);var n={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return n;var r,i=e.charCodeAt(0),a=i===47;a?(n.root=`/`,r=1):r=0;for(var o=-1,s=0,c=-1,l=!0,u=e.length-1,d=0;u>=r;--u)if((i=e.charCodeAt(u))!==47)c===-1&&(l=!1,c=u+1),i===46?o===-1?o=u:d!==1&&(d=1):o!==-1&&(d=-1);else if(!l){s=u+1;break}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===s+1?c!==-1&&(n.base=n.name=s===0&&a?e.slice(1,c):e.slice(s,c)):(s===0&&a?(n.name=e.slice(1,o),n.base=e.slice(1,c)):(n.name=e.slice(s,o),n.base=e.slice(s,c)),n.ext=e.slice(o,c)),s>0?n.dir=e.slice(0,s-1):a&&(n.dir=`/`),n},sep:`/`,delimiter:`:`,win32:null,posix:null};r.posix=r,e.exports=r}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,`__esModule`,{value:!0})};var r={};let i;n.r(r),n.d(r,{URI:()=>u,Utils:()=>C}),typeof process==`object`?i=process.platform===`win32`:typeof navigator==`object`&&(i=navigator.userAgent.indexOf(`Windows`)>=0);let a=/^\w[\w\d+.-]*$/,o=/^\//,s=/^\/\//;function c(e,t){if(!e.scheme&&t)throw Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!a.test(e.scheme))throw Error(`[UriError]: Scheme contains illegal characters.`);if(e.path){if(e.authority){if(!o.test(e.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(s.test(e.path))throw Error(`[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")`)}}let l=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class u{static isUri(e){return e instanceof u||!!e&&typeof e.authority==`string`&&typeof e.fragment==`string`&&typeof e.path==`string`&&typeof e.query==`string`&&typeof e.scheme==`string`&&typeof e.fsPath==`string`&&typeof e.with==`function`&&typeof e.toString==`function`}scheme;authority;path;query;fragment;constructor(e,t,n,r,i,a=!1){typeof e==`object`?(this.scheme=e.scheme||``,this.authority=e.authority||``,this.path=e.path||``,this.query=e.query||``,this.fragment=e.fragment||``):(this.scheme=function(e,t){return e||t?e:`file`}(e,a),this.authority=t||``,this.path=function(e,t){switch(e){case`https`:case`http`:case`file`:t?t[0]!==`/`&&(t=`/`+t):t=`/`}return t}(this.scheme,n||``),this.query=r||``,this.fragment=i||``,c(this,a))}get fsPath(){return g(this,!1)}with(e){if(!e)return this;let{scheme:t,authority:n,path:r,query:i,fragment:a}=e;return t===void 0?t=this.scheme:t===null&&(t=``),n===void 0?n=this.authority:n===null&&(n=``),r===void 0?r=this.path:r===null&&(r=``),i===void 0?i=this.query:i===null&&(i=``),a===void 0?a=this.fragment:a===null&&(a=``),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&a===this.fragment?this:new f(t,n,r,i,a)}static parse(e,t=!1){let n=l.exec(e);return n?new f(n[2]||``,b(n[4]||``),b(n[5]||``),b(n[7]||``),b(n[9]||``),t):new f(``,``,``,``,``)}static file(e){let t=``;if(i&&(e=e.replace(/\\/g,`/`)),e[0]===`/`&&e[1]===`/`){let n=e.indexOf(`/`,2);n===-1?(t=e.substring(2),e=`/`):(t=e.substring(2,n),e=e.substring(n)||`/`)}return new f(`file`,t,e,``,``)}static from(e){let t=new f(e.scheme,e.authority,e.path,e.query,e.fragment);return c(t,!0),t}toString(e=!1){return _(this,e)}toJSON(){return this}static revive(e){if(e){if(e instanceof u)return e;{let t=new f(e);return t._formatted=e.external,t._fsPath=e._sep===d?e.fsPath:null,t}}return e}}let d=i?1:void 0;class f extends u{_formatted=null;_fsPath=null;get fsPath(){return this._fsPath||=g(this,!1),this._fsPath}toString(e=!1){return e?_(this,!0):(this._formatted||=_(this,!1),this._formatted)}toJSON(){let e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath,e._sep=d),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e}}let p={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(e,t,n){let r,i=-1;for(let a=0;a<e.length;a++){let o=e.charCodeAt(a);if(o>=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||o===45||o===46||o===95||o===126||t&&o===47||n&&o===91||n&&o===93||n&&o===58)i!==-1&&(r+=encodeURIComponent(e.substring(i,a)),i=-1),r!==void 0&&(r+=e.charAt(a));else{r===void 0&&(r=e.substr(0,a));let t=p[o];t===void 0?i===-1&&(i=a):(i!==-1&&(r+=encodeURIComponent(e.substring(i,a)),i=-1),r+=t)}}return i!==-1&&(r+=encodeURIComponent(e.substring(i))),r===void 0?e:r}function h(e){let t;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===35||r===63?(t===void 0&&(t=e.substr(0,n)),t+=p[r]):t!==void 0&&(t+=e[n])}return t===void 0?e:t}function g(e,t){let n;return n=e.authority&&e.path.length>1&&e.scheme===`file`?`//${e.authority}${e.path}`:e.path.charCodeAt(0)===47&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&e.path.charCodeAt(2)===58?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,i&&(n=n.replace(/\//g,`\\`)),n}function _(e,t){let n=t?h:m,r=``,{scheme:i,authority:a,path:o,query:s,fragment:c}=e;if(i&&(r+=i,r+=`:`),(a||i===`file`)&&(r+=`/`,r+=`/`),a){let e=a.indexOf(`@`);if(e!==-1){let t=a.substr(0,e);a=a.substr(e+1),e=t.lastIndexOf(`:`),e===-1?r+=n(t,!1,!1):(r+=n(t.substr(0,e),!1,!1),r+=`:`,r+=n(t.substr(e+1),!1,!0)),r+=`@`}a=a.toLowerCase(),e=a.lastIndexOf(`:`),e===-1?r+=n(a,!1,!0):(r+=n(a.substr(0,e),!1,!0),r+=a.substr(e))}if(o){if(o.length>=3&&o.charCodeAt(0)===47&&o.charCodeAt(2)===58){let e=o.charCodeAt(1);e>=65&&e<=90&&(o=`/${String.fromCharCode(e+32)}:${o.substr(3)}`)}else if(o.length>=2&&o.charCodeAt(1)===58){let e=o.charCodeAt(0);e>=65&&e<=90&&(o=`${String.fromCharCode(e+32)}:${o.substr(2)}`)}r+=n(o,!0,!1)}return s&&(r+=`?`,r+=n(s,!1,!1)),c&&(r+=`#`,r+=t?c:m(c,!1,!1)),r}function v(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+v(e.substr(3)):e}}let y=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function b(e){return e.match(y)?e.replace(y,(e=>v(e))):e}var x=n(975);let S=x.posix||x;var C;(function(e){e.joinPath=function(e,...t){return e.with({path:S.join(e.path,...t)})},e.resolvePath=function(e,...t){let n=e.path,r=!1;n[0]!==`/`&&(n=`/`+n,r=!0);let i=S.resolve(n,...t);return r&&i[0]===`/`&&!e.authority&&(i=i.substring(1)),e.with({path:i})},e.dirname=function(e){if(e.path.length===0||e.path===`/`)return e;let t=S.dirname(e.path);return t.length===1&&t.charCodeAt(0)===46&&(t=``),e.with({path:t})},e.basename=function(e){return S.basename(e.path)},e.extname=function(e){return S.extname(e.path)}})(C||={}),$a=r})();const{URI:Y,Utils:eo}=$a;var X;(function(e){e.basename=eo.basename,e.dirname=eo.dirname,e.extname=eo.extname,e.joinPath=eo.joinPath,e.resolvePath=eo.resolvePath;let t=typeof process==`object`&&(process==null?void 0:process.platform)===`win32`;function n(e,t){return e?.toString()===t?.toString()}e.equals=n;function r(e,n){let r=typeof e==`string`?Y.parse(e).path:e.path,i=typeof n==`string`?Y.parse(n).path:n.path,a=r.split(`/`).filter(e=>e.length>0),o=i.split(`/`).filter(e=>e.length>0);if(t){let e=/^[A-Z]:$/;if(a[0]&&e.test(a[0])&&(a[0]=a[0].toLowerCase()),o[0]&&e.test(o[0])&&(o[0]=o[0].toLowerCase()),a[0]!==o[0])return i.substring(1)}let s=0;for(;s<a.length&&a[s]===o[s];s++);return`../`.repeat(a.length-s)+o.slice(s).join(`/`)}e.relative=r;function i(e){return Y.parse(e.toString()).toString()}e.normalize=i})(X||={});var to=class{constructor(e){this.nameProvider=e.references.NameProvider,this.references=e.references.References,this.grammarConfig=e.parser.GrammarConfig}getDefinition(e,t,n){let r=e.parseResult.value;if(r.$cstNode){let n=r.$cstNode,i=_i(n,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);if(i)return this.collectLocationLinks(i,t)}}collectLocationLinks(e,t){let n=this.findLink(e);if(n)return[J.LocationLink.create(n.targetDocument.textDocument.uri,(n.target.astNode.$cstNode??n.target).range,n.target.range,n.source.range)]}findLink(e){let t=this.references.findDeclarationNode(e);if(t?.astNode){let n=q(t.astNode);if(t&&n)return{source:e,target:t,targetDocument:n}}}};function no(e){let t=[],n=e.Grammar;for(let e of n.rules)hr(e)&&oa(e)&&qi(ka(e))&&t.push(e.name);return{multilineCommentRules:t,nameRegexp:gi}}Ot();var ro=class{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]??this.rootNode}buildRootNode(e){return this.rootNode=new co(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){let t=new oo;return t.grammarSource=e,t.root=this.rootNode,this.current.content.push(t),this.nodeStack.push(t),t}buildLeafNode(e,t){let n=new ao(e.startOffset,e.image.length,di(e),e.tokenType,!t);return n.grammarSource=t,n.root=this.rootNode,this.current.content.push(n),n}removeNode(e){let t=e.container;if(t){let n=t.content.indexOf(e);n>=0&&t.content.splice(n,1)}}addHiddenNodes(e){let t=[];for(let n of e){let e=new ao(n.startOffset,n.image.length,di(n),n.tokenType,!0);e.root=this.rootNode,t.push(e)}let n=this.current,r=!1;if(n.content.length>0){n.content.push(...t);return}for(;n.container;){let e=n.container.content.indexOf(n);if(e>0){n.container.content.splice(e,0,...t),r=!0;break}n=n.container}r||this.rootNode.content.unshift(...t)}construct(e){let t=this.current;typeof e.$type==`string`&&(this.current.astNode=e),e.$cstNode=t;let n=this.nodeStack.pop();n?.content.length===0&&this.removeNode(n)}},io=class{get parent(){return this.container}get feature(){return this.grammarSource}get hidden(){return!1}get astNode(){let e=typeof this._astNode?.$type==`string`?this._astNode:this.container?.astNode;if(!e)throw Error(`This node has no associated AST element`);return e}set astNode(e){this._astNode=e}get element(){return this.astNode}get text(){return this.root.fullText.substring(this.offset,this.end)}},ao=class extends io{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(e,t,n,r,i=!1){super(),this._hidden=i,this._offset=e,this._tokenType=r,this._length=t,this._range=n}},oo=class extends io{constructor(){super(...arguments),this.content=new so(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 e=this.firstNonHiddenNode,t=this.lastNonHiddenNode;if(e&&t){if(this._rangeCache===void 0){let{range:n}=e,{range:r}=t;this._rangeCache={start:n.start,end:r.end.line<n.start.line?n.start:r.end}}return this._rangeCache}else return{start:F.create(0,0),end:F.create(0,0)}}get firstNonHiddenNode(){for(let e of this.content)if(!e.hidden)return e;return this.content[0]}get lastNonHiddenNode(){for(let e=this.content.length-1;e>=0;e--){let t=this.content[e];if(!t.hidden)return t}return this.content[this.content.length-1]}},so=class e extends Array{constructor(t){super(),this.parent=t,Object.setPrototypeOf(this,e.prototype)}push(...e){return this.addParents(e),super.push(...e)}unshift(...e){return this.addParents(e),super.unshift(...e)}splice(e,t,...n){return this.addParents(n),super.splice(e,t,...n)}addParents(e){for(let t of e)t.container=this.parent}},co=class extends oo{get text(){return this._text.substring(this.offset,this.end)}get fullText(){return this._text}constructor(e){super(),this._text=``,this._text=e??``}};const lo=Symbol(`Datatype`);function uo(e){return e.$type===lo}const fo=e=>e.endsWith(``)?e:e+``;var po=class{constructor(e){this._unorderedGroups=new Map,this.allRules=new Map,this.lexer=e.parser.Lexer;let t=this.lexer.definition,n=e.LanguageMetaData.mode===`production`;this.wrapper=new yo(t,Object.assign(Object.assign({},e.parser.ParserConfig),{skipValidations:n,errorMessageProvider:e.parser.ParserErrorMessageProvider}))}alternatives(e,t){this.wrapper.wrapOr(e,t)}optional(e,t){this.wrapper.wrapOption(e,t)}many(e,t){this.wrapper.wrapMany(e,t)}atLeastOne(e,t){this.wrapper.wrapAtLeastOne(e,t)}getRule(e){return this.allRules.get(e)}isRecording(){return this.wrapper.IS_RECORDING}get unorderedGroups(){return this._unorderedGroups}getRuleStack(){return this.wrapper.RULE_STACK}finalize(){this.wrapper.wrapSelfAnalysis()}},mo=class extends po{get current(){return this.stack[this.stack.length-1]}constructor(e){super(e),this.nodeBuilder=new ro,this.stack=[],this.assignmentMap=new Map,this.linker=e.references.Linker,this.converter=e.parser.ValueConverter,this.astReflection=e.shared.AstReflection}rule(e,t){let n=this.computeRuleType(e),r=this.wrapper.DEFINE_RULE(fo(e.name),this.startImplementation(n,t).bind(this));return this.allRules.set(e.name,r),e.entry&&(this.mainRule=r),r}computeRuleType(e){if(!e.fragment)return ba(e)?lo:wa(e)??e.name}parse(e,t={}){this.nodeBuilder.buildRootNode(e);let n=this.lexerResult=this.lexer.tokenize(e);this.wrapper.input=n.tokens;let r=t.rule?this.allRules.get(t.rule):this.mainRule;if(!r)throw Error(t.rule?`No rule found with name '${t.rule}'`:`No main rule available.`);let i=this.doParse(r);return this.nodeBuilder.addHiddenNodes(n.hidden),this.unorderedGroups.clear(),this.lexerResult=void 0,{value:i,lexerErrors:n.errors,lexerReport:n.report,parserErrors:this.wrapper.errors}}doParse(e){let t=e.call(this.wrapper,{});if(this.stack.length>0&&(t=this.construct()),t===void 0)throw Error(`No result from parser`);if(this.stack.length>0)throw Error(`Parser stack is not empty after parsing`);return t}startImplementation(e,t){return n=>{let r=!this.isRecording()&&e!==void 0;if(r){let t={$type:e};this.stack.push(t),e===lo&&(t.value=``)}return t(n),r?this.construct():void 0}}extractHiddenTokens(e){let t=this.lexerResult.hidden;if(!t.length)return[];let n=e.startOffset;for(let e=0;e<t.length;e++)if(t[e].startOffset>n)return t.splice(0,e);return t.splice(0,t.length)}consume(e,t,n){let r=this.wrapper.wrapConsume(e,t);if(!this.isRecording()&&this.isValidToken(r)){let e=this.extractHiddenTokens(r);this.nodeBuilder.addHiddenNodes(e);let t=this.nodeBuilder.buildLeafNode(r,n),{assignment:i,isCrossRef:a}=this.getAssignment(n),o=this.current;if(i){let e=Ir(n)?r.image:this.converter.convert(r.image,t);this.assign(i.operator,i.feature,e,t,a)}else if(uo(o)){let e=r.image;Ir(n)||(e=this.converter.convert(e,t).toString()),o.value+=e}}}isValidToken(e){return!e.isInsertedInRecovery&&!isNaN(e.startOffset)&&typeof e.endOffset==`number`&&!isNaN(e.endOffset)}subrule(e,t,n,r,i){let a;!this.isRecording()&&!n&&(a=this.nodeBuilder.buildCompositeNode(r));let o;try{o=this.wrapper.wrapSubrule(e,t,i)}finally{this.isRecording()||(o===void 0&&!n&&(o=this.construct()),o!==void 0&&a&&a.length>0&&this.performSubruleAssignment(o,r,a))}}performSubruleAssignment(e,t,n){let{assignment:r,isCrossRef:i}=this.getAssignment(t);if(r)this.assign(r.operator,r.feature,e,n,i);else if(!r){let t=this.current;if(uo(t))t.value+=e.toString();else if(typeof e==`object`&&e){let n=this.assignWithoutOverride(e,t);this.stack.pop(),this.stack.push(n)}}}action(e,t){if(!this.isRecording()){let n=this.current;if(t.feature&&t.operator){n=this.construct(),this.nodeBuilder.removeNode(n.$cstNode),this.nodeBuilder.buildCompositeNode(t).content.push(n.$cstNode);let r={$type:e};this.stack.push(r),this.assign(t.operator,t.feature,n,n.$cstNode,!1)}else n.$type=e}}construct(){if(this.isRecording())return;let e=this.current;return ki(e),this.nodeBuilder.construct(e),this.stack.pop(),uo(e)?this.converter.convert(e.value,e.$cstNode):(zi(this.astReflection,e),e)}getAssignment(e){if(!this.assignmentMap.has(e)){let t=Ai(e,Er);this.assignmentMap.set(e,{assignment:t,isCrossRef:t?Ar(t.terminal):!1})}return this.assignmentMap.get(e)}assign(e,t,n,r,i){let a=this.current,o;switch(o=i&&typeof n==`string`?this.linker.buildReference(a,t,r,n):n,e){case`=`:a[t]=o;break;case`?=`:a[t]=!0;break;case`+=`:Array.isArray(a[t])||(a[t]=[]),a[t].push(o)}}assignWithoutOverride(e,t){for(let[n,r]of Object.entries(t)){let t=e[n];t===void 0?e[n]=r:Array.isArray(t)&&Array.isArray(r)&&(r.push(...t),e[n]=r)}let n=e.$cstNode;return n&&(n.astNode=void 0,e.$cstNode=void 0),e}get definitionErrors(){return this.wrapper.definitionErrors}},ho=class{buildMismatchTokenMessage(e){return l.buildMismatchTokenMessage(e)}buildNotAllInputParsedMessage(e){return l.buildNotAllInputParsedMessage(e)}buildNoViableAltMessage(e){return l.buildNoViableAltMessage(e)}buildEarlyExitMessage(e){return l.buildEarlyExitMessage(e)}},go=class extends ho{buildMismatchTokenMessage({expected:e,actual:t}){return`Expecting ${e.LABEL?"`"+e.LABEL+"`":e.name.endsWith(`:KW`)?`keyword '${e.name.substring(0,e.name.length-3)}'`:`token of type '${e.name}'`} but found \`${t.image}\`.`}buildNotAllInputParsedMessage({firstRedundant:e}){return`Expecting end of file but found \`${e.image}\`.`}},_o=class extends po{constructor(){super(...arguments),this.tokens=[],this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}action(){}construct(){}parse(e){return this.resetState(),this.tokens=this.lexer.tokenize(e,{mode:`partial`}).tokens,this.wrapper.input=[...this.tokens],this.mainRule.call(this.wrapper,{}),this.unorderedGroups.clear(),{tokens:this.tokens,elementStack:[...this.lastElementStack],tokenIndex:this.nextTokenIndex}}rule(e,t){let n=this.wrapper.DEFINE_RULE(fo(e.name),this.startImplementation(t).bind(this));return this.allRules.set(e.name,n),e.entry&&(this.mainRule=n),n}resetState(){this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}startImplementation(e){return t=>{let n=this.keepStackSize();try{e(t)}finally{this.resetStackSize(n)}}}removeUnexpectedElements(){this.elementStack.splice(this.stackSize)}keepStackSize(){let e=this.elementStack.length;return this.stackSize=e,e}resetStackSize(e){this.removeUnexpectedElements(),this.stackSize=e}consume(e,t,n){this.wrapper.wrapConsume(e,t),this.isRecording()||(this.lastElementStack=[...this.elementStack,n],this.nextTokenIndex=this.currIdx+1)}subrule(e,t,n,r,i){this.before(r),this.wrapper.wrapSubrule(e,t,i),this.after(r)}before(e){this.isRecording()||this.elementStack.push(e)}after(e){if(!this.isRecording()){let t=this.elementStack.lastIndexOf(e);t>=0&&this.elementStack.splice(t)}}get currIdx(){return this.wrapper.currIdx}};const vo={recoveryEnabled:!0,nodeLocationTracking:`full`,skipValidations:!0,errorMessageProvider:new go};var yo=class extends d{constructor(e,t){let n=t&&`maxLookahead`in t;super(e,Object.assign(Object.assign(Object.assign({},vo),{lookaheadStrategy:n?new p({maxLookahead:t.maxLookahead}):new g({logging:t.skipValidations?()=>{}:void 0})}),t))}get IS_RECORDING(){return this.RECORDING_PHASE}DEFINE_RULE(e,t,n){return this.RULE(e,t,n)}wrapSelfAnalysis(){this.performSelfAnalysis()}wrapConsume(e,t){return this.consume(e,t,void 0)}wrapSubrule(e,t,n){return this.subrule(e,t,{ARGS:[n]})}wrapOr(e,t){this.or(e,t)}wrapOption(e,t){this.option(e,t)}wrapMany(e,t){this.many(e,t)}wrapAtLeastOne(e,t){this.atLeastOne(e,t)}};function bo(e,t,n){return xo({parser:t,tokens:n,ruleNames:new Map},e),t}function xo(e,t){let n=na(t,!1),r=K(t.rules).filter(U).filter(e=>n.has(e));for(let t of r){let n=Object.assign(Object.assign({},e),{consume:1,optional:1,subrule:1,many:1,or:1});e.parser.rule(t,So(n,t.definition))}}function So(e,t,n=!1){let r;if(Ir(t))r=Mo(e,t);else if(Sr(t))r=Co(e,t);else if(Er(t))r=So(e,t.terminal);else if(Ar(t))r=jo(e,t);else if(Hr(t))r=wo(e,t);else if(wr(t))r=Do(e,t);else if(Xr(t))r=Oo(e,t);else if(Pr(t))r=ko(e,t);else if(Mr(t)){let n=e.consume++;r=()=>e.parser.consume(n,f,t)}else throw new Hi(t.$cstNode,`Unexpected element type: ${t.$type}`);return No(e,n?void 0:Ao(t),r,t.cardinality)}function Co(e,t){let n=Ta(t);return()=>e.parser.action(n,t)}function wo(e,t){let n=t.rule.ref;if(U(n)){let r=e.subrule++,i=n.fragment,a=t.arguments.length>0?To(n,t.arguments):()=>({});return o=>e.parser.subrule(r,Po(e,n),i,t,a(o))}else if(hr(n)){let r=e.consume++,i=Io(e,n.name);return()=>e.parser.consume(r,i,t)}else if(n)Ui(n);else throw new Hi(t.$cstNode,`Undefined rule: ${t.rule.$refText}`)}function To(e,t){let n=t.map(e=>Eo(e.value));return t=>{let r={};for(let i=0;i<n.length;i++){let a=e.parameters[i],o=n[i];r[a.name]=o(t)}return r}}function Eo(e){if(Kn(e)){let t=Eo(e.left),n=Eo(e.right);return e=>t(e)||n(e)}else if(Wn(e)){let t=Eo(e.left),n=Eo(e.right);return e=>t(e)&&n(e)}else if(tr(e)){let t=Eo(e.value);return e=>!t(e)}else if(ar(e)){let t=e.parameter.ref.name;return e=>e!==void 0&&e[t]===!0}else if(Hn(e)){let t=!!e.true;return()=>t}Ui(e)}function Do(e,t){if(t.elements.length===1)return So(e,t.elements[0]);{let n=[];for(let r of t.elements){let t={ALT:So(e,r,!0)},i=Ao(r);i&&(t.GATE=Eo(i)),n.push(t)}let r=e.or++;return t=>e.parser.alternatives(r,n.map(e=>{let n={ALT:()=>e.ALT(t)},r=e.GATE;return r&&(n.GATE=()=>r(t)),n}))}}function Oo(e,t){if(t.elements.length===1)return So(e,t.elements[0]);let n=[];for(let r of t.elements){let t={ALT:So(e,r,!0)},i=Ao(r);i&&(t.GATE=Eo(i)),n.push(t)}let r=e.or++,i=(e,t)=>`uGroup_${e}_${t.getRuleStack().join(`-`)}`,a=No(e,Ao(t),t=>e.parser.alternatives(r,n.map((n,a)=>{let o={ALT:()=>!0},s=e.parser;o.ALT=()=>{if(n.ALT(t),!s.isRecording()){let e=i(r,s);s.unorderedGroups.get(e)||s.unorderedGroups.set(e,[]);let t=s.unorderedGroups.get(e);t?.[a]===void 0&&(t[a]=!0)}};let c=n.GATE;return c?o.GATE=()=>c(t):o.GATE=()=>!s.unorderedGroups.get(i(r,s))?.[a],o})),`*`);return t=>{a(t),e.parser.isRecording()||e.parser.unorderedGroups.delete(i(r,e.parser))}}function ko(e,t){let n=t.elements.map(t=>So(e,t));return e=>n.forEach(t=>t(e))}function Ao(e){if(Pr(e))return e.guardCondition}function jo(e,t,n=t.terminal){if(!n){if(!t.type.ref)throw Error(`Could not resolve reference to type: `+t.type.$refText);let n=ma(t.type.ref)?.terminal;if(!n)throw Error(`Could not find name assignment for type: `+Ta(t.type.ref));return jo(e,t,n)}else if(Hr(n)&&U(n.rule.ref)){let r=n.rule.ref,i=e.subrule++;return n=>e.parser.subrule(i,Po(e,r),!1,t,n)}else if(Hr(n)&&hr(n.rule.ref)){let r=e.consume++,i=Io(e,n.rule.ref.name);return()=>e.parser.consume(r,i,t)}else if(Ir(n)){let r=e.consume++,i=Io(e,n.value);return()=>e.parser.consume(r,i,t)}else throw Error(`Could not build cross reference parser`)}function Mo(e,t){let n=e.consume++,r=e.tokens[t.value];if(!r)throw Error(`Could not find token for keyword: `+t.value);return()=>e.parser.consume(n,r,t)}function No(e,t,n,r){let i=t&&Eo(t);if(!r)if(i){let t=e.or++;return r=>e.parser.alternatives(t,[{ALT:()=>n(r),GATE:()=>i(r)},{ALT:m(),GATE:()=>!i(r)}])}else return n;if(r===`*`){let t=e.many++;return r=>e.parser.many(t,{DEF:()=>n(r),GATE:i?()=>i(r):void 0})}else if(r===`+`){let t=e.many++;if(i){let r=e.or++;return a=>e.parser.alternatives(r,[{ALT:()=>e.parser.atLeastOne(t,{DEF:()=>n(a)}),GATE:()=>i(a)},{ALT:m(),GATE:()=>!i(a)}])}else return r=>e.parser.atLeastOne(t,{DEF:()=>n(r)})}else if(r===`?`){let t=e.optional++;return r=>e.parser.optional(t,{DEF:()=>n(r),GATE:i?()=>i(r):void 0})}else Ui(r)}function Po(e,t){let n=Fo(e,t),r=e.parser.getRule(n);if(!r)throw Error(`Rule "${n}" not found."`);return r}function Fo(e,t){if(U(t))return t.name;if(e.ruleNames.has(t))return e.ruleNames.get(t);{let n=t,r=n.$container,i=t.$type;for(;!U(r);)(Pr(r)||wr(r)||Xr(r))&&(i=r.elements.indexOf(n).toString()+`:`+i),n=r,r=r.$container;return i=r.name+`:`+i,e.ruleNames.set(t,i),i}}function Io(e,t){let n=e.tokens[t];if(!n)throw Error(`Token "${t}" not found."`);return n}function Lo(e){let t=e.Grammar,n=e.parser.Lexer,r=new _o(e);return bo(t,r,n.definition),r.finalize(),r}function Ro(e){let t=zo(e);return t.finalize(),t}function zo(e){let t=e.Grammar,n=e.parser.Lexer;return bo(t,new mo(e),n.definition)}var Bo=class{constructor(){this.diagnostics=[]}buildTokens(e,t){let n=K(na(e,!1)),r=this.buildTerminalTokens(n),i=this.buildKeywordTokens(n,r,t);return i.push(...r),i}flushLexingReport(e){return{diagnostics:this.popDiagnostics()}}popDiagnostics(){let e=[...this.diagnostics];return this.diagnostics=[],e}buildTerminalTokens(e){return e.filter(hr).filter(e=>!e.fragment).map(e=>this.buildTerminalToken(e)).toArray()}buildTerminalToken(e){let t=ka(e),n=this.requiresCustomPattern(t)?this.regexPatternFunction(t):t,r={name:e.name,PATTERN:n};return typeof n==`function`&&(r.LINE_BREAKS=!0),e.hidden&&(r.GROUP=Yi(t)?u.SKIPPED:`hidden`),r}requiresCustomPattern(e){return e.flags.includes(`u`)||e.flags.includes(`s`)?!0:!!(e.source.includes(`?<=`)||e.source.includes(`?<!`))}regexPatternFunction(e){let t=new RegExp(e,e.flags+`y`);return(e,n)=>(t.lastIndex=n,t.exec(e))}buildKeywordTokens(e,t,n){return e.filter(U).flatMap(e=>Pi(e).filter(Ir)).distinct(e=>e.value).toArray().sort((e,t)=>t.value.length-e.value.length).map(e=>this.buildKeywordToken(e,t,!!n?.caseInsensitive))}buildKeywordToken(e,t,n){let r=this.buildKeywordPattern(e,n),i={name:e.value,PATTERN:r,LONGER_ALT:this.findLongerAlt(e,t)};return typeof r==`function`&&(i.LINE_BREAKS=!0),i}buildKeywordPattern(e,t){return t?new RegExp(Xi(e.value),`i`):e.value}findLongerAlt(e,t){return t.reduce((t,n)=>{let r=n?.PATTERN;return r?.source&&Zi(`^`+r.source+`$`,e.value)&&t.push(n),t},[])}},Vo=class{convert(e,t){let n=t.grammarSource;if(Ar(n)&&(n=aa(n)),Hr(n)){let r=n.rule.ref;if(!r)throw Error(`This cst node was not parsed by a rule.`);return this.runConverter(r,e,t)}return e}runConverter(e,t,n){switch(e.name.toUpperCase()){case`INT`:return Ho.convertInt(t);case`STRING`:return Ho.convertString(t);case`ID`:return Ho.convertID(t)}switch(Oa(e)?.toLowerCase()){case`number`:return Ho.convertNumber(t);case`boolean`:return Ho.convertBoolean(t);case`bigint`:return Ho.convertBigint(t);case`date`:return Ho.convertDate(t);default:return t}}},Ho;(function(e){function t(e){let t=``;for(let r=1;r<e.length-1;r++){let i=e.charAt(r);if(i===`\\`){let i=e.charAt(++r);t+=n(i)}else t+=i}return t}e.convertString=t;function n(e){switch(e){case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
|
|
20
|
-
`;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`0`:return`\0`;default:return e}}function r(e){return e.charAt(0)===`^`?e.substring(1):e}e.convertID=r;function i(e){return parseInt(e)}e.convertInt=i;function a(e){return BigInt(e)}e.convertBigint=a;function o(e){return new Date(e)}e.convertDate=o;function s(e){return Number(e)}e.convertNumber=s;function c(e){return e.toLowerCase()===`true`}e.convertBoolean=c})(Ho||={});var Z={};t(Z,a(ee(),1));function Uo(){return new Promise(e=>{typeof setImmediate>`u`?setTimeout(e,0):setImmediate(e)})}let Wo=0;function Go(){return Wo=performance.now(),new Z.CancellationTokenSource}const Ko=Symbol(`OperationCancelled`);function qo(e){return e===Ko}async function Q(e){if(e===Z.CancellationToken.None)return;let t=performance.now();if(t-Wo>=10&&(Wo=t,await Uo(),Wo=performance.now()),e.isCancellationRequested)throw Ko}var Jo=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=t=>(e(t),this),this.reject=e=>(t(e),this)})}},Yo=class e{constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(t,n){for(let n of t)if(e.isIncremental(n)){let e=$o(n.range),t=this.offsetAt(e.start),r=this.offsetAt(e.end);this._content=this._content.substring(0,t)+n.text+this._content.substring(r,this._content.length);let i=Math.max(e.start.line,0),a=Math.max(e.end.line,0),o=this._lineOffsets,s=Qo(n.text,!1,t);if(a-i===s.length)for(let e=0,t=s.length;e<t;e++)o[e+i+1]=s[e];else s.length<1e4?o.splice(i+1,a-i,...s):this._lineOffsets=o=o.slice(0,i+1).concat(s,o.slice(a+1));let c=n.text.length-(r-t);if(c!==0)for(let e=i+1+s.length,t=o.length;e<t;e++)o[e]=o[e]+c}else if(e.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=Qo(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,r=t.length;if(r===0)return{line:0,character:e};for(;n<r;){let i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}let i=n-1;return{line:i,character:e-t[i]}}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line],r=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,r),n)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range!==void 0&&(t.rangeLength===void 0||typeof t.rangeLength==`number`)}static isFull(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range===void 0&&t.rangeLength===void 0}},Xo;(function(e){function t(e,t,n,r){return new Yo(e,t,n,r)}e.create=t;function n(e,t,n){if(e instanceof Yo)return e.update(t,n),e;throw Error(`TextDocument.update: document must be created by TextDocument.create`)}e.update=n;function r(e,t){let n=e.getText(),r=Zo(t.map(es),(e,t)=>{let n=e.range.start.line-t.range.start.line;return n===0?e.range.start.character-t.range.start.character:n}),i=0,a=[];for(let t of r){let r=e.offsetAt(t.range.start);if(r<i)throw Error(`Overlapping edit`);r>i&&a.push(n.substring(i,r)),t.newText.length&&a.push(t.newText),i=e.offsetAt(t.range.end)}return a.push(n.substr(i)),a.join(``)}e.applyEdits=r})(Xo||={});function Zo(e,t){if(e.length<=1)return e;let n=e.length/2|0,r=e.slice(0,n),i=e.slice(n);Zo(r,t),Zo(i,t);let a=0,o=0,s=0;for(;a<r.length&&o<i.length;)t(r[a],i[o])<=0?e[s++]=r[a++]:e[s++]=i[o++];for(;a<r.length;)e[s++]=r[a++];for(;o<i.length;)e[s++]=i[o++];return e}function Qo(e,t,n=0){let r=t?[n]:[];for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);(i===13||i===10)&&(i===13&&t+1<e.length&&e.charCodeAt(t+1)===10&&t++,r.push(n+t+1))}return r}function $o(e){let t=e.start,n=e.end;return t.line>n.line||t.line===n.line&&t.character>n.character?{start:n,end:t}:e}function es(e){let t=$o(e.range);return t===e.range?e:{newText:e.newText,range:t}}var $;(function(e){e[e.Changed=0]=`Changed`,e[e.Parsed=1]=`Parsed`,e[e.IndexedContent=2]=`IndexedContent`,e[e.ComputedScopes=3]=`ComputedScopes`,e[e.Linked=4]=`Linked`,e[e.IndexedReferences=5]=`IndexedReferences`,e[e.Validated=6]=`Validated`})($||={});var ts=class{constructor(e){this.serviceRegistry=e.ServiceRegistry,this.textDocuments=e.workspace.TextDocuments,this.fileSystemProvider=e.workspace.FileSystemProvider}async fromUri(e,t=Z.CancellationToken.None){let n=await this.fileSystemProvider.readFile(e);return this.createAsync(e,n,t)}fromTextDocument(e,t,n){return t??=Y.parse(e.uri),Z.CancellationToken.is(n)?this.createAsync(t,e,n):this.create(t,e,n)}fromString(e,t,n){return Z.CancellationToken.is(n)?this.createAsync(t,e,n):this.create(t,e,n)}fromModel(e,t){return this.create(t,{$model:e})}create(e,t,n){if(typeof t==`string`){let r=this.parse(e,t,n);return this.createLangiumDocument(r,e,void 0,t)}else if(`$model`in t){let n={value:t.$model,parserErrors:[],lexerErrors:[]};return this.createLangiumDocument(n,e)}else{let r=this.parse(e,t.getText(),n);return this.createLangiumDocument(r,e,t)}}async createAsync(e,t,n){if(typeof t==`string`){let r=await this.parseAsync(e,t,n);return this.createLangiumDocument(r,e,void 0,t)}else{let r=await this.parseAsync(e,t.getText(),n);return this.createLangiumDocument(r,e,t)}}createLangiumDocument(e,t,n,r){let i;if(n)i={parseResult:e,uri:t,state:$.Parsed,references:[],textDocument:n};else{let n=this.createTextDocumentGetter(t,r);i={parseResult:e,uri:t,state:$.Parsed,references:[],get textDocument(){return n()}}}return e.value.$document=i,i}async update(e,t){let n=e.parseResult.value.$cstNode?.root.fullText,r=this.textDocuments?.get(e.uri.toString()),i=r?r.getText():await this.fileSystemProvider.readFile(e.uri);if(r)Object.defineProperty(e,`textDocument`,{value:r});else{let t=this.createTextDocumentGetter(e.uri,i);Object.defineProperty(e,`textDocument`,{get:t})}return n!==i&&(e.parseResult=await this.parseAsync(e.uri,i,t),e.parseResult.value.$document=e),e.state=$.Parsed,e}parse(e,t,n){return this.serviceRegistry.getServices(e).parser.LangiumParser.parse(t,n)}parseAsync(e,t,n){return this.serviceRegistry.getServices(e).parser.AsyncParser.parse(t,n)}createTextDocumentGetter(e,t){let n=this.serviceRegistry,r;return()=>r??=Xo.create(e.toString(),n.getServices(e).LanguageMetaData.languageId,0,t??``)}},ns=class{constructor(e){this.documentMap=new Map,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.serviceRegistry=e.ServiceRegistry}get all(){return K(this.documentMap.values())}addDocument(e){let t=e.uri.toString();if(this.documentMap.has(t))throw Error(`A document with the URI '${t}' is already present.`);this.documentMap.set(t,e)}getDocument(e){let t=e.toString();return this.documentMap.get(t)}async getOrCreateDocument(e,t){let n=this.getDocument(e);return n||(n=await this.langiumDocumentFactory.fromUri(e,t),this.addDocument(n),n)}createDocument(e,t,n){if(n)return this.langiumDocumentFactory.fromString(t,e,n).then(e=>(this.addDocument(e),e));{let n=this.langiumDocumentFactory.fromString(t,e);return this.addDocument(n),n}}hasDocument(e){return this.documentMap.has(e.toString())}invalidateDocument(e){let t=e.toString(),n=this.documentMap.get(t);return n&&(this.serviceRegistry.getServices(e).references.Linker.unlink(n),n.state=$.Changed,n.precomputedScopes=void 0,n.diagnostics=void 0),n}deleteDocument(e){let t=e.toString(),n=this.documentMap.get(t);return n&&(n.state=$.Changed,this.documentMap.delete(t)),n}};const rs=Symbol(`ref_resolving`);var is=class{constructor(e){this.reflection=e.shared.AstReflection,this.langiumDocuments=()=>e.shared.workspace.LangiumDocuments,this.scopeProvider=e.references.ScopeProvider,this.astNodeLocator=e.workspace.AstNodeLocator}async link(e,t=Z.CancellationToken.None){for(let n of Fi(e.parseResult.value))await Q(t),Li(n).forEach(t=>this.doLink(t,e))}doLink(e,t){let n=e.reference;if(n._ref===void 0){n._ref=rs;try{let t=this.getCandidate(e);En(t)?n._ref=t:(n._nodeDescription=t,this.langiumDocuments().hasDocument(t.documentUri)?n._ref=this.loadAstNode(t)??this.createLinkingError(e,t):n._ref=void 0)}catch(t){console.error(`An error occurred while resolving reference to '${n.$refText}':`,t);let r=t.message??String(t);n._ref=Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${n.$refText}': ${r}`})}t.references.push(n)}}unlink(e){for(let t of e.references)delete t._ref,delete t._nodeDescription;e.references=[]}getCandidate(e){return this.scopeProvider.getScope(e).getElement(e.reference.$refText)??this.createLinkingError(e)}buildReference(e,t,n,r){let i=this,a={$refNode:n,$refText:r,get ref(){if(H(this._ref))return this._ref;if(Tn(this._nodeDescription))this._ref=i.loadAstNode(this._nodeDescription)??i.createLinkingError({reference:a,container:e,property:t},this._nodeDescription);else if(this._ref===void 0){this._ref=rs;let n=Mi(e).$document,r=i.getLinkedNode({reference:a,container:e,property:t});if(r.error&&n&&n.state<$.ComputedScopes){this._ref=void 0;return}this._ref=r.node??r.error,this._nodeDescription=r.descr,n?.references.push(this)}else if(this._ref===rs)throw Error(`Cyclic reference resolution detected: ${i.astNodeLocator.getAstNodePath(e)}/${t} (symbol '${r}')`);return H(this._ref)?this._ref:void 0},get $nodeDescription(){return this._nodeDescription},get error(){return En(this._ref)?this._ref:void 0}};return a}getLinkedNode(e){try{let t=this.getCandidate(e);if(En(t))return{error:t};let n=this.loadAstNode(t);return n?{node:n,descr:t}:{descr:t,error:this.createLinkingError(e,t)}}catch(t){console.error(`An error occurred while resolving reference to '${e.reference.$refText}':`,t);let n=t.message??String(t);return{error:Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${e.reference.$refText}': ${n}`})}}}loadAstNode(e){if(e.node)return e.node;let t=this.langiumDocuments().getDocument(e.documentUri);if(t)return this.astNodeLocator.getAstNode(t.parseResult.value,e.path)}createLinkingError(e,t){let n=Mi(e.container).$document;n&&n.state<$.ComputedScopes&&console.warn(`Attempted reference resolution before document reached ComputedScopes state (${n.uri}).`);let r=this.reflection.getReferenceType(e);return Object.assign(Object.assign({},e),{message:`Could not resolve reference to ${r} named '${e.reference.$refText}'.`,targetDescription:t})}};function as(e){return typeof e.name==`string`}var os=class{getName(e){if(as(e))return e.name}getNameNode(e){return ca(e.$cstNode,`name`)}},ss=class{constructor(e){this.nameProvider=e.references.NameProvider,this.index=e.shared.workspace.IndexManager,this.nodeLocator=e.workspace.AstNodeLocator}findDeclaration(e){if(e){let t=pa(e),n=e.astNode;if(t&&n){let r=n[t.feature];if(wn(r))return r.ref;if(Array.isArray(r)){for(let t of r)if(wn(t)&&t.$refNode&&t.$refNode.offset<=e.offset&&t.$refNode.end>=e.end)return t.ref}}if(n){let t=this.nameProvider.getNameNode(n);if(t&&(t===e||ui(e,t)))return n}}}findDeclarationNode(e){let t=this.findDeclaration(e);if(t?.$cstNode)return this.nameProvider.getNameNode(t)??t.$cstNode}findReferences(e,t){let n=[];if(t.includeDeclaration){let t=this.getReferenceToSelf(e);t&&n.push(t)}let r=this.index.findAllReferences(e,this.nodeLocator.getAstNodePath(e));return t.documentUri&&(r=r.filter(e=>X.equals(e.sourceUri,t.documentUri))),n.push(...r),K(n)}getReferenceToSelf(e){let t=this.nameProvider.getNameNode(e);if(t){let n=q(e),r=this.nodeLocator.getAstNodePath(e);return{sourceUri:n.uri,sourcePath:r,targetUri:n.uri,targetPath:r,segment:fi(t),local:!0}}}},cs=class{constructor(e){if(this.map=new Map,e)for(let[t,n]of e)this.add(t,n)}get size(){return si.sum(K(this.map.values()).map(e=>e.length))}clear(){this.map.clear()}delete(e,t){if(t===void 0)return this.map.delete(e);{let n=this.map.get(e);if(n){let r=n.indexOf(t);if(r>=0)return n.length===1?this.map.delete(e):n.splice(r,1),!0}return!1}}get(e){return this.map.get(e)??[]}has(e,t){if(t===void 0)return this.map.has(e);{let n=this.map.get(e);return n?n.indexOf(t)>=0:!1}}add(e,t){return this.map.has(e)?this.map.get(e).push(t):this.map.set(e,[t]),this}addAll(e,t){return this.map.has(e)?this.map.get(e).push(...t):this.map.set(e,Array.from(t)),this}forEach(e){this.map.forEach((t,n)=>t.forEach(t=>e(t,n,this)))}[Symbol.iterator](){return this.entries().iterator()}entries(){return K(this.map.entries()).flatMap(([e,t])=>t.map(t=>[e,t]))}keys(){return K(this.map.keys())}values(){return K(this.map.values()).flat()}entriesGroupedByKey(){return K(this.map.entries())}},ls=class{get size(){return this.map.size}constructor(e){if(this.map=new Map,this.inverse=new Map,e)for(let[t,n]of e)this.set(t,n)}clear(){this.map.clear(),this.inverse.clear()}set(e,t){return this.map.set(e,t),this.inverse.set(t,e),this}get(e){return this.map.get(e)}getKey(e){return this.inverse.get(e)}delete(e){let t=this.map.get(e);return t===void 0?!1:(this.map.delete(e),this.inverse.delete(t),!0)}},us=class{constructor(e){this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider}async computeExports(e,t=Z.CancellationToken.None){return this.computeExportsForNode(e.parseResult.value,e,void 0,t)}async computeExportsForNode(e,t,n=Ni,r=Z.CancellationToken.None){let i=[];this.exportNode(e,i,t);for(let a of n(e))await Q(r),this.exportNode(a,i,t);return i}exportNode(e,t,n){let r=this.nameProvider.getName(e);r&&t.push(this.descriptions.createDescription(e,r,n))}async computeLocalScopes(e,t=Z.CancellationToken.None){let n=e.parseResult.value,r=new cs;for(let i of Pi(n))await Q(t),this.processNode(i,e,r);return r}processNode(e,t,n){let r=e.$container;if(r){let i=this.nameProvider.getName(e);i&&n.add(r,this.descriptions.createDescription(e,i,t))}}},ds=class{constructor(e,t,n){this.elements=e,this.outerScope=t,this.caseInsensitive=n?.caseInsensitive??!1}getAllElements(){return this.outerScope?this.elements.concat(this.outerScope.getAllElements()):this.elements}getElement(e){let t=this.caseInsensitive?this.elements.find(t=>t.name.toLowerCase()===e.toLowerCase()):this.elements.find(t=>t.name===e);if(t)return t;if(this.outerScope)return this.outerScope.getElement(e)}},fs=class{constructor(e,t,n){this.elements=new Map,this.caseInsensitive=n?.caseInsensitive??!1;for(let t of e){let e=this.caseInsensitive?t.name.toLowerCase():t.name;this.elements.set(e,t)}this.outerScope=t}getElement(e){let t=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(t);if(n)return n;if(this.outerScope)return this.outerScope.getElement(e)}getAllElements(){let e=K(this.elements.values());return this.outerScope&&(e=e.concat(this.outerScope.getAllElements())),e}};const ps={getElement(){},getAllElements(){return ai}};var ms=class{constructor(){this.toDispose=[],this.isDisposed=!1}onDispose(e){this.toDispose.push(e)}dispose(){this.throwIfDisposed(),this.clear(),this.isDisposed=!0,this.toDispose.forEach(e=>e.dispose())}throwIfDisposed(){if(this.isDisposed)throw Error(`This cache has already been disposed`)}},hs=class extends ms{constructor(){super(...arguments),this.cache=new Map}has(e){return this.throwIfDisposed(),this.cache.has(e)}set(e,t){this.throwIfDisposed(),this.cache.set(e,t)}get(e,t){if(this.throwIfDisposed(),this.cache.has(e))return this.cache.get(e);if(t){let n=t();return this.cache.set(e,n),n}else return}delete(e){return this.throwIfDisposed(),this.cache.delete(e)}clear(){this.throwIfDisposed(),this.cache.clear()}},gs=class extends ms{constructor(e){super(),this.cache=new Map,this.converter=e??(e=>e)}has(e,t){return this.throwIfDisposed(),this.cacheForContext(e).has(t)}set(e,t,n){this.throwIfDisposed(),this.cacheForContext(e).set(t,n)}get(e,t,n){this.throwIfDisposed();let r=this.cacheForContext(e);if(r.has(t))return r.get(t);if(n){let e=n();return r.set(t,e),e}else return}delete(e,t){return this.throwIfDisposed(),this.cacheForContext(e).delete(t)}clear(e){if(this.throwIfDisposed(),e){let t=this.converter(e);this.cache.delete(t)}else this.cache.clear()}cacheForContext(e){let t=this.converter(e),n=this.cache.get(t);return n||(n=new Map,this.cache.set(t,n)),n}},_s=class extends hs{constructor(e,t){super(),t?(this.toDispose.push(e.workspace.DocumentBuilder.onBuildPhase(t,()=>{this.clear()})),this.toDispose.push(e.workspace.DocumentBuilder.onUpdate((e,t)=>{t.length>0&&this.clear()}))):this.toDispose.push(e.workspace.DocumentBuilder.onUpdate(()=>{this.clear()}))}},vs=class{constructor(e){this.reflection=e.shared.AstReflection,this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider,this.indexManager=e.shared.workspace.IndexManager,this.globalScopeCache=new _s(e.shared)}getScope(e){let t=[],n=this.reflection.getReferenceType(e),r=q(e.container).precomputedScopes;if(r){let i=e.container;do{let e=r.get(i);e.length>0&&t.push(K(e).filter(e=>this.reflection.isSubtype(e.type,n))),i=i.$container}while(i)}let i=this.getGlobalScope(n,e);for(let e=t.length-1;e>=0;e--)i=this.createScope(t[e],i);return i}createScope(e,t,n){return new ds(K(e),t,n)}createScopeForNodes(e,t,n){return new ds(K(e).map(e=>{let t=this.nameProvider.getName(e);if(t)return this.descriptions.createDescription(e,t)}).nonNullable(),t,n)}getGlobalScope(e,t){return this.globalScopeCache.get(e,()=>new fs(this.indexManager.allElements(e)))}};function ys(e){return typeof e.$comment==`string`}function bs(e){return typeof e==`object`&&!!e&&(`$ref`in e||`$error`in e)}var xs=class{constructor(e){this.ignoreProperties=new Set([`$container`,`$containerProperty`,`$containerIndex`,`$document`,`$cstNode`]),this.langiumDocuments=e.shared.workspace.LangiumDocuments,this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider,this.commentProvider=e.documentation.CommentProvider}serialize(e,t){let n=t??{},r=t?.replacer,i=(e,t)=>this.replacer(e,t,n),a=r?(e,t)=>r(e,t,i):i;try{return this.currentDocument=q(e),JSON.stringify(e,a,t?.space)}finally{this.currentDocument=void 0}}deserialize(e,t){let n=t??{},r=JSON.parse(e);return this.linkNode(r,r,n),r}replacer(e,t,{refText:n,sourceText:r,textRegions:i,comments:a,uriConverter:o}){if(!this.ignoreProperties.has(e))if(wn(t)){let e=t.ref,r=n?t.$refText:void 0;if(e){let n=q(e),i=``;this.currentDocument&&this.currentDocument!==n&&(i=o?o(n.uri,t):n.uri.toString());let a=this.astNodeLocator.getAstNodePath(e);return{$ref:`${i}#${a}`,$refText:r}}else return{$error:t.error?.message??`Could not resolve reference`,$refText:r}}else if(H(t)){let n;if(i&&(n=this.addAstNodeRegionWithAssignmentsTo(Object.assign({},t)),(!e||t.$document)&&n?.$textRegion&&(n.$textRegion.documentURI=this.currentDocument?.uri.toString())),r&&!e&&(n??=Object.assign({},t),n.$sourceText=t.$cstNode?.text),a){n??=Object.assign({},t);let e=this.commentProvider.getComment(t);e&&(n.$comment=e.replace(/\r/g,``))}return n??t}else return t}addAstNodeRegionWithAssignmentsTo(e){let t=e=>({offset:e.offset,end:e.end,length:e.length,range:e.range});if(e.$cstNode){let n=e.$textRegion=t(e.$cstNode),r=n.assignments={};return Object.keys(e).filter(e=>!e.startsWith(`$`)).forEach(n=>{let i=sa(e.$cstNode,n).map(t);i.length!==0&&(r[n]=i)}),e}}linkNode(e,t,n,r,i,a){for(let[r,i]of Object.entries(e))if(Array.isArray(i))for(let a=0;a<i.length;a++){let o=i[a];bs(o)?i[a]=this.reviveReference(e,r,t,o,n):H(o)&&this.linkNode(o,t,n,e,r,a)}else bs(i)?e[r]=this.reviveReference(e,r,t,i,n):H(i)&&this.linkNode(i,t,n,e,r);let o=e;o.$container=r,o.$containerProperty=i,o.$containerIndex=a}reviveReference(e,t,n,r,i){let a=r.$refText,o=r.$error;if(r.$ref){let e=this.getRefNode(n,r.$ref,i.uriConverter);if(H(e))return a||=this.nameProvider.getName(e),{$refText:a??``,ref:e};o=e}if(o){let n={$refText:a??``};return n.error={container:e,property:t,message:o,reference:n},n}else return}getRefNode(e,t,n){try{let r=t.indexOf(`#`);if(r===0)return this.astNodeLocator.getAstNode(e,t.substring(1))||`Could not resolve path: `+t;if(r<0){let e=n?n(t):Y.parse(t),r=this.langiumDocuments.getDocument(e);return r?r.parseResult.value:`Could not find document for URI: `+t}let i=n?n(t.substring(0,r)):Y.parse(t.substring(0,r)),a=this.langiumDocuments.getDocument(i);return a?r===t.length-1?a.parseResult.value:this.astNodeLocator.getAstNode(a.parseResult.value,t.substring(r+1))||`Could not resolve URI: `+t:`Could not find document for URI: `+t}catch(e){return String(e)}}},Ss=class{get map(){return this.fileExtensionMap}constructor(e){this.languageIdMap=new Map,this.fileExtensionMap=new Map,this.fileNameMap=new Map,this.textDocuments=e?.workspace.TextDocuments}register(e){let t=e.LanguageMetaData;for(let n of t.fileExtensions)this.fileExtensionMap.has(n)&&console.warn(`The file extension ${n} is used by multiple languages. It is now assigned to '${t.languageId}'.`),this.fileExtensionMap.set(n,e);if(t.fileNames)for(let n of t.fileNames)this.fileNameMap.has(n)&&console.warn(`The file name ${n} is used by multiple languages. It is now assigned to '${t.languageId}'.`),this.fileNameMap.set(n,e);this.languageIdMap.set(t.languageId,e),this.languageIdMap.size===1?this.singleton=e:this.singleton=void 0}getServices(e){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 t=this.textDocuments?.get(e)?.languageId;if(t!==void 0){let e=this.languageIdMap.get(t);if(e)return e}let n=X.extname(e),r=X.basename(e),i=this.fileNameMap.get(r)??this.fileExtensionMap.get(n);if(!i)throw t?Error(`The service registry contains no services for the extension '${n}' for language '${t}'.`):Error(`The service registry contains no services for the extension '${n}'.`);return i}hasServices(e){try{return this.getServices(e),!0}catch{return!1}}get all(){return Array.from(this.languageIdMap.values())}},Cs;(function(e){e.merge=(e,t)=>As(As({},e),t)})(Cs||={});function ws(e,t,n,r,i,a,o,s,c){return Ds([e,t,n,r,i,a,o,s,c].reduce(As,{}))}const Ts=Symbol(`isProxy`);function Es(e){if(e&&e[Ts])for(let t of Object.values(e))Es(t);return e}function Ds(e,t){let n=new Proxy({},{deleteProperty:()=>!1,set:()=>{throw Error(`Cannot set property on injected service container`)},get:(r,i)=>i===Ts?!0:ks(r,i,e,t||n),getOwnPropertyDescriptor:(r,i)=>(ks(r,i,e,t||n),Object.getOwnPropertyDescriptor(r,i)),has:(t,n)=>n in e,ownKeys:()=>[...Object.getOwnPropertyNames(e)]});return n}const Os=Symbol();function ks(e,t,n,r){if(t in e){if(e[t]instanceof Error)throw Error(`Construction failure. Please make sure that your dependencies are constructable.`,{cause:e[t]});if(e[t]===Os)throw Error(`Cycle detected. Please make "`+String(t)+`" lazy. Visit https://langium.org/docs/reference/configuration-services/#resolving-cyclic-dependencies`);return e[t]}else if(t in n){let i=n[t];e[t]=Os;try{e[t]=typeof i==`function`?i(r):Ds(i,r)}catch(n){throw e[t]=n instanceof Error?n:void 0,n}return e[t]}else return}function As(e,t){if(t){for(let[n,r]of Object.entries(t))if(r!==void 0){let t=e[n];t!==null&&r!==null&&typeof t==`object`&&typeof r==`object`?e[n]=As(t,r):e[n]=r}}return e}var js=class{constructor(e){this.grammarConfig=()=>e.parser.GrammarConfig}getComment(e){return ys(e)?e.$comment:vi(e.$cstNode,this.grammarConfig().multilineCommentRules)?.text}};Ot();function Ms(e,t,n){let r,i;typeof e==`string`?(i=t,r=n):(i=e.range.start,r=t),i||=F.create(0,0);let a=Ps(e),o=Xs(r);return Us({index:0,tokens:Ls({lines:a,position:i,options:o}),position:i})}function Ns(e,t){let n=Xs(t),r=Ps(e);if(r.length===0)return!1;let i=r[0],a=r[r.length-1],o=n.start,s=n.end;return!!o?.exec(i)&&!!s?.exec(a)}function Ps(e){let t=``;return t=typeof e==`string`?e:e.text,t.split(Wi)}const Fs=/\s*(@([\p{L}][\p{L}\p{N}]*)?)/uy,Is=/\{(@[\p{L}][\p{L}\p{N}]*)(\s*)([^\r\n}]+)?\}/gu;function Ls(e){let t=[],n=e.position.line,r=e.position.character;for(let i=0;i<e.lines.length;i++){let a=i===0,o=i===e.lines.length-1,s=e.lines[i],c=0;if(a&&e.options.start){let t=e.options.start?.exec(s);t&&(c=t.index+t[0].length)}else{let t=e.options.line?.exec(s);t&&(c=t.index+t[0].length)}if(o){let t=e.options.end?.exec(s);t&&(s=s.substring(0,t.index))}if(s=s.substring(0,Hs(s)),Vs(s,c)>=s.length){if(t.length>0){let e=F.create(n,r);t.push({type:`break`,content:``,range:I.create(e,e)})}}else{Fs.lastIndex=c;let e=Fs.exec(s);if(e){let i=e[0],a=e[1],o=F.create(n,r+c),l=F.create(n,r+c+i.length);t.push({type:`tag`,content:a,range:I.create(o,l)}),c+=i.length,c=Vs(s,c)}if(c<s.length){let e=s.substring(c),i=Array.from(e.matchAll(Is));t.push(...Rs(i,e,n,r+c))}}n++,r=0}return t.length>0&&t[t.length-1].type===`break`?t.slice(0,-1):t}function Rs(e,t,n,r){let i=[];if(e.length===0){let e=F.create(n,r),a=F.create(n,r+t.length);i.push({type:`text`,content:t,range:I.create(e,a)})}else{let a=0;for(let o of e){let e=o.index,s=t.substring(a,e);s.length>0&&i.push({type:`text`,content:t.substring(a,e),range:I.create(F.create(n,a+r),F.create(n,e+r))});let c=s.length+1,l=o[1];if(i.push({type:`inline-tag`,content:l,range:I.create(F.create(n,a+c+r),F.create(n,a+c+l.length+r))}),c+=l.length,o.length===4){c+=o[2].length;let e=o[3];i.push({type:`text`,content:e,range:I.create(F.create(n,a+c+r),F.create(n,a+c+e.length+r))})}else i.push({type:`text`,content:``,range:I.create(F.create(n,a+c+r),F.create(n,a+c+r))});a=e+o[0].length}let o=t.substring(a);o.length>0&&i.push({type:`text`,content:o,range:I.create(F.create(n,a+r),F.create(n,a+r+o.length))})}return i}const zs=/\S/,Bs=/\s*$/;function Vs(e,t){let n=e.substring(t).match(zs);return n?t+n.index:e.length}function Hs(e){let t=e.match(Bs);if(t&&typeof t.index==`number`)return t.index}function Us(e){let t=F.create(e.position.line,e.position.character);if(e.tokens.length===0)return new Qs([],I.create(t,t));let n=[];for(;e.index<e.tokens.length;){let t=Ws(e,n[n.length-1]);t&&n.push(t)}let r=n[0]?.range.start??t,i=n[n.length-1]?.range.end??t;return new Qs(n,I.create(r,i))}function Ws(e,t){let n=e.tokens[e.index];if(n.type===`tag`)return Js(e,!1);if(n.type===`text`||n.type===`inline-tag`)return Ks(e);Gs(n,t),e.index++}function Gs(e,t){if(t){let n=new rc(``,e.range);`inlines`in t?t.inlines.push(n):t.content.inlines.push(n)}}function Ks(e){let t=e.tokens[e.index],n=t,r=t,i=[];for(;t&&t.type!==`break`&&t.type!==`tag`;)i.push(qs(e)),r=t,t=e.tokens[e.index];return new nc(i,I.create(n.range.start,r.range.end))}function qs(e){return e.tokens[e.index].type===`inline-tag`?Js(e,!0):Ys(e)}function Js(e,t){let n=e.tokens[e.index++],r=n.content.substring(1);if(e.tokens[e.index]?.type===`text`)if(t){let i=Ys(e);return new $s(r,new nc([i],i.range),t,I.create(n.range.start,i.range.end))}else{let i=Ks(e);return new $s(r,i,t,I.create(n.range.start,i.range.end))}else{let e=n.range;return new $s(r,new nc([],e),t,e)}}function Ys(e){let t=e.tokens[e.index++];return new rc(t.content,t.range)}function Xs(e){if(!e)return Xs({start:`/**`,end:`*/`,line:`*`});let{start:t,end:n,line:r}=e;return{start:Zs(t,!0),end:Zs(n,!1),line:Zs(r,!0)}}function Zs(e,t){if(typeof e==`string`||typeof e==`object`){let n=typeof e==`string`?Xi(e):e.source;return t?RegExp(`^\\s*${n}`):RegExp(`\\s*${n}\\s*$`)}else return e}var Qs=class{constructor(e,t){this.elements=e,this.range=t}getTag(e){return this.getAllTags().find(t=>t.name===e)}getTags(e){return this.getAllTags().filter(t=>t.name===e)}getAllTags(){return this.elements.filter(e=>`name`in e)}toString(){let e=``;for(let t of this.elements)if(e.length===0)e=t.toString();else{let n=t.toString();e+=ic(e)+n}return e.trim()}toMarkdown(e){let t=``;for(let n of this.elements)if(t.length===0)t=n.toMarkdown(e);else{let r=n.toMarkdown(e);t+=ic(t)+r}return t.trim()}},$s=class{constructor(e,t,n,r){this.name=e,this.content=t,this.inline=n,this.range=r}toString(){let e=`@${this.name}`,t=this.content.toString();return this.content.inlines.length===1?e=`${e} ${t}`:this.content.inlines.length>1&&(e=`${e}\n${t}`),this.inline?`{${e}}`:e}toMarkdown(e){return(e?.renderTag)?.call(e,this)??this.toMarkdownDefault(e)}toMarkdownDefault(e){let t=this.content.toMarkdown(e);if(this.inline){let n=ec(this.name,t,e??{});if(typeof n==`string`)return n}let n=``;e?.tag===`italic`||e?.tag===void 0?n=`*`:e?.tag===`bold`?n=`**`:e?.tag===`bold-italic`&&(n=`***`);let r=`${n}@${this.name}${n}`;return this.content.inlines.length===1?r=`${r} — ${t}`:this.content.inlines.length>1&&(r=`${r}\n${t}`),this.inline?`{${r}}`:r}};function ec(e,t,n){if(e===`linkplain`||e===`linkcode`||e===`link`){let r=t.indexOf(` `),i=t;if(r>0){let e=Vs(t,r);i=t.substring(e),t=t.substring(0,r)}return(e===`linkcode`||e===`link`&&n.link===`code`)&&(i=`\`${i}\``),n.renderLink?.call(n,t,i)??tc(t,i)}}function tc(e,t){try{return Y.parse(e,!0),`[${t}](${e})`}catch{return e}}var nc=class{constructor(e,t){this.inlines=e,this.range=t}toString(){let e=``;for(let t=0;t<this.inlines.length;t++){let n=this.inlines[t],r=this.inlines[t+1];e+=n.toString(),r&&r.range.start.line>n.range.start.line&&(e+=`
|
|
20
|
+
`;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`0`:return`\0`;default:return e}}function r(e){return e.charAt(0)===`^`?e.substring(1):e}e.convertID=r;function i(e){return parseInt(e)}e.convertInt=i;function a(e){return BigInt(e)}e.convertBigint=a;function o(e){return new Date(e)}e.convertDate=o;function s(e){return Number(e)}e.convertNumber=s;function c(e){return e.toLowerCase()===`true`}e.convertBoolean=c})(Ho||={});var Z=i({});t(Z,a(ee(),1));function Uo(){return new Promise(e=>{typeof setImmediate>`u`?setTimeout(e,0):setImmediate(e)})}let Wo=0;function Go(){return Wo=performance.now(),new Z.CancellationTokenSource}const Ko=Symbol(`OperationCancelled`);function qo(e){return e===Ko}async function Q(e){if(e===Z.CancellationToken.None)return;let t=performance.now();if(t-Wo>=10&&(Wo=t,await Uo(),Wo=performance.now()),e.isCancellationRequested)throw Ko}var Jo=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=t=>(e(t),this),this.reject=e=>(t(e),this)})}},Yo=class e{constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(t,n){for(let n of t)if(e.isIncremental(n)){let e=$o(n.range),t=this.offsetAt(e.start),r=this.offsetAt(e.end);this._content=this._content.substring(0,t)+n.text+this._content.substring(r,this._content.length);let i=Math.max(e.start.line,0),a=Math.max(e.end.line,0),o=this._lineOffsets,s=Qo(n.text,!1,t);if(a-i===s.length)for(let e=0,t=s.length;e<t;e++)o[e+i+1]=s[e];else s.length<1e4?o.splice(i+1,a-i,...s):this._lineOffsets=o=o.slice(0,i+1).concat(s,o.slice(a+1));let c=n.text.length-(r-t);if(c!==0)for(let e=i+1+s.length,t=o.length;e<t;e++)o[e]=o[e]+c}else if(e.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=Qo(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,r=t.length;if(r===0)return{line:0,character:e};for(;n<r;){let i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}let i=n-1;return{line:i,character:e-t[i]}}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line],r=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,r),n)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range!==void 0&&(t.rangeLength===void 0||typeof t.rangeLength==`number`)}static isFull(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range===void 0&&t.rangeLength===void 0}},Xo;(function(e){function t(e,t,n,r){return new Yo(e,t,n,r)}e.create=t;function n(e,t,n){if(e instanceof Yo)return e.update(t,n),e;throw Error(`TextDocument.update: document must be created by TextDocument.create`)}e.update=n;function r(e,t){let n=e.getText(),r=Zo(t.map(es),(e,t)=>{let n=e.range.start.line-t.range.start.line;return n===0?e.range.start.character-t.range.start.character:n}),i=0,a=[];for(let t of r){let r=e.offsetAt(t.range.start);if(r<i)throw Error(`Overlapping edit`);r>i&&a.push(n.substring(i,r)),t.newText.length&&a.push(t.newText),i=e.offsetAt(t.range.end)}return a.push(n.substr(i)),a.join(``)}e.applyEdits=r})(Xo||={});function Zo(e,t){if(e.length<=1)return e;let n=e.length/2|0,r=e.slice(0,n),i=e.slice(n);Zo(r,t),Zo(i,t);let a=0,o=0,s=0;for(;a<r.length&&o<i.length;)t(r[a],i[o])<=0?e[s++]=r[a++]:e[s++]=i[o++];for(;a<r.length;)e[s++]=r[a++];for(;o<i.length;)e[s++]=i[o++];return e}function Qo(e,t,n=0){let r=t?[n]:[];for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);(i===13||i===10)&&(i===13&&t+1<e.length&&e.charCodeAt(t+1)===10&&t++,r.push(n+t+1))}return r}function $o(e){let t=e.start,n=e.end;return t.line>n.line||t.line===n.line&&t.character>n.character?{start:n,end:t}:e}function es(e){let t=$o(e.range);return t===e.range?e:{newText:e.newText,range:t}}var $;(function(e){e[e.Changed=0]=`Changed`,e[e.Parsed=1]=`Parsed`,e[e.IndexedContent=2]=`IndexedContent`,e[e.ComputedScopes=3]=`ComputedScopes`,e[e.Linked=4]=`Linked`,e[e.IndexedReferences=5]=`IndexedReferences`,e[e.Validated=6]=`Validated`})($||={});var ts=class{constructor(e){this.serviceRegistry=e.ServiceRegistry,this.textDocuments=e.workspace.TextDocuments,this.fileSystemProvider=e.workspace.FileSystemProvider}async fromUri(e,t=Z.CancellationToken.None){let n=await this.fileSystemProvider.readFile(e);return this.createAsync(e,n,t)}fromTextDocument(e,t,n){return t??=Y.parse(e.uri),Z.CancellationToken.is(n)?this.createAsync(t,e,n):this.create(t,e,n)}fromString(e,t,n){return Z.CancellationToken.is(n)?this.createAsync(t,e,n):this.create(t,e,n)}fromModel(e,t){return this.create(t,{$model:e})}create(e,t,n){if(typeof t==`string`){let r=this.parse(e,t,n);return this.createLangiumDocument(r,e,void 0,t)}else if(`$model`in t){let n={value:t.$model,parserErrors:[],lexerErrors:[]};return this.createLangiumDocument(n,e)}else{let r=this.parse(e,t.getText(),n);return this.createLangiumDocument(r,e,t)}}async createAsync(e,t,n){if(typeof t==`string`){let r=await this.parseAsync(e,t,n);return this.createLangiumDocument(r,e,void 0,t)}else{let r=await this.parseAsync(e,t.getText(),n);return this.createLangiumDocument(r,e,t)}}createLangiumDocument(e,t,n,r){let i;if(n)i={parseResult:e,uri:t,state:$.Parsed,references:[],textDocument:n};else{let n=this.createTextDocumentGetter(t,r);i={parseResult:e,uri:t,state:$.Parsed,references:[],get textDocument(){return n()}}}return e.value.$document=i,i}async update(e,t){let n=e.parseResult.value.$cstNode?.root.fullText,r=this.textDocuments?.get(e.uri.toString()),i=r?r.getText():await this.fileSystemProvider.readFile(e.uri);if(r)Object.defineProperty(e,`textDocument`,{value:r});else{let t=this.createTextDocumentGetter(e.uri,i);Object.defineProperty(e,`textDocument`,{get:t})}return n!==i&&(e.parseResult=await this.parseAsync(e.uri,i,t),e.parseResult.value.$document=e),e.state=$.Parsed,e}parse(e,t,n){return this.serviceRegistry.getServices(e).parser.LangiumParser.parse(t,n)}parseAsync(e,t,n){return this.serviceRegistry.getServices(e).parser.AsyncParser.parse(t,n)}createTextDocumentGetter(e,t){let n=this.serviceRegistry,r;return()=>r??=Xo.create(e.toString(),n.getServices(e).LanguageMetaData.languageId,0,t??``)}},ns=class{constructor(e){this.documentMap=new Map,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.serviceRegistry=e.ServiceRegistry}get all(){return K(this.documentMap.values())}addDocument(e){let t=e.uri.toString();if(this.documentMap.has(t))throw Error(`A document with the URI '${t}' is already present.`);this.documentMap.set(t,e)}getDocument(e){let t=e.toString();return this.documentMap.get(t)}async getOrCreateDocument(e,t){let n=this.getDocument(e);return n||(n=await this.langiumDocumentFactory.fromUri(e,t),this.addDocument(n),n)}createDocument(e,t,n){if(n)return this.langiumDocumentFactory.fromString(t,e,n).then(e=>(this.addDocument(e),e));{let n=this.langiumDocumentFactory.fromString(t,e);return this.addDocument(n),n}}hasDocument(e){return this.documentMap.has(e.toString())}invalidateDocument(e){let t=e.toString(),n=this.documentMap.get(t);return n&&(this.serviceRegistry.getServices(e).references.Linker.unlink(n),n.state=$.Changed,n.precomputedScopes=void 0,n.diagnostics=void 0),n}deleteDocument(e){let t=e.toString(),n=this.documentMap.get(t);return n&&(n.state=$.Changed,this.documentMap.delete(t)),n}};const rs=Symbol(`ref_resolving`);var is=class{constructor(e){this.reflection=e.shared.AstReflection,this.langiumDocuments=()=>e.shared.workspace.LangiumDocuments,this.scopeProvider=e.references.ScopeProvider,this.astNodeLocator=e.workspace.AstNodeLocator}async link(e,t=Z.CancellationToken.None){for(let n of Fi(e.parseResult.value))await Q(t),Li(n).forEach(t=>this.doLink(t,e))}doLink(e,t){let n=e.reference;if(n._ref===void 0){n._ref=rs;try{let t=this.getCandidate(e);En(t)?n._ref=t:(n._nodeDescription=t,this.langiumDocuments().hasDocument(t.documentUri)?n._ref=this.loadAstNode(t)??this.createLinkingError(e,t):n._ref=void 0)}catch(t){console.error(`An error occurred while resolving reference to '${n.$refText}':`,t);let r=t.message??String(t);n._ref=Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${n.$refText}': ${r}`})}t.references.push(n)}}unlink(e){for(let t of e.references)delete t._ref,delete t._nodeDescription;e.references=[]}getCandidate(e){return this.scopeProvider.getScope(e).getElement(e.reference.$refText)??this.createLinkingError(e)}buildReference(e,t,n,r){let i=this,a={$refNode:n,$refText:r,get ref(){if(H(this._ref))return this._ref;if(Tn(this._nodeDescription))this._ref=i.loadAstNode(this._nodeDescription)??i.createLinkingError({reference:a,container:e,property:t},this._nodeDescription);else if(this._ref===void 0){this._ref=rs;let n=Mi(e).$document,r=i.getLinkedNode({reference:a,container:e,property:t});if(r.error&&n&&n.state<$.ComputedScopes){this._ref=void 0;return}this._ref=r.node??r.error,this._nodeDescription=r.descr,n?.references.push(this)}else if(this._ref===rs)throw Error(`Cyclic reference resolution detected: ${i.astNodeLocator.getAstNodePath(e)}/${t} (symbol '${r}')`);return H(this._ref)?this._ref:void 0},get $nodeDescription(){return this._nodeDescription},get error(){return En(this._ref)?this._ref:void 0}};return a}getLinkedNode(e){try{let t=this.getCandidate(e);if(En(t))return{error:t};let n=this.loadAstNode(t);return n?{node:n,descr:t}:{descr:t,error:this.createLinkingError(e,t)}}catch(t){console.error(`An error occurred while resolving reference to '${e.reference.$refText}':`,t);let n=t.message??String(t);return{error:Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${e.reference.$refText}': ${n}`})}}}loadAstNode(e){if(e.node)return e.node;let t=this.langiumDocuments().getDocument(e.documentUri);if(t)return this.astNodeLocator.getAstNode(t.parseResult.value,e.path)}createLinkingError(e,t){let n=Mi(e.container).$document;n&&n.state<$.ComputedScopes&&console.warn(`Attempted reference resolution before document reached ComputedScopes state (${n.uri}).`);let r=this.reflection.getReferenceType(e);return Object.assign(Object.assign({},e),{message:`Could not resolve reference to ${r} named '${e.reference.$refText}'.`,targetDescription:t})}};function as(e){return typeof e.name==`string`}var os=class{getName(e){if(as(e))return e.name}getNameNode(e){return ca(e.$cstNode,`name`)}},ss=class{constructor(e){this.nameProvider=e.references.NameProvider,this.index=e.shared.workspace.IndexManager,this.nodeLocator=e.workspace.AstNodeLocator}findDeclaration(e){if(e){let t=pa(e),n=e.astNode;if(t&&n){let r=n[t.feature];if(wn(r))return r.ref;if(Array.isArray(r)){for(let t of r)if(wn(t)&&t.$refNode&&t.$refNode.offset<=e.offset&&t.$refNode.end>=e.end)return t.ref}}if(n){let t=this.nameProvider.getNameNode(n);if(t&&(t===e||ui(e,t)))return n}}}findDeclarationNode(e){let t=this.findDeclaration(e);if(t?.$cstNode)return this.nameProvider.getNameNode(t)??t.$cstNode}findReferences(e,t){let n=[];if(t.includeDeclaration){let t=this.getReferenceToSelf(e);t&&n.push(t)}let r=this.index.findAllReferences(e,this.nodeLocator.getAstNodePath(e));return t.documentUri&&(r=r.filter(e=>X.equals(e.sourceUri,t.documentUri))),n.push(...r),K(n)}getReferenceToSelf(e){let t=this.nameProvider.getNameNode(e);if(t){let n=q(e),r=this.nodeLocator.getAstNodePath(e);return{sourceUri:n.uri,sourcePath:r,targetUri:n.uri,targetPath:r,segment:fi(t),local:!0}}}},cs=class{constructor(e){if(this.map=new Map,e)for(let[t,n]of e)this.add(t,n)}get size(){return si.sum(K(this.map.values()).map(e=>e.length))}clear(){this.map.clear()}delete(e,t){if(t===void 0)return this.map.delete(e);{let n=this.map.get(e);if(n){let r=n.indexOf(t);if(r>=0)return n.length===1?this.map.delete(e):n.splice(r,1),!0}return!1}}get(e){return this.map.get(e)??[]}has(e,t){if(t===void 0)return this.map.has(e);{let n=this.map.get(e);return n?n.indexOf(t)>=0:!1}}add(e,t){return this.map.has(e)?this.map.get(e).push(t):this.map.set(e,[t]),this}addAll(e,t){return this.map.has(e)?this.map.get(e).push(...t):this.map.set(e,Array.from(t)),this}forEach(e){this.map.forEach((t,n)=>t.forEach(t=>e(t,n,this)))}[Symbol.iterator](){return this.entries().iterator()}entries(){return K(this.map.entries()).flatMap(([e,t])=>t.map(t=>[e,t]))}keys(){return K(this.map.keys())}values(){return K(this.map.values()).flat()}entriesGroupedByKey(){return K(this.map.entries())}},ls=class{get size(){return this.map.size}constructor(e){if(this.map=new Map,this.inverse=new Map,e)for(let[t,n]of e)this.set(t,n)}clear(){this.map.clear(),this.inverse.clear()}set(e,t){return this.map.set(e,t),this.inverse.set(t,e),this}get(e){return this.map.get(e)}getKey(e){return this.inverse.get(e)}delete(e){let t=this.map.get(e);return t===void 0?!1:(this.map.delete(e),this.inverse.delete(t),!0)}},us=class{constructor(e){this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider}async computeExports(e,t=Z.CancellationToken.None){return this.computeExportsForNode(e.parseResult.value,e,void 0,t)}async computeExportsForNode(e,t,n=Ni,r=Z.CancellationToken.None){let i=[];this.exportNode(e,i,t);for(let a of n(e))await Q(r),this.exportNode(a,i,t);return i}exportNode(e,t,n){let r=this.nameProvider.getName(e);r&&t.push(this.descriptions.createDescription(e,r,n))}async computeLocalScopes(e,t=Z.CancellationToken.None){let n=e.parseResult.value,r=new cs;for(let i of Pi(n))await Q(t),this.processNode(i,e,r);return r}processNode(e,t,n){let r=e.$container;if(r){let i=this.nameProvider.getName(e);i&&n.add(r,this.descriptions.createDescription(e,i,t))}}},ds=class{constructor(e,t,n){this.elements=e,this.outerScope=t,this.caseInsensitive=n?.caseInsensitive??!1}getAllElements(){return this.outerScope?this.elements.concat(this.outerScope.getAllElements()):this.elements}getElement(e){let t=this.caseInsensitive?this.elements.find(t=>t.name.toLowerCase()===e.toLowerCase()):this.elements.find(t=>t.name===e);if(t)return t;if(this.outerScope)return this.outerScope.getElement(e)}},fs=class{constructor(e,t,n){this.elements=new Map,this.caseInsensitive=n?.caseInsensitive??!1;for(let t of e){let e=this.caseInsensitive?t.name.toLowerCase():t.name;this.elements.set(e,t)}this.outerScope=t}getElement(e){let t=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(t);if(n)return n;if(this.outerScope)return this.outerScope.getElement(e)}getAllElements(){let e=K(this.elements.values());return this.outerScope&&(e=e.concat(this.outerScope.getAllElements())),e}};const ps={getElement(){},getAllElements(){return ai}};var ms=class{constructor(){this.toDispose=[],this.isDisposed=!1}onDispose(e){this.toDispose.push(e)}dispose(){this.throwIfDisposed(),this.clear(),this.isDisposed=!0,this.toDispose.forEach(e=>e.dispose())}throwIfDisposed(){if(this.isDisposed)throw Error(`This cache has already been disposed`)}},hs=class extends ms{constructor(){super(...arguments),this.cache=new Map}has(e){return this.throwIfDisposed(),this.cache.has(e)}set(e,t){this.throwIfDisposed(),this.cache.set(e,t)}get(e,t){if(this.throwIfDisposed(),this.cache.has(e))return this.cache.get(e);if(t){let n=t();return this.cache.set(e,n),n}else return}delete(e){return this.throwIfDisposed(),this.cache.delete(e)}clear(){this.throwIfDisposed(),this.cache.clear()}},gs=class extends ms{constructor(e){super(),this.cache=new Map,this.converter=e??(e=>e)}has(e,t){return this.throwIfDisposed(),this.cacheForContext(e).has(t)}set(e,t,n){this.throwIfDisposed(),this.cacheForContext(e).set(t,n)}get(e,t,n){this.throwIfDisposed();let r=this.cacheForContext(e);if(r.has(t))return r.get(t);if(n){let e=n();return r.set(t,e),e}else return}delete(e,t){return this.throwIfDisposed(),this.cacheForContext(e).delete(t)}clear(e){if(this.throwIfDisposed(),e){let t=this.converter(e);this.cache.delete(t)}else this.cache.clear()}cacheForContext(e){let t=this.converter(e),n=this.cache.get(t);return n||(n=new Map,this.cache.set(t,n)),n}},_s=class extends hs{constructor(e,t){super(),t?(this.toDispose.push(e.workspace.DocumentBuilder.onBuildPhase(t,()=>{this.clear()})),this.toDispose.push(e.workspace.DocumentBuilder.onUpdate((e,t)=>{t.length>0&&this.clear()}))):this.toDispose.push(e.workspace.DocumentBuilder.onUpdate(()=>{this.clear()}))}},vs=class{constructor(e){this.reflection=e.shared.AstReflection,this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider,this.indexManager=e.shared.workspace.IndexManager,this.globalScopeCache=new _s(e.shared)}getScope(e){let t=[],n=this.reflection.getReferenceType(e),r=q(e.container).precomputedScopes;if(r){let i=e.container;do{let e=r.get(i);e.length>0&&t.push(K(e).filter(e=>this.reflection.isSubtype(e.type,n))),i=i.$container}while(i)}let i=this.getGlobalScope(n,e);for(let e=t.length-1;e>=0;e--)i=this.createScope(t[e],i);return i}createScope(e,t,n){return new ds(K(e),t,n)}createScopeForNodes(e,t,n){return new ds(K(e).map(e=>{let t=this.nameProvider.getName(e);if(t)return this.descriptions.createDescription(e,t)}).nonNullable(),t,n)}getGlobalScope(e,t){return this.globalScopeCache.get(e,()=>new fs(this.indexManager.allElements(e)))}};function ys(e){return typeof e.$comment==`string`}function bs(e){return typeof e==`object`&&!!e&&(`$ref`in e||`$error`in e)}var xs=class{constructor(e){this.ignoreProperties=new Set([`$container`,`$containerProperty`,`$containerIndex`,`$document`,`$cstNode`]),this.langiumDocuments=e.shared.workspace.LangiumDocuments,this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider,this.commentProvider=e.documentation.CommentProvider}serialize(e,t){let n=t??{},r=t?.replacer,i=(e,t)=>this.replacer(e,t,n),a=r?(e,t)=>r(e,t,i):i;try{return this.currentDocument=q(e),JSON.stringify(e,a,t?.space)}finally{this.currentDocument=void 0}}deserialize(e,t){let n=t??{},r=JSON.parse(e);return this.linkNode(r,r,n),r}replacer(e,t,{refText:n,sourceText:r,textRegions:i,comments:a,uriConverter:o}){if(!this.ignoreProperties.has(e))if(wn(t)){let e=t.ref,r=n?t.$refText:void 0;if(e){let n=q(e),i=``;this.currentDocument&&this.currentDocument!==n&&(i=o?o(n.uri,t):n.uri.toString());let a=this.astNodeLocator.getAstNodePath(e);return{$ref:`${i}#${a}`,$refText:r}}else return{$error:t.error?.message??`Could not resolve reference`,$refText:r}}else if(H(t)){let n;if(i&&(n=this.addAstNodeRegionWithAssignmentsTo(Object.assign({},t)),(!e||t.$document)&&n?.$textRegion&&(n.$textRegion.documentURI=this.currentDocument?.uri.toString())),r&&!e&&(n??=Object.assign({},t),n.$sourceText=t.$cstNode?.text),a){n??=Object.assign({},t);let e=this.commentProvider.getComment(t);e&&(n.$comment=e.replace(/\r/g,``))}return n??t}else return t}addAstNodeRegionWithAssignmentsTo(e){let t=e=>({offset:e.offset,end:e.end,length:e.length,range:e.range});if(e.$cstNode){let n=e.$textRegion=t(e.$cstNode),r=n.assignments={};return Object.keys(e).filter(e=>!e.startsWith(`$`)).forEach(n=>{let i=sa(e.$cstNode,n).map(t);i.length!==0&&(r[n]=i)}),e}}linkNode(e,t,n,r,i,a){for(let[r,i]of Object.entries(e))if(Array.isArray(i))for(let a=0;a<i.length;a++){let o=i[a];bs(o)?i[a]=this.reviveReference(e,r,t,o,n):H(o)&&this.linkNode(o,t,n,e,r,a)}else bs(i)?e[r]=this.reviveReference(e,r,t,i,n):H(i)&&this.linkNode(i,t,n,e,r);let o=e;o.$container=r,o.$containerProperty=i,o.$containerIndex=a}reviveReference(e,t,n,r,i){let a=r.$refText,o=r.$error;if(r.$ref){let e=this.getRefNode(n,r.$ref,i.uriConverter);if(H(e))return a||=this.nameProvider.getName(e),{$refText:a??``,ref:e};o=e}if(o){let n={$refText:a??``};return n.error={container:e,property:t,message:o,reference:n},n}else return}getRefNode(e,t,n){try{let r=t.indexOf(`#`);if(r===0)return this.astNodeLocator.getAstNode(e,t.substring(1))||`Could not resolve path: `+t;if(r<0){let e=n?n(t):Y.parse(t),r=this.langiumDocuments.getDocument(e);return r?r.parseResult.value:`Could not find document for URI: `+t}let i=n?n(t.substring(0,r)):Y.parse(t.substring(0,r)),a=this.langiumDocuments.getDocument(i);return a?r===t.length-1?a.parseResult.value:this.astNodeLocator.getAstNode(a.parseResult.value,t.substring(r+1))||`Could not resolve URI: `+t:`Could not find document for URI: `+t}catch(e){return String(e)}}},Ss=class{get map(){return this.fileExtensionMap}constructor(e){this.languageIdMap=new Map,this.fileExtensionMap=new Map,this.fileNameMap=new Map,this.textDocuments=e?.workspace.TextDocuments}register(e){let t=e.LanguageMetaData;for(let n of t.fileExtensions)this.fileExtensionMap.has(n)&&console.warn(`The file extension ${n} is used by multiple languages. It is now assigned to '${t.languageId}'.`),this.fileExtensionMap.set(n,e);if(t.fileNames)for(let n of t.fileNames)this.fileNameMap.has(n)&&console.warn(`The file name ${n} is used by multiple languages. It is now assigned to '${t.languageId}'.`),this.fileNameMap.set(n,e);this.languageIdMap.set(t.languageId,e),this.languageIdMap.size===1?this.singleton=e:this.singleton=void 0}getServices(e){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 t=this.textDocuments?.get(e)?.languageId;if(t!==void 0){let e=this.languageIdMap.get(t);if(e)return e}let n=X.extname(e),r=X.basename(e),i=this.fileNameMap.get(r)??this.fileExtensionMap.get(n);if(!i)throw t?Error(`The service registry contains no services for the extension '${n}' for language '${t}'.`):Error(`The service registry contains no services for the extension '${n}'.`);return i}hasServices(e){try{return this.getServices(e),!0}catch{return!1}}get all(){return Array.from(this.languageIdMap.values())}},Cs;(function(e){e.merge=(e,t)=>As(As({},e),t)})(Cs||={});function ws(e,t,n,r,i,a,o,s,c){return Ds([e,t,n,r,i,a,o,s,c].reduce(As,{}))}const Ts=Symbol(`isProxy`);function Es(e){if(e&&e[Ts])for(let t of Object.values(e))Es(t);return e}function Ds(e,t){let n=new Proxy({},{deleteProperty:()=>!1,set:()=>{throw Error(`Cannot set property on injected service container`)},get:(r,i)=>i===Ts?!0:ks(r,i,e,t||n),getOwnPropertyDescriptor:(r,i)=>(ks(r,i,e,t||n),Object.getOwnPropertyDescriptor(r,i)),has:(t,n)=>n in e,ownKeys:()=>[...Object.getOwnPropertyNames(e)]});return n}const Os=Symbol();function ks(e,t,n,r){if(t in e){if(e[t]instanceof Error)throw Error(`Construction failure. Please make sure that your dependencies are constructable.`,{cause:e[t]});if(e[t]===Os)throw Error(`Cycle detected. Please make "`+String(t)+`" lazy. Visit https://langium.org/docs/reference/configuration-services/#resolving-cyclic-dependencies`);return e[t]}else if(t in n){let i=n[t];e[t]=Os;try{e[t]=typeof i==`function`?i(r):Ds(i,r)}catch(n){throw e[t]=n instanceof Error?n:void 0,n}return e[t]}else return}function As(e,t){if(t){for(let[n,r]of Object.entries(t))if(r!==void 0){let t=e[n];t!==null&&r!==null&&typeof t==`object`&&typeof r==`object`?e[n]=As(t,r):e[n]=r}}return e}var js=class{constructor(e){this.grammarConfig=()=>e.parser.GrammarConfig}getComment(e){return ys(e)?e.$comment:vi(e.$cstNode,this.grammarConfig().multilineCommentRules)?.text}};Ot();function Ms(e,t,n){let r,i;typeof e==`string`?(i=t,r=n):(i=e.range.start,r=t),i||=F.create(0,0);let a=Ps(e),o=Xs(r);return Us({index:0,tokens:Ls({lines:a,position:i,options:o}),position:i})}function Ns(e,t){let n=Xs(t),r=Ps(e);if(r.length===0)return!1;let i=r[0],a=r[r.length-1],o=n.start,s=n.end;return!!o?.exec(i)&&!!s?.exec(a)}function Ps(e){let t=``;return t=typeof e==`string`?e:e.text,t.split(Wi)}const Fs=/\s*(@([\p{L}][\p{L}\p{N}]*)?)/uy,Is=/\{(@[\p{L}][\p{L}\p{N}]*)(\s*)([^\r\n}]+)?\}/gu;function Ls(e){let t=[],n=e.position.line,r=e.position.character;for(let i=0;i<e.lines.length;i++){let a=i===0,o=i===e.lines.length-1,s=e.lines[i],c=0;if(a&&e.options.start){let t=e.options.start?.exec(s);t&&(c=t.index+t[0].length)}else{let t=e.options.line?.exec(s);t&&(c=t.index+t[0].length)}if(o){let t=e.options.end?.exec(s);t&&(s=s.substring(0,t.index))}if(s=s.substring(0,Hs(s)),Vs(s,c)>=s.length){if(t.length>0){let e=F.create(n,r);t.push({type:`break`,content:``,range:I.create(e,e)})}}else{Fs.lastIndex=c;let e=Fs.exec(s);if(e){let i=e[0],a=e[1],o=F.create(n,r+c),l=F.create(n,r+c+i.length);t.push({type:`tag`,content:a,range:I.create(o,l)}),c+=i.length,c=Vs(s,c)}if(c<s.length){let e=s.substring(c),i=Array.from(e.matchAll(Is));t.push(...Rs(i,e,n,r+c))}}n++,r=0}return t.length>0&&t[t.length-1].type===`break`?t.slice(0,-1):t}function Rs(e,t,n,r){let i=[];if(e.length===0){let e=F.create(n,r),a=F.create(n,r+t.length);i.push({type:`text`,content:t,range:I.create(e,a)})}else{let a=0;for(let o of e){let e=o.index,s=t.substring(a,e);s.length>0&&i.push({type:`text`,content:t.substring(a,e),range:I.create(F.create(n,a+r),F.create(n,e+r))});let c=s.length+1,l=o[1];if(i.push({type:`inline-tag`,content:l,range:I.create(F.create(n,a+c+r),F.create(n,a+c+l.length+r))}),c+=l.length,o.length===4){c+=o[2].length;let e=o[3];i.push({type:`text`,content:e,range:I.create(F.create(n,a+c+r),F.create(n,a+c+e.length+r))})}else i.push({type:`text`,content:``,range:I.create(F.create(n,a+c+r),F.create(n,a+c+r))});a=e+o[0].length}let o=t.substring(a);o.length>0&&i.push({type:`text`,content:o,range:I.create(F.create(n,a+r),F.create(n,a+r+o.length))})}return i}const zs=/\S/,Bs=/\s*$/;function Vs(e,t){let n=e.substring(t).match(zs);return n?t+n.index:e.length}function Hs(e){let t=e.match(Bs);if(t&&typeof t.index==`number`)return t.index}function Us(e){let t=F.create(e.position.line,e.position.character);if(e.tokens.length===0)return new Qs([],I.create(t,t));let n=[];for(;e.index<e.tokens.length;){let t=Ws(e,n[n.length-1]);t&&n.push(t)}let r=n[0]?.range.start??t,i=n[n.length-1]?.range.end??t;return new Qs(n,I.create(r,i))}function Ws(e,t){let n=e.tokens[e.index];if(n.type===`tag`)return Js(e,!1);if(n.type===`text`||n.type===`inline-tag`)return Ks(e);Gs(n,t),e.index++}function Gs(e,t){if(t){let n=new rc(``,e.range);`inlines`in t?t.inlines.push(n):t.content.inlines.push(n)}}function Ks(e){let t=e.tokens[e.index],n=t,r=t,i=[];for(;t&&t.type!==`break`&&t.type!==`tag`;)i.push(qs(e)),r=t,t=e.tokens[e.index];return new nc(i,I.create(n.range.start,r.range.end))}function qs(e){return e.tokens[e.index].type===`inline-tag`?Js(e,!0):Ys(e)}function Js(e,t){let n=e.tokens[e.index++],r=n.content.substring(1);if(e.tokens[e.index]?.type===`text`)if(t){let i=Ys(e);return new $s(r,new nc([i],i.range),t,I.create(n.range.start,i.range.end))}else{let i=Ks(e);return new $s(r,i,t,I.create(n.range.start,i.range.end))}else{let e=n.range;return new $s(r,new nc([],e),t,e)}}function Ys(e){let t=e.tokens[e.index++];return new rc(t.content,t.range)}function Xs(e){if(!e)return Xs({start:`/**`,end:`*/`,line:`*`});let{start:t,end:n,line:r}=e;return{start:Zs(t,!0),end:Zs(n,!1),line:Zs(r,!0)}}function Zs(e,t){if(typeof e==`string`||typeof e==`object`){let n=typeof e==`string`?Xi(e):e.source;return t?RegExp(`^\\s*${n}`):RegExp(`\\s*${n}\\s*$`)}else return e}var Qs=class{constructor(e,t){this.elements=e,this.range=t}getTag(e){return this.getAllTags().find(t=>t.name===e)}getTags(e){return this.getAllTags().filter(t=>t.name===e)}getAllTags(){return this.elements.filter(e=>`name`in e)}toString(){let e=``;for(let t of this.elements)if(e.length===0)e=t.toString();else{let n=t.toString();e+=ic(e)+n}return e.trim()}toMarkdown(e){let t=``;for(let n of this.elements)if(t.length===0)t=n.toMarkdown(e);else{let r=n.toMarkdown(e);t+=ic(t)+r}return t.trim()}},$s=class{constructor(e,t,n,r){this.name=e,this.content=t,this.inline=n,this.range=r}toString(){let e=`@${this.name}`,t=this.content.toString();return this.content.inlines.length===1?e=`${e} ${t}`:this.content.inlines.length>1&&(e=`${e}\n${t}`),this.inline?`{${e}}`:e}toMarkdown(e){return(e?.renderTag)?.call(e,this)??this.toMarkdownDefault(e)}toMarkdownDefault(e){let t=this.content.toMarkdown(e);if(this.inline){let n=ec(this.name,t,e??{});if(typeof n==`string`)return n}let n=``;e?.tag===`italic`||e?.tag===void 0?n=`*`:e?.tag===`bold`?n=`**`:e?.tag===`bold-italic`&&(n=`***`);let r=`${n}@${this.name}${n}`;return this.content.inlines.length===1?r=`${r} — ${t}`:this.content.inlines.length>1&&(r=`${r}\n${t}`),this.inline?`{${r}}`:r}};function ec(e,t,n){if(e===`linkplain`||e===`linkcode`||e===`link`){let r=t.indexOf(` `),i=t;if(r>0){let e=Vs(t,r);i=t.substring(e),t=t.substring(0,r)}return(e===`linkcode`||e===`link`&&n.link===`code`)&&(i=`\`${i}\``),n.renderLink?.call(n,t,i)??tc(t,i)}}function tc(e,t){try{return Y.parse(e,!0),`[${t}](${e})`}catch{return e}}var nc=class{constructor(e,t){this.inlines=e,this.range=t}toString(){let e=``;for(let t=0;t<this.inlines.length;t++){let n=this.inlines[t],r=this.inlines[t+1];e+=n.toString(),r&&r.range.start.line>n.range.start.line&&(e+=`
|
|
21
21
|
`)}return e}toMarkdown(e){let t=``;for(let n=0;n<this.inlines.length;n++){let r=this.inlines[n],i=this.inlines[n+1];t+=r.toMarkdown(e),i&&i.range.start.line>r.range.start.line&&(t+=`
|
|
22
22
|
`)}return t}},rc=class{constructor(e,t){this.text=e,this.range=t}toString(){return this.text}toMarkdown(){return this.text}};function ic(e){return e.endsWith(`
|
|
23
23
|
`)?`
|
|
24
24
|
`:`
|
|
25
25
|
|
|
26
|
-
`}var ac=class{constructor(e){this.indexManager=e.shared.workspace.IndexManager,this.commentProvider=e.documentation.CommentProvider}getDocumentation(e){let t=this.commentProvider.getComment(e);if(t&&Ns(t))return Ms(t).toMarkdown({renderLink:(t,n)=>this.documentationLinkRenderer(e,t,n),renderTag:t=>this.documentationTagRenderer(e,t)})}documentationLinkRenderer(e,t,n){let r=this.findNameInPrecomputedScopes(e,t)??this.findNameInGlobalScope(e,t);if(r&&r.nameSegment){let e=r.nameSegment.range.start.line+1,t=r.nameSegment.range.start.character+1;return`[${n}](${r.documentUri.with({fragment:`L${e},${t}`}).toString()})`}else return}documentationTagRenderer(e,t){}findNameInPrecomputedScopes(e,t){let n=q(e).precomputedScopes;if(!n)return;let r=e;do{let e=n.get(r).find(e=>e.name===t);if(e)return e;r=r.$container}while(r)}findNameInGlobalScope(e,t){return this.indexManager.allElements().find(e=>e.name===t)}},oc={};t(oc,a(w(),1));var sc=class{constructor(e){this.syncParser=e.parser.LangiumParser}parse(e,t){return Promise.resolve(this.syncParser.parse(e))}},cc=class{buildUnexpectedCharactersMessage(e,t,n,r,i){return h.buildUnexpectedCharactersMessage(e,t,n,r,i)}buildUnableToPopLexerModeMessage(e){return h.buildUnableToPopLexerModeMessage(e)}};const lc={mode:`full`};var uc=class{constructor(e){this.errorMessageProvider=e.parser.LexerErrorMessageProvider,this.tokenBuilder=e.parser.TokenBuilder;let t=this.tokenBuilder.buildTokens(e.Grammar,{caseInsensitive:e.LanguageMetaData.caseInsensitive});this.tokenTypes=this.toTokenTypeDictionary(t),this.chevrotainLexer=new u(pc(t)?Object.values(t):t,{positionTracking:`full`,skipValidations:e.LanguageMetaData.mode===`production`,errorMessageProvider:this.errorMessageProvider})}get definition(){return this.tokenTypes}tokenize(e,t=lc){var n;let r=this.chevrotainLexer.tokenize(e);return{tokens:r.tokens,errors:r.errors,hidden:r.groups.hidden??[],report:(n=this.tokenBuilder).flushLexingReport?.call(n,e)}}toTokenTypeDictionary(e){if(pc(e))return e;let t=fc(e)?Object.values(e.modes).flat():e,n={};return t.forEach(e=>n[e.name]=e),n}};function dc(e){return Array.isArray(e)&&(e.length===0||`name`in e[0])}function fc(e){return e&&`modes`in e&&`defaultMode`in e}function pc(e){return!dc(e)&&!fc(e)}var mc=class{constructor(e){this.grammarElementIdMap=new ls,this.tokenTypeIdMap=new ls,this.grammar=e.Grammar,this.lexer=e.parser.Lexer,this.linker=e.references.Linker}dehydrate(e){return{lexerErrors:e.lexerErrors,lexerReport:e.lexerReport?this.dehydrateLexerReport(e.lexerReport):void 0,parserErrors:e.parserErrors.map(e=>Object.assign(Object.assign({},e),{message:e.message})),value:this.dehydrateAstNode(e.value,this.createDehyrationContext(e.value))}}dehydrateLexerReport(e){return e}createDehyrationContext(e){let t=new Map,n=new Map;for(let n of Fi(e))t.set(n,{});if(e.$cstNode)for(let t of ci(e.$cstNode))n.set(t,{});return{astNodes:t,cstNodes:n}}dehydrateAstNode(e,t){let n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode!==void 0&&(n.$cstNode=this.dehydrateCstNode(e.$cstNode,t));for(let[r,i]of Object.entries(e))if(!r.startsWith(`$`))if(Array.isArray(i)){let e=[];n[r]=e;for(let n of i)H(n)?e.push(this.dehydrateAstNode(n,t)):wn(n)?e.push(this.dehydrateReference(n,t)):e.push(n)}else H(i)?n[r]=this.dehydrateAstNode(i,t):wn(i)?n[r]=this.dehydrateReference(i,t):i!==void 0&&(n[r]=i);return n}dehydrateReference(e,t){let n={};return n.$refText=e.$refText,e.$refNode&&(n.$refNode=t.cstNodes.get(e.$refNode)),n}dehydrateCstNode(e,t){let n=t.cstNodes.get(e);return An(e)?n.fullText=e.fullText:n.grammarSource=this.getGrammarElementId(e.grammarSource),n.hidden=e.hidden,n.astNode=t.astNodes.get(e.astNode),On(e)?n.content=e.content.map(e=>this.dehydrateCstNode(e,t)):kn(e)&&(n.tokenType=e.tokenType.name,n.offset=e.offset,n.length=e.length,n.startLine=e.range.start.line,n.startColumn=e.range.start.character,n.endLine=e.range.end.line,n.endColumn=e.range.end.character),n}hydrate(e){let t=e.value,n=this.createHydrationContext(t);return`$cstNode`in t&&this.hydrateCstNode(t.$cstNode,n),{lexerErrors:e.lexerErrors,lexerReport:e.lexerReport,parserErrors:e.parserErrors,value:this.hydrateAstNode(t,n)}}createHydrationContext(e){let t=new Map,n=new Map;for(let n of Fi(e))t.set(n,{});let r;if(e.$cstNode)for(let t of ci(e.$cstNode)){let e;`fullText`in t?(e=new co(t.fullText),r=e):`content`in t?e=new oo:`tokenType`in t&&(e=this.hydrateCstLeafNode(t)),e&&(n.set(t,e),e.root=r)}return{astNodes:t,cstNodes:n}}hydrateAstNode(e,t){let n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode&&(n.$cstNode=t.cstNodes.get(e.$cstNode));for(let[r,i]of Object.entries(e))if(!r.startsWith(`$`))if(Array.isArray(i)){let e=[];n[r]=e;for(let a of i)H(a)?e.push(this.setParent(this.hydrateAstNode(a,t),n)):wn(a)?e.push(this.hydrateReference(a,n,r,t)):e.push(a)}else H(i)?n[r]=this.setParent(this.hydrateAstNode(i,t),n):wn(i)?n[r]=this.hydrateReference(i,n,r,t):i!==void 0&&(n[r]=i);return n}setParent(e,t){return e.$container=t,e}hydrateReference(e,t,n,r){return this.linker.buildReference(t,n,r.cstNodes.get(e.$refNode),e.$refText)}hydrateCstNode(e,t,n=0){let r=t.cstNodes.get(e);if(typeof e.grammarSource==`number`&&(r.grammarSource=this.getGrammarElement(e.grammarSource)),r.astNode=t.astNodes.get(e.astNode),On(r))for(let i of e.content){let e=this.hydrateCstNode(i,t,n++);r.content.push(e)}return r}hydrateCstLeafNode(e){let t=this.getTokenType(e.tokenType),n=e.offset,r=e.length,i=e.startLine,a=e.startColumn,o=e.endLine,s=e.endColumn,c=e.hidden;return new ao(n,r,{start:{line:i,character:a},end:{line:o,character:s}},t,c)}getTokenType(e){return this.lexer.definition[e]}getGrammarElementId(e){if(e)return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.get(e)}getGrammarElement(e){return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.getKey(e)}createGrammarElementIdMap(){let e=0;for(let t of Fi(this.grammar))Ln(t)&&this.grammarElementIdMap.set(t,e++)}},hc;(function(e){function t(e){return{dispose:async()=>await e()}}e.create=t})(hc||={});var gc=class{readFile(){throw Error(`No file system is available.`)}async readDirectory(){return[]}};const _c={fileSystemProvider:()=>new gc},vc={Grammar:()=>void 0,LanguageMetaData:()=>({caseInsensitive:!1,fileExtensions:[`.langium`],languageId:`langium`})},yc={AstReflection:()=>new ti};function bc(){let e=ws(zc(_c),yc),t=ws(Rc({shared:e}),vc);return e.ServiceRegistry.register(t),t}function xc(e){let t=bc(),n=t.serializer.JsonSerializer.deserialize(e);return t.shared.workspace.LangiumDocumentFactory.fromModel(n,Y.parse(`memory://${n.name??`grammar`}.langium`)),n}var Sc=class{constructor(e){this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider}createDescription(e,t,n){let r=n??q(e);t??=this.nameProvider.getName(e);let i=this.astNodeLocator.getAstNodePath(e);if(!t)throw Error(`Node at path ${i} has no name.`);let a,o=()=>a??=fi(this.nameProvider.getNameNode(e)??e.$cstNode);return{node:e,name:t,get nameSegment(){return o()},selectionSegment:fi(e.$cstNode),type:e.$type,documentUri:r.uri,path:i}}},Cc=class{constructor(e){this.nodeLocator=e.workspace.AstNodeLocator}async createDescriptions(e,t=Z.CancellationToken.None){let n=[],r=e.parseResult.value;for(let e of Fi(r))await Q(t),Li(e).filter(e=>!En(e)).forEach(e=>{let t=this.createDescription(e);t&&n.push(t)});return n}createDescription(e){let t=e.reference.$nodeDescription,n=e.reference.$refNode;if(!t||!n)return;let r=q(e.container).uri;return{sourceUri:r,sourcePath:this.nodeLocator.getAstNodePath(e.container),targetUri:t.documentUri,targetPath:t.path,segment:fi(n),local:X.equals(t.documentUri,r)}}},wc=class{constructor(){this.segmentSeparator=`/`,this.indexSeparator=`@`}getAstNodePath(e){if(e.$container){let t=this.getAstNodePath(e.$container),n=this.getPathSegment(e);return t+this.segmentSeparator+n}return``}getPathSegment({$containerProperty:e,$containerIndex:t}){if(!e)throw Error(`Missing '$containerProperty' in AST node.`);return t===void 0?e:e+this.indexSeparator+t}getAstNode(e,t){return t.split(this.segmentSeparator).reduce((e,t)=>{if(!e||t.length===0)return e;let n=t.indexOf(this.indexSeparator);if(n>0){let r=t.substring(0,n),i=parseInt(t.substring(n+1));return e[r]?.[i]}return e[t]},e)}},Tc=class{constructor(e){this._ready=new Jo,this.settings={},this.workspaceConfig=!1,this.onConfigurationSectionUpdateEmitter=new oc.Emitter,this.serviceRegistry=e.ServiceRegistry}get ready(){return this._ready.promise}initialize(e){this.workspaceConfig=e.capabilities.workspace?.configuration??!1}async initialized(e){if(this.workspaceConfig){if(e.register){let t=this.serviceRegistry.all;e.register({section:t.map(e=>this.toSectionName(e.LanguageMetaData.languageId))})}if(e.fetchConfiguration){let t=this.serviceRegistry.all.map(e=>({section:this.toSectionName(e.LanguageMetaData.languageId)})),n=await e.fetchConfiguration(t);t.forEach((e,t)=>{this.updateSectionConfiguration(e.section,n[t])})}}this._ready.resolve()}updateConfiguration(e){e.settings&&Object.keys(e.settings).forEach(t=>{let n=e.settings[t];this.updateSectionConfiguration(t,n),this.onConfigurationSectionUpdateEmitter.fire({section:t,configuration:n})})}updateSectionConfiguration(e,t){this.settings[e]=t}async getConfiguration(e,t){await this.ready;let n=this.toSectionName(e);if(this.settings[n])return this.settings[n][t]}toSectionName(e){return`${e}`}get onConfigurationSectionUpdate(){return this.onConfigurationSectionUpdateEmitter.event}},Ec=class{constructor(e){this.updateBuildOptions={validation:{categories:[`built-in`,`fast`]}},this.updateListeners=[],this.buildPhaseListeners=new cs,this.documentPhaseListeners=new cs,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=$.Changed,this.langiumDocuments=e.workspace.LangiumDocuments,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.textDocuments=e.workspace.TextDocuments,this.indexManager=e.workspace.IndexManager,this.serviceRegistry=e.ServiceRegistry}async build(e,t={},n=Z.CancellationToken.None){for(let n of e){let e=n.uri.toString();if(n.state===$.Validated){if(typeof t.validation==`boolean`&&t.validation)n.state=$.IndexedReferences,n.diagnostics=void 0,this.buildState.delete(e);else if(typeof t.validation==`object`){let r=this.buildState.get(e),i=r?.result?.validationChecks;if(i){let a=(t.validation.categories??jc.all).filter(e=>!i.includes(e));a.length>0&&(this.buildState.set(e,{completed:!1,options:{validation:Object.assign(Object.assign({},t.validation),{categories:a})},result:r.result}),n.state=$.IndexedReferences)}}}else this.buildState.delete(e)}this.currentState=$.Changed,await this.emitUpdate(e.map(e=>e.uri),[]),await this.buildDocuments(e,t,n)}async update(e,t,n=Z.CancellationToken.None){this.currentState=$.Changed;for(let e of t)this.langiumDocuments.deleteDocument(e),this.buildState.delete(e.toString()),this.indexManager.remove(e);for(let t of e){if(!this.langiumDocuments.invalidateDocument(t)){let e=this.langiumDocumentFactory.fromModel({$type:`INVALID`},t);e.state=$.Changed,this.langiumDocuments.addDocument(e)}this.buildState.delete(t.toString())}let r=K(e).concat(t).map(e=>e.toString()).toSet();this.langiumDocuments.all.filter(e=>!r.has(e.uri.toString())&&this.shouldRelink(e,r)).forEach(e=>{this.serviceRegistry.getServices(e.uri).references.Linker.unlink(e),e.state=Math.min(e.state,$.ComputedScopes),e.diagnostics=void 0}),await this.emitUpdate(e,t),await Q(n);let i=this.sortDocuments(this.langiumDocuments.all.filter(e=>e.state<$.Linked||!this.buildState.get(e.uri.toString())?.completed).toArray());await this.buildDocuments(i,this.updateBuildOptions,n)}async emitUpdate(e,t){await Promise.all(this.updateListeners.map(n=>n(e,t)))}sortDocuments(e){let t=0,n=e.length-1;for(;t<n;){for(;t<e.length&&this.hasTextDocument(e[t]);)t++;for(;n>=0&&!this.hasTextDocument(e[n]);)n--;t<n&&([e[t],e[n]]=[e[n],e[t]])}return e}hasTextDocument(e){return!!this.textDocuments?.get(e.uri)}shouldRelink(e,t){return e.references.some(e=>e.error!==void 0)?!0:this.indexManager.isAffected(e,t)}onUpdate(e){return this.updateListeners.push(e),hc.create(()=>{let t=this.updateListeners.indexOf(e);t>=0&&this.updateListeners.splice(t,1)})}async buildDocuments(e,t,n){this.prepareBuild(e,t),await this.runCancelable(e,$.Parsed,n,e=>this.langiumDocumentFactory.update(e,n)),await this.runCancelable(e,$.IndexedContent,n,e=>this.indexManager.updateContent(e,n)),await this.runCancelable(e,$.ComputedScopes,n,async e=>{e.precomputedScopes=await this.serviceRegistry.getServices(e.uri).references.ScopeComputation.computeLocalScopes(e,n)});let r=e.filter(e=>this.shouldLink(e));await this.runCancelable(r,$.Linked,n,e=>this.serviceRegistry.getServices(e.uri).references.Linker.link(e,n)),await this.runCancelable(r,$.IndexedReferences,n,e=>this.indexManager.updateReferences(e,n));let i=e.filter(e=>this.shouldValidate(e));await this.runCancelable(i,$.Validated,n,e=>this.validate(e,n));for(let t of e){let e=this.buildState.get(t.uri.toString());e&&(e.completed=!0)}}prepareBuild(e,t){for(let n of e){let e=n.uri.toString(),r=this.buildState.get(e);(!r||r.completed)&&this.buildState.set(e,{completed:!1,options:t,result:r?.result})}}async runCancelable(e,t,n,r){let i=e.filter(e=>e.state<t);for(let e of i)await Q(n),await r(e),e.state=t,await this.notifyDocumentPhase(e,t,n);let a=e.filter(e=>e.state===t);await this.notifyBuildPhase(a,t,n),this.currentState=t}onBuildPhase(e,t){return this.buildPhaseListeners.add(e,t),hc.create(()=>{this.buildPhaseListeners.delete(e,t)})}onDocumentPhase(e,t){return this.documentPhaseListeners.add(e,t),hc.create(()=>{this.documentPhaseListeners.delete(e,t)})}waitUntil(e,t,n){let r;if(t&&`path`in t?r=t:n=t,n??=Z.CancellationToken.None,r){let t=this.langiumDocuments.getDocument(r);if(t&&t.state>=e)return Promise.resolve(r)}return this.currentState>=e?Promise.resolve(void 0):n.isCancellationRequested?Promise.reject(Ko):new Promise((t,i)=>{let a=this.onBuildPhase(e,()=>{a.dispose(),o.dispose(),t(r?this.langiumDocuments.getDocument(r)?.uri:void 0)}),o=n.onCancellationRequested(()=>{a.dispose(),o.dispose(),i(Ko)})})}async notifyDocumentPhase(e,t,n){let r=this.documentPhaseListeners.get(t).slice();for(let t of r)try{await t(e,n)}catch(e){if(!qo(e))throw e}}async notifyBuildPhase(e,t,n){if(e.length===0)return;let r=this.buildPhaseListeners.get(t).slice();for(let t of r)await Q(n),await t(e,n)}shouldLink(e){return this.getBuildOptions(e).eagerLinking??!0}shouldValidate(e){return!!this.getBuildOptions(e).validation}async validate(e,t){let n=this.serviceRegistry.getServices(e.uri).validation.DocumentValidator,r=this.getBuildOptions(e).validation,i=typeof r==`object`?r:void 0,a=await n.validateDocument(e,i,t);e.diagnostics?e.diagnostics.push(...a):e.diagnostics=a;let o=this.buildState.get(e.uri.toString());if(o){o.result??={};let e=i?.categories??jc.all;o.result.validationChecks?o.result.validationChecks.push(...e):o.result.validationChecks=[...e]}}getBuildOptions(e){return this.buildState.get(e.uri.toString())?.options??{}}},Dc=class{constructor(e){this.symbolIndex=new Map,this.symbolByTypeIndex=new gs,this.referenceIndex=new Map,this.documents=e.workspace.LangiumDocuments,this.serviceRegistry=e.ServiceRegistry,this.astReflection=e.AstReflection}findAllReferences(e,t){let n=q(e).uri,r=[];return this.referenceIndex.forEach(e=>{e.forEach(e=>{X.equals(e.targetUri,n)&&e.targetPath===t&&r.push(e)})}),K(r)}allElements(e,t){let n=K(this.symbolIndex.keys());return t&&(n=n.filter(e=>!t||t.has(e))),n.map(t=>this.getFileDescriptions(t,e)).flat()}getFileDescriptions(e,t){return t?this.symbolByTypeIndex.get(e,t,()=>(this.symbolIndex.get(e)??[]).filter(e=>this.astReflection.isSubtype(e.type,t))):this.symbolIndex.get(e)??[]}remove(e){let t=e.toString();this.symbolIndex.delete(t),this.symbolByTypeIndex.clear(t),this.referenceIndex.delete(t)}async updateContent(e,t=Z.CancellationToken.None){let n=await this.serviceRegistry.getServices(e.uri).references.ScopeComputation.computeExports(e,t),r=e.uri.toString();this.symbolIndex.set(r,n),this.symbolByTypeIndex.clear(r)}async updateReferences(e,t=Z.CancellationToken.None){let n=await this.serviceRegistry.getServices(e.uri).workspace.ReferenceDescriptionProvider.createDescriptions(e,t);this.referenceIndex.set(e.uri.toString(),n)}isAffected(e,t){let n=this.referenceIndex.get(e.uri.toString());return n?n.some(e=>!e.local&&t.has(e.targetUri.toString())):!1}},Oc=class{constructor(){this.previousTokenSource=new Z.CancellationTokenSource,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();let t=Go();return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,n=Z.CancellationToken.None){let r=new Jo,i={action:t,deferred:r,cancellationToken:n};return e.push(i),this.performNextOperation(),r.promise}async performNextOperation(){if(!this.done)return;let e=[];if(this.writeQueue.length>0)e.push(this.writeQueue.shift());else if(this.readQueue.length>0)e.push(...this.readQueue.splice(0,this.readQueue.length));else return;this.done=!1,await Promise.all(e.map(async({action:e,deferred:t,cancellationToken:n})=>{try{let r=await Promise.resolve().then(()=>e(n));t.resolve(r)}catch(e){qo(e)?t.resolve(void 0):t.reject(e)}})),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}},kc=class{constructor(e){this.initialBuildOptions={},this._ready=new Jo,this.serviceRegistry=e.ServiceRegistry,this.langiumDocuments=e.workspace.LangiumDocuments,this.documentBuilder=e.workspace.DocumentBuilder,this.fileSystemProvider=e.workspace.FileSystemProvider,this.mutex=e.workspace.WorkspaceLock}get ready(){return this._ready.promise}get workspaceFolders(){return this.folders}initialize(e){this.folders=e.workspaceFolders??void 0}initialized(e){return this.mutex.write(e=>this.initializeWorkspace(this.folders??[],e))}async initializeWorkspace(e,t=Z.CancellationToken.None){let n=await this.performStartup(e);await Q(t),await this.documentBuilder.build(n,this.initialBuildOptions,t)}async performStartup(e){let t=this.serviceRegistry.all.flatMap(e=>e.LanguageMetaData.fileExtensions),n=this.serviceRegistry.all.flatMap(e=>e.LanguageMetaData.fileNames??[]),r=[],i=e=>{r.push(e),this.langiumDocuments.hasDocument(e.uri)||this.langiumDocuments.addDocument(e)};return await this.loadAdditionalDocuments(e,i),await Promise.all(e.map(e=>[e,this.getRootFolder(e)]).map(async e=>this.traverseFolder(...e,{fileExtensions:t,fileNames:n},i))),this._ready.resolve(),r}loadAdditionalDocuments(e,t){return Promise.resolve()}getRootFolder(e){return Y.parse(e.uri)}async traverseFolder(e,t,n,r){let i=await this.fileSystemProvider.readDirectory(t);await Promise.all(i.map(async t=>{this.includeEntry(e,t,n)&&(t.isDirectory?await this.traverseFolder(e,t.uri,n,r):t.isFile&&r(await this.langiumDocuments.getOrCreateDocument(t.uri)))}))}includeEntry(e,t,n){let r=X.basename(t.uri);return r.startsWith(`.`)?!1:t.isDirectory?r!==`node_modules`&&r!==`out`:t.isFile?n.fileExtensions.includes(X.extname(t.uri))||n.fileNames.includes(X.basename(t.uri)):!1}};function Ac(e){return{code:e}}var jc;(function(e){e.all=[`fast`,`slow`,`built-in`]})(jc||={});var Mc=class{constructor(e){this.entries=new cs,this.entriesBefore=[],this.entriesAfter=[],this.reflection=e.shared.AstReflection}register(e,t=this,n=`fast`){if(n===`built-in`)throw Error(`The 'built-in' category is reserved for lexer, parser, and linker errors.`);for(let[r,i]of Object.entries(e)){let e=i;if(Array.isArray(e))for(let i of e){let e={check:this.wrapValidationException(i,t),category:n};this.addEntry(r,e)}else if(typeof e==`function`){let i={check:this.wrapValidationException(e,t),category:n};this.addEntry(r,i)}else Ui(e)}}wrapValidationException(e,t){return async(n,r,i)=>{await this.handleException(()=>e.call(t,n,r,i),`An error occurred during validation`,r,n)}}async handleException(e,t,n,r){try{await e()}catch(e){if(qo(e))throw e;console.error(`${t}:`,e),e instanceof Error&&e.stack&&console.error(e.stack),n(`error`,`${t}: ${e instanceof Error?e.message:String(e)}`,{node:r})}}addEntry(e,t){if(e===`AstNode`){this.entries.add(`AstNode`,t);return}for(let n of this.reflection.getAllSubTypes(e))this.entries.add(n,t)}getChecks(e,t){let n=K(this.entries.get(e)).concat(this.entries.get(`AstNode`));return t&&(n=n.filter(e=>t.includes(e.category))),n.map(e=>e.check)}registerBeforeDocument(e,t=this){this.entriesBefore.push(this.wrapPreparationException(e,`An error occurred during set-up of the validation`,t))}registerAfterDocument(e,t=this){this.entriesAfter.push(this.wrapPreparationException(e,`An error occurred during tear-down of the validation`,t))}wrapPreparationException(e,t,n){return async(r,i,a,o)=>{await this.handleException(()=>e.call(n,r,i,a,o),t,i,r)}}get checksBefore(){return this.entriesBefore}get checksAfter(){return this.entriesAfter}},Nc=class{constructor(e){this.validationRegistry=e.validation.ValidationRegistry,this.metadata=e.LanguageMetaData}async validateDocument(e,t={},n=Z.CancellationToken.None){let r=e.parseResult,i=[];if(await Q(n),(!t.categories||t.categories.includes(`built-in`))&&(this.processLexingErrors(r,i,t),t.stopAfterLexingErrors&&i.some(e=>e.data?.code===Lc.LexingError)||(this.processParsingErrors(r,i,t),t.stopAfterParsingErrors&&i.some(e=>e.data?.code===Lc.ParsingError))||(this.processLinkingErrors(e,i,t),t.stopAfterLinkingErrors&&i.some(e=>e.data?.code===Lc.LinkingError))))return i;try{i.push(...await this.validateAst(r.value,t,n))}catch(e){if(qo(e))throw e;console.error(`An error occurred during validation:`,e)}return await Q(n),i}processLexingErrors(e,t,n){let r=[...e.lexerErrors,...e.lexerReport?.diagnostics??[]];for(let e of r){let n=e.severity??`error`,r={severity:Fc(n),range:{start:{line:e.line-1,character:e.column-1},end:{line:e.line-1,character:e.column+e.length-1}},message:e.message,data:Ic(n),source:this.getSource()};t.push(r)}}processParsingErrors(e,t,n){for(let n of e.parserErrors){let e;if(isNaN(n.token.startOffset)){if(`previousToken`in n){let t=n.previousToken;if(isNaN(t.startOffset)){let t={line:0,character:0};e={start:t,end:t}}else{let n={line:t.endLine-1,character:t.endColumn};e={start:n,end:n}}}}else e=di(n.token);if(e){let r={severity:Fc(`error`),range:e,message:n.message,data:Ac(Lc.ParsingError),source:this.getSource()};t.push(r)}}}processLinkingErrors(e,t,n){for(let n of e.references){let e=n.error;if(e){let n={node:e.container,property:e.property,index:e.index,data:{code:Lc.LinkingError,containerType:e.container.$type,property:e.property,refText:e.reference.$refText}};t.push(this.toDiagnostic(`error`,e.message,n))}}}async validateAst(e,t,n=Z.CancellationToken.None){let r=[],i=(e,t,n)=>{r.push(this.toDiagnostic(e,t,n))};return await this.validateAstBefore(e,t,i,n),await this.validateAstNodes(e,t,i,n),await this.validateAstAfter(e,t,i,n),r}async validateAstBefore(e,t,n,r=Z.CancellationToken.None){let i=this.validationRegistry.checksBefore;for(let a of i)await Q(r),await a(e,n,t.categories??[],r)}async validateAstNodes(e,t,n,r=Z.CancellationToken.None){await Promise.all(Fi(e).map(async e=>{await Q(r);let i=this.validationRegistry.getChecks(e.$type,t.categories);for(let t of i)await t(e,n,r)}))}async validateAstAfter(e,t,n,r=Z.CancellationToken.None){let i=this.validationRegistry.checksAfter;for(let a of i)await Q(r),await a(e,n,t.categories??[],r)}toDiagnostic(e,t,n){return{message:t,range:Pc(n),severity:Fc(e),code:n.code,codeDescription:n.codeDescription,tags:n.tags,relatedInformation:n.relatedInformation,data:n.data,source:this.getSource()}}getSource(){return this.metadata.languageId}};function Pc(e){if(e.range)return e.range;let t;return typeof e.property==`string`?t=ca(e.node.$cstNode,e.property,e.index):typeof e.keyword==`string`&&(t=da(e.node.$cstNode,e.keyword,e.index)),t??=e.node.$cstNode,t?t.range:{start:{line:0,character:0},end:{line:0,character:0}}}function Fc(e){switch(e){case`error`:return 1;case`warning`:return 2;case`info`:return 3;case`hint`:return 4;default:throw Error(`Invalid diagnostic severity: `+e)}}function Ic(e){switch(e){case`error`:return Ac(Lc.LexingError);case`warning`:return Ac(Lc.LexingWarning);case`info`:return Ac(Lc.LexingInfo);case`hint`:return Ac(Lc.LexingHint);default:throw Error(`Invalid diagnostic severity: `+e)}}var Lc;(function(e){e.LexingError=`lexing-error`,e.LexingWarning=`lexing-warning`,e.LexingInfo=`lexing-info`,e.LexingHint=`lexing-hint`,e.ParsingError=`parsing-error`,e.LinkingError=`linking-error`})(Lc||={});function Rc(e){return{documentation:{CommentProvider:e=>new js(e),DocumentationProvider:e=>new ac(e)},parser:{AsyncParser:e=>new sc(e),GrammarConfig:e=>no(e),LangiumParser:e=>Ro(e),CompletionParser:e=>Lo(e),ValueConverter:()=>new Vo,TokenBuilder:()=>new Bo,Lexer:e=>new uc(e),ParserErrorMessageProvider:()=>new go,LexerErrorMessageProvider:()=>new cc},workspace:{AstNodeLocator:()=>new wc,AstNodeDescriptionProvider:e=>new Sc(e),ReferenceDescriptionProvider:e=>new Cc(e)},references:{Linker:e=>new is(e),NameProvider:()=>new os,ScopeProvider:e=>new vs(e),ScopeComputation:e=>new us(e),References:e=>new ss(e)},serializer:{Hydrator:e=>new mc(e),JsonSerializer:e=>new xs(e)},validation:{DocumentValidator:e=>new Nc(e),ValidationRegistry:e=>new Mc(e)},shared:()=>e.shared}}function zc(e){return{ServiceRegistry:e=>new Ss(e),workspace:{LangiumDocuments:e=>new ns(e),LangiumDocumentFactory:e=>new ts(e),DocumentBuilder:e=>new Ec(e),IndexManager:e=>new Dc(e),WorkspaceManager:e=>new kc(e),FileSystemProvider:t=>e.fileSystemProvider(t),WorkspaceLock:()=>new Oc,ConfigurationProvider:e=>new Tc(e)}}}var Bc=class{constructor(e){this.references=e.references.References,this.nameProvider=e.references.NameProvider,this.grammarConfig=e.parser.GrammarConfig}getDocumentHighlight(e,t,n){let r=e.parseResult.value.$cstNode;if(!r)return;let i=_i(r,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);if(!i)return;let a=this.references.findDeclaration(i);if(a){let t=X.equals(q(a).uri,e.uri),n={documentUri:e.uri,includeDeclaration:t};return this.references.findReferences(a,n).map(e=>this.createDocumentHighlight(e)).toArray()}}createDocumentHighlight(e){return J.DocumentHighlight.create(e.segment.range)}},Vc=class{constructor(e){this.nameProvider=e.references.NameProvider,this.nodeKindProvider=e.shared.lsp.NodeKindProvider}getSymbols(e,t,n){return this.getSymbol(e,e.parseResult.value)}getSymbol(e,t){let n=t.$cstNode,r=this.nameProvider.getNameNode(t);if(r&&n){let i=this.nameProvider.getName(t);return[{kind:this.nodeKindProvider.getSymbolKind(t),name:i||r.text,range:n.range,selectionRange:r.range,children:this.getChildSymbols(e,t)}]}else return this.getChildSymbols(e,t)||[]}getChildSymbols(e,t){let n=[];for(let r of Ni(t)){let t=this.getSymbol(e,r);n.push(...t)}if(n.length>0)return n}},Hc=class{constructor(e){this.workspaceManager=e.workspace.WorkspaceManager,this.documentBuilder=e.workspace.DocumentBuilder,this.workspaceLock=e.workspace.WorkspaceLock,this.serviceRegistry=e.ServiceRegistry;let t=!1;e.lsp.LanguageServer.onInitialize(e=>{t=!!e.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration}),e.lsp.LanguageServer.onInitialized(n=>{t&&this.registerFileWatcher(e)})}registerFileWatcher(e){let t=[],n=K(e.ServiceRegistry.all).flatMap(e=>e.LanguageMetaData.fileExtensions).map(e=>e.startsWith(`.`)?e.substring(1):e).distinct().toArray();n.length>0&&t.push({globPattern:n.length===1?`**/*.${n[0]}`:`**/*.{${n.join(`,`)}}`});let r=K(e.ServiceRegistry.all).flatMap(e=>e.LanguageMetaData.fileNames??[]).distinct().toArray();if(r.length>0&&t.push({globPattern:r.length===1?`**/${r[0]}`:`**/{${r.join(`,`)}}`}),t.length>0){let n=e.lsp.Connection,r={watchers:t};n?.client.register(J.DidChangeWatchedFilesNotification.type,r)}}fireDocumentUpdate(e,t){e=e.filter(e=>this.serviceRegistry.hasServices(e)),this.workspaceManager.ready.then(()=>{this.workspaceLock.write(n=>this.documentBuilder.update(e,t,n))}).catch(e=>{console.error(`Workspace initialization failed. Could not perform document update.`,e)})}didChangeContent(e){this.fireDocumentUpdate([Y.parse(e.document.uri)],[])}didChangeWatchedFiles(e){let t=K(e.changes).filter(e=>e.type!==J.FileChangeType.Deleted).distinct(e=>e.uri).map(e=>Y.parse(e.uri)).toArray(),n=K(e.changes).filter(e=>e.type===J.FileChangeType.Deleted).distinct(e=>e.uri).map(e=>Y.parse(e.uri)).toArray();this.fireDocumentUpdate(t,n)}},Uc=class{constructor(e){this.commentNames=e.parser.GrammarConfig.multilineCommentRules}getFoldingRanges(e,t,n){let r=[];return this.collectFolding(e,e=>r.push(e)),r}collectFolding(e,t){let n=e.parseResult?.value;if(n){if(this.shouldProcessContent(n)){let r=Pi(n).iterator(),i;do if(i=r.next(),!i.done){let n=i.value;this.shouldProcess(n)&&this.collectObjectFolding(e,n,t),this.shouldProcessContent(n)||r.prune()}while(!i.done)}this.collectCommentFolding(e,n,t)}}shouldProcess(e){return!0}shouldProcessContent(e){return!0}collectObjectFolding(e,t,n){let r=t.$cstNode;if(r){let t=this.toFoldingRange(e,r);t&&n(t)}}collectCommentFolding(e,t,n){let r=t.$cstNode;if(r){for(let t of li(r))if(this.commentNames.includes(t.tokenType.name)){let r=this.toFoldingRange(e,t,J.FoldingRangeKind.Comment);r&&n(r)}}}toFoldingRange(e,t,n){let r=t.range,i=r.start,a=r.end;if(!(a.line-i.line<2))return this.includeLastFoldingLine(t,n)||(a=e.textDocument.positionAt(e.textDocument.offsetAt({line:a.line,character:0})-1)),J.FoldingRange.create(i.line,a.line,i.character,a.character,n)}includeLastFoldingLine(e,t){if(t===J.FoldingRangeKind.Comment)return!1;let n=e.text,r=n.charAt(n.length-1);return!(r===`}`||r===`)`||r===`]`)}},Wc=class{match(e,t){if(e.length===0)return!0;let n=!1,r,i=0,a=t.length;for(let o=0;o<a;o++){let a=t.charCodeAt(o),s=e.charCodeAt(i);if((a===s||this.toUpperCharCode(a)===this.toUpperCharCode(s))&&(n||=r===void 0||this.isWordTransition(r,a),n&&i++,i===e.length))return!0;r=a}return!1}isWordTransition(e,t){return Gc<=e&&e<=Kc&&qc<=t&&t<=Jc||e===Yc&&t!==Yc}toUpperCharCode(e){return Gc<=e&&e<=Kc?e-32:e}};const Gc=97,Kc=122,qc=65,Jc=90,Yc=95;var Xc=class{constructor(e){this.references=e.references.References,this.grammarConfig=e.parser.GrammarConfig}getHoverContent(e,t){let n=e.parseResult?.value?.$cstNode;if(n){let r=e.textDocument.offsetAt(t.position),i=_i(n,r,this.grammarConfig.nameRegexp);if(i&&i.offset+i.length>r){let e=this.references.findDeclaration(i);if(e)return this.getAstNodeHoverContent(e);if(Ir(i.grammarSource))return this.getKeywordHoverContent(i.grammarSource)}}}getKeywordHoverContent(e){let t=ys(e)?e.$comment:void 0;if(t||=vi(e.$cstNode,[`ML_COMMENT`])?.text,t&&Ns(t)){let e=Ms(t).toMarkdown();if(e)return{contents:{kind:`markdown`,value:e}}}}},Zc=class extends Xc{constructor(e){super(e),this.documentationProvider=e.documentation.DocumentationProvider}getAstNodeHoverContent(e){let t=this.documentationProvider.getDocumentation(e);if(t)return{contents:{kind:`markdown`,value:t}}}};const Qc={[J.SemanticTokenTypes.class]:0,[J.SemanticTokenTypes.comment]:1,[J.SemanticTokenTypes.enum]:2,[J.SemanticTokenTypes.enumMember]:3,[J.SemanticTokenTypes.event]:4,[J.SemanticTokenTypes.function]:5,[J.SemanticTokenTypes.interface]:6,[J.SemanticTokenTypes.keyword]:7,[J.SemanticTokenTypes.macro]:8,[J.SemanticTokenTypes.method]:9,[J.SemanticTokenTypes.modifier]:10,[J.SemanticTokenTypes.namespace]:11,[J.SemanticTokenTypes.number]:12,[J.SemanticTokenTypes.operator]:13,[J.SemanticTokenTypes.parameter]:14,[J.SemanticTokenTypes.property]:15,[J.SemanticTokenTypes.regexp]:16,[J.SemanticTokenTypes.string]:17,[J.SemanticTokenTypes.struct]:18,[J.SemanticTokenTypes.type]:19,[J.SemanticTokenTypes.typeParameter]:20,[J.SemanticTokenTypes.variable]:21,[J.SemanticTokenTypes.decorator]:22},$c={[J.SemanticTokenModifiers.abstract]:1,[J.SemanticTokenModifiers.async]:2,[J.SemanticTokenModifiers.declaration]:4,[J.SemanticTokenModifiers.defaultLibrary]:8,[J.SemanticTokenModifiers.definition]:16,[J.SemanticTokenModifiers.deprecated]:32,[J.SemanticTokenModifiers.documentation]:64,[J.SemanticTokenModifiers.modification]:128,[J.SemanticTokenModifiers.readonly]:256,[J.SemanticTokenModifiers.static]:512};function el(e){let t=[],n=[],r=!0,i=!0,a=!0;for(let o of e)o&&(o.legend.tokenTypes.forEach((e,n)=>{let r=t[n];if(r&&r!==e)throw Error(`Cannot merge '${r}' and '${e}' token types. They use the same index ${n}.`);t[n]=e}),o.legend.tokenModifiers.forEach((e,t)=>{let r=n[t];if(r&&r!==e)throw Error(`Cannot merge '${r}' and '${e}' token modifier. They use the same index ${t}.`);n[t]=e}),o.full?typeof o.full==`object`&&!o.full.delta&&(i=!1):r=!1,o.range||(a=!1));return{legend:{tokenTypes:t,tokenModifiers:n},full:r&&{delta:i},range:a}}var tl=class extends J.SemanticTokensBuilder{constructor(){super(...arguments),this._tokens=[]}push(e,t,n,r,i){this._tokens.push({line:e,char:t,length:n,tokenType:r,tokenModifiers:i})}build(){return this.applyTokens(),super.build()}buildEdits(){return this.applyTokens(),super.buildEdits()}flush(){this.previousResult(this.id)}applyTokens(){for(let e of this._tokens.sort(this.compareTokens))super.push(e.line,e.char,e.length,e.tokenType,e.tokenModifiers);this._tokens=[]}compareTokens(e,t){return e.line===t.line?e.char-t.char:e.line-t.line}},nl=class{constructor(e){this.tokensBuilders=new Map,e.shared.workspace.TextDocuments.onDidClose(e=>{this.tokensBuilders.delete(e.document.uri)}),e.shared.lsp.LanguageServer.onInitialize(e=>{this.initialize(e.capabilities.textDocument?.semanticTokens)})}initialize(e){this.clientCapabilities=e}get tokenTypes(){return Qc}get tokenModifiers(){return $c}get semanticTokensOptions(){return{legend:{tokenTypes:Object.keys(this.tokenTypes),tokenModifiers:Object.keys(this.tokenModifiers)},full:{delta:!0},range:!0}}async semanticHighlight(e,t,n=Z.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.flush(),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.build()}async semanticHighlightRange(e,t,n=Z.CancellationToken.None){return this.currentRange=t.range,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.flush(),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.build()}async semanticHighlightDelta(e,t,n=Z.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.previousResult(t.previousResultId),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.buildEdits()}createAcceptor(){return e=>{`line`in e?this.highlightToken({range:{start:{line:e.line,character:e.char},end:{line:e.line,character:e.char+e.length}},type:e.type,modifier:e.modifier}):`range`in e?this.highlightToken(e):`keyword`in e?this.highlightKeyword(e):`property`in e?this.highlightProperty(e):this.highlightNode({node:e.cst,type:e.type,modifier:e.modifier})}}getDocumentTokensBuilder(e){let t=this.tokensBuilders.get(e.uri.toString());if(t)return t;let n=new tl;return this.tokensBuilders.set(e.uri.toString(),n),n}async computeHighlighting(e,t,n){let r=e.parseResult.value,i=Fi(r,{range:this.currentRange}).iterator(),a;do if(a=i.next(),!a.done){await Q(n);let e=a.value;this.highlightElement(e,t)===`prune`&&i.prune()}while(!a.done)}highlightToken(e){let{range:t,type:n}=e,r=e.modifier;if(this.currentRange&&!hi(t,this.currentRange)||!this.currentDocument||!this.currentTokensBuilder)return;let i=this.tokenTypes[n],a=0;if(r!==void 0){typeof r==`string`&&(r=[r]);for(let e of r){let t=this.tokenModifiers[e];a|=t}}let o=t.start.line,s=t.end.line;if(o===s){let e=t.start.character,n=t.end.character-e;this.currentTokensBuilder.push(o,e,n,i,a)}else if(this.clientCapabilities?.multilineTokenSupport){let e=t.start.character,n=this.currentDocument.textDocument.offsetAt(t.start),r=this.currentDocument.textDocument.offsetAt(t.end);this.currentTokensBuilder.push(o,e,r-n,i,a)}else{let e=t.start,n=this.currentDocument.textDocument.offsetAt({line:o+1,character:0});this.currentTokensBuilder.push(e.line,e.character,n-e.character-1,i,a);for(let e=o+1;e<s;e++){let t=n;n=this.currentDocument.textDocument.offsetAt({line:e+1,character:0}),this.currentTokensBuilder.push(e,0,n-t-1,i,a)}this.currentTokensBuilder.push(s,0,t.end.character,i,a)}}highlightProperty(e){let t=[];if(typeof e.index==`number`){let n=ca(e.node.$cstNode,e.property,e.index);n&&t.push(n)}else t.push(...sa(e.node.$cstNode,e.property));let{type:n,modifier:r}=e;for(let e of t)this.highlightNode({node:e,type:n,modifier:r})}highlightKeyword(e){let{node:t,keyword:n,type:r,index:i,modifier:a}=e,o=[];if(typeof i==`number`){let e=da(t.$cstNode,n,i);e&&o.push(e)}else o.push(...ua(t.$cstNode,n));for(let e of o)this.highlightNode({node:e,type:r,modifier:a})}highlightNode(e){let{node:t,type:n,modifier:r}=e,i=t.range;this.highlightToken({range:i,type:n,modifier:r})}},rl;(function(e){function t(e,t,r){let i=new Map;Object.entries(t).forEach(([e,t])=>i.set(t,e));let a=0,o=0;return n(e.data,5).map(e=>{a+=e[0],e[0]!==0&&(o=0),o+=e[1];let t=e[2];return{offset:r.textDocument.offsetAt({line:a,character:o}),tokenType:i.get(e[3]),tokenModifiers:e[4],text:r.textDocument.getText({start:{line:a,character:o},end:{line:a,character:o+t}})}})}e.decode=t;function n(e,t){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}})(rl||={});function il(e){let t=[],n=[];e.forEach(e=>{e?.triggerCharacters&&t.push(...e.triggerCharacters),e?.retriggerCharacters&&n.push(...e.retriggerCharacters)});let r={triggerCharacters:t.length>0?Array.from(new Set(t)).sort():void 0,retriggerCharacters:n.length>0?Array.from(new Set(n)).sort():void 0};return r.triggerCharacters?r:void 0}var al=V(),ol=class{constructor(e){this.onInitializeEmitter=new al.Emitter,this.onInitializedEmitter=new al.Emitter,this.services=e}get onInitialize(){return this.onInitializeEmitter.event}get onInitialized(){return this.onInitializedEmitter.event}async initialize(e){return this.eagerLoadServices(),this.fireInitializeOnDefaultServices(e),this.onInitializeEmitter.fire(e),this.onInitializeEmitter.dispose(),this.buildInitializeResult(e)}eagerLoadServices(){Es(this.services),this.services.ServiceRegistry.all.forEach(e=>Es(e))}hasService(e){return this.services.ServiceRegistry.all.some(t=>e(t)!==void 0)}buildInitializeResult(e){let t=this.services.lsp.DocumentUpdateHandler,n=this.services.lsp.FileOperationHandler?.fileOperationOptions,r=this.services.ServiceRegistry.all,i=this.hasService(e=>e.lsp?.Formatter),a=r.map(e=>e.lsp?.Formatter?.formatOnTypeOptions).find(e=>!!e),o=this.hasService(e=>e.lsp?.CodeActionProvider),s=this.hasService(e=>e.lsp?.SemanticTokenProvider),c=el(r.map(e=>e.lsp?.SemanticTokenProvider?.semanticTokensOptions)),l=this.services.lsp?.ExecuteCommandHandler?.commands,u=this.hasService(e=>e.lsp?.DocumentLinkProvider),d=il(r.map(e=>e.lsp?.SignatureHelp?.signatureHelpOptions)),f=this.hasService(e=>e.lsp?.TypeProvider),p=this.hasService(e=>e.lsp?.ImplementationProvider),m=this.hasService(e=>e.lsp?.CompletionProvider),h=Za(r.map(e=>e.lsp?.CompletionProvider?.completionOptions)),g=this.hasService(e=>e.lsp?.ReferencesProvider),_=this.hasService(e=>e.lsp?.DocumentSymbolProvider),v=this.hasService(e=>e.lsp?.DefinitionProvider),y=this.hasService(e=>e.lsp?.DocumentHighlightProvider),b=this.hasService(e=>e.lsp?.FoldingRangeProvider),x=this.hasService(e=>e.lsp?.HoverProvider),S=this.hasService(e=>e.lsp?.RenameProvider),C=this.hasService(e=>e.lsp?.CallHierarchyProvider),w=this.hasService(e=>e.lsp?.TypeHierarchyProvider),ee=this.hasService(e=>e.lsp?.CodeLensProvider),T=this.hasService(e=>e.lsp?.DeclarationProvider),E=this.hasService(e=>e.lsp?.InlayHintProvider),D=this.services.lsp?.WorkspaceSymbolProvider;return{capabilities:{workspace:{workspaceFolders:{supported:!0},fileOperations:n},executeCommandProvider:l&&{commands:l},textDocumentSync:{change:al.TextDocumentSyncKind.Incremental,openClose:!0,save:!!t.didSaveDocument,willSave:!!t.willSaveDocument,willSaveWaitUntil:!!t.willSaveDocumentWaitUntil},completionProvider:m?h:void 0,referencesProvider:g,documentSymbolProvider:_,definitionProvider:v,typeDefinitionProvider:f,documentHighlightProvider:y,codeActionProvider:o,documentFormattingProvider:i,documentRangeFormattingProvider:i,documentOnTypeFormattingProvider:a,foldingRangeProvider:b,hoverProvider:x,renameProvider:S?{prepareProvider:!0}:void 0,semanticTokensProvider:s?c:void 0,signatureHelpProvider:d,implementationProvider:p,callHierarchyProvider:C?{}:void 0,typeHierarchyProvider:w?{}:void 0,documentLinkProvider:u?{resolveProvider:!1}:void 0,codeLensProvider:ee?{resolveProvider:!1}:void 0,declarationProvider:T,inlayHintProvider:E?{resolveProvider:!1}:void 0,workspaceSymbolProvider:D?{resolveProvider:!!D.resolveSymbol}:void 0}}}initialized(e){this.fireInitializedOnDefaultServices(e),this.onInitializedEmitter.fire(e),this.onInitializedEmitter.dispose()}fireInitializeOnDefaultServices(e){this.services.workspace.ConfigurationProvider.initialize(e),this.services.workspace.WorkspaceManager.initialize(e)}fireInitializedOnDefaultServices(e){let t=this.services.lsp.Connection,n=t?Object.assign(Object.assign({},e),{register:e=>t.client.register(al.DidChangeConfigurationNotification.type,e),fetchConfiguration:e=>t.workspace.getConfiguration(e)}):e;this.services.workspace.ConfigurationProvider.initialized(n).catch(e=>console.error(`Error in ConfigurationProvider initialization:`,e)),this.services.workspace.WorkspaceManager.initialized(e).catch(e=>console.error(`Error in WorkspaceManager initialization:`,e))}},sl=class{getSymbolKind(e){return J.SymbolKind.Field}getCompletionItemKind(e){return J.CompletionItemKind.Reference}},cl=class{constructor(e){this.nameProvider=e.references.NameProvider,this.references=e.references.References,this.grammarConfig=e.parser.GrammarConfig}findReferences(e,t,n){let r=e.parseResult.value.$cstNode;if(!r)return[];let i=_i(r,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);return i?this.getReferences(i,t,e):[]}getReferences(e,t,n){let r=[],i=this.references.findDeclaration(e);if(i){let e={includeDeclaration:t.context.includeDeclaration};this.references.findReferences(i,e).forEach(e=>{r.push(J.Location.create(e.sourceUri.toString(),e.segment.range))})}return r}};Ot();var ll=class{constructor(e){this.references=e.references.References,this.nameProvider=e.references.NameProvider,this.grammarConfig=e.parser.GrammarConfig}async rename(e,t,n){let r={},i=e.parseResult.value.$cstNode;if(!i)return;let a=_i(i,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);if(!a)return;let o=this.references.findDeclaration(a);if(o)return this.references.findReferences(o,{onlyLocal:!1,includeDeclaration:!0}).forEach(e=>{let n=L.replace(e.segment.range,t.newName),i=e.sourceUri.toString();r[i]?r[i].push(n):r[i]=[n]}),{changes:r}}prepareRename(e,t,n){return this.renameNodeRange(e,t.position)}renameNodeRange(e,t){let n=e.parseResult.value.$cstNode,r=e.textDocument.offsetAt(t);if(n&&r){let e=_i(n,r,this.grammarConfig.nameRegexp);if(!e)return;if(this.references.findDeclaration(e)||this.isNameNode(e))return e.range}}isNameNode(e){return e?.astNode&&as(e.astNode)&&e===this.nameProvider.getNameNode(e.astNode)}},ul=class{constructor(e){this.indexManager=e.workspace.IndexManager,this.nodeKindProvider=e.lsp.NodeKindProvider,this.fuzzyMatcher=e.lsp.FuzzyMatcher}async getSymbols(e,t=Z.CancellationToken.None){let n=[],r=e.query.toLowerCase();for(let e of this.indexManager.allElements())if(await Q(t),this.fuzzyMatcher.match(r,e.name)){let t=this.getWorkspaceSymbol(e);t&&n.push(t)}return n}getWorkspaceSymbol(e){let t=e.nameSegment;if(t)return{kind:this.nodeKindProvider.getSymbolKind(e),name:e.name,location:{range:t.range,uri:e.documentUri.toString()}}}},dl=class{constructor(e){this._configuration=e,this._syncedDocuments=new Map,this._onDidChangeContent=new J.Emitter,this._onDidOpen=new J.Emitter,this._onDidClose=new J.Emitter,this._onDidSave=new J.Emitter,this._onWillSave=new J.Emitter}get onDidOpen(){return this._onDidOpen.event}get onDidChangeContent(){return this._onDidChangeContent.event}get onWillSave(){return this._onWillSave.event}onWillSaveWaitUntil(e){this._willSaveWaitUntil=e}get onDidSave(){return this._onDidSave.event}get onDidClose(){return this._onDidClose.event}get(e){return this._syncedDocuments.get(X.normalize(e))}set(e){let t=X.normalize(e.uri),n=!0;this._syncedDocuments.has(t)&&(n=!1),this._syncedDocuments.set(t,e);let r=Object.freeze({document:e});return this._onDidOpen.fire(r),this._onDidChangeContent.fire(r),n}delete(e){let t=X.normalize(typeof e==`object`&&`uri`in e?e.uri:e),n=this._syncedDocuments.get(t);n!==void 0&&(this._syncedDocuments.delete(t),this._onDidClose.fire(Object.freeze({document:n})))}all(){return Array.from(this._syncedDocuments.values())}keys(){return Array.from(this._syncedDocuments.keys())}listen(e){e.__textDocumentSync=J.TextDocumentSyncKind.Incremental;let t=[];return t.push(e.onDidOpenTextDocument(e=>{let t=e.textDocument,n=X.normalize(t.uri),r=this._configuration.create(n,t.languageId,t.version,t.text);this._syncedDocuments.set(n,r);let i=Object.freeze({document:r});this._onDidOpen.fire(i),this._onDidChangeContent.fire(i)})),t.push(e.onDidChangeTextDocument(e=>{let t=e.textDocument,n=e.contentChanges;if(n.length===0)return;let{version:r}=t;if(r==null)throw Error(`Received document change event for ${t.uri} without valid version identifier`);let i=X.normalize(t.uri),a=this._syncedDocuments.get(i);a!==void 0&&(a=this._configuration.update(a,n,r),this._syncedDocuments.set(i,a),this._onDidChangeContent.fire(Object.freeze({document:a})))})),t.push(e.onDidCloseTextDocument(e=>{let t=X.normalize(e.textDocument.uri),n=this._syncedDocuments.get(t);n!==void 0&&(this._syncedDocuments.delete(t),this._onDidClose.fire(Object.freeze({document:n})))})),t.push(e.onWillSaveTextDocument(e=>{let t=this._syncedDocuments.get(X.normalize(e.textDocument.uri));t!==void 0&&this._onWillSave.fire(Object.freeze({document:t,reason:e.reason}))})),t.push(e.onWillSaveTextDocumentWaitUntil((e,t)=>{let n=this._syncedDocuments.get(X.normalize(e.textDocument.uri));return n!==void 0&&this._willSaveWaitUntil?this._willSaveWaitUntil(Object.freeze({document:n,reason:e.reason}),t):[]})),t.push(e.onDidSaveTextDocument(e=>{let t=this._syncedDocuments.get(X.normalize(e.textDocument.uri));t!==void 0&&this._onDidSave.fire(Object.freeze({document:t}))})),J.Disposable.create(()=>{t.forEach(e=>e.dispose())})}},fl=class{constructor(e){this.notebookDocuments=new Map,this.notebookCellMap=new Map,this._onDidOpen=new J.Emitter,this._onDidSave=new J.Emitter,this._onDidChange=new J.Emitter,this._onDidClose=new J.Emitter,`listen`in e?this._cellTextDocuments=e:this._cellTextDocuments=new dl(e)}get cellTextDocuments(){return this._cellTextDocuments}getCellTextDocument(e){return this._cellTextDocuments.get(e.document)}getNotebookDocument(e){return this.notebookDocuments.get(X.normalize(e))}getNotebookCell(e){let t=this.notebookCellMap.get(X.normalize(e));return t&&t[0]}findNotebookDocumentForCell(e){let t=typeof e==`string`||`scheme`in e?e:e.document,n=this.notebookCellMap.get(X.normalize(t));return n&&n[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(e){let t=new pl,n=[];return n.push(this.cellTextDocuments.listen(t)),n.push(e.notebooks.synchronization.onDidOpenNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri);this.notebookDocuments.set(n,e.notebookDocument);for(let n of e.cellTextDocuments)t.openTextDocument({textDocument:n});this.updateCellMap(e.notebookDocument),this._onDidOpen.fire(e.notebookDocument)})),n.push(e.notebooks.synchronization.onDidChangeNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri),r=this.notebookDocuments.get(n);if(r===void 0)return;r.version=e.notebookDocument.version;let i=r.metadata,a=!1,o=e.change;o.metadata!==void 0&&(a=!0,r.metadata=o.metadata);let s=[],c=[],l=[],u=[];if(o.cells!==void 0){let e=o.cells;if(e.structure!==void 0){let n=e.structure.array;if(r.cells.splice(n.start,n.deleteCount,...n.cells===void 0?[]:n.cells),e.structure.didOpen!==void 0)for(let n of e.structure.didOpen)t.openTextDocument({textDocument:n}),s.push(n.uri);if(e.structure.didClose)for(let n of e.structure.didClose)t.closeTextDocument({textDocument:n}),c.push(n.uri)}if(e.data!==void 0){let t=new Map(e.data.map(e=>[e.document,e]));for(let e=0;e<=r.cells.length;e++){let n=t.get(r.cells[e].document);if(n!==void 0){let i=r.cells.splice(e,1,n);if(l.push({old:i[0],new:n}),t.delete(n.document),t.size===0)break}}}if(e.textContent!==void 0)for(let n of e.textContent)t.changeTextDocument({textDocument:n.document,contentChanges:n.changes}),u.push(n.document.uri)}this.updateCellMap(r);let d={notebookDocument:r};a&&(d.metadata={old:i,new:r.metadata});let f=[];for(let e of s)f.push(this.getNotebookCell(e));let p=[];for(let e of c)p.push(this.getNotebookCell(e));let m=[];for(let e of u)m.push(this.getNotebookCell(e));(f.length>0||p.length>0||l.length>0||m.length>0)&&(d.cells={added:f,removed:p,changed:{data:l,textContent:m}}),(d.metadata!==void 0||d.cells!==void 0)&&this._onDidChange.fire(d)})),n.push(e.notebooks.synchronization.onDidSaveNotebookDocument(e=>{let t=this.getNotebookDocument(e.notebookDocument.uri);t!==void 0&&this._onDidSave.fire(t)})),n.push(e.notebooks.synchronization.onDidCloseNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri),r=this.notebookDocuments.get(n);if(r!==void 0){this._onDidClose.fire(r);for(let n of e.cellTextDocuments)t.closeTextDocument({textDocument:n});this.notebookDocuments.delete(n);for(let e of r.cells)this.notebookCellMap.delete(e.document)}})),J.Disposable.create(()=>{n.forEach(e=>e.dispose())})}updateCellMap(e){for(let t of e.cells)this.notebookCellMap.set(t.document,[t,e])}},pl=class e{onDidOpenTextDocument(e){return this.openHandler=e,J.Disposable.create(()=>{this.openHandler=void 0})}openTextDocument(e){this.openHandler&&this.openHandler(e)}onDidChangeTextDocument(e){return this.changeHandler=e,J.Disposable.create(()=>{this.changeHandler=e})}changeTextDocument(e){this.changeHandler&&this.changeHandler(e)}onDidCloseTextDocument(e){return this.closeHandler=e,J.Disposable.create(()=>{this.closeHandler=void 0})}closeTextDocument(e){this.closeHandler&&this.closeHandler(e)}onWillSaveTextDocument(){return e.NULL_DISPOSE}onWillSaveTextDocumentWaitUntil(){return e.NULL_DISPOSE}onDidSaveTextDocument(){return e.NULL_DISPOSE}};pl.NULL_DISPOSE=Object.freeze({dispose:()=>{}});function ml(e){return Cs.merge(Rc(e),hl(e))}function hl(e){return{lsp:{CompletionProvider:e=>new Qa(e),DocumentSymbolProvider:e=>new Vc(e),HoverProvider:e=>new Zc(e),FoldingRangeProvider:e=>new Uc(e),ReferencesProvider:e=>new cl(e),DefinitionProvider:e=>new to(e),DocumentHighlightProvider:e=>new Bc(e),RenameProvider:e=>new ll(e)},shared:()=>e.shared}}function gl(e){return Cs.merge(zc(e),_l(e))}function _l(e){return{lsp:{Connection:()=>e.connection,LanguageServer:e=>new ol(e),DocumentUpdateHandler:e=>new Hc(e),WorkspaceSymbolProvider:e=>new ul(e),NodeKindProvider:()=>new sl,FuzzyMatcher:()=>new Wc},workspace:{TextDocuments:()=>new dl(Xo),NotebookDocuments:e=>new fl(e.workspace.TextDocuments)}}}var vl=class{constructor(){this.collector=()=>{}}getNodeFormatter(e){return new yl(e,this.collector)}formatDocument(e,t){let n=e.parseResult;return n.lexerErrors.length===0&&n.parserErrors.length===0?this.doDocumentFormat(e,t.options):[]}isFormatRangeErrorFree(e,t){let n=e.parseResult;return n.lexerErrors.length||n.parserErrors.length?Math.min(...n.lexerErrors.map(e=>e.line??Number.MAX_VALUE),...n.parserErrors.map(e=>e.token.startLine??Number.MAX_VALUE))>t.end.line:!0}formatDocumentRange(e,t){return this.isFormatRangeErrorFree(e,t.range)?this.doDocumentFormat(e,t.options,t.range):[]}formatDocumentOnType(e,t){let n={start:{character:0,line:t.position.line},end:t.position};return this.isFormatRangeErrorFree(e,n)?this.doDocumentFormat(e,t.options,n):[]}get formatOnTypeOptions(){}doDocumentFormat(e,t,n){let r=new Map;this.collector=(e,t,n)=>{let i=this.nodeModeToKey(e,t),a=r.get(i),o=n.options.priority??0,s=a?.options.priority??0;(!a||s<=o)&&r.set(i,n)},this.iterateAstFormatting(e,n);let i=this.iterateCstFormatting(e,r,t,n);return this.avoidOverlappingEdits(e.textDocument,i)}avoidOverlappingEdits(e,t){let n=[];for(let r of t){let t=n[n.length-1];for(;t&&e.offsetAt(r.range.start)<e.offsetAt(t.range.end);)n.pop(),t=n[n.length-1];n.push(r)}return n.filter(t=>this.isNecessary(t,e))}iterateAstFormatting(e,t){let n=e.parseResult.value;this.format(n);let r=Pi(n).iterator(),i;do if(i=r.next(),!i.done){let e=i.value;this.insideRange(e.$cstNode.range,t)?this.format(e):r.prune()}while(!i.done)}nodeModeToKey(e,t){return`${e.offset}:${e.end}:${t}`}insideRange(e,t){return!t||e.start.line<=t.start.line&&e.end.line>=t.end.line||e.start.line>=t.start.line&&e.end.line<=t.end.line||e.start.line<=t.end.line&&e.end.line>=t.end.line}isNecessary(e,t){return e.newText!==t.getText(e.range).replace(/\r/g,``)}iterateCstFormatting(e,t,n,r){let i={indentation:0,options:n,document:e.textDocument},a=[],o=this.iterateCstTree(e,i).iterator(),s,c;do if(c=o.next(),!c.done){let e=c.value,n=kn(e),o=this.nodeModeToKey(e,`prepend`),l=t.get(o);if(t.delete(o),l){let t=this.createTextEdit(s,e,l,i);for(let e of t)e&&this.insideRange(e.range,r)&&a.push(e)}let u=this.nodeModeToKey(e,`append`),d=t.get(u);if(t.delete(u),d){let t=wi(e);if(t){let n=this.createTextEdit(e,t,d,i);for(let e of n)e&&this.insideRange(e.range,r)&&a.push(e)}}if(!l&&e.hidden){let t=this.createHiddenTextEdits(s,e,void 0,i);for(let e of t)e&&this.insideRange(e.range,r)&&a.push(e)}n&&(s=e)}while(!c.done);return a}createHiddenTextEdits(e,t,n,r){let i=t.range.start.line;if(e&&e.range.end.line===i)return[];let a=[],o={start:{character:0,line:i},end:t.range.start},s=r.document.getText(o),c=this.findFittingMove(o,n?.moves??[],r),l=this.getExistingIndentationCharacterCount(s,r),u=this.getIndentationCharacterCount(r,c)-l;if(u===0)return[];let d=``;u>0&&(d=(r.options.insertSpaces?` `:` `).repeat(u));let f=t.text.split(`
|
|
26
|
+
`}var ac=class{constructor(e){this.indexManager=e.shared.workspace.IndexManager,this.commentProvider=e.documentation.CommentProvider}getDocumentation(e){let t=this.commentProvider.getComment(e);if(t&&Ns(t))return Ms(t).toMarkdown({renderLink:(t,n)=>this.documentationLinkRenderer(e,t,n),renderTag:t=>this.documentationTagRenderer(e,t)})}documentationLinkRenderer(e,t,n){let r=this.findNameInPrecomputedScopes(e,t)??this.findNameInGlobalScope(e,t);if(r&&r.nameSegment){let e=r.nameSegment.range.start.line+1,t=r.nameSegment.range.start.character+1;return`[${n}](${r.documentUri.with({fragment:`L${e},${t}`}).toString()})`}else return}documentationTagRenderer(e,t){}findNameInPrecomputedScopes(e,t){let n=q(e).precomputedScopes;if(!n)return;let r=e;do{let e=n.get(r).find(e=>e.name===t);if(e)return e;r=r.$container}while(r)}findNameInGlobalScope(e,t){return this.indexManager.allElements().find(e=>e.name===t)}},oc=i({});t(oc,a(w(),1));var sc=class{constructor(e){this.syncParser=e.parser.LangiumParser}parse(e,t){return Promise.resolve(this.syncParser.parse(e))}},cc=class{buildUnexpectedCharactersMessage(e,t,n,r,i){return h.buildUnexpectedCharactersMessage(e,t,n,r,i)}buildUnableToPopLexerModeMessage(e){return h.buildUnableToPopLexerModeMessage(e)}};const lc={mode:`full`};var uc=class{constructor(e){this.errorMessageProvider=e.parser.LexerErrorMessageProvider,this.tokenBuilder=e.parser.TokenBuilder;let t=this.tokenBuilder.buildTokens(e.Grammar,{caseInsensitive:e.LanguageMetaData.caseInsensitive});this.tokenTypes=this.toTokenTypeDictionary(t),this.chevrotainLexer=new u(pc(t)?Object.values(t):t,{positionTracking:`full`,skipValidations:e.LanguageMetaData.mode===`production`,errorMessageProvider:this.errorMessageProvider})}get definition(){return this.tokenTypes}tokenize(e,t=lc){var n;let r=this.chevrotainLexer.tokenize(e);return{tokens:r.tokens,errors:r.errors,hidden:r.groups.hidden??[],report:(n=this.tokenBuilder).flushLexingReport?.call(n,e)}}toTokenTypeDictionary(e){if(pc(e))return e;let t=fc(e)?Object.values(e.modes).flat():e,n={};return t.forEach(e=>n[e.name]=e),n}};function dc(e){return Array.isArray(e)&&(e.length===0||`name`in e[0])}function fc(e){return e&&`modes`in e&&`defaultMode`in e}function pc(e){return!dc(e)&&!fc(e)}var mc=class{constructor(e){this.grammarElementIdMap=new ls,this.tokenTypeIdMap=new ls,this.grammar=e.Grammar,this.lexer=e.parser.Lexer,this.linker=e.references.Linker}dehydrate(e){return{lexerErrors:e.lexerErrors,lexerReport:e.lexerReport?this.dehydrateLexerReport(e.lexerReport):void 0,parserErrors:e.parserErrors.map(e=>Object.assign(Object.assign({},e),{message:e.message})),value:this.dehydrateAstNode(e.value,this.createDehyrationContext(e.value))}}dehydrateLexerReport(e){return e}createDehyrationContext(e){let t=new Map,n=new Map;for(let n of Fi(e))t.set(n,{});if(e.$cstNode)for(let t of ci(e.$cstNode))n.set(t,{});return{astNodes:t,cstNodes:n}}dehydrateAstNode(e,t){let n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode!==void 0&&(n.$cstNode=this.dehydrateCstNode(e.$cstNode,t));for(let[r,i]of Object.entries(e))if(!r.startsWith(`$`))if(Array.isArray(i)){let e=[];n[r]=e;for(let n of i)H(n)?e.push(this.dehydrateAstNode(n,t)):wn(n)?e.push(this.dehydrateReference(n,t)):e.push(n)}else H(i)?n[r]=this.dehydrateAstNode(i,t):wn(i)?n[r]=this.dehydrateReference(i,t):i!==void 0&&(n[r]=i);return n}dehydrateReference(e,t){let n={};return n.$refText=e.$refText,e.$refNode&&(n.$refNode=t.cstNodes.get(e.$refNode)),n}dehydrateCstNode(e,t){let n=t.cstNodes.get(e);return An(e)?n.fullText=e.fullText:n.grammarSource=this.getGrammarElementId(e.grammarSource),n.hidden=e.hidden,n.astNode=t.astNodes.get(e.astNode),On(e)?n.content=e.content.map(e=>this.dehydrateCstNode(e,t)):kn(e)&&(n.tokenType=e.tokenType.name,n.offset=e.offset,n.length=e.length,n.startLine=e.range.start.line,n.startColumn=e.range.start.character,n.endLine=e.range.end.line,n.endColumn=e.range.end.character),n}hydrate(e){let t=e.value,n=this.createHydrationContext(t);return`$cstNode`in t&&this.hydrateCstNode(t.$cstNode,n),{lexerErrors:e.lexerErrors,lexerReport:e.lexerReport,parserErrors:e.parserErrors,value:this.hydrateAstNode(t,n)}}createHydrationContext(e){let t=new Map,n=new Map;for(let n of Fi(e))t.set(n,{});let r;if(e.$cstNode)for(let t of ci(e.$cstNode)){let e;`fullText`in t?(e=new co(t.fullText),r=e):`content`in t?e=new oo:`tokenType`in t&&(e=this.hydrateCstLeafNode(t)),e&&(n.set(t,e),e.root=r)}return{astNodes:t,cstNodes:n}}hydrateAstNode(e,t){let n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode&&(n.$cstNode=t.cstNodes.get(e.$cstNode));for(let[r,i]of Object.entries(e))if(!r.startsWith(`$`))if(Array.isArray(i)){let e=[];n[r]=e;for(let a of i)H(a)?e.push(this.setParent(this.hydrateAstNode(a,t),n)):wn(a)?e.push(this.hydrateReference(a,n,r,t)):e.push(a)}else H(i)?n[r]=this.setParent(this.hydrateAstNode(i,t),n):wn(i)?n[r]=this.hydrateReference(i,n,r,t):i!==void 0&&(n[r]=i);return n}setParent(e,t){return e.$container=t,e}hydrateReference(e,t,n,r){return this.linker.buildReference(t,n,r.cstNodes.get(e.$refNode),e.$refText)}hydrateCstNode(e,t,n=0){let r=t.cstNodes.get(e);if(typeof e.grammarSource==`number`&&(r.grammarSource=this.getGrammarElement(e.grammarSource)),r.astNode=t.astNodes.get(e.astNode),On(r))for(let i of e.content){let e=this.hydrateCstNode(i,t,n++);r.content.push(e)}return r}hydrateCstLeafNode(e){let t=this.getTokenType(e.tokenType),n=e.offset,r=e.length,i=e.startLine,a=e.startColumn,o=e.endLine,s=e.endColumn,c=e.hidden;return new ao(n,r,{start:{line:i,character:a},end:{line:o,character:s}},t,c)}getTokenType(e){return this.lexer.definition[e]}getGrammarElementId(e){if(e)return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.get(e)}getGrammarElement(e){return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.getKey(e)}createGrammarElementIdMap(){let e=0;for(let t of Fi(this.grammar))Ln(t)&&this.grammarElementIdMap.set(t,e++)}},hc;(function(e){function t(e){return{dispose:async()=>await e()}}e.create=t})(hc||={});var gc=class{readFile(){throw Error(`No file system is available.`)}async readDirectory(){return[]}};const _c={fileSystemProvider:()=>new gc},vc={Grammar:()=>void 0,LanguageMetaData:()=>({caseInsensitive:!1,fileExtensions:[`.langium`],languageId:`langium`})},yc={AstReflection:()=>new ti};function bc(){let e=ws(zc(_c),yc),t=ws(Rc({shared:e}),vc);return e.ServiceRegistry.register(t),t}function xc(e){let t=bc(),n=t.serializer.JsonSerializer.deserialize(e);return t.shared.workspace.LangiumDocumentFactory.fromModel(n,Y.parse(`memory://${n.name??`grammar`}.langium`)),n}var Sc=class{constructor(e){this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider}createDescription(e,t,n){let r=n??q(e);t??=this.nameProvider.getName(e);let i=this.astNodeLocator.getAstNodePath(e);if(!t)throw Error(`Node at path ${i} has no name.`);let a,o=()=>a??=fi(this.nameProvider.getNameNode(e)??e.$cstNode);return{node:e,name:t,get nameSegment(){return o()},selectionSegment:fi(e.$cstNode),type:e.$type,documentUri:r.uri,path:i}}},Cc=class{constructor(e){this.nodeLocator=e.workspace.AstNodeLocator}async createDescriptions(e,t=Z.CancellationToken.None){let n=[],r=e.parseResult.value;for(let e of Fi(r))await Q(t),Li(e).filter(e=>!En(e)).forEach(e=>{let t=this.createDescription(e);t&&n.push(t)});return n}createDescription(e){let t=e.reference.$nodeDescription,n=e.reference.$refNode;if(!t||!n)return;let r=q(e.container).uri;return{sourceUri:r,sourcePath:this.nodeLocator.getAstNodePath(e.container),targetUri:t.documentUri,targetPath:t.path,segment:fi(n),local:X.equals(t.documentUri,r)}}},wc=class{constructor(){this.segmentSeparator=`/`,this.indexSeparator=`@`}getAstNodePath(e){if(e.$container){let t=this.getAstNodePath(e.$container),n=this.getPathSegment(e);return t+this.segmentSeparator+n}return``}getPathSegment({$containerProperty:e,$containerIndex:t}){if(!e)throw Error(`Missing '$containerProperty' in AST node.`);return t===void 0?e:e+this.indexSeparator+t}getAstNode(e,t){return t.split(this.segmentSeparator).reduce((e,t)=>{if(!e||t.length===0)return e;let n=t.indexOf(this.indexSeparator);if(n>0){let r=t.substring(0,n),i=parseInt(t.substring(n+1));return e[r]?.[i]}return e[t]},e)}},Tc=class{constructor(e){this._ready=new Jo,this.settings={},this.workspaceConfig=!1,this.onConfigurationSectionUpdateEmitter=new oc.Emitter,this.serviceRegistry=e.ServiceRegistry}get ready(){return this._ready.promise}initialize(e){this.workspaceConfig=e.capabilities.workspace?.configuration??!1}async initialized(e){if(this.workspaceConfig){if(e.register){let t=this.serviceRegistry.all;e.register({section:t.map(e=>this.toSectionName(e.LanguageMetaData.languageId))})}if(e.fetchConfiguration){let t=this.serviceRegistry.all.map(e=>({section:this.toSectionName(e.LanguageMetaData.languageId)})),n=await e.fetchConfiguration(t);t.forEach((e,t)=>{this.updateSectionConfiguration(e.section,n[t])})}}this._ready.resolve()}updateConfiguration(e){e.settings&&Object.keys(e.settings).forEach(t=>{let n=e.settings[t];this.updateSectionConfiguration(t,n),this.onConfigurationSectionUpdateEmitter.fire({section:t,configuration:n})})}updateSectionConfiguration(e,t){this.settings[e]=t}async getConfiguration(e,t){await this.ready;let n=this.toSectionName(e);if(this.settings[n])return this.settings[n][t]}toSectionName(e){return`${e}`}get onConfigurationSectionUpdate(){return this.onConfigurationSectionUpdateEmitter.event}},Ec=class{constructor(e){this.updateBuildOptions={validation:{categories:[`built-in`,`fast`]}},this.updateListeners=[],this.buildPhaseListeners=new cs,this.documentPhaseListeners=new cs,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=$.Changed,this.langiumDocuments=e.workspace.LangiumDocuments,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.textDocuments=e.workspace.TextDocuments,this.indexManager=e.workspace.IndexManager,this.serviceRegistry=e.ServiceRegistry}async build(e,t={},n=Z.CancellationToken.None){for(let n of e){let e=n.uri.toString();if(n.state===$.Validated){if(typeof t.validation==`boolean`&&t.validation)n.state=$.IndexedReferences,n.diagnostics=void 0,this.buildState.delete(e);else if(typeof t.validation==`object`){let r=this.buildState.get(e),i=r?.result?.validationChecks;if(i){let a=(t.validation.categories??jc.all).filter(e=>!i.includes(e));a.length>0&&(this.buildState.set(e,{completed:!1,options:{validation:Object.assign(Object.assign({},t.validation),{categories:a})},result:r.result}),n.state=$.IndexedReferences)}}}else this.buildState.delete(e)}this.currentState=$.Changed,await this.emitUpdate(e.map(e=>e.uri),[]),await this.buildDocuments(e,t,n)}async update(e,t,n=Z.CancellationToken.None){this.currentState=$.Changed;for(let e of t)this.langiumDocuments.deleteDocument(e),this.buildState.delete(e.toString()),this.indexManager.remove(e);for(let t of e){if(!this.langiumDocuments.invalidateDocument(t)){let e=this.langiumDocumentFactory.fromModel({$type:`INVALID`},t);e.state=$.Changed,this.langiumDocuments.addDocument(e)}this.buildState.delete(t.toString())}let r=K(e).concat(t).map(e=>e.toString()).toSet();this.langiumDocuments.all.filter(e=>!r.has(e.uri.toString())&&this.shouldRelink(e,r)).forEach(e=>{this.serviceRegistry.getServices(e.uri).references.Linker.unlink(e),e.state=Math.min(e.state,$.ComputedScopes),e.diagnostics=void 0}),await this.emitUpdate(e,t),await Q(n);let i=this.sortDocuments(this.langiumDocuments.all.filter(e=>e.state<$.Linked||!this.buildState.get(e.uri.toString())?.completed).toArray());await this.buildDocuments(i,this.updateBuildOptions,n)}async emitUpdate(e,t){await Promise.all(this.updateListeners.map(n=>n(e,t)))}sortDocuments(e){let t=0,n=e.length-1;for(;t<n;){for(;t<e.length&&this.hasTextDocument(e[t]);)t++;for(;n>=0&&!this.hasTextDocument(e[n]);)n--;t<n&&([e[t],e[n]]=[e[n],e[t]])}return e}hasTextDocument(e){return!!this.textDocuments?.get(e.uri)}shouldRelink(e,t){return e.references.some(e=>e.error!==void 0)?!0:this.indexManager.isAffected(e,t)}onUpdate(e){return this.updateListeners.push(e),hc.create(()=>{let t=this.updateListeners.indexOf(e);t>=0&&this.updateListeners.splice(t,1)})}async buildDocuments(e,t,n){this.prepareBuild(e,t),await this.runCancelable(e,$.Parsed,n,e=>this.langiumDocumentFactory.update(e,n)),await this.runCancelable(e,$.IndexedContent,n,e=>this.indexManager.updateContent(e,n)),await this.runCancelable(e,$.ComputedScopes,n,async e=>{e.precomputedScopes=await this.serviceRegistry.getServices(e.uri).references.ScopeComputation.computeLocalScopes(e,n)});let r=e.filter(e=>this.shouldLink(e));await this.runCancelable(r,$.Linked,n,e=>this.serviceRegistry.getServices(e.uri).references.Linker.link(e,n)),await this.runCancelable(r,$.IndexedReferences,n,e=>this.indexManager.updateReferences(e,n));let i=e.filter(e=>this.shouldValidate(e));await this.runCancelable(i,$.Validated,n,e=>this.validate(e,n));for(let t of e){let e=this.buildState.get(t.uri.toString());e&&(e.completed=!0)}}prepareBuild(e,t){for(let n of e){let e=n.uri.toString(),r=this.buildState.get(e);(!r||r.completed)&&this.buildState.set(e,{completed:!1,options:t,result:r?.result})}}async runCancelable(e,t,n,r){let i=e.filter(e=>e.state<t);for(let e of i)await Q(n),await r(e),e.state=t,await this.notifyDocumentPhase(e,t,n);let a=e.filter(e=>e.state===t);await this.notifyBuildPhase(a,t,n),this.currentState=t}onBuildPhase(e,t){return this.buildPhaseListeners.add(e,t),hc.create(()=>{this.buildPhaseListeners.delete(e,t)})}onDocumentPhase(e,t){return this.documentPhaseListeners.add(e,t),hc.create(()=>{this.documentPhaseListeners.delete(e,t)})}waitUntil(e,t,n){let r;if(t&&`path`in t?r=t:n=t,n??=Z.CancellationToken.None,r){let t=this.langiumDocuments.getDocument(r);if(t&&t.state>=e)return Promise.resolve(r)}return this.currentState>=e?Promise.resolve(void 0):n.isCancellationRequested?Promise.reject(Ko):new Promise((t,i)=>{let a=this.onBuildPhase(e,()=>{a.dispose(),o.dispose(),t(r?this.langiumDocuments.getDocument(r)?.uri:void 0)}),o=n.onCancellationRequested(()=>{a.dispose(),o.dispose(),i(Ko)})})}async notifyDocumentPhase(e,t,n){let r=this.documentPhaseListeners.get(t).slice();for(let t of r)try{await t(e,n)}catch(e){if(!qo(e))throw e}}async notifyBuildPhase(e,t,n){if(e.length===0)return;let r=this.buildPhaseListeners.get(t).slice();for(let t of r)await Q(n),await t(e,n)}shouldLink(e){return this.getBuildOptions(e).eagerLinking??!0}shouldValidate(e){return!!this.getBuildOptions(e).validation}async validate(e,t){let n=this.serviceRegistry.getServices(e.uri).validation.DocumentValidator,r=this.getBuildOptions(e).validation,i=typeof r==`object`?r:void 0,a=await n.validateDocument(e,i,t);e.diagnostics?e.diagnostics.push(...a):e.diagnostics=a;let o=this.buildState.get(e.uri.toString());if(o){o.result??={};let e=i?.categories??jc.all;o.result.validationChecks?o.result.validationChecks.push(...e):o.result.validationChecks=[...e]}}getBuildOptions(e){return this.buildState.get(e.uri.toString())?.options??{}}},Dc=class{constructor(e){this.symbolIndex=new Map,this.symbolByTypeIndex=new gs,this.referenceIndex=new Map,this.documents=e.workspace.LangiumDocuments,this.serviceRegistry=e.ServiceRegistry,this.astReflection=e.AstReflection}findAllReferences(e,t){let n=q(e).uri,r=[];return this.referenceIndex.forEach(e=>{e.forEach(e=>{X.equals(e.targetUri,n)&&e.targetPath===t&&r.push(e)})}),K(r)}allElements(e,t){let n=K(this.symbolIndex.keys());return t&&(n=n.filter(e=>!t||t.has(e))),n.map(t=>this.getFileDescriptions(t,e)).flat()}getFileDescriptions(e,t){return t?this.symbolByTypeIndex.get(e,t,()=>(this.symbolIndex.get(e)??[]).filter(e=>this.astReflection.isSubtype(e.type,t))):this.symbolIndex.get(e)??[]}remove(e){let t=e.toString();this.symbolIndex.delete(t),this.symbolByTypeIndex.clear(t),this.referenceIndex.delete(t)}async updateContent(e,t=Z.CancellationToken.None){let n=await this.serviceRegistry.getServices(e.uri).references.ScopeComputation.computeExports(e,t),r=e.uri.toString();this.symbolIndex.set(r,n),this.symbolByTypeIndex.clear(r)}async updateReferences(e,t=Z.CancellationToken.None){let n=await this.serviceRegistry.getServices(e.uri).workspace.ReferenceDescriptionProvider.createDescriptions(e,t);this.referenceIndex.set(e.uri.toString(),n)}isAffected(e,t){let n=this.referenceIndex.get(e.uri.toString());return n?n.some(e=>!e.local&&t.has(e.targetUri.toString())):!1}},Oc=class{constructor(){this.previousTokenSource=new Z.CancellationTokenSource,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();let t=Go();return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,n=Z.CancellationToken.None){let r=new Jo,i={action:t,deferred:r,cancellationToken:n};return e.push(i),this.performNextOperation(),r.promise}async performNextOperation(){if(!this.done)return;let e=[];if(this.writeQueue.length>0)e.push(this.writeQueue.shift());else if(this.readQueue.length>0)e.push(...this.readQueue.splice(0,this.readQueue.length));else return;this.done=!1,await Promise.all(e.map(async({action:e,deferred:t,cancellationToken:n})=>{try{let r=await Promise.resolve().then(()=>e(n));t.resolve(r)}catch(e){qo(e)?t.resolve(void 0):t.reject(e)}})),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}},kc=class{constructor(e){this.initialBuildOptions={},this._ready=new Jo,this.serviceRegistry=e.ServiceRegistry,this.langiumDocuments=e.workspace.LangiumDocuments,this.documentBuilder=e.workspace.DocumentBuilder,this.fileSystemProvider=e.workspace.FileSystemProvider,this.mutex=e.workspace.WorkspaceLock}get ready(){return this._ready.promise}get workspaceFolders(){return this.folders}initialize(e){this.folders=e.workspaceFolders??void 0}initialized(e){return this.mutex.write(e=>this.initializeWorkspace(this.folders??[],e))}async initializeWorkspace(e,t=Z.CancellationToken.None){let n=await this.performStartup(e);await Q(t),await this.documentBuilder.build(n,this.initialBuildOptions,t)}async performStartup(e){let t=this.serviceRegistry.all.flatMap(e=>e.LanguageMetaData.fileExtensions),n=this.serviceRegistry.all.flatMap(e=>e.LanguageMetaData.fileNames??[]),r=[],i=e=>{r.push(e),this.langiumDocuments.hasDocument(e.uri)||this.langiumDocuments.addDocument(e)};return await this.loadAdditionalDocuments(e,i),await Promise.all(e.map(e=>[e,this.getRootFolder(e)]).map(async e=>this.traverseFolder(...e,{fileExtensions:t,fileNames:n},i))),this._ready.resolve(),r}loadAdditionalDocuments(e,t){return Promise.resolve()}getRootFolder(e){return Y.parse(e.uri)}async traverseFolder(e,t,n,r){let i=await this.fileSystemProvider.readDirectory(t);await Promise.all(i.map(async t=>{this.includeEntry(e,t,n)&&(t.isDirectory?await this.traverseFolder(e,t.uri,n,r):t.isFile&&r(await this.langiumDocuments.getOrCreateDocument(t.uri)))}))}includeEntry(e,t,n){let r=X.basename(t.uri);return r.startsWith(`.`)?!1:t.isDirectory?r!==`node_modules`&&r!==`out`:t.isFile?n.fileExtensions.includes(X.extname(t.uri))||n.fileNames.includes(X.basename(t.uri)):!1}};function Ac(e){return{code:e}}var jc;(function(e){e.all=[`fast`,`slow`,`built-in`]})(jc||={});var Mc=class{constructor(e){this.entries=new cs,this.entriesBefore=[],this.entriesAfter=[],this.reflection=e.shared.AstReflection}register(e,t=this,n=`fast`){if(n===`built-in`)throw Error(`The 'built-in' category is reserved for lexer, parser, and linker errors.`);for(let[r,i]of Object.entries(e)){let e=i;if(Array.isArray(e))for(let i of e){let e={check:this.wrapValidationException(i,t),category:n};this.addEntry(r,e)}else if(typeof e==`function`){let i={check:this.wrapValidationException(e,t),category:n};this.addEntry(r,i)}else Ui(e)}}wrapValidationException(e,t){return async(n,r,i)=>{await this.handleException(()=>e.call(t,n,r,i),`An error occurred during validation`,r,n)}}async handleException(e,t,n,r){try{await e()}catch(e){if(qo(e))throw e;console.error(`${t}:`,e),e instanceof Error&&e.stack&&console.error(e.stack),n(`error`,`${t}: ${e instanceof Error?e.message:String(e)}`,{node:r})}}addEntry(e,t){if(e===`AstNode`){this.entries.add(`AstNode`,t);return}for(let n of this.reflection.getAllSubTypes(e))this.entries.add(n,t)}getChecks(e,t){let n=K(this.entries.get(e)).concat(this.entries.get(`AstNode`));return t&&(n=n.filter(e=>t.includes(e.category))),n.map(e=>e.check)}registerBeforeDocument(e,t=this){this.entriesBefore.push(this.wrapPreparationException(e,`An error occurred during set-up of the validation`,t))}registerAfterDocument(e,t=this){this.entriesAfter.push(this.wrapPreparationException(e,`An error occurred during tear-down of the validation`,t))}wrapPreparationException(e,t,n){return async(r,i,a,o)=>{await this.handleException(()=>e.call(n,r,i,a,o),t,i,r)}}get checksBefore(){return this.entriesBefore}get checksAfter(){return this.entriesAfter}},Nc=class{constructor(e){this.validationRegistry=e.validation.ValidationRegistry,this.metadata=e.LanguageMetaData}async validateDocument(e,t={},n=Z.CancellationToken.None){let r=e.parseResult,i=[];if(await Q(n),(!t.categories||t.categories.includes(`built-in`))&&(this.processLexingErrors(r,i,t),t.stopAfterLexingErrors&&i.some(e=>e.data?.code===Lc.LexingError)||(this.processParsingErrors(r,i,t),t.stopAfterParsingErrors&&i.some(e=>e.data?.code===Lc.ParsingError))||(this.processLinkingErrors(e,i,t),t.stopAfterLinkingErrors&&i.some(e=>e.data?.code===Lc.LinkingError))))return i;try{i.push(...await this.validateAst(r.value,t,n))}catch(e){if(qo(e))throw e;console.error(`An error occurred during validation:`,e)}return await Q(n),i}processLexingErrors(e,t,n){let r=[...e.lexerErrors,...e.lexerReport?.diagnostics??[]];for(let e of r){let n=e.severity??`error`,r={severity:Fc(n),range:{start:{line:e.line-1,character:e.column-1},end:{line:e.line-1,character:e.column+e.length-1}},message:e.message,data:Ic(n),source:this.getSource()};t.push(r)}}processParsingErrors(e,t,n){for(let n of e.parserErrors){let e;if(isNaN(n.token.startOffset)){if(`previousToken`in n){let t=n.previousToken;if(isNaN(t.startOffset)){let t={line:0,character:0};e={start:t,end:t}}else{let n={line:t.endLine-1,character:t.endColumn};e={start:n,end:n}}}}else e=di(n.token);if(e){let r={severity:Fc(`error`),range:e,message:n.message,data:Ac(Lc.ParsingError),source:this.getSource()};t.push(r)}}}processLinkingErrors(e,t,n){for(let n of e.references){let e=n.error;if(e){let n={node:e.container,property:e.property,index:e.index,data:{code:Lc.LinkingError,containerType:e.container.$type,property:e.property,refText:e.reference.$refText}};t.push(this.toDiagnostic(`error`,e.message,n))}}}async validateAst(e,t,n=Z.CancellationToken.None){let r=[],i=(e,t,n)=>{r.push(this.toDiagnostic(e,t,n))};return await this.validateAstBefore(e,t,i,n),await this.validateAstNodes(e,t,i,n),await this.validateAstAfter(e,t,i,n),r}async validateAstBefore(e,t,n,r=Z.CancellationToken.None){let i=this.validationRegistry.checksBefore;for(let a of i)await Q(r),await a(e,n,t.categories??[],r)}async validateAstNodes(e,t,n,r=Z.CancellationToken.None){await Promise.all(Fi(e).map(async e=>{await Q(r);let i=this.validationRegistry.getChecks(e.$type,t.categories);for(let t of i)await t(e,n,r)}))}async validateAstAfter(e,t,n,r=Z.CancellationToken.None){let i=this.validationRegistry.checksAfter;for(let a of i)await Q(r),await a(e,n,t.categories??[],r)}toDiagnostic(e,t,n){return{message:t,range:Pc(n),severity:Fc(e),code:n.code,codeDescription:n.codeDescription,tags:n.tags,relatedInformation:n.relatedInformation,data:n.data,source:this.getSource()}}getSource(){return this.metadata.languageId}};function Pc(e){if(e.range)return e.range;let t;return typeof e.property==`string`?t=ca(e.node.$cstNode,e.property,e.index):typeof e.keyword==`string`&&(t=da(e.node.$cstNode,e.keyword,e.index)),t??=e.node.$cstNode,t?t.range:{start:{line:0,character:0},end:{line:0,character:0}}}function Fc(e){switch(e){case`error`:return 1;case`warning`:return 2;case`info`:return 3;case`hint`:return 4;default:throw Error(`Invalid diagnostic severity: `+e)}}function Ic(e){switch(e){case`error`:return Ac(Lc.LexingError);case`warning`:return Ac(Lc.LexingWarning);case`info`:return Ac(Lc.LexingInfo);case`hint`:return Ac(Lc.LexingHint);default:throw Error(`Invalid diagnostic severity: `+e)}}var Lc;(function(e){e.LexingError=`lexing-error`,e.LexingWarning=`lexing-warning`,e.LexingInfo=`lexing-info`,e.LexingHint=`lexing-hint`,e.ParsingError=`parsing-error`,e.LinkingError=`linking-error`})(Lc||={});function Rc(e){return{documentation:{CommentProvider:e=>new js(e),DocumentationProvider:e=>new ac(e)},parser:{AsyncParser:e=>new sc(e),GrammarConfig:e=>no(e),LangiumParser:e=>Ro(e),CompletionParser:e=>Lo(e),ValueConverter:()=>new Vo,TokenBuilder:()=>new Bo,Lexer:e=>new uc(e),ParserErrorMessageProvider:()=>new go,LexerErrorMessageProvider:()=>new cc},workspace:{AstNodeLocator:()=>new wc,AstNodeDescriptionProvider:e=>new Sc(e),ReferenceDescriptionProvider:e=>new Cc(e)},references:{Linker:e=>new is(e),NameProvider:()=>new os,ScopeProvider:e=>new vs(e),ScopeComputation:e=>new us(e),References:e=>new ss(e)},serializer:{Hydrator:e=>new mc(e),JsonSerializer:e=>new xs(e)},validation:{DocumentValidator:e=>new Nc(e),ValidationRegistry:e=>new Mc(e)},shared:()=>e.shared}}function zc(e){return{ServiceRegistry:e=>new Ss(e),workspace:{LangiumDocuments:e=>new ns(e),LangiumDocumentFactory:e=>new ts(e),DocumentBuilder:e=>new Ec(e),IndexManager:e=>new Dc(e),WorkspaceManager:e=>new kc(e),FileSystemProvider:t=>e.fileSystemProvider(t),WorkspaceLock:()=>new Oc,ConfigurationProvider:e=>new Tc(e)}}}var Bc=class{constructor(e){this.references=e.references.References,this.nameProvider=e.references.NameProvider,this.grammarConfig=e.parser.GrammarConfig}getDocumentHighlight(e,t,n){let r=e.parseResult.value.$cstNode;if(!r)return;let i=_i(r,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);if(!i)return;let a=this.references.findDeclaration(i);if(a){let t=X.equals(q(a).uri,e.uri),n={documentUri:e.uri,includeDeclaration:t};return this.references.findReferences(a,n).map(e=>this.createDocumentHighlight(e)).toArray()}}createDocumentHighlight(e){return J.DocumentHighlight.create(e.segment.range)}},Vc=class{constructor(e){this.nameProvider=e.references.NameProvider,this.nodeKindProvider=e.shared.lsp.NodeKindProvider}getSymbols(e,t,n){return this.getSymbol(e,e.parseResult.value)}getSymbol(e,t){let n=t.$cstNode,r=this.nameProvider.getNameNode(t);if(r&&n){let i=this.nameProvider.getName(t);return[{kind:this.nodeKindProvider.getSymbolKind(t),name:i||r.text,range:n.range,selectionRange:r.range,children:this.getChildSymbols(e,t)}]}else return this.getChildSymbols(e,t)||[]}getChildSymbols(e,t){let n=[];for(let r of Ni(t)){let t=this.getSymbol(e,r);n.push(...t)}if(n.length>0)return n}},Hc=class{constructor(e){this.workspaceManager=e.workspace.WorkspaceManager,this.documentBuilder=e.workspace.DocumentBuilder,this.workspaceLock=e.workspace.WorkspaceLock,this.serviceRegistry=e.ServiceRegistry;let t=!1;e.lsp.LanguageServer.onInitialize(e=>{t=!!e.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration}),e.lsp.LanguageServer.onInitialized(n=>{t&&this.registerFileWatcher(e)})}registerFileWatcher(e){let t=[],n=K(e.ServiceRegistry.all).flatMap(e=>e.LanguageMetaData.fileExtensions).map(e=>e.startsWith(`.`)?e.substring(1):e).distinct().toArray();n.length>0&&t.push({globPattern:n.length===1?`**/*.${n[0]}`:`**/*.{${n.join(`,`)}}`});let r=K(e.ServiceRegistry.all).flatMap(e=>e.LanguageMetaData.fileNames??[]).distinct().toArray();if(r.length>0&&t.push({globPattern:r.length===1?`**/${r[0]}`:`**/{${r.join(`,`)}}`}),t.length>0){let n=e.lsp.Connection,r={watchers:t};n?.client.register(J.DidChangeWatchedFilesNotification.type,r)}}fireDocumentUpdate(e,t){e=e.filter(e=>this.serviceRegistry.hasServices(e)),this.workspaceManager.ready.then(()=>{this.workspaceLock.write(n=>this.documentBuilder.update(e,t,n))}).catch(e=>{console.error(`Workspace initialization failed. Could not perform document update.`,e)})}didChangeContent(e){this.fireDocumentUpdate([Y.parse(e.document.uri)],[])}didChangeWatchedFiles(e){let t=K(e.changes).filter(e=>e.type!==J.FileChangeType.Deleted).distinct(e=>e.uri).map(e=>Y.parse(e.uri)).toArray(),n=K(e.changes).filter(e=>e.type===J.FileChangeType.Deleted).distinct(e=>e.uri).map(e=>Y.parse(e.uri)).toArray();this.fireDocumentUpdate(t,n)}},Uc=class{constructor(e){this.commentNames=e.parser.GrammarConfig.multilineCommentRules}getFoldingRanges(e,t,n){let r=[];return this.collectFolding(e,e=>r.push(e)),r}collectFolding(e,t){let n=e.parseResult?.value;if(n){if(this.shouldProcessContent(n)){let r=Pi(n).iterator(),i;do if(i=r.next(),!i.done){let n=i.value;this.shouldProcess(n)&&this.collectObjectFolding(e,n,t),this.shouldProcessContent(n)||r.prune()}while(!i.done)}this.collectCommentFolding(e,n,t)}}shouldProcess(e){return!0}shouldProcessContent(e){return!0}collectObjectFolding(e,t,n){let r=t.$cstNode;if(r){let t=this.toFoldingRange(e,r);t&&n(t)}}collectCommentFolding(e,t,n){let r=t.$cstNode;if(r){for(let t of li(r))if(this.commentNames.includes(t.tokenType.name)){let r=this.toFoldingRange(e,t,J.FoldingRangeKind.Comment);r&&n(r)}}}toFoldingRange(e,t,n){let r=t.range,i=r.start,a=r.end;if(!(a.line-i.line<2))return this.includeLastFoldingLine(t,n)||(a=e.textDocument.positionAt(e.textDocument.offsetAt({line:a.line,character:0})-1)),J.FoldingRange.create(i.line,a.line,i.character,a.character,n)}includeLastFoldingLine(e,t){if(t===J.FoldingRangeKind.Comment)return!1;let n=e.text,r=n.charAt(n.length-1);return!(r===`}`||r===`)`||r===`]`)}},Wc=class{match(e,t){if(e.length===0)return!0;let n=!1,r,i=0,a=t.length;for(let o=0;o<a;o++){let a=t.charCodeAt(o),s=e.charCodeAt(i);if((a===s||this.toUpperCharCode(a)===this.toUpperCharCode(s))&&(n||=r===void 0||this.isWordTransition(r,a),n&&i++,i===e.length))return!0;r=a}return!1}isWordTransition(e,t){return Gc<=e&&e<=Kc&&qc<=t&&t<=Jc||e===Yc&&t!==Yc}toUpperCharCode(e){return Gc<=e&&e<=Kc?e-32:e}};const Gc=97,Kc=122,qc=65,Jc=90,Yc=95;var Xc=class{constructor(e){this.references=e.references.References,this.grammarConfig=e.parser.GrammarConfig}getHoverContent(e,t){let n=e.parseResult?.value?.$cstNode;if(n){let r=e.textDocument.offsetAt(t.position),i=_i(n,r,this.grammarConfig.nameRegexp);if(i&&i.offset+i.length>r){let e=this.references.findDeclaration(i);if(e)return this.getAstNodeHoverContent(e);if(Ir(i.grammarSource))return this.getKeywordHoverContent(i.grammarSource)}}}getKeywordHoverContent(e){let t=ys(e)?e.$comment:void 0;if(t||=vi(e.$cstNode,[`ML_COMMENT`])?.text,t&&Ns(t)){let e=Ms(t).toMarkdown();if(e)return{contents:{kind:`markdown`,value:e}}}}},Zc=class extends Xc{constructor(e){super(e),this.documentationProvider=e.documentation.DocumentationProvider}getAstNodeHoverContent(e){let t=this.documentationProvider.getDocumentation(e);if(t)return{contents:{kind:`markdown`,value:t}}}};const Qc={[J.SemanticTokenTypes.class]:0,[J.SemanticTokenTypes.comment]:1,[J.SemanticTokenTypes.enum]:2,[J.SemanticTokenTypes.enumMember]:3,[J.SemanticTokenTypes.event]:4,[J.SemanticTokenTypes.function]:5,[J.SemanticTokenTypes.interface]:6,[J.SemanticTokenTypes.keyword]:7,[J.SemanticTokenTypes.macro]:8,[J.SemanticTokenTypes.method]:9,[J.SemanticTokenTypes.modifier]:10,[J.SemanticTokenTypes.namespace]:11,[J.SemanticTokenTypes.number]:12,[J.SemanticTokenTypes.operator]:13,[J.SemanticTokenTypes.parameter]:14,[J.SemanticTokenTypes.property]:15,[J.SemanticTokenTypes.regexp]:16,[J.SemanticTokenTypes.string]:17,[J.SemanticTokenTypes.struct]:18,[J.SemanticTokenTypes.type]:19,[J.SemanticTokenTypes.typeParameter]:20,[J.SemanticTokenTypes.variable]:21,[J.SemanticTokenTypes.decorator]:22},$c={[J.SemanticTokenModifiers.abstract]:1,[J.SemanticTokenModifiers.async]:2,[J.SemanticTokenModifiers.declaration]:4,[J.SemanticTokenModifiers.defaultLibrary]:8,[J.SemanticTokenModifiers.definition]:16,[J.SemanticTokenModifiers.deprecated]:32,[J.SemanticTokenModifiers.documentation]:64,[J.SemanticTokenModifiers.modification]:128,[J.SemanticTokenModifiers.readonly]:256,[J.SemanticTokenModifiers.static]:512};function el(e){let t=[],n=[],r=!0,i=!0,a=!0;for(let o of e)o&&(o.legend.tokenTypes.forEach((e,n)=>{let r=t[n];if(r&&r!==e)throw Error(`Cannot merge '${r}' and '${e}' token types. They use the same index ${n}.`);t[n]=e}),o.legend.tokenModifiers.forEach((e,t)=>{let r=n[t];if(r&&r!==e)throw Error(`Cannot merge '${r}' and '${e}' token modifier. They use the same index ${t}.`);n[t]=e}),o.full?typeof o.full==`object`&&!o.full.delta&&(i=!1):r=!1,o.range||(a=!1));return{legend:{tokenTypes:t,tokenModifiers:n},full:r&&{delta:i},range:a}}var tl=class extends J.SemanticTokensBuilder{constructor(){super(...arguments),this._tokens=[]}push(e,t,n,r,i){this._tokens.push({line:e,char:t,length:n,tokenType:r,tokenModifiers:i})}build(){return this.applyTokens(),super.build()}buildEdits(){return this.applyTokens(),super.buildEdits()}flush(){this.previousResult(this.id)}applyTokens(){for(let e of this._tokens.sort(this.compareTokens))super.push(e.line,e.char,e.length,e.tokenType,e.tokenModifiers);this._tokens=[]}compareTokens(e,t){return e.line===t.line?e.char-t.char:e.line-t.line}},nl=class{constructor(e){this.tokensBuilders=new Map,e.shared.workspace.TextDocuments.onDidClose(e=>{this.tokensBuilders.delete(e.document.uri)}),e.shared.lsp.LanguageServer.onInitialize(e=>{this.initialize(e.capabilities.textDocument?.semanticTokens)})}initialize(e){this.clientCapabilities=e}get tokenTypes(){return Qc}get tokenModifiers(){return $c}get semanticTokensOptions(){return{legend:{tokenTypes:Object.keys(this.tokenTypes),tokenModifiers:Object.keys(this.tokenModifiers)},full:{delta:!0},range:!0}}async semanticHighlight(e,t,n=Z.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.flush(),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.build()}async semanticHighlightRange(e,t,n=Z.CancellationToken.None){return this.currentRange=t.range,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.flush(),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.build()}async semanticHighlightDelta(e,t,n=Z.CancellationToken.None){return this.currentRange=void 0,this.currentDocument=e,this.currentTokensBuilder=this.getDocumentTokensBuilder(e),this.currentTokensBuilder.previousResult(t.previousResultId),await this.computeHighlighting(e,this.createAcceptor(),n),this.currentTokensBuilder.buildEdits()}createAcceptor(){return e=>{`line`in e?this.highlightToken({range:{start:{line:e.line,character:e.char},end:{line:e.line,character:e.char+e.length}},type:e.type,modifier:e.modifier}):`range`in e?this.highlightToken(e):`keyword`in e?this.highlightKeyword(e):`property`in e?this.highlightProperty(e):this.highlightNode({node:e.cst,type:e.type,modifier:e.modifier})}}getDocumentTokensBuilder(e){let t=this.tokensBuilders.get(e.uri.toString());if(t)return t;let n=new tl;return this.tokensBuilders.set(e.uri.toString(),n),n}async computeHighlighting(e,t,n){let r=e.parseResult.value,i=Fi(r,{range:this.currentRange}).iterator(),a;do if(a=i.next(),!a.done){await Q(n);let e=a.value;this.highlightElement(e,t)===`prune`&&i.prune()}while(!a.done)}highlightToken(e){let{range:t,type:n}=e,r=e.modifier;if(this.currentRange&&!hi(t,this.currentRange)||!this.currentDocument||!this.currentTokensBuilder)return;let i=this.tokenTypes[n],a=0;if(r!==void 0){typeof r==`string`&&(r=[r]);for(let e of r){let t=this.tokenModifiers[e];a|=t}}let o=t.start.line,s=t.end.line;if(o===s){let e=t.start.character,n=t.end.character-e;this.currentTokensBuilder.push(o,e,n,i,a)}else if(this.clientCapabilities?.multilineTokenSupport){let e=t.start.character,n=this.currentDocument.textDocument.offsetAt(t.start),r=this.currentDocument.textDocument.offsetAt(t.end);this.currentTokensBuilder.push(o,e,r-n,i,a)}else{let e=t.start,n=this.currentDocument.textDocument.offsetAt({line:o+1,character:0});this.currentTokensBuilder.push(e.line,e.character,n-e.character-1,i,a);for(let e=o+1;e<s;e++){let t=n;n=this.currentDocument.textDocument.offsetAt({line:e+1,character:0}),this.currentTokensBuilder.push(e,0,n-t-1,i,a)}this.currentTokensBuilder.push(s,0,t.end.character,i,a)}}highlightProperty(e){let t=[];if(typeof e.index==`number`){let n=ca(e.node.$cstNode,e.property,e.index);n&&t.push(n)}else t.push(...sa(e.node.$cstNode,e.property));let{type:n,modifier:r}=e;for(let e of t)this.highlightNode({node:e,type:n,modifier:r})}highlightKeyword(e){let{node:t,keyword:n,type:r,index:i,modifier:a}=e,o=[];if(typeof i==`number`){let e=da(t.$cstNode,n,i);e&&o.push(e)}else o.push(...ua(t.$cstNode,n));for(let e of o)this.highlightNode({node:e,type:r,modifier:a})}highlightNode(e){let{node:t,type:n,modifier:r}=e,i=t.range;this.highlightToken({range:i,type:n,modifier:r})}},rl;(function(e){function t(e,t,r){let i=new Map;Object.entries(t).forEach(([e,t])=>i.set(t,e));let a=0,o=0;return n(e.data,5).map(e=>{a+=e[0],e[0]!==0&&(o=0),o+=e[1];let t=e[2];return{offset:r.textDocument.offsetAt({line:a,character:o}),tokenType:i.get(e[3]),tokenModifiers:e[4],text:r.textDocument.getText({start:{line:a,character:o},end:{line:a,character:o+t}})}})}e.decode=t;function n(e,t){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}})(rl||={});function il(e){let t=[],n=[];e.forEach(e=>{e?.triggerCharacters&&t.push(...e.triggerCharacters),e?.retriggerCharacters&&n.push(...e.retriggerCharacters)});let r={triggerCharacters:t.length>0?Array.from(new Set(t)).sort():void 0,retriggerCharacters:n.length>0?Array.from(new Set(n)).sort():void 0};return r.triggerCharacters?r:void 0}var al=V(),ol=class{constructor(e){this.onInitializeEmitter=new al.Emitter,this.onInitializedEmitter=new al.Emitter,this.services=e}get onInitialize(){return this.onInitializeEmitter.event}get onInitialized(){return this.onInitializedEmitter.event}async initialize(e){return this.eagerLoadServices(),this.fireInitializeOnDefaultServices(e),this.onInitializeEmitter.fire(e),this.onInitializeEmitter.dispose(),this.buildInitializeResult(e)}eagerLoadServices(){Es(this.services),this.services.ServiceRegistry.all.forEach(e=>Es(e))}hasService(e){return this.services.ServiceRegistry.all.some(t=>e(t)!==void 0)}buildInitializeResult(e){let t=this.services.lsp.DocumentUpdateHandler,n=this.services.lsp.FileOperationHandler?.fileOperationOptions,r=this.services.ServiceRegistry.all,i=this.hasService(e=>e.lsp?.Formatter),a=r.map(e=>e.lsp?.Formatter?.formatOnTypeOptions).find(e=>!!e),o=this.hasService(e=>e.lsp?.CodeActionProvider),s=this.hasService(e=>e.lsp?.SemanticTokenProvider),c=el(r.map(e=>e.lsp?.SemanticTokenProvider?.semanticTokensOptions)),l=this.services.lsp?.ExecuteCommandHandler?.commands,u=this.hasService(e=>e.lsp?.DocumentLinkProvider),d=il(r.map(e=>e.lsp?.SignatureHelp?.signatureHelpOptions)),f=this.hasService(e=>e.lsp?.TypeProvider),p=this.hasService(e=>e.lsp?.ImplementationProvider),m=this.hasService(e=>e.lsp?.CompletionProvider),h=Za(r.map(e=>e.lsp?.CompletionProvider?.completionOptions)),g=this.hasService(e=>e.lsp?.ReferencesProvider),_=this.hasService(e=>e.lsp?.DocumentSymbolProvider),v=this.hasService(e=>e.lsp?.DefinitionProvider),y=this.hasService(e=>e.lsp?.DocumentHighlightProvider),b=this.hasService(e=>e.lsp?.FoldingRangeProvider),x=this.hasService(e=>e.lsp?.HoverProvider),S=this.hasService(e=>e.lsp?.RenameProvider),C=this.hasService(e=>e.lsp?.CallHierarchyProvider),w=this.hasService(e=>e.lsp?.TypeHierarchyProvider),ee=this.hasService(e=>e.lsp?.CodeLensProvider),T=this.hasService(e=>e.lsp?.DeclarationProvider),E=this.hasService(e=>e.lsp?.InlayHintProvider),D=this.services.lsp?.WorkspaceSymbolProvider;return{capabilities:{workspace:{workspaceFolders:{supported:!0},fileOperations:n},executeCommandProvider:l&&{commands:l},textDocumentSync:{change:al.TextDocumentSyncKind.Incremental,openClose:!0,save:!!t.didSaveDocument,willSave:!!t.willSaveDocument,willSaveWaitUntil:!!t.willSaveDocumentWaitUntil},completionProvider:m?h:void 0,referencesProvider:g,documentSymbolProvider:_,definitionProvider:v,typeDefinitionProvider:f,documentHighlightProvider:y,codeActionProvider:o,documentFormattingProvider:i,documentRangeFormattingProvider:i,documentOnTypeFormattingProvider:a,foldingRangeProvider:b,hoverProvider:x,renameProvider:S?{prepareProvider:!0}:void 0,semanticTokensProvider:s?c:void 0,signatureHelpProvider:d,implementationProvider:p,callHierarchyProvider:C?{}:void 0,typeHierarchyProvider:w?{}:void 0,documentLinkProvider:u?{resolveProvider:!1}:void 0,codeLensProvider:ee?{resolveProvider:!1}:void 0,declarationProvider:T,inlayHintProvider:E?{resolveProvider:!1}:void 0,workspaceSymbolProvider:D?{resolveProvider:!!D.resolveSymbol}:void 0}}}initialized(e){this.fireInitializedOnDefaultServices(e),this.onInitializedEmitter.fire(e),this.onInitializedEmitter.dispose()}fireInitializeOnDefaultServices(e){this.services.workspace.ConfigurationProvider.initialize(e),this.services.workspace.WorkspaceManager.initialize(e)}fireInitializedOnDefaultServices(e){let t=this.services.lsp.Connection,n=t?Object.assign(Object.assign({},e),{register:e=>t.client.register(al.DidChangeConfigurationNotification.type,e),fetchConfiguration:e=>t.workspace.getConfiguration(e)}):e;this.services.workspace.ConfigurationProvider.initialized(n).catch(e=>console.error(`Error in ConfigurationProvider initialization:`,e)),this.services.workspace.WorkspaceManager.initialized(e).catch(e=>console.error(`Error in WorkspaceManager initialization:`,e))}},sl=class{getSymbolKind(e){return J.SymbolKind.Field}getCompletionItemKind(e){return J.CompletionItemKind.Reference}},cl=class{constructor(e){this.nameProvider=e.references.NameProvider,this.references=e.references.References,this.grammarConfig=e.parser.GrammarConfig}findReferences(e,t,n){let r=e.parseResult.value.$cstNode;if(!r)return[];let i=_i(r,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);return i?this.getReferences(i,t,e):[]}getReferences(e,t,n){let r=[],i=this.references.findDeclaration(e);if(i){let e={includeDeclaration:t.context.includeDeclaration};this.references.findReferences(i,e).forEach(e=>{r.push(J.Location.create(e.sourceUri.toString(),e.segment.range))})}return r}};Ot();var ll=class{constructor(e){this.references=e.references.References,this.nameProvider=e.references.NameProvider,this.grammarConfig=e.parser.GrammarConfig}async rename(e,t,n){let r={},i=e.parseResult.value.$cstNode;if(!i)return;let a=_i(i,e.textDocument.offsetAt(t.position),this.grammarConfig.nameRegexp);if(!a)return;let o=this.references.findDeclaration(a);if(o)return this.references.findReferences(o,{onlyLocal:!1,includeDeclaration:!0}).forEach(e=>{let n=L.replace(e.segment.range,t.newName),i=e.sourceUri.toString();r[i]?r[i].push(n):r[i]=[n]}),{changes:r}}prepareRename(e,t,n){return this.renameNodeRange(e,t.position)}renameNodeRange(e,t){let n=e.parseResult.value.$cstNode,r=e.textDocument.offsetAt(t);if(n&&r){let e=_i(n,r,this.grammarConfig.nameRegexp);if(!e)return;if(this.references.findDeclaration(e)||this.isNameNode(e))return e.range}}isNameNode(e){return e?.astNode&&as(e.astNode)&&e===this.nameProvider.getNameNode(e.astNode)}},ul=class{constructor(e){this.indexManager=e.workspace.IndexManager,this.nodeKindProvider=e.lsp.NodeKindProvider,this.fuzzyMatcher=e.lsp.FuzzyMatcher}async getSymbols(e,t=Z.CancellationToken.None){let n=[],r=e.query.toLowerCase();for(let e of this.indexManager.allElements())if(await Q(t),this.fuzzyMatcher.match(r,e.name)){let t=this.getWorkspaceSymbol(e);t&&n.push(t)}return n}getWorkspaceSymbol(e){let t=e.nameSegment;if(t)return{kind:this.nodeKindProvider.getSymbolKind(e),name:e.name,location:{range:t.range,uri:e.documentUri.toString()}}}},dl=class{constructor(e){this._configuration=e,this._syncedDocuments=new Map,this._onDidChangeContent=new J.Emitter,this._onDidOpen=new J.Emitter,this._onDidClose=new J.Emitter,this._onDidSave=new J.Emitter,this._onWillSave=new J.Emitter}get onDidOpen(){return this._onDidOpen.event}get onDidChangeContent(){return this._onDidChangeContent.event}get onWillSave(){return this._onWillSave.event}onWillSaveWaitUntil(e){this._willSaveWaitUntil=e}get onDidSave(){return this._onDidSave.event}get onDidClose(){return this._onDidClose.event}get(e){return this._syncedDocuments.get(X.normalize(e))}set(e){let t=X.normalize(e.uri),n=!0;this._syncedDocuments.has(t)&&(n=!1),this._syncedDocuments.set(t,e);let r=Object.freeze({document:e});return this._onDidOpen.fire(r),this._onDidChangeContent.fire(r),n}delete(e){let t=X.normalize(typeof e==`object`&&`uri`in e?e.uri:e),n=this._syncedDocuments.get(t);n!==void 0&&(this._syncedDocuments.delete(t),this._onDidClose.fire(Object.freeze({document:n})))}all(){return Array.from(this._syncedDocuments.values())}keys(){return Array.from(this._syncedDocuments.keys())}listen(e){e.__textDocumentSync=J.TextDocumentSyncKind.Incremental;let t=[];return t.push(e.onDidOpenTextDocument(e=>{let t=e.textDocument,n=X.normalize(t.uri),r=this._configuration.create(n,t.languageId,t.version,t.text);this._syncedDocuments.set(n,r);let i=Object.freeze({document:r});this._onDidOpen.fire(i),this._onDidChangeContent.fire(i)})),t.push(e.onDidChangeTextDocument(e=>{let t=e.textDocument,n=e.contentChanges;if(n.length===0)return;let{version:r}=t;if(r==null)throw Error(`Received document change event for ${t.uri} without valid version identifier`);let i=X.normalize(t.uri),a=this._syncedDocuments.get(i);a!==void 0&&(a=this._configuration.update(a,n,r),this._syncedDocuments.set(i,a),this._onDidChangeContent.fire(Object.freeze({document:a})))})),t.push(e.onDidCloseTextDocument(e=>{let t=X.normalize(e.textDocument.uri),n=this._syncedDocuments.get(t);n!==void 0&&(this._syncedDocuments.delete(t),this._onDidClose.fire(Object.freeze({document:n})))})),t.push(e.onWillSaveTextDocument(e=>{let t=this._syncedDocuments.get(X.normalize(e.textDocument.uri));t!==void 0&&this._onWillSave.fire(Object.freeze({document:t,reason:e.reason}))})),t.push(e.onWillSaveTextDocumentWaitUntil((e,t)=>{let n=this._syncedDocuments.get(X.normalize(e.textDocument.uri));return n!==void 0&&this._willSaveWaitUntil?this._willSaveWaitUntil(Object.freeze({document:n,reason:e.reason}),t):[]})),t.push(e.onDidSaveTextDocument(e=>{let t=this._syncedDocuments.get(X.normalize(e.textDocument.uri));t!==void 0&&this._onDidSave.fire(Object.freeze({document:t}))})),J.Disposable.create(()=>{t.forEach(e=>e.dispose())})}},fl=class{constructor(e){this.notebookDocuments=new Map,this.notebookCellMap=new Map,this._onDidOpen=new J.Emitter,this._onDidSave=new J.Emitter,this._onDidChange=new J.Emitter,this._onDidClose=new J.Emitter,`listen`in e?this._cellTextDocuments=e:this._cellTextDocuments=new dl(e)}get cellTextDocuments(){return this._cellTextDocuments}getCellTextDocument(e){return this._cellTextDocuments.get(e.document)}getNotebookDocument(e){return this.notebookDocuments.get(X.normalize(e))}getNotebookCell(e){let t=this.notebookCellMap.get(X.normalize(e));return t&&t[0]}findNotebookDocumentForCell(e){let t=typeof e==`string`||`scheme`in e?e:e.document,n=this.notebookCellMap.get(X.normalize(t));return n&&n[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(e){let t=new pl,n=[];return n.push(this.cellTextDocuments.listen(t)),n.push(e.notebooks.synchronization.onDidOpenNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri);this.notebookDocuments.set(n,e.notebookDocument);for(let n of e.cellTextDocuments)t.openTextDocument({textDocument:n});this.updateCellMap(e.notebookDocument),this._onDidOpen.fire(e.notebookDocument)})),n.push(e.notebooks.synchronization.onDidChangeNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri),r=this.notebookDocuments.get(n);if(r===void 0)return;r.version=e.notebookDocument.version;let i=r.metadata,a=!1,o=e.change;o.metadata!==void 0&&(a=!0,r.metadata=o.metadata);let s=[],c=[],l=[],u=[];if(o.cells!==void 0){let e=o.cells;if(e.structure!==void 0){let n=e.structure.array;if(r.cells.splice(n.start,n.deleteCount,...n.cells===void 0?[]:n.cells),e.structure.didOpen!==void 0)for(let n of e.structure.didOpen)t.openTextDocument({textDocument:n}),s.push(n.uri);if(e.structure.didClose)for(let n of e.structure.didClose)t.closeTextDocument({textDocument:n}),c.push(n.uri)}if(e.data!==void 0){let t=new Map(e.data.map(e=>[e.document,e]));for(let e=0;e<=r.cells.length;e++){let n=t.get(r.cells[e].document);if(n!==void 0){let i=r.cells.splice(e,1,n);if(l.push({old:i[0],new:n}),t.delete(n.document),t.size===0)break}}}if(e.textContent!==void 0)for(let n of e.textContent)t.changeTextDocument({textDocument:n.document,contentChanges:n.changes}),u.push(n.document.uri)}this.updateCellMap(r);let d={notebookDocument:r};a&&(d.metadata={old:i,new:r.metadata});let f=[];for(let e of s)f.push(this.getNotebookCell(e));let p=[];for(let e of c)p.push(this.getNotebookCell(e));let m=[];for(let e of u)m.push(this.getNotebookCell(e));(f.length>0||p.length>0||l.length>0||m.length>0)&&(d.cells={added:f,removed:p,changed:{data:l,textContent:m}}),(d.metadata!==void 0||d.cells!==void 0)&&this._onDidChange.fire(d)})),n.push(e.notebooks.synchronization.onDidSaveNotebookDocument(e=>{let t=this.getNotebookDocument(e.notebookDocument.uri);t!==void 0&&this._onDidSave.fire(t)})),n.push(e.notebooks.synchronization.onDidCloseNotebookDocument(e=>{let n=X.normalize(e.notebookDocument.uri),r=this.notebookDocuments.get(n);if(r!==void 0){this._onDidClose.fire(r);for(let n of e.cellTextDocuments)t.closeTextDocument({textDocument:n});this.notebookDocuments.delete(n);for(let e of r.cells)this.notebookCellMap.delete(e.document)}})),J.Disposable.create(()=>{n.forEach(e=>e.dispose())})}updateCellMap(e){for(let t of e.cells)this.notebookCellMap.set(t.document,[t,e])}},pl=class e{onDidOpenTextDocument(e){return this.openHandler=e,J.Disposable.create(()=>{this.openHandler=void 0})}openTextDocument(e){this.openHandler&&this.openHandler(e)}onDidChangeTextDocument(e){return this.changeHandler=e,J.Disposable.create(()=>{this.changeHandler=e})}changeTextDocument(e){this.changeHandler&&this.changeHandler(e)}onDidCloseTextDocument(e){return this.closeHandler=e,J.Disposable.create(()=>{this.closeHandler=void 0})}closeTextDocument(e){this.closeHandler&&this.closeHandler(e)}onWillSaveTextDocument(){return e.NULL_DISPOSE}onWillSaveTextDocumentWaitUntil(){return e.NULL_DISPOSE}onDidSaveTextDocument(){return e.NULL_DISPOSE}};pl.NULL_DISPOSE=Object.freeze({dispose:()=>{}});function ml(e){return Cs.merge(Rc(e),hl(e))}function hl(e){return{lsp:{CompletionProvider:e=>new Qa(e),DocumentSymbolProvider:e=>new Vc(e),HoverProvider:e=>new Zc(e),FoldingRangeProvider:e=>new Uc(e),ReferencesProvider:e=>new cl(e),DefinitionProvider:e=>new to(e),DocumentHighlightProvider:e=>new Bc(e),RenameProvider:e=>new ll(e)},shared:()=>e.shared}}function gl(e){return Cs.merge(zc(e),_l(e))}function _l(e){return{lsp:{Connection:()=>e.connection,LanguageServer:e=>new ol(e),DocumentUpdateHandler:e=>new Hc(e),WorkspaceSymbolProvider:e=>new ul(e),NodeKindProvider:()=>new sl,FuzzyMatcher:()=>new Wc},workspace:{TextDocuments:()=>new dl(Xo),NotebookDocuments:e=>new fl(e.workspace.TextDocuments)}}}var vl=class{constructor(){this.collector=()=>{}}getNodeFormatter(e){return new yl(e,this.collector)}formatDocument(e,t){let n=e.parseResult;return n.lexerErrors.length===0&&n.parserErrors.length===0?this.doDocumentFormat(e,t.options):[]}isFormatRangeErrorFree(e,t){let n=e.parseResult;return n.lexerErrors.length||n.parserErrors.length?Math.min(...n.lexerErrors.map(e=>e.line??Number.MAX_VALUE),...n.parserErrors.map(e=>e.token.startLine??Number.MAX_VALUE))>t.end.line:!0}formatDocumentRange(e,t){return this.isFormatRangeErrorFree(e,t.range)?this.doDocumentFormat(e,t.options,t.range):[]}formatDocumentOnType(e,t){let n={start:{character:0,line:t.position.line},end:t.position};return this.isFormatRangeErrorFree(e,n)?this.doDocumentFormat(e,t.options,n):[]}get formatOnTypeOptions(){}doDocumentFormat(e,t,n){let r=new Map;this.collector=(e,t,n)=>{let i=this.nodeModeToKey(e,t),a=r.get(i),o=n.options.priority??0,s=a?.options.priority??0;(!a||s<=o)&&r.set(i,n)},this.iterateAstFormatting(e,n);let i=this.iterateCstFormatting(e,r,t,n);return this.avoidOverlappingEdits(e.textDocument,i)}avoidOverlappingEdits(e,t){let n=[];for(let r of t){let t=n[n.length-1];for(;t&&e.offsetAt(r.range.start)<e.offsetAt(t.range.end);)n.pop(),t=n[n.length-1];n.push(r)}return n.filter(t=>this.isNecessary(t,e))}iterateAstFormatting(e,t){let n=e.parseResult.value;this.format(n);let r=Pi(n).iterator(),i;do if(i=r.next(),!i.done){let e=i.value;this.insideRange(e.$cstNode.range,t)?this.format(e):r.prune()}while(!i.done)}nodeModeToKey(e,t){return`${e.offset}:${e.end}:${t}`}insideRange(e,t){return!t||e.start.line<=t.start.line&&e.end.line>=t.end.line||e.start.line>=t.start.line&&e.end.line<=t.end.line||e.start.line<=t.end.line&&e.end.line>=t.end.line}isNecessary(e,t){return e.newText!==t.getText(e.range).replace(/\r/g,``)}iterateCstFormatting(e,t,n,r){let i={indentation:0,options:n,document:e.textDocument},a=[],o=this.iterateCstTree(e,i).iterator(),s,c;do if(c=o.next(),!c.done){let e=c.value,n=kn(e),o=this.nodeModeToKey(e,`prepend`),l=t.get(o);if(t.delete(o),l){let t=this.createTextEdit(s,e,l,i);for(let e of t)e&&this.insideRange(e.range,r)&&a.push(e)}let u=this.nodeModeToKey(e,`append`),d=t.get(u);if(t.delete(u),d){let t=wi(e);if(t){let n=this.createTextEdit(e,t,d,i);for(let e of n)e&&this.insideRange(e.range,r)&&a.push(e)}}if(!l&&e.hidden){let t=this.createHiddenTextEdits(s,e,void 0,i);for(let e of t)e&&this.insideRange(e.range,r)&&a.push(e)}n&&(s=e)}while(!c.done);return a}createHiddenTextEdits(e,t,n,r){let i=t.range.start.line;if(e&&e.range.end.line===i)return[];let a=[],o={start:{character:0,line:i},end:t.range.start},s=r.document.getText(o),c=this.findFittingMove(o,n?.moves??[],r),l=this.getExistingIndentationCharacterCount(s,r),u=this.getIndentationCharacterCount(r,c)-l;if(u===0)return[];let d=``;u>0&&(d=(r.options.insertSpaces?` `:` `).repeat(u));let f=t.text.split(`
|
|
27
27
|
`);f[0]=s+f[0];for(let e=0;e<f.length;e++){let t=i+e,n={character:0,line:t};if(u>0)a.push({newText:d,range:{start:n,end:n}});else{let r=f[e],i=0;for(;i<r.length;i++){let e=r.charAt(i);if(e!==` `&&e!==` `)break}a.push({newText:``,range:{start:n,end:{line:t,character:Math.min(i,Math.abs(u))}}})}}return a}getExistingIndentationCharacterCount(e,t){let n=` `.repeat(t.options.tabSize);return(t.options.insertSpaces?e.replaceAll(` `,n):e.replaceAll(n,` `)).length}getIndentationCharacterCount(e,t){let n=e.indentation;return t&&t.tabs&&(n+=t.tabs),(e.options.insertSpaces?e.options.tabSize:1)*n}createTextEdit(e,t,n,r){if(t.hidden)return this.createHiddenTextEdits(e,t,n,r);if(e&&(e.range.end.line>t.range.start.line||e.range.end.line===t.range.start.line&&e.range.end.character>t.range.start.character))return[];let i={start:e?.range.end??{character:0,line:0},end:t.range.start},a=this.findFittingMove(i,n.moves,r);if(!a)return[];let o=a.characters,s=a.lines,c=a.tabs,l=r.indentation;r.indentation+=c??0;let u=[];return o===void 0?s===void 0?c!==void 0&&u.push(this.createTabTextEdit(i,!!e,r)):u.push(this.createLineTextEdit(i,s,r,n.options)):e?.hidden||u.push(this.createSpaceTextEdit(i,o,n.options)),kn(t)&&(r.indentation=l),u}createSpaceTextEdit(e,t,n){if(e.start.line===e.end.line){let r=e.end.character-e.start.character;t=this.fitIntoOptions(t,r,n)}return{newText:` `.repeat(t),range:e}}createLineTextEdit(e,t,n,r){let i=e.end.line-e.start.line;t=this.fitIntoOptions(t,i,r);let a=(n.options.insertSpaces?` `.repeat(n.options.tabSize):` `).repeat(n.indentation);return{newText:`${`
|
|
28
28
|
`.repeat(t)}${a}`,range:e}}createTabTextEdit(e,t,n){let r=(n.options.insertSpaces?` `.repeat(n.options.tabSize):` `).repeat(n.indentation),i=t?1:0,a=Math.max(e.end.line-e.start.line,i);return{newText:`${`
|
|
29
|
-
`.repeat(a)}${r}`,range:e}}fitIntoOptions(e,t,n){return n.allowMore?e=Math.max(t,e):n.allowLess&&(e=Math.min(t,e)),e}findFittingMove(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];let r=e.end.line-e.start.line;for(let e of t)if(e.lines!==void 0&&r<=e.lines)return e;else if(e.lines===void 0&&r===0)return e;return t[t.length-1]}iterateCstTree(e,t){let n=e.parseResult.value.$cstNode;return n?new oi(n,e=>this.iterateCst(e,t)):ai}iterateCst(e,t){if(!On(e))return ai;let n=t.indentation;return new ni(()=>({index:0}),r=>r.index<e.content.length?{done:!1,value:e.content[r.index++]}:(t.indentation=n,G))}},yl=class{constructor(e,t){this.astNode=e,this.collector=t}node(e){return new bl(e.$cstNode?[e.$cstNode]:[],this.collector)}nodes(...e){let t=[];for(let n of e)n.$cstNode&&t.push(n.$cstNode);return new bl(t,this.collector)}property(e,t){let n=ca(this.astNode.$cstNode,e,t);return new bl(n?[n]:[],this.collector)}properties(...e){let t=[];for(let n of e){let e=sa(this.astNode.$cstNode,n);t.push(...e)}return new bl(t,this.collector)}keyword(e,t){let n=da(this.astNode.$cstNode,e,t);return new bl(n?[n]:[],this.collector)}keywords(...e){let t=[];for(let n of e){let e=ua(this.astNode.$cstNode,n);t.push(...e)}return new bl(t,this.collector)}cst(e){return new bl([...e],this.collector)}interior(e,t){let n=e.nodes,r=t.nodes;if(n.length!==1||r.length!==1)return new bl([],this.collector);let i=n[0],a=r[0];if(i.offset>a.offset){let e=i;i=a,a=e}return new bl(Ti(i,a),this.collector)}},bl=class e{constructor(e,t){this.nodes=e,this.collector=t}prepend(e){for(let t of this.nodes)this.collector(t,`prepend`,e);return this}append(e){for(let t of this.nodes)this.collector(t,`append`,e);return this}surround(e){for(let t of this.nodes)this.collector(t,`prepend`,e),this.collector(t,`append`,e);return this}slice(t,n){return new e(this.nodes.slice(t,n),this.collector)}},xl;(function(e){function t(...e){return{options:{},moves:e.flatMap(e=>e.moves).sort(l)}}e.fit=t;function n(e){return i(0,e)}e.noSpace=n;function r(e){return i(1,e)}e.oneSpace=r;function i(e,t){return{options:t??{},moves:[{characters:e}]}}e.spaces=i;function a(e){return o(1,e)}e.newLine=a;function o(e,t){return{options:t??{},moves:[{lines:e}]}}e.newLines=o;function s(e){return{options:e??{},moves:[{tabs:1,lines:1}]}}e.indent=s;function c(e){return{options:e??{},moves:[{tabs:0}]}}e.noIndent=c;function l(e,t){let n=e.lines??0,r=t.lines??0,i=e.tabs??0,a=t.tabs??0,o=e.characters??0,s=t.characters??0;return n<r?-1:n>r?1:i<a?-1:i>a?1:o<s?-1:o>s?1:0}})(xl||={});var Sl=class{constructor(){this.encoding=`utf-8`}readFile(e){return _.promises.readFile(e.fsPath,this.encoding)}async readDirectory(e){return(await _.promises.readdir(e.fsPath,{withFileTypes:!0})).map(t=>({dirent:t,isFile:t.isFile(),isDirectory:t.isDirectory(),uri:X.joinPath(e,t.name)}))}};export{
|
|
29
|
+
`.repeat(a)}${r}`,range:e}}fitIntoOptions(e,t,n){return n.allowMore?e=Math.max(t,e):n.allowLess&&(e=Math.min(t,e)),e}findFittingMove(e,t,n){if(t.length===0)return;if(t.length===1)return t[0];let r=e.end.line-e.start.line;for(let e of t)if(e.lines!==void 0&&r<=e.lines)return e;else if(e.lines===void 0&&r===0)return e;return t[t.length-1]}iterateCstTree(e,t){let n=e.parseResult.value.$cstNode;return n?new oi(n,e=>this.iterateCst(e,t)):ai}iterateCst(e,t){if(!On(e))return ai;let n=t.indentation;return new ni(()=>({index:0}),r=>r.index<e.content.length?{done:!1,value:e.content[r.index++]}:(t.indentation=n,G))}},yl=class{constructor(e,t){this.astNode=e,this.collector=t}node(e){return new bl(e.$cstNode?[e.$cstNode]:[],this.collector)}nodes(...e){let t=[];for(let n of e)n.$cstNode&&t.push(n.$cstNode);return new bl(t,this.collector)}property(e,t){let n=ca(this.astNode.$cstNode,e,t);return new bl(n?[n]:[],this.collector)}properties(...e){let t=[];for(let n of e){let e=sa(this.astNode.$cstNode,n);t.push(...e)}return new bl(t,this.collector)}keyword(e,t){let n=da(this.astNode.$cstNode,e,t);return new bl(n?[n]:[],this.collector)}keywords(...e){let t=[];for(let n of e){let e=ua(this.astNode.$cstNode,n);t.push(...e)}return new bl(t,this.collector)}cst(e){return new bl([...e],this.collector)}interior(e,t){let n=e.nodes,r=t.nodes;if(n.length!==1||r.length!==1)return new bl([],this.collector);let i=n[0],a=r[0];if(i.offset>a.offset){let e=i;i=a,a=e}return new bl(Ti(i,a),this.collector)}},bl=class e{constructor(e,t){this.nodes=e,this.collector=t}prepend(e){for(let t of this.nodes)this.collector(t,`prepend`,e);return this}append(e){for(let t of this.nodes)this.collector(t,`append`,e);return this}surround(e){for(let t of this.nodes)this.collector(t,`prepend`,e),this.collector(t,`append`,e);return this}slice(t,n){return new e(this.nodes.slice(t,n),this.collector)}},xl;(function(e){function t(...e){return{options:{},moves:e.flatMap(e=>e.moves).sort(l)}}e.fit=t;function n(e){return i(0,e)}e.noSpace=n;function r(e){return i(1,e)}e.oneSpace=r;function i(e,t){return{options:t??{},moves:[{characters:e}]}}e.spaces=i;function a(e){return o(1,e)}e.newLine=a;function o(e,t){return{options:t??{},moves:[{lines:e}]}}e.newLines=o;function s(e){return{options:e??{},moves:[{tabs:1,lines:1}]}}e.indent=s;function c(e){return{options:e??{},moves:[{tabs:0}]}}e.noIndent=c;function l(e,t){let n=e.lines??0,r=t.lines??0,i=e.tabs??0,a=t.tabs??0,o=e.characters??0,s=t.characters??0;return n<r?-1:n>r?1:i<a?-1:i>a?1:o<s?-1:o>s?1:0}})(xl||={});var Sl=class{constructor(){this.encoding=`utf-8`}readFile(e){return _.promises.readFile(e.fsPath,this.encoding)}async readDirectory(e){return(await _.promises.readdir(e.fsPath,{withFileTypes:!0})).map(t=>({dirent:t,isFile:t.isFile(),isDirectory:t.isDirectory(),uri:X.joinPath(e,t.name)}))}};export{H as $,Q as A,$i as B,ds as C,as as D,os as E,Y as F,Pi as G,Ai as H,Qa as I,K as J,vi as K,da as L,Vo as M,Ho as N,ns as O,X as P,Dn as Q,ca as R,fs as S,cs as T,q as U,Oi as V,ji as W,Ir as X,Ar as Y,Hr as Z,ws as _,gl as a,F as at,_s as b,Xc as c,ct,kc as d,Ot as dt,Cn as et,Dc as f,k as ft,ac as g,hc as h,ml as i,Ie as it,qo as j,$ as k,Bc as l,Ye as lt,xc as m,vl as n,Fe as nt,ul as o,I as ot,Sc as p,ai as q,xl as r,me as rt,nl as s,lt as st,Sl as t,V as tt,Nc as u,L as ut,vs as v,us as w,ps as x,hs as y,sa as z};
|