MCPcopy
hub / github.com/google/adk-python / h

Class h

src/google/adk/cli/browser/chunk-NALL4A3P.js:151–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149`;return n=n+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
150For Further details.`,n}function gA(t){if(t instanceof pe)return"SUBRULE";if(t instanceof he)return"OPTION";if(t instanceof xe)return"OR";if(t instanceof Ae)return"AT_LEAST_ONE";if(t instanceof $e)return"AT_LEAST_ONE_SEP";if(t instanceof Re)return"MANY_SEP";if(t instanceof se)return"MANY";if(t instanceof te)return"CONSUME";throw Error("non exhaustive match")}function yA(t,e,r){let n=ht(e.configs.elements,s=>s.state.transitions),i=zh(n.filter(s=>s instanceof Xi).map(s=>s.tokenType),s=>s.tokenTypeIdx);return{actualToken:r,possibleTokenTypes:i,tokenPath:t}}function TA(t,e){return t.edges[e.tokenTypeIdx]}function RA(t,e,r){let n=new es,i=[];for(let a of t.elements){if(r.is(a.alt)===!1)continue;if(a.state.type===Qi){i.push(a);continue}let o=a.state.transitions.length;for(let c=0;c<o;c++){let l=a.state.transitions[c],u=xA(l,e);u!==void 0&&n.add({state:u,alt:a.alt,stack:a.stack})}}let s;if(i.length===0&&n.size===1&&(s=n),s===void 0){s=new es;for(let a of n.elements)Hc(a,s)}if(i.length>0&&!$A(s))for(let a of i)s.add(a);return s}function xA(t,e){if(t instanceof Xi&&xa(e,t.tokenType))return t.target}function vA(t,e){let r;for(let n of t.elements)if(e.is(n.alt)===!0){if(r===void 0)r=n.alt;else if(r!==n.alt)return}return r}function Ng(t){return{configs:t,edges:{},isAcceptState:!1,prediction:-1}}function kg(t,e,r,n){return n=Cg(t,n),e.edges[r.tokenTypeIdx]=n,n}function Cg(t,e){if(e===Pa)return e;let r=e.configs.key,n=t.states[r];return n!==void 0?n:(e.configs.finalize(),t.states[r]=e,e)}function EA(t){let e=new es,r=t.transitions.length;for(let n=0;n<r;n++){let s={state:t.transitions[n].target,alt:n,stack:[]};Hc(s,e)}return e}function Hc(t,e){let r=t.state;if(r.type===Qi){if(t.stack.length>0){let i=[...t.stack],a={state:i.pop(),alt:t.alt,stack:i};Hc(a,e)}else e.add(t);return}r.epsilonOnlyTransitions||e.add(t);let n=r.transitions.length;for(let i=0;i<n;i++){let s=r.transitions[i],a=AA(t,s);a!==void 0&&Hc(a,e)}}function AA(t,e){if(e instanceof ba)return{state:e.target,alt:t.alt,stack:t.stack};if(e instanceof Ji){let r=[...t.stack,e.followState];return{state:e.target,alt:t.alt,stack:r}}}function $A(t){for(let e of t.elements)if(e.state.type===Qi)return!0;return!1}function SA(t){for(let e of t.elements)if(e.state.type!==Qi)return!1;return!0}function kA(t){if(SA(t))return!0;let e=NA(t.elements);return CA(e)&&!wA(e)}function NA(t){let e=new Map;for(let r of t){let n=Lf(r,!1),i=e.get(n);i===void 0&&(i={},e.set(n,i)),i[r.alt]=!0}return e}function CA(t){for(let e of Array.from(t.values()))if(Object.keys(e).length>1)return!0;return!1}function wA(t){for(let e of Array.from(t.values()))if(Object.keys(e).length===1)return!0;return!1}as();var qa=class{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]??this.rootNode}buildRootNode(e){return this.rootNode=new os(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){let r=new si;return r.grammarSource=e,r.root=this.rootNode,this.current.content.push(r),this.nodeStack.push(r),r}buildLeafNode(e,r){let n=new ii(e.startOffset,e.image.length,Pi(e),e.tokenType,!r);return n.grammarSource=r,n.root=this.rootNode,this.current.content.push(n),n}removeNode(e){let r=e.container;if(r){let n=r.content.indexOf(e);n>=0&&r.content.splice(n,1)}}addHiddenNodes(e){let r=[];for(let s of e){let a=new ii(s.startOffset,s.image.length,Pi(s),s.tokenType,!0);a.root=this.rootNode,r.push(a)}let n=this.current,i=!1;if(n.content.length>0){n.content.push(...r);return}for(;n.container;){let s=n.container.content.indexOf(n);if(s>0){n.container.content.splice(s,0,...r),i=!0;break}n=n.container}i||this.rootNode.content.unshift(...r)}construct(e){let r=this.current;typeof e.$type=="string"&&!e.$infixName&&(this.current.astNode=e),e.$cstNode=r;let n=this.nodeStack.pop();n?.content.length===0&&this.removeNode(n)}},za=class{get hidden(){return!1}get astNode(){let e=typeof this._astNode?.$type=="string"?this._astNode:this.container?.astNode;if(!e)throw new Error("This node has no associated AST element");return e}set astNode(e){this._astNode=e}get text(){return this.root.fullText.substring(this.offset,this.end)}},ii=class extends za{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,r,n,i,s=!1){super(),this._hidden=s,this._offset=e,this._tokenType=i,this._length=r,this._range=n}},si=class extends za{constructor(){super(...arguments),this.content=new Sd(this)}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,r=this.lastNonHiddenNode;if(e&&r){if(this._rangeCache===void 0){let{range:n}=e,{range:i}=r;this._rangeCache={start:n.start,end:i.end.line<n.start.line?n.start:i.end}}return this._rangeCache}else return{start:ce.create(0,0),end:ce.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 r=this.content[e];if(!r.hidden)return r}return this.content[this.content.length-1]}},Sd=class t extends Array{constructor(e){super(),this.parent=e,Object.setPrototypeOf(this,t.prototype)}push(...e){return this.addParents(e),super.push(...e)}unshift(...e){return this.addParents(e),super.unshift(...e)}splice(e,r,...n){return this.addParents(n),super.splice(e,r,...n)}addParents(e){for(let r of e)r.container=this.parent}},os=class extends si{get text(){return this._text.substring(this.offset,this.end)}get fullText(){return this._text}constructor(e){super(),this._text="",this._text=e??""}};var sl=Symbol("Datatype");function kd(t){return t.$type===sl}var jg="\u200B",Bg=t=>t.endsWith(jg)?t:t+jg,ja=class{constructor(e){this._unorderedGroups=new Map,this.allRules=new Map,this.lexer=e.parser.Lexer;let r=this.lexer.definition,n=e.LanguageMetaData.mode==="production";e.shared.profilers.LangiumProfiler?.isActive("parsing")?this.wrapper=new Nd(r,er(ge({},e.parser.ParserConfig),{skipValidations:n,errorMessageProvider:e.parser.ParserErrorMessageProvider}),e.shared.profilers.LangiumProfiler.createTask("parsing",e.LanguageMetaData.languageId)):this.wrapper=new ol(r,er(ge({},e.parser.ParserConfig),{skipValidations:n,errorMessageProvider:e.parser.ParserErrorMessageProvider}))}alternatives(e,r){this.wrapper.wrapOr(e,r)}optional(e,r){this.wrapper.wrapOption(e,r)}many(e,r){this.wrapper.wrapMany(e,r)}atLeastOne(e,r){this.wrapper.wrapAtLeastOne(e,r)}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()}},Ba=class extends ja{get current(){return this.stack[this.stack.length-1]}constructor(e){super(e),this.nodeBuilder=new qa,this.stack=[],this.assignmentMap=new Map,this.operatorPrecedence=new Map,this.linker=e.references.Linker,this.converter=e.parser.ValueConverter,this.astReflection=e.shared.AstReflection}rule(e,r){let n=this.computeRuleType(e),i;dn(e)&&(i=e.name,this.registerPrecedenceMap(e));let s=this.wrapper.DEFINE_RULE(Bg(e.name),this.startImplementation(n,i,r).bind(this));return this.allRules.set(e.name,s),nt(e)&&e.entry&&(this.mainRule=s),s}registerPrecedenceMap(e){let r=e.name,n=new Map;for(let i=0;i<e.operators.precedences.length;i++){let s=e.operators.precedences[i];for(let a of s.operators)n.set(a.value,{precedence:i,rightAssoc:s.associativity==="right"})}this.operatorPrecedence.set(r,n)}computeRuleType(e){return dn(e)?hn(e):e.fragment?void 0:ha(e)?sl:hn(e)}parse(e,r={}){this.nodeBuilder.buildRootNode(e);let n=this.lexerResult=this.lexer.tokenize(e);this.wrapper.input=n.tokens;let i=r.rule?this.allRules.get(r.rule):this.mainRule;if(!i)throw new Error(r.rule?`No rule found with name '${r.rule}'`:"No main rule available.");let s=this.doParse(i);return this.nodeBuilder.addHiddenNodes(n.hidden),this.unorderedGroups.clear(),this.lexerResult=void 0,Ai(s,{deep:!0}),{value:s,lexerErrors:n.errors,lexerReport:n.report,parserErrors:this.wrapper.errors}}doParse(e){let r=this.wrapper.rule(e);if(this.stack.length>0&&(r=this.construct()),r===void 0)throw new Error("No result from parser");if(this.stack.length>0)throw new Error("Parser stack is not empty after parsing");return r}startImplementation(e,r,n){return i=>{let s=!this.isRecording()&&e!==void 0;if(s){let a={$type:e};this.stack.push(a),e===sl?a.value="":r!==void 0&&(a.$infixName=r)}return n(i),s?this.construct():void 0}}extractHiddenTokens(e){let r=this.lexerResult.hidden;if(!r.length)return[];let n=e.startOffset;for(let i=0;i<r.length;i++)if(r[i].startOffset>n)return r.splice(0,i);return r.splice(0,r.length)}consume(e,r,n){let i=this.wrapper.wrapConsume(e,r);if(!this.isRecording()&&this.isValidToken(i)){let s=this.extractHiddenTokens(i);this.nodeBuilder.addHiddenNodes(s);let a=this.nodeBuilder.buildLeafNode(i,n),{assignment:o,crossRef:c}=this.getAssignment(n),l=this.current;if(o){let u=Ht(n)?i.image:this.converter.convert(i.image,a);this.assign(o.operator,o.feature,u,a,c)}else if(kd(l)){let u=i.image;Ht(n)||(u=this.converter.convert(u,a).toString()),l.value+=u}}}isValidToken(e){return!e.isInsertedInRecovery&&!isNaN(e.startOffset)&&typeof e.endOffset=="number"&&!isNaN(e.endOffset)}subrule(e,r,n,i,s){let a;!this.isRecording()&&!n&&(a=this.nodeBuilder.buildCompositeNode(i));let o;try{o=this.wrapper.wrapSubrule(e,r,s)}finally{this.isRecording()||(o===void 0&&!n&&(o=this.construct()),o!==void 0&&a&&a.length>0&&this.performSubruleAssignment(o,i,a))}}performSubruleAssignment(e,r,n){let{assignment:i,crossRef:s}=this.getAssignment(r);if(i)this.assign(i.operator,i.feature,e,n,s);else if(!i){let a=this.current;if(kd(a))a.value+=e.toString();else if(typeof e=="object"&&e){let c=this.assignWithoutOverride(e,a);this.stack.pop(),this.stack.push(c)}}}action(e,r){if(!this.isRecording()){let n=this.current;if(r.feature&&r.operator){n=this.construct(),this.nodeBuilder.removeNode(n.$cstNode),this.nodeBuilder.buildCompositeNode(r).content.push(n.$cstNode);let s={$type:e};this.stack.push(s),this.assign(r.operator,r.feature,n,n.$cstNode)}else n.$type=e}}construct(){if(this.isRecording())return;let e=this.stack.pop();return this.nodeBuilder.construct(e),"$infixName"in e?this.constructInfix(e,this.operatorPrecedence.get(e.$infixName)):kd(e)?this.converter.convert(e.value,e.$cstNode):(Tu(this.astReflection,e),e)}constructInfix(e,r){let n=e.parts;if(!Array.isArray(n)||n.length===0)return;let i=e.operators;if(!Array.isArray(i)||n.length<2)return n[0];let s=0,a=-1;for(let k=0;k<i.length;k++){let G=i[k],M=r.get(G)??{precedence:1/0,rightAssoc:!1};M.precedence>a?(a=M.precedence,s=k):M.precedence===a&&(M.rightAssoc||(s=k))}let o=i.slice(0,s),c=i.slice(s+1),l=n.slice(0,s+1),u=n.slice(s+1),p={$infixName:e.$infixName,$type:e.$type,$cstNode:e.$cstNode,parts:l,operators:o},h={$infixName:e.$infixName,$type:e.$type,$cstNode:e.$cstNode,parts:u,operators:c},g=this.constructInfix(p,r),C=this.constructInfix(h,r);return{$type:e.$type,$cstNode:e.$cstNode,left:g,operator:i[s],right:C}}getAssignment(e){if(!this.assignmentMap.has(e)){let r=Dr(e,sr);this.assignmentMap.set(e,{assignment:r,crossRef:r&&ar(r.terminal)?r.terminal.isMulti?"multi":"single":void 0})}return this.assignmentMap.get(e)}assign(e,r,n,i,s){let a=this.current,o;switch(s==="single"&&typeof n=="string"?o=this.linker.buildReference(a,r,i,n):s==="multi"&&typeof n=="string"?o=this.linker.buildMultiReference(a,r,i,n):o=n,e){case"=":{a[r]=o;break}case"?=":{a[r]=!0;break}case"+=":Array.isArray(a[r])||(a[r]=[]),a[r].push(o)}}assignWithoutOverride(e,r){for(let[i,s]of Object.entries(r)){let a=e[i];a===void 0?e[i]=s:Array.isArray(a)&&Array.isArray(s)&&(s.push(...a),e[i]=s)}let n=e.$cstNode;return n&&(n.astNode=void 0,e.$cstNode=void 0),e}get definitionErrors(){return this.wrapper.definitionErrors}},al=class{buildMismatchTokenMessage(e){return Hr.buildMismatchTokenMessage(e)}buildNotAllInputParsedMessage(e){return Hr.buildNotAllInputParsedMessage(e)}buildNoViableAltMessage(e){return Hr.buildNoViableAltMessage(e)}buildEarlyExitMessage(e){return Hr.buildEarlyExitMessage(e)}},cs=class extends al{buildMismatchTokenMessage({expected:e,actual:r}){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 \`${r.image}\`.`}buildNotAllInputParsedMessage({firstRedundant:e}){return`Expecting end of file but found \`${e.image}\`.`}},Wa=class extends ja{constructor(){super(...arguments),this.tokens=[],this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}action(){}construct(){}parse(e){this.resetState();let r=this.lexer.tokenize(e,{mode:"partial"});return this.tokens=r.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,r){let n=this.wrapper.DEFINE_RULE(Bg(e.name),this.startImplementation(r).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 r=>{let n=this.keepStackSize();try{e(r)}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,r,n){this.wrapper.wrapConsume(e,r),this.isRecording()||(this.lastElementStack=[...this.elementStack,n],this.nextTokenIndex=this.currIdx+1)}subrule(e,r,n,i,s){this.before(i),this.wrapper.wrapSubrule(e,r,s),this.after(i)}before(e){this.isRecording()||this.elementStack.push(e)}after(e){if(!this.isRecording()){let r=this.elementStack.lastIndexOf(e);r>=0&&this.elementStack.splice(r)}}get currIdx(){return this.wrapper.currIdx}},_A={recoveryEnabled:!0,nodeLocationTracking:"full",skipValidations:!0,errorMessageProvider:new cs},ol=class extends Ia{constructor(e,r){let n=r&&"maxLookahead"in r;super(e,ge(er(ge({},_A),{lookaheadStrategy:n?new Yr({maxLookahead:r.maxLookahead}):new Oa({logging:r.skipValidations?()=>{}:void 0})}),r))}get IS_RECORDING(){return this.RECORDING_PHASE}DEFINE_RULE(e,r,n){return this.RULE(e,r,n)}wrapSelfAnalysis(){this.performSelfAnalysis()}wrapConsume(e,r){return this.consume(e,r,void 0)}wrapSubrule(e,r,n){return this.subrule(e,r,{ARGS:[n]})}wrapOr(e,r){this.or(e,r)}wrapOption(e,r){this.option(e,r)}wrapMany(e,r){this.many(e,r)}wrapAtLeastOne(e,r){this.atLeastOne(e,r)}rule(e){return e.call(this,{})}},Nd=class extends ol{constructor(e,r,n){super(e,r),this.task=n}rule(e){this.task.start(),this.task.startSubTask(this.ruleName(e));try{return super.rule(e)}finally{this.task.stopSubTask(this.ruleName(e)),this.task.stop()}}ruleName(e){return e.ruleName}subrule(e,r,n){this.task.startSubTask(this.ruleName(r));try{return super.subrule(e,r,n)}finally{this.task.stopSubTask(this.ruleName(r))}}};function Va(t,e,r){return bA({parser:e,tokens:r,ruleNames:new Map},t),e}function bA(t,e){let r=da(e,!1),n=ee(e.rules).filter(nt).filter(s=>r.has(s));for(let s of n){let a=er(ge({},t),{consume:1,optional:1,subrule:1,many:1,or:1});t.parser.rule(s,ai(a,s.definition))}let i=ee(e.rules).filter(dn).filter(s=>r.has(s));for(let s of i)t.parser.rule(s,PA(t,s))}function PA(t,e){let r=e.call.rule.ref;if(!r)throw new Error("Could not resolve reference to infix operator rule: "+e.call.rule.$refText);if(kt(r))throw new Error("Cannot use terminal rule in infix expression");let n=e.operators.precedences.flatMap(g=>g.operators),i={$type:"Group",elements:[]},s={$container:i,$type:"Assignment",feature:"parts",operator:"+=",terminal:e.call},a={$container:i,$type:"Group",elements:[],cardinality:"*"};i.elements.push(s,a);let c={$container:a,$type:"Assignment",feature:"operators",operator:"+=",terminal:{$type:"Alternatives",elements:n}},l=er(ge({},s),{$container:a});a.elements.push(c,l);let p=n.map(g=>t.tokens[g.value]).map((g,C)=>({ALT:()=>t.parser.consume(C,g,c)})),h;return g=>{h??(h=wd(t,r)),t.parser.subrule(0,h,!1,s,g),t.parser.many(0,{DEF:()=>{t.parser.alternatives(0,p),t.parser.subrule(1,h,!1,l,g)}})}}function ai(t,e,r=!1){let n;if(Ht(e))n=UA(t,e);else if(Ur(e))n=OA(t,e);else if(sr(e))n=ai(t,e.terminal);else if(ar(e))n=Wg(t,e);else if(or(e))n=LA(t,e);else if(ec(e))n=MA(t,e);else if(ic(e))n=FA(t,e);else if(fn(e))n=GA(t,e);else if(Su(e)){let i=t.consume++;n=()=>t.parser.consume(i,Bt,e)}else throw new Vn(e.$cstNode,`Unexpected element type: ${e.$type}`);return Vg(t,r?void 0:cl(e),n,e.cardinality)}function OA(t,e){let r=hn(e);return()=>t.parser.action(r,e)}function LA(t,e){let r=e.rule.ref;if(Gr(r)){let n=t.subrule++,i=nt(r)&&r.fragment,s=e.arguments.length>0?DA(r,e.arguments):()=>({}),a;return o=>{a??(a=wd(t,r)),t.parser.subrule(n,a,i,e,s(o))}}else if(kt(r)){let n=t.consume++,i=Cd(t,r.name);return()=>t.parser.consume(n,i,e)}else if(r)Rr(r);else throw new Vn(e.$cstNode,`Undefined rule: ${e.rule.$refText}`)}function DA(t,e){if(e.some(n=>n.calledByName)){let n=e.map(i=>({parameterName:i.parameter?.ref?.name,predicate:Ar(i.value)}));return i=>{let s={};for(let{parameterName:a,predicate:o}of n)a&&(s[a]=o(i));return s}}else{let n=e.map(i=>Ar(i.value));return i=>{let s={};for(let a=0;a<n.length;a++)if(a<t.parameters.length){let o=t.parameters[a].name,c=n[a];s[o]=c(i)}return s}}}function Ar(t){if($u(t)){let e=Ar(t.left),r=Ar(t.right);return n=>e(n)||r(n)}else if(Au(t)){let e=Ar(t.left),r=Ar(t.right);return n=>e(n)&&r(n)}else if(Cu(t)){let e=Ar(t.value);return r=>!e(r)}else if(wu(t)){let e=t.parameter.ref.name;return r=>r!==void 0&&r[e]===!0}else if(vu(t)){let e=!!t.true;return()=>e}Rr(t)}function MA(t,e){if(e.elements.length===1)return ai(t,e.elements[0]);{let r=[];for(let i of e.elements){let s={ALT:ai(t,i,!0)},a=cl(i);a&&(s.GATE=Ar(a)),r.push(s)}let n=t.or++;return i=>t.parser.alternatives(n,r.map(s=>{let a={ALT:()=>s.ALT(i)},o=s.GATE;return o&&(a.GATE=()=>o(i)),a}))}}function FA(t,e){if(e.elements.length===1)return ai(t,e.elements[0]);let r=[];for(let o of e.elements){let c={ALT:ai(t,o,!0)},l=cl(o);l&&(c.GATE=Ar(l)),r.push(c)}let n=t.or++,i=(o,c)=>{let l=c.getRuleStack().join("-");return`uGroup_${o}_${l}`},s=o=>t.parser.alternatives(n,r.map((c,l)=>{let u={ALT:()=>!0},p=t.parser;u.ALT=()=>{if(c.ALT(o),!p.isRecording()){let g=i(n,p);p.unorderedGroups.get(g)||p.unorderedGroups.set(g,[]);let C=p.unorderedGroups.get(g);typeof C?.[l]>"u"&&(C[l]=!0)}};let h=c.GATE;return h?u.GATE=()=>h(o):u.GATE=()=>!p.unorderedGroups.get(i(n,p))?.[l],u})),a=Vg(t,cl(e),s,"*");return o=>{a(o),t.parser.isRecording()||t.parser.unorderedGroups.delete(i(n,t.parser))}}function GA(t,e){let r=e.elements.map(n=>ai(t,n));return n=>r.forEach(i=>i(n))}function cl(t){if(fn(t))return t.guardCondition}function Wg(t,e,r=e.terminal){if(r)if(or(r)&&nt(r.rule.ref)){let n=r.rule.ref,i=t.subrule++,s;return a=>{s??(s=wd(t,n)),t.parser.subrule(i,s,!1,e,a)}}else if(or(r)&&kt(r.rule.ref)){let n=t.consume++,i=Cd(t,r.rule.ref.name);return()=>t.parser.consume(n,i,e)}else if(Ht(r)){let n=t.consume++,i=Cd(t,r.value);return()=>t.parser.consume(n,i,e)}else throw new Error("Could not build cross reference parser");else{if(!e.type.ref)throw new Error("Could not resolve reference to type: "+e.type.$refText);let i=uc(e.type.ref)?.terminal;if(!i)throw new Error("Could not find name assignment for type: "+hn(e.type.ref));return Wg(t,e,i)}}function UA(t,e){let r=t.consume++,n=t.tokens[e.value];if(!n)throw new Error("Could not find token for keyword: "+e.value);return()=>t.parser.consume(r,n,e)}function Vg(t,e,r,n){let i=e&&Ar(e);if(!n)if(i){let s=t.or++;return a=>t.parser.alternatives(s,[{ALT:()=>r(a),GATE:()=>i(a)},{ALT:Vc(),GATE:()=>!i(a)}])}else return r;if(n==="*"){let s=t.many++;return a=>t.parser.many(s,{DEF:()=>r(a),GATE:i?()=>i(a):void 0})}else if(n==="+"){let s=t.many++;if(i){let a=t.or++;return o=>t.parser.alternatives(a,[{ALT:()=>t.parser.atLeastOne(s,{DEF:()=>r(o)}),GATE:()=>i(o)},{ALT:Vc(),GATE:()=>!i(o)}])}else return a=>t.parser.atLeastOne(s,{DEF:()=>r(a)})}else if(n==="?"){let s=t.optional++;return a=>t.parser.optional(s,{DEF:()=>r(a),GATE:i?()=>i(a):void 0})}else Rr(n)}function wd(t,e){let r=qA(t,e),n=t.parser.getRule(r);if(!n)throw new Error(`Rule "${r}" not found."`);return n}function qA(t,e){if(Gr(e))return e.name;if(t.ruleNames.has(e))return t.ruleNames.get(e);{let r=e,n=r.$container,i=e.$type;for(;!nt(n);)(fn(n)||ec(n)||ic(n))&&(i=n.elements.indexOf(r).toString()+":"+i),r=n,n=n.$container;return i=n.name+":"+i,t.ruleNames.set(e,i),i}}function Cd(t,e){let r=t.tokens[e];if(!r)throw new Error(`Token "${e}" not found."`);return r}function Id(t){let e=t.Grammar,r=t.parser.Lexer,n=new Wa(t);return Va(e,n,r.definition),n.finalize(),n}function _d(t){let e=Kg(t);return e.finalize(),e}function Kg(t){let e=t.Grammar,r=t.parser.Lexer,n=new Ba(t);return Va(e,n,r.definition)}var Jr=class{constructor(){this.diagnostics=[]}buildTokens(e,r){let n=ee(da(e,!1)),i=this.buildTerminalTokens(n),s=this.buildKeywordTokens(n,i,r);return s.push(...i),s}flushLexingReport(e){return{diagnostics:this.popDiagnostics()}}popDiagnostics(){let e=[...this.diagnostics];return this.diagnostics=[],e}buildTerminalTokens(e){return e.filter(kt).filter(r=>!r.fragment).map(r=>this.buildTerminalToken(r)).toArray()}buildTerminalToken(e){let r=Li(e),n=this.requiresCustomPattern(r)?this.regexPatternFunction(r):r,i={name:e.name,PATTERN:n};return typeof n=="function"&&(i.LINE_BREAKS=!0),e.hidden&&(i.GROUP=fa(r)?He.SKIPPED:"hidden"),i}requiresCustomPattern(e){return!!(e.flags.includes("u")||e.flags.includes("s"))}regexPatternFunction(e){let r=new RegExp(e,e.flags+"y");return(n,i)=>(r.lastIndex=i,r.exec(n))}buildKeywordTokens(e,r,n){return e.filter(Gr).flatMap(i=>nr(i).filter(Ht)).distinct(i=>i.value).toArray().sort((i,s)=>s.value.length-i.value.length).map(i=>this.buildKeywordToken(i,r,!!n?.caseInsensitive))}buildKeywordToken(e,r,n){let i=this.buildKeywordPattern(e,n),s={name:e.value,PATTERN:i,LONGER_ALT:this.findLongerAlt(e,r)};return typeof i=="function"&&(s.LINE_BREAKS=!0),s}buildKeywordPattern(e,r){return r?new RegExp(pn(e.value),"i"):e.value}findLongerAlt(e,r){return r.reduce((n,i)=>{let s=i?.PATTERN;return s?.source&&Ku("^"+s.source+"$",e.value)&&n.push(i),n},[])}};var oi=class{convert(e,r){let n=r.grammarSource;if(ar(n)&&(n=Xu(n)),or(n)){let i=n.rule.ref;if(!i)throw new Error("This cst node was not parsed by a rule.");return this.runConverter(i,e,r)}return e}runConverter(e,r,n){switch(e.name.toUpperCase()){case"INT":return $r.convertInt(r);case"STRING":return $r.convertString(r);case"ID":return $r.convertID(r)}switch(nf(e)?.toLowerCase()){case"number":return $r.convertNumber(r);case"boolean":return $r.convertBoolean(r);case"bigint":return $r.convertBigint(r);case"date":return $r.convertDate(r);default:return r}}},$r;(function(t){function e(l){let u="";for(let p=1;p<l.length-1;p++){let h=l.charAt(p);if(h==="\\"){let g=l.charAt(++p);u+=r(g)}else u+=h}return u}t.convertString=e;function r(l){switch(l){case"b":return"\b";case"f":return"\f";case"n":return`
151`;case"r":return"\r";case"t":return" ";case"v":return"\v";case"0":return"\0";default:return l}}function n(l){return l.charAt(0)==="^"?l.substring(1):l}t.convertID=n;function i(l){return parseInt(l)}t.convertInt=i;function s(l){return BigInt(l)}t.convertBigint=s;function a(l){return new Date(l)}t.convertDate=a;function o(l){return Number(l)}t.convertNumber=o;function c(l){return l.toLowerCase()==="true"}t.convertBoolean=c})($r||($r={}));var W={};ae(W,du(Ka(),1));function Fd(){return new Promise(t=>{typeof setImmediate>"u"?setTimeout(t,0):setImmediate(t)})}var dl=0,Jg=10;function pl(){return dl=performance.now(),new W.CancellationTokenSource}function Qg(t){Jg=t}var Yt=Symbol("OperationCancelled");function Sr(t){return t===Yt}function Me(t){return P(this,null,function*(){if(t===W.CancellationToken.None)return;let e=performance.now();if(e-dl>=Jg&&(dl=e,yield Fd(),dl=performance.now()),t.isCancellationRequested)throw Yt})}var It=class{constructor(){this.promise=new Promise((e,r)=>{this.resolve=n=>(e(n),this),this.reject=n=>(r(n),this)})}};var hl=class t{constructor(e,r,n,i){this._uri=e,this._languageId=r,this._version=n,this._content=i,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let r=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(r,n)}return this._content}update(e,r){for(let n of e)if(t.isIncremental(n)){let i=ty(n.range),s=this.offsetAt(i.start),a=this.offsetAt(i.end);this._content=this._content.substring(0,s)+n.text+this._content.substring(a,this._content.length);let o=Math.max(i.start.line,0),c=Math.max(i.end.line,0),l=this._lineOffsets,u=Zg(n.text,!1,s);if(c-o===u.length)for(let h=0,g=u.length;h<g;h++)l[h+o+1]=u[h];else u.length<1e4?l.splice(o+1,c-o,...u):this._lineOffsets=l=l.slice(0,o+1).concat(u,l.slice(c+1));let p=n.text.length-(a-s);if(p!==0)for(let h=o+1+u.length,g=l.length;h<g;h++)l[h]=l[h]+p}else if(t.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=r}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=Zg(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let r=this.getLineOffsets(),n=0,i=r.length;if(i===0)return{line:0,character:e};for(;n<i;){let a=Math.floor((n+i)/2);r[a]>e?i=a:n=a+1}let s=n-1;return e=this.ensureBeforeEOL(e,r[s]),{line:s,character:e-r[s]}}offsetAt(e){let r=this.getLineOffsets();if(e.line>=r.length)return this._content.length;if(e.line<0)return 0;let n=r[e.line];if(e.character<=0)return n;let i=e.line+1<r.length?r[e.line+1]:this._content.length,s=Math.min(n+e.character,i);return this.ensureBeforeEOL(s,n)}ensureBeforeEOL(e,r){for(;e>r&&ey(this._content.charCodeAt(e-1));)e--;return e}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let r=e;return r!=null&&typeof r.text=="string"&&r.range!==void 0&&(r.rangeLength===void 0||typeof r.rangeLength=="number")}static isFull(e){let r=e;return r!=null&&typeof r.text=="string"&&r.range===void 0&&r.rangeLength===void 0}},ds;(function(t){function e(i,s,a,o){return new hl(i,s,a,o)}t.create=e;function r(i,s,a){if(i instanceof hl)return i.update(s,a),i;throw new Error("TextDocument.update: document must be created by TextDocument.create")}t.update=r;function n(i,s){let a=i.getText(),o=Gd(s.map(JA),(u,p)=>{let h=u.range.start.line-p.range.start.line;return h===0?u.range.start.character-p.range.start.character:h}),c=0,l=[];for(let u of o){let p=i.offsetAt(u.range.start);if(p<c)throw new Error("Overlapping edit");p>c&&l.push(a.substring(c,p)),u.newText.length&&l.push(u.newText),c=i.offsetAt(u.range.end)}return l.push(a.substr(c)),l.join("")}t.applyEdits=n})(ds||(ds={}));function Gd(t,e){if(t.length<=1)return t;let r=t.length/2|0,n=t.slice(0,r),i=t.slice(r);Gd(n,e),Gd(i,e);let s=0,a=0,o=0;for(;s<n.length&&a<i.length;)e(n[s],i[a])<=0?t[o++]=n[s++]:t[o++]=i[a++];for(;s<n.length;)t[o++]=n[s++];for(;a<i.length;)t[o++]=i[a++];return t}function Zg(t,e,r=0){let n=e?[r]:[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);ey(s)&&(s===13&&i+1<t.length&&t.charCodeAt(i+1)===10&&i++,n.push(r+i+1))}return n}function ey(t){return t===13||t===10}function ty(t){let e=t.start,r=t.end;return e.line>r.line||e.line===r.line&&e.character>r.character?{start:r,end:e}:t}function JA(t){let e=ty(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var ry;(()=>{"use strict";var t={975:$=>{function y(T){if(typeof T!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(T))}function L(T,x){for(var A,_="",U=0,N=-1,Y=0,Q=0;Q<=T.length;++Q){if(Q<T.length)A=T.charCodeAt(Q);else{if(A===47)break;A=47}if(A===47){if(!(N===Q-1||Y===1))if(N!==Q-1&&Y===2){if(_.length<2||U!==2||_.charCodeAt(_.length-1)!==46||_.charCodeAt(_.length-2)!==46){if(_.length>2){var de=_.lastIndexOf("/");if(de!==_.length-1){de===-1?(_="",U=0):U=(_=_.slice(0,de)).length-1-_.lastIndexOf("/"),N=Q,Y=0;continue}}else if(_.length===2||_.length===1){_="",U=0,N=Q,Y=0;continue}}x&&(_.length>0?_+="/..":_="..",U=2)}else _.length>0?_+="/"+T.slice(N+1,Q):_=T.slice(N+1,Q),U=Q-N-1;N=Q,Y=0}else A===46&&Y!==-1?++Y:Y=-1}return _}var O={resolve:function(){for(var T,x="",A=!1,_=arguments.length-1;_>=-1&&!A;_--){var U;_>=0?U=arguments[_]:(T===void 0&&(T=process.cwd()),U=T),y(U),U.length!==0&&(x=U+"/"+x,A=U.charCodeAt(0)===47)}return x=L(x,!A),A?x.length>0?"/"+x:"/":x.length>0?x:"."},normalize:function(T){if(y(T),T.length===0)return".";var x=T.charCodeAt(0)===47,A=T.charCodeAt(T.length-1)===47;return(T=L(T,!x)).length!==0||x||(T="."),T.length>0&&A&&(T+="/"),x?"/"+T:T},isAbsolute:function(T){return y(T),T.length>0&&T.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var T,x=0;x<arguments.length;++x){var A=arguments[x];y(A),A.length>0&&(T===void 0?T=A:T+="/"+A)}return T===void 0?".":O.normalize(T)},relative:function(T,x){if(y(T),y(x),T===x||(T=O.resolve(T))===(x=O.resolve(x)))return"";for(var A=1;A<T.length&&T.charCodeAt(A)===47;++A);for(var _=T.length,U=_-A,N=1;N<x.length&&x.charCodeAt(N)===47;++N);for(var Y=x.length-N,Q=U<Y?U:Y,de=-1,ue=0;ue<=Q;++ue){if(ue===Q){if(Y>Q){if(x.charCodeAt(N+ue)===47)return x.slice(N+ue+1);if(ue===0)return x.slice(N+ue)}else U>Q&&(T.charCodeAt(A+ue)===47?de=ue:ue===0&&(de=0));break}var ve=T.charCodeAt(A+ue);if(ve!==x.charCodeAt(N+ue))break;ve===47&&(de=ue)}var We="";for(ue=A+de+1;ue<=_;++ue)ue!==_&&T.charCodeAt(ue)!==47||(We.length===0?We+="..":We+="/..");return We.length>0?We+x.slice(N+de):(N+=de,x.charCodeAt(N)===47&&++N,x.slice(N))},_makeLong:function(T){return T},dirname:function(T){if(y(T),T.length===0)return".";for(var x=T.charCodeAt(0),A=x===47,_=-1,U=!0,N=T.length-1;N>=1;--N)if((x=T.charCodeAt(N))===47){if(!U){_=N;break}}else U=!1;return _===-1?A?"/":".":A&&_===1?"//":T.slice(0,_)},basename:function(T,x){if(x!==void 0&&typeof x!="string")throw new TypeError('"ext" argument must be a string');y(T);var A,_=0,U=-1,N=!0;if(x!==void 0&&x.length>0&&x.length<=T.length){if(x.length===T.length&&x===T)return"";var Y=x.length-1,Q=-1;for(A=T.length-1;A>=0;--A){var de=T.charCodeAt(A);if(de===47){if(!N){_=A+1;break}}else Q===-1&&(N=!1,Q=A+1),Y>=0&&(de===x.charCodeAt(Y)?--Y==-1&&(U=A):(Y=-1,U=Q))}return _===U?U=Q:U===-1&&(U=T.length),T.slice(_,U)}for(A=T.length-1;A>=0;--A)if(T.charCodeAt(A)===47){if(!N){_=A+1;break}}else U===-1&&(N=!1,U=A+1);return U===-1?"":T.slice(_,U)},extname:function(T){y(T);for(var x=-1,A=0,_=-1,U=!0,N=0,Y=T.length-1;Y>=0;--Y){var Q=T.charCodeAt(Y);if(Q!==47)_===-1&&(U=!1,_=Y+1),Q===46?x===-1?x=Y:N!==1&&(N=1):x!==-1&&(N=-1);else if(!U){A=Y+1;break}}return x===-1||_===-1||N===0||N===1&&x===_-1&&x===A+1?"":T.slice(x,_)},format:function(T){if(T===null||typeof T!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof T);return(function(x,A){var _=A.dir||A.root,U=A.base||(A.name||"")+(A.ext||"");return _?_===A.root?_+U:_+"/"+U:U})(0,T)},parse:function(T){y(T);var x={root:"",dir:"",base:"",ext:"",name:""};if(T.length===0)return x;var A,_=T.charCodeAt(0),U=_===47;U?(x.root="/",A=1):A=0;for(var N=-1,Y=0,Q=-1,de=!0,ue=T.length-1,ve=0;ue>=A;--ue)if((_=T.charCodeAt(ue))!==47)Q===-1&&(de=!1,Q=ue+1),_===46?N===-1?N=ue:ve!==1&&(ve=1):N!==-1&&(ve=-1);else if(!de){Y=ue+1;break}return N===-1||Q===-1||ve===0||ve===1&&N===Q-1&&N===Y+1?Q!==-1&&(x.base=x.name=Y===0&&U?T.slice(1,Q):T.slice(Y,Q)):(Y===0&&U?(x.name=T.slice(1,N),x.base=T.slice(1,Q)):(x.name=T.slice(Y,N),x.base=T.slice(Y,Q)),x.ext=T.slice(N,Q)),Y>0?x.dir=T.slice(0,Y-1):U&&(x.dir="/"),x},sep:"/",delimiter:":",win32:null,posix:null};O.posix=O,$.exports=O}},e={};function r($){var y=e[$];if(y!==void 0)return y.exports;var L=e[$]={exports:{}};return t[$](L,L.exports,r),L.exports}r.d=($,y)=>{for(var L in y)r.o(y,L)&&!r.o($,L)&&Object.defineProperty($,L,{enumerable:!0,get:y[L]})},r.o=($,y)=>Object.prototype.hasOwnProperty.call($,y),r.r=$=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty($,Symbol.toStringTag,{value:"Module"}),Object.defineProperty($,"__esModule",{value:!0})};var n={};let i;r.r(n),r.d(n,{URI:()=>h,Utils:()=>Kt}),typeof process=="object"?i=process.platform==="win32":typeof navigator=="object"&&(i=navigator.userAgent.indexOf("Windows")>=0);let s=/^\w[\w\d+.-]*$/,a=/^\//,o=/^\/\//;function c($,y){if(!$.scheme&&y)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${$.authority}", path: "${$.path}", query: "${$.query}", fragment: "${$.fragment}"}`);if($.scheme&&!s.test($.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if($.path){if($.authority){if(!a.test($.path))throw new 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(o.test($.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}}let l="",u="/",p=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class h{static isUri(y){return y instanceof h||!!y&&typeof y.authority=="string"&&typeof y.fragment=="string"&&typeof y.path=="string"&&typeof y.query=="string"&&typeof y.scheme=="string"&&typeof y.fsPath=="string"&&typeof y.with=="function"&&typeof y.toString=="function"}scheme;authority;path;query;fragment;constructor(y,L,O,T,x,A=!1){typeof y=="object"?(this.scheme=y.scheme||l,this.authority=y.authority||l,this.path=y.path||l,this.query=y.query||l,this.fragment=y.fragment||l):(this.scheme=(function(_,U){return _||U?_:"file"})(y,A),this.authority=L||l,this.path=(function(_,U){switch(_){case"https":case"http":case"file":U?U[0]!==u&&(U=u+U):U=u}return U})(this.scheme,O||l),this.query=T||l,this.fragment=x||l,c(this,A))}get fsPath(){return b(this,!1)}with(y){if(!y)return this;let{scheme:L,authority:O,path:T,query:x,fragment:A}=y;return L===void 0?L=this.scheme:L===null&&(L=l),O===void 0?O=this.authority:O===null&&(O=l),T===void 0?T=this.path:T===null&&(T=l),x===void 0?x=this.query:x===null&&(x=l),A===void 0?A=this.fragment:A===null&&(A=l),L===this.scheme&&O===this.authority&&T===this.path&&x===this.query&&A===this.fragment?this:new C(L,O,T,x,A)}static parse(y,L=!1){let O=p.exec(y);return O?new C(O[2]||l,ye(O[4]||l),ye(O[5]||l),ye(O[7]||l),ye(O[9]||l),L):new C(l,l,l,l,l)}static file(y){let L=l;if(i&&(y=y.replace(/\\/g,u)),y[0]===u&&y[1]===u){let O=y.indexOf(u,2);O===-1?(L=y.substring(2),y=u):(L=y.substring(2,O),y=y.substring(O)||u)}return new C("file",L,y,l,l)}static from(y){let L=new C(y.scheme,y.authority,y.path,y.query,y.fragment);return c(L,!0),L}toString(y=!1){return E(this,y)}toJSON(){return this}static revive(y){if(y){if(y instanceof h)return y;{let L=new C(y);return L._formatted=y.external,L._fsPath=y._sep===g?y.fsPath:null,L}}return y}}let g=i?1:void 0;class C extends h{_formatted=null;_fsPath=null;get fsPath(){return this._fsPath||(this._fsPath=b(this,!1)),this._fsPath}toString(y=!1){return y?E(this,!0):(this._formatted||(this._formatted=E(this,!1)),this._formatted)}toJSON(){let y={$mid:1};return this._fsPath&&(y.fsPath=this._fsPath,y._sep=g),this._formatted&&(y.external=this._formatted),this.path&&(y.path=this.path),this.scheme&&(y.scheme=this.scheme),this.authority&&(y.authority=this.authority),this.query&&(y.query=this.query),this.fragment&&(y.fragment=this.fragment),y}}let k={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 G($,y,L){let O,T=-1;for(let x=0;x<$.length;x++){let A=$.charCodeAt(x);if(A>=97&&A<=122||A>=65&&A<=90||A>=48&&A<=57||A===45||A===46||A===95||A===126||y&&A===47||L&&A===91||L&&A===93||L&&A===58)T!==-1&&(O+=encodeURIComponent($.substring(T,x)),T=-1),O!==void 0&&(O+=$.charAt(x));else{O===void 0&&(O=$.substr(0,x));let _=k[A];_!==void 0?(T!==-1&&(O+=encodeURIComponent($.substring(T,x)),T=-1),O+=_):T===-1&&(T=x)}}return T!==-1&&(O+=encodeURIComponent($.substring(T))),O!==void 0?O:$}function M($){let y;for(let L=0;L<$.length;L++){let O=$.charCodeAt(L);O===35||O===63?(y===void 0&&(y=$.substr(0,L)),y+=k[O]):y!==void 0&&(y+=$[L])}return y!==void 0?y:$}function b($,y){let L;return L=$.authority&&$.path.length>1&&$.scheme==="file"?`//${$.authority}${$.path}`:$.path.charCodeAt(0)===47&&($.path.charCodeAt(1)>=65&&$.path.charCodeAt(1)<=90||$.path.charCodeAt(1)>=97&&$.path.charCodeAt(1)<=122)&&$.path.charCodeAt(2)===58?y?$.path.substr(1):$.path[1].toLowerCase()+$.path.substr(2):$.path,i&&(L=L.replace(/\//g,"\\")),L}function E($,y){let L=y?M:G,O="",{scheme:T,authority:x,path:A,query:_,fragment:U}=$;if(T&&(O+=T,O+=":"),(x||T==="file")&&(O+=u,O+=u),x){let N=x.indexOf("@");if(N!==-1){let Y=x.substr(0,N);x=x.substr(N+1),N=Y.lastIndexOf(":"),N===-1?O+=L(Y,!1,!1):(O+=L(Y.substr(0,N),!1,!1),O+=":",O+=L(Y.substr(N+1),!1,!0)),O+="@"}x=x.toLowerCase(),N=x.lastIndexOf(":"),N===-1?O+=L(x,!1,!0):(O+=L(x.substr(0,N),!1,!0),O+=x.substr(N))}if(A){if(A.length>=3&&A.charCodeAt(0)===47&&A.charCodeAt(2)===58){let N=A.charCodeAt(1);N>=65&&N<=90&&(A=`/${String.fromCharCode(N+32)}:${A.substr(3)}`)}else if(A.length>=2&&A.charCodeAt(1)===58){let N=A.charCodeAt(0);N>=65&&N<=90&&(A=`${String.fromCharCode(N+32)}:${A.substr(2)}`)}O+=L(A,!0,!1)}return _&&(O+="?",O+=L(_,!1,!1)),U&&(O+="#",O+=y?U:G(U,!1,!1)),O}function H($){try{return decodeURIComponent($)}catch(y){return $.length>3?$.substr(0,3)+H($.substr(3)):$}}let F=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function ye($){return $.match(F)?$.replace(F,y=>H(y)):$}var dr=r(975);let Je=dr.posix||dr,Qt="/";var Kt;(function($){$.joinPath=function(y,...L){return y.with({path:Je.join(y.path,...L)})},$.resolvePath=function(y,...L){let O=y.path,T=!1;O[0]!==Qt&&(O=Qt+O,T=!0);let x=Je.resolve(O,...L);return T&&x[0]===Qt&&!y.authority&&(x=x.substring(1)),y.with({path:x})},$.dirname=function(y){if(y.path.length===0||y.path===Qt)return y;let L=Je.dirname(y.path);return L.length===1&&L.charCodeAt(0)===46&&(L=""),y.with({path:L})},$.basename=function(y){return Je.basename(y.path)},$.extname=function(y){return Je.extname(y.path)}})(Kt||(Kt={})),ry=n})();var{URI:rt,Utils:ps}=ry;var Be;(function(t){t.basename=ps.basename,t.dirname=ps.dirname,t.extname=ps.extname,t.joinPath=ps.joinPath,t.resolvePath=ps.resolvePath;let e=typeof process=="object"&&process?.platform==="win32";function r(a,o){return a?.toString()===o?.toString()}t.equals=r;function n(a,o){let c=typeof a=="string"?rt.parse(a).path:a.path,l=typeof o=="string"?rt.parse(o).path:o.path,u=c.split("/").filter(k=>k.length>0),p=l.split("/").filter(k=>k.length>0);if(e){let k=/^[A-Z]:$/;if(u[0]&&k.test(u[0])&&(u[0]=u[0].toLowerCase()),p[0]&&k.test(p[0])&&(p[0]=p[0].toLowerCase()),u[0]!==p[0])return l.substring(1)}let h=0;for(;h<u.length&&u[h]===p[h];h++);let g="../".repeat(u.length-h),C=p.slice(h).join("/");return g+C}t.relative=n;function i(a){return rt.parse(a.toString()).toString()}t.normalize=i;function s(a,o){let c=typeof a=="string"?a:a.path,l=typeof o=="string"?o:o.path;return l.charAt(l.length-1)==="/"&&(l=l.slice(0,-1)),c.charAt(c.length-1)==="/"&&(c=c.slice(0,-1)),l===c?!0:l.length<c.length||l.charAt(c.length)!=="/"?!1:l.startsWith(c)}t.contains=s})(Be||(Be={}));var hs=class{constructor(){this.root={name:"",children:new Map}}normalizeUri(e){return Be.normalize(e)}clear(){this.root.children.clear()}insert(e,r){let n=this.getNode(this.normalizeUri(e),!0);n.element=r}delete(e){let r=this.getNode(this.normalizeUri(e),!1);r?.parent&&r.parent.children.delete(r.name)}has(e){return this.getNode(this.normalizeUri(e),!1)?.element!==void 0}hasNode(e){return this.getNode(this.normalizeUri(e),!1)!==void 0}find(e){return this.getNode(this.normalizeUri(e),!1)?.element}findNode(e){let r=this.normalizeUri(e),n=this.getNode(r,!1);if(n)return{name:n.name,uri:Be.joinPath(rt.parse(r),n.name).toString(),element:n.element}}findChildren(e){let r=this.normalizeUri(e),n=this.getNode(r,!1);return n?Array.from(n.children.values()).map(i=>({name:i.name,uri:Be.joinPath(rt.parse(r),i.name).toString(),element:i.element})):[]}all(){return this.collectValues(this.root)}findAll(e){let r=this.getNode(Be.normalize(e),!1);return r?this.collectValues(r):[]}getNode(e,r){let n=e.split("/");e.charAt(e.length-1)==="/"&&n.pop();let i=this.root;for(let s of n){let a=i.children.get(s);if(!a)if(r)a={name:s,children:new Map,parent:i},i.children.set(s,a);else return;i=a}return i}collectValues(e){let r=[];e.element&&r.push(e.element);for(let n of e.children.values())r.push(...this.collectValues(n));return r}};var re=(function(t){return t[t.Changed=0]="Changed",t[t.Parsed=1]="Parsed",t[t.IndexedContent=2]="IndexedContent",t[t.ComputedScopes=3]="ComputedScopes",t[t.Linked=4]="Linked",t[t.IndexedReferences=5]="IndexedReferences",t[t.Validated=6]="Validated",t})(re||{}),Ha=class{constructor(e){this.serviceRegistry=e.ServiceRegistry,this.textDocuments=e.workspace.TextDocuments,this.fileSystemProvider=e.workspace.FileSystemProvider}fromUri(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){let i=yield this.fileSystemProvider.readFile(e);return this.createAsync(e,i,r)})}fromTextDocument(e,r,n){return r=r??rt.parse(e.uri),W.CancellationToken.is(n)?this.createAsync(r,e,n):this.create(r,e,n)}fromString(e,r,n){return W.CancellationToken.is(n)?this.createAsync(r,e,n):this.create(r,e,n)}fromModel(e,r){return this.create(r,{$model:e})}create(e,r,n){if(typeof r=="string"){let i=this.parse(e,r,n);return this.createLangiumDocument(i,e,void 0,r)}else if("$model"in r){let i={value:r.$model,parserErrors:[],lexerErrors:[]};return this.createLangiumDocument(i,e)}else{let i=this.parse(e,r.getText(),n);return this.createLangiumDocument(i,e,r)}}createAsync(e,r,n){return P(this,null,function*(){if(typeof r=="string"){let i=yield this.parseAsync(e,r,n);return this.createLangiumDocument(i,e,void 0,r)}else{let i=yield this.parseAsync(e,r.getText(),n);return this.createLangiumDocument(i,e,r)}})}createLangiumDocument(e,r,n,i){let s;if(n)s={parseResult:e,uri:r,state:re.Parsed,references:[],textDocument:n};else{let a=this.createTextDocumentGetter(r,i);s={parseResult:e,uri:r,state:re.Parsed,references:[],get textDocument(){return a()}}}return e.value.$document=s,s}update(e,r){return P(this,null,function*(){let n=e.parseResult.value.$cstNode?.root.fullText,i=this.textDocuments?.get(e.uri.toString()),s=i?i.getText():yield this.fileSystemProvider.readFile(e.uri);if(i)Object.defineProperty(e,"textDocument",{value:i});else{let a=this.createTextDocumentGetter(e.uri,s);Object.defineProperty(e,"textDocument",{get:a})}return n!==s&&(e.parseResult=yield this.parseAsync(e.uri,s,r),e.parseResult.value.$document=e),e.state=re.Parsed,e})}parse(e,r,n){return this.serviceRegistry.getServices(e).parser.LangiumParser.parse(r,n)}parseAsync(e,r,n){return this.serviceRegistry.getServices(e).parser.AsyncParser.parse(r,n)}createTextDocumentGetter(e,r){let n=this.serviceRegistry,i;return()=>i??(i=ds.create(e.toString(),n.getServices(e).LanguageMetaData.languageId,0,r??""))}},Ya=class{constructor(e){this.documentTrie=new hs,this.services=e,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.documentBuilder=()=>e.workspace.DocumentBuilder}get all(){return ee(this.documentTrie.all())}addDocument(e){let r=e.uri.toString();if(this.documentTrie.has(r))throw new Error(`A document with the URI '${r}' is already present.`);this.documentTrie.insert(r,e)}getDocument(e){let r=e.toString();return this.documentTrie.find(r)}getDocuments(e){let r=e.toString();return this.documentTrie.findAll(r)}getOrCreateDocument(e,r){return P(this,null,function*(){let n=this.getDocument(e);return n||(n=yield this.langiumDocumentFactory.fromUri(e,r),this.addDocument(n),n)})}createDocument(e,r,n){if(n)return this.langiumDocumentFactory.fromString(r,e,n).then(i=>(this.addDocument(i),i));{let i=this.langiumDocumentFactory.fromString(r,e);return this.addDocument(i),i}}hasDocument(e){return this.documentTrie.has(e.toString())}invalidateDocument(e){let r=e.toString(),n=this.documentTrie.find(r);return n&&this.documentBuilder().resetToState(n,re.Changed),n}deleteDocument(e){let r=e.toString(),n=this.documentTrie.find(r);return n&&(n.state=re.Changed,this.documentTrie.delete(r)),n}deleteDocuments(e){let r=e.toString(),n=this.documentTrie.findAll(r);for(let i of n)i.state=re.Changed;return this.documentTrie.delete(r),n}};var li=Symbol("RefResolving"),Xa=class{constructor(e){this.reflection=e.shared.AstReflection,this.langiumDocuments=()=>e.shared.workspace.LangiumDocuments,this.scopeProvider=e.references.ScopeProvider,this.astNodeLocator=e.workspace.AstNodeLocator,this.profiler=e.shared.profilers.LangiumProfiler,this.languageId=e.LanguageMetaData.languageId}link(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){if(this.profiler?.isActive("linking")){let i=this.profiler.createTask("linking",this.languageId);i.start();try{for(let s of St(e.parseResult.value))yield Me(r),sn(s).forEach(a=>{let o=`${s.$type}:${a.property}`;i.startSubTask(o);try{this.doLink(a,e)}finally{i.stopSubTask(o)}})}finally{i.stop()}}else for(let i of St(e.parseResult.value))yield Me(r),sn(i).forEach(s=>this.doLink(s,e))})}doLink(e,r){let n=e.reference;if("_ref"in n&&n._ref===void 0){n._ref=li;try{let i=this.getCandidate(e);if(bn(i))n._ref=i;else{n._nodeDescription=i;let s=this.loadAstNode(i);n._ref=s??this.createLinkingError(e,i)}}catch(i){console.error(`An error occurred while resolving reference to '${n.$refText}':`,i);let s=i.message??String(i);n._ref={info:e,message:`An error occurred while resolving reference to '${n.$refText}': ${s}`}}r.references.push(n)}else if("_items"in n&&n._items===void 0){n._items=li;try{let i=this.getCandidates(e),s=[];if(bn(i))n._linkingError=i;else for(let a of i){let o=this.loadAstNode(a);o&&s.push({ref:o,$nodeDescription:a})}n._items=s}catch(i){n._linkingError={info:e,message:`An error occurred while resolving reference to '${n.$refText}': ${i}`},n._items=[]}r.references.push(n)}}unlink(e){for(let r of e.references)"_ref"in r?(r._ref=void 0,delete r._nodeDescription):"_items"in r&&(r._items=void 0,delete r._linkingError);e.references=[]}getCandidate(e){return this.scopeProvider.getScope(e).getElement(e.reference.$refText)??this.createLinkingError(e)}getCandidates(e){let n=this.scopeProvider.getScope(e).getElements(e.reference.$refText).distinct(i=>`${i.documentUri}#${i.path}`).toArray();return n.length>0?n:this.createLinkingError(e)}buildReference(e,r,n,i){let s=this,a={$refNode:n,$refText:i,_ref:void 0,get ref(){if(Oe(this._ref))return this._ref;if(mu(this._nodeDescription)){let o=s.loadAstNode(this._nodeDescription);this._ref=o??s.createLinkingError({reference:a,container:e,property:r},this._nodeDescription)}else if(this._ref===void 0){this._ref=li;let o=$i(e).$document,c=s.getLinkedNode({reference:a,container:e,property:r});if(c.error&&o&&o.state<re.ComputedScopes)return this._ref=void 0;this._ref=c.node??c.error,this._nodeDescription=c.descr,o?.references.push(this)}else this._ref===li&&s.throwCyclicReferenceError(e,r,i);return Oe(this._ref)?this._ref:void 0},get $nodeDescription(){return this._nodeDescription},get error(){return bn(this._ref)?this._ref:void 0}};return a}buildMultiReference(e,r,n,i){let s=this,a={$refNode:n,$refText:i,_items:void 0,get items(){if(Array.isArray(this._items))return this._items;if(this._items===void 0){this._items=li;let o=$i(e).$document,c=s.getCandidates({reference:a,container:e,property:r}),l=[];if(bn(c))this._linkingError=c;else for(let u of c){let p=s.loadAstNode(u);p&&l.push({ref:p,$nodeDescription:u})}this._items=l,o?.references.push(this)}else this._items===li&&s.throwCyclicReferenceError(e,r,i);return Array.isArray(this._items)?this._items:[]},get error(){if(this._linkingError)return this._linkingError;if(!(this.items.length>0))return this._linkingError=s.createLinkingError({reference:a,container:e,property:r})}};return a}throwCyclicReferenceError(e,r,n){throw new Error(`Cyclic reference resolution detected: ${this.astNodeLocator.getAstNodePath(e)}/${r} (symbol '${n}')`)}getLinkedNode(e){try{let r=this.getCandidate(e);if(bn(r))return{error:r};let n=this.loadAstNode(r);return n?{node:n,descr:r}:{descr:r,error:this.createLinkingError(e,r)}}catch(r){console.error(`An error occurred while resolving reference to '${e.reference.$refText}':`,r);let n=r.message??String(r);return{error:{info:e,message:`An error occurred while resolving reference to '${e.reference.$refText}': ${n}`}}}}loadAstNode(e){if(e.node)return e.node;let r=this.langiumDocuments().getDocument(e.documentUri);if(r)return this.astNodeLocator.getAstNode(r.parseResult.value,e.path)}createLinkingError(e,r){let n=$i(e.container).$document;n&&n.state<re.ComputedScopes&&console.warn(`Attempted reference resolution before document reached ComputedScopes state (${n.uri}).`);let i=this.reflection.getReferenceType(e);return{info:e,message:`Could not resolve reference to ${i} named '${e.reference.$refText}'.`,targetDescription:r}}};function ny(t){return typeof t.name=="string"}var Ja=class{getName(e){if(ny(e))return e.name}getNameNode(e){return pa(e.$cstNode,"name")}};var Qa=class{constructor(e){this.nameProvider=e.references.NameProvider,this.index=e.shared.workspace.IndexManager,this.nodeLocator=e.workspace.AstNodeLocator,this.documents=e.shared.workspace.LangiumDocuments,this.hasMultiReference=St(e.Grammar).some(r=>ar(r)&&r.isMulti)}findDeclarations(e){if(e){let r=rf(e),n=e.astNode;if(r&&n){let i=n[r.feature];if(tt(i)||Ut(i))return Go(i);if(Array.isArray(i)){for(let s of i)if((tt(s)||Ut(s))&&s.$refNode&&s.$refNode.offset<=e.offset&&s.$refNode.end>=e.end)return Go(s)}}if(n){let i=this.nameProvider.getNameNode(n);if(i&&(i===e||Gu(e,i)))return this.getSelfNodes(n)}}return[]}getSelfNodes(e){if(this.hasMultiReference){let r=this.index.findAllReferences(e,this.nodeLocator.getAstNodePath(e)),n=this.getNodeFromReferenceDescription(r.head());if(n){for(let i of sn(n))if(Ut(i.reference)&&i.reference.items.some(s=>s.ref===e))return i.reference.items.map(s=>s.ref)}return[e]}else return[e]}getNodeFromReferenceDescription(e){if(!e)return;let r=this.documents.getDocument(e.sourceUri);if(r)return this.nodeLocator.getAstNode(r.parseResult.value,e.sourcePath)}findDeclarationNodes(e){let r=this.findDeclarations(e),n=[];for(let i of r){let s=this.nameProvider.getNameNode(i)??i.$cstNode;s&&n.push(s)}return n}findReferences(e,r){let n=[];r.includeDeclaration&&n.push(...this.getSelfReferences(e));let i=this.index.findAllReferences(e,this.nodeLocator.getAstNodePath(e));return r.documentUri&&(i=i.filter(s=>Be.equals(s.sourceUri,r.documentUri))),n.push(...i),ee(n)}getSelfReferences(e){let r=this.getSelfNodes(e),n=[];for(let i of r){let s=this.nameProvider.getNameNode(i);if(s){let a=yt(i),o=this.nodeLocator.getAstNodePath(i);n.push({sourceUri:a.uri,sourcePath:o,targetUri:a.uri,targetPath:o,segment:Wn(s),local:!0})}}return n}};var Rt=class{constructor(e){if(this.map=new Map,e)for(let[r,n]of e)this.add(r,n)}get size(){return Ei.sum(ee(this.map.values()).map(e=>e.length))}clear(){this.map.clear()}delete(e,r){if(r===void 0)return this.map.delete(e);{let n=this.map.get(e);if(n){let i=n.indexOf(r);if(i>=0)return n.length===1?this.map.delete(e):n.splice(i,1),!0}return!1}}get(e){return this.map.get(e)??[]}getStream(e){let r=this.map.get(e);return r?ee(r):nn}has(e,r){if(r===void 0)return this.map.has(e);{let n=this.map.get(e);return n?n.indexOf(r)>=0:!1}}add(e,r){return this.map.has(e)?this.map.get(e).push(r):this.map.set(e,[r]),this}addAll(e,r){return this.map.has(e)?this.map.get(e).push(...r):this.map.set(e,Array.from(r)),this}forEach(e){this.map.forEach((r,n)=>r.forEach(i=>e(i,n,this)))}[Symbol.iterator](){return this.entries().iterator()}entries(){return ee(this.map.entries()).flatMap(([e,r])=>r.map(n=>[e,n]))}keys(){return ee(this.map.keys())}values(){return ee(this.map.values()).flat()}entriesGroupedByKey(){return ee(this.map.entries())}},ui=class{get size(){return this.map.size}constructor(e){if(this.map=new Map,this.inverse=new Map,e)for(let[r,n]of e)this.set(r,n)}clear(){this.map.clear(),this.inverse.clear()}set(e,r){return this.map.set(e,r),this.inverse.set(r,e),this}get(e){return this.map.get(e)}getKey(e){return this.inverse.get(e)}delete(e){let r=this.map.get(e);return r!==void 0?(this.map.delete(e),this.inverse.delete(r),!0):!1}};var Za=class{constructor(e){this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider}collectExportedSymbols(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){return this.collectExportedSymbolsForNode(e.parseResult.value,e,void 0,r)})}collectExportedSymbolsForNode(s,a){return P(this,arguments,function*(e,r,n=Xs,i=W.CancellationToken.None){let o=[];this.addExportedSymbol(e,o,r);for(let c of n(e))yield Me(i),this.addExportedSymbol(c,o,r);return o})}addExportedSymbol(e,r,n){let i=this.nameProvider.getName(e);i&&r.push(this.descriptions.createDescription(e,i,n))}collectLocalSymbols(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){let i=e.parseResult.value,s=new Rt;for(let a of nr(i))yield Me(r),this.addLocalSymbol(a,e,s);return s})}addLocalSymbol(e,r,n){let i=e.$container;if(i){let s=this.nameProvider.getName(e);s&&n.add(i,this.descriptions.createDescription(e,s,r))}}};var ms=class{constructor(e,r,n){this.elements=e,this.outerScope=r,this.caseInsensitive=n?.caseInsensitive??!1,this.concatOuterScope=n?.concatOuterScope??!0}getAllElements(){return this.outerScope?this.elements.concat(this.outerScope.getAllElements()):this.elements}getElement(e){let r=this.caseInsensitive?e.toLowerCase():e,n=this.caseInsensitive?this.elements.find(i=>i.name.toLowerCase()===r):this.elements.find(i=>i.name===e);if(n)return n;if(this.outerScope)return this.outerScope.getElement(e)}getElements(e){let r=this.caseInsensitive?e.toLowerCase():e,n=this.caseInsensitive?this.elements.filter(i=>i.name.toLowerCase()===r):this.elements.filter(i=>i.name===e);return(this.concatOuterScope||n.isEmpty())&&this.outerScope?n.concat(this.outerScope.getElements(e)):n}},Ud=class{constructor(e,r,n){this.elements=new Map,this.caseInsensitive=n?.caseInsensitive??!1,this.concatOuterScope=n?.concatOuterScope??!0;for(let i of e){let s=this.caseInsensitive?i.name.toLowerCase():i.name;this.elements.set(s,i)}this.outerScope=r}getElement(e){let r=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(r);if(n)return n;if(this.outerScope)return this.outerScope.getElement(e)}getElements(e){let r=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(r),i=n?[n]:[];return(this.concatOuterScope||i.length>0)&&this.outerScope?ee(i).concat(this.outerScope.getElements(e)):ee(i)}getAllElements(){let e=ee(this.elements.values());return this.outerScope&&(e=e.concat(this.outerScope.getAllElements())),e}},eo=class{constructor(e,r,n){this.elements=new Rt,this.caseInsensitive=n?.caseInsensitive??!1,this.concatOuterScope=n?.concatOuterScope??!0;for(let i of e){let s=this.caseInsensitive?i.name.toLowerCase():i.name;this.elements.add(s,i)}this.outerScope=r}getElement(e){let r=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(r)[0];if(n)return n;if(this.outerScope)return this.outerScope.getElement(e)}getElements(e){let r=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(r);return(this.concatOuterScope||n.length===0)&&this.outerScope?ee(n).concat(this.outerScope.getElements(e)):ee(n)}getAllElements(){let e=ee(this.elements.values());return this.outerScope&&(e=e.concat(this.outerScope.getAllElements())),e}},QA={getElement(){},getElements(){return nn},getAllElements(){return nn}};var gs=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 new Error("This cache has already been disposed")}},to=class extends gs{constructor(){super(...arguments),this.cache=new Map}has(e){return this.throwIfDisposed(),this.cache.has(e)}set(e,r){this.throwIfDisposed(),this.cache.set(e,r)}get(e,r){if(this.throwIfDisposed(),this.cache.has(e))return this.cache.get(e);if(r){let n=r();return this.cache.set(e,n),n}else return}delete(e){return this.throwIfDisposed(),this.cache.delete(e)}clear(){this.throwIfDisposed(),this.cache.clear()}},fi=class extends gs{constructor(e){super(),this.cache=new Map,this.converter=e??(r=>r)}has(e,r){return this.throwIfDisposed(),this.cacheForContext(e).has(r)}set(e,r,n){this.throwIfDisposed(),this.cacheForContext(e).set(r,n)}get(e,r,n){this.throwIfDisposed();let i=this.cacheForContext(e);if(i.has(r))return i.get(r);if(n){let s=n();return i.set(r,s),s}else return}delete(e,r){return this.throwIfDisposed(),this.cacheForContext(e).delete(r)}clear(e){if(this.throwIfDisposed(),e){let r=this.converter(e);this.cache.delete(r)}else this.cache.clear()}cacheForContext(e){let r=this.converter(e),n=this.cache.get(r);return n||(n=new Map,this.cache.set(r,n)),n}},ml=class extends fi{constructor(e,r){super(n=>n.toString()),r?(this.toDispose.push(e.workspace.DocumentBuilder.onDocumentPhase(r,n=>{this.clear(n.uri.toString())})),this.toDispose.push(e.workspace.DocumentBuilder.onUpdate((n,i)=>{for(let s of i)this.clear(s)}))):this.toDispose.push(e.workspace.DocumentBuilder.onUpdate((n,i)=>{let s=n.concat(i);for(let a of s)this.clear(a)}))}},ys=class extends to{constructor(e,r){super(),r?(this.toDispose.push(e.workspace.DocumentBuilder.onBuildPhase(r,()=>{this.clear()})),this.toDispose.push(e.workspace.DocumentBuilder.onUpdate((n,i)=>{i.length>0&&this.clear()}))):this.toDispose.push(e.workspace.DocumentBuilder.onUpdate(()=>{this.clear()}))}};var ro=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 ys(e.shared)}getScope(e){let r=[],n=this.reflection.getReferenceType(e),i=yt(e.container).localSymbols;if(i){let a=e.container;do i.has(a)&&r.push(i.getStream(a).filter(o=>this.reflection.isSubtype(o.type,n))),a=a.$container;while(a)}let s=this.getGlobalScope(n,e);for(let a=r.length-1;a>=0;a--)s=this.createScope(r[a],s);return s}createScope(e,r,n){return new ms(ee(e),r,n)}createScopeForNodes(e,r,n){let i=ee(e).map(s=>{let a=this.nameProvider.getName(s);if(a)return this.descriptions.createDescription(s,a)}).nonNullable();return new ms(i,r,n)}getGlobalScope(e,r){return this.globalScopeCache.get(e,()=>new eo(this.indexManager.allElements(e)))}};function qd(t){return typeof t.$comment=="string"}function iy(t){return typeof t=="object"&&!!t&&("$ref"in t||"$error"in t)}var no=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,r){let n=r??{},i=r?.replacer,s=(o,c)=>this.replacer(o,c,n),a=i?(o,c)=>i(o,c,s):s;try{return this.currentDocument=yt(e),JSON.stringify(e,a,r?.space)}finally{this.currentDocument=void 0}}deserialize(e,r){let n=r??{},i=JSON.parse(e);return this.linkNode(i,i,n),i}replacer(e,r,{refText:n,sourceText:i,textRegions:s,comments:a,uriConverter:o}){if(!this.ignoreProperties.has(e))if(tt(r)){let c=r.ref,l=n?r.$refText:void 0;if(c){let u=yt(c),p="";this.currentDocument&&this.currentDocument!==u&&(o?p=o(u.uri,c):p=u.uri.toString());let h=this.astNodeLocator.getAstNodePath(c);return{$ref:`${p}#${h}`,$refText:l}}else return{$error:r.error?.message??"Could not resolve reference",$refText:l}}else if(Ut(r)){let c=n?r.$refText:void 0,l=[];for(let u of r.items){let p=u.ref,h=yt(u.ref),g="";this.currentDocument&&this.currentDocument!==h&&(o?g=o(h.uri,p):g=h.uri.toString());let C=this.astNodeLocator.getAstNodePath(p);l.push(`${g}#${C}`)}return{$refs:l,$refText:c}}else if(Oe(r)){let c;if(s&&(c=this.addAstNodeRegionWithAssignmentsTo(ge({},r)),(!e||r.$document)&&c?.$textRegion&&(c.$textRegion.documentURI=this.currentDocument?.uri.toString())),i&&!e&&(c??(c=ge({},r)),c.$sourceText=r.$cstNode?.text),a){c??(c=ge({},r));let l=this.commentProvider.getComment(r);l&&(c.$comment=l.replace(/\r/g,""))}return c??r}else return r}addAstNodeRegionWithAssignmentsTo(e){let r=n=>({offset:n.offset,end:n.end,length:n.length,range:n.range});if(e.$cstNode){let n=e.$textRegion=r(e.$cstNode),i=n.assignments={};return Object.keys(e).filter(s=>!s.startsWith("$")).forEach(s=>{let a=Qu(e.$cstNode,s).map(r);a.length!==0&&(i[s]=a)}),e}}linkNode(e,r,n,i,s,a){for(let[c,l]of Object.entries(e))if(Array.isArray(l))for(let u=0;u<l.length;u++){let p=l[u];iy(p)?l[u]=this.reviveReference(e,c,r,p,n):Oe(p)&&this.linkNode(p,r,n,e,c,u)}else iy(l)?e[c]=this.reviveReference(e,c,r,l,n):Oe(l)&&this.linkNode(l,r,n,e,c);let o=e;o.$container=i,o.$containerProperty=s,o.$containerIndex=a}reviveReference(e,r,n,i,s){let a=i.$refText,o=i.$error,c;if(i.$ref){let l=this.getRefNode(n,i.$ref,s.uriConverter);if(Oe(l))return a||(a=this.nameProvider.getName(l)),{$refText:a??"",ref:l};o=l}else if(i.$refs){let l=[];for(let u of i.$refs){let p=this.getRefNode(n,u,s.uriConverter);Oe(p)&&l.push({ref:p})}if(l.length===0)c={$refText:a??"",items:l},o??(o="Could not resolve multi-reference");else return{$refText:a??"",items:l}}if(o)return c??(c={$refText:a??"",ref:void 0}),c.error={info:{container:e,property:r,reference:c},message:o},c}getRefNode(e,r,n){try{let i=r.indexOf("#");if(i===0){let c=this.astNodeLocator.getAstNode(e,r.substring(1));return c||"Could not resolve path: "+r}if(i<0){let c=n?n(r):rt.parse(r),l=this.langiumDocuments.getDocument(c);return l?l.parseResult.value:"Could not find document for URI: "+r}let s=n?n(r.substring(0,i)):rt.parse(r.substring(0,i)),a=this.langiumDocuments.getDocument(s);if(!a)return"Could not find document for URI: "+r;if(i===r.length-1)return a.parseResult.value;let o=this.astNodeLocator.getAstNode(a.parseResult.value,r.substring(i+1));return o||"Could not resolve URI: "+r}catch(i){return String(i)}}};var io=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 r=e.LanguageMetaData;for(let n of r.fileExtensions)this.fileExtensionMap.has(n)&&console.warn(`The file extension ${n} is used by multiple languages. It is now assigned to '${r.languageId}'.`),this.fileExtensionMap.set(n,e);if(r.fileNames)for(let n of r.fileNames)this.fileNameMap.has(n)&&console.warn(`The file name ${n} is used by multiple languages. It is now assigned to '${r.languageId}'.`),this.fileNameMap.set(n,e);this.languageIdMap.set(r.languageId,e)}getServices(e){if(this.languageIdMap.size===0)throw new Error("The service registry is empty. Use `register` to register the services of a language.");let r=this.textDocuments?.get(e)?.languageId;if(r!==void 0){let a=this.languageIdMap.get(r);if(a)return a}let n=Be.extname(e),i=Be.basename(e),s=this.fileNameMap.get(i)??this.fileExtensionMap.get(n);if(!s)throw r?new Error(`The service registry contains no services for the extension '${n}' for language '${r}'.`):new Error(`The service registry contains no services for the extension '${n}'.`);return s}hasServices(e){try{return this.getServices(e),!0}catch(r){return!1}}get all(){return Array.from(this.languageIdMap.values())}};function di(t){return{code:t}}var gl;(function(t){t.defaults=["fast","slow","built-in"],t.all=t.defaults})(gl||(gl={}));var so=class{constructor(e){this.entries=new Rt,this.knownCategories=new Set(gl.defaults),this.entriesBefore=[],this.entriesAfter=[],this.reflection=e.shared.AstReflection}register(e,r=this,n="fast"){if(n==="built-in")throw new Error("The 'built-in' category is reserved for lexer, parser, and linker errors.");this.knownCategories.add(n);for(let[i,s]of Object.entries(e)){let a=s;if(Array.isArray(a))for(let o of a){let c={check:this.wrapValidationException(o,r),category:n};this.addEntry(i,c)}else if(typeof a=="function"){let o={check:this.wrapValidationException(a,r),category:n};this.addEntry(i,o)}else Rr(a)}}wrapValidationException(e,r){return(n,i,s)=>P(this,null,function*(){yield this.handleException(()=>e.call(r,n,i,s),"An error occurred during validation",i,n)})}handleException(e,r,n,i){return P(this,null,function*(){try{yield e()}catch(s){if(Sr(s))throw s;console.error(`${r}:`,s),s instanceof Error&&s.stack&&console.error(s.stack);let a=s instanceof Error?s.message:String(s);n("error",`${r}: ${a}`,{node:i})}})}addEntry(e,r){if(e==="AstNode"){this.entries.add("AstNode",r);return}for(let n of this.reflection.getAllSubTypes(e))this.entries.add(n,r)}getChecks(e,r){let n=ee(this.entries.get(e)).concat(this.entries.get("AstNode"));return r&&(n=n.filter(i=>r.includes(i.category))),n.map(i=>i.check)}registerBeforeDocument(e,r=this){this.entriesBefore.push(this.wrapPreparationException(e,"An error occurred during set-up of the validation",r))}registerAfterDocument(e,r=this){this.entriesAfter.push(this.wrapPreparationException(e,"An error occurred during tear-down of the validation",r))}wrapPreparationException(e,r,n){return(i,s,a,o)=>P(this,null,function*(){yield this.handleException(()=>e.call(n,i,s,a,o),r,s,i)})}get checksBefore(){return this.entriesBefore}get checksAfter(){return this.entriesAfter}getAllValidationCategories(e){return this.knownCategories}};var sy=Object.freeze({validateNode:!0,validateChildren:!0}),ao=class{constructor(e){this.validationRegistry=e.validation.ValidationRegistry,this.metadata=e.LanguageMetaData,this.profiler=e.shared.profilers.LangiumProfiler,this.languageId=e.LanguageMetaData.languageId}validateDocument(i){return P(this,arguments,function*(e,r={},n=W.CancellationToken.None){let s=e.parseResult,a=[];if(yield Me(n),(!r.categories||r.categories.includes("built-in"))&&(this.processLexingErrors(s,a,r),r.stopAfterLexingErrors&&a.some(o=>o.data?.code===lr.LexingError)||(this.processParsingErrors(s,a,r),r.stopAfterParsingErrors&&a.some(o=>o.data?.code===lr.ParsingError))||(this.processLinkingErrors(e,a,r),r.stopAfterLinkingErrors&&a.some(o=>o.data?.code===lr.LinkingError))))return a;try{a.push(...yield this.validateAst(s.value,r,n))}catch(o){if(Sr(o))throw o;console.error("An error occurred during validation:",o)}return yield Me(n),a})}processLexingErrors(e,r,n){let i=[...e.lexerErrors,...e.lexerReport?.diagnostics??[]];for(let s of i){let a=s.severity??"error",o={severity:yl(a),range:{start:{line:s.line-1,character:s.column-1},end:{line:s.line-1,character:s.column+s.length-1}},message:s.message,data:oy(a),source:this.getSource()};r.push(o)}}processParsingErrors(e,r,n){for(let i of e.parserErrors){let s;if(isNaN(i.token.startOffset)){if("previousToken"in i){let a=i.previousToken;if(isNaN(a.startOffset)){let o={line:0,character:0};s={start:o,end:o}}else{let o={line:a.endLine-1,character:a.endColumn};s={start:o,end:o}}}}else s=Pi(i.token);if(s){let a={severity:yl("error"),range:s,message:i.message,data:di(lr.ParsingError),source:this.getSource()};r.push(a)}}}processLinkingErrors(e,r,n){for(let i of e.references){let s=i.error;if(s){let a={node:s.info.container,range:i.$refNode?.range,property:s.info.property,index:s.info.index,data:{code:lr.LinkingError,containerType:s.info.container.$type,property:s.info.property,refText:s.info.reference.$refText}};r.push(this.toDiagnostic("error",s.message,a))}}}validateAst(i,s){return P(this,arguments,function*(e,r,n=W.CancellationToken.None){let a=[],o=(c,l,u)=>{a.push(this.toDiagnostic(c,l,u))};return yield this.validateAstBefore(e,r,o,n),yield this.validateAstNodes(e,r,o,n),yield this.validateAstAfter(e,r,o,n),a})}validateAstBefore(s,a,o){return P(this,arguments,function*(e,r,n,i=W.CancellationToken.None){let c=this.validationRegistry.checksBefore;for(let l of c)yield Me(i),yield l(e,n,r.categories??[],i)})}validateAstNodes(s,a,o){return P(this,arguments,function*(e,r,n,i=W.CancellationToken.None){if(this.profiler?.isActive("validating")){let c=this.profiler.createTask("validating",this.languageId);c.start();try{let l=St(e).iterator();for(let u of l){c.startSubTask(u.$type);let p=this.validateSingleNodeOptions(u,r);if(p.validateNode)try{let h=this.validationRegistry.getChecks(u.$type,r.categories);for(let g of h)yield g(u,n,i)}finally{c.stopSubTask(u.$type)}p.validateChildren||l.prune()}}finally{c.stop()}}else{let c=St(e).iterator();for(let l of c){yield Me(i);let u=this.validateSingleNodeOptions(l,r);if(u.validateNode){let p=this.validationRegistry.getChecks(l.$type,r.categories);for(let h of p)yield h(l,n,i)}u.validateChildren||c.prune()}}})}validateSingleNodeOptions(e,r){return sy}validateAstAfter(s,a,o){return P(this,arguments,function*(e,r,n,i=W.CancellationToken.None){let c=this.validationRegistry.checksAfter;for(let l of c)yield Me(i),yield l(e,n,r.categories??[],i)})}toDiagnostic(e,r,n){return{message:r,range:ay(n),severity:yl(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 ay(t){if(t.range)return t.range;let e;return typeof t.property=="string"?e=pa(t.node.$cstNode,t.property,t.index):typeof t.keyword=="string"&&(e=ef(t.node.$cstNode,t.keyword,t.index)),e??(e=t.node.$cstNode),e?e.range:{start:{line:0,character:0},end:{line:0,character:0}}}function yl(t){switch(t){case"error":return 1;case"warning":return 2;case"info":return 3;case"hint":return 4;default:throw new Error("Invalid diagnostic severity: "+t)}}function oy(t){switch(t){case"error":return di(lr.LexingError);case"warning":return di(lr.LexingWarning);case"info":return di(lr.LexingInfo);case"hint":return di(lr.LexingHint);default:throw new Error("Invalid diagnostic severity: "+t)}}var lr=(function(t){return t.LexingError="lexing-error",t.LexingWarning="lexing-warning",t.LexingInfo="lexing-info",t.LexingHint="lexing-hint",t.ParsingError="parsing-error",t.LinkingError="linking-error",t})(lr||{});var oo=class{constructor(e){this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider}createDescription(e,r,n){let i=n??yt(e);r??(r=this.nameProvider.getName(e));let s=this.astNodeLocator.getAstNodePath(e);if(!r)throw new Error(`Node at path ${s} has no name.`);let a,o=()=>a??(a=Wn(this.nameProvider.getNameNode(e)??e.$cstNode));return{node:e,name:r,get nameSegment(){return o()},selectionSegment:Wn(e.$cstNode),type:e.$type,documentUri:i.uri,path:s}}},co=class{constructor(e){this.nodeLocator=e.workspace.AstNodeLocator}createDescriptions(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){let i=[],s=e.parseResult.value;for(let a of St(s))yield Me(r),sn(a).forEach(o=>{o.reference.error||i.push(...this.createInfoDescriptions(o))});return i})}createInfoDescriptions(e){let r=e.reference;if(r.error||!r.$refNode)return[];let n=[];tt(r)&&r.$nodeDescription?n=[r.$nodeDescription]:Ut(r)&&(n=r.items.map(c=>c.$nodeDescription).filter(c=>c!==void 0));let i=yt(e.container).uri,s=this.nodeLocator.getAstNodePath(e.container),a=[],o=Wn(r.$refNode);for(let c of n)a.push({sourceUri:i,sourcePath:s,targetUri:c.documentUri,targetPath:c.path,segment:o,local:Be.equals(c.documentUri,i)});return a}};var lo=class{constructor(){this.segmentSeparator="/",this.indexSeparator="@"}getAstNodePath(e){if(e.$container){let r=this.getAstNodePath(e.$container),n=this.getPathSegment(e);return r+this.segmentSeparator+n}return""}getPathSegment({$containerProperty:e,$containerIndex:r}){if(!e)throw new Error("Missing '$containerProperty' in AST node.");return r!==void 0?e+this.indexSeparator+r:e}getAstNode(e,r){return r.split(this.segmentSeparator).reduce((i,s)=>{if(!i||s.length===0)return i;let a=s.indexOf(this.indexSeparator);if(a>0){let o=s.substring(0,a),c=parseInt(s.substring(a+1));return i[o]?.[c]}return i[s]},e)}};var we={};ae(we,du(ci(),1));var uo=class{constructor(e){this._ready=new It,this.onConfigurationSectionUpdateEmitter=new we.Emitter,this.settings={},this.workspaceConfig=!1,this.serviceRegistry=e.ServiceRegistry}get ready(){return this._ready.promise}initialize(e){this.workspaceConfig=e.capabilities.workspace?.configuration??!1}initialized(e){return P(this,null,function*(){if(this.workspaceConfig){if(e.register){let r=this.serviceRegistry.all;e.register({section:r.map(n=>this.toSectionName(n.LanguageMetaData.languageId))})}if(e.fetchConfiguration){let r=this.serviceRegistry.all.map(i=>({section:this.toSectionName(i.LanguageMetaData.languageId)})),n=yield e.fetchConfiguration(r);r.forEach((i,s)=>{this.updateSectionConfiguration(i.section,n[s])})}}this._ready.resolve()})}updateConfiguration(e){typeof e.settings!="object"||e.settings===null||Object.entries(e.settings).forEach(([r,n])=>{this.updateSectionConfiguration(r,n),this.onConfigurationSectionUpdateEmitter.fire({section:r,configuration:n})})}updateSectionConfiguration(e,r){this.settings[e]=r}getConfiguration(e,r){return P(this,null,function*(){yield this.ready;let n=this.toSectionName(e);if(this.settings[n])return this.settings[n][r]})}toSectionName(e){return`${e}`}get onConfigurationSectionUpdate(){return this.onConfigurationSectionUpdateEmitter.event}};var Ps=du(Ix(),1);var Cn;(function(t){function e(r){return{dispose:()=>P(null,null,function*(){return yield r()})}}t.create=e})(Cn||(Cn={}));var xo=class{constructor(e){this.updateBuildOptions={validation:{categories:["built-in","fast"]}},this.updateListeners=[],this.buildPhaseListeners=new Rt,this.documentPhaseListeners=new Rt,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=re.Changed,this.langiumDocuments=e.workspace.LangiumDocuments,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.textDocuments=e.workspace.TextDocuments,this.indexManager=e.workspace.IndexManager,this.fileSystemProvider=e.workspace.FileSystemProvider,this.workspaceManager=()=>e.workspace.WorkspaceManager,this.serviceRegistry=e.ServiceRegistry}build(i){return P(this,arguments,function*(e,r={},n=W.CancellationToken.None){for(let s of e){let a=s.uri.toString();if(s.state===re.Validated){if(typeof r.validation=="boolean"&&r.validation)this.resetToState(s,re.IndexedReferences);else if(typeof r.validation=="object"){let o=this.findMissingValidationCategories(s,r);o.length>0&&(this.buildState.set(a,{completed:!1,options:{validation:{categories:o}},result:this.buildState.get(a)?.result}),s.state=re.IndexedReferences)}}else this.buildState.delete(a)}this.currentState=re.Changed,yield this.emitUpdate(e.map(s=>s.uri),[]),yield this.buildDocuments(e,r,n)})}update(i,s){return P(this,arguments,function*(e,r,n=W.CancellationToken.None){this.currentState=re.Changed;let a=[];for(let u of r){let p=this.langiumDocuments.deleteDocuments(u);for(let h of p)a.push(h.uri),this.cleanUpDeleted(h)}let o=(yield Promise.all(e.map(u=>this.findChangedUris(u)))).flat();for(let u of o){let p=this.langiumDocuments.getDocument(u);p===void 0&&(p=this.langiumDocumentFactory.fromModel({$type:"INVALID"},u),p.state=re.Changed,this.langiumDocuments.addDocument(p)),this.resetToState(p,re.Changed)}let c=ee(o).concat(a).map(u=>u.toString()).toSet();this.langiumDocuments.all.filter(u=>!c.has(u.uri.toString())&&this.shouldRelink(u,c)).forEach(u=>this.resetToState(u,re.ComputedScopes)),yield this.emitUpdate(o,a),yield Me(n);let l=this.sortDocuments(this.langiumDocuments.all.filter(u=>u.state<re.Validated||!this.buildState.get(u.uri.toString())?.completed||this.resultsAreIncomplete(u,this.updateBuildOptions)).toArray());yield this.buildDocuments(l,this.updateBuildOptions,n)})}resultsAreIncomplete(e,r){return this.findMissingValidationCategories(e,r).length>=1}findMissingValidationCategories(e,r){let n=this.buildState.get(e.uri.toString()),i=this.serviceRegistry.getServices(e.uri).validation.ValidationRegistry.getAllValidationCategories(e),s=n?.result?.validationChecks?new Set(n?.result?.validationChecks):n?.completed?i:new Set,a=r===void 0||r.validation===!0?i:typeof r.validation=="object"?r.validation.categories??i:[];return ee(a).filter(o=>!s.has(o)).toArray()}findChangedUris(e){return P(this,null,function*(){if(this.langiumDocuments.getDocument(e)??this.textDocuments?.get(e))return[e];try{let n=yield this.fileSystemProvider.stat(e);if(n.isDirectory)return yield this.workspaceManager().searchFolder(e);if(this.workspaceManager().shouldIncludeEntry(n))return[e]}catch(n){}return[]})}emitUpdate(e,r){return P(this,null,function*(){yield Promise.all(this.updateListeners.map(n=>n(e,r)))})}sortDocuments(e){let r=0,n=e.length-1;for(;r<n;){for(;r<e.length&&this.hasTextDocument(e[r]);)r++;for(;n>=0&&!this.hasTextDocument(e[n]);)n--;r<n&&([e[r],e[n]]=[e[n],e[r]])}return e}hasTextDocument(e){return!!this.textDocuments?.get(e.uri)}shouldRelink(e,r){return e.references.some(n=>n.error!==void 0)?!0:this.indexManager.isAffected(e,r)}onUpdate(e){return this.updateListeners.push(e),Cn.create(()=>{let r=this.updateListeners.indexOf(e);r>=0&&this.updateListeners.splice(r,1)})}resetToState(e,r){switch(r){case re.Changed:case re.Parsed:this.indexManager.removeContent(e.uri);case re.IndexedContent:e.localSymbols=void 0;case re.ComputedScopes:this.serviceRegistry.getServices(e.uri).references.Linker.unlink(e);case re.Linked:this.indexManager.removeReferences(e.uri);case re.IndexedReferences:e.diagnostics=void 0,this.buildState.delete(e.uri.toString());case re.Validated:}e.state>r&&(e.state=r)}cleanUpDeleted(e){this.buildState.delete(e.uri.toString()),this.indexManager.remove(e.uri),e.state=re.Changed}buildDocuments(e,r,n){return P(this,null,function*(){this.prepareBuild(e,r),yield this.runCancelable(e,re.Parsed,n,a=>this.langiumDocumentFactory.update(a,n)),yield this.runCancelable(e,re.IndexedContent,n,a=>this.indexManager.updateContent(a,n)),yield this.runCancelable(e,re.ComputedScopes,n,a=>P(this,null,function*(){let o=this.serviceRegistry.getServices(a.uri).references.ScopeComputation;a.localSymbols=yield o.collectLocalSymbols(a,n)}));let i=e.filter(a=>this.shouldLink(a));yield this.runCancelable(i,re.Linked,n,a=>this.serviceRegistry.getServices(a.uri).references.Linker.link(a,n)),yield this.runCancelable(i,re.IndexedReferences,n,a=>this.indexManager.updateReferences(a,n));let s=e.filter(a=>this.shouldValidate(a)?!0:(this.markAsCompleted(a),!1));yield this.runCancelable(s,re.Validated,n,a=>P(this,null,function*(){yield this.validate(a,n),this.markAsCompleted(a)}))})}markAsCompleted(e){let r=this.buildState.get(e.uri.toString());r&&(r.completed=!0)}prepareBuild(e,r){for(let n of e){let i=n.uri.toString(),s=this.buildState.get(i);(!s||s.completed)&&this.buildState.set(i,{completed:!1,options:r,result:s?.result})}}runCancelable(e,r,n,i){return P(this,null,function*(){for(let a of e)a.state<r&&(yield Me(n),yield i(a),a.state=r,yield this.notifyDocumentPhase(a,r,n));let s=e.filter(a=>a.state===r);yield this.notifyBuildPhase(s,r,n),this.currentState=r})}onBuildPhase(e,r){return this.buildPhaseListeners.add(e,r),Cn.create(()=>{this.buildPhaseListeners.delete(e,r)})}onDocumentPhase(e,r){return this.documentPhaseListeners.add(e,r),Cn.create(()=>{this.documentPhaseListeners.delete(e,r)})}waitUntil(e,r,n){let i;return r&&"path"in r?i=r:n=r,n??(n=W.CancellationToken.None),i?this.awaitDocumentState(e,i,n):this.awaitBuilderState(e,n)}awaitDocumentState(e,r,n){let i=this.langiumDocuments.getDocument(r);if(i){if(i.state>=e)return Promise.resolve(r);if(n.isCancellationRequested)return Promise.reject(Yt);if(this.currentState>=e&&e>i.state)return Promise.reject(new Ps.ResponseError(Ps.LSPErrorCodes.RequestFailed,`Document state of ${r.toString()} is ${re[i.state]}, requiring ${re[e]}, but workspace state is already ${re[this.currentState]}. Returning undefined.`))}else return Promise.reject(new Ps.ResponseError(Ps.LSPErrorCodes.ServerCancelled,`No document found for URI: ${r.toString()}`));return new Promise((s,a)=>{let o=this.onDocumentPhase(e,l=>{Be.equals(l.uri,r)&&(o.dispose(),c.dispose(),s(l.uri))}),c=n.onCancellationRequested(()=>{o.dispose(),c.dispose(),a(Yt)})})}awaitBuilderState(e,r){return this.currentState>=e?Promise.resolve():r.isCancellationRequested?Promise.reject(Yt):new Promise((n,i)=>{let s=this.onBuildPhase(e,()=>{s.dispose(),a.dispose(),n()}),a=r.onCancellationRequested(()=>{s.dispose(),a.dispose(),i(Yt)})})}notifyDocumentPhase(e,r,n){return P(this,null,function*(){let s=this.documentPhaseListeners.get(r).slice();for(let a of s)try{yield Me(n),yield a(e,n)}catch(o){if(!Sr(o))throw o}})}notifyBuildPhase(e,r,n){return P(this,null,function*(){if(e.length===0)return;let s=this.buildPhaseListeners.get(r).slice();for(let a of s)yield Me(n),yield a(e,n)})}shouldLink(e){return this.getBuildOptions(e).eagerLinking??!0}shouldValidate(e){return!!this.getBuildOptions(e).validation}validate(e,r){return P(this,null,function*(){let n=this.serviceRegistry.getServices(e.uri).validation.DocumentValidator,i=this.getBuildOptions(e),s=typeof i.validation=="object"?ge({},i.validation):{};s.categories=this.findMissingValidationCategories(e,i);let a=yield n.validateDocument(e,s,r);e.diagnostics?e.diagnostics.push(...a):e.diagnostics=a;let o=this.buildState.get(e.uri.toString());o&&(o.result??(o.result={}),o.result.validationChecks?o.result.validationChecks=ee(o.result.validationChecks).concat(s.categories).distinct().toArray():o.result.validationChecks=[...s.categories])})}getBuildOptions(e){return this.buildState.get(e.uri.toString())?.options??{}}};var vo=class{constructor(e){this.symbolIndex=new Map,this.symbolByTypeIndex=new fi,this.referenceIndex=new Map,this.documents=e.workspace.LangiumDocuments,this.serviceRegistry=e.ServiceRegistry,this.astReflection=e.AstReflection}findAllReferences(e,r){let n=yt(e).uri,i=[];return this.referenceIndex.forEach(s=>{s.forEach(a=>{Be.equals(a.targetUri,n)&&a.targetPath===r&&i.push(a)})}),ee(i)}allElements(e,r){let n=ee(this.symbolIndex.keys());return r&&(n=n.filter(i=>!r||r.has(i))),n.map(i=>this.getFileDescriptions(i,e)).flat()}getFileDescriptions(e,r){return r?this.symbolByTypeIndex.get(e,r,()=>(this.symbolIndex.get(e)??[]).filter(s=>this.astReflection.isSubtype(s.type,r))):this.symbolIndex.get(e)??[]}remove(e){this.removeContent(e),this.removeReferences(e)}removeContent(e){let r=e.toString();this.symbolIndex.delete(r),this.symbolByTypeIndex.clear(r)}removeReferences(e){let r=e.toString();this.referenceIndex.delete(r)}updateContent(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){let s=yield this.serviceRegistry.getServices(e.uri).references.ScopeComputation.collectExportedSymbols(e,r),a=e.uri.toString();this.symbolIndex.set(a,s),this.symbolByTypeIndex.clear(a)})}updateReferences(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){let s=yield this.serviceRegistry.getServices(e.uri).workspace.ReferenceDescriptionProvider.createDescriptions(e,r);this.referenceIndex.set(e.uri.toString(),s)})}isAffected(e,r){let n=this.referenceIndex.get(e.uri.toString());return n?n.some(i=>!i.local&&r.has(i.targetUri.toString())):!1}};var Eo=class{constructor(e){this.initialBuildOptions={},this._ready=new It,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(r=>this.initializeWorkspace(this.folders??[],r))}initializeWorkspace(n){return P(this,arguments,function*(e,r=W.CancellationToken.None){let i=yield this.performStartup(e);yield Me(r),yield this.documentBuilder.build(i,this.initialBuildOptions,r)})}performStartup(e){return P(this,null,function*(){let r=[],n=a=>{r.push(a),this.langiumDocuments.hasDocument(a.uri)||this.langiumDocuments.addDocument(a)};yield this.loadAdditionalDocuments(e,n);let i=[];yield Promise.all(e.map(a=>this.getRootFolder(a)).map(a=>P(this,null,function*(){return this.traverseFolder(a,i)})));let s=ee(i).distinct(a=>a.toString()).filter(a=>!this.langiumDocuments.hasDocument(a));return yield this.loadWorkspaceDocuments(s,n),this._ready.resolve(),r})}loadWorkspaceDocuments(e,r){return P(this,null,function*(){yield Promise.all(e.map(n=>P(this,null,function*(){let i=yield this.langiumDocuments.getOrCreateDocument(n);r(i)})))})}loadAdditionalDocuments(e,r){return Promise.resolve()}getRootFolder(e){return rt.parse(e.uri)}traverseFolder(e,r){return P(this,null,function*(){try{let n=yield this.fileSystemProvider.readDirectory(e);yield Promise.all(n.map(i=>P(this,null,function*(){this.shouldIncludeEntry(i)&&(i.isDirectory?yield this.traverseFolder(i.uri,r):i.isFile&&r.push(i.uri))})))}catch(n){console.error("Failure to read directory content of "+e.toString(!0),n)}})}searchFolder(e){return P(this,null,function*(){let r=[];return yield this.traverseFolder(e,r),r})}shouldIncludeEntry(e){let r=Be.basename(e.uri);return r.startsWith(".")?!1:e.isDirectory?r!=="node_modules"&&r!=="out":e.isFile?this.serviceRegistry.hasServices(e.uri):!1}};var Ao=class{buildUnexpectedCharactersMessage(e,r,n,i,s){return ji.buildUnexpectedCharactersMessage(e,r,n,i,s)}buildUnableToPopLexerModeMessage(e){return ji.buildUnableToPopLexerModeMessage(e)}},Xl={mode:"full"},gi=class{constructor(e){this.errorMessageProvider=e.parser.LexerErrorMessageProvider,this.tokenBuilder=e.parser.TokenBuilder;let r=this.tokenBuilder.buildTokens(e.Grammar,{caseInsensitive:e.LanguageMetaData.caseInsensitive});this.tokenTypes=this.toTokenTypeDictionary(r);let n=oh(r)?Object.values(r):r,i=e.LanguageMetaData.mode==="production";this.chevrotainLexer=new He(n,{positionTracking:"full",skipValidations:i,errorMessageProvider:this.errorMessageProvider})}get definition(){return this.tokenTypes}tokenize(e,r=Xl){let n=this.chevrotainLexer.tokenize(e);return{tokens:n.tokens,errors:n.errors,hidden:n.groups.hidden??[],report:this.tokenBuilder.flushLexingReport?.(e)}}toTokenTypeDictionary(e){if(oh(e))return e;let r=ch(e)?Object.values(e.modes).flat():e,n={};return r.forEach(i=>n[i.name]=i),n}};function Jl(t){return Array.isArray(t)&&(t.length===0||"name"in t[0])}function ch(t){return t&&"modes"in t&&"defaultMode"in t}function oh(t){return!Jl(t)&&!ch(t)}as();function fh(t,e,r){let n,i;typeof t=="string"?(i=e,n=r):(i=t.range.start,n=e),i||(i=ce.create(0,0));let s=Px(t),a=ph(n),o=U$({lines:s,position:i,options:a});return W$({index:0,tokens:o,position:i})}function dh(t,e){let r=ph(e),n=Px(t);if(n.length===0)return!1;let i=n[0],s=n[n.length-1],a=r.start,o=r.end;return!!a?.exec(i)&&!!o?.exec(s)}function Px(t){let e="";return typeof t=="string"?e=t:e=t.text,e.split(Wu)}var _x=/\s*(@([\p{L}][\p{L}\p{N}]*)?)/uy,G$=/\{(@[\p{L}][\p{L}\p{N}]*)(\s*)([^\r\n}]+)?\}/gu;function U$(t){let e=[],r=t.position.line,n=t.position.character;for(let i=0;i<t.lines.length;i++){let s=i===0,a=i===t.lines.length-1,o=t.lines[i],c=0;if(s&&t.options.start){let u=t.options.start?.exec(o);u&&(c=u.index+u[0].length)}else{let u=t.options.line?.exec(o);u&&(c=u.index+u[0].length)}if(a){let u=t.options.end?.exec(o);u&&(o=o.substring(0,u.index))}if(o=o.substring(0,B$(o)),uh(o,c)>=o.length){if(e.length>0){let u=ce.create(r,n);e.push({type:"break",content:"",range:ie.create(u,u)})}}else{_x.lastIndex=c;let u=_x.exec(o);if(u){let p=u[0],h=u[1],g=ce.create(r,n+c),C=ce.create(r,n+c+p.length);e.push({type:"tag",content:h,range:ie.create(g,C)}),c+=p.length,c=uh(o,c)}if(c<o.length){let p=o.substring(c),h=Array.from(p.matchAll(G$));e.push(...q$(h,p,r,n+c))}}r++,n=0}return e.length>0&&e[e.length-1].type==="break"?e.slice(0,-1):e}function q$(t,e,r,n){let i=[];if(t.length===0){let s=ce.create(r,n),a=ce.create(r,n+e.length);i.push({type:"text",content:e,range:ie.create(s,a)})}else{let s=0;for(let o of t){let c=o.index,l=e.substring(s,c);l.length>0&&i.push({type:"text",content:e.substring(s,c),range:ie.create(ce.create(r,s+n),ce.create(r,c+n))});let u=l.length+1,p=o[1];if(i.push({type:"inline-tag",content:p,range:ie.create(ce.create(r,s+u+n),ce.create(r,s+u+p.length+n))}),u+=p.length,o.length===4){u+=o[2].length;let h=o[3];i.push({type:"text",content:h,range:ie.create(ce.create(r,s+u+n),ce.create(r,s+u+h.length+n))})}else i.push({type:"text",content:"",range:ie.create(ce.create(r,s+u+n),ce.create(r,s+u+n))});s=c+o[0].length}let a=e.substring(s);a.length>0&&i.push({type:"text",content:a,range:ie.create(ce.create(r,s+n),ce.create(r,s+n+a.length))})}return i}var z$=/\S/,j$=/\s*$/;function uh(t,e){let r=t.substring(e).match(z$);return r?e+r.index:t.length}function B$(t){let e=t.match(j$);if(e&&typeof e.index=="number")return e.index}function W$(t){let e=ce.create(t.position.line,t.position.character);if(t.tokens.length===0)return new Ql([],ie.create(e,e));let r=[];for(;t.index<t.tokens.length;){let s=V$(t,r[r.length-1]);s&&r.push(s)}let n=r[0]?.range.start??e,i=r[r.length-1]?.range.end??e;return new Ql(r,ie.create(n,i))}function V$(t,e){let r=t.tokens[t.index];if(r.type==="tag")return Lx(t,!1);if(r.type==="text"||r.type==="inline-tag")return Ox(t);K$(r,e),t.index++}function K$(t,e){if(e){let r=new Zl("",t.range);"inlines"in e?e.inlines.push(r):e.content.inlines.push(r)}}function Ox(t){let e=t.tokens[t.index],r=e,n=e,i=[];for(;e&&e.type!=="break"&&e.type!=="tag";)i.push(H$(t)),n=e,e=t.tokens[t.index];return new So(i,ie.create(r.range.start,n.range.end))}function H$(t){return t.tokens[t.index].type==="inline-tag"?Lx(t,!0):Dx(t)}function Lx(t,e){let r=t.tokens[t.index++],n=r.content.substring(1);if(t.tokens[t.index]?.type==="text")if(e){let s=Dx(t);return new $o(n,new So([s],s.range),e,ie.create(r.range.start,s.range.end))}else{let s=Ox(t);return new $o(n,s,e,ie.create(r.range.start,s.range.end))}else{let s=r.range;return new $o(n,new So([],s),e,s)}}function Dx(t){let e=t.tokens[t.index++];return new Zl(e.content,e.range)}function ph(t){if(!t)return ph({start:"/**",end:"*/",line:"*"});let{start:e,end:r,line:n}=t;return{start:lh(e,!0),end:lh(r,!1),line:lh(n,!0)}}function lh(t,e){if(typeof t=="string"||typeof t=="object"){let r=typeof t=="string"?pn(t):t.source;return e?new RegExp(`^\\s*${r}`):new RegExp(`\\s*${r}\\s*$`)}else return t}var Ql=class{constructor(e,r){this.elements=e,this.range=r}getTag(e){return this.getAllTags().find(r=>r.name===e)}getTags(e){return this.getAllTags().filter(r=>r.name===e)}getAllTags(){return this.elements.filter(e=>"name"in e)}toString(){let e="";for(let r of this.elements)if(e.length===0)e=r.toString();else{let n=r.toString();e+=bx(e)+n}return e.trim()}toMarkdown(e){let r="";for(let n of this.elements)if(r.length===0)r=n.toMarkdown(e);else{let i=n.toMarkdown(e);r+=bx(r)+i}return r.trim()}},$o=class{constructor(e,r,n,i){this.name=e,this.content=r,this.inline=n,this.range=i}toString(){let e=`@${this.name}`,r=this.content.toString();return this.content.inlines.length===1?e=`${e} ${r}`:this.content.inlines.length>1&&(e=`${e}
152${r}`),this.inline?`{${e}}`:e}toMarkdown(e){return e?.renderTag?.(this)??this.toMarkdownDefault(e)}toMarkdownDefault(e){let r=this.content.toMarkdown(e);if(this.inline){let s=Y$(this.name,r,e??{});if(typeof s=="string")return s}let n="";e?.tag==="italic"||e?.tag===void 0?n="*":e?.tag==="bold"?n="**":e?.tag==="bold-italic"&&(n="***");let i=`${n}@${this.name}${n}`;return this.content.inlines.length===1?i=`${i} \u2014 ${r}`:this.content.inlines.length>1&&(i=`${i}
153${r}`),this.inline?`{${i}}`:i}};function Y$(t,e,r){if(t==="linkplain"||t==="linkcode"||t==="link"){let n=e.indexOf(" "),i=e;if(n>0){let a=uh(e,n);i=e.substring(a),e=e.substring(0,n)}return(t==="linkcode"||t==="link"&&r.link==="code")&&(i=`\`${i}\``),r.renderLink?.(e,i)??X$(e,i)}}function X$(t,e){try{return rt.parse(t,!0),`[${e}](${t})`}catch(r){return t}}var So=class{constructor(e,r){this.inlines=e,this.range=r}toString(){let e="";for(let r=0;r<this.inlines.length;r++){let n=this.inlines[r],i=this.inlines[r+1];e+=n.toString(),i&&i.range.start.line>n.range.start.line&&(e+=`
154`)}return e}toMarkdown(e){let r="";for(let n=0;n<this.inlines.length;n++){let i=this.inlines[n],s=this.inlines[n+1];r+=i.toMarkdown(e),s&&s.range.start.line>i.range.start.line&&(r+=`

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected