devicetree-language-server 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -3,8 +3,8 @@
3
3
  ${JSON.stringify(Object.fromEntries(r))}`));return}let s=parseInt(i);if(isNaN(s)){this.fireError(new Error(`Content-Length value must be a number. Got ${i}`));return}this.nextMessageLength=s}let n=this.buffer.tryReadBody(this.nextMessageLength);if(n===void 0){this.setPartialMessageTimer();return}this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.readSemaphore.lock(async()=>{let r=this.options.contentDecoder!==void 0?await this.options.contentDecoder.decode(n):n,i=await this.options.contentTypeDecoder.decode(r,this.options);this.callback(i)}).catch(r=>{this.fireError(r)})}}catch(n){this.fireError(n)}}clearPartialMessageTimer(){this.partialMessageTimer&&(this.partialMessageTimer.dispose(),this.partialMessageTimer=void 0)}setPartialMessageTimer(){this.clearPartialMessageTimer(),!(this._partialMessageTimeout<=0)&&(this.partialMessageTimer=(0,Kg.default)().timer.setTimeout((e,n)=>{this.partialMessageTimer=void 0,e===this.messageToken&&(this.firePartialMessage({messageToken:e,waitingTime:n}),this.setPartialMessageTimer())},this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout))}};ts.ReadableStreamMessageReader=Xg});var Fk=N(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.WriteableStreamMessageWriter=ns.AbstractMessageWriter=ns.MessageWriter=void 0;var xk=es(),Pc=Ho(),LB=zg(),Lk=Wo(),qB="Content-Length: ",qk=`\r
4
4
  `,$k;(function(t){function e(n){let r=n;return r&&Pc.func(r.dispose)&&Pc.func(r.onClose)&&Pc.func(r.onError)&&Pc.func(r.write)}t.is=e})($k||(ns.MessageWriter=$k={}));var _d=class{constructor(){this.errorEmitter=new Lk.Emitter,this.closeEmitter=new Lk.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(e,n,r){this.errorEmitter.fire([this.asError(e),n,r])}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}asError(e){return e instanceof Error?e:new Error(`Writer received error. Reason: ${Pc.string(e.message)?e.message:"unknown"}`)}};ns.AbstractMessageWriter=_d;var Jg;(function(t){function e(n){return n===void 0||typeof n=="string"?{charset:n??"utf-8",contentTypeEncoder:(0,xk.default)().applicationJson.encoder}:{charset:n.charset??"utf-8",contentEncoder:n.contentEncoder,contentTypeEncoder:n.contentTypeEncoder??(0,xk.default)().applicationJson.encoder}}t.fromOptions=e})(Jg||(Jg={}));var Qg=class extends _d{constructor(e,n){super(),this.writable=e,this.options=Jg.fromOptions(n),this.errorCount=0,this.writeSemaphore=new LB.Semaphore(1),this.writable.onError(r=>this.fireError(r)),this.writable.onClose(()=>this.fireClose())}async write(e){return this.writeSemaphore.lock(async()=>this.options.contentTypeEncoder.encode(e,this.options).then(r=>this.options.contentEncoder!==void 0?this.options.contentEncoder.encode(r):r).then(r=>{let i=[];return i.push(qB,r.byteLength.toString(),qk),i.push(qk),this.doWrite(e,i,r)},r=>{throw this.fireError(r),r}))}async doWrite(e,n,r){try{return await this.writable.write(n.join(""),"ascii"),this.writable.write(r)}catch(i){return this.handleError(i,e),Promise.reject(i)}}handleError(e,n){this.errorCount++,this.fireError(e,n,this.errorCount)}end(){this.writable.end()}};ns.WriteableStreamMessageWriter=Qg});var Bk=N(Sd=>{"use strict";Object.defineProperty(Sd,"__esModule",{value:!0});Sd.AbstractMessageBuffer=void 0;var $B=13,FB=10,BB=`\r
5
5
  `,Zg=class{constructor(e="utf-8"){this._encoding=e,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append(e){let n=typeof e=="string"?this.fromString(e,this._encoding):e;this._chunks.push(n),this._totalLength+=n.byteLength}tryReadHeaders(e=!1){if(this._chunks.length===0)return;let n=0,r=0,i=0,s=0;e:for(;r<this._chunks.length;){let l=this._chunks[r];for(i=0;i<l.length;){switch(l[i]){case $B:switch(n){case 0:n=1;break;case 2:n=3;break;default:n=0}break;case FB:switch(n){case 1:n=2;break;case 3:n=4,i++;break e;default:n=0}break;default:n=0}i++}s+=l.byteLength,r++}if(n!==4)return;let o=this._read(s+i),a=new Map,c=this.toString(o,"ascii").split(BB);if(c.length<2)return a;for(let l=0;l<c.length-2;l++){let u=c[l],d=u.indexOf(":");if(d===-1)throw new Error(`Message header must separate key and value using ':'
6
- ${u}`);let f=u.substr(0,d),p=u.substr(d+1).trim();a.set(e?f.toLowerCase():f,p)}return a}tryReadBody(e){if(!(this._totalLength<e))return this._read(e)}get numberOfBytes(){return this._totalLength}_read(e){if(e===0)return this.emptyBuffer();if(e>this._totalLength)throw new Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===e){let s=this._chunks[0];return this._chunks.shift(),this._totalLength-=e,this.asNative(s)}if(this._chunks[0].byteLength>e){let s=this._chunks[0],o=this.asNative(s,e);return this._chunks[0]=s.slice(e),this._totalLength-=e,o}let n=this.allocNative(e),r=0,i=0;for(;e>0;){let s=this._chunks[i];if(s.byteLength>e){let o=s.slice(0,e);n.set(o,r),r+=e,this._chunks[i]=s.slice(e),this._totalLength-=e,e-=e}else n.set(s,r),r+=s.byteLength,this._chunks.shift(),this._totalLength-=s.byteLength,e-=s.byteLength}return n}};Sd.AbstractMessageBuffer=Zg});var Wk=N(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.createMessageConnection=ve.ConnectionOptions=ve.MessageStrategy=ve.CancellationStrategy=ve.CancellationSenderStrategy=ve.CancellationReceiverStrategy=ve.RequestCancellationReceiverStrategy=ve.IdCancellationReceiverStrategy=ve.ConnectionStrategy=ve.ConnectionError=ve.ConnectionErrors=ve.LogTraceNotification=ve.SetTraceNotification=ve.TraceFormat=ve.TraceValues=ve.Trace=ve.NullLogger=ve.ProgressType=ve.ProgressToken=void 0;var jk=es(),wt=Ho(),pe=Ig(),Uk=Mg(),Nc=Wo(),ey=Td(),Ec;(function(t){t.type=new pe.NotificationType("$/cancelRequest")})(Ec||(Ec={}));var ty;(function(t){function e(n){return typeof n=="string"||typeof n=="number"}t.is=e})(ty||(ve.ProgressToken=ty={}));var Rc;(function(t){t.type=new pe.NotificationType("$/progress")})(Rc||(Rc={}));var ny=class{constructor(){}};ve.ProgressType=ny;var ry;(function(t){function e(n){return wt.func(n)}t.is=e})(ry||(ry={}));ve.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}});var Ke;(function(t){t[t.Off=0]="Off",t[t.Messages=1]="Messages",t[t.Compact=2]="Compact",t[t.Verbose=3]="Verbose"})(Ke||(ve.Trace=Ke={}));var Hk;(function(t){t.Off="off",t.Messages="messages",t.Compact="compact",t.Verbose="verbose"})(Hk||(ve.TraceValues=Hk={}));(function(t){function e(r){if(!wt.string(r))return t.Off;switch(r=r.toLowerCase(),r){case"off":return t.Off;case"messages":return t.Messages;case"compact":return t.Compact;case"verbose":return t.Verbose;default:return t.Off}}t.fromString=e;function n(r){switch(r){case t.Off:return"off";case t.Messages:return"messages";case t.Compact:return"compact";case t.Verbose:return"verbose";default:return"off"}}t.toString=n})(Ke||(ve.Trace=Ke={}));var ir;(function(t){t.Text="text",t.JSON="json"})(ir||(ve.TraceFormat=ir={}));(function(t){function e(n){return wt.string(n)?(n=n.toLowerCase(),n==="json"?t.JSON:t.Text):t.Text}t.fromString=e})(ir||(ve.TraceFormat=ir={}));var iy;(function(t){t.type=new pe.NotificationType("$/setTrace")})(iy||(ve.SetTraceNotification=iy={}));var kd;(function(t){t.type=new pe.NotificationType("$/logTrace")})(kd||(ve.LogTraceNotification=kd={}));var wc;(function(t){t[t.Closed=1]="Closed",t[t.Disposed=2]="Disposed",t[t.AlreadyListening=3]="AlreadyListening"})(wc||(ve.ConnectionErrors=wc={}));var Yo=class t extends Error{constructor(e,n){super(n),this.code=e,Object.setPrototypeOf(this,t.prototype)}};ve.ConnectionError=Yo;var sy;(function(t){function e(n){let r=n;return r&&wt.func(r.cancelUndispatched)}t.is=e})(sy||(ve.ConnectionStrategy=sy={}));var Pd;(function(t){function e(n){let r=n;return r&&(r.kind===void 0||r.kind==="id")&&wt.func(r.createCancellationTokenSource)&&(r.dispose===void 0||wt.func(r.dispose))}t.is=e})(Pd||(ve.IdCancellationReceiverStrategy=Pd={}));var oy;(function(t){function e(n){let r=n;return r&&r.kind==="request"&&wt.func(r.createCancellationTokenSource)&&(r.dispose===void 0||wt.func(r.dispose))}t.is=e})(oy||(ve.RequestCancellationReceiverStrategy=oy={}));var Nd;(function(t){t.Message=Object.freeze({createCancellationTokenSource(n){return new ey.CancellationTokenSource}});function e(n){return Pd.is(n)||oy.is(n)}t.is=e})(Nd||(ve.CancellationReceiverStrategy=Nd={}));var Rd;(function(t){t.Message=Object.freeze({sendCancellation(n,r){return n.sendNotification(Ec.type,{id:r})},cleanup(n){}});function e(n){let r=n;return r&&wt.func(r.sendCancellation)&&wt.func(r.cleanup)}t.is=e})(Rd||(ve.CancellationSenderStrategy=Rd={}));var wd;(function(t){t.Message=Object.freeze({receiver:Nd.Message,sender:Rd.Message});function e(n){let r=n;return r&&Nd.is(r.receiver)&&Rd.is(r.sender)}t.is=e})(wd||(ve.CancellationStrategy=wd={}));var Ed;(function(t){function e(n){let r=n;return r&&wt.func(r.handleMessage)}t.is=e})(Ed||(ve.MessageStrategy=Ed={}));var Vk;(function(t){function e(n){let r=n;return r&&(wd.is(r.cancellationStrategy)||sy.is(r.connectionStrategy)||Ed.is(r.messageStrategy))}t.is=e})(Vk||(ve.ConnectionOptions=Vk={}));var Ur;(function(t){t[t.New=1]="New",t[t.Listening=2]="Listening",t[t.Closed=3]="Closed",t[t.Disposed=4]="Disposed"})(Ur||(Ur={}));function jB(t,e,n,r){let i=n!==void 0?n:ve.NullLogger,s=0,o=0,a=0,c="2.0",l,u=new Map,d,f=new Map,p=new Map,m,h=new Uk.LinkedMap,y=new Map,_=new Set,v=new Map,b=Ke.Off,P=ir.Text,E,H=Ur.New,O=new Nc.Emitter,B=new Nc.Emitter,Ae=new Nc.Emitter,lt=new Nc.Emitter,Gt=new Nc.Emitter,Re=r&&r.cancellationStrategy?r.cancellationStrategy:wd.Message;function pr(R){if(R===null)throw new Error("Can't send requests with id null since the response can't be correlated.");return"req-"+R.toString()}function Ji(R){return R===null?"res-unknown-"+(++a).toString():"res-"+R.toString()}function Xu(){return"not-"+(++o).toString()}function og(R,L){pe.Message.isRequest(L)?R.set(pr(L.id),L):pe.Message.isResponse(L)?R.set(Ji(L.id),L):R.set(Xu(),L)}function Ju(R){}function yc(){return H===Ur.Listening}function zs(){return H===Ur.Closed}function Ci(){return H===Ur.Disposed}function $o(){(H===Ur.New||H===Ur.Listening)&&(H=Ur.Closed,B.fire(void 0))}function Gs(R){O.fire([R,void 0,void 0])}function Qu(R){O.fire(R)}t.onClose($o),t.onError(Gs),e.onClose($o),e.onError(Qu);function Tc(){m||h.size===0||(m=(0,jk.default)().timer.setImmediate(()=>{m=void 0,Zu()}))}function vc(R){pe.Message.isRequest(R)?td(R):pe.Message.isNotification(R)?rd(R):pe.Message.isResponse(R)?nd(R):Fo(R)}function Zu(){if(h.size===0)return;let R=h.shift();try{let L=r?.messageStrategy;Ed.is(L)?L.handleMessage(R,vc):vc(R)}finally{Tc()}}let ed=R=>{try{if(pe.Message.isNotification(R)&&R.method===Ec.type.method){let L=R.params.id,G=pr(L),ne=h.get(G);if(pe.Message.isRequest(ne)){let Je=r?.connectionStrategy,ht=Je&&Je.cancelUndispatched?Je.cancelUndispatched(ne,Ju):void 0;if(ht&&(ht.error!==void 0||ht.result!==void 0)){h.delete(G),v.delete(L),ht.id=ne.id,Ks(ht,R.method,Date.now()),e.write(ht).catch(()=>i.error("Sending response for canceled message failed."));return}}let et=v.get(L);if(et!==void 0){et.cancel(),Bo(R);return}else _.add(L)}og(h,R)}finally{Tc()}};function td(R){if(Ci())return;function L(we,rt,ze){let Dt={jsonrpc:c,id:R.id};we instanceof pe.ResponseError?Dt.error=we.toJson():Dt.result=we===void 0?null:we,Ks(Dt,rt,ze),e.write(Dt).catch(()=>i.error("Sending response failed."))}function G(we,rt,ze){let Dt={jsonrpc:c,id:R.id,error:we.toJson()};Ks(Dt,rt,ze),e.write(Dt).catch(()=>i.error("Sending response failed."))}function ne(we,rt,ze){we===void 0&&(we=null);let Dt={jsonrpc:c,id:R.id,result:we};Ks(Dt,rt,ze),e.write(Dt).catch(()=>i.error("Sending response failed."))}od(R);let et=u.get(R.method),Je,ht;et&&(Je=et.type,ht=et.handler);let kt=Date.now();if(ht||l){let we=R.id??String(Date.now()),rt=Pd.is(Re.receiver)?Re.receiver.createCancellationTokenSource(we):Re.receiver.createCancellationTokenSource(R);R.id!==null&&_.has(R.id)&&rt.cancel(),R.id!==null&&v.set(we,rt);try{let ze;if(ht)if(R.params===void 0){if(Je!==void 0&&Je.numberOfParams!==0){G(new pe.ResponseError(pe.ErrorCodes.InvalidParams,`Request ${R.method} defines ${Je.numberOfParams} params but received none.`),R.method,kt);return}ze=ht(rt.token)}else if(Array.isArray(R.params)){if(Je!==void 0&&Je.parameterStructures===pe.ParameterStructures.byName){G(new pe.ResponseError(pe.ErrorCodes.InvalidParams,`Request ${R.method} defines parameters by name but received parameters by position`),R.method,kt);return}ze=ht(...R.params,rt.token)}else{if(Je!==void 0&&Je.parameterStructures===pe.ParameterStructures.byPosition){G(new pe.ResponseError(pe.ErrorCodes.InvalidParams,`Request ${R.method} defines parameters by position but received parameters by name`),R.method,kt);return}ze=ht(R.params,rt.token)}else l&&(ze=l(R.method,R.params,rt.token));let Dt=ze;ze?Dt.then?Dt.then(Xt=>{v.delete(we),L(Xt,R.method,kt)},Xt=>{v.delete(we),Xt instanceof pe.ResponseError?G(Xt,R.method,kt):Xt&&wt.string(Xt.message)?G(new pe.ResponseError(pe.ErrorCodes.InternalError,`Request ${R.method} failed with message: ${Xt.message}`),R.method,kt):G(new pe.ResponseError(pe.ErrorCodes.InternalError,`Request ${R.method} failed unexpectedly without providing any details.`),R.method,kt)}):(v.delete(we),L(ze,R.method,kt)):(v.delete(we),ne(ze,R.method,kt))}catch(ze){v.delete(we),ze instanceof pe.ResponseError?L(ze,R.method,kt):ze&&wt.string(ze.message)?G(new pe.ResponseError(pe.ErrorCodes.InternalError,`Request ${R.method} failed with message: ${ze.message}`),R.method,kt):G(new pe.ResponseError(pe.ErrorCodes.InternalError,`Request ${R.method} failed unexpectedly without providing any details.`),R.method,kt)}}else G(new pe.ResponseError(pe.ErrorCodes.MethodNotFound,`Unhandled method ${R.method}`),R.method,kt)}function nd(R){if(!Ci())if(R.id===null)R.error?i.error(`Received response message without id: Error is:
7
- ${JSON.stringify(R.error,void 0,4)}`):i.error("Received response message without id. No further error information provided.");else{let L=R.id,G=y.get(L);if(ad(R,G),G!==void 0){y.delete(L);try{if(R.error){let ne=R.error;G.reject(new pe.ResponseError(ne.code,ne.message,ne.data))}else if(R.result!==void 0)G.resolve(R.result);else throw new Error("Should never happen.")}catch(ne){ne.message?i.error(`Response handler '${G.method}' failed with message: ${ne.message}`):i.error(`Response handler '${G.method}' failed unexpectedly.`)}}}}function rd(R){if(Ci())return;let L,G;if(R.method===Ec.type.method){let ne=R.params.id;_.delete(ne),Bo(R);return}else{let ne=f.get(R.method);ne&&(G=ne.handler,L=ne.type)}if(G||d)try{if(Bo(R),G)if(R.params===void 0)L!==void 0&&L.numberOfParams!==0&&L.parameterStructures!==pe.ParameterStructures.byName&&i.error(`Notification ${R.method} defines ${L.numberOfParams} params but received none.`),G();else if(Array.isArray(R.params)){let ne=R.params;R.method===Rc.type.method&&ne.length===2&&ty.is(ne[0])?G({token:ne[0],value:ne[1]}):(L!==void 0&&(L.parameterStructures===pe.ParameterStructures.byName&&i.error(`Notification ${R.method} defines parameters by name but received parameters by position`),L.numberOfParams!==R.params.length&&i.error(`Notification ${R.method} defines ${L.numberOfParams} params but received ${ne.length} arguments`)),G(...ne))}else L!==void 0&&L.parameterStructures===pe.ParameterStructures.byPosition&&i.error(`Notification ${R.method} defines parameters by position but received parameters by name`),G(R.params);else d&&d(R.method,R.params)}catch(ne){ne.message?i.error(`Notification handler '${R.method}' failed with message: ${ne.message}`):i.error(`Notification handler '${R.method}' failed unexpectedly.`)}else Ae.fire(R)}function Fo(R){if(!R){i.error("Received empty message.");return}i.error(`Received message which is neither a response nor a notification message:
6
+ ${u}`);let f=u.substr(0,d),p=u.substr(d+1).trim();a.set(e?f.toLowerCase():f,p)}return a}tryReadBody(e){if(!(this._totalLength<e))return this._read(e)}get numberOfBytes(){return this._totalLength}_read(e){if(e===0)return this.emptyBuffer();if(e>this._totalLength)throw new Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===e){let s=this._chunks[0];return this._chunks.shift(),this._totalLength-=e,this.asNative(s)}if(this._chunks[0].byteLength>e){let s=this._chunks[0],o=this.asNative(s,e);return this._chunks[0]=s.slice(e),this._totalLength-=e,o}let n=this.allocNative(e),r=0,i=0;for(;e>0;){let s=this._chunks[i];if(s.byteLength>e){let o=s.slice(0,e);n.set(o,r),r+=e,this._chunks[i]=s.slice(e),this._totalLength-=e,e-=e}else n.set(s,r),r+=s.byteLength,this._chunks.shift(),this._totalLength-=s.byteLength,e-=s.byteLength}return n}};Sd.AbstractMessageBuffer=Zg});var Wk=N(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.createMessageConnection=ve.ConnectionOptions=ve.MessageStrategy=ve.CancellationStrategy=ve.CancellationSenderStrategy=ve.CancellationReceiverStrategy=ve.RequestCancellationReceiverStrategy=ve.IdCancellationReceiverStrategy=ve.ConnectionStrategy=ve.ConnectionError=ve.ConnectionErrors=ve.LogTraceNotification=ve.SetTraceNotification=ve.TraceFormat=ve.TraceValues=ve.Trace=ve.NullLogger=ve.ProgressType=ve.ProgressToken=void 0;var jk=es(),wt=Ho(),he=Ig(),Uk=Mg(),Nc=Wo(),ey=Td(),Ec;(function(t){t.type=new he.NotificationType("$/cancelRequest")})(Ec||(Ec={}));var ty;(function(t){function e(n){return typeof n=="string"||typeof n=="number"}t.is=e})(ty||(ve.ProgressToken=ty={}));var Rc;(function(t){t.type=new he.NotificationType("$/progress")})(Rc||(Rc={}));var ny=class{constructor(){}};ve.ProgressType=ny;var ry;(function(t){function e(n){return wt.func(n)}t.is=e})(ry||(ry={}));ve.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}});var Ke;(function(t){t[t.Off=0]="Off",t[t.Messages=1]="Messages",t[t.Compact=2]="Compact",t[t.Verbose=3]="Verbose"})(Ke||(ve.Trace=Ke={}));var Hk;(function(t){t.Off="off",t.Messages="messages",t.Compact="compact",t.Verbose="verbose"})(Hk||(ve.TraceValues=Hk={}));(function(t){function e(r){if(!wt.string(r))return t.Off;switch(r=r.toLowerCase(),r){case"off":return t.Off;case"messages":return t.Messages;case"compact":return t.Compact;case"verbose":return t.Verbose;default:return t.Off}}t.fromString=e;function n(r){switch(r){case t.Off:return"off";case t.Messages:return"messages";case t.Compact:return"compact";case t.Verbose:return"verbose";default:return"off"}}t.toString=n})(Ke||(ve.Trace=Ke={}));var ir;(function(t){t.Text="text",t.JSON="json"})(ir||(ve.TraceFormat=ir={}));(function(t){function e(n){return wt.string(n)?(n=n.toLowerCase(),n==="json"?t.JSON:t.Text):t.Text}t.fromString=e})(ir||(ve.TraceFormat=ir={}));var iy;(function(t){t.type=new he.NotificationType("$/setTrace")})(iy||(ve.SetTraceNotification=iy={}));var kd;(function(t){t.type=new he.NotificationType("$/logTrace")})(kd||(ve.LogTraceNotification=kd={}));var wc;(function(t){t[t.Closed=1]="Closed",t[t.Disposed=2]="Disposed",t[t.AlreadyListening=3]="AlreadyListening"})(wc||(ve.ConnectionErrors=wc={}));var Yo=class t extends Error{constructor(e,n){super(n),this.code=e,Object.setPrototypeOf(this,t.prototype)}};ve.ConnectionError=Yo;var sy;(function(t){function e(n){let r=n;return r&&wt.func(r.cancelUndispatched)}t.is=e})(sy||(ve.ConnectionStrategy=sy={}));var Pd;(function(t){function e(n){let r=n;return r&&(r.kind===void 0||r.kind==="id")&&wt.func(r.createCancellationTokenSource)&&(r.dispose===void 0||wt.func(r.dispose))}t.is=e})(Pd||(ve.IdCancellationReceiverStrategy=Pd={}));var oy;(function(t){function e(n){let r=n;return r&&r.kind==="request"&&wt.func(r.createCancellationTokenSource)&&(r.dispose===void 0||wt.func(r.dispose))}t.is=e})(oy||(ve.RequestCancellationReceiverStrategy=oy={}));var Nd;(function(t){t.Message=Object.freeze({createCancellationTokenSource(n){return new ey.CancellationTokenSource}});function e(n){return Pd.is(n)||oy.is(n)}t.is=e})(Nd||(ve.CancellationReceiverStrategy=Nd={}));var Rd;(function(t){t.Message=Object.freeze({sendCancellation(n,r){return n.sendNotification(Ec.type,{id:r})},cleanup(n){}});function e(n){let r=n;return r&&wt.func(r.sendCancellation)&&wt.func(r.cleanup)}t.is=e})(Rd||(ve.CancellationSenderStrategy=Rd={}));var wd;(function(t){t.Message=Object.freeze({receiver:Nd.Message,sender:Rd.Message});function e(n){let r=n;return r&&Nd.is(r.receiver)&&Rd.is(r.sender)}t.is=e})(wd||(ve.CancellationStrategy=wd={}));var Ed;(function(t){function e(n){let r=n;return r&&wt.func(r.handleMessage)}t.is=e})(Ed||(ve.MessageStrategy=Ed={}));var Vk;(function(t){function e(n){let r=n;return r&&(wd.is(r.cancellationStrategy)||sy.is(r.connectionStrategy)||Ed.is(r.messageStrategy))}t.is=e})(Vk||(ve.ConnectionOptions=Vk={}));var Ur;(function(t){t[t.New=1]="New",t[t.Listening=2]="Listening",t[t.Closed=3]="Closed",t[t.Disposed=4]="Disposed"})(Ur||(Ur={}));function jB(t,e,n,r){let i=n!==void 0?n:ve.NullLogger,s=0,o=0,a=0,c="2.0",l,u=new Map,d,f=new Map,p=new Map,m,h=new Uk.LinkedMap,y=new Map,_=new Set,v=new Map,b=Ke.Off,P=ir.Text,E,H=Ur.New,O=new Nc.Emitter,B=new Nc.Emitter,Ae=new Nc.Emitter,lt=new Nc.Emitter,Gt=new Nc.Emitter,Re=r&&r.cancellationStrategy?r.cancellationStrategy:wd.Message;function pr(R){if(R===null)throw new Error("Can't send requests with id null since the response can't be correlated.");return"req-"+R.toString()}function Ji(R){return R===null?"res-unknown-"+(++a).toString():"res-"+R.toString()}function Xu(){return"not-"+(++o).toString()}function og(R,L){he.Message.isRequest(L)?R.set(pr(L.id),L):he.Message.isResponse(L)?R.set(Ji(L.id),L):R.set(Xu(),L)}function Ju(R){}function yc(){return H===Ur.Listening}function zs(){return H===Ur.Closed}function Ci(){return H===Ur.Disposed}function $o(){(H===Ur.New||H===Ur.Listening)&&(H=Ur.Closed,B.fire(void 0))}function Gs(R){O.fire([R,void 0,void 0])}function Qu(R){O.fire(R)}t.onClose($o),t.onError(Gs),e.onClose($o),e.onError(Qu);function Tc(){m||h.size===0||(m=(0,jk.default)().timer.setImmediate(()=>{m=void 0,Zu()}))}function vc(R){he.Message.isRequest(R)?td(R):he.Message.isNotification(R)?rd(R):he.Message.isResponse(R)?nd(R):Fo(R)}function Zu(){if(h.size===0)return;let R=h.shift();try{let L=r?.messageStrategy;Ed.is(L)?L.handleMessage(R,vc):vc(R)}finally{Tc()}}let ed=R=>{try{if(he.Message.isNotification(R)&&R.method===Ec.type.method){let L=R.params.id,G=pr(L),ne=h.get(G);if(he.Message.isRequest(ne)){let Je=r?.connectionStrategy,ht=Je&&Je.cancelUndispatched?Je.cancelUndispatched(ne,Ju):void 0;if(ht&&(ht.error!==void 0||ht.result!==void 0)){h.delete(G),v.delete(L),ht.id=ne.id,Ks(ht,R.method,Date.now()),e.write(ht).catch(()=>i.error("Sending response for canceled message failed."));return}}let et=v.get(L);if(et!==void 0){et.cancel(),Bo(R);return}else _.add(L)}og(h,R)}finally{Tc()}};function td(R){if(Ci())return;function L(we,rt,ze){let Dt={jsonrpc:c,id:R.id};we instanceof he.ResponseError?Dt.error=we.toJson():Dt.result=we===void 0?null:we,Ks(Dt,rt,ze),e.write(Dt).catch(()=>i.error("Sending response failed."))}function G(we,rt,ze){let Dt={jsonrpc:c,id:R.id,error:we.toJson()};Ks(Dt,rt,ze),e.write(Dt).catch(()=>i.error("Sending response failed."))}function ne(we,rt,ze){we===void 0&&(we=null);let Dt={jsonrpc:c,id:R.id,result:we};Ks(Dt,rt,ze),e.write(Dt).catch(()=>i.error("Sending response failed."))}od(R);let et=u.get(R.method),Je,ht;et&&(Je=et.type,ht=et.handler);let kt=Date.now();if(ht||l){let we=R.id??String(Date.now()),rt=Pd.is(Re.receiver)?Re.receiver.createCancellationTokenSource(we):Re.receiver.createCancellationTokenSource(R);R.id!==null&&_.has(R.id)&&rt.cancel(),R.id!==null&&v.set(we,rt);try{let ze;if(ht)if(R.params===void 0){if(Je!==void 0&&Je.numberOfParams!==0){G(new he.ResponseError(he.ErrorCodes.InvalidParams,`Request ${R.method} defines ${Je.numberOfParams} params but received none.`),R.method,kt);return}ze=ht(rt.token)}else if(Array.isArray(R.params)){if(Je!==void 0&&Je.parameterStructures===he.ParameterStructures.byName){G(new he.ResponseError(he.ErrorCodes.InvalidParams,`Request ${R.method} defines parameters by name but received parameters by position`),R.method,kt);return}ze=ht(...R.params,rt.token)}else{if(Je!==void 0&&Je.parameterStructures===he.ParameterStructures.byPosition){G(new he.ResponseError(he.ErrorCodes.InvalidParams,`Request ${R.method} defines parameters by position but received parameters by name`),R.method,kt);return}ze=ht(R.params,rt.token)}else l&&(ze=l(R.method,R.params,rt.token));let Dt=ze;ze?Dt.then?Dt.then(Xt=>{v.delete(we),L(Xt,R.method,kt)},Xt=>{v.delete(we),Xt instanceof he.ResponseError?G(Xt,R.method,kt):Xt&&wt.string(Xt.message)?G(new he.ResponseError(he.ErrorCodes.InternalError,`Request ${R.method} failed with message: ${Xt.message}`),R.method,kt):G(new he.ResponseError(he.ErrorCodes.InternalError,`Request ${R.method} failed unexpectedly without providing any details.`),R.method,kt)}):(v.delete(we),L(ze,R.method,kt)):(v.delete(we),ne(ze,R.method,kt))}catch(ze){v.delete(we),ze instanceof he.ResponseError?L(ze,R.method,kt):ze&&wt.string(ze.message)?G(new he.ResponseError(he.ErrorCodes.InternalError,`Request ${R.method} failed with message: ${ze.message}`),R.method,kt):G(new he.ResponseError(he.ErrorCodes.InternalError,`Request ${R.method} failed unexpectedly without providing any details.`),R.method,kt)}}else G(new he.ResponseError(he.ErrorCodes.MethodNotFound,`Unhandled method ${R.method}`),R.method,kt)}function nd(R){if(!Ci())if(R.id===null)R.error?i.error(`Received response message without id: Error is:
7
+ ${JSON.stringify(R.error,void 0,4)}`):i.error("Received response message without id. No further error information provided.");else{let L=R.id,G=y.get(L);if(ad(R,G),G!==void 0){y.delete(L);try{if(R.error){let ne=R.error;G.reject(new he.ResponseError(ne.code,ne.message,ne.data))}else if(R.result!==void 0)G.resolve(R.result);else throw new Error("Should never happen.")}catch(ne){ne.message?i.error(`Response handler '${G.method}' failed with message: ${ne.message}`):i.error(`Response handler '${G.method}' failed unexpectedly.`)}}}}function rd(R){if(Ci())return;let L,G;if(R.method===Ec.type.method){let ne=R.params.id;_.delete(ne),Bo(R);return}else{let ne=f.get(R.method);ne&&(G=ne.handler,L=ne.type)}if(G||d)try{if(Bo(R),G)if(R.params===void 0)L!==void 0&&L.numberOfParams!==0&&L.parameterStructures!==he.ParameterStructures.byName&&i.error(`Notification ${R.method} defines ${L.numberOfParams} params but received none.`),G();else if(Array.isArray(R.params)){let ne=R.params;R.method===Rc.type.method&&ne.length===2&&ty.is(ne[0])?G({token:ne[0],value:ne[1]}):(L!==void 0&&(L.parameterStructures===he.ParameterStructures.byName&&i.error(`Notification ${R.method} defines parameters by name but received parameters by position`),L.numberOfParams!==R.params.length&&i.error(`Notification ${R.method} defines ${L.numberOfParams} params but received ${ne.length} arguments`)),G(...ne))}else L!==void 0&&L.parameterStructures===he.ParameterStructures.byPosition&&i.error(`Notification ${R.method} defines parameters by position but received parameters by name`),G(R.params);else d&&d(R.method,R.params)}catch(ne){ne.message?i.error(`Notification handler '${R.method}' failed with message: ${ne.message}`):i.error(`Notification handler '${R.method}' failed unexpectedly.`)}else Ae.fire(R)}function Fo(R){if(!R){i.error("Received empty message.");return}i.error(`Received message which is neither a response nor a notification message:
8
8
  ${JSON.stringify(R,null,4)}`);let L=R;if(wt.string(L.id)||wt.number(L.id)){let G=L.id,ne=y.get(G);ne&&ne.reject(new Error("The received response has neither a result nor an error property."))}}function Fr(R){if(R!=null)switch(b){case Ke.Verbose:return JSON.stringify(R,null,4);case Ke.Compact:return JSON.stringify(R);default:return}}function id(R){if(!(b===Ke.Off||!E))if(P===ir.Text){let L;(b===Ke.Verbose||b===Ke.Compact)&&R.params&&(L=`Params: ${Fr(R.params)}
9
9
 
10
10
  `),E.log(`Sending request '${R.method} - (${R.id})'.`,L)}else Di("send-request",R)}function sd(R){if(!(b===Ke.Off||!E))if(P===ir.Text){let L;(b===Ke.Verbose||b===Ke.Compact)&&(R.params?L=`Params: ${Fr(R.params)}
@@ -29,7 +29,7 @@ ${JSON.stringify(R,null,4)}`);let L=R;if(wt.string(L.id)||wt.number(L.id)){let G
29
29
 
30
30
  `:R.error===void 0&&(G=`No result returned.
31
31
 
32
- `)),L){let ne=R.error?` Request failed: ${R.error.message} (${R.error.code}).`:"";E.log(`Received response '${L.method} - (${R.id})' in ${Date.now()-L.timerStart}ms.${ne}`,G)}else E.log(`Received response ${R.id} without active response promise.`,G)}else Di("receive-response",R)}function Di(R,L){if(!E||b===Ke.Off)return;let G={isLSPMessage:!0,type:R,message:L,timestamp:Date.now()};E.log(G)}function Qi(){if(zs())throw new Yo(wc.Closed,"Connection is closed.");if(Ci())throw new Yo(wc.Disposed,"Connection is disposed.")}function cd(){if(yc())throw new Yo(wc.AlreadyListening,"Connection is already listening")}function ld(){if(!yc())throw new Error("Call listen() first.")}function ui(R){return R===void 0?null:R}function bc(R){if(R!==null)return R}function _c(R){return R!=null&&!Array.isArray(R)&&typeof R=="object"}function jo(R,L){switch(R){case pe.ParameterStructures.auto:return _c(L)?bc(L):[ui(L)];case pe.ParameterStructures.byName:if(!_c(L))throw new Error("Received parameters by name but param is not an object literal.");return bc(L);case pe.ParameterStructures.byPosition:return[ui(L)];default:throw new Error(`Unknown parameter structure ${R.toString()}`)}}function Sc(R,L){let G,ne=R.numberOfParams;switch(ne){case 0:G=void 0;break;case 1:G=jo(R.parameterStructures,L[0]);break;default:G=[];for(let et=0;et<L.length&&et<ne;et++)G.push(ui(L[et]));if(L.length<ne)for(let et=L.length;et<ne;et++)G.push(null);break}return G}let Ai={sendNotification:(R,...L)=>{Qi();let G,ne;if(wt.string(R)){G=R;let Je=L[0],ht=0,kt=pe.ParameterStructures.auto;pe.ParameterStructures.is(Je)&&(ht=1,kt=Je);let we=L.length,rt=we-ht;switch(rt){case 0:ne=void 0;break;case 1:ne=jo(kt,L[ht]);break;default:if(kt===pe.ParameterStructures.byName)throw new Error(`Received ${rt} parameters for 'by Name' notification parameter structure.`);ne=L.slice(ht,we).map(ze=>ui(ze));break}}else{let Je=L;G=R.method,ne=Sc(R,Je)}let et={jsonrpc:c,method:G,params:ne};return sd(et),e.write(et).catch(Je=>{throw i.error("Sending notification failed."),Je})},onNotification:(R,L)=>{Qi();let G;return wt.func(R)?d=R:L&&(wt.string(R)?(G=R,f.set(R,{type:void 0,handler:L})):(G=R.method,f.set(R.method,{type:R,handler:L}))),{dispose:()=>{G!==void 0?f.delete(G):d=void 0}}},onProgress:(R,L,G)=>{if(p.has(L))throw new Error(`Progress handler for token ${L} already registered`);return p.set(L,G),{dispose:()=>{p.delete(L)}}},sendProgress:(R,L,G)=>Ai.sendNotification(Rc.type,{token:L,value:G}),onUnhandledProgress:lt.event,sendRequest:(R,...L)=>{Qi(),ld();let G,ne,et;if(wt.string(R)){G=R;let we=L[0],rt=L[L.length-1],ze=0,Dt=pe.ParameterStructures.auto;pe.ParameterStructures.is(we)&&(ze=1,Dt=we);let Xt=L.length;ey.CancellationToken.is(rt)&&(Xt=Xt-1,et=rt);let rr=Xt-ze;switch(rr){case 0:ne=void 0;break;case 1:ne=jo(Dt,L[ze]);break;default:if(Dt===pe.ParameterStructures.byName)throw new Error(`Received ${rr} parameters for 'by Name' request parameter structure.`);ne=L.slice(ze,Xt).map(ud=>ui(ud));break}}else{let we=L;G=R.method,ne=Sc(R,we);let rt=R.numberOfParams;et=ey.CancellationToken.is(we[rt])?we[rt]:void 0}let Je=s++,ht;et&&(ht=et.onCancellationRequested(()=>{let we=Re.sender.sendCancellation(Ai,Je);return we===void 0?(i.log(`Received no promise from cancellation strategy when cancelling id ${Je}`),Promise.resolve()):we.catch(()=>{i.log(`Sending cancellation messages for id ${Je} failed`)})}));let kt={jsonrpc:c,id:Je,method:G,params:ne};return id(kt),typeof Re.sender.enableCancellation=="function"&&Re.sender.enableCancellation(kt),new Promise(async(we,rt)=>{let ze=rr=>{we(rr),Re.sender.cleanup(Je),ht?.dispose()},Dt=rr=>{rt(rr),Re.sender.cleanup(Je),ht?.dispose()},Xt={method:G,timerStart:Date.now(),resolve:ze,reject:Dt};try{await e.write(kt),y.set(Je,Xt)}catch(rr){throw i.error("Sending request failed."),Xt.reject(new pe.ResponseError(pe.ErrorCodes.MessageWriteError,rr.message?rr.message:"Unknown reason")),rr}})},onRequest:(R,L)=>{Qi();let G=null;return ry.is(R)?(G=void 0,l=R):wt.string(R)?(G=null,L!==void 0&&(G=R,u.set(R,{handler:L,type:void 0}))):L!==void 0&&(G=R.method,u.set(R.method,{type:R,handler:L})),{dispose:()=>{G!==null&&(G!==void 0?u.delete(G):l=void 0)}}},hasPendingResponse:()=>y.size>0,trace:async(R,L,G)=>{let ne=!1,et=ir.Text;G!==void 0&&(wt.boolean(G)?ne=G:(ne=G.sendNotification||!1,et=G.traceFormat||ir.Text)),b=R,P=et,b===Ke.Off?E=void 0:E=L,ne&&!zs()&&!Ci()&&await Ai.sendNotification(iy.type,{value:Ke.toString(R)})},onError:O.event,onClose:B.event,onUnhandledNotification:Ae.event,onDispose:Gt.event,end:()=>{e.end()},dispose:()=>{if(Ci())return;H=Ur.Disposed,Gt.fire(void 0);let R=new pe.ResponseError(pe.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(let L of y.values())L.reject(R);y=new Map,v=new Map,_=new Set,h=new Uk.LinkedMap,wt.func(e.dispose)&&e.dispose(),wt.func(t.dispose)&&t.dispose()},listen:()=>{Qi(),cd(),H=Ur.Listening,t.listen(ed)},inspect:()=>{(0,jk.default)().console.log("inspect")}};return Ai.onNotification(kd.type,R=>{if(b===Ke.Off||!E)return;let L=b===Ke.Verbose||b===Ke.Compact;E.log(R.message,L?R.verbose:void 0)}),Ai.onNotification(Rc.type,R=>{let L=p.get(R.token);L?L(R.value):lt.fire(R)}),Ai}ve.createMessageConnection=jB});var Cd=N(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.ProgressType=M.ProgressToken=M.createMessageConnection=M.NullLogger=M.ConnectionOptions=M.ConnectionStrategy=M.AbstractMessageBuffer=M.WriteableStreamMessageWriter=M.AbstractMessageWriter=M.MessageWriter=M.ReadableStreamMessageReader=M.AbstractMessageReader=M.MessageReader=M.SharedArrayReceiverStrategy=M.SharedArraySenderStrategy=M.CancellationToken=M.CancellationTokenSource=M.Emitter=M.Event=M.Disposable=M.LRUCache=M.Touch=M.LinkedMap=M.ParameterStructures=M.NotificationType9=M.NotificationType8=M.NotificationType7=M.NotificationType6=M.NotificationType5=M.NotificationType4=M.NotificationType3=M.NotificationType2=M.NotificationType1=M.NotificationType0=M.NotificationType=M.ErrorCodes=M.ResponseError=M.RequestType9=M.RequestType8=M.RequestType7=M.RequestType6=M.RequestType5=M.RequestType4=M.RequestType3=M.RequestType2=M.RequestType1=M.RequestType0=M.RequestType=M.Message=M.RAL=void 0;M.MessageStrategy=M.CancellationStrategy=M.CancellationSenderStrategy=M.CancellationReceiverStrategy=M.ConnectionError=M.ConnectionErrors=M.LogTraceNotification=M.SetTraceNotification=M.TraceFormat=M.TraceValues=M.Trace=void 0;var dt=Ig();Object.defineProperty(M,"Message",{enumerable:!0,get:function(){return dt.Message}});Object.defineProperty(M,"RequestType",{enumerable:!0,get:function(){return dt.RequestType}});Object.defineProperty(M,"RequestType0",{enumerable:!0,get:function(){return dt.RequestType0}});Object.defineProperty(M,"RequestType1",{enumerable:!0,get:function(){return dt.RequestType1}});Object.defineProperty(M,"RequestType2",{enumerable:!0,get:function(){return dt.RequestType2}});Object.defineProperty(M,"RequestType3",{enumerable:!0,get:function(){return dt.RequestType3}});Object.defineProperty(M,"RequestType4",{enumerable:!0,get:function(){return dt.RequestType4}});Object.defineProperty(M,"RequestType5",{enumerable:!0,get:function(){return dt.RequestType5}});Object.defineProperty(M,"RequestType6",{enumerable:!0,get:function(){return dt.RequestType6}});Object.defineProperty(M,"RequestType7",{enumerable:!0,get:function(){return dt.RequestType7}});Object.defineProperty(M,"RequestType8",{enumerable:!0,get:function(){return dt.RequestType8}});Object.defineProperty(M,"RequestType9",{enumerable:!0,get:function(){return dt.RequestType9}});Object.defineProperty(M,"ResponseError",{enumerable:!0,get:function(){return dt.ResponseError}});Object.defineProperty(M,"ErrorCodes",{enumerable:!0,get:function(){return dt.ErrorCodes}});Object.defineProperty(M,"NotificationType",{enumerable:!0,get:function(){return dt.NotificationType}});Object.defineProperty(M,"NotificationType0",{enumerable:!0,get:function(){return dt.NotificationType0}});Object.defineProperty(M,"NotificationType1",{enumerable:!0,get:function(){return dt.NotificationType1}});Object.defineProperty(M,"NotificationType2",{enumerable:!0,get:function(){return dt.NotificationType2}});Object.defineProperty(M,"NotificationType3",{enumerable:!0,get:function(){return dt.NotificationType3}});Object.defineProperty(M,"NotificationType4",{enumerable:!0,get:function(){return dt.NotificationType4}});Object.defineProperty(M,"NotificationType5",{enumerable:!0,get:function(){return dt.NotificationType5}});Object.defineProperty(M,"NotificationType6",{enumerable:!0,get:function(){return dt.NotificationType6}});Object.defineProperty(M,"NotificationType7",{enumerable:!0,get:function(){return dt.NotificationType7}});Object.defineProperty(M,"NotificationType8",{enumerable:!0,get:function(){return dt.NotificationType8}});Object.defineProperty(M,"NotificationType9",{enumerable:!0,get:function(){return dt.NotificationType9}});Object.defineProperty(M,"ParameterStructures",{enumerable:!0,get:function(){return dt.ParameterStructures}});var ay=Mg();Object.defineProperty(M,"LinkedMap",{enumerable:!0,get:function(){return ay.LinkedMap}});Object.defineProperty(M,"LRUCache",{enumerable:!0,get:function(){return ay.LRUCache}});Object.defineProperty(M,"Touch",{enumerable:!0,get:function(){return ay.Touch}});var UB=Dk();Object.defineProperty(M,"Disposable",{enumerable:!0,get:function(){return UB.Disposable}});var zk=Wo();Object.defineProperty(M,"Event",{enumerable:!0,get:function(){return zk.Event}});Object.defineProperty(M,"Emitter",{enumerable:!0,get:function(){return zk.Emitter}});var Gk=Td();Object.defineProperty(M,"CancellationTokenSource",{enumerable:!0,get:function(){return Gk.CancellationTokenSource}});Object.defineProperty(M,"CancellationToken",{enumerable:!0,get:function(){return Gk.CancellationToken}});var Kk=Ik();Object.defineProperty(M,"SharedArraySenderStrategy",{enumerable:!0,get:function(){return Kk.SharedArraySenderStrategy}});Object.defineProperty(M,"SharedArrayReceiverStrategy",{enumerable:!0,get:function(){return Kk.SharedArrayReceiverStrategy}});var cy=Mk();Object.defineProperty(M,"MessageReader",{enumerable:!0,get:function(){return cy.MessageReader}});Object.defineProperty(M,"AbstractMessageReader",{enumerable:!0,get:function(){return cy.AbstractMessageReader}});Object.defineProperty(M,"ReadableStreamMessageReader",{enumerable:!0,get:function(){return cy.ReadableStreamMessageReader}});var ly=Fk();Object.defineProperty(M,"MessageWriter",{enumerable:!0,get:function(){return ly.MessageWriter}});Object.defineProperty(M,"AbstractMessageWriter",{enumerable:!0,get:function(){return ly.AbstractMessageWriter}});Object.defineProperty(M,"WriteableStreamMessageWriter",{enumerable:!0,get:function(){return ly.WriteableStreamMessageWriter}});var HB=Bk();Object.defineProperty(M,"AbstractMessageBuffer",{enumerable:!0,get:function(){return HB.AbstractMessageBuffer}});var an=Wk();Object.defineProperty(M,"ConnectionStrategy",{enumerable:!0,get:function(){return an.ConnectionStrategy}});Object.defineProperty(M,"ConnectionOptions",{enumerable:!0,get:function(){return an.ConnectionOptions}});Object.defineProperty(M,"NullLogger",{enumerable:!0,get:function(){return an.NullLogger}});Object.defineProperty(M,"createMessageConnection",{enumerable:!0,get:function(){return an.createMessageConnection}});Object.defineProperty(M,"ProgressToken",{enumerable:!0,get:function(){return an.ProgressToken}});Object.defineProperty(M,"ProgressType",{enumerable:!0,get:function(){return an.ProgressType}});Object.defineProperty(M,"Trace",{enumerable:!0,get:function(){return an.Trace}});Object.defineProperty(M,"TraceValues",{enumerable:!0,get:function(){return an.TraceValues}});Object.defineProperty(M,"TraceFormat",{enumerable:!0,get:function(){return an.TraceFormat}});Object.defineProperty(M,"SetTraceNotification",{enumerable:!0,get:function(){return an.SetTraceNotification}});Object.defineProperty(M,"LogTraceNotification",{enumerable:!0,get:function(){return an.LogTraceNotification}});Object.defineProperty(M,"ConnectionErrors",{enumerable:!0,get:function(){return an.ConnectionErrors}});Object.defineProperty(M,"ConnectionError",{enumerable:!0,get:function(){return an.ConnectionError}});Object.defineProperty(M,"CancellationReceiverStrategy",{enumerable:!0,get:function(){return an.CancellationReceiverStrategy}});Object.defineProperty(M,"CancellationSenderStrategy",{enumerable:!0,get:function(){return an.CancellationSenderStrategy}});Object.defineProperty(M,"CancellationStrategy",{enumerable:!0,get:function(){return an.CancellationStrategy}});Object.defineProperty(M,"MessageStrategy",{enumerable:!0,get:function(){return an.MessageStrategy}});var VB=es();M.RAL=VB.default});var Jk=N(py=>{"use strict";Object.defineProperty(py,"__esModule",{value:!0});var Yk=require("util"),Oi=Cd(),Dd=class t extends Oi.AbstractMessageBuffer{constructor(e="utf-8"){super(e)}emptyBuffer(){return t.emptyBuffer}fromString(e,n){return Buffer.from(e,n)}toString(e,n){return e instanceof Buffer?e.toString(n):new Yk.TextDecoder(n).decode(e)}asNative(e,n){return n===void 0?e instanceof Buffer?e:Buffer.from(e):e instanceof Buffer?e.slice(0,n):Buffer.from(e,0,n)}allocNative(e){return Buffer.allocUnsafe(e)}};Dd.emptyBuffer=Buffer.allocUnsafe(0);var uy=class{constructor(e){this.stream=e}onClose(e){return this.stream.on("close",e),Oi.Disposable.create(()=>this.stream.off("close",e))}onError(e){return this.stream.on("error",e),Oi.Disposable.create(()=>this.stream.off("error",e))}onEnd(e){return this.stream.on("end",e),Oi.Disposable.create(()=>this.stream.off("end",e))}onData(e){return this.stream.on("data",e),Oi.Disposable.create(()=>this.stream.off("data",e))}},dy=class{constructor(e){this.stream=e}onClose(e){return this.stream.on("close",e),Oi.Disposable.create(()=>this.stream.off("close",e))}onError(e){return this.stream.on("error",e),Oi.Disposable.create(()=>this.stream.off("error",e))}onEnd(e){return this.stream.on("end",e),Oi.Disposable.create(()=>this.stream.off("end",e))}write(e,n){return new Promise((r,i)=>{let s=o=>{o==null?r():i(o)};typeof e=="string"?this.stream.write(e,n,s):this.stream.write(e,s)})}end(){this.stream.end()}},Xk=Object.freeze({messageBuffer:Object.freeze({create:t=>new Dd(t)}),applicationJson:Object.freeze({encoder:Object.freeze({name:"application/json",encode:(t,e)=>{try{return Promise.resolve(Buffer.from(JSON.stringify(t,void 0,0),e.charset))}catch(n){return Promise.reject(n)}}}),decoder:Object.freeze({name:"application/json",decode:(t,e)=>{try{return t instanceof Buffer?Promise.resolve(JSON.parse(t.toString(e.charset))):Promise.resolve(JSON.parse(new Yk.TextDecoder(e.charset).decode(t)))}catch(n){return Promise.reject(n)}}})}),stream:Object.freeze({asReadableStream:t=>new uy(t),asWritableStream:t=>new dy(t)}),console,timer:Object.freeze({setTimeout(t,e,...n){let r=setTimeout(t,e,...n);return{dispose:()=>clearTimeout(r)}},setImmediate(t,...e){let n=setImmediate(t,...e);return{dispose:()=>clearImmediate(n)}},setInterval(t,e,...n){let r=setInterval(t,e,...n);return{dispose:()=>clearInterval(r)}}})});function fy(){return Xk}(function(t){function e(){Oi.RAL.install(Xk)}t.install=e})(fy||(fy={}));py.default=fy});var Qs=N(Oe=>{"use strict";var WB=Oe&&Oe.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),zB=Oe&&Oe.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&WB(e,t,n)};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.createMessageConnection=Oe.createServerSocketTransport=Oe.createClientSocketTransport=Oe.createServerPipeTransport=Oe.createClientPipeTransport=Oe.generateRandomPipeName=Oe.StreamMessageWriter=Oe.StreamMessageReader=Oe.SocketMessageWriter=Oe.SocketMessageReader=Oe.PortMessageWriter=Oe.PortMessageReader=Oe.IPCMessageWriter=Oe.IPCMessageReader=void 0;var Xo=Jk();Xo.default.install();var Qk=require("path"),GB=require("os"),KB=require("crypto"),Od=require("net"),sr=Cd();zB(Cd(),Oe);var hy=class extends sr.AbstractMessageReader{constructor(e){super(),this.process=e;let n=this.process;n.on("error",r=>this.fireError(r)),n.on("close",()=>this.fireClose())}listen(e){return this.process.on("message",e),sr.Disposable.create(()=>this.process.off("message",e))}};Oe.IPCMessageReader=hy;var my=class extends sr.AbstractMessageWriter{constructor(e){super(),this.process=e,this.errorCount=0;let n=this.process;n.on("error",r=>this.fireError(r)),n.on("close",()=>this.fireClose)}write(e){try{return typeof this.process.send=="function"&&this.process.send(e,void 0,void 0,n=>{n?(this.errorCount++,this.handleError(n,e)):this.errorCount=0}),Promise.resolve()}catch(n){return this.handleError(n,e),Promise.reject(n)}}handleError(e,n){this.errorCount++,this.fireError(e,n,this.errorCount)}end(){}};Oe.IPCMessageWriter=my;var gy=class extends sr.AbstractMessageReader{constructor(e){super(),this.onData=new sr.Emitter,e.on("close",()=>this.fireClose),e.on("error",n=>this.fireError(n)),e.on("message",n=>{this.onData.fire(n)})}listen(e){return this.onData.event(e)}};Oe.PortMessageReader=gy;var yy=class extends sr.AbstractMessageWriter{constructor(e){super(),this.port=e,this.errorCount=0,e.on("close",()=>this.fireClose()),e.on("error",n=>this.fireError(n))}write(e){try{return this.port.postMessage(e),Promise.resolve()}catch(n){return this.handleError(n,e),Promise.reject(n)}}handleError(e,n){this.errorCount++,this.fireError(e,n,this.errorCount)}end(){}};Oe.PortMessageWriter=yy;var Xs=class extends sr.ReadableStreamMessageReader{constructor(e,n="utf-8"){super((0,Xo.default)().stream.asReadableStream(e),n)}};Oe.SocketMessageReader=Xs;var Js=class extends sr.WriteableStreamMessageWriter{constructor(e,n){super((0,Xo.default)().stream.asWritableStream(e),n),this.socket=e}dispose(){super.dispose(),this.socket.destroy()}};Oe.SocketMessageWriter=Js;var Ad=class extends sr.ReadableStreamMessageReader{constructor(e,n){super((0,Xo.default)().stream.asReadableStream(e),n)}};Oe.StreamMessageReader=Ad;var Id=class extends sr.WriteableStreamMessageWriter{constructor(e,n){super((0,Xo.default)().stream.asWritableStream(e),n)}};Oe.StreamMessageWriter=Id;var Zk=process.env.XDG_RUNTIME_DIR,YB=new Map([["linux",107],["darwin",103]]);function XB(){let t=(0,KB.randomBytes)(21).toString("hex");if(process.platform==="win32")return`\\\\.\\pipe\\vscode-jsonrpc-${t}-sock`;let e;Zk?e=Qk.join(Zk,`vscode-ipc-${t}.sock`):e=Qk.join(GB.tmpdir(),`vscode-${t}.sock`);let n=YB.get(process.platform);return n!==void 0&&e.length>n&&(0,Xo.default)().console.warn(`WARNING: IPC handle "${e}" is longer than ${n} characters.`),e}Oe.generateRandomPipeName=XB;function JB(t,e="utf-8"){let n,r=new Promise((i,s)=>{n=i});return new Promise((i,s)=>{let o=(0,Od.createServer)(a=>{o.close(),n([new Xs(a,e),new Js(a,e)])});o.on("error",s),o.listen(t,()=>{o.removeListener("error",s),i({onConnected:()=>r})})})}Oe.createClientPipeTransport=JB;function QB(t,e="utf-8"){let n=(0,Od.createConnection)(t);return[new Xs(n,e),new Js(n,e)]}Oe.createServerPipeTransport=QB;function ZB(t,e="utf-8"){let n,r=new Promise((i,s)=>{n=i});return new Promise((i,s)=>{let o=(0,Od.createServer)(a=>{o.close(),n([new Xs(a,e),new Js(a,e)])});o.on("error",s),o.listen(t,"127.0.0.1",()=>{o.removeListener("error",s),i({onConnected:()=>r})})})}Oe.createClientSocketTransport=ZB;function ej(t,e="utf-8"){let n=(0,Od.createConnection)(t,"127.0.0.1");return[new Xs(n,e),new Js(n,e)]}Oe.createServerSocketTransport=ej;function tj(t){let e=t;return e.read!==void 0&&e.addListener!==void 0}function nj(t){let e=t;return e.write!==void 0&&e.addListener!==void 0}function rj(t,e,n,r){n||(n=sr.NullLogger);let i=tj(t)?new Ad(t):t,s=nj(e)?new Id(e):e;return sr.ConnectionStrategy.is(r)&&(r={connectionStrategy:r}),(0,sr.createMessageConnection)(i,s,n,r)}Oe.createMessageConnection=rj});var Ty=N((DQ,eP)=>{"use strict";eP.exports=Qs()});var xd=N((tP,Md)=>{(function(t){if(typeof Md=="object"&&typeof Md.exports=="object"){var e=t(require,tP);e!==void 0&&(Md.exports=e)}else typeof define=="function"&&define.amd&&define(["require","exports"],t)})(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextDocument=e.EOL=e.WorkspaceFolder=e.InlineCompletionContext=e.SelectedCompletionInfo=e.InlineCompletionTriggerKind=e.InlineCompletionList=e.InlineCompletionItem=e.StringValue=e.InlayHint=e.InlayHintLabelPart=e.InlayHintKind=e.InlineValueContext=e.InlineValueEvaluatableExpression=e.InlineValueVariableLookup=e.InlineValueText=e.SemanticTokens=e.SemanticTokenModifiers=e.SemanticTokenTypes=e.SelectionRange=e.DocumentLink=e.FormattingOptions=e.CodeLens=e.CodeAction=e.CodeActionContext=e.CodeActionTriggerKind=e.CodeActionKind=e.DocumentSymbol=e.WorkspaceSymbol=e.SymbolInformation=e.SymbolTag=e.SymbolKind=e.DocumentHighlight=e.DocumentHighlightKind=e.SignatureInformation=e.ParameterInformation=e.Hover=e.MarkedString=e.CompletionList=e.CompletionItem=e.CompletionItemLabelDetails=e.InsertTextMode=e.InsertReplaceEdit=e.CompletionItemTag=e.InsertTextFormat=e.CompletionItemKind=e.MarkupContent=e.MarkupKind=e.TextDocumentItem=e.OptionalVersionedTextDocumentIdentifier=e.VersionedTextDocumentIdentifier=e.TextDocumentIdentifier=e.WorkspaceChange=e.WorkspaceEdit=e.DeleteFile=e.RenameFile=e.CreateFile=e.TextDocumentEdit=e.AnnotatedTextEdit=e.ChangeAnnotationIdentifier=e.ChangeAnnotation=e.TextEdit=e.Command=e.Diagnostic=e.CodeDescription=e.DiagnosticTag=e.DiagnosticSeverity=e.DiagnosticRelatedInformation=e.FoldingRange=e.FoldingRangeKind=e.ColorPresentation=e.ColorInformation=e.Color=e.LocationLink=e.Location=e.Range=e.Position=e.uinteger=e.integer=e.URI=e.DocumentUri=void 0;var n;(function(T){function w(C){return typeof C=="string"}T.is=w})(n||(e.DocumentUri=n={}));var r;(function(T){function w(C){return typeof C=="string"}T.is=w})(r||(e.URI=r={}));var i;(function(T){T.MIN_VALUE=-2147483648,T.MAX_VALUE=2147483647;function w(C){return typeof C=="number"&&T.MIN_VALUE<=C&&C<=T.MAX_VALUE}T.is=w})(i||(e.integer=i={}));var s;(function(T){T.MIN_VALUE=0,T.MAX_VALUE=2147483647;function w(C){return typeof C=="number"&&T.MIN_VALUE<=C&&C<=T.MAX_VALUE}T.is=w})(s||(e.uinteger=s={}));var o;(function(T){function w(S,g){return S===Number.MAX_VALUE&&(S=s.MAX_VALUE),g===Number.MAX_VALUE&&(g=s.MAX_VALUE),{line:S,character:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.uinteger(g.line)&&A.uinteger(g.character)}T.is=C})(o||(e.Position=o={}));var a;(function(T){function w(S,g,D,$){if(A.uinteger(S)&&A.uinteger(g)&&A.uinteger(D)&&A.uinteger($))return{start:o.create(S,g),end:o.create(D,$)};if(o.is(S)&&o.is(g))return{start:S,end:g};throw new Error("Range#create called with invalid arguments[".concat(S,", ").concat(g,", ").concat(D,", ").concat($,"]"))}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&o.is(g.start)&&o.is(g.end)}T.is=C})(a||(e.Range=a={}));var c;(function(T){function w(S,g){return{uri:S,range:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.range)&&(A.string(g.uri)||A.undefined(g.uri))}T.is=C})(c||(e.Location=c={}));var l;(function(T){function w(S,g,D,$){return{targetUri:S,targetRange:g,targetSelectionRange:D,originSelectionRange:$}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.targetRange)&&A.string(g.targetUri)&&a.is(g.targetSelectionRange)&&(a.is(g.originSelectionRange)||A.undefined(g.originSelectionRange))}T.is=C})(l||(e.LocationLink=l={}));var u;(function(T){function w(S,g,D,$){return{red:S,green:g,blue:D,alpha:$}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.numberRange(g.red,0,1)&&A.numberRange(g.green,0,1)&&A.numberRange(g.blue,0,1)&&A.numberRange(g.alpha,0,1)}T.is=C})(u||(e.Color=u={}));var d;(function(T){function w(S,g){return{range:S,color:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.range)&&u.is(g.color)}T.is=C})(d||(e.ColorInformation=d={}));var f;(function(T){function w(S,g,D){return{label:S,textEdit:g,additionalTextEdits:D}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.string(g.label)&&(A.undefined(g.textEdit)||E.is(g))&&(A.undefined(g.additionalTextEdits)||A.typedArray(g.additionalTextEdits,E.is))}T.is=C})(f||(e.ColorPresentation=f={}));var p;(function(T){T.Comment="comment",T.Imports="imports",T.Region="region"})(p||(e.FoldingRangeKind=p={}));var m;(function(T){function w(S,g,D,$,Te,At){var ut={startLine:S,endLine:g};return A.defined(D)&&(ut.startCharacter=D),A.defined($)&&(ut.endCharacter=$),A.defined(Te)&&(ut.kind=Te),A.defined(At)&&(ut.collapsedText=At),ut}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.uinteger(g.startLine)&&A.uinteger(g.startLine)&&(A.undefined(g.startCharacter)||A.uinteger(g.startCharacter))&&(A.undefined(g.endCharacter)||A.uinteger(g.endCharacter))&&(A.undefined(g.kind)||A.string(g.kind))}T.is=C})(m||(e.FoldingRange=m={}));var h;(function(T){function w(S,g){return{location:S,message:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&c.is(g.location)&&A.string(g.message)}T.is=C})(h||(e.DiagnosticRelatedInformation=h={}));var y;(function(T){T.Error=1,T.Warning=2,T.Information=3,T.Hint=4})(y||(e.DiagnosticSeverity=y={}));var _;(function(T){T.Unnecessary=1,T.Deprecated=2})(_||(e.DiagnosticTag=_={}));var v;(function(T){function w(C){var S=C;return A.objectLiteral(S)&&A.string(S.href)}T.is=w})(v||(e.CodeDescription=v={}));var b;(function(T){function w(S,g,D,$,Te,At){var ut={range:S,message:g};return A.defined(D)&&(ut.severity=D),A.defined($)&&(ut.code=$),A.defined(Te)&&(ut.source=Te),A.defined(At)&&(ut.relatedInformation=At),ut}T.create=w;function C(S){var g,D=S;return A.defined(D)&&a.is(D.range)&&A.string(D.message)&&(A.number(D.severity)||A.undefined(D.severity))&&(A.integer(D.code)||A.string(D.code)||A.undefined(D.code))&&(A.undefined(D.codeDescription)||A.string((g=D.codeDescription)===null||g===void 0?void 0:g.href))&&(A.string(D.source)||A.undefined(D.source))&&(A.undefined(D.relatedInformation)||A.typedArray(D.relatedInformation,h.is))}T.is=C})(b||(e.Diagnostic=b={}));var P;(function(T){function w(S,g){for(var D=[],$=2;$<arguments.length;$++)D[$-2]=arguments[$];var Te={title:S,command:g};return A.defined(D)&&D.length>0&&(Te.arguments=D),Te}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.title)&&A.string(g.command)}T.is=C})(P||(e.Command=P={}));var E;(function(T){function w(D,$){return{range:D,newText:$}}T.replace=w;function C(D,$){return{range:{start:D,end:D},newText:$}}T.insert=C;function S(D){return{range:D,newText:""}}T.del=S;function g(D){var $=D;return A.objectLiteral($)&&A.string($.newText)&&a.is($.range)}T.is=g})(E||(e.TextEdit=E={}));var H;(function(T){function w(S,g,D){var $={label:S};return g!==void 0&&($.needsConfirmation=g),D!==void 0&&($.description=D),$}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.string(g.label)&&(A.boolean(g.needsConfirmation)||g.needsConfirmation===void 0)&&(A.string(g.description)||g.description===void 0)}T.is=C})(H||(e.ChangeAnnotation=H={}));var O;(function(T){function w(C){var S=C;return A.string(S)}T.is=w})(O||(e.ChangeAnnotationIdentifier=O={}));var B;(function(T){function w(D,$,Te){return{range:D,newText:$,annotationId:Te}}T.replace=w;function C(D,$,Te){return{range:{start:D,end:D},newText:$,annotationId:Te}}T.insert=C;function S(D,$){return{range:D,newText:"",annotationId:$}}T.del=S;function g(D){var $=D;return E.is($)&&(H.is($.annotationId)||O.is($.annotationId))}T.is=g})(B||(e.AnnotatedTextEdit=B={}));var Ae;(function(T){function w(S,g){return{textDocument:S,edits:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&zs.is(g.textDocument)&&Array.isArray(g.edits)}T.is=C})(Ae||(e.TextDocumentEdit=Ae={}));var lt;(function(T){function w(S,g,D){var $={kind:"create",uri:S};return g!==void 0&&(g.overwrite!==void 0||g.ignoreIfExists!==void 0)&&($.options=g),D!==void 0&&($.annotationId=D),$}T.create=w;function C(S){var g=S;return g&&g.kind==="create"&&A.string(g.uri)&&(g.options===void 0||(g.options.overwrite===void 0||A.boolean(g.options.overwrite))&&(g.options.ignoreIfExists===void 0||A.boolean(g.options.ignoreIfExists)))&&(g.annotationId===void 0||O.is(g.annotationId))}T.is=C})(lt||(e.CreateFile=lt={}));var Gt;(function(T){function w(S,g,D,$){var Te={kind:"rename",oldUri:S,newUri:g};return D!==void 0&&(D.overwrite!==void 0||D.ignoreIfExists!==void 0)&&(Te.options=D),$!==void 0&&(Te.annotationId=$),Te}T.create=w;function C(S){var g=S;return g&&g.kind==="rename"&&A.string(g.oldUri)&&A.string(g.newUri)&&(g.options===void 0||(g.options.overwrite===void 0||A.boolean(g.options.overwrite))&&(g.options.ignoreIfExists===void 0||A.boolean(g.options.ignoreIfExists)))&&(g.annotationId===void 0||O.is(g.annotationId))}T.is=C})(Gt||(e.RenameFile=Gt={}));var Re;(function(T){function w(S,g,D){var $={kind:"delete",uri:S};return g!==void 0&&(g.recursive!==void 0||g.ignoreIfNotExists!==void 0)&&($.options=g),D!==void 0&&($.annotationId=D),$}T.create=w;function C(S){var g=S;return g&&g.kind==="delete"&&A.string(g.uri)&&(g.options===void 0||(g.options.recursive===void 0||A.boolean(g.options.recursive))&&(g.options.ignoreIfNotExists===void 0||A.boolean(g.options.ignoreIfNotExists)))&&(g.annotationId===void 0||O.is(g.annotationId))}T.is=C})(Re||(e.DeleteFile=Re={}));var pr;(function(T){function w(C){var S=C;return S&&(S.changes!==void 0||S.documentChanges!==void 0)&&(S.documentChanges===void 0||S.documentChanges.every(function(g){return A.string(g.kind)?lt.is(g)||Gt.is(g)||Re.is(g):Ae.is(g)}))}T.is=w})(pr||(e.WorkspaceEdit=pr={}));var Ji=function(){function T(w,C){this.edits=w,this.changeAnnotations=C}return T.prototype.insert=function(w,C,S){var g,D;if(S===void 0?g=E.insert(w,C):O.is(S)?(D=S,g=B.insert(w,C,S)):(this.assertChangeAnnotations(this.changeAnnotations),D=this.changeAnnotations.manage(S),g=B.insert(w,C,D)),this.edits.push(g),D!==void 0)return D},T.prototype.replace=function(w,C,S){var g,D;if(S===void 0?g=E.replace(w,C):O.is(S)?(D=S,g=B.replace(w,C,S)):(this.assertChangeAnnotations(this.changeAnnotations),D=this.changeAnnotations.manage(S),g=B.replace(w,C,D)),this.edits.push(g),D!==void 0)return D},T.prototype.delete=function(w,C){var S,g;if(C===void 0?S=E.del(w):O.is(C)?(g=C,S=B.del(w,C)):(this.assertChangeAnnotations(this.changeAnnotations),g=this.changeAnnotations.manage(C),S=B.del(w,g)),this.edits.push(S),g!==void 0)return g},T.prototype.add=function(w){this.edits.push(w)},T.prototype.all=function(){return this.edits},T.prototype.clear=function(){this.edits.splice(0,this.edits.length)},T.prototype.assertChangeAnnotations=function(w){if(w===void 0)throw new Error("Text edit change is not configured to manage change annotations.")},T}(),Xu=function(){function T(w){this._annotations=w===void 0?Object.create(null):w,this._counter=0,this._size=0}return T.prototype.all=function(){return this._annotations},Object.defineProperty(T.prototype,"size",{get:function(){return this._size},enumerable:!1,configurable:!0}),T.prototype.manage=function(w,C){var S;if(O.is(w)?S=w:(S=this.nextId(),C=w),this._annotations[S]!==void 0)throw new Error("Id ".concat(S," is already in use."));if(C===void 0)throw new Error("No annotation provided for id ".concat(S));return this._annotations[S]=C,this._size++,S},T.prototype.nextId=function(){return this._counter++,this._counter.toString()},T}(),og=function(){function T(w){var C=this;this._textEditChanges=Object.create(null),w!==void 0?(this._workspaceEdit=w,w.documentChanges?(this._changeAnnotations=new Xu(w.changeAnnotations),w.changeAnnotations=this._changeAnnotations.all(),w.documentChanges.forEach(function(S){if(Ae.is(S)){var g=new Ji(S.edits,C._changeAnnotations);C._textEditChanges[S.textDocument.uri]=g}})):w.changes&&Object.keys(w.changes).forEach(function(S){var g=new Ji(w.changes[S]);C._textEditChanges[S]=g})):this._workspaceEdit={}}return Object.defineProperty(T.prototype,"edit",{get:function(){return this.initDocumentChanges(),this._changeAnnotations!==void 0&&(this._changeAnnotations.size===0?this._workspaceEdit.changeAnnotations=void 0:this._workspaceEdit.changeAnnotations=this._changeAnnotations.all()),this._workspaceEdit},enumerable:!1,configurable:!0}),T.prototype.getTextEditChange=function(w){if(zs.is(w)){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var C={uri:w.uri,version:w.version},S=this._textEditChanges[C.uri];if(!S){var g=[],D={textDocument:C,edits:g};this._workspaceEdit.documentChanges.push(D),S=new Ji(g,this._changeAnnotations),this._textEditChanges[C.uri]=S}return S}else{if(this.initChanges(),this._workspaceEdit.changes===void 0)throw new Error("Workspace edit is not configured for normal text edit changes.");var S=this._textEditChanges[w];if(!S){var g=[];this._workspaceEdit.changes[w]=g,S=new Ji(g),this._textEditChanges[w]=S}return S}},T.prototype.initDocumentChanges=function(){this._workspaceEdit.documentChanges===void 0&&this._workspaceEdit.changes===void 0&&(this._changeAnnotations=new Xu,this._workspaceEdit.documentChanges=[],this._workspaceEdit.changeAnnotations=this._changeAnnotations.all())},T.prototype.initChanges=function(){this._workspaceEdit.documentChanges===void 0&&this._workspaceEdit.changes===void 0&&(this._workspaceEdit.changes=Object.create(null))},T.prototype.createFile=function(w,C,S){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var g;H.is(C)||O.is(C)?g=C:S=C;var D,$;if(g===void 0?D=lt.create(w,S):($=O.is(g)?g:this._changeAnnotations.manage(g),D=lt.create(w,S,$)),this._workspaceEdit.documentChanges.push(D),$!==void 0)return $},T.prototype.renameFile=function(w,C,S,g){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var D;H.is(S)||O.is(S)?D=S:g=S;var $,Te;if(D===void 0?$=Gt.create(w,C,g):(Te=O.is(D)?D:this._changeAnnotations.manage(D),$=Gt.create(w,C,g,Te)),this._workspaceEdit.documentChanges.push($),Te!==void 0)return Te},T.prototype.deleteFile=function(w,C,S){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var g;H.is(C)||O.is(C)?g=C:S=C;var D,$;if(g===void 0?D=Re.create(w,S):($=O.is(g)?g:this._changeAnnotations.manage(g),D=Re.create(w,S,$)),this._workspaceEdit.documentChanges.push(D),$!==void 0)return $},T}();e.WorkspaceChange=og;var Ju;(function(T){function w(S){return{uri:S}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)}T.is=C})(Ju||(e.TextDocumentIdentifier=Ju={}));var yc;(function(T){function w(S,g){return{uri:S,version:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)&&A.integer(g.version)}T.is=C})(yc||(e.VersionedTextDocumentIdentifier=yc={}));var zs;(function(T){function w(S,g){return{uri:S,version:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)&&(g.version===null||A.integer(g.version))}T.is=C})(zs||(e.OptionalVersionedTextDocumentIdentifier=zs={}));var Ci;(function(T){function w(S,g,D,$){return{uri:S,languageId:g,version:D,text:$}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)&&A.string(g.languageId)&&A.integer(g.version)&&A.string(g.text)}T.is=C})(Ci||(e.TextDocumentItem=Ci={}));var $o;(function(T){T.PlainText="plaintext",T.Markdown="markdown";function w(C){var S=C;return S===T.PlainText||S===T.Markdown}T.is=w})($o||(e.MarkupKind=$o={}));var Gs;(function(T){function w(C){var S=C;return A.objectLiteral(C)&&$o.is(S.kind)&&A.string(S.value)}T.is=w})(Gs||(e.MarkupContent=Gs={}));var Qu;(function(T){T.Text=1,T.Method=2,T.Function=3,T.Constructor=4,T.Field=5,T.Variable=6,T.Class=7,T.Interface=8,T.Module=9,T.Property=10,T.Unit=11,T.Value=12,T.Enum=13,T.Keyword=14,T.Snippet=15,T.Color=16,T.File=17,T.Reference=18,T.Folder=19,T.EnumMember=20,T.Constant=21,T.Struct=22,T.Event=23,T.Operator=24,T.TypeParameter=25})(Qu||(e.CompletionItemKind=Qu={}));var Tc;(function(T){T.PlainText=1,T.Snippet=2})(Tc||(e.InsertTextFormat=Tc={}));var vc;(function(T){T.Deprecated=1})(vc||(e.CompletionItemTag=vc={}));var Zu;(function(T){function w(S,g,D){return{newText:S,insert:g,replace:D}}T.create=w;function C(S){var g=S;return g&&A.string(g.newText)&&a.is(g.insert)&&a.is(g.replace)}T.is=C})(Zu||(e.InsertReplaceEdit=Zu={}));var ed;(function(T){T.asIs=1,T.adjustIndentation=2})(ed||(e.InsertTextMode=ed={}));var td;(function(T){function w(C){var S=C;return S&&(A.string(S.detail)||S.detail===void 0)&&(A.string(S.description)||S.description===void 0)}T.is=w})(td||(e.CompletionItemLabelDetails=td={}));var nd;(function(T){function w(C){return{label:C}}T.create=w})(nd||(e.CompletionItem=nd={}));var rd;(function(T){function w(C,S){return{items:C||[],isIncomplete:!!S}}T.create=w})(rd||(e.CompletionList=rd={}));var Fo;(function(T){function w(S){return S.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}T.fromPlainText=w;function C(S){var g=S;return A.string(g)||A.objectLiteral(g)&&A.string(g.language)&&A.string(g.value)}T.is=C})(Fo||(e.MarkedString=Fo={}));var Fr;(function(T){function w(C){var S=C;return!!S&&A.objectLiteral(S)&&(Gs.is(S.contents)||Fo.is(S.contents)||A.typedArray(S.contents,Fo.is))&&(C.range===void 0||a.is(C.range))}T.is=w})(Fr||(e.Hover=Fr={}));var id;(function(T){function w(C,S){return S?{label:C,documentation:S}:{label:C}}T.create=w})(id||(e.ParameterInformation=id={}));var sd;(function(T){function w(C,S){for(var g=[],D=2;D<arguments.length;D++)g[D-2]=arguments[D];var $={label:C};return A.defined(S)&&($.documentation=S),A.defined(g)?$.parameters=g:$.parameters=[],$}T.create=w})(sd||(e.SignatureInformation=sd={}));var Ks;(function(T){T.Text=1,T.Read=2,T.Write=3})(Ks||(e.DocumentHighlightKind=Ks={}));var od;(function(T){function w(C,S){var g={range:C};return A.number(S)&&(g.kind=S),g}T.create=w})(od||(e.DocumentHighlight=od={}));var Bo;(function(T){T.File=1,T.Module=2,T.Namespace=3,T.Package=4,T.Class=5,T.Method=6,T.Property=7,T.Field=8,T.Constructor=9,T.Enum=10,T.Interface=11,T.Function=12,T.Variable=13,T.Constant=14,T.String=15,T.Number=16,T.Boolean=17,T.Array=18,T.Object=19,T.Key=20,T.Null=21,T.EnumMember=22,T.Struct=23,T.Event=24,T.Operator=25,T.TypeParameter=26})(Bo||(e.SymbolKind=Bo={}));var ad;(function(T){T.Deprecated=1})(ad||(e.SymbolTag=ad={}));var Di;(function(T){function w(C,S,g,D,$){var Te={name:C,kind:S,location:{uri:D,range:g}};return $&&(Te.containerName=$),Te}T.create=w})(Di||(e.SymbolInformation=Di={}));var Qi;(function(T){function w(C,S,g,D){return D!==void 0?{name:C,kind:S,location:{uri:g,range:D}}:{name:C,kind:S,location:{uri:g}}}T.create=w})(Qi||(e.WorkspaceSymbol=Qi={}));var cd;(function(T){function w(S,g,D,$,Te,At){var ut={name:S,detail:g,kind:D,range:$,selectionRange:Te};return At!==void 0&&(ut.children=At),ut}T.create=w;function C(S){var g=S;return g&&A.string(g.name)&&A.number(g.kind)&&a.is(g.range)&&a.is(g.selectionRange)&&(g.detail===void 0||A.string(g.detail))&&(g.deprecated===void 0||A.boolean(g.deprecated))&&(g.children===void 0||Array.isArray(g.children))&&(g.tags===void 0||Array.isArray(g.tags))}T.is=C})(cd||(e.DocumentSymbol=cd={}));var ld;(function(T){T.Empty="",T.QuickFix="quickfix",T.Refactor="refactor",T.RefactorExtract="refactor.extract",T.RefactorInline="refactor.inline",T.RefactorRewrite="refactor.rewrite",T.Source="source",T.SourceOrganizeImports="source.organizeImports",T.SourceFixAll="source.fixAll"})(ld||(e.CodeActionKind=ld={}));var ui;(function(T){T.Invoked=1,T.Automatic=2})(ui||(e.CodeActionTriggerKind=ui={}));var bc;(function(T){function w(S,g,D){var $={diagnostics:S};return g!=null&&($.only=g),D!=null&&($.triggerKind=D),$}T.create=w;function C(S){var g=S;return A.defined(g)&&A.typedArray(g.diagnostics,b.is)&&(g.only===void 0||A.typedArray(g.only,A.string))&&(g.triggerKind===void 0||g.triggerKind===ui.Invoked||g.triggerKind===ui.Automatic)}T.is=C})(bc||(e.CodeActionContext=bc={}));var _c;(function(T){function w(S,g,D){var $={title:S},Te=!0;return typeof g=="string"?(Te=!1,$.kind=g):P.is(g)?$.command=g:$.edit=g,Te&&D!==void 0&&($.kind=D),$}T.create=w;function C(S){var g=S;return g&&A.string(g.title)&&(g.diagnostics===void 0||A.typedArray(g.diagnostics,b.is))&&(g.kind===void 0||A.string(g.kind))&&(g.edit!==void 0||g.command!==void 0)&&(g.command===void 0||P.is(g.command))&&(g.isPreferred===void 0||A.boolean(g.isPreferred))&&(g.edit===void 0||pr.is(g.edit))}T.is=C})(_c||(e.CodeAction=_c={}));var jo;(function(T){function w(S,g){var D={range:S};return A.defined(g)&&(D.data=g),D}T.create=w;function C(S){var g=S;return A.defined(g)&&a.is(g.range)&&(A.undefined(g.command)||P.is(g.command))}T.is=C})(jo||(e.CodeLens=jo={}));var Sc;(function(T){function w(S,g){return{tabSize:S,insertSpaces:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.uinteger(g.tabSize)&&A.boolean(g.insertSpaces)}T.is=C})(Sc||(e.FormattingOptions=Sc={}));var Ai;(function(T){function w(S,g,D){return{range:S,target:g,data:D}}T.create=w;function C(S){var g=S;return A.defined(g)&&a.is(g.range)&&(A.undefined(g.target)||A.string(g.target))}T.is=C})(Ai||(e.DocumentLink=Ai={}));var R;(function(T){function w(S,g){return{range:S,parent:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.range)&&(g.parent===void 0||T.is(g.parent))}T.is=C})(R||(e.SelectionRange=R={}));var L;(function(T){T.namespace="namespace",T.type="type",T.class="class",T.enum="enum",T.interface="interface",T.struct="struct",T.typeParameter="typeParameter",T.parameter="parameter",T.variable="variable",T.property="property",T.enumMember="enumMember",T.event="event",T.function="function",T.method="method",T.macro="macro",T.keyword="keyword",T.modifier="modifier",T.comment="comment",T.string="string",T.number="number",T.regexp="regexp",T.operator="operator",T.decorator="decorator"})(L||(e.SemanticTokenTypes=L={}));var G;(function(T){T.declaration="declaration",T.definition="definition",T.readonly="readonly",T.static="static",T.deprecated="deprecated",T.abstract="abstract",T.async="async",T.modification="modification",T.documentation="documentation",T.defaultLibrary="defaultLibrary"})(G||(e.SemanticTokenModifiers=G={}));var ne;(function(T){function w(C){var S=C;return A.objectLiteral(S)&&(S.resultId===void 0||typeof S.resultId=="string")&&Array.isArray(S.data)&&(S.data.length===0||typeof S.data[0]=="number")}T.is=w})(ne||(e.SemanticTokens=ne={}));var et;(function(T){function w(S,g){return{range:S,text:g}}T.create=w;function C(S){var g=S;return g!=null&&a.is(g.range)&&A.string(g.text)}T.is=C})(et||(e.InlineValueText=et={}));var Je;(function(T){function w(S,g,D){return{range:S,variableName:g,caseSensitiveLookup:D}}T.create=w;function C(S){var g=S;return g!=null&&a.is(g.range)&&A.boolean(g.caseSensitiveLookup)&&(A.string(g.variableName)||g.variableName===void 0)}T.is=C})(Je||(e.InlineValueVariableLookup=Je={}));var ht;(function(T){function w(S,g){return{range:S,expression:g}}T.create=w;function C(S){var g=S;return g!=null&&a.is(g.range)&&(A.string(g.expression)||g.expression===void 0)}T.is=C})(ht||(e.InlineValueEvaluatableExpression=ht={}));var kt;(function(T){function w(S,g){return{frameId:S,stoppedLocation:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&a.is(S.stoppedLocation)}T.is=C})(kt||(e.InlineValueContext=kt={}));var we;(function(T){T.Type=1,T.Parameter=2;function w(C){return C===1||C===2}T.is=w})(we||(e.InlayHintKind=we={}));var rt;(function(T){function w(S){return{value:S}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&(g.tooltip===void 0||A.string(g.tooltip)||Gs.is(g.tooltip))&&(g.location===void 0||c.is(g.location))&&(g.command===void 0||P.is(g.command))}T.is=C})(rt||(e.InlayHintLabelPart=rt={}));var ze;(function(T){function w(S,g,D){var $={position:S,label:g};return D!==void 0&&($.kind=D),$}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&o.is(g.position)&&(A.string(g.label)||A.typedArray(g.label,rt.is))&&(g.kind===void 0||we.is(g.kind))&&g.textEdits===void 0||A.typedArray(g.textEdits,E.is)&&(g.tooltip===void 0||A.string(g.tooltip)||Gs.is(g.tooltip))&&(g.paddingLeft===void 0||A.boolean(g.paddingLeft))&&(g.paddingRight===void 0||A.boolean(g.paddingRight))}T.is=C})(ze||(e.InlayHint=ze={}));var Dt;(function(T){function w(C){return{kind:"snippet",value:C}}T.createSnippet=w})(Dt||(e.StringValue=Dt={}));var Xt;(function(T){function w(C,S,g,D){return{insertText:C,filterText:S,range:g,command:D}}T.create=w})(Xt||(e.InlineCompletionItem=Xt={}));var rr;(function(T){function w(C){return{items:C}}T.create=w})(rr||(e.InlineCompletionList=rr={}));var ud;(function(T){T.Invoked=0,T.Automatic=1})(ud||(e.InlineCompletionTriggerKind=ud={}));var yk;(function(T){function w(C,S){return{range:C,text:S}}T.create=w})(yk||(e.SelectedCompletionInfo=yk={}));var Tk;(function(T){function w(C,S){return{triggerKind:C,selectedCompletionInfo:S}}T.create=w})(Tk||(e.InlineCompletionContext=Tk={}));var vk;(function(T){function w(C){var S=C;return A.objectLiteral(S)&&r.is(S.uri)&&A.string(S.name)}T.is=w})(vk||(e.WorkspaceFolder=vk={})),e.EOL=[`
32
+ `)),L){let ne=R.error?` Request failed: ${R.error.message} (${R.error.code}).`:"";E.log(`Received response '${L.method} - (${R.id})' in ${Date.now()-L.timerStart}ms.${ne}`,G)}else E.log(`Received response ${R.id} without active response promise.`,G)}else Di("receive-response",R)}function Di(R,L){if(!E||b===Ke.Off)return;let G={isLSPMessage:!0,type:R,message:L,timestamp:Date.now()};E.log(G)}function Qi(){if(zs())throw new Yo(wc.Closed,"Connection is closed.");if(Ci())throw new Yo(wc.Disposed,"Connection is disposed.")}function cd(){if(yc())throw new Yo(wc.AlreadyListening,"Connection is already listening")}function ld(){if(!yc())throw new Error("Call listen() first.")}function ui(R){return R===void 0?null:R}function bc(R){if(R!==null)return R}function _c(R){return R!=null&&!Array.isArray(R)&&typeof R=="object"}function jo(R,L){switch(R){case he.ParameterStructures.auto:return _c(L)?bc(L):[ui(L)];case he.ParameterStructures.byName:if(!_c(L))throw new Error("Received parameters by name but param is not an object literal.");return bc(L);case he.ParameterStructures.byPosition:return[ui(L)];default:throw new Error(`Unknown parameter structure ${R.toString()}`)}}function Sc(R,L){let G,ne=R.numberOfParams;switch(ne){case 0:G=void 0;break;case 1:G=jo(R.parameterStructures,L[0]);break;default:G=[];for(let et=0;et<L.length&&et<ne;et++)G.push(ui(L[et]));if(L.length<ne)for(let et=L.length;et<ne;et++)G.push(null);break}return G}let Ai={sendNotification:(R,...L)=>{Qi();let G,ne;if(wt.string(R)){G=R;let Je=L[0],ht=0,kt=he.ParameterStructures.auto;he.ParameterStructures.is(Je)&&(ht=1,kt=Je);let we=L.length,rt=we-ht;switch(rt){case 0:ne=void 0;break;case 1:ne=jo(kt,L[ht]);break;default:if(kt===he.ParameterStructures.byName)throw new Error(`Received ${rt} parameters for 'by Name' notification parameter structure.`);ne=L.slice(ht,we).map(ze=>ui(ze));break}}else{let Je=L;G=R.method,ne=Sc(R,Je)}let et={jsonrpc:c,method:G,params:ne};return sd(et),e.write(et).catch(Je=>{throw i.error("Sending notification failed."),Je})},onNotification:(R,L)=>{Qi();let G;return wt.func(R)?d=R:L&&(wt.string(R)?(G=R,f.set(R,{type:void 0,handler:L})):(G=R.method,f.set(R.method,{type:R,handler:L}))),{dispose:()=>{G!==void 0?f.delete(G):d=void 0}}},onProgress:(R,L,G)=>{if(p.has(L))throw new Error(`Progress handler for token ${L} already registered`);return p.set(L,G),{dispose:()=>{p.delete(L)}}},sendProgress:(R,L,G)=>Ai.sendNotification(Rc.type,{token:L,value:G}),onUnhandledProgress:lt.event,sendRequest:(R,...L)=>{Qi(),ld();let G,ne,et;if(wt.string(R)){G=R;let we=L[0],rt=L[L.length-1],ze=0,Dt=he.ParameterStructures.auto;he.ParameterStructures.is(we)&&(ze=1,Dt=we);let Xt=L.length;ey.CancellationToken.is(rt)&&(Xt=Xt-1,et=rt);let rr=Xt-ze;switch(rr){case 0:ne=void 0;break;case 1:ne=jo(Dt,L[ze]);break;default:if(Dt===he.ParameterStructures.byName)throw new Error(`Received ${rr} parameters for 'by Name' request parameter structure.`);ne=L.slice(ze,Xt).map(ud=>ui(ud));break}}else{let we=L;G=R.method,ne=Sc(R,we);let rt=R.numberOfParams;et=ey.CancellationToken.is(we[rt])?we[rt]:void 0}let Je=s++,ht;et&&(ht=et.onCancellationRequested(()=>{let we=Re.sender.sendCancellation(Ai,Je);return we===void 0?(i.log(`Received no promise from cancellation strategy when cancelling id ${Je}`),Promise.resolve()):we.catch(()=>{i.log(`Sending cancellation messages for id ${Je} failed`)})}));let kt={jsonrpc:c,id:Je,method:G,params:ne};return id(kt),typeof Re.sender.enableCancellation=="function"&&Re.sender.enableCancellation(kt),new Promise(async(we,rt)=>{let ze=rr=>{we(rr),Re.sender.cleanup(Je),ht?.dispose()},Dt=rr=>{rt(rr),Re.sender.cleanup(Je),ht?.dispose()},Xt={method:G,timerStart:Date.now(),resolve:ze,reject:Dt};try{await e.write(kt),y.set(Je,Xt)}catch(rr){throw i.error("Sending request failed."),Xt.reject(new he.ResponseError(he.ErrorCodes.MessageWriteError,rr.message?rr.message:"Unknown reason")),rr}})},onRequest:(R,L)=>{Qi();let G=null;return ry.is(R)?(G=void 0,l=R):wt.string(R)?(G=null,L!==void 0&&(G=R,u.set(R,{handler:L,type:void 0}))):L!==void 0&&(G=R.method,u.set(R.method,{type:R,handler:L})),{dispose:()=>{G!==null&&(G!==void 0?u.delete(G):l=void 0)}}},hasPendingResponse:()=>y.size>0,trace:async(R,L,G)=>{let ne=!1,et=ir.Text;G!==void 0&&(wt.boolean(G)?ne=G:(ne=G.sendNotification||!1,et=G.traceFormat||ir.Text)),b=R,P=et,b===Ke.Off?E=void 0:E=L,ne&&!zs()&&!Ci()&&await Ai.sendNotification(iy.type,{value:Ke.toString(R)})},onError:O.event,onClose:B.event,onUnhandledNotification:Ae.event,onDispose:Gt.event,end:()=>{e.end()},dispose:()=>{if(Ci())return;H=Ur.Disposed,Gt.fire(void 0);let R=new he.ResponseError(he.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(let L of y.values())L.reject(R);y=new Map,v=new Map,_=new Set,h=new Uk.LinkedMap,wt.func(e.dispose)&&e.dispose(),wt.func(t.dispose)&&t.dispose()},listen:()=>{Qi(),cd(),H=Ur.Listening,t.listen(ed)},inspect:()=>{(0,jk.default)().console.log("inspect")}};return Ai.onNotification(kd.type,R=>{if(b===Ke.Off||!E)return;let L=b===Ke.Verbose||b===Ke.Compact;E.log(R.message,L?R.verbose:void 0)}),Ai.onNotification(Rc.type,R=>{let L=p.get(R.token);L?L(R.value):lt.fire(R)}),Ai}ve.createMessageConnection=jB});var Cd=N(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.ProgressType=M.ProgressToken=M.createMessageConnection=M.NullLogger=M.ConnectionOptions=M.ConnectionStrategy=M.AbstractMessageBuffer=M.WriteableStreamMessageWriter=M.AbstractMessageWriter=M.MessageWriter=M.ReadableStreamMessageReader=M.AbstractMessageReader=M.MessageReader=M.SharedArrayReceiverStrategy=M.SharedArraySenderStrategy=M.CancellationToken=M.CancellationTokenSource=M.Emitter=M.Event=M.Disposable=M.LRUCache=M.Touch=M.LinkedMap=M.ParameterStructures=M.NotificationType9=M.NotificationType8=M.NotificationType7=M.NotificationType6=M.NotificationType5=M.NotificationType4=M.NotificationType3=M.NotificationType2=M.NotificationType1=M.NotificationType0=M.NotificationType=M.ErrorCodes=M.ResponseError=M.RequestType9=M.RequestType8=M.RequestType7=M.RequestType6=M.RequestType5=M.RequestType4=M.RequestType3=M.RequestType2=M.RequestType1=M.RequestType0=M.RequestType=M.Message=M.RAL=void 0;M.MessageStrategy=M.CancellationStrategy=M.CancellationSenderStrategy=M.CancellationReceiverStrategy=M.ConnectionError=M.ConnectionErrors=M.LogTraceNotification=M.SetTraceNotification=M.TraceFormat=M.TraceValues=M.Trace=void 0;var dt=Ig();Object.defineProperty(M,"Message",{enumerable:!0,get:function(){return dt.Message}});Object.defineProperty(M,"RequestType",{enumerable:!0,get:function(){return dt.RequestType}});Object.defineProperty(M,"RequestType0",{enumerable:!0,get:function(){return dt.RequestType0}});Object.defineProperty(M,"RequestType1",{enumerable:!0,get:function(){return dt.RequestType1}});Object.defineProperty(M,"RequestType2",{enumerable:!0,get:function(){return dt.RequestType2}});Object.defineProperty(M,"RequestType3",{enumerable:!0,get:function(){return dt.RequestType3}});Object.defineProperty(M,"RequestType4",{enumerable:!0,get:function(){return dt.RequestType4}});Object.defineProperty(M,"RequestType5",{enumerable:!0,get:function(){return dt.RequestType5}});Object.defineProperty(M,"RequestType6",{enumerable:!0,get:function(){return dt.RequestType6}});Object.defineProperty(M,"RequestType7",{enumerable:!0,get:function(){return dt.RequestType7}});Object.defineProperty(M,"RequestType8",{enumerable:!0,get:function(){return dt.RequestType8}});Object.defineProperty(M,"RequestType9",{enumerable:!0,get:function(){return dt.RequestType9}});Object.defineProperty(M,"ResponseError",{enumerable:!0,get:function(){return dt.ResponseError}});Object.defineProperty(M,"ErrorCodes",{enumerable:!0,get:function(){return dt.ErrorCodes}});Object.defineProperty(M,"NotificationType",{enumerable:!0,get:function(){return dt.NotificationType}});Object.defineProperty(M,"NotificationType0",{enumerable:!0,get:function(){return dt.NotificationType0}});Object.defineProperty(M,"NotificationType1",{enumerable:!0,get:function(){return dt.NotificationType1}});Object.defineProperty(M,"NotificationType2",{enumerable:!0,get:function(){return dt.NotificationType2}});Object.defineProperty(M,"NotificationType3",{enumerable:!0,get:function(){return dt.NotificationType3}});Object.defineProperty(M,"NotificationType4",{enumerable:!0,get:function(){return dt.NotificationType4}});Object.defineProperty(M,"NotificationType5",{enumerable:!0,get:function(){return dt.NotificationType5}});Object.defineProperty(M,"NotificationType6",{enumerable:!0,get:function(){return dt.NotificationType6}});Object.defineProperty(M,"NotificationType7",{enumerable:!0,get:function(){return dt.NotificationType7}});Object.defineProperty(M,"NotificationType8",{enumerable:!0,get:function(){return dt.NotificationType8}});Object.defineProperty(M,"NotificationType9",{enumerable:!0,get:function(){return dt.NotificationType9}});Object.defineProperty(M,"ParameterStructures",{enumerable:!0,get:function(){return dt.ParameterStructures}});var ay=Mg();Object.defineProperty(M,"LinkedMap",{enumerable:!0,get:function(){return ay.LinkedMap}});Object.defineProperty(M,"LRUCache",{enumerable:!0,get:function(){return ay.LRUCache}});Object.defineProperty(M,"Touch",{enumerable:!0,get:function(){return ay.Touch}});var UB=Dk();Object.defineProperty(M,"Disposable",{enumerable:!0,get:function(){return UB.Disposable}});var zk=Wo();Object.defineProperty(M,"Event",{enumerable:!0,get:function(){return zk.Event}});Object.defineProperty(M,"Emitter",{enumerable:!0,get:function(){return zk.Emitter}});var Gk=Td();Object.defineProperty(M,"CancellationTokenSource",{enumerable:!0,get:function(){return Gk.CancellationTokenSource}});Object.defineProperty(M,"CancellationToken",{enumerable:!0,get:function(){return Gk.CancellationToken}});var Kk=Ik();Object.defineProperty(M,"SharedArraySenderStrategy",{enumerable:!0,get:function(){return Kk.SharedArraySenderStrategy}});Object.defineProperty(M,"SharedArrayReceiverStrategy",{enumerable:!0,get:function(){return Kk.SharedArrayReceiverStrategy}});var cy=Mk();Object.defineProperty(M,"MessageReader",{enumerable:!0,get:function(){return cy.MessageReader}});Object.defineProperty(M,"AbstractMessageReader",{enumerable:!0,get:function(){return cy.AbstractMessageReader}});Object.defineProperty(M,"ReadableStreamMessageReader",{enumerable:!0,get:function(){return cy.ReadableStreamMessageReader}});var ly=Fk();Object.defineProperty(M,"MessageWriter",{enumerable:!0,get:function(){return ly.MessageWriter}});Object.defineProperty(M,"AbstractMessageWriter",{enumerable:!0,get:function(){return ly.AbstractMessageWriter}});Object.defineProperty(M,"WriteableStreamMessageWriter",{enumerable:!0,get:function(){return ly.WriteableStreamMessageWriter}});var HB=Bk();Object.defineProperty(M,"AbstractMessageBuffer",{enumerable:!0,get:function(){return HB.AbstractMessageBuffer}});var an=Wk();Object.defineProperty(M,"ConnectionStrategy",{enumerable:!0,get:function(){return an.ConnectionStrategy}});Object.defineProperty(M,"ConnectionOptions",{enumerable:!0,get:function(){return an.ConnectionOptions}});Object.defineProperty(M,"NullLogger",{enumerable:!0,get:function(){return an.NullLogger}});Object.defineProperty(M,"createMessageConnection",{enumerable:!0,get:function(){return an.createMessageConnection}});Object.defineProperty(M,"ProgressToken",{enumerable:!0,get:function(){return an.ProgressToken}});Object.defineProperty(M,"ProgressType",{enumerable:!0,get:function(){return an.ProgressType}});Object.defineProperty(M,"Trace",{enumerable:!0,get:function(){return an.Trace}});Object.defineProperty(M,"TraceValues",{enumerable:!0,get:function(){return an.TraceValues}});Object.defineProperty(M,"TraceFormat",{enumerable:!0,get:function(){return an.TraceFormat}});Object.defineProperty(M,"SetTraceNotification",{enumerable:!0,get:function(){return an.SetTraceNotification}});Object.defineProperty(M,"LogTraceNotification",{enumerable:!0,get:function(){return an.LogTraceNotification}});Object.defineProperty(M,"ConnectionErrors",{enumerable:!0,get:function(){return an.ConnectionErrors}});Object.defineProperty(M,"ConnectionError",{enumerable:!0,get:function(){return an.ConnectionError}});Object.defineProperty(M,"CancellationReceiverStrategy",{enumerable:!0,get:function(){return an.CancellationReceiverStrategy}});Object.defineProperty(M,"CancellationSenderStrategy",{enumerable:!0,get:function(){return an.CancellationSenderStrategy}});Object.defineProperty(M,"CancellationStrategy",{enumerable:!0,get:function(){return an.CancellationStrategy}});Object.defineProperty(M,"MessageStrategy",{enumerable:!0,get:function(){return an.MessageStrategy}});var VB=es();M.RAL=VB.default});var Jk=N(py=>{"use strict";Object.defineProperty(py,"__esModule",{value:!0});var Yk=require("util"),Oi=Cd(),Dd=class t extends Oi.AbstractMessageBuffer{constructor(e="utf-8"){super(e)}emptyBuffer(){return t.emptyBuffer}fromString(e,n){return Buffer.from(e,n)}toString(e,n){return e instanceof Buffer?e.toString(n):new Yk.TextDecoder(n).decode(e)}asNative(e,n){return n===void 0?e instanceof Buffer?e:Buffer.from(e):e instanceof Buffer?e.slice(0,n):Buffer.from(e,0,n)}allocNative(e){return Buffer.allocUnsafe(e)}};Dd.emptyBuffer=Buffer.allocUnsafe(0);var uy=class{constructor(e){this.stream=e}onClose(e){return this.stream.on("close",e),Oi.Disposable.create(()=>this.stream.off("close",e))}onError(e){return this.stream.on("error",e),Oi.Disposable.create(()=>this.stream.off("error",e))}onEnd(e){return this.stream.on("end",e),Oi.Disposable.create(()=>this.stream.off("end",e))}onData(e){return this.stream.on("data",e),Oi.Disposable.create(()=>this.stream.off("data",e))}},dy=class{constructor(e){this.stream=e}onClose(e){return this.stream.on("close",e),Oi.Disposable.create(()=>this.stream.off("close",e))}onError(e){return this.stream.on("error",e),Oi.Disposable.create(()=>this.stream.off("error",e))}onEnd(e){return this.stream.on("end",e),Oi.Disposable.create(()=>this.stream.off("end",e))}write(e,n){return new Promise((r,i)=>{let s=o=>{o==null?r():i(o)};typeof e=="string"?this.stream.write(e,n,s):this.stream.write(e,s)})}end(){this.stream.end()}},Xk=Object.freeze({messageBuffer:Object.freeze({create:t=>new Dd(t)}),applicationJson:Object.freeze({encoder:Object.freeze({name:"application/json",encode:(t,e)=>{try{return Promise.resolve(Buffer.from(JSON.stringify(t,void 0,0),e.charset))}catch(n){return Promise.reject(n)}}}),decoder:Object.freeze({name:"application/json",decode:(t,e)=>{try{return t instanceof Buffer?Promise.resolve(JSON.parse(t.toString(e.charset))):Promise.resolve(JSON.parse(new Yk.TextDecoder(e.charset).decode(t)))}catch(n){return Promise.reject(n)}}})}),stream:Object.freeze({asReadableStream:t=>new uy(t),asWritableStream:t=>new dy(t)}),console,timer:Object.freeze({setTimeout(t,e,...n){let r=setTimeout(t,e,...n);return{dispose:()=>clearTimeout(r)}},setImmediate(t,...e){let n=setImmediate(t,...e);return{dispose:()=>clearImmediate(n)}},setInterval(t,e,...n){let r=setInterval(t,e,...n);return{dispose:()=>clearInterval(r)}}})});function fy(){return Xk}(function(t){function e(){Oi.RAL.install(Xk)}t.install=e})(fy||(fy={}));py.default=fy});var Qs=N(Oe=>{"use strict";var WB=Oe&&Oe.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),zB=Oe&&Oe.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&WB(e,t,n)};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.createMessageConnection=Oe.createServerSocketTransport=Oe.createClientSocketTransport=Oe.createServerPipeTransport=Oe.createClientPipeTransport=Oe.generateRandomPipeName=Oe.StreamMessageWriter=Oe.StreamMessageReader=Oe.SocketMessageWriter=Oe.SocketMessageReader=Oe.PortMessageWriter=Oe.PortMessageReader=Oe.IPCMessageWriter=Oe.IPCMessageReader=void 0;var Xo=Jk();Xo.default.install();var Qk=require("path"),GB=require("os"),KB=require("crypto"),Od=require("net"),sr=Cd();zB(Cd(),Oe);var hy=class extends sr.AbstractMessageReader{constructor(e){super(),this.process=e;let n=this.process;n.on("error",r=>this.fireError(r)),n.on("close",()=>this.fireClose())}listen(e){return this.process.on("message",e),sr.Disposable.create(()=>this.process.off("message",e))}};Oe.IPCMessageReader=hy;var my=class extends sr.AbstractMessageWriter{constructor(e){super(),this.process=e,this.errorCount=0;let n=this.process;n.on("error",r=>this.fireError(r)),n.on("close",()=>this.fireClose)}write(e){try{return typeof this.process.send=="function"&&this.process.send(e,void 0,void 0,n=>{n?(this.errorCount++,this.handleError(n,e)):this.errorCount=0}),Promise.resolve()}catch(n){return this.handleError(n,e),Promise.reject(n)}}handleError(e,n){this.errorCount++,this.fireError(e,n,this.errorCount)}end(){}};Oe.IPCMessageWriter=my;var gy=class extends sr.AbstractMessageReader{constructor(e){super(),this.onData=new sr.Emitter,e.on("close",()=>this.fireClose),e.on("error",n=>this.fireError(n)),e.on("message",n=>{this.onData.fire(n)})}listen(e){return this.onData.event(e)}};Oe.PortMessageReader=gy;var yy=class extends sr.AbstractMessageWriter{constructor(e){super(),this.port=e,this.errorCount=0,e.on("close",()=>this.fireClose()),e.on("error",n=>this.fireError(n))}write(e){try{return this.port.postMessage(e),Promise.resolve()}catch(n){return this.handleError(n,e),Promise.reject(n)}}handleError(e,n){this.errorCount++,this.fireError(e,n,this.errorCount)}end(){}};Oe.PortMessageWriter=yy;var Xs=class extends sr.ReadableStreamMessageReader{constructor(e,n="utf-8"){super((0,Xo.default)().stream.asReadableStream(e),n)}};Oe.SocketMessageReader=Xs;var Js=class extends sr.WriteableStreamMessageWriter{constructor(e,n){super((0,Xo.default)().stream.asWritableStream(e),n),this.socket=e}dispose(){super.dispose(),this.socket.destroy()}};Oe.SocketMessageWriter=Js;var Ad=class extends sr.ReadableStreamMessageReader{constructor(e,n){super((0,Xo.default)().stream.asReadableStream(e),n)}};Oe.StreamMessageReader=Ad;var Id=class extends sr.WriteableStreamMessageWriter{constructor(e,n){super((0,Xo.default)().stream.asWritableStream(e),n)}};Oe.StreamMessageWriter=Id;var Zk=process.env.XDG_RUNTIME_DIR,YB=new Map([["linux",107],["darwin",103]]);function XB(){let t=(0,KB.randomBytes)(21).toString("hex");if(process.platform==="win32")return`\\\\.\\pipe\\vscode-jsonrpc-${t}-sock`;let e;Zk?e=Qk.join(Zk,`vscode-ipc-${t}.sock`):e=Qk.join(GB.tmpdir(),`vscode-${t}.sock`);let n=YB.get(process.platform);return n!==void 0&&e.length>n&&(0,Xo.default)().console.warn(`WARNING: IPC handle "${e}" is longer than ${n} characters.`),e}Oe.generateRandomPipeName=XB;function JB(t,e="utf-8"){let n,r=new Promise((i,s)=>{n=i});return new Promise((i,s)=>{let o=(0,Od.createServer)(a=>{o.close(),n([new Xs(a,e),new Js(a,e)])});o.on("error",s),o.listen(t,()=>{o.removeListener("error",s),i({onConnected:()=>r})})})}Oe.createClientPipeTransport=JB;function QB(t,e="utf-8"){let n=(0,Od.createConnection)(t);return[new Xs(n,e),new Js(n,e)]}Oe.createServerPipeTransport=QB;function ZB(t,e="utf-8"){let n,r=new Promise((i,s)=>{n=i});return new Promise((i,s)=>{let o=(0,Od.createServer)(a=>{o.close(),n([new Xs(a,e),new Js(a,e)])});o.on("error",s),o.listen(t,"127.0.0.1",()=>{o.removeListener("error",s),i({onConnected:()=>r})})})}Oe.createClientSocketTransport=ZB;function ej(t,e="utf-8"){let n=(0,Od.createConnection)(t,"127.0.0.1");return[new Xs(n,e),new Js(n,e)]}Oe.createServerSocketTransport=ej;function tj(t){let e=t;return e.read!==void 0&&e.addListener!==void 0}function nj(t){let e=t;return e.write!==void 0&&e.addListener!==void 0}function rj(t,e,n,r){n||(n=sr.NullLogger);let i=tj(t)?new Ad(t):t,s=nj(e)?new Id(e):e;return sr.ConnectionStrategy.is(r)&&(r={connectionStrategy:r}),(0,sr.createMessageConnection)(i,s,n,r)}Oe.createMessageConnection=rj});var Ty=N((DQ,eP)=>{"use strict";eP.exports=Qs()});var xd=N((tP,Md)=>{(function(t){if(typeof Md=="object"&&typeof Md.exports=="object"){var e=t(require,tP);e!==void 0&&(Md.exports=e)}else typeof define=="function"&&define.amd&&define(["require","exports"],t)})(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextDocument=e.EOL=e.WorkspaceFolder=e.InlineCompletionContext=e.SelectedCompletionInfo=e.InlineCompletionTriggerKind=e.InlineCompletionList=e.InlineCompletionItem=e.StringValue=e.InlayHint=e.InlayHintLabelPart=e.InlayHintKind=e.InlineValueContext=e.InlineValueEvaluatableExpression=e.InlineValueVariableLookup=e.InlineValueText=e.SemanticTokens=e.SemanticTokenModifiers=e.SemanticTokenTypes=e.SelectionRange=e.DocumentLink=e.FormattingOptions=e.CodeLens=e.CodeAction=e.CodeActionContext=e.CodeActionTriggerKind=e.CodeActionKind=e.DocumentSymbol=e.WorkspaceSymbol=e.SymbolInformation=e.SymbolTag=e.SymbolKind=e.DocumentHighlight=e.DocumentHighlightKind=e.SignatureInformation=e.ParameterInformation=e.Hover=e.MarkedString=e.CompletionList=e.CompletionItem=e.CompletionItemLabelDetails=e.InsertTextMode=e.InsertReplaceEdit=e.CompletionItemTag=e.InsertTextFormat=e.CompletionItemKind=e.MarkupContent=e.MarkupKind=e.TextDocumentItem=e.OptionalVersionedTextDocumentIdentifier=e.VersionedTextDocumentIdentifier=e.TextDocumentIdentifier=e.WorkspaceChange=e.WorkspaceEdit=e.DeleteFile=e.RenameFile=e.CreateFile=e.TextDocumentEdit=e.AnnotatedTextEdit=e.ChangeAnnotationIdentifier=e.ChangeAnnotation=e.TextEdit=e.Command=e.Diagnostic=e.CodeDescription=e.DiagnosticTag=e.DiagnosticSeverity=e.DiagnosticRelatedInformation=e.FoldingRange=e.FoldingRangeKind=e.ColorPresentation=e.ColorInformation=e.Color=e.LocationLink=e.Location=e.Range=e.Position=e.uinteger=e.integer=e.URI=e.DocumentUri=void 0;var n;(function(T){function w(C){return typeof C=="string"}T.is=w})(n||(e.DocumentUri=n={}));var r;(function(T){function w(C){return typeof C=="string"}T.is=w})(r||(e.URI=r={}));var i;(function(T){T.MIN_VALUE=-2147483648,T.MAX_VALUE=2147483647;function w(C){return typeof C=="number"&&T.MIN_VALUE<=C&&C<=T.MAX_VALUE}T.is=w})(i||(e.integer=i={}));var s;(function(T){T.MIN_VALUE=0,T.MAX_VALUE=2147483647;function w(C){return typeof C=="number"&&T.MIN_VALUE<=C&&C<=T.MAX_VALUE}T.is=w})(s||(e.uinteger=s={}));var o;(function(T){function w(S,g){return S===Number.MAX_VALUE&&(S=s.MAX_VALUE),g===Number.MAX_VALUE&&(g=s.MAX_VALUE),{line:S,character:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.uinteger(g.line)&&A.uinteger(g.character)}T.is=C})(o||(e.Position=o={}));var a;(function(T){function w(S,g,D,$){if(A.uinteger(S)&&A.uinteger(g)&&A.uinteger(D)&&A.uinteger($))return{start:o.create(S,g),end:o.create(D,$)};if(o.is(S)&&o.is(g))return{start:S,end:g};throw new Error("Range#create called with invalid arguments[".concat(S,", ").concat(g,", ").concat(D,", ").concat($,"]"))}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&o.is(g.start)&&o.is(g.end)}T.is=C})(a||(e.Range=a={}));var c;(function(T){function w(S,g){return{uri:S,range:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.range)&&(A.string(g.uri)||A.undefined(g.uri))}T.is=C})(c||(e.Location=c={}));var l;(function(T){function w(S,g,D,$){return{targetUri:S,targetRange:g,targetSelectionRange:D,originSelectionRange:$}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.targetRange)&&A.string(g.targetUri)&&a.is(g.targetSelectionRange)&&(a.is(g.originSelectionRange)||A.undefined(g.originSelectionRange))}T.is=C})(l||(e.LocationLink=l={}));var u;(function(T){function w(S,g,D,$){return{red:S,green:g,blue:D,alpha:$}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.numberRange(g.red,0,1)&&A.numberRange(g.green,0,1)&&A.numberRange(g.blue,0,1)&&A.numberRange(g.alpha,0,1)}T.is=C})(u||(e.Color=u={}));var d;(function(T){function w(S,g){return{range:S,color:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.range)&&u.is(g.color)}T.is=C})(d||(e.ColorInformation=d={}));var f;(function(T){function w(S,g,D){return{label:S,textEdit:g,additionalTextEdits:D}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.string(g.label)&&(A.undefined(g.textEdit)||E.is(g))&&(A.undefined(g.additionalTextEdits)||A.typedArray(g.additionalTextEdits,E.is))}T.is=C})(f||(e.ColorPresentation=f={}));var p;(function(T){T.Comment="comment",T.Imports="imports",T.Region="region"})(p||(e.FoldingRangeKind=p={}));var m;(function(T){function w(S,g,D,$,Te,At){var ut={startLine:S,endLine:g};return A.defined(D)&&(ut.startCharacter=D),A.defined($)&&(ut.endCharacter=$),A.defined(Te)&&(ut.kind=Te),A.defined(At)&&(ut.collapsedText=At),ut}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.uinteger(g.startLine)&&A.uinteger(g.startLine)&&(A.undefined(g.startCharacter)||A.uinteger(g.startCharacter))&&(A.undefined(g.endCharacter)||A.uinteger(g.endCharacter))&&(A.undefined(g.kind)||A.string(g.kind))}T.is=C})(m||(e.FoldingRange=m={}));var h;(function(T){function w(S,g){return{location:S,message:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&c.is(g.location)&&A.string(g.message)}T.is=C})(h||(e.DiagnosticRelatedInformation=h={}));var y;(function(T){T.Error=1,T.Warning=2,T.Information=3,T.Hint=4})(y||(e.DiagnosticSeverity=y={}));var _;(function(T){T.Unnecessary=1,T.Deprecated=2})(_||(e.DiagnosticTag=_={}));var v;(function(T){function w(C){var S=C;return A.objectLiteral(S)&&A.string(S.href)}T.is=w})(v||(e.CodeDescription=v={}));var b;(function(T){function w(S,g,D,$,Te,At){var ut={range:S,message:g};return A.defined(D)&&(ut.severity=D),A.defined($)&&(ut.code=$),A.defined(Te)&&(ut.source=Te),A.defined(At)&&(ut.relatedInformation=At),ut}T.create=w;function C(S){var g,D=S;return A.defined(D)&&a.is(D.range)&&A.string(D.message)&&(A.number(D.severity)||A.undefined(D.severity))&&(A.integer(D.code)||A.string(D.code)||A.undefined(D.code))&&(A.undefined(D.codeDescription)||A.string((g=D.codeDescription)===null||g===void 0?void 0:g.href))&&(A.string(D.source)||A.undefined(D.source))&&(A.undefined(D.relatedInformation)||A.typedArray(D.relatedInformation,h.is))}T.is=C})(b||(e.Diagnostic=b={}));var P;(function(T){function w(S,g){for(var D=[],$=2;$<arguments.length;$++)D[$-2]=arguments[$];var Te={title:S,command:g};return A.defined(D)&&D.length>0&&(Te.arguments=D),Te}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.title)&&A.string(g.command)}T.is=C})(P||(e.Command=P={}));var E;(function(T){function w(D,$){return{range:D,newText:$}}T.replace=w;function C(D,$){return{range:{start:D,end:D},newText:$}}T.insert=C;function S(D){return{range:D,newText:""}}T.del=S;function g(D){var $=D;return A.objectLiteral($)&&A.string($.newText)&&a.is($.range)}T.is=g})(E||(e.TextEdit=E={}));var H;(function(T){function w(S,g,D){var $={label:S};return g!==void 0&&($.needsConfirmation=g),D!==void 0&&($.description=D),$}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&A.string(g.label)&&(A.boolean(g.needsConfirmation)||g.needsConfirmation===void 0)&&(A.string(g.description)||g.description===void 0)}T.is=C})(H||(e.ChangeAnnotation=H={}));var O;(function(T){function w(C){var S=C;return A.string(S)}T.is=w})(O||(e.ChangeAnnotationIdentifier=O={}));var B;(function(T){function w(D,$,Te){return{range:D,newText:$,annotationId:Te}}T.replace=w;function C(D,$,Te){return{range:{start:D,end:D},newText:$,annotationId:Te}}T.insert=C;function S(D,$){return{range:D,newText:"",annotationId:$}}T.del=S;function g(D){var $=D;return E.is($)&&(H.is($.annotationId)||O.is($.annotationId))}T.is=g})(B||(e.AnnotatedTextEdit=B={}));var Ae;(function(T){function w(S,g){return{textDocument:S,edits:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&zs.is(g.textDocument)&&Array.isArray(g.edits)}T.is=C})(Ae||(e.TextDocumentEdit=Ae={}));var lt;(function(T){function w(S,g,D){var $={kind:"create",uri:S};return g!==void 0&&(g.overwrite!==void 0||g.ignoreIfExists!==void 0)&&($.options=g),D!==void 0&&($.annotationId=D),$}T.create=w;function C(S){var g=S;return g&&g.kind==="create"&&A.string(g.uri)&&(g.options===void 0||(g.options.overwrite===void 0||A.boolean(g.options.overwrite))&&(g.options.ignoreIfExists===void 0||A.boolean(g.options.ignoreIfExists)))&&(g.annotationId===void 0||O.is(g.annotationId))}T.is=C})(lt||(e.CreateFile=lt={}));var Gt;(function(T){function w(S,g,D,$){var Te={kind:"rename",oldUri:S,newUri:g};return D!==void 0&&(D.overwrite!==void 0||D.ignoreIfExists!==void 0)&&(Te.options=D),$!==void 0&&(Te.annotationId=$),Te}T.create=w;function C(S){var g=S;return g&&g.kind==="rename"&&A.string(g.oldUri)&&A.string(g.newUri)&&(g.options===void 0||(g.options.overwrite===void 0||A.boolean(g.options.overwrite))&&(g.options.ignoreIfExists===void 0||A.boolean(g.options.ignoreIfExists)))&&(g.annotationId===void 0||O.is(g.annotationId))}T.is=C})(Gt||(e.RenameFile=Gt={}));var Re;(function(T){function w(S,g,D){var $={kind:"delete",uri:S};return g!==void 0&&(g.recursive!==void 0||g.ignoreIfNotExists!==void 0)&&($.options=g),D!==void 0&&($.annotationId=D),$}T.create=w;function C(S){var g=S;return g&&g.kind==="delete"&&A.string(g.uri)&&(g.options===void 0||(g.options.recursive===void 0||A.boolean(g.options.recursive))&&(g.options.ignoreIfNotExists===void 0||A.boolean(g.options.ignoreIfNotExists)))&&(g.annotationId===void 0||O.is(g.annotationId))}T.is=C})(Re||(e.DeleteFile=Re={}));var pr;(function(T){function w(C){var S=C;return S&&(S.changes!==void 0||S.documentChanges!==void 0)&&(S.documentChanges===void 0||S.documentChanges.every(function(g){return A.string(g.kind)?lt.is(g)||Gt.is(g)||Re.is(g):Ae.is(g)}))}T.is=w})(pr||(e.WorkspaceEdit=pr={}));var Ji=function(){function T(w,C){this.edits=w,this.changeAnnotations=C}return T.prototype.insert=function(w,C,S){var g,D;if(S===void 0?g=E.insert(w,C):O.is(S)?(D=S,g=B.insert(w,C,S)):(this.assertChangeAnnotations(this.changeAnnotations),D=this.changeAnnotations.manage(S),g=B.insert(w,C,D)),this.edits.push(g),D!==void 0)return D},T.prototype.replace=function(w,C,S){var g,D;if(S===void 0?g=E.replace(w,C):O.is(S)?(D=S,g=B.replace(w,C,S)):(this.assertChangeAnnotations(this.changeAnnotations),D=this.changeAnnotations.manage(S),g=B.replace(w,C,D)),this.edits.push(g),D!==void 0)return D},T.prototype.delete=function(w,C){var S,g;if(C===void 0?S=E.del(w):O.is(C)?(g=C,S=B.del(w,C)):(this.assertChangeAnnotations(this.changeAnnotations),g=this.changeAnnotations.manage(C),S=B.del(w,g)),this.edits.push(S),g!==void 0)return g},T.prototype.add=function(w){this.edits.push(w)},T.prototype.all=function(){return this.edits},T.prototype.clear=function(){this.edits.splice(0,this.edits.length)},T.prototype.assertChangeAnnotations=function(w){if(w===void 0)throw new Error("Text edit change is not configured to manage change annotations.")},T}(),Xu=function(){function T(w){this._annotations=w===void 0?Object.create(null):w,this._counter=0,this._size=0}return T.prototype.all=function(){return this._annotations},Object.defineProperty(T.prototype,"size",{get:function(){return this._size},enumerable:!1,configurable:!0}),T.prototype.manage=function(w,C){var S;if(O.is(w)?S=w:(S=this.nextId(),C=w),this._annotations[S]!==void 0)throw new Error("Id ".concat(S," is already in use."));if(C===void 0)throw new Error("No annotation provided for id ".concat(S));return this._annotations[S]=C,this._size++,S},T.prototype.nextId=function(){return this._counter++,this._counter.toString()},T}(),og=function(){function T(w){var C=this;this._textEditChanges=Object.create(null),w!==void 0?(this._workspaceEdit=w,w.documentChanges?(this._changeAnnotations=new Xu(w.changeAnnotations),w.changeAnnotations=this._changeAnnotations.all(),w.documentChanges.forEach(function(S){if(Ae.is(S)){var g=new Ji(S.edits,C._changeAnnotations);C._textEditChanges[S.textDocument.uri]=g}})):w.changes&&Object.keys(w.changes).forEach(function(S){var g=new Ji(w.changes[S]);C._textEditChanges[S]=g})):this._workspaceEdit={}}return Object.defineProperty(T.prototype,"edit",{get:function(){return this.initDocumentChanges(),this._changeAnnotations!==void 0&&(this._changeAnnotations.size===0?this._workspaceEdit.changeAnnotations=void 0:this._workspaceEdit.changeAnnotations=this._changeAnnotations.all()),this._workspaceEdit},enumerable:!1,configurable:!0}),T.prototype.getTextEditChange=function(w){if(zs.is(w)){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var C={uri:w.uri,version:w.version},S=this._textEditChanges[C.uri];if(!S){var g=[],D={textDocument:C,edits:g};this._workspaceEdit.documentChanges.push(D),S=new Ji(g,this._changeAnnotations),this._textEditChanges[C.uri]=S}return S}else{if(this.initChanges(),this._workspaceEdit.changes===void 0)throw new Error("Workspace edit is not configured for normal text edit changes.");var S=this._textEditChanges[w];if(!S){var g=[];this._workspaceEdit.changes[w]=g,S=new Ji(g),this._textEditChanges[w]=S}return S}},T.prototype.initDocumentChanges=function(){this._workspaceEdit.documentChanges===void 0&&this._workspaceEdit.changes===void 0&&(this._changeAnnotations=new Xu,this._workspaceEdit.documentChanges=[],this._workspaceEdit.changeAnnotations=this._changeAnnotations.all())},T.prototype.initChanges=function(){this._workspaceEdit.documentChanges===void 0&&this._workspaceEdit.changes===void 0&&(this._workspaceEdit.changes=Object.create(null))},T.prototype.createFile=function(w,C,S){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var g;H.is(C)||O.is(C)?g=C:S=C;var D,$;if(g===void 0?D=lt.create(w,S):($=O.is(g)?g:this._changeAnnotations.manage(g),D=lt.create(w,S,$)),this._workspaceEdit.documentChanges.push(D),$!==void 0)return $},T.prototype.renameFile=function(w,C,S,g){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var D;H.is(S)||O.is(S)?D=S:g=S;var $,Te;if(D===void 0?$=Gt.create(w,C,g):(Te=O.is(D)?D:this._changeAnnotations.manage(D),$=Gt.create(w,C,g,Te)),this._workspaceEdit.documentChanges.push($),Te!==void 0)return Te},T.prototype.deleteFile=function(w,C,S){if(this.initDocumentChanges(),this._workspaceEdit.documentChanges===void 0)throw new Error("Workspace edit is not configured for document changes.");var g;H.is(C)||O.is(C)?g=C:S=C;var D,$;if(g===void 0?D=Re.create(w,S):($=O.is(g)?g:this._changeAnnotations.manage(g),D=Re.create(w,S,$)),this._workspaceEdit.documentChanges.push(D),$!==void 0)return $},T}();e.WorkspaceChange=og;var Ju;(function(T){function w(S){return{uri:S}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)}T.is=C})(Ju||(e.TextDocumentIdentifier=Ju={}));var yc;(function(T){function w(S,g){return{uri:S,version:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)&&A.integer(g.version)}T.is=C})(yc||(e.VersionedTextDocumentIdentifier=yc={}));var zs;(function(T){function w(S,g){return{uri:S,version:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)&&(g.version===null||A.integer(g.version))}T.is=C})(zs||(e.OptionalVersionedTextDocumentIdentifier=zs={}));var Ci;(function(T){function w(S,g,D,$){return{uri:S,languageId:g,version:D,text:$}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.string(g.uri)&&A.string(g.languageId)&&A.integer(g.version)&&A.string(g.text)}T.is=C})(Ci||(e.TextDocumentItem=Ci={}));var $o;(function(T){T.PlainText="plaintext",T.Markdown="markdown";function w(C){var S=C;return S===T.PlainText||S===T.Markdown}T.is=w})($o||(e.MarkupKind=$o={}));var Gs;(function(T){function w(C){var S=C;return A.objectLiteral(C)&&$o.is(S.kind)&&A.string(S.value)}T.is=w})(Gs||(e.MarkupContent=Gs={}));var Qu;(function(T){T.Text=1,T.Method=2,T.Function=3,T.Constructor=4,T.Field=5,T.Variable=6,T.Class=7,T.Interface=8,T.Module=9,T.Property=10,T.Unit=11,T.Value=12,T.Enum=13,T.Keyword=14,T.Snippet=15,T.Color=16,T.File=17,T.Reference=18,T.Folder=19,T.EnumMember=20,T.Constant=21,T.Struct=22,T.Event=23,T.Operator=24,T.TypeParameter=25})(Qu||(e.CompletionItemKind=Qu={}));var Tc;(function(T){T.PlainText=1,T.Snippet=2})(Tc||(e.InsertTextFormat=Tc={}));var vc;(function(T){T.Deprecated=1})(vc||(e.CompletionItemTag=vc={}));var Zu;(function(T){function w(S,g,D){return{newText:S,insert:g,replace:D}}T.create=w;function C(S){var g=S;return g&&A.string(g.newText)&&a.is(g.insert)&&a.is(g.replace)}T.is=C})(Zu||(e.InsertReplaceEdit=Zu={}));var ed;(function(T){T.asIs=1,T.adjustIndentation=2})(ed||(e.InsertTextMode=ed={}));var td;(function(T){function w(C){var S=C;return S&&(A.string(S.detail)||S.detail===void 0)&&(A.string(S.description)||S.description===void 0)}T.is=w})(td||(e.CompletionItemLabelDetails=td={}));var nd;(function(T){function w(C){return{label:C}}T.create=w})(nd||(e.CompletionItem=nd={}));var rd;(function(T){function w(C,S){return{items:C||[],isIncomplete:!!S}}T.create=w})(rd||(e.CompletionList=rd={}));var Fo;(function(T){function w(S){return S.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}T.fromPlainText=w;function C(S){var g=S;return A.string(g)||A.objectLiteral(g)&&A.string(g.language)&&A.string(g.value)}T.is=C})(Fo||(e.MarkedString=Fo={}));var Fr;(function(T){function w(C){var S=C;return!!S&&A.objectLiteral(S)&&(Gs.is(S.contents)||Fo.is(S.contents)||A.typedArray(S.contents,Fo.is))&&(C.range===void 0||a.is(C.range))}T.is=w})(Fr||(e.Hover=Fr={}));var id;(function(T){function w(C,S){return S?{label:C,documentation:S}:{label:C}}T.create=w})(id||(e.ParameterInformation=id={}));var sd;(function(T){function w(C,S){for(var g=[],D=2;D<arguments.length;D++)g[D-2]=arguments[D];var $={label:C};return A.defined(S)&&($.documentation=S),A.defined(g)?$.parameters=g:$.parameters=[],$}T.create=w})(sd||(e.SignatureInformation=sd={}));var Ks;(function(T){T.Text=1,T.Read=2,T.Write=3})(Ks||(e.DocumentHighlightKind=Ks={}));var od;(function(T){function w(C,S){var g={range:C};return A.number(S)&&(g.kind=S),g}T.create=w})(od||(e.DocumentHighlight=od={}));var Bo;(function(T){T.File=1,T.Module=2,T.Namespace=3,T.Package=4,T.Class=5,T.Method=6,T.Property=7,T.Field=8,T.Constructor=9,T.Enum=10,T.Interface=11,T.Function=12,T.Variable=13,T.Constant=14,T.String=15,T.Number=16,T.Boolean=17,T.Array=18,T.Object=19,T.Key=20,T.Null=21,T.EnumMember=22,T.Struct=23,T.Event=24,T.Operator=25,T.TypeParameter=26})(Bo||(e.SymbolKind=Bo={}));var ad;(function(T){T.Deprecated=1})(ad||(e.SymbolTag=ad={}));var Di;(function(T){function w(C,S,g,D,$){var Te={name:C,kind:S,location:{uri:D,range:g}};return $&&(Te.containerName=$),Te}T.create=w})(Di||(e.SymbolInformation=Di={}));var Qi;(function(T){function w(C,S,g,D){return D!==void 0?{name:C,kind:S,location:{uri:g,range:D}}:{name:C,kind:S,location:{uri:g}}}T.create=w})(Qi||(e.WorkspaceSymbol=Qi={}));var cd;(function(T){function w(S,g,D,$,Te,At){var ut={name:S,detail:g,kind:D,range:$,selectionRange:Te};return At!==void 0&&(ut.children=At),ut}T.create=w;function C(S){var g=S;return g&&A.string(g.name)&&A.number(g.kind)&&a.is(g.range)&&a.is(g.selectionRange)&&(g.detail===void 0||A.string(g.detail))&&(g.deprecated===void 0||A.boolean(g.deprecated))&&(g.children===void 0||Array.isArray(g.children))&&(g.tags===void 0||Array.isArray(g.tags))}T.is=C})(cd||(e.DocumentSymbol=cd={}));var ld;(function(T){T.Empty="",T.QuickFix="quickfix",T.Refactor="refactor",T.RefactorExtract="refactor.extract",T.RefactorInline="refactor.inline",T.RefactorRewrite="refactor.rewrite",T.Source="source",T.SourceOrganizeImports="source.organizeImports",T.SourceFixAll="source.fixAll"})(ld||(e.CodeActionKind=ld={}));var ui;(function(T){T.Invoked=1,T.Automatic=2})(ui||(e.CodeActionTriggerKind=ui={}));var bc;(function(T){function w(S,g,D){var $={diagnostics:S};return g!=null&&($.only=g),D!=null&&($.triggerKind=D),$}T.create=w;function C(S){var g=S;return A.defined(g)&&A.typedArray(g.diagnostics,b.is)&&(g.only===void 0||A.typedArray(g.only,A.string))&&(g.triggerKind===void 0||g.triggerKind===ui.Invoked||g.triggerKind===ui.Automatic)}T.is=C})(bc||(e.CodeActionContext=bc={}));var _c;(function(T){function w(S,g,D){var $={title:S},Te=!0;return typeof g=="string"?(Te=!1,$.kind=g):P.is(g)?$.command=g:$.edit=g,Te&&D!==void 0&&($.kind=D),$}T.create=w;function C(S){var g=S;return g&&A.string(g.title)&&(g.diagnostics===void 0||A.typedArray(g.diagnostics,b.is))&&(g.kind===void 0||A.string(g.kind))&&(g.edit!==void 0||g.command!==void 0)&&(g.command===void 0||P.is(g.command))&&(g.isPreferred===void 0||A.boolean(g.isPreferred))&&(g.edit===void 0||pr.is(g.edit))}T.is=C})(_c||(e.CodeAction=_c={}));var jo;(function(T){function w(S,g){var D={range:S};return A.defined(g)&&(D.data=g),D}T.create=w;function C(S){var g=S;return A.defined(g)&&a.is(g.range)&&(A.undefined(g.command)||P.is(g.command))}T.is=C})(jo||(e.CodeLens=jo={}));var Sc;(function(T){function w(S,g){return{tabSize:S,insertSpaces:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&A.uinteger(g.tabSize)&&A.boolean(g.insertSpaces)}T.is=C})(Sc||(e.FormattingOptions=Sc={}));var Ai;(function(T){function w(S,g,D){return{range:S,target:g,data:D}}T.create=w;function C(S){var g=S;return A.defined(g)&&a.is(g.range)&&(A.undefined(g.target)||A.string(g.target))}T.is=C})(Ai||(e.DocumentLink=Ai={}));var R;(function(T){function w(S,g){return{range:S,parent:g}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&a.is(g.range)&&(g.parent===void 0||T.is(g.parent))}T.is=C})(R||(e.SelectionRange=R={}));var L;(function(T){T.namespace="namespace",T.type="type",T.class="class",T.enum="enum",T.interface="interface",T.struct="struct",T.typeParameter="typeParameter",T.parameter="parameter",T.variable="variable",T.property="property",T.enumMember="enumMember",T.event="event",T.function="function",T.method="method",T.macro="macro",T.keyword="keyword",T.modifier="modifier",T.comment="comment",T.string="string",T.number="number",T.regexp="regexp",T.operator="operator",T.decorator="decorator"})(L||(e.SemanticTokenTypes=L={}));var G;(function(T){T.declaration="declaration",T.definition="definition",T.readonly="readonly",T.static="static",T.deprecated="deprecated",T.abstract="abstract",T.async="async",T.modification="modification",T.documentation="documentation",T.defaultLibrary="defaultLibrary"})(G||(e.SemanticTokenModifiers=G={}));var ne;(function(T){function w(C){var S=C;return A.objectLiteral(S)&&(S.resultId===void 0||typeof S.resultId=="string")&&Array.isArray(S.data)&&(S.data.length===0||typeof S.data[0]=="number")}T.is=w})(ne||(e.SemanticTokens=ne={}));var et;(function(T){function w(S,g){return{range:S,text:g}}T.create=w;function C(S){var g=S;return g!=null&&a.is(g.range)&&A.string(g.text)}T.is=C})(et||(e.InlineValueText=et={}));var Je;(function(T){function w(S,g,D){return{range:S,variableName:g,caseSensitiveLookup:D}}T.create=w;function C(S){var g=S;return g!=null&&a.is(g.range)&&A.boolean(g.caseSensitiveLookup)&&(A.string(g.variableName)||g.variableName===void 0)}T.is=C})(Je||(e.InlineValueVariableLookup=Je={}));var ht;(function(T){function w(S,g){return{range:S,expression:g}}T.create=w;function C(S){var g=S;return g!=null&&a.is(g.range)&&(A.string(g.expression)||g.expression===void 0)}T.is=C})(ht||(e.InlineValueEvaluatableExpression=ht={}));var kt;(function(T){function w(S,g){return{frameId:S,stoppedLocation:g}}T.create=w;function C(S){var g=S;return A.defined(g)&&a.is(S.stoppedLocation)}T.is=C})(kt||(e.InlineValueContext=kt={}));var we;(function(T){T.Type=1,T.Parameter=2;function w(C){return C===1||C===2}T.is=w})(we||(e.InlayHintKind=we={}));var rt;(function(T){function w(S){return{value:S}}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&(g.tooltip===void 0||A.string(g.tooltip)||Gs.is(g.tooltip))&&(g.location===void 0||c.is(g.location))&&(g.command===void 0||P.is(g.command))}T.is=C})(rt||(e.InlayHintLabelPart=rt={}));var ze;(function(T){function w(S,g,D){var $={position:S,label:g};return D!==void 0&&($.kind=D),$}T.create=w;function C(S){var g=S;return A.objectLiteral(g)&&o.is(g.position)&&(A.string(g.label)||A.typedArray(g.label,rt.is))&&(g.kind===void 0||we.is(g.kind))&&g.textEdits===void 0||A.typedArray(g.textEdits,E.is)&&(g.tooltip===void 0||A.string(g.tooltip)||Gs.is(g.tooltip))&&(g.paddingLeft===void 0||A.boolean(g.paddingLeft))&&(g.paddingRight===void 0||A.boolean(g.paddingRight))}T.is=C})(ze||(e.InlayHint=ze={}));var Dt;(function(T){function w(C){return{kind:"snippet",value:C}}T.createSnippet=w})(Dt||(e.StringValue=Dt={}));var Xt;(function(T){function w(C,S,g,D){return{insertText:C,filterText:S,range:g,command:D}}T.create=w})(Xt||(e.InlineCompletionItem=Xt={}));var rr;(function(T){function w(C){return{items:C}}T.create=w})(rr||(e.InlineCompletionList=rr={}));var ud;(function(T){T.Invoked=0,T.Automatic=1})(ud||(e.InlineCompletionTriggerKind=ud={}));var yk;(function(T){function w(C,S){return{range:C,text:S}}T.create=w})(yk||(e.SelectedCompletionInfo=yk={}));var Tk;(function(T){function w(C,S){return{triggerKind:C,selectedCompletionInfo:S}}T.create=w})(Tk||(e.InlineCompletionContext=Tk={}));var vk;(function(T){function w(C){var S=C;return A.objectLiteral(S)&&r.is(S.uri)&&A.string(S.name)}T.is=w})(vk||(e.WorkspaceFolder=vk={})),e.EOL=[`
33
33
  `,`\r
34
34
  `,"\r"];var bk;(function(T){function w(D,$,Te,At){return new uB(D,$,Te,At)}T.create=w;function C(D){var $=D;return!!(A.defined($)&&A.string($.uri)&&(A.undefined($.languageId)||A.string($.languageId))&&A.uinteger($.lineCount)&&A.func($.getText)&&A.func($.positionAt)&&A.func($.offsetAt))}T.is=C;function S(D,$){for(var Te=D.getText(),At=g($,function(Uo,dd){var _k=Uo.range.start.line-dd.range.start.line;return _k===0?Uo.range.start.character-dd.range.start.character:_k}),ut=Te.length,Br=At.length-1;Br>=0;Br--){var jr=At[Br],Ii=D.offsetAt(jr.range.start),Ie=D.offsetAt(jr.range.end);if(Ie<=ut)Te=Te.substring(0,Ii)+jr.newText+Te.substring(Ie,Te.length);else throw new Error("Overlapping edit");ut=Ii}return Te}T.applyEdits=S;function g(D,$){if(D.length<=1)return D;var Te=D.length/2|0,At=D.slice(0,Te),ut=D.slice(Te);g(At,$),g(ut,$);for(var Br=0,jr=0,Ii=0;Br<At.length&&jr<ut.length;){var Ie=$(At[Br],ut[jr]);Ie<=0?D[Ii++]=At[Br++]:D[Ii++]=ut[jr++]}for(;Br<At.length;)D[Ii++]=At[Br++];for(;jr<ut.length;)D[Ii++]=ut[jr++];return D}})(bk||(e.TextDocument=bk={}));var uB=function(){function T(w,C,S,g){this._uri=w,this._languageId=C,this._version=S,this._content=g,this._lineOffsets=void 0}return Object.defineProperty(T.prototype,"uri",{get:function(){return this._uri},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"languageId",{get:function(){return this._languageId},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),T.prototype.getText=function(w){if(w){var C=this.offsetAt(w.start),S=this.offsetAt(w.end);return this._content.substring(C,S)}return this._content},T.prototype.update=function(w,C){this._content=w.text,this._version=C,this._lineOffsets=void 0},T.prototype.getLineOffsets=function(){if(this._lineOffsets===void 0){for(var w=[],C=this._content,S=!0,g=0;g<C.length;g++){S&&(w.push(g),S=!1);var D=C.charAt(g);S=D==="\r"||D===`
35
35
  `,D==="\r"&&g+1<C.length&&C.charAt(g+1)===`
@@ -179,8 +179,8 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
179
179
  || ${o} === "boolean" || ${i} === null`).assign(a,(0,_e._)`[${i}]`)}}}function r3({gen:t,parentData:e,parentDataProperty:n},r){t.if((0,_e._)`${e} !== undefined`,()=>t.assign((0,_e._)`${e}[${n}]`,r))}function v_(t,e,n,r=rc.Correct){let i=r===rc.Correct?_e.operators.EQ:_e.operators.NEQ,s;switch(t){case"null":return(0,_e._)`${e} ${i} null`;case"array":s=(0,_e._)`Array.isArray(${e})`;break;case"object":s=(0,_e._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=o((0,_e._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=o();break;default:return(0,_e._)`typeof ${e} ${i} ${t}`}return r===rc.Correct?s:(0,_e.not)(s);function o(a=_e.nil){return(0,_e.and)((0,_e._)`typeof ${e} == "number"`,a,n?(0,_e._)`isFinite(${e})`:_e.nil)}}Rn.checkDataType=v_;function b_(t,e,n,r){if(t.length===1)return v_(t[0],e,n,r);let i,s=(0,A1.toHash)(t);if(s.array&&s.object){let o=(0,_e._)`typeof ${e} != "object"`;i=s.null?o:(0,_e._)`!${e} || ${o}`,delete s.null,delete s.array,delete s.object}else i=_e.nil;s.number&&delete s.integer;for(let o in s)i=(0,_e.and)(i,v_(o,e,n,r));return i}Rn.checkDataTypes=b_;var i3={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,_e._)`{type: ${t}}`:(0,_e._)`{type: ${e}}`};function __(t){let e=s3(t);(0,QY.reportError)(e,i3)}Rn.reportTypeError=__;function s3(t){let{gen:e,data:n,schema:r}=t,i=(0,A1.schemaRefOrVal)(t,r,"type");return{gen:e,keyword:"type",data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:t}}});var x1=N(wm=>{"use strict";Object.defineProperty(wm,"__esModule",{value:!0});wm.assignDefaults=void 0;var ic=be(),o3=Ne();function a3(t,e){let{properties:n,items:r}=t.schema;if(e==="object"&&n)for(let i in n)M1(t,i,n[i].default);else e==="array"&&Array.isArray(r)&&r.forEach((i,s)=>M1(t,s,i.default))}wm.assignDefaults=a3;function M1(t,e,n){let{gen:r,compositeRule:i,data:s,opts:o}=t;if(n===void 0)return;let a=(0,ic._)`${s}${(0,ic.getProperty)(e)}`;if(i){(0,o3.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,ic._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,ic._)`${c} || ${a} === null || ${a} === ""`),r.if(c,(0,ic._)`${a} = ${(0,ic.stringify)(n)}`)}});var Or=N(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.validateUnion=nt.validateArray=nt.usePattern=nt.callValidateCode=nt.schemaProperties=nt.allSchemaProperties=nt.noPropertyInData=nt.propertyInData=nt.isOwnProperty=nt.hasPropFunc=nt.reportMissingProp=nt.checkMissingProp=nt.checkReportMissingProp=void 0;var _t=be(),S_=Ne(),Ms=Ir(),c3=Ne();function l3(t,e){let{gen:n,data:r,it:i}=t;n.if(P_(n,r,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,_t._)`${e}`},!0),t.error()})}nt.checkReportMissingProp=l3;function u3({gen:t,data:e,it:{opts:n}},r,i){return(0,_t.or)(...r.map(s=>(0,_t.and)(P_(t,e,s,n.ownProperties),(0,_t._)`${i} = ${s}`)))}nt.checkMissingProp=u3;function d3(t,e){t.setParams({missingProperty:e},!0),t.error()}nt.reportMissingProp=d3;function L1(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,_t._)`Object.prototype.hasOwnProperty`})}nt.hasPropFunc=L1;function k_(t,e,n){return(0,_t._)`${L1(t)}.call(${e}, ${n})`}nt.isOwnProperty=k_;function f3(t,e,n,r){let i=(0,_t._)`${e}${(0,_t.getProperty)(n)} !== undefined`;return r?(0,_t._)`${i} && ${k_(t,e,n)}`:i}nt.propertyInData=f3;function P_(t,e,n,r){let i=(0,_t._)`${e}${(0,_t.getProperty)(n)} === undefined`;return r?(0,_t.or)(i,(0,_t.not)(k_(t,e,n))):i}nt.noPropertyInData=P_;function q1(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}nt.allSchemaProperties=q1;function p3(t,e){return q1(e).filter(n=>!(0,S_.alwaysValidSchema)(t,e[n]))}nt.schemaProperties=p3;function h3({schemaCode:t,data:e,it:{gen:n,topSchemaRef:r,schemaPath:i,errorPath:s},it:o},a,c,l){let u=l?(0,_t._)`${t}, ${e}, ${r}${i}`:e,d=[[Ms.default.instancePath,(0,_t.strConcat)(Ms.default.instancePath,s)],[Ms.default.parentData,o.parentData],[Ms.default.parentDataProperty,o.parentDataProperty],[Ms.default.rootData,Ms.default.rootData]];o.opts.dynamicRef&&d.push([Ms.default.dynamicAnchors,Ms.default.dynamicAnchors]);let f=(0,_t._)`${u}, ${n.object(...d)}`;return c!==_t.nil?(0,_t._)`${a}.call(${c}, ${f})`:(0,_t._)`${a}(${f})`}nt.callValidateCode=h3;var m3=(0,_t._)`new RegExp`;function g3({gen:t,it:{opts:e}},n){let r=e.unicodeRegExp?"u":"",{regExp:i}=e.code,s=i(n,r);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,_t._)`${i.code==="new RegExp"?m3:(0,c3.useFunc)(t,i)}(${n}, ${r})`})}nt.usePattern=g3;function y3(t){let{gen:e,data:n,keyword:r,it:i}=t,s=e.name("valid");if(i.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(s,!0),o(()=>e.break()),s;function o(a){let c=e.const("len",(0,_t._)`${n}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:r,dataProp:l,dataPropType:S_.Type.Num},s),e.if((0,_t.not)(s),a)})}}nt.validateArray=y3;function T3(t){let{gen:e,schema:n,keyword:r,it:i}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(c=>(0,S_.alwaysValidSchema)(i,c))&&!i.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>n.forEach((c,l)=>{let u=t.subschema({keyword:r,schemaProp:l,compositeRule:!0},a);e.assign(o,(0,_t._)`${o} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,_t.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}nt.validateUnion=T3});var B1=N(Ni=>{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});Ni.validateKeywordUsage=Ni.validSchemaType=Ni.funcKeywordCode=Ni.macroKeywordCode=void 0;var qn=be(),Ao=Ir(),v3=Or(),b3=yu();function _3(t,e){let{gen:n,keyword:r,schema:i,parentSchema:s,it:o}=t,a=e.macro.call(o.self,i,s,o),c=F1(n,r,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let l=n.name("valid");t.subschema({schema:a,schemaPath:qn.nil,errSchemaPath:`${o.errSchemaPath}/${r}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}Ni.macroKeywordCode=_3;function S3(t,e){var n;let{gen:r,keyword:i,schema:s,parentSchema:o,$data:a,it:c}=t;P3(c,e);let l=!a&&e.compile?e.compile.call(c.self,s,o,c):e.validate,u=F1(r,i,l),d=r.let("valid");t.block$data(d,f),t.ok((n=e.valid)!==null&&n!==void 0?n:d);function f(){if(e.errors===!1)h(),e.modifying&&$1(t),y(()=>t.error());else{let _=e.async?p():m();e.modifying&&$1(t),y(()=>k3(t,_))}}function p(){let _=r.let("ruleErrs",null);return r.try(()=>h((0,qn._)`await `),v=>r.assign(d,!1).if((0,qn._)`${v} instanceof ${c.ValidationError}`,()=>r.assign(_,(0,qn._)`${v}.errors`),()=>r.throw(v))),_}function m(){let _=(0,qn._)`${u}.errors`;return r.assign(_,null),h(qn.nil),_}function h(_=e.async?(0,qn._)`await `:qn.nil){let v=c.opts.passContext?Ao.default.this:Ao.default.self,b=!("compile"in e&&!a||e.schema===!1);r.assign(d,(0,qn._)`${_}${(0,v3.callValidateCode)(t,u,v,b)}`,e.modifying)}function y(_){var v;r.if((0,qn.not)((v=e.valid)!==null&&v!==void 0?v:d),_)}}Ni.funcKeywordCode=S3;function $1(t){let{gen:e,data:n,it:r}=t;e.if(r.parentData,()=>e.assign(n,(0,qn._)`${r.parentData}[${r.parentDataProperty}]`))}function k3(t,e){let{gen:n}=t;n.if((0,qn._)`Array.isArray(${e})`,()=>{n.assign(Ao.default.vErrors,(0,qn._)`${Ao.default.vErrors} === null ? ${e} : ${Ao.default.vErrors}.concat(${e})`).assign(Ao.default.errors,(0,qn._)`${Ao.default.vErrors}.length`),(0,b3.extendErrors)(t)},()=>t.error())}function P3({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function F1(t,e,n){if(n===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,qn.stringify)(n)})}function N3(t,e,n=!1){return!e.length||e.some(r=>r==="array"?Array.isArray(t):r==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==r||n&&typeof t>"u")}Ni.validSchemaType=N3;function R3({schema:t,opts:e,self:n,errSchemaPath:r},i,s){if(Array.isArray(i.keyword)?!i.keyword.includes(s):i.keyword!==s)throw new Error("ajv implementation error");let o=i.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")n.logger.error(c);else throw new Error(c)}}Ni.validateKeywordUsage=R3});var U1=N(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});xs.extendSubschemaMode=xs.extendSubschemaData=xs.getSubschema=void 0;var Ri=be(),j1=Ne();function w3(t,{keyword:e,schemaProp:n,schema:r,schemaPath:i,errSchemaPath:s,topSchemaRef:o}){if(e!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return n===void 0?{schema:a,schemaPath:(0,Ri._)`${t.schemaPath}${(0,Ri.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[n],schemaPath:(0,Ri._)`${t.schemaPath}${(0,Ri.getProperty)(e)}${(0,Ri.getProperty)(n)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,j1.escapeFragment)(n)}`}}if(r!==void 0){if(i===void 0||s===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:i,topSchemaRef:o,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}xs.getSubschema=w3;function E3(t,e,{dataProp:n,dataPropType:r,data:i,dataTypes:s,propertyName:o}){if(i!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(n!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,f=a.let("data",(0,Ri._)`${e.data}${(0,Ri.getProperty)(n)}`,!0);c(f),t.errorPath=(0,Ri.str)`${l}${(0,j1.getErrorPath)(n,r,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Ri._)`${n}`,t.dataPathArr=[...u,t.parentDataProperty]}if(i!==void 0){let l=i instanceof Ri.Name?i:a.let("data",i,!0);c(l),o!==void 0&&(t.propertyName=o)}s&&(t.dataTypes=s);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}xs.extendSubschemaData=E3;function C3(t,{jtdDiscriminator:e,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:s}){r!==void 0&&(t.compositeRule=r),i!==void 0&&(t.createErrors=i),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=n}xs.extendSubschemaMode=C3});var N_=N((WRe,H1)=>{"use strict";H1.exports=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}});var W1=N((zRe,V1)=>{"use strict";var Ls=V1.exports=function(t,e,n){typeof e=="function"&&(n=e,e={}),n=e.cb||n;var r=typeof n=="function"?n:n.pre||function(){},i=n.post||function(){};Em(e,r,i,t,"",t)};Ls.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ls.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ls.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ls.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Em(t,e,n,r,i,s,o,a,c,l){if(r&&typeof r=="object"&&!Array.isArray(r)){e(r,i,s,o,a,c,l);for(var u in r){var d=r[u];if(Array.isArray(d)){if(u in Ls.arrayKeywords)for(var f=0;f<d.length;f++)Em(t,e,n,d[f],i+"/"+u+"/"+f,s,i,u,r,f)}else if(u in Ls.propsKeywords){if(d&&typeof d=="object")for(var p in d)Em(t,e,n,d[p],i+"/"+u+"/"+D3(p),s,i,u,r,p)}else(u in Ls.keywords||t.allKeys&&!(u in Ls.skipKeywords))&&Em(t,e,n,d,i+"/"+u,s,i,u,r)}n(r,i,s,o,a,c,l)}}function D3(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var vu=N(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.getSchemaRefs=tr.resolveUrl=tr.normalizeId=tr._getFullPath=tr.getFullPath=tr.inlineRef=void 0;var A3=Ne(),I3=N_(),O3=W1(),M3=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function x3(t,e=!0){return typeof t=="boolean"?!0:e===!0?!R_(t):e?z1(t)<=e:!1}tr.inlineRef=x3;var L3=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function R_(t){for(let e in t){if(L3.has(e))return!0;let n=t[e];if(Array.isArray(n)&&n.some(R_)||typeof n=="object"&&R_(n))return!0}return!1}function z1(t){let e=0;for(let n in t){if(n==="$ref")return 1/0;if(e++,!M3.has(n)&&(typeof t[n]=="object"&&(0,A3.eachItem)(t[n],r=>e+=z1(r)),e===1/0))return 1/0}return e}function G1(t,e="",n){n!==!1&&(e=sc(e));let r=t.parse(e);return K1(t,r)}tr.getFullPath=G1;function K1(t,e){return t.serialize(e).split("#")[0]+"#"}tr._getFullPath=K1;var q3=/#\/?$/;function sc(t){return t?t.replace(q3,""):""}tr.normalizeId=sc;function $3(t,e,n){return n=sc(n),t.resolve(e,n)}tr.resolveUrl=$3;var F3=/^[a-z_][-a-z0-9._]*$/i;function B3(t,e){if(typeof t=="boolean")return{};let{schemaId:n,uriResolver:r}=this.opts,i=sc(t[n]||e),s={"":i},o=G1(r,i,!1),a={},c=new Set;return O3(t,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=o+f,y=s[m];typeof d[n]=="string"&&(y=_.call(this,d[n])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[f]=y;function _(b){let P=this.opts.uriResolver.resolve;if(b=sc(y?P(y,b):b),c.has(b))throw u(b);c.add(b);let E=this.refs[b];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?l(d,E.schema,b):b!==sc(h)&&(b[0]==="#"?(l(d,a[b],b),a[b]=d):this.refs[b]=h),b}function v(b){if(typeof b=="string"){if(!F3.test(b))throw new Error(`invalid anchor "${b}"`);_.call(this,`#${b}`)}}}),a;function l(d,f,p){if(f!==void 0&&!I3(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}tr.getSchemaRefs=B3});var Su=N(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.getData=qs.KeywordCxt=qs.validateFunctionCode=void 0;var Z1=E1(),Y1=Tu(),E_=T_(),Cm=Tu(),j3=x1(),_u=B1(),w_=U1(),se=be(),me=Ir(),U3=vu(),Yi=Ne(),bu=yu();function H3(t){if(nq(t)&&(rq(t),tq(t))){z3(t);return}eq(t,()=>(0,Z1.topBoolOrEmptySchema)(t))}qs.validateFunctionCode=H3;function eq({gen:t,validateName:e,schema:n,schemaEnv:r,opts:i},s){i.code.es5?t.func(e,(0,se._)`${me.default.data}, ${me.default.valCxt}`,r.$async,()=>{t.code((0,se._)`"use strict"; ${X1(n,i)}`),W3(t,i),t.code(s)}):t.func(e,(0,se._)`${me.default.data}, ${V3(i)}`,r.$async,()=>t.code(X1(n,i)).code(s))}function V3(t){return(0,se._)`{${me.default.instancePath}="", ${me.default.parentData}, ${me.default.parentDataProperty}, ${me.default.rootData}=${me.default.data}${t.dynamicRef?(0,se._)`, ${me.default.dynamicAnchors}={}`:se.nil}}={}`}function W3(t,e){t.if(me.default.valCxt,()=>{t.var(me.default.instancePath,(0,se._)`${me.default.valCxt}.${me.default.instancePath}`),t.var(me.default.parentData,(0,se._)`${me.default.valCxt}.${me.default.parentData}`),t.var(me.default.parentDataProperty,(0,se._)`${me.default.valCxt}.${me.default.parentDataProperty}`),t.var(me.default.rootData,(0,se._)`${me.default.valCxt}.${me.default.rootData}`),e.dynamicRef&&t.var(me.default.dynamicAnchors,(0,se._)`${me.default.valCxt}.${me.default.dynamicAnchors}`)},()=>{t.var(me.default.instancePath,(0,se._)`""`),t.var(me.default.parentData,(0,se._)`undefined`),t.var(me.default.parentDataProperty,(0,se._)`undefined`),t.var(me.default.rootData,me.default.data),e.dynamicRef&&t.var(me.default.dynamicAnchors,(0,se._)`{}`)})}function z3(t){let{schema:e,opts:n,gen:r}=t;eq(t,()=>{n.$comment&&e.$comment&&sq(t),J3(t),r.let(me.default.vErrors,null),r.let(me.default.errors,0),n.unevaluated&&G3(t),iq(t),eX(t)})}function G3(t){let{gen:e,validateName:n}=t;t.evaluated=e.const("evaluated",(0,se._)`${n}.evaluated`),e.if((0,se._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,se._)`${t.evaluated}.props`,(0,se._)`undefined`)),e.if((0,se._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,se._)`${t.evaluated}.items`,(0,se._)`undefined`))}function X1(t,e){let n=typeof t=="object"&&t[e.schemaId];return n&&(e.code.source||e.code.process)?(0,se._)`/*# sourceURL=${n} */`:se.nil}function K3(t,e){if(nq(t)&&(rq(t),tq(t))){Y3(t,e);return}(0,Z1.boolOrEmptySchema)(t,e)}function tq({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let n in t)if(e.RULES.all[n])return!0;return!1}function nq(t){return typeof t.schema!="boolean"}function Y3(t,e){let{schema:n,gen:r,opts:i}=t;i.$comment&&n.$comment&&sq(t),Q3(t),Z3(t);let s=r.const("_errs",me.default.errors);iq(t,s),r.var(e,(0,se._)`${s} === ${me.default.errors}`)}function rq(t){(0,Yi.checkUnknownRules)(t),X3(t)}function iq(t,e){if(t.opts.jtd)return J1(t,[],!1,e);let n=(0,Y1.getSchemaTypes)(t.schema),r=(0,Y1.coerceAndCheckDataType)(t,n);J1(t,n,!r,e)}function X3(t){let{schema:e,errSchemaPath:n,opts:r,self:i}=t;e.$ref&&r.ignoreKeywordsWithRef&&(0,Yi.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function J3(t){let{schema:e,opts:n}=t;e.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,Yi.checkStrictMode)(t,"default is ignored in the schema root")}function Q3(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,U3.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Z3(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function sq({gen:t,schemaEnv:e,schema:n,errSchemaPath:r,opts:i}){let s=n.$comment;if(i.$comment===!0)t.code((0,se._)`${me.default.self}.logger.log(${s})`);else if(typeof i.$comment=="function"){let o=(0,se.str)`${r}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,se._)`${me.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function eX(t){let{gen:e,schemaEnv:n,validateName:r,ValidationError:i,opts:s}=t;n.$async?e.if((0,se._)`${me.default.errors} === 0`,()=>e.return(me.default.data),()=>e.throw((0,se._)`new ${i}(${me.default.vErrors})`)):(e.assign((0,se._)`${r}.errors`,me.default.vErrors),s.unevaluated&&tX(t),e.return((0,se._)`${me.default.errors} === 0`))}function tX({gen:t,evaluated:e,props:n,items:r}){n instanceof se.Name&&t.assign((0,se._)`${e}.props`,n),r instanceof se.Name&&t.assign((0,se._)`${e}.items`,r)}function J1(t,e,n,r){let{gen:i,schema:s,data:o,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Yi.schemaHasRulesButRef)(s,u))){i.block(()=>aq(t,"$ref",u.all.$ref.definition));return}c.jtd||nX(t,e),i.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,E_.shouldUseGroup)(s,f)&&(f.type?(i.if((0,Cm.checkDataType)(f.type,o,c.strictNumbers)),Q1(t,f),e.length===1&&e[0]===f.type&&n&&(i.else(),(0,Cm.reportTypeError)(t)),i.endIf()):Q1(t,f),a||i.if((0,se._)`${me.default.errors} === ${r||0}`))}}function Q1(t,e){let{gen:n,schema:r,opts:{useDefaults:i}}=t;i&&(0,j3.assignDefaults)(t,e.type),n.block(()=>{for(let s of e.rules)(0,E_.shouldUseRule)(r,s)&&aq(t,s.keyword,s.definition,e.type)})}function nX(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(rX(t,e),t.opts.allowUnionTypes||iX(t,e),sX(t,t.dataTypes))}function rX(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(n=>{oq(t.dataTypes,n)||C_(t,`type "${n}" not allowed by context "${t.dataTypes.join(",")}"`)}),aX(t,e)}}function iX(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&C_(t,"use allowUnionTypes to allow union type keyword")}function sX(t,e){let n=t.self.RULES.all;for(let r in n){let i=n[r];if(typeof i=="object"&&(0,E_.shouldUseRule)(t.schema,i)){let{type:s}=i.definition;s.length&&!s.some(o=>oX(e,o))&&C_(t,`missing type "${s.join(",")}" for keyword "${r}"`)}}}function oX(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function oq(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function aX(t,e){let n=[];for(let r of t.dataTypes)oq(e,r)?n.push(r):e.includes("integer")&&r==="number"&&n.push("integer");t.dataTypes=n}function C_(t,e){let n=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${n}" (strictTypes)`,(0,Yi.checkStrictMode)(t,e,t.opts.strictTypes)}var Dm=class{constructor(e,n,r){if((0,_u.validateKeywordUsage)(e,n,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=n.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Yi.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=n.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=n,this.$data)this.schemaCode=e.gen.const("vSchema",cq(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,_u.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=e.gen.const("_errs",me.default.errors))}result(e,n,r){this.failResult((0,se.not)(e),n,r)}failResult(e,n,r){this.gen.if(e),r?r():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,n){this.failResult((0,se.not)(e),void 0,n)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:n}=this;this.fail((0,se._)`${n} !== undefined && (${(0,se.or)(this.invalid$data(),e)})`)}error(e,n,r){if(n){this.setParams(n),this._error(e,r),this.setParams({});return}this._error(e,r)}_error(e,n){(e?bu.reportExtraError:bu.reportError)(this,this.def.error,n)}$dataError(){(0,bu.reportError)(this,this.def.$dataError||bu.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,bu.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,n){n?Object.assign(this.params,e):this.params=e}block$data(e,n,r=se.nil){this.gen.block(()=>{this.check$data(e,r),n()})}check$data(e=se.nil,n=se.nil){if(!this.$data)return;let{gen:r,schemaCode:i,schemaType:s,def:o}=this;r.if((0,se.or)((0,se._)`${i} === undefined`,n)),e!==se.nil&&r.assign(e,!0),(s.length||o.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==se.nil&&r.assign(e,!1)),r.else()}invalid$data(){let{gen:e,schemaCode:n,schemaType:r,def:i,it:s}=this;return(0,se.or)(o(),a());function o(){if(r.length){if(!(n instanceof se.Name))throw new Error("ajv implementation error");let c=Array.isArray(r)?r:[r];return(0,se._)`${(0,Cm.checkDataTypes)(c,n,s.opts.strictNumbers,Cm.DataType.Wrong)}`}return se.nil}function a(){if(i.validateSchema){let c=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,se._)`!${c}(${n})`}return se.nil}}subschema(e,n){let r=(0,w_.getSubschema)(this.it,e);(0,w_.extendSubschemaData)(r,this.it,e),(0,w_.extendSubschemaMode)(r,e);let i={...this.it,...r,items:void 0,props:void 0};return K3(i,n),i}mergeEvaluated(e,n){let{it:r,gen:i}=this;r.opts.unevaluated&&(r.props!==!0&&e.props!==void 0&&(r.props=Yi.mergeEvaluated.props(i,e.props,r.props,n)),r.items!==!0&&e.items!==void 0&&(r.items=Yi.mergeEvaluated.items(i,e.items,r.items,n)))}mergeValidEvaluated(e,n){let{it:r,gen:i}=this;if(r.opts.unevaluated&&(r.props!==!0||r.items!==!0))return i.if(n,()=>this.mergeEvaluated(e,se.Name)),!0}};qs.KeywordCxt=Dm;function aq(t,e,n,r){let i=new Dm(t,n,e);"code"in n?n.code(i,r):i.$data&&n.validate?(0,_u.funcKeywordCode)(i,n):"macro"in n?(0,_u.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,_u.funcKeywordCode)(i,n)}var cX=/^\/(?:[^~]|~0|~1)*$/,lX=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function cq(t,{dataLevel:e,dataNames:n,dataPathArr:r}){let i,s;if(t==="")return me.default.rootData;if(t[0]==="/"){if(!cX.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,s=me.default.rootData}else{let l=lX.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(i=l[2],i==="#"){if(u>=e)throw new Error(c("property/index",u));return r[e-u]}if(u>e)throw new Error(c("data",u));if(s=n[e-u],!i)return s}let o=s,a=i.split("/");for(let l of a)l&&(s=(0,se._)`${s}${(0,se.getProperty)((0,Yi.unescapeJsonPointer)(l))}`,o=(0,se._)`${o} && ${s}`);return o;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}qs.getData=cq});var Am=N(A_=>{"use strict";Object.defineProperty(A_,"__esModule",{value:!0});var D_=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};A_.default=D_});var ku=N(M_=>{"use strict";Object.defineProperty(M_,"__esModule",{value:!0});var I_=vu(),O_=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,I_.resolveUrl)(e,n,r),this.missingSchema=(0,I_.normalizeId)((0,I_.getFullPath)(e,this.missingRef))}};M_.default=O_});var Pu=N(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.resolveSchema=Mr.getCompilingSchema=Mr.resolveRef=Mr.compileSchema=Mr.SchemaEnv=void 0;var oi=be(),uX=Am(),Io=Ir(),ai=vu(),lq=Ne(),dX=Su(),oc=class{constructor(e){var n;this.refs={},this.dynamicAnchors={};let r;typeof e.schema=="object"&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(n=e.baseId)!==null&&n!==void 0?n:(0,ai.normalizeId)(r?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=r?.$async,this.refs={}}};Mr.SchemaEnv=oc;function L_(t){let e=uq.call(this,t);if(e)return e;let n=(0,ai.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:r,lines:i}=this.opts.code,{ownProperties:s}=this.opts,o=new oi.CodeGen(this.scope,{es5:r,lines:i,ownProperties:s}),a;t.$async&&(a=o.scopeValue("Error",{ref:uX.default,code:(0,oi._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let l={gen:o,allErrors:this.opts.allErrors,data:Io.default.data,parentData:Io.default.parentData,parentDataProperty:Io.default.parentDataProperty,dataNames:[Io.default.data],dataPathArr:[oi.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,oi.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:n,baseId:t.baseId||n,schemaPath:oi.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,oi._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,dX.validateFunctionCode)(l),o.optimize(this.opts.code.optimize);let d=o.toString();u=`${o.scopeRefs(Io.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${Io.default.self}`,`${Io.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:m,items:h}=l;p.evaluated={props:m instanceof oi.Name?void 0:m,items:h instanceof oi.Name?void 0:h,dynamicProps:m instanceof oi.Name,dynamicItems:h instanceof oi.Name},p.source&&(p.source.evaluated=(0,oi.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}Mr.compileSchema=L_;function fX(t,e,n){var r;n=(0,ai.resolveUrl)(this.opts.uriResolver,e,n);let i=t.refs[n];if(i)return i;let s=mX.call(this,t,n);if(s===void 0){let o=(r=t.localRefs)===null||r===void 0?void 0:r[n],{schemaId:a}=this.opts;o&&(s=new oc({schema:o,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[n]=pX.call(this,s)}Mr.resolveRef=fX;function pX(t){return(0,ai.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:L_.call(this,t)}function uq(t){for(let e of this._compilations)if(hX(e,t))return e}Mr.getCompilingSchema=uq;function hX(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function mX(t,e){let n;for(;typeof(n=this.refs[e])=="string";)e=n;return n||this.schemas[e]||Im.call(this,t,e)}function Im(t,e){let n=this.opts.uriResolver.parse(e),r=(0,ai._getFullPath)(this.opts.uriResolver,n),i=(0,ai.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&r===i)return x_.call(this,n,t);let s=(0,ai.normalizeId)(r),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=Im.call(this,t,o);return typeof a?.schema!="object"?void 0:x_.call(this,n,a)}if(typeof o?.schema=="object"){if(o.validate||L_.call(this,o),s===(0,ai.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,l=a[c];return l&&(i=(0,ai.resolveUrl)(this.opts.uriResolver,i,l)),new oc({schema:a,schemaId:c,root:t,baseId:i})}return x_.call(this,n,o)}}Mr.resolveSchema=Im;var gX=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function x_(t,{baseId:e,schema:n,root:r}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof n=="boolean")return;let c=n[(0,lq.unescapeFragment)(a)];if(c===void 0)return;n=c;let l=typeof n=="object"&&n[this.opts.schemaId];!gX.has(a)&&l&&(e=(0,ai.resolveUrl)(this.opts.uriResolver,e,l))}let s;if(typeof n!="boolean"&&n.$ref&&!(0,lq.schemaHasRulesButRef)(n,this.RULES)){let a=(0,ai.resolveUrl)(this.opts.uriResolver,e,n.$ref);s=Im.call(this,r,a)}let{schemaId:o}=this.opts;if(s=s||new oc({schema:n,schemaId:o,root:r,baseId:e}),s.schema!==s.root.schema)return s}});var dq=N((QRe,yX)=>{yX.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var pq=N((ZRe,fq)=>{"use strict";var TX={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};fq.exports={HEX:TX}});var _q=N((ewe,bq)=>{"use strict";var{HEX:vX}=pq(),bX=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function yq(t){if(vq(t,".")<3)return{host:t,isIPV4:!1};let e=t.match(bX)||[],[n]=e;return n?{host:SX(n,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function q_(t,e=!1){let n="",r=!0;for(let i of t){if(vX[i]===void 0)return;i!=="0"&&r===!0&&(r=!1),r||(n+=i)}return e&&n.length===0&&(n="0"),n}function _X(t){let e=0,n={error:!1,address:"",zone:""},r=[],i=[],s=!1,o=!1,a=!1;function c(){if(i.length){if(s===!1){let l=q_(i);if(l!==void 0)r.push(l);else return n.error=!0,!1}i.length=0}return!0}for(let l=0;l<t.length;l++){let u=t[l];if(!(u==="["||u==="]"))if(u===":"){if(o===!0&&(a=!0),!c())break;if(e++,r.push(":"),e>7){n.error=!0;break}l-1>=0&&t[l-1]===":"&&(o=!0);continue}else if(u==="%"){if(!c())break;s=!0}else{i.push(u);continue}}return i.length&&(s?n.zone=i.join(""):a?r.push(i.join("")):r.push(q_(i))),n.address=r.join(""),n}function Tq(t){if(vq(t,":")<2)return{host:t,isIPV6:!1};let e=_X(t);if(e.error)return{host:t,isIPV6:!1};{let n=e.address,r=e.address;return e.zone&&(n+="%"+e.zone,r+="%25"+e.zone),{host:n,escapedHost:r,isIPV6:!0}}}function SX(t,e){let n="",r=!0,i=t.length;for(let s=0;s<i;s++){let o=t[s];o==="0"&&r?(s+1<=i&&t[s+1]===e||s+1===i)&&(n+=o,r=!1):(o===e?r=!0:r=!1,n+=o)}return n}function vq(t,e){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}var hq=/^\.\.?\//u,mq=/^\/\.(?:\/|$)/u,gq=/^\/\.\.(?:\/|$)/u,kX=/^\/?(?:.|\n)*?(?=\/|$)/u;function PX(t){let e=[];for(;t.length;)if(t.match(hq))t=t.replace(hq,"");else if(t.match(mq))t=t.replace(mq,"/");else if(t.match(gq))t=t.replace(gq,"/"),e.pop();else if(t==="."||t==="..")t="";else{let n=t.match(kX);if(n){let r=n[0];t=t.slice(r.length),e.push(r)}else throw new Error("Unexpected dot segment condition")}return e.join("")}function NX(t,e){let n=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=n(t.scheme)),t.userinfo!==void 0&&(t.userinfo=n(t.userinfo)),t.host!==void 0&&(t.host=n(t.host)),t.path!==void 0&&(t.path=n(t.path)),t.query!==void 0&&(t.query=n(t.query)),t.fragment!==void 0&&(t.fragment=n(t.fragment)),t}function RX(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let n=unescape(t.host),r=yq(n);if(r.isIPV4)n=r.host;else{let i=Tq(r.host);i.isIPV6===!0?n=`[${i.escapedHost}]`:n=t.host}e.push(n)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}bq.exports={recomposeAuthority:RX,normalizeComponentEncoding:NX,removeDotSegments:PX,normalizeIPv4:yq,normalizeIPv6:Tq,stringArrayToHexStripped:q_}});var wq=N((twe,Rq)=>{"use strict";var wX=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,EX=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function Sq(t){return typeof t.secure=="boolean"?t.secure:String(t.scheme).toLowerCase()==="wss"}function kq(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Pq(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function CX(t){return t.secure=Sq(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function DX(t){if((t.port===(Sq(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,n]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=n,t.resourceName=void 0}return t.fragment=void 0,t}function AX(t,e){if(!t.path)return t.error="URN can not be parsed",t;let n=t.path.match(EX);if(n){let r=e.scheme||t.scheme||"urn";t.nid=n[1].toLowerCase(),t.nss=n[2];let i=`${r}:${e.nid||t.nid}`,s=$_[i];t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function IX(t,e){let n=e.scheme||t.scheme||"urn",r=t.nid.toLowerCase(),i=`${n}:${e.nid||r}`,s=$_[i];s&&(t=s.serialize(t,e));let o=t,a=t.nss;return o.path=`${r||e.nid}:${a}`,e.skipEscape=!0,o}function OX(t,e){let n=t;return n.uuid=n.nss,n.nss=void 0,!e.tolerant&&(!n.uuid||!wX.test(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function MX(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Nq={scheme:"http",domainHost:!0,parse:kq,serialize:Pq},xX={scheme:"https",domainHost:Nq.domainHost,parse:kq,serialize:Pq},Om={scheme:"ws",domainHost:!0,parse:CX,serialize:DX},LX={scheme:"wss",domainHost:Om.domainHost,parse:Om.parse,serialize:Om.serialize},qX={scheme:"urn",parse:AX,serialize:IX,skipNormalize:!0},$X={scheme:"urn:uuid",parse:OX,serialize:MX,skipNormalize:!0},$_={http:Nq,https:xX,ws:Om,wss:LX,urn:qX,"urn:uuid":$X};Rq.exports=$_});var Cq=N((nwe,xm)=>{"use strict";var{normalizeIPv6:FX,normalizeIPv4:BX,removeDotSegments:Nu,recomposeAuthority:jX,normalizeComponentEncoding:Mm}=_q(),F_=wq();function UX(t,e){return typeof t=="string"?t=wi(Xi(t,e),e):typeof t=="object"&&(t=Xi(wi(t,e),e)),t}function HX(t,e,n){let r=Object.assign({scheme:"null"},n),i=Eq(Xi(t,r),Xi(e,r),r,!0);return wi(i,{...r,skipEscape:!0})}function Eq(t,e,n,r){let i={};return r||(t=Xi(wi(t,n),n),e=Xi(wi(e,n),n)),n=n||{},!n.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=Nu(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=Nu(e.path||""),i.query=e.query):(e.path?(e.path.charAt(0)==="/"?i.path=Nu(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?i.path="/"+e.path:t.path?i.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=Nu(i.path)),i.query=e.query):(i.path=t.path,e.query!==void 0?i.query=e.query:i.query=t.query),i.userinfo=t.userinfo,i.host=t.host,i.port=t.port),i.scheme=t.scheme),i.fragment=e.fragment,i}function VX(t,e,n){return typeof t=="string"?(t=unescape(t),t=wi(Mm(Xi(t,n),!0),{...n,skipEscape:!0})):typeof t=="object"&&(t=wi(Mm(t,!0),{...n,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=wi(Mm(Xi(e,n),!0),{...n,skipEscape:!0})):typeof e=="object"&&(e=wi(Mm(e,!0),{...n,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function wi(t,e){let n={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},r=Object.assign({},e),i=[],s=F_[(r.scheme||n.scheme||"").toLowerCase()];s&&s.serialize&&s.serialize(n,r),n.path!==void 0&&(r.skipEscape?n.path=unescape(n.path):(n.path=escape(n.path),n.scheme!==void 0&&(n.path=n.path.split("%3A").join(":")))),r.reference!=="suffix"&&n.scheme&&i.push(n.scheme,":");let o=jX(n);if(o!==void 0&&(r.reference!=="suffix"&&i.push("//"),i.push(o),n.path&&n.path.charAt(0)!=="/"&&i.push("/")),n.path!==void 0){let a=n.path;!r.absolutePath&&(!s||!s.absolutePath)&&(a=Nu(a)),o===void 0&&(a=a.replace(/^\/\//u,"/%2F")),i.push(a)}return n.query!==void 0&&i.push("?",n.query),n.fragment!==void 0&&i.push("#",n.fragment),i.join("")}var WX=Array.from({length:127},(t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function zX(t){let e=0;for(let n=0,r=t.length;n<r;++n)if(e=t.charCodeAt(n),e>126||WX[e])return!0;return!1}var GX=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Xi(t,e){let n=Object.assign({},e),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=t.indexOf("%")!==-1,s=!1;n.reference==="suffix"&&(t=(n.scheme?n.scheme+":":"")+"//"+t);let o=t.match(GX);if(o){if(r.scheme=o[1],r.userinfo=o[3],r.host=o[4],r.port=parseInt(o[5],10),r.path=o[6]||"",r.query=o[7],r.fragment=o[8],isNaN(r.port)&&(r.port=o[5]),r.host){let c=BX(r.host);if(c.isIPV4===!1){let l=FX(c.host);r.host=l.host.toLowerCase(),s=l.isIPV6}else r.host=c.host,s=!0}r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path?r.reference="same-document":r.scheme===void 0?r.reference="relative":r.fragment===void 0?r.reference="absolute":r.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");let a=F_[(n.scheme||r.scheme||"").toLowerCase()];if(!n.unicodeSupport&&(!a||!a.unicodeSupport)&&r.host&&(n.domainHost||a&&a.domainHost)&&s===!1&&zX(r.host))try{r.host=URL.domainToASCII(r.host.toLowerCase())}catch(c){r.error=r.error||"Host's domain name can not be converted to ASCII: "+c}(!a||a&&!a.skipNormalize)&&(i&&r.scheme!==void 0&&(r.scheme=unescape(r.scheme)),i&&r.host!==void 0&&(r.host=unescape(r.host)),r.path&&(r.path=escape(unescape(r.path))),r.fragment&&(r.fragment=encodeURI(decodeURIComponent(r.fragment)))),a&&a.parse&&a.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return r}var B_={SCHEMES:F_,normalize:UX,resolve:HX,resolveComponents:Eq,equal:VX,serialize:wi,parse:Xi};xm.exports=B_;xm.exports.default=B_;xm.exports.fastUri=B_});var Aq=N(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var Dq=Cq();Dq.code='require("ajv/dist/runtime/uri").default';j_.default=Dq});var Fq=N(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.CodeGen=fn.Name=fn.nil=fn.stringify=fn.str=fn._=fn.KeywordCxt=void 0;var KX=Su();Object.defineProperty(fn,"KeywordCxt",{enumerable:!0,get:function(){return KX.KeywordCxt}});var ac=be();Object.defineProperty(fn,"_",{enumerable:!0,get:function(){return ac._}});Object.defineProperty(fn,"str",{enumerable:!0,get:function(){return ac.str}});Object.defineProperty(fn,"stringify",{enumerable:!0,get:function(){return ac.stringify}});Object.defineProperty(fn,"nil",{enumerable:!0,get:function(){return ac.nil}});Object.defineProperty(fn,"Name",{enumerable:!0,get:function(){return ac.Name}});Object.defineProperty(fn,"CodeGen",{enumerable:!0,get:function(){return ac.CodeGen}});var YX=Am(),Lq=ku(),XX=y_(),Ru=Pu(),JX=be(),wu=vu(),Lm=Tu(),H_=Ne(),Iq=dq(),QX=Aq(),qq=(t,e)=>new RegExp(t,e);qq.code="new RegExp";var ZX=["removeAdditional","useDefaults","coerceTypes"],e4=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),t4={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},n4={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Oq=200;function r4(t){var e,n,r,i,s,o,a,c,l,u,d,f,p,m,h,y,_,v,b,P,E,H,O,B,Ae;let lt=t.strict,Gt=(e=t.code)===null||e===void 0?void 0:e.optimize,Re=Gt===!0||Gt===void 0?1:Gt||0,pr=(r=(n=t.code)===null||n===void 0?void 0:n.regExp)!==null&&r!==void 0?r:qq,Ji=(i=t.uriResolver)!==null&&i!==void 0?i:QX.default;return{strictSchema:(o=(s=t.strictSchema)!==null&&s!==void 0?s:lt)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:lt)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:lt)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:lt)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:lt)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:Re,regExp:pr}:{optimize:Re,regExp:pr},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:Oq,loopEnum:(y=t.loopEnum)!==null&&y!==void 0?y:Oq,meta:(_=t.meta)!==null&&_!==void 0?_:!0,messages:(v=t.messages)!==null&&v!==void 0?v:!0,inlineRefs:(b=t.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(P=t.schemaId)!==null&&P!==void 0?P:"$id",addUsedSchema:(E=t.addUsedSchema)!==null&&E!==void 0?E:!0,validateSchema:(H=t.validateSchema)!==null&&H!==void 0?H:!0,validateFormats:(O=t.validateFormats)!==null&&O!==void 0?O:!0,unicodeRegExp:(B=t.unicodeRegExp)!==null&&B!==void 0?B:!0,int32range:(Ae=t.int32range)!==null&&Ae!==void 0?Ae:!0,uriResolver:Ji}}var Eu=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...r4(e)};let{es5:n,lines:r}=this.opts.code;this.scope=new JX.ValueScope({scope:{},prefixes:e4,es5:n,lines:r}),this.logger=l4(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,XX.getRules)(),Mq.call(this,t4,e,"NOT SUPPORTED"),Mq.call(this,n4,e,"DEPRECATED","warn"),this._metaOpts=a4.call(this),e.formats&&s4.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&o4.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),i4.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:n,schemaId:r}=this.opts,i=Iq;r==="id"&&(i={...Iq},i.id=i.$id,delete i.$id),n&&e&&this.addMetaSchema(i,i[r],!1)}defaultMeta(){let{meta:e,schemaId:n}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[n]||e:void 0}validate(e,n){let r;if(typeof e=="string"){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);let i=r(n);return"$async"in r||(this.errors=r.errors),i}compile(e,n){let r=this._addSchema(e,n);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,n){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:r}=this.opts;return i.call(this,e,n);async function i(u,d){await s.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||o.call(this,f)}async function s(u){u&&!this.getSchema(u)&&await i.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof Lq.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),o.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await s.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,n)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=r(u))}finally{delete this._loading[u]}}}addSchema(e,n,r,i=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,r,i);return this}let s;if(typeof e=="object"){let{schemaId:o}=this.opts;if(s=e[o],s!==void 0&&typeof s!="string")throw new Error(`schema ${o} must be string`)}return n=(0,wu.normalizeId)(n||s),this._checkUnique(n),this.schemas[n]=this._addSchema(e,r,n,i,!0),this}addMetaSchema(e,n,r=this.opts.validateSchema){return this.addSchema(e,n,!0,r),this}validateSchema(e,n){if(typeof e=="boolean")return!0;let r;if(r=e.$schema,r!==void 0&&typeof r!="string")throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(r,e);if(!i&&n){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return i}getSchema(e){let n;for(;typeof(n=xq.call(this,e))=="string";)e=n;if(n===void 0){let{schemaId:r}=this.opts,i=new Ru.SchemaEnv({schema:{},schemaId:r});if(n=Ru.resolveSchema.call(this,i,e),!n)return;this.refs[e]=n}return n.validate||this._compileSchemaEnv(n)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let n=xq.call(this,e);return typeof n=="object"&&this._cache.delete(n.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let n=e;this._cache.delete(n);let r=e[this.opts.schemaId];return r&&(r=(0,wu.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let n of e)this.addKeyword(n);return this}addKeyword(e,n){let r;if(typeof e=="string")r=e,typeof n=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),n.keyword=r);else if(typeof e=="object"&&n===void 0){if(n=e,r=n.keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(d4.call(this,r,n),!n)return(0,H_.eachItem)(r,s=>U_.call(this,s)),this;p4.call(this,n);let i={...n,type:(0,Lm.getJSONTypes)(n.type),schemaType:(0,Lm.getJSONTypes)(n.schemaType)};return(0,H_.eachItem)(r,i.type.length===0?s=>U_.call(this,s,i):s=>i.type.forEach(o=>U_.call(this,s,i,o))),this}getKeyword(e){let n=this.RULES.all[e];return typeof n=="object"?n.definition:!!n}removeKeyword(e){let{RULES:n}=this;delete n.keywords[e],delete n.all[e];for(let r of n.rules){let i=r.rules.findIndex(s=>s.keyword===e);i>=0&&r.rules.splice(i,1)}return this}addFormat(e,n){return typeof n=="string"&&(n=new RegExp(n)),this.formats[e]=n,this}errorsText(e=this.errors,{separator:n=", ",dataVar:r="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${r}${i.instancePath} ${i.message}`).reduce((i,s)=>i+n+s)}$dataMetaSchema(e,n){let r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of n){let s=i.split("/").slice(1),o=e;for(let a of s)o=o[a];for(let a in r){let c=r[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=o[a];l&&u&&(o[a]=$q(u))}}return e}_removeAllSchemas(e,n){for(let r in e){let i=e[r];(!n||n.test(r))&&(typeof i=="string"?delete e[r]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[r]))}}_addSchema(e,n,r,i=this.opts.validateSchema,s=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;r=(0,wu.normalizeId)(o||r);let l=wu.getSchemaRefs.call(this,e,r);return c=new Ru.SchemaEnv({schema:e,schemaId:a,meta:n,baseId:r,localRefs:l}),this._cache.set(c.schema,c),s&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=c),i&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Ru.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let n=this.opts;this.opts=this._metaOpts;try{Ru.compileSchema.call(this,e)}finally{this.opts=n}}};Eu.ValidationError=YX.default;Eu.MissingRefError=Lq.default;fn.default=Eu;function Mq(t,e,n,r="error"){for(let i in t){let s=i;s in e&&this.logger[r](`${n}: option ${i}. ${t[s]}`)}}function xq(t){return t=(0,wu.normalizeId)(t),this.schemas[t]||this.refs[t]}function i4(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function s4(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function o4(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let n=t[e];n.keyword||(n.keyword=e),this.addKeyword(n)}}function a4(){let t={...this.opts};for(let e of ZX)delete t[e];return t}var c4={log(){},warn(){},error(){}};function l4(t){if(t===!1)return c4;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var u4=/^[a-z_$][a-z0-9_$:-]*$/i;function d4(t,e){let{RULES:n}=this;if((0,H_.eachItem)(t,r=>{if(n.keywords[r])throw new Error(`Keyword ${r} is already defined`);if(!u4.test(r))throw new Error(`Keyword ${r} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function U_(t,e,n){var r;let i=e?.post;if(n&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,o=i?s.post:s.rules.find(({type:c})=>c===n);if(o||(o={type:n,rules:[]},s.rules.push(o)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Lm.getJSONTypes)(e.type),schemaType:(0,Lm.getJSONTypes)(e.schemaType)}};e.before?f4.call(this,o,a,e.before):o.rules.push(a),s.all[t]=a,(r=e.implements)===null||r===void 0||r.forEach(c=>this.addKeyword(c))}function f4(t,e,n){let r=t.rules.findIndex(i=>i.keyword===n);r>=0?t.rules.splice(r,0,e):(t.rules.push(e),this.logger.warn(`rule ${n} is not defined`))}function p4(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=$q(e)),t.validateSchema=this.compile(e,!0))}var h4={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function $q(t){return{anyOf:[t,h4]}}});var Bq=N(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var m4={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};V_.default=m4});var Fm=N(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.callRef=Oo.getValidate=void 0;var g4=ku(),jq=Or(),nr=be(),cc=Ir(),Uq=Pu(),qm=Ne(),y4={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:n,it:r}=t,{baseId:i,schemaEnv:s,validateName:o,opts:a,self:c}=r,{root:l}=s;if((n==="#"||n==="#/")&&i===l.baseId)return d();let u=Uq.resolveRef.call(c,l,i,n);if(u===void 0)throw new g4.default(r.opts.uriResolver,i,n);if(u instanceof Uq.SchemaEnv)return f(u);return p(u);function d(){if(s===l)return $m(t,o,s,s.$async);let m=e.scopeValue("root",{ref:l});return $m(t,(0,nr._)`${m}.validate`,l,l.$async)}function f(m){let h=Hq(t,m);$m(t,h,m,m.$async)}function p(m){let h=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,nr.stringify)(m)}:{ref:m}),y=e.name("valid"),_=t.subschema({schema:m,dataTypes:[],schemaPath:nr.nil,topSchemaRef:h,errSchemaPath:n},y);t.mergeEvaluated(_),t.ok(y)}}};function Hq(t,e){let{gen:n}=t;return e.validate?n.scopeValue("validate",{ref:e.validate}):(0,nr._)`${n.scopeValue("wrapper",{ref:e})}.validate`}Oo.getValidate=Hq;function $m(t,e,n,r){let{gen:i,it:s}=t,{allErrors:o,schemaEnv:a,opts:c}=s,l=c.passContext?cc.default.this:nr.nil;r?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=i.let("valid");i.try(()=>{i.code((0,nr._)`await ${(0,jq.callValidateCode)(t,e,l)}`),p(e),o||i.assign(m,!0)},h=>{i.if((0,nr._)`!(${h} instanceof ${s.ValidationError})`,()=>i.throw(h)),f(h),o||i.assign(m,!1)}),t.ok(m)}function d(){t.result((0,jq.callValidateCode)(t,e,l),()=>p(e),()=>f(e))}function f(m){let h=(0,nr._)`${m}.errors`;i.assign(cc.default.vErrors,(0,nr._)`${cc.default.vErrors} === null ? ${h} : ${cc.default.vErrors}.concat(${h})`),i.assign(cc.default.errors,(0,nr._)`${cc.default.vErrors}.length`)}function p(m){var h;if(!s.opts.unevaluated)return;let y=(h=n?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=qm.mergeEvaluated.props(i,y.props,s.props));else{let _=i.var("props",(0,nr._)`${m}.evaluated.props`);s.props=qm.mergeEvaluated.props(i,_,s.props,nr.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=qm.mergeEvaluated.items(i,y.items,s.items));else{let _=i.var("items",(0,nr._)`${m}.evaluated.items`);s.items=qm.mergeEvaluated.items(i,_,s.items,nr.Name)}}}Oo.callRef=$m;Oo.default=y4});var Vq=N(W_=>{"use strict";Object.defineProperty(W_,"__esModule",{value:!0});var T4=Bq(),v4=Fm(),b4=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",T4.default,v4.default];W_.default=b4});var Wq=N(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});var Bm=be(),$s=Bm.operators,jm={maximum:{okStr:"<=",ok:$s.LTE,fail:$s.GT},minimum:{okStr:">=",ok:$s.GTE,fail:$s.LT},exclusiveMaximum:{okStr:"<",ok:$s.LT,fail:$s.GTE},exclusiveMinimum:{okStr:">",ok:$s.GT,fail:$s.LTE}},_4={message:({keyword:t,schemaCode:e})=>(0,Bm.str)`must be ${jm[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Bm._)`{comparison: ${jm[t].okStr}, limit: ${e}}`},S4={keyword:Object.keys(jm),type:"number",schemaType:"number",$data:!0,error:_4,code(t){let{keyword:e,data:n,schemaCode:r}=t;t.fail$data((0,Bm._)`${n} ${jm[e].fail} ${r} || isNaN(${n})`)}};z_.default=S4});var zq=N(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});var Cu=be(),k4={message:({schemaCode:t})=>(0,Cu.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Cu._)`{multipleOf: ${t}}`},P4={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:k4,code(t){let{gen:e,data:n,schemaCode:r,it:i}=t,s=i.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,Cu._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,Cu._)`${o} !== parseInt(${o})`;t.fail$data((0,Cu._)`(${r} === 0 || (${o} = ${n}/${r}, ${a}))`)}};G_.default=P4});var Kq=N(K_=>{"use strict";Object.defineProperty(K_,"__esModule",{value:!0});function Gq(t){let e=t.length,n=0,r=0,i;for(;r<e;)n++,i=t.charCodeAt(r++),i>=55296&&i<=56319&&r<e&&(i=t.charCodeAt(r),(i&64512)===56320&&r++);return n}K_.default=Gq;Gq.code='require("ajv/dist/runtime/ucs2length").default'});var Yq=N(Y_=>{"use strict";Object.defineProperty(Y_,"__esModule",{value:!0});var Mo=be(),N4=Ne(),R4=Kq(),w4={message({keyword:t,schemaCode:e}){let n=t==="maxLength"?"more":"fewer";return(0,Mo.str)`must NOT have ${n} than ${e} characters`},params:({schemaCode:t})=>(0,Mo._)`{limit: ${t}}`},E4={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:w4,code(t){let{keyword:e,data:n,schemaCode:r,it:i}=t,s=e==="maxLength"?Mo.operators.GT:Mo.operators.LT,o=i.opts.unicode===!1?(0,Mo._)`${n}.length`:(0,Mo._)`${(0,N4.useFunc)(t.gen,R4.default)}(${n})`;t.fail$data((0,Mo._)`${o} ${s} ${r}`)}};Y_.default=E4});var Xq=N(X_=>{"use strict";Object.defineProperty(X_,"__esModule",{value:!0});var C4=Or(),D4=Ne(),lc=be(),A4={message:({schemaCode:t})=>(0,lc.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,lc._)`{pattern: ${t}}`},I4={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:A4,code(t){let{gen:e,data:n,$data:r,schema:i,schemaCode:s,it:o}=t,a=o.opts.unicodeRegExp?"u":"";if(r){let{regExp:c}=o.opts.code,l=c.code==="new RegExp"?(0,lc._)`new RegExp`:(0,D4.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,lc._)`${l}(${s}, ${a}).test(${n})`),()=>e.assign(u,!1)),t.fail$data((0,lc._)`!${u}`)}else{let c=(0,C4.usePattern)(t,i);t.fail$data((0,lc._)`!${c}.test(${n})`)}}};X_.default=I4});var Jq=N(J_=>{"use strict";Object.defineProperty(J_,"__esModule",{value:!0});var Du=be(),O4={message({keyword:t,schemaCode:e}){let n=t==="maxProperties"?"more":"fewer";return(0,Du.str)`must NOT have ${n} than ${e} properties`},params:({schemaCode:t})=>(0,Du._)`{limit: ${t}}`},M4={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:O4,code(t){let{keyword:e,data:n,schemaCode:r}=t,i=e==="maxProperties"?Du.operators.GT:Du.operators.LT;t.fail$data((0,Du._)`Object.keys(${n}).length ${i} ${r}`)}};J_.default=M4});var Qq=N(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});var Au=Or(),Iu=be(),x4=Ne(),L4={message:({params:{missingProperty:t}})=>(0,Iu.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Iu._)`{missingProperty: ${t}}`},q4={keyword:"required",type:"object",schemaType:"array",$data:!0,error:L4,code(t){let{gen:e,schema:n,schemaCode:r,data:i,$data:s,it:o}=t,{opts:a}=o;if(!s&&n.length===0)return;let c=n.length>=a.loopRequired;if(o.allErrors?l():u(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:m}=t.it;for(let h of n)if(p?.[h]===void 0&&!m.has(h)){let y=o.schemaEnv.baseId+o.errSchemaPath,_=`required property "${h}" is not defined at "${y}" (strictRequired)`;(0,x4.checkStrictMode)(o,_,o.opts.strictRequired)}}function l(){if(c||s)t.block$data(Iu.nil,d);else for(let p of n)(0,Au.checkReportMissingProp)(t,p)}function u(){let p=e.let("missing");if(c||s){let m=e.let("valid",!0);t.block$data(m,()=>f(p,m)),t.ok(m)}else e.if((0,Au.checkMissingProp)(t,n,p)),(0,Au.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",r,p=>{t.setParams({missingProperty:p}),e.if((0,Au.noPropertyInData)(e,i,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,r,()=>{e.assign(m,(0,Au.propertyInData)(e,i,p,a.ownProperties)),e.if((0,Iu.not)(m),()=>{t.error(),e.break()})},Iu.nil)}}};Q_.default=q4});var Zq=N(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});var Ou=be(),$4={message({keyword:t,schemaCode:e}){let n=t==="maxItems"?"more":"fewer";return(0,Ou.str)`must NOT have ${n} than ${e} items`},params:({schemaCode:t})=>(0,Ou._)`{limit: ${t}}`},F4={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:$4,code(t){let{keyword:e,data:n,schemaCode:r}=t,i=e==="maxItems"?Ou.operators.GT:Ou.operators.LT;t.fail$data((0,Ou._)`${n}.length ${i} ${r}`)}};Z_.default=F4});var Um=N(eS=>{"use strict";Object.defineProperty(eS,"__esModule",{value:!0});var e$=N_();e$.code='require("ajv/dist/runtime/equal").default';eS.default=e$});var t$=N(nS=>{"use strict";Object.defineProperty(nS,"__esModule",{value:!0});var tS=Tu(),pn=be(),B4=Ne(),j4=Um(),U4={message:({params:{i:t,j:e}})=>(0,pn.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,pn._)`{i: ${t}, j: ${e}}`},H4={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:U4,code(t){let{gen:e,data:n,$data:r,schema:i,parentSchema:s,schemaCode:o,it:a}=t;if(!r&&!i)return;let c=e.let("valid"),l=s.items?(0,tS.getSchemaTypes)(s.items):[];t.block$data(c,u,(0,pn._)`${o} === false`),t.ok(c);function u(){let m=e.let("i",(0,pn._)`${n}.length`),h=e.let("j");t.setParams({i:m,j:h}),e.assign(c,!0),e.if((0,pn._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function f(m,h){let y=e.name("item"),_=(0,tS.checkDataTypes)(l,y,a.opts.strictNumbers,tS.DataType.Wrong),v=e.const("indices",(0,pn._)`{}`);e.for((0,pn._)`;${m}--;`,()=>{e.let(y,(0,pn._)`${n}[${m}]`),e.if(_,(0,pn._)`continue`),l.length>1&&e.if((0,pn._)`typeof ${y} == "string"`,(0,pn._)`${y} += "_"`),e.if((0,pn._)`typeof ${v}[${y}] == "number"`,()=>{e.assign(h,(0,pn._)`${v}[${y}]`),t.error(),e.assign(c,!1).break()}).code((0,pn._)`${v}[${y}] = ${m}`)})}function p(m,h){let y=(0,B4.useFunc)(e,j4.default),_=e.name("outer");e.label(_).for((0,pn._)`;${m}--;`,()=>e.for((0,pn._)`${h} = ${m}; ${h}--;`,()=>e.if((0,pn._)`${y}(${n}[${m}], ${n}[${h}])`,()=>{t.error(),e.assign(c,!1).break(_)})))}}};nS.default=H4});var n$=N(iS=>{"use strict";Object.defineProperty(iS,"__esModule",{value:!0});var rS=be(),V4=Ne(),W4=Um(),z4={message:"must be equal to constant",params:({schemaCode:t})=>(0,rS._)`{allowedValue: ${t}}`},G4={keyword:"const",$data:!0,error:z4,code(t){let{gen:e,data:n,$data:r,schemaCode:i,schema:s}=t;r||s&&typeof s=="object"?t.fail$data((0,rS._)`!${(0,V4.useFunc)(e,W4.default)}(${n}, ${i})`):t.fail((0,rS._)`${s} !== ${n}`)}};iS.default=G4});var r$=N(sS=>{"use strict";Object.defineProperty(sS,"__esModule",{value:!0});var Mu=be(),K4=Ne(),Y4=Um(),X4={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Mu._)`{allowedValues: ${t}}`},J4={keyword:"enum",schemaType:"array",$data:!0,error:X4,code(t){let{gen:e,data:n,$data:r,schema:i,schemaCode:s,it:o}=t;if(!r&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=o.opts.loopEnum,c,l=()=>c??(c=(0,K4.useFunc)(e,Y4.default)),u;if(a||r)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let p=e.const("vSchema",s);u=(0,Mu.or)(...i.map((m,h)=>f(p,h)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",s,p=>e.if((0,Mu._)`${l()}(${n}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,m){let h=i[m];return typeof h=="object"&&h!==null?(0,Mu._)`${l()}(${n}, ${p}[${m}])`:(0,Mu._)`${n} === ${h}`}}};sS.default=J4});var i$=N(oS=>{"use strict";Object.defineProperty(oS,"__esModule",{value:!0});var Q4=Wq(),Z4=zq(),e9=Yq(),t9=Xq(),n9=Jq(),r9=Qq(),i9=Zq(),s9=t$(),o9=n$(),a9=r$(),c9=[Q4.default,Z4.default,e9.default,t9.default,n9.default,r9.default,i9.default,s9.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},o9.default,a9.default];oS.default=c9});var cS=N(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});xu.validateAdditionalItems=void 0;var xo=be(),aS=Ne(),l9={message:({params:{len:t}})=>(0,xo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,xo._)`{limit: ${t}}`},u9={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:l9,code(t){let{parentSchema:e,it:n}=t,{items:r}=e;if(!Array.isArray(r)){(0,aS.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}s$(t,r)}};function s$(t,e){let{gen:n,schema:r,data:i,keyword:s,it:o}=t;o.items=!0;let a=n.const("len",(0,xo._)`${i}.length`);if(r===!1)t.setParams({len:e.length}),t.pass((0,xo._)`${a} <= ${e.length}`);else if(typeof r=="object"&&!(0,aS.alwaysValidSchema)(o,r)){let l=n.var("valid",(0,xo._)`${a} <= ${e.length}`);n.if((0,xo.not)(l),()=>c(l)),t.ok(l)}function c(l){n.forRange("i",e.length,a,u=>{t.subschema({keyword:s,dataProp:u,dataPropType:aS.Type.Num},l),o.allErrors||n.if((0,xo.not)(l),()=>n.break())})}}xu.validateAdditionalItems=s$;xu.default=u9});var lS=N(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.validateTuple=void 0;var o$=be(),Hm=Ne(),d9=Or(),f9={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:n}=t;if(Array.isArray(e))return a$(t,"additionalItems",e);n.items=!0,!(0,Hm.alwaysValidSchema)(n,e)&&t.ok((0,d9.validateArray)(t))}};function a$(t,e,n=t.schema){let{gen:r,parentSchema:i,data:s,keyword:o,it:a}=t;u(i),a.opts.unevaluated&&n.length&&a.items!==!0&&(a.items=Hm.mergeEvaluated.items(r,n.length,a.items));let c=r.name("valid"),l=r.const("len",(0,o$._)`${s}.length`);n.forEach((d,f)=>{(0,Hm.alwaysValidSchema)(a,d)||(r.if((0,o$._)`${l} > ${f}`,()=>t.subschema({keyword:o,schemaProp:f,dataProp:f},c)),t.ok(c))});function u(d){let{opts:f,errSchemaPath:p}=a,m=n.length,h=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let y=`"${o}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,Hm.checkStrictMode)(a,y,f.strictTuples)}}}Lu.validateTuple=a$;Lu.default=f9});var c$=N(uS=>{"use strict";Object.defineProperty(uS,"__esModule",{value:!0});var p9=lS(),h9={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,p9.validateTuple)(t,"items")};uS.default=h9});var u$=N(dS=>{"use strict";Object.defineProperty(dS,"__esModule",{value:!0});var l$=be(),m9=Ne(),g9=Or(),y9=cS(),T9={message:({params:{len:t}})=>(0,l$.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,l$._)`{limit: ${t}}`},v9={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:T9,code(t){let{schema:e,parentSchema:n,it:r}=t,{prefixItems:i}=n;r.items=!0,!(0,m9.alwaysValidSchema)(r,e)&&(i?(0,y9.validateAdditionalItems)(t,i):t.ok((0,g9.validateArray)(t)))}};dS.default=v9});var d$=N(fS=>{"use strict";Object.defineProperty(fS,"__esModule",{value:!0});var xr=be(),Vm=Ne(),b9={message:({params:{min:t,max:e}})=>e===void 0?(0,xr.str)`must contain at least ${t} valid item(s)`:(0,xr.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,xr._)`{minContains: ${t}}`:(0,xr._)`{minContains: ${t}, maxContains: ${e}}`},_9={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:b9,code(t){let{gen:e,schema:n,parentSchema:r,data:i,it:s}=t,o,a,{minContains:c,maxContains:l}=r;s.opts.next?(o=c===void 0?1:c,a=l):o=1;let u=e.const("len",(0,xr._)`${i}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,Vm.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,Vm.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Vm.alwaysValidSchema)(s,n)){let h=(0,xr._)`${u} >= ${o}`;a!==void 0&&(h=(0,xr._)`${h} && ${u} <= ${a}`),t.pass(h);return}s.items=!0;let d=e.name("valid");a===void 0&&o===1?p(d,()=>e.if(d,()=>e.break())):o===0?(e.let(d,!0),a!==void 0&&e.if((0,xr._)`${i}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),y=e.let("count",0);p(h,()=>e.if(h,()=>m(y)))}function p(h,y){e.forRange("i",0,u,_=>{t.subschema({keyword:"contains",dataProp:_,dataPropType:Vm.Type.Num,compositeRule:!0},h),y()})}function m(h){e.code((0,xr._)`${h}++`),a===void 0?e.if((0,xr._)`${h} >= ${o}`,()=>e.assign(d,!0).break()):(e.if((0,xr._)`${h} > ${a}`,()=>e.assign(d,!1).break()),o===1?e.assign(d,!0):e.if((0,xr._)`${h} >= ${o}`,()=>e.assign(d,!0)))}}};fS.default=_9});var Wm=N(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.validateSchemaDeps=Ei.validatePropertyDeps=Ei.error=void 0;var pS=be(),S9=Ne(),qu=Or();Ei.error={message:({params:{property:t,depsCount:e,deps:n}})=>{let r=e===1?"property":"properties";return(0,pS.str)`must have ${r} ${n} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:n,missingProperty:r}})=>(0,pS._)`{property: ${t},
180
180
  missingProperty: ${r},
181
181
  depsCount: ${e},
182
- deps: ${n}}`};var k9={keyword:"dependencies",type:"object",schemaType:"object",error:Ei.error,code(t){let[e,n]=P9(t);f$(t,e),p$(t,n)}};function P9({schema:t}){let e={},n={};for(let r in t){if(r==="__proto__")continue;let i=Array.isArray(t[r])?e:n;i[r]=t[r]}return[e,n]}function f$(t,e=t.schema){let{gen:n,data:r,it:i}=t;if(Object.keys(e).length===0)return;let s=n.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,qu.propertyInData)(n,r,o,i.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors?n.if(c,()=>{for(let l of a)(0,qu.checkReportMissingProp)(t,l)}):(n.if((0,pS._)`${c} && (${(0,qu.checkMissingProp)(t,a,s)})`),(0,qu.reportMissingProp)(t,s),n.else())}}Ei.validatePropertyDeps=f$;function p$(t,e=t.schema){let{gen:n,data:r,keyword:i,it:s}=t,o=n.name("valid");for(let a in e)(0,S9.alwaysValidSchema)(s,e[a])||(n.if((0,qu.propertyInData)(n,r,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>n.var(o,!0)),t.ok(o))}Ei.validateSchemaDeps=p$;Ei.default=k9});var m$=N(hS=>{"use strict";Object.defineProperty(hS,"__esModule",{value:!0});var h$=be(),N9=Ne(),R9={message:"property name must be valid",params:({params:t})=>(0,h$._)`{propertyName: ${t.propertyName}}`},w9={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:R9,code(t){let{gen:e,schema:n,data:r,it:i}=t;if((0,N9.alwaysValidSchema)(i,n))return;let s=e.name("valid");e.forIn("key",r,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,h$.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};hS.default=w9});var gS=N(mS=>{"use strict";Object.defineProperty(mS,"__esModule",{value:!0});var zm=Or(),ci=be(),E9=Ir(),Gm=Ne(),C9={message:"must NOT have additional properties",params:({params:t})=>(0,ci._)`{additionalProperty: ${t.additionalProperty}}`},D9={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:C9,code(t){let{gen:e,schema:n,parentSchema:r,data:i,errsCount:s,it:o}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,Gm.alwaysValidSchema)(o,n))return;let l=(0,zm.allSchemaProperties)(r.properties),u=(0,zm.allSchemaProperties)(r.patternProperties);d(),t.ok((0,ci._)`${s} === ${E9.default.errors}`);function d(){e.forIn("key",i,y=>{!l.length&&!u.length?m(y):e.if(f(y),()=>m(y))})}function f(y){let _;if(l.length>8){let v=(0,Gm.schemaRefOrVal)(o,r.properties,"properties");_=(0,zm.isOwnProperty)(e,v,y)}else l.length?_=(0,ci.or)(...l.map(v=>(0,ci._)`${y} === ${v}`)):_=ci.nil;return u.length&&(_=(0,ci.or)(_,...u.map(v=>(0,ci._)`${(0,zm.usePattern)(t,v)}.test(${y})`))),(0,ci.not)(_)}function p(y){e.code((0,ci._)`delete ${i}[${y}]`)}function m(y){if(c.removeAdditional==="all"||c.removeAdditional&&n===!1){p(y);return}if(n===!1){t.setParams({additionalProperty:y}),t.error(),a||e.break();return}if(typeof n=="object"&&!(0,Gm.alwaysValidSchema)(o,n)){let _=e.name("valid");c.removeAdditional==="failing"?(h(y,_,!1),e.if((0,ci.not)(_),()=>{t.reset(),p(y)})):(h(y,_),a||e.if((0,ci.not)(_),()=>e.break()))}}function h(y,_,v){let b={keyword:"additionalProperties",dataProp:y,dataPropType:Gm.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,_)}}};mS.default=D9});var T$=N(TS=>{"use strict";Object.defineProperty(TS,"__esModule",{value:!0});var A9=Su(),g$=Or(),yS=Ne(),y$=gS(),I9={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:n,parentSchema:r,data:i,it:s}=t;s.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&y$.default.code(new A9.KeywordCxt(s,y$.default,"additionalProperties"));let o=(0,g$.allSchemaProperties)(n);for(let d of o)s.definedProperties.add(d);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=yS.mergeEvaluated.props(e,(0,yS.toHash)(o),s.props));let a=o.filter(d=>!(0,yS.alwaysValidSchema)(s,n[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,g$.propertyInData)(e,i,d,s.opts.ownProperties)),u(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return s.opts.useDefaults&&!s.compositeRule&&n[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};TS.default=I9});var S$=N(vS=>{"use strict";Object.defineProperty(vS,"__esModule",{value:!0});var v$=Or(),Km=be(),b$=Ne(),_$=Ne(),O9={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:n,data:r,parentSchema:i,it:s}=t,{opts:o}=s,a=(0,v$.allSchemaProperties)(n),c=a.filter(h=>(0,b$.alwaysValidSchema)(s,n[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&i.properties,u=e.name("valid");s.props!==!0&&!(s.props instanceof Km.Name)&&(s.props=(0,_$.evaluatedPropsToName)(e,s.props));let{props:d}=s;f();function f(){for(let h of a)l&&p(h),s.allErrors?m(h):(e.var(u,!0),m(h),e.if(u))}function p(h){for(let y in l)new RegExp(h).test(y)&&(0,b$.checkStrictMode)(s,`property ${y} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",r,y=>{e.if((0,Km._)`${(0,v$.usePattern)(t,h)}.test(${y})`,()=>{let _=c.includes(h);_||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:y,dataPropType:_$.Type.Str},u),s.opts.unevaluated&&d!==!0?e.assign((0,Km._)`${d}[${y}]`,!0):!_&&!s.allErrors&&e.if((0,Km.not)(u),()=>e.break())})})}}};vS.default=O9});var k$=N(bS=>{"use strict";Object.defineProperty(bS,"__esModule",{value:!0});var M9=Ne(),x9={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:n,it:r}=t;if((0,M9.alwaysValidSchema)(r,n)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};bS.default=x9});var P$=N(_S=>{"use strict";Object.defineProperty(_S,"__esModule",{value:!0});var L9=Or(),q9={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:L9.validateUnion,error:{message:"must match a schema in anyOf"}};_S.default=q9});var N$=N(SS=>{"use strict";Object.defineProperty(SS,"__esModule",{value:!0});var Ym=be(),$9=Ne(),F9={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ym._)`{passingSchemas: ${t.passing}}`},B9={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:F9,code(t){let{gen:e,schema:n,parentSchema:r,it:i}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(i.opts.discriminator&&r.discriminator)return;let s=n,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(o,()=>t.reset(),()=>t.error(!0));function l(){s.forEach((u,d)=>{let f;(0,$9.alwaysValidSchema)(i,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Ym._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Ym._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Ym.Name)})})}}};SS.default=B9});var R$=N(kS=>{"use strict";Object.defineProperty(kS,"__esModule",{value:!0});var j9=Ne(),U9={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:n,it:r}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");let i=e.name("valid");n.forEach((s,o)=>{if((0,j9.alwaysValidSchema)(r,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};kS.default=U9});var C$=N(PS=>{"use strict";Object.defineProperty(PS,"__esModule",{value:!0});var Xm=be(),E$=Ne(),H9={message:({params:t})=>(0,Xm.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Xm._)`{failingKeyword: ${t.ifClause}}`},V9={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:H9,code(t){let{gen:e,parentSchema:n,it:r}=t;n.then===void 0&&n.else===void 0&&(0,E$.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let i=w$(r,"then"),s=w$(r,"else");if(!i&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),i&&s){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else i?e.if(a,l("then")):e.if((0,Xm.not)(a),l("else"));t.pass(o,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(o,a),t.mergeValidEvaluated(f,o),d?e.assign(d,(0,Xm._)`${u}`):t.setParams({ifClause:u})}}}};function w$(t,e){let n=t.schema[e];return n!==void 0&&!(0,E$.alwaysValidSchema)(t,n)}PS.default=V9});var D$=N(NS=>{"use strict";Object.defineProperty(NS,"__esModule",{value:!0});var W9=Ne(),z9={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){e.if===void 0&&(0,W9.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};NS.default=z9});var A$=N(RS=>{"use strict";Object.defineProperty(RS,"__esModule",{value:!0});var G9=cS(),K9=c$(),Y9=lS(),X9=u$(),J9=d$(),Q9=Wm(),Z9=m$(),eJ=gS(),tJ=T$(),nJ=S$(),rJ=k$(),iJ=P$(),sJ=N$(),oJ=R$(),aJ=C$(),cJ=D$();function lJ(t=!1){let e=[rJ.default,iJ.default,sJ.default,oJ.default,aJ.default,cJ.default,Z9.default,eJ.default,Q9.default,tJ.default,nJ.default];return t?e.push(K9.default,X9.default):e.push(G9.default,Y9.default),e.push(J9.default),e}RS.default=lJ});var I$=N(wS=>{"use strict";Object.defineProperty(wS,"__esModule",{value:!0});var Ft=be(),uJ={message:({schemaCode:t})=>(0,Ft.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ft._)`{format: ${t}}`},dJ={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:uJ,code(t,e){let{gen:n,data:r,$data:i,schema:s,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;i?f():p();function f(){let m=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=n.const("fDef",(0,Ft._)`${m}[${o}]`),y=n.let("fType"),_=n.let("format");n.if((0,Ft._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>n.assign(y,(0,Ft._)`${h}.type || "string"`).assign(_,(0,Ft._)`${h}.validate`),()=>n.assign(y,(0,Ft._)`"string"`).assign(_,h)),t.fail$data((0,Ft.or)(v(),b()));function v(){return c.strictSchema===!1?Ft.nil:(0,Ft._)`${o} && !${_}`}function b(){let P=u.$async?(0,Ft._)`(${h}.async ? await ${_}(${r}) : ${_}(${r}))`:(0,Ft._)`${_}(${r})`,E=(0,Ft._)`(typeof ${_} == "function" ? ${P} : ${_}.test(${r}))`;return(0,Ft._)`${_} && ${_} !== true && ${y} === ${e} && !${E}`}}function p(){let m=d.formats[s];if(!m){v();return}if(m===!0)return;let[h,y,_]=b(m);h===e&&t.pass(P());function v(){if(c.strictSchema===!1){d.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function b(E){let H=E instanceof RegExp?(0,Ft.regexpCode)(E):c.code.formats?(0,Ft._)`${c.code.formats}${(0,Ft.getProperty)(s)}`:void 0,O=n.scopeValue("formats",{key:s,ref:E,code:H});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,Ft._)`${O}.validate`]:["string",E,O]}function P(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Ft._)`await ${_}(${r})`}return typeof y=="function"?(0,Ft._)`${_}(${r})`:(0,Ft._)`${_}.test(${r})`}}}};wS.default=dJ});var O$=N(ES=>{"use strict";Object.defineProperty(ES,"__esModule",{value:!0});var fJ=I$(),pJ=[fJ.default];ES.default=pJ});var M$=N(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.contentVocabulary=uc.metadataVocabulary=void 0;uc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];uc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var L$=N(CS=>{"use strict";Object.defineProperty(CS,"__esModule",{value:!0});var hJ=Vq(),mJ=i$(),gJ=A$(),yJ=O$(),x$=M$(),TJ=[hJ.default,mJ.default,(0,gJ.default)(),yJ.default,x$.metadataVocabulary,x$.contentVocabulary];CS.default=TJ});var AS=N($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});$u.dynamicAnchor=void 0;var DS=be(),vJ=Ir(),q$=Pu(),bJ=Fm(),_J={keyword:"$dynamicAnchor",schemaType:"string",code:t=>$$(t,t.schema)};function $$(t,e){let{gen:n,it:r}=t;r.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,DS._)`${vJ.default.dynamicAnchors}${(0,DS.getProperty)(e)}`,s=r.errSchemaPath==="#"?r.validateName:SJ(t);n.if((0,DS._)`!${i}`,()=>n.assign(i,s))}$u.dynamicAnchor=$$;function SJ(t){let{schemaEnv:e,schema:n,self:r}=t.it,{root:i,baseId:s,localRefs:o,meta:a}=e.root,{schemaId:c}=r.opts,l=new q$.SchemaEnv({schema:n,schemaId:c,root:i,baseId:s,localRefs:o,meta:a});return q$.compileSchema.call(r,l),(0,bJ.getValidate)(t,l)}$u.default=_J});var IS=N(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.dynamicRef=void 0;var F$=be(),kJ=Ir(),B$=Fm(),PJ={keyword:"$dynamicRef",schemaType:"string",code:t=>j$(t,t.schema)};function j$(t,e){let{gen:n,keyword:r,it:i}=t;if(e[0]!=="#")throw new Error(`"${r}" only supports hash fragment reference`);let s=e.slice(1);if(i.allErrors)o();else{let c=n.let("valid",!1);o(c),t.ok(c)}function o(c){if(i.schemaEnv.root.dynamicAnchors[s]){let l=n.let("_v",(0,F$._)`${kJ.default.dynamicAnchors}${(0,F$.getProperty)(s)}`);n.if(l,a(l,c),a(i.validateName,c))}else a(i.validateName,c)()}function a(c,l){return l?()=>n.block(()=>{(0,B$.callRef)(t,c),n.let(l,!0)}):()=>(0,B$.callRef)(t,c)}}Fu.dynamicRef=j$;Fu.default=PJ});var U$=N(OS=>{"use strict";Object.defineProperty(OS,"__esModule",{value:!0});var NJ=AS(),RJ=Ne(),wJ={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,NJ.dynamicAnchor)(t,""):(0,RJ.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};OS.default=wJ});var H$=N(MS=>{"use strict";Object.defineProperty(MS,"__esModule",{value:!0});var EJ=IS(),CJ={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,EJ.dynamicRef)(t,t.schema)};MS.default=CJ});var V$=N(xS=>{"use strict";Object.defineProperty(xS,"__esModule",{value:!0});var DJ=AS(),AJ=IS(),IJ=U$(),OJ=H$(),MJ=[DJ.default,AJ.default,IJ.default,OJ.default];xS.default=MJ});var z$=N(LS=>{"use strict";Object.defineProperty(LS,"__esModule",{value:!0});var W$=Wm(),xJ={keyword:"dependentRequired",type:"object",schemaType:"object",error:W$.error,code:t=>(0,W$.validatePropertyDeps)(t)};LS.default=xJ});var G$=N(qS=>{"use strict";Object.defineProperty(qS,"__esModule",{value:!0});var LJ=Wm(),qJ={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,LJ.validateSchemaDeps)(t)};qS.default=qJ});var K$=N($S=>{"use strict";Object.defineProperty($S,"__esModule",{value:!0});var $J=Ne(),FJ={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:n}){e.contains===void 0&&(0,$J.checkStrictMode)(n,`"${t}" without "contains" is ignored`)}};$S.default=FJ});var Y$=N(FS=>{"use strict";Object.defineProperty(FS,"__esModule",{value:!0});var BJ=z$(),jJ=G$(),UJ=K$(),HJ=[BJ.default,jJ.default,UJ.default];FS.default=HJ});var J$=N(BS=>{"use strict";Object.defineProperty(BS,"__esModule",{value:!0});var Fs=be(),X$=Ne(),VJ=Ir(),WJ={message:"must NOT have unevaluated properties",params:({params:t})=>(0,Fs._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},zJ={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:WJ,code(t){let{gen:e,schema:n,data:r,errsCount:i,it:s}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:o,props:a}=s;a instanceof Fs.Name?e.if((0,Fs._)`${a} !== true`,()=>e.forIn("key",r,d=>e.if(l(a,d),()=>c(d)))):a!==!0&&e.forIn("key",r,d=>a===void 0?c(d):e.if(u(a,d),()=>c(d))),s.props=!0,t.ok((0,Fs._)`${i} === ${VJ.default.errors}`);function c(d){if(n===!1){t.setParams({unevaluatedProperty:d}),t.error(),o||e.break();return}if(!(0,X$.alwaysValidSchema)(s,n)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:X$.Type.Str},f),o||e.if((0,Fs.not)(f),()=>e.break())}}function l(d,f){return(0,Fs._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let m in d)d[m]===!0&&p.push((0,Fs._)`${f} !== ${m}`);return(0,Fs.and)(...p)}}};BS.default=zJ});var Z$=N(jS=>{"use strict";Object.defineProperty(jS,"__esModule",{value:!0});var Lo=be(),Q$=Ne(),GJ={message:({params:{len:t}})=>(0,Lo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Lo._)`{limit: ${t}}`},KJ={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:GJ,code(t){let{gen:e,schema:n,data:r,it:i}=t,s=i.items||0;if(s===!0)return;let o=e.const("len",(0,Lo._)`${r}.length`);if(n===!1)t.setParams({len:s}),t.fail((0,Lo._)`${o} > ${s}`);else if(typeof n=="object"&&!(0,Q$.alwaysValidSchema)(i,n)){let c=e.var("valid",(0,Lo._)`${o} <= ${s}`);e.if((0,Lo.not)(c),()=>a(c,s)),t.ok(c)}i.items=!0;function a(c,l){e.forRange("i",l,o,u=>{t.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:Q$.Type.Num},c),i.allErrors||e.if((0,Lo.not)(c),()=>e.break())})}}};jS.default=KJ});var eF=N(US=>{"use strict";Object.defineProperty(US,"__esModule",{value:!0});var YJ=J$(),XJ=Z$(),JJ=[YJ.default,XJ.default];US.default=JJ});var nF=N(Jm=>{"use strict";Object.defineProperty(Jm,"__esModule",{value:!0});Jm.DiscrError=void 0;var tF;(function(t){t.Tag="tag",t.Mapping="mapping"})(tF||(Jm.DiscrError=tF={}))});var iF=N(VS=>{"use strict";Object.defineProperty(VS,"__esModule",{value:!0});var dc=be(),HS=nF(),rF=Pu(),QJ=ku(),ZJ=Ne(),e6={message:({params:{discrError:t,tagName:e}})=>t===HS.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>(0,dc._)`{error: ${t}, tag: ${n}, tagValue: ${e}}`},t6={keyword:"discriminator",type:"object",schemaType:"object",error:e6,code(t){let{gen:e,data:n,schema:r,parentSchema:i,it:s}=t,{oneOf:o}=i;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=r.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,dc._)`${n}${(0,dc.getProperty)(a)}`);e.if((0,dc._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:HS.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,dc._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:HS.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(h,dc.Name),m}function f(){var p;let m={},h=_(i),y=!0;for(let P=0;P<o.length;P++){let E=o[P];if(E?.$ref&&!(0,ZJ.schemaHasRulesButRef)(E,s.self.RULES)){let O=E.$ref;if(E=rF.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,O),E instanceof rF.SchemaEnv&&(E=E.schema),E===void 0)throw new QJ.default(s.opts.uriResolver,s.baseId,O)}let H=(p=E?.properties)===null||p===void 0?void 0:p[a];if(typeof H!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(h||_(E)),v(H,P)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return m;function _({required:P}){return Array.isArray(P)&&P.includes(a)}function v(P,E){if(P.const)b(P.const,E);else if(P.enum)for(let H of P.enum)b(H,E);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(P,E){if(typeof P!="string"||P in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[P]=E}}}};VS.default=t6});var sF=N((nEe,n6)=>{n6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/schema",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format"},{$ref:"meta/content"}],type:["object","boolean"],properties:{definitions:{$comment:"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},dependencies:{$comment:'"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"',type:"object",additionalProperties:{anyOf:[{$recursiveRef:"#"},{$ref:"meta/validation#/$defs/stringArray"}]}}}}});var oF=N((rEe,r6)=>{r6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{additionalItems:{$recursiveRef:"#"},unevaluatedItems:{$recursiveRef:"#"},items:{anyOf:[{$recursiveRef:"#"},{$ref:"#/$defs/schemaArray"}]},contains:{$recursiveRef:"#"},additionalProperties:{$recursiveRef:"#"},unevaluatedProperties:{$recursiveRef:"#"},properties:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$recursiveRef:"#"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$recursiveRef:"#"}},propertyNames:{$recursiveRef:"#"},if:{$recursiveRef:"#"},then:{$recursiveRef:"#"},else:{$recursiveRef:"#"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$recursiveRef:"#"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$recursiveRef:"#"}}}}});var aF=N((iEe,i6)=>{i6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/content",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentMediaType:{type:"string"},contentEncoding:{type:"string"},contentSchema:{$recursiveRef:"#"}}}});var cF=N((sEe,s6)=>{s6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/core",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{type:"string",format:"uri"},$anchor:{type:"string",pattern:"^[A-Za-z][-A-Za-z0-9.:_]*$"},$ref:{type:"string",format:"uri-reference"},$recursiveRef:{type:"string",format:"uri-reference"},$recursiveAnchor:{type:"boolean",default:!1},$vocabulary:{type:"object",propertyNames:{type:"string",format:"uri"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}}}}});var lF=N((oEe,o6)=>{o6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/format",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:"Format vocabulary meta-schema",type:["object","boolean"],properties:{format:{type:"string"}}}});var uF=N((aEe,a6)=>{a6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var dF=N((cEe,c6)=>{c6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/validation",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}},const:!0,enum:{type:"array",items:!0},type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var fF=N(WS=>{"use strict";Object.defineProperty(WS,"__esModule",{value:!0});var l6=sF(),u6=oF(),d6=aF(),f6=cF(),p6=lF(),h6=uF(),m6=dF(),g6=["/properties"];function y6(t){return[l6,u6,d6,f6,e(this,p6),h6,e(this,m6)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function e(n,r){return t?n.$dataMetaSchema(r,g6):r}}WS.default=y6});var pF=N((St,GS)=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.MissingRefError=St.ValidationError=St.CodeGen=St.Name=St.nil=St.stringify=St.str=St._=St.KeywordCxt=St.Ajv2019=void 0;var T6=Fq(),v6=L$(),b6=V$(),_6=Y$(),S6=eF(),k6=iF(),P6=fF(),zS="https://json-schema.org/draft/2019-09/schema",fc=class extends T6.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(b6.default),v6.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(_6.default),this.addVocabulary(S6.default),this.opts.discriminator&&this.addKeyword(k6.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:n}=this.opts;n&&(P6.default.call(this,e),this.refs["http://json-schema.org/schema"]=zS)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(zS)?zS:void 0)}};St.Ajv2019=fc;GS.exports=St=fc;GS.exports.Ajv2019=fc;Object.defineProperty(St,"__esModule",{value:!0});St.default=fc;var N6=Su();Object.defineProperty(St,"KeywordCxt",{enumerable:!0,get:function(){return N6.KeywordCxt}});var pc=be();Object.defineProperty(St,"_",{enumerable:!0,get:function(){return pc._}});Object.defineProperty(St,"str",{enumerable:!0,get:function(){return pc.str}});Object.defineProperty(St,"stringify",{enumerable:!0,get:function(){return pc.stringify}});Object.defineProperty(St,"nil",{enumerable:!0,get:function(){return pc.nil}});Object.defineProperty(St,"Name",{enumerable:!0,get:function(){return pc.Name}});Object.defineProperty(St,"CodeGen",{enumerable:!0,get:function(){return pc.CodeGen}});var R6=Am();Object.defineProperty(St,"ValidationError",{enumerable:!0,get:function(){return R6.default}});var w6=ku();Object.defineProperty(St,"MissingRefError",{enumerable:!0,get:function(){return w6.default}})});var gc=require("path"),Be=q(Vw());var Cf=class t{constructor(e,n,r,i){this._uri=e,this._languageId=n,this._version=r,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 n=this.offsetAt(e.start),r=this.offsetAt(e.end);return this._content.substring(n,r)}return this._content}update(e,n){for(let r of e)if(t.isIncremental(r)){let i=zw(r.range),s=this.offsetAt(i.start),o=this.offsetAt(i.end);this._content=this._content.substring(0,s)+r.text+this._content.substring(o,this._content.length);let a=Math.max(i.start.line,0),c=Math.max(i.end.line,0),l=this._lineOffsets,u=Ww(r.text,!1,s);if(c-a===u.length)for(let f=0,p=u.length;f<p;f++)l[f+a+1]=u[f];else u.length<1e4?l.splice(a+1,c-a,...u):this._lineOffsets=l=l.slice(0,a+1).concat(u,l.slice(c+1));let d=r.text.length-(o-s);if(d!==0)for(let f=a+1+u.length,p=l.length;f<p;f++)l[f]=l[f]+d}else if(t.isFull(r))this._content=r.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=n}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=Ww(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let n=this.getLineOffsets(),r=0,i=n.length;if(i===0)return{line:0,character:e};for(;r<i;){let o=Math.floor((r+i)/2);n[o]>e?i=o:r=o+1}let s=r-1;return{line:s,character:e-n[s]}}offsetAt(e){let n=this.getLineOffsets();if(e.line>=n.length)return this._content.length;if(e.line<0)return 0;let r=n[e.line],i=e.line+1<n.length?n[e.line+1]:this._content.length;return Math.max(Math.min(r+e.character,i),r)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let n=e;return n!=null&&typeof n.text=="string"&&n.range!==void 0&&(n.rangeLength===void 0||typeof n.rangeLength=="number")}static isFull(e){let n=e;return n!=null&&typeof n.text=="string"&&n.range===void 0&&n.rangeLength===void 0}},Vn;(function(t){function e(i,s,o,a){return new Cf(i,s,o,a)}t.create=e;function n(i,s,o){if(i instanceof Cf)return i.update(s,o),i;throw new Error("TextDocument.update: document must be created by TextDocument.create")}t.update=n;function r(i,s){let o=i.getText(),a=oT(s.map(OU),(u,d)=>{let f=u.range.start.line-d.range.start.line;return f===0?u.range.start.character-d.range.start.character:f}),c=0,l=[];for(let u of a){let d=i.offsetAt(u.range.start);if(d<c)throw new Error("Overlapping edit");d>c&&l.push(o.substring(c,d)),u.newText.length&&l.push(u.newText),c=i.offsetAt(u.range.end)}return l.push(o.substr(c)),l.join("")}t.applyEdits=r})(Vn||(Vn={}));function oT(t,e){if(t.length<=1)return t;let n=t.length/2|0,r=t.slice(0,n),i=t.slice(n);oT(r,e),oT(i,e);let s=0,o=0,a=0;for(;s<r.length&&o<i.length;)e(r[s],i[o])<=0?t[a++]=r[s++]:t[a++]=i[o++];for(;s<r.length;)t[a++]=r[s++];for(;o<i.length;)t[a++]=i[o++];return t}function Ww(t,e,n=0){let r=e?[n]:[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);(s===13||s===10)&&(s===13&&i+1<t.length&&t.charCodeAt(i+1)===10&&i++,r.push(n+i+1))}return r}function zw(t){let e=t.start,n=t.end;return e.line>n.line||e.line===n.line&&e.character>n.character?{start:n,end:e}:t}function OU(t){let e=zw(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var Df=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],Af=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var lT=q(require("url")),tE=require("crypto"),fa=require("path"),cn=q(j());var aT=q(j());var Wn=q(j());var te=class{constructor(e){this._children=[];this.syntaxIssues=[];this.resettableIssues=[];this._firstToken=e?.start,this._lastToken=e?.end}get issues(){return[...this.syntaxIssues,...this.resettableIssues]}resetIssues(){this.resettableIssues=[],this.children.forEach(e=>e.resetIssues())}get serializeIssues(){return this.issues.map(e=>e())}get firstToken(){return this._firstToken??this._children[0].firstToken}set firstToken(e){this._firstToken=e}get lastToken(){return this._lastToken??this._children[this._children.length-1]?.lastToken??this.firstToken}set lastToken(e){this._lastToken=e}get fsPath(){return this.firstToken.fsPath}getTopMostAstNodeForFile(e){return he(e,this.fsPath)?[this]:this.children.flatMap(n=>n.getTopMostAstNodeForFile(e))}getDocumentSymbols(e){if(!this.docSymbolsMeta)return this.children.flatMap(r=>r.getDocumentSymbols(e)??[]);if(!he(this.fsPath,e))return[];let n=ce(this);return[{name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind,range:n,selectionRange:n,children:[...this.children.flatMap(r=>r.getDocumentSymbols(e)??[])]}]}getWorkspaceSymbols(){if(!this.docSymbolsMeta)return this.children.flatMap(i=>i.getWorkspaceSymbols()??[]);let e=this.docSymbolsMeta.kind;if(![Wn.SymbolKind.File,Wn.SymbolKind.Class,Wn.SymbolKind.Constant].some(i=>i===e))return[];let n=zn(this.fsPath),r=n?.range??ce(this);return[{location:Wn.Location.create(ue(n?.docFsPath??this.fsPath),r),name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind},...this.children.flatMap(i=>i.getWorkspaceSymbols()??[]).filter(i=>i.kind===Wn.SymbolKind.File||i.kind===Wn.SymbolKind.Class||i.kind===Wn.SymbolKind.Constant)]}buildSemanticTokens(e){this._children.forEach(n=>n.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(xi(this.semanticTokenType),Li(this.semanticTokenModifiers),this.firstToken,this.lastToken)}get children(){return this._children}get allDescendants(){return this.allDescendantsCache??=[...this._children,...this._children.flatMap(e=>e.allDescendants)],this.allDescendantsCache}addChild(e){e&&(e.parentNode=this,this._children.push(e)),this.allDescendantsCache=void 0}isAncestorOf(e){return this.children.some(n=>n===e||n.isAncestorOf(e))}toPrettyString(e){return this.toString()}toString(e){return"TODO"}get range(){return Wn.Range.create(Wn.Position.create(this.firstToken.pos.line,this.firstToken.pos.col),Wn.Position.create(this.lastToken.pos.line,this.lastToken.pos.colEnd))}get serializeURL(){return ue(this.fsPath)}serialize(e){return{url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var ge=class extends te{get firstToken(){return this.operator?this.operator.firstToken:super.firstToken}toJson(){return-1}#e;resolve(e){return this.#e??=$c(this.toString(),e),this.#e}#n;evaluate(e){return this.#n??=De(`${this.operator?this.operator.toString():""}${this.resolve(e)}`),this.#n}#r;isTrue(e){return this.#r??=De(`!!(${this.operator?this.operator.toString():""}${this.resolve(e)})`),typeof this.#r=="boolean"&&this.#r}toPrettyString(e){let n=this.evaluate(e);return`${n.toString()} /* ${this.toString()}${typeof n=="number"?` = 0x${n.toString(16)}`:""} */`}serialize(e){return{type:"EXPRESSION",value:this.toString(),evaluated:this.evaluate(e),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},Qt=class t extends ge{constructor(n,r,i){super();this.expression=n;this.wrapped=r;this.addChild(n),i&&(this.addChild(i.operator),this.addChild(i.expression),this.join=[],this.join?.push(i))}get firstToken(){return this.openBracket?this.openBracket:super.firstToken}get lastToken(){return this.closeBracket?this.closeBracket:super.lastToken}addExpression(n,r){this.addChild(n),this.addChild(r),this.join??=[],this.join?.push({operator:n,expression:r})}toString(){let n=this.children.map(r=>"radix"in r&&r.radix===16?`0x${r.toString()}`:r.toString()).join(" ");return this.wrapped?`(${n})`:`${n}`}isTrue(n){let r=`(${this.children.map(i=>i instanceof ge?i.resolve(n):i.toString()).join(" ")})`;return De(`!!(${this.operator?this.operator.toString():""}${r})`)}get flatJoin(){return this.wrapped?this.join??(this.expression instanceof t?this.expression.flatJoin:[]):[...this.expression instanceof t?this.expression.flatJoin:[],...this.join?.flatMap(n=>[{operator:n.operator,expression:n.expression instanceof t?n.expression.expression:n.expression},...n.expression instanceof t?n.expression.flatJoin:[]])??[]]}};var hi=class extends ge{constructor(n,r,i){super(r);this.value=n;this.docSymbolsMeta={name:`param${i+1}`,kind:aT.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},Ut=class extends ge{constructor(n,r){super();this.functionName=n;this.params=r;this.addChild(n),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(n){return he(this.fsPath,n)?[{name:this.functionName.name,kind:aT.SymbolKind.Function,range:ce(this),selectionRange:ce(this),children:this.params.flatMap(r=>r?.getDocumentSymbols(n)??[])}]:[]}toString(){return`${this.functionName.toString()}(${this.params.map(n=>n?.toString()??"").join(", ")})`}isTrue(n){if(this.functionName.name==="defined"){let r=!!(this.params.length===1&&this.params[0]&&n.has(this.params[0].value));return this.operator?De(`!!(${this.operator}${r})`):r}return super.isTrue(n)}};var Wr=q(j());var Jw=q(j());var Gw=q(j());var re=class extends te{constructor(n,r){super(r);this.value=n;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:Gw.SymbolKind.String}}toString(){return`"${this.value.toString()}"`}toJson(){return this.value}serialize(){return{type:"STRING",value:this.value,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Yw=q(j());var Kw=q(j());var Zt=class extends ge{constructor(n,r,i=10){super(r);this.value=n;this.radix=i;this.docSymbolsMeta={name:this.value.toString(),kind:Kw.SymbolKind.Number},this.semanticTokenType="number",this.semanticTokenModifiers="declaration"}resolve(n){return this.value.toString()}evaluate(n){return this.value}isTrue(n){return!!this.value}toString(n){return this.value.toString(n??this.radix)}toJson(){return this.value}toPrettyString(n){let r=this.value;return this.radix===16?`0x${r.toString(16)} /* ${typeof r=="number"?`${r.toString(10)}`:""} */`:`${r.toString(10)} /* ${typeof r=="number"?`0x${r.toString(16)}`:""} */`}serialize(){return{type:"NUMBER_VALUE",value:`${this.radix===16?"0x":""}${this.toString()}`,evaluated:this.value,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var gt=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Cell Array",kind:Yw.SymbolKind.Array},this.values.forEach(r=>this.addChild(r))}toString(){return`<${this.values.map(n=>n.toString()).join(" ")}>`}toPrettyString(n){return`<${this.values.map(r=>r.toPrettyString(n)).join(" ")}>`}toJson(){if(this.values.length===1)return this.values[0].value?.toJson();if(this.values.length===2&&this.values.every(n=>n.value instanceof Zt)){let n=new ArrayBuffer(8),r=new DataView(n);return this.values.map(i=>i.value.value).forEach((i,s)=>{r.setUint32(s*4,i)}),r.getBigUint64(0)}return this.values.map(n=>n.value?.toJson()??NaN)}serialize(n){return{type:"ARRAY_VALUE",value:this.values.map(r=>r.value?.serialize(n)??null),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Xw=q(j());var or=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Byte String Value",kind:Xw.SymbolKind.Array},this.values.forEach(r=>this.addChild(r))}toString(){return`[${this.values.map(n=>n.toString(16).padStart(2,"0")).join(" ")}]`}toJson(){return this.values.map(n=>n.value?.toJson()??NaN)}serialize(){return{type:"BYTESTRING",values:this.values.map(n=>n.value?.serialize()??null),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Ye=class extends te{constructor(n,r){super(r);this.name=n;this.semanticTokenType="property",this.semanticTokenModifiers="declaration"}toString(){return this.name}serialize(){return{value:this.name,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},je=class extends te{constructor(n,r=[]){super();this.propertyName=n;this.labels=r;this._values=void 0;this.docSymbolsMeta={name:this.propertyName?.name??"Unknown",kind:Jw.SymbolKind.Property},this.labels.forEach(i=>this.addChild(i)),this.addChild(n)}set values(n){if(this._values)throw new Error("Only one property name is allowed");this._values=n,this.addChild(n)}get values(){return this._values}get quickValues(){return this.values?.values.map(n=>n?n.value instanceof re?n.value.value:n.value instanceof gt?n.value.values.map(r=>r.value instanceof Zt?r.value.value:NaN):n.value instanceof or?n.value.values.map(r=>r.value?.value??NaN):NaN:null)}getFlatAstValues(){return this.values?.values.flatMap(n=>n?n.value instanceof re?n.value:n.value instanceof gt?n.value.values.map(r=>r.value):n.value instanceof or?n.value.values.map(r=>r.value):n.value:null)}toString(){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(n=>n?.toString()??"NULL").join(", ")??"NULL"}`:""};`}toPrettyString(n,r){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(i=>i?.toPrettyString(n)??"NULL").join(r?`,
183
- ${" ".repeat(r)}`:", ")??"NULL"}`:""};${ro(this.fsPath)?" /* default value from binding */":""}`}serialize(n){return{name:this.propertyName?.serialize()??null,values:this.values===void 0?void 0:this.values?.values.map(r=>r?.value?.serialize(n)??null)??null,url:this.serializeURL,range:this.range,issues:[...this.serializeIssues,...this.values?.issues.map(r=>r())??[]]}}};var Qw=q(j());var En=class extends te{constructor(n,r){super();this.keyword=r;this.addChild(r),this.docSymbolsMeta={name:n,kind:Qw.SymbolKind.Function}}};var Gn=class extends En{constructor(n){super("Delete Node",n);this._nodeNameOrRef=null}set nodeNameOrRef(n){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=n,this.addChild(n)}get nodeNameOrRef(){return this._nodeNameOrRef}};var yt=class extends En{constructor(n){super("Delete Property",n);this._propertyName=null}set propertyName(n){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=n,this.addChild(n)}get propertyName(){return this._propertyName}};var Zw=q(j());var ie=class extends te{constructor(n){super();this.label=n;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:Zw.SymbolKind.Key},this.addChild(n)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}serialize(){return{type:"LABEL_REF",label:this.label?.toString()??null,nodePath:this.linksTo?.pathString??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Ue=class t extends te{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof Tt)return[this.pathName];if(!(this.parentNode instanceof t))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof t)}get deleteNodes(){return this.children.filter(e=>e instanceof Gn)}addNodeChild(e){this.addChild(e)}},Tt=class extends Ue{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Wr.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof je)}#e;get name(){return this.#e??=new xe("/",de(this.firstToken)),this.#e}get identifierAst(){return this.name}get deleteProperties(){return this.children.filter(e=>e instanceof yt)}get nodes(){return this.children.filter(e=>e instanceof He)}get pathName(){return"/"}serialize(e){return{type:"ROOT",properties:this.properties.map(n=>n.serialize(e)),nodes:this.nodes.map(n=>n.serialize(e)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&ae(this.openScope),scopeClose:this.closeScope&&ae(this.closeScope,!1)}}},Et=class extends Ue{constructor(n=[]){super();this.labels=n;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Wr.SymbolKind.Class},n.forEach(r=>{super.addChild(r)})}get serializeIssues(){return[...this.issues,...this.reference?.issues??[]].map(n=>n())}get identifierAst(){return this.reference}set reference(n){if(this._reference)throw new Error("Only on label reference is allowed");this._reference=n;let r;n instanceof ie?r=n.value:r=n?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:r??"DTC Name",kind:Wr.SymbolKind.Class},this.addChild(n)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get reference(){return this._reference}get nodes(){return this.children.filter(n=>n instanceof He)}get pathName(){if(this.reference instanceof ie&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(n=>n instanceof je)}get deleteProperties(){return this.children.filter(n=>n instanceof yt)}serialize(n){return{type:"REF",labels:this.labels.map(r=>r.serialize(n)),name:this.reference?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&ae(this.openScope),scopeClose:this.closeScope&&ae(this.closeScope,!1)}}},He=class t extends Ue{constructor(n=[],r){super();this.labels=n;this.omitIfNoRef=r;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Wr.SymbolKind.Class},r&&this.addChild(r),n.forEach(i=>{this.addChild(i)})}get identifierAst(){return this.name}get serializeIssues(){return[...this.issues,...this.name?.issues??[]].map(n=>n())}set name(n){if(this._name)throw new Error("Only on label reference is allowed");this._name=n,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:Wr.SymbolKind.Class},this.addChild(n)}get name(){return this._name}get nodes(){return this.children.filter(n=>n instanceof t)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(n=>n instanceof je)}get deleteProperties(){return this.children.filter(n=>n instanceof yt)}serialize(n){return{type:"CHILD",labels:this.labels.map(r=>r.serialize(n)),name:this.name?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&ae(this.openScope),scopeClose:this.closeScope&&ae(this.closeScope,!1)}}},Fc=class extends te{constructor(n,r){super(r);this.address=n;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address?.map((n,r)=>n.toString(16).padStart(r?8:0,"0")).join("")??"NaN"}serialize(){return{address:this.address,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},xe=class extends te{constructor(n,r,i){super(r);this.name=n;this._address=i;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(n){if(this._address)throw new Error("Address can only be set once");n&&(this.lastToken=void 0,this._address=n,n.forEach(r=>this.addChild(r)))}get fullAddress(){return this._address?[...this._address.flatMap(n=>n.address)]:void 0}toString(){return this._address!==void 0?`${this.name}@${this._address.map(n=>n.toString()).join(",")}`:this.name}buildSemanticTokens(n){let r=this.firstToken;if(!r.value)return;let i={...r,pos:{...r.pos,len:this.name.length}};n(xi("type"),Li("declaration"),i,i),this.address!==void 0&&this.address.forEach(s=>{n(xi("decorator"),Li("declaration"),s.firstToken,s.lastToken),s.buildSemanticTokens(n)})}get serializeIssues(){return[...this.issues,...this._address?.flatMap(n=>n.issues)??[]].map(n=>n())}serialize(){let n=this.firstToken;return{fullName:this.toString(),name:{name:this.name,url:this.serializeURL,range:Wr.Range.create(Wr.Position.create(n.pos.line,n.pos.col),Wr.Position.create(n.pos.line,n.pos.colEnd)),issues:this.serializeIssues},address:this.address?.map(r=>r.serialize())??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var ar=(t,e,n=!0,r=!0)=>({start:{line:t?.pos.line??0,character:n?t?.pos.col??0:(t?.pos.col??0)+(t?.pos.len??0)},end:{line:e?.pos.line??0,character:r?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var ae=(t,e=!0)=>cn.Position.create(t.pos.line,e?t.pos.colEnd:t.pos.col),ce=t=>ar(t.firstToken,t.lastToken),xi=t=>Df.findIndex(e=>e===t),Li=t=>Af.findIndex(e=>e===t),Bc=(t,e,n)=>!he(t.fsPath,e)||n.line<t.pos.line?!1:n.line>t.pos.line?!0:n.character>=t.pos.colEnd,uT=(t,e,n)=>he(t.fsPath,e)?n.line<t.pos.line?!0:n.line>t.pos.line?!1:n.character<t.pos.col:!1,Cn=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!((r.pos.line<n.line||r.pos.line===n.line&&r.pos.col<=n.character)&&(i.pos.line>n.line||i.pos.line===n.line&&i.pos.colEnd>=n.character)&&he(t.fsPath,e))},Mf=(t,e)=>{let n=(i,s)=>i.line<s.line||i.line===s.line&&i.character<=s.character,r=(i,s)=>i.line>s.line||i.line===s.line&&i.character>=s.character;return n(t.start,e.start)&&r(t.end,e.end)},nE=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!(t.lastToken.value!==";"&&(r.pos.line===n.line||i.pos.line===n.line)&&n.character>=i.pos.colEnd&&he(t.fsPath,e))},rE=(t,e,n)=>{if(!t)return!1;let i=t.filter(s=>s.pos.line===n.line).at(-1);return i&&i.pos.col>=n.character?!1:e.lastToken===i};var zr=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>Cn(s,e,n));return r},jc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].find(s=>uT(s.lastToken,e,n));return r===t?void 0:r},Uc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>Bc(s.firstToken,e,n));return r===t?void 0:r},dT="#virtual",ro=t=>t.includes(dT),xf=(t,e)=>`${t}?loc=${e.start.line}:${e.start.character}-${e.end.line}:${e.end.character}${dT}`,zn=t=>{if(!ro(t))return;let[e,n]=t.split("?"),[r,i]=n.replace("loc=","").replace(dT,"").split("-"),[s,o]=r.split(":"),[a,c]=i.split(":");return{docFsPath:e,range:cn.Range.create(cn.Position.create(Number.parseInt(s),Number.parseInt(o)),cn.Position.create(Number.parseInt(a),Number.parseInt(c)))}},fT=t=>{let e=zn(t.fsPath);e&&(t.range=e.range,t.fsPath=e?.docFsPath,t.virtual=!0,t.linkedTo=t.linkedTo.map(({range:n,fsPath:r})=>{let i=zn(r);return{range:i?.range??n,fsPath:i?.docFsPath??r,templateStrings:[]}}))},z=(t,e,n=e,r,{severity:i=cn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,inclusiveStart:u,inclusiveEnd:d}={severity:cn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let f={issues:Array.isArray(t)?t:[t],range:ar(e,n,u,d),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:h,fsPath:y})=>({range:h,fsPath:y,templateStrings:[]})),tags:o,templateStrings:a,edit:c,codeActionTitle:l};fT(f);let p,m=()=>(p??={severity:f.severity,range:f.range,message:f.issues?f.issues.map(qU).join(" or "):"",source:"devicetree",tags:f.tags,data:{firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},type:"SyntaxIssue",items:f.issues,edit:f.edit,codeActionTitle:f.codeActionTitle,virtual:!!f.virtual}},p);return r?.syntaxIssues.push(m),{raw:f,diagnostic:m}},Ht=(t,e,n,r,{severity:i=cn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,linkedToTemplateStrings:u=[]}={severity:cn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let d={issues:Array.isArray(t)?t:[t],range:ar(e,n),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:m,fsPath:h},y)=>({range:m,fsPath:h,templateStrings:u.at(y)??[]})),tags:o,templateStrings:a,edit:c,codeActionTitle:l};fT(d);let f,p=()=>(f??={severity:d.severity,range:d.range,message:$U(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(m=>({message:d.issues.map(h=>FU(h,m.templateStrings)).join(" or "),location:{uri:ue(m.fsPath),range:m.range}}))]},f);return r?.resettableIssues.push(p),{raw:d,diagnostic:p}},F=(t,e,n,r,{severity:i=cn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l}={severity:cn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let u={issues:Array.isArray(t)?t:[t],range:ar(e,n),severity:i,fsPath:e.fsPath,linkedTo:s.map(({range:p,fsPath:m})=>({range:p,fsPath:m,templateStrings:[]})),tags:o,templateStrings:a,edit:c,codeActionTitle:l};fT(u);let d,f=()=>(d??={severity:u.severity,range:u.range,message:BU(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(jU).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"StandardTypeIssue",firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},edit:u.edit,codeActionTitle:u.codeActionTitle,items:u.issues,virtual:!!u.virtual}},d);return Array.isArray(r)?r.forEach(p=>p.resettableIssues.push(f)):r?.resettableIssues.push(f),{raw:u,diagnostic:f}};function st(t,e,n,{severity:r=cn.DiagnosticSeverity.Warning,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:cn.DiagnosticSeverity.Warning,linkedTo:[],templateStrings:[],edit:[],codeActionTitle:void 0},l=n){let u={issues:Array.isArray(t)?t:[t],range:cn.Range.create(n,l),severity:r,fsPath:e,linkedTo:i.map(({range:p,fsPath:m})=>({range:p,fsPath:m,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},d;return{raw:u,diagnostic:()=>(d??={severity:u.severity,range:u.range,message:UU(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(HU).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"FormattingIssues",items:u.issues,edit:u.edit,codeActionTitle:u.codeActionTitle,virtual:!!u.virtual}},d)}}var iE=(t,e)=>[...t].sort((r,i)=>{let s=e.getSortKey(r),o=e.getSortKey(i);if(s===void 0||o===void 0)throw new Error("Sort keys must be set");if(s!==o)return s-o;let a=r.lastToken,c=i.lastToken;return a.pos.line!==c.pos.line?a.pos.line-c.pos.line:a.pos.col-c.pos.col});async function Nt(t,e,n){let r=Se(t.textDocument.uri);if(!e)return[];let i=performance.now(),s=await e.getRuntime(),o,a,c=s.context.allParsers.flatMap(u=>u.injectedMacros).find(u=>Cn(u,r,t.position));return c&&(o={runtime:s,item:null,ast:zr(c,r,t.position)},a=Number.MAX_SAFE_INTEGER),o||(o=s.getDeepestAstNode(r,t.position),a=e.getSortKey(o?.ast)??e.getSortKeyFile(t.position,r)),console.log(`search: ${performance.now()-i}ms`),n(o,u=>{let d=t.position;if(he(u.fsPath,r)){let f=u.lastToken;return f.pos.line<d.line||f.pos.line===d.line&&f.pos.colEnd<=d.character}return a!==void 0&&(e.getSortKey(u)??-1)<=a})}function de(t,e){return{start:t,end:e??t}}var U=(t,e)=>t?.tokens.some(n=>n===e),tt=(t,e)=>n=>n?.value&&(e?.caseInsensitive?t.toLowerCase()===n.value.toLowerCase():t===n.value)?"yes":e?.allowPartial?MU(t)(n):"no",Le=t=>e=>e?.tokens.some(n=>n===t)?"yes":"no",MU=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",ln=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&he(t.fsPath,e.fsPath),Vt=(t,e)=>t?.tokens[0]===21&&e?.tokens[0]===21&&(t?.prevToken&&t.prevToken.value===e?.value||e?.prevToken&&e.prevToken.value===t?.value)?!0:!!t&&!!e&&t.pos.colEnd===e.pos.col&&ln(t,e),Lf=t=>t.map((e,n)=>({index:n,context:e,files:e.getContextFiles()})),vn=(t,e,n,r)=>{if("id"in e){let s=t?.find(o=>o.id===e.id);return s||void 0}if("name"in e){let s=t?.find(o=>o.ctxNames.includes(e.name));return s||void 0}return n?.getContextFiles().find(s=>he(s,e.fsPath))?n:Lf(t).sort(s=>s.context.id===r?-1:0).find(s=>s.files.some(o=>he(o,e.fsPath)))?.context},pT=(t,e)=>Lf(t).filter(r=>r.files.some(i=>he(i,e))).map(r=>r.context),sE=t=>{let e=/^(\w+)\s+(.*)$/,n=/^(\w+)\(([^)]*)\)\s+(.*)$/,r=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.*)$/,i;if(i=r.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l=l.replace(/__VA_ARGS__/g,c.slice(a.length).join(", ")),l}}else if(i=n.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l}}else if(i=e.exec(t)){let[,,s]=i;return s.trim()}};function xU(t){if(!t.trim())return[];let e=[],n="",r=0;for(let i=0;i<t.length;i++){let s=t[i];s===","&&r===0?(e.push(n.trim()),n=""):(s==="("?r++:s===")"&&r--,n+=s)}return n.trim()&&e.push(n.trim()),e}var LU=0,$c=(t,e)=>{let n=o=>o.replace(/\s*##\s*/g,""),r=o=>o.replace(/#(\w+)/g,(a,c)=>`"${c}"`),i=t,s;do s=i,i=n(s),i=r(i),i=i.replace(/\b(\w+)\(([^()]*(?:\([^()]*\)[^()]*)*)\)|\b(\w+)\b/g,(o,a,c,l)=>{if(a==="defined"){let u=c.split(",").map(d=>d.trim());return u[0]?e.get(u[0])?.resolver:u}else if(a&&typeof e.get(a)?.resolver=="function"){let u=xU(c).map(d=>d.trim()).map(d=>d==="__COUNTER__"?(LU++).toString():d).map(d=>$c(d,e));return(e.get(a)?.resolver)(...u)}else if(l&&typeof e.get(l)?.resolver=="string")return e.get(l)?.resolver;return o});while(i!==s);return i};function hT(t){return t.replace(/'(.)'/g,(e,n)=>n.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function De(t){try{return(0,eval)(hT(t))}catch{}return t}var ue=t=>lT.default.pathToFileURL(t).toString(),Se=t=>it(lT.default.fileURLToPath(t)),oE=(t,e)=>{let n=(0,fa.relative)(t,e);return!!n&&!n.startsWith("..")&&!(0,fa.isAbsolute)(n)},he=(t,e)=>!t||!e?!1:t===e,it=t=>(0,fa.normalize)(process.platform==="win32"?t.toLowerCase():t),qi=t=>(0,tE.createHash)("sha256").update([it(t.dtsFile),...t.includePaths.map(it),...t.overlays.map(it),t.bindingType,...t.zephyrBindings.map(it),...t.deviceOrgBindingsMetaSchema.map(it),...t.deviceOrgTreeBindings.map(it),`showFormattingErrorAsDiagnostics-${t.showFormattingErrorAsDiagnostics}`,`disableFileWatchers-${t.disableFileWatchers}`].join(":")).digest("hex"),qU=t=>{switch(t){case 0:return"Expected value";case 1:return"Expected ';'";case 2:return"Expected '{'";case 3:return"Expected '}'";case 4:return"Expected '['";case 5:return"Expected ']'";case 12:return"Expected '>'";case 13:return"Expected '<'";case 16:return`Expected '"'`;case 17:return`Expected "'"\\`;case 24:return"Missing ':'";case 21:return"Missing '/'";case 26:return'Expected ")"';case 28:return'Missing ","';case 6:return"Expected property name";case 7:return"Expected node name";case 49:return"Node name shall start with a lower or upper case character";case 50:return"Node unit address should not start with 0x";case 51:return"Node unit address should not end with with ULL";case 8:return"Expected node address";case 9:return"Expected node path";case 48:return"Expected node path reference";case 10:return"Expected node reference";case 11:return"Expected root node name";case 14:return"Expected bytestring";case 15:return"Expected two digits for each byte in bytestring";case 20:return"Hex values are not allowed";case 18:return"Expected label name";case 19:return"Expected '/' at the start of a node path";case 23:return"Found ';' without a statement";case 25:return"Did you mean /delete-node/ or /delete-property/?";case 34:return"Did you mean /delete-node/?";case 35:return"Did you mean /delete-property/?";case 22:return"Unknown syntax";case 27:return"Expected expression";case 31:return"Expected macro identifier";case 30:return"Expected macro identifier or function like macro";case 29:return"White space is not allowed";case 32:return"Properties can only be defined in a node";case 53:return"Node name syntax can only be used inside a node definition.";case 33:return"Properties can only be deleted inside a node";case 36:return"Unable to resolve include";case 52:return"Unknown Node Address syntax";case 37:return"Expected start address";case 38:return"Expected end address";case 39:case 40:return"Expected 8|16|32|64";case 42:return"Unknown macro name";case 43:return"Expected function like macro";case 44:return"Macro expects less arguments";case 45:return"Macro expects more arguments";case 46:return"Missing #ENDIF";case 47:return"Block Unused";case 41:return"This syntax is not officially part of the DTS V0.4 standard"}},$U=t=>t.issues.map(e=>{switch(e){case 0:return`Property "${t.templateStrings[0]}" is replaced by a later definition`;case 1:return"Cannot delete a property before it has been defined";case 2:return"Node name already defined";case 5:return"Cannot delete a node before it has been defined";case 3:return`No node with that reference "${t.templateStrings[0]}" has been defined`;case 8:return`No node with name "${t.templateStrings[0]}" could be found in "/${t.templateStrings[1]}".`;case 4:return`Label name "${t.templateStrings[0]}" already defined`;case 6:return`Property "${t.templateStrings[0]}" was deleted`;case 7:return`Node "${t.templateStrings[0]}" was deleted`;case 9:return`The following node "${t.templateStrings[1]}" shall be present in "${t.templateStrings[0]}" node.`;case 10:return`The following node "${t.templateStrings[0]}" address range collides with another node. Address start: "${t.templateStrings[1]}", end: "${t.templateStrings[2]}".`}}).join(" or "),FU=(t,e)=>{switch(t){case 0:return"Property name already defined.";case 2:return"Defined here";case 4:return"Defined here";case 7:case 6:return"Deleted here";case 9:return"Node";case 10:return`Node "${e[0]}". Address start: "${e[1]}", end: "${e[2]}".`;default:return"TODO"}},BU=t=>t.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${t.templateStrings[0]}`;case 1:return"INTRO should be empty";case 8:return"INTRO can only be assigned one value";case 5:return"INTRO should be assigned a U32";case 6:return"INTRO should be assigned a U64";case 7:return"INTRO should be assigned a 'property encoded array'";case 2:return"INTRO should be assigned a string";case 3:return"INTRO should be assigned a string list";case 4:return`INTRO expects ${t.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 27:return"INTRO name is not permitted under this node";case 34:return"INTRO name is not defined in the type binding for this node";case 10:return"INTRO address value must match node address";case 12:return"INTRO should be 'cpu'";case 13:return"INTRO should be 'memory'";case 14:return"INTRO is deprecated and should not be used'";case 15:return`INTRO ${t.templateStrings[1]}'`;case 18:return"INTRO value must be unique in the entire Devicetree";case 19:return`INTRO should have format ${t.templateStrings[1]}`;case 16:return`INTRO requires property "${t.templateStrings[1]}" in node path "${t.templateStrings[2]}"`;case 17:return"Unable to resolve interrupt parent node";case 20:return`INTRO should have format ${t.templateStrings[1]}`;case 21:return"Node is disabled";case 22:return"Unable to resolve handle";case 23:return`Unable to find "${t.templateStrings[0]}" in ${t.templateStrings[1]}`;case 24:return t.templateStrings[0];case 25:return t.templateStrings[0];case 26:return t.templateStrings[0];case 28:return t.templateStrings[0];case 35:return"Unable to find mapping range for address";case 29:return`INTRO exceeds address space available for this mapping. The range ends at ${t.templateStrings[2]}, the node ends at ${t.templateStrings[1]}`;case 30:return"Map entry overlaps with others entries";case 31:return"Unable to match to a nexus map entry";case 32:return`Unknown node type "${t.templateStrings[0]}"`;case 33:return`Missing name for "${t.templateStrings[0]}" index ${t.templateStrings[1]}"`;case 36:return"Node address is missing";case 37:return`Binding should be used on bus type${t.templateStrings.length?"s":""}: ${t.templateStrings.join(" or ")}`;case 38:return"Empty ranges property should only be used when address size cells is identical to the parent node"}}).join(" or ").replace("INTRO",`Property "${t.templateStrings[0]}"`).replaceAll("INTRO ",""),jU=t=>{switch(t){case 16:case 0:return"Node";case 15:return"Ignored reason";case 18:return"Conflicting properties";case 8:return"Additional value";case 21:return"Disabled by";case 29:return"Mapping range";case 30:return"Map entry";case 31:return"Nexus map entries";case 33:return"Names property";case 35:return"Range property";default:return"TODO"}},UU=t=>t.issues.map(e=>{switch(e){case 4:return"Add end of line to end of file";case 1:return`${t.codeActionTitle}. Expecting ${t.templateStrings[0]}.`;case 0:return"Move to a new line";case 3:return"Remove trailing whitespace at the end of file.";case 2:return"Remove trailing whitespace at the end of the line.";case 5:return`Fix indentation. ${t.templateStrings.at(0)?.length===0?"No indentation expected":`Expecting ${t.templateStrings[0]}`}`;case 6:return`Move token "${t.templateStrings[0]}" next to expression`;case 7:return"Remove (...) enclosure. This expression should only be enclosed in the #define of the macro";case 8:return`Line is too long. ${t.codeActionTitle}`;case 9:return`Hex values must be lowercase. ${t.codeActionTitle}`;case 10:return"Node address is already a hex value. Remove '0x'.";case 10:return"Node address size is determined by '@size-cells', Remove 'ull'.";case 12:return`'\\' is not necessary. ${t.codeActionTitle}`}}).join(" or "),HU=t=>"TODO",aE=(t,e)=>Lt(t,e)<=0?t:e,cE=(t,e)=>Lt(t,e)>=0?t:e,Lt=(t,e)=>{let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=t[t.length-n+r]??0,s=e[e.length-n+r]??0;if(i<s)return-1;if(i>s)return 1}return 0},br=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0,c=o+a+i;r[n-1-s]=c>>>0,i=c>4294967295?1:0}return i&&r.unshift(1),r},mT=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0;o-=i,o<a?(o+=4294967296,i=1):i=0,r[n-1-s]=o-a>>>0}for(;r.length>1&&r[0]===0;)r.shift();return r},VU=(t,e)=>br(t,e),lE=(t,e)=>{let n=[];for(let r of t){let i=r.childAddress,s=r.length,o=br(i,s);if(Lt(e,i)>=0&&Lt(e,o)<0){let a=mT(e,i),c=r.parentAddress,l=VU(c,a),u=br(c,s);n.push({start:l,end:u,range:ar(r.rangeTokens.start,r.rangeTokens.end),fsPath:r.rangeTokens.start.fsPath})}}return n};function uE(t){return Array.isArray(t)&&Array.isArray(t[0])}function Hc(t){return!t||t instanceof Ut?t:Hc(t.parentNode)}function ds(t,e){let n=t.getText(),r=e.slice().sort((s,o)=>{let a=t.offsetAt(s.range.start),c=t.offsetAt(o.range.start);if(a!==c)return c-a;let l=t.offsetAt(s.range.end),u=t.offsetAt(o.range.end);if(l!==u)return u-l;let d=a===l&&s.newText.length>0,f=c===u&&o.newText.length>0;return d!==f?d?1:-1:0}),i=n;for(let s of r){let o=t.offsetAt(s.range.start),a=t.offsetAt(s.range.end);i=i.slice(0,o)+s.newText+i.slice(a)}return i}function eE(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}function dE(t,e){return eE(t.end,e.start)>0&&eE(t.start,e.end)<0}var fE=(t,e)=>{let n=pE(t,e),r=hE(t,e);n&&(t.topComment=n),r&&(t.endComment=r)},pE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.lastToken===t.firstToken.prevToken&&(i.lastToken.pos.line===t.firstToken.pos.line||i.lastToken.pos.line+1===t.firstToken.pos.line));if(!n||n.astBeforeComment)return;n.astAfterComment=t;let r=pE(n,e);return r&&(r.astAfterComment=t,n.astAfterComment=void 0),r??n},hE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.firstToken.prevToken===t.lastToken&&i.firstToken.pos.line===t.lastToken.pos.line);if(!n)return;n.astBeforeComment=t;let r=hE(n,e);return r&&(r.astBeforeComment=t,n.astBeforeComment=void 0),r??n},io=(t,e,n)=>{let r=[42,44,45,36];return n||r.push(52,32,53,8,49),t.severity===cn.DiagnosticSeverity.Error&&he(t.fsPath,e)&&!r.some(i=>t.issues.includes(i))};function qf(t){let e=t?.charAt(0);return!!e&&(e>="A"&&e<="Z"||e>="a"&&e<="z")}var $f=t=>{if(t)return t instanceof Ue?t:$f(t?.parentNode)},so=(t,e,n=0)=>{if(!e||!e.parentNode?.fsPath)return n;let r=$f(e.parentNode);return so(t,r,n+1)};function mE(t,e,n,r){let i=n-e,s=r.length,o=t.length-i+s,a=new Array(o),c=0;for(let l=0;l<e;l++,c++)a[c]=t[l];for(let l=0;l<s;l++,c++)a[c]=r[l];for(let l=n;l<t.length;l++,c++)a[c]=t[l];return a}var nl=require("fs"),Sa=require("path"),lo=q(j());var oD=require("path"),Sr=q(j());var Dn=class extends te{constructor(n,r,i,s){super();this.startLabels=n;this.value=r;this.endLabels=i;this.bits=s;this.startLabels.forEach(o=>{this.addChild(o)}),this.addChild(s),this.addChild(r),this.endLabels.forEach(o=>{this.addChild(o)})}toString(){return`${[this.value?.toString()??"NULL",...this.endLabels.map(n=>n.toString())].join(" ")}`}toPrettyString(n){return`${[this.value?.toPrettyString(n)??"NULL",...this.endLabels.map(r=>r.toString())].join(" ")}`}toJson(){return this.value?.toJson()}};var Kt=t=>t instanceof En?!0:t instanceof Ue?!1:t.parentNode?Kt(t.parentNode):!1;var gT=t=>{if(t instanceof je)return t;if(!(t instanceof Ue))return t.parentNode?gT(t.parentNode):void 0},oo=t=>!t||t instanceof je?!1:t instanceof Dn||oo(t.parentNode),pa=t=>[...t.map(e=>{if(e instanceof He||e instanceof Tt)return e.name;if(e instanceof Et)return e.reference})].filter(e=>!!e),yT=(t,e)=>e?e.parentNode===t||yT(t,e.parentNode):!1;var Ot=q(j());var gE=q(j());var Gr=class extends te{constructor(){super();this._pathParts=[]}addPath(n,r){this._pathParts.push(n),r&&this.addChild(r),this.addChild(n)}get pathParts(){return[...this._pathParts]}toString(){return this._pathParts.map(n=>n?.toString()??"<NULL>").join("/")}buildSemanticTokens(n){this._children.forEach(r=>{r instanceof xe?r.buildSemanticTokens(n):n(xi("operator"),Li("declaration"),r.firstToken,r.lastToken)})}},ot=class extends te{constructor(n){super();this.path=n;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:gE.SymbolKind.Namespace},this.addChild(n)}toString(){return`&${this.path?.toString()??"NULL"}`}toJson(){return-1}serialize(){let n=this.path?.toString();return{type:"NODE_PATH",nodePath:n==="/"?n:`/${n??""}`,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Y=class{constructor(e,n,r="optional",i=void 0,s,o){this.name=e;this.type=n;this.def=i;this.additionalTypeCheck=o;this.hideAutoComplete=!1;this.list=!1;this.onHover=()=>({kind:Ot.MarkupKind.Markdown,value:["### Type","**DTS native type** ",`${this.type.map(e=>e.types.join(" or ")).join(",")}
182
+ deps: ${n}}`};var k9={keyword:"dependencies",type:"object",schemaType:"object",error:Ei.error,code(t){let[e,n]=P9(t);f$(t,e),p$(t,n)}};function P9({schema:t}){let e={},n={};for(let r in t){if(r==="__proto__")continue;let i=Array.isArray(t[r])?e:n;i[r]=t[r]}return[e,n]}function f$(t,e=t.schema){let{gen:n,data:r,it:i}=t;if(Object.keys(e).length===0)return;let s=n.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,qu.propertyInData)(n,r,o,i.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors?n.if(c,()=>{for(let l of a)(0,qu.checkReportMissingProp)(t,l)}):(n.if((0,pS._)`${c} && (${(0,qu.checkMissingProp)(t,a,s)})`),(0,qu.reportMissingProp)(t,s),n.else())}}Ei.validatePropertyDeps=f$;function p$(t,e=t.schema){let{gen:n,data:r,keyword:i,it:s}=t,o=n.name("valid");for(let a in e)(0,S9.alwaysValidSchema)(s,e[a])||(n.if((0,qu.propertyInData)(n,r,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>n.var(o,!0)),t.ok(o))}Ei.validateSchemaDeps=p$;Ei.default=k9});var m$=N(hS=>{"use strict";Object.defineProperty(hS,"__esModule",{value:!0});var h$=be(),N9=Ne(),R9={message:"property name must be valid",params:({params:t})=>(0,h$._)`{propertyName: ${t.propertyName}}`},w9={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:R9,code(t){let{gen:e,schema:n,data:r,it:i}=t;if((0,N9.alwaysValidSchema)(i,n))return;let s=e.name("valid");e.forIn("key",r,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,h$.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};hS.default=w9});var gS=N(mS=>{"use strict";Object.defineProperty(mS,"__esModule",{value:!0});var zm=Or(),ci=be(),E9=Ir(),Gm=Ne(),C9={message:"must NOT have additional properties",params:({params:t})=>(0,ci._)`{additionalProperty: ${t.additionalProperty}}`},D9={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:C9,code(t){let{gen:e,schema:n,parentSchema:r,data:i,errsCount:s,it:o}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,Gm.alwaysValidSchema)(o,n))return;let l=(0,zm.allSchemaProperties)(r.properties),u=(0,zm.allSchemaProperties)(r.patternProperties);d(),t.ok((0,ci._)`${s} === ${E9.default.errors}`);function d(){e.forIn("key",i,y=>{!l.length&&!u.length?m(y):e.if(f(y),()=>m(y))})}function f(y){let _;if(l.length>8){let v=(0,Gm.schemaRefOrVal)(o,r.properties,"properties");_=(0,zm.isOwnProperty)(e,v,y)}else l.length?_=(0,ci.or)(...l.map(v=>(0,ci._)`${y} === ${v}`)):_=ci.nil;return u.length&&(_=(0,ci.or)(_,...u.map(v=>(0,ci._)`${(0,zm.usePattern)(t,v)}.test(${y})`))),(0,ci.not)(_)}function p(y){e.code((0,ci._)`delete ${i}[${y}]`)}function m(y){if(c.removeAdditional==="all"||c.removeAdditional&&n===!1){p(y);return}if(n===!1){t.setParams({additionalProperty:y}),t.error(),a||e.break();return}if(typeof n=="object"&&!(0,Gm.alwaysValidSchema)(o,n)){let _=e.name("valid");c.removeAdditional==="failing"?(h(y,_,!1),e.if((0,ci.not)(_),()=>{t.reset(),p(y)})):(h(y,_),a||e.if((0,ci.not)(_),()=>e.break()))}}function h(y,_,v){let b={keyword:"additionalProperties",dataProp:y,dataPropType:Gm.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,_)}}};mS.default=D9});var T$=N(TS=>{"use strict";Object.defineProperty(TS,"__esModule",{value:!0});var A9=Su(),g$=Or(),yS=Ne(),y$=gS(),I9={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:n,parentSchema:r,data:i,it:s}=t;s.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&y$.default.code(new A9.KeywordCxt(s,y$.default,"additionalProperties"));let o=(0,g$.allSchemaProperties)(n);for(let d of o)s.definedProperties.add(d);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=yS.mergeEvaluated.props(e,(0,yS.toHash)(o),s.props));let a=o.filter(d=>!(0,yS.alwaysValidSchema)(s,n[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,g$.propertyInData)(e,i,d,s.opts.ownProperties)),u(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return s.opts.useDefaults&&!s.compositeRule&&n[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};TS.default=I9});var S$=N(vS=>{"use strict";Object.defineProperty(vS,"__esModule",{value:!0});var v$=Or(),Km=be(),b$=Ne(),_$=Ne(),O9={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:n,data:r,parentSchema:i,it:s}=t,{opts:o}=s,a=(0,v$.allSchemaProperties)(n),c=a.filter(h=>(0,b$.alwaysValidSchema)(s,n[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&i.properties,u=e.name("valid");s.props!==!0&&!(s.props instanceof Km.Name)&&(s.props=(0,_$.evaluatedPropsToName)(e,s.props));let{props:d}=s;f();function f(){for(let h of a)l&&p(h),s.allErrors?m(h):(e.var(u,!0),m(h),e.if(u))}function p(h){for(let y in l)new RegExp(h).test(y)&&(0,b$.checkStrictMode)(s,`property ${y} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",r,y=>{e.if((0,Km._)`${(0,v$.usePattern)(t,h)}.test(${y})`,()=>{let _=c.includes(h);_||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:y,dataPropType:_$.Type.Str},u),s.opts.unevaluated&&d!==!0?e.assign((0,Km._)`${d}[${y}]`,!0):!_&&!s.allErrors&&e.if((0,Km.not)(u),()=>e.break())})})}}};vS.default=O9});var k$=N(bS=>{"use strict";Object.defineProperty(bS,"__esModule",{value:!0});var M9=Ne(),x9={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:n,it:r}=t;if((0,M9.alwaysValidSchema)(r,n)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};bS.default=x9});var P$=N(_S=>{"use strict";Object.defineProperty(_S,"__esModule",{value:!0});var L9=Or(),q9={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:L9.validateUnion,error:{message:"must match a schema in anyOf"}};_S.default=q9});var N$=N(SS=>{"use strict";Object.defineProperty(SS,"__esModule",{value:!0});var Ym=be(),$9=Ne(),F9={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ym._)`{passingSchemas: ${t.passing}}`},B9={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:F9,code(t){let{gen:e,schema:n,parentSchema:r,it:i}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(i.opts.discriminator&&r.discriminator)return;let s=n,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(o,()=>t.reset(),()=>t.error(!0));function l(){s.forEach((u,d)=>{let f;(0,$9.alwaysValidSchema)(i,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Ym._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Ym._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Ym.Name)})})}}};SS.default=B9});var R$=N(kS=>{"use strict";Object.defineProperty(kS,"__esModule",{value:!0});var j9=Ne(),U9={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:n,it:r}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");let i=e.name("valid");n.forEach((s,o)=>{if((0,j9.alwaysValidSchema)(r,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};kS.default=U9});var C$=N(PS=>{"use strict";Object.defineProperty(PS,"__esModule",{value:!0});var Xm=be(),E$=Ne(),H9={message:({params:t})=>(0,Xm.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Xm._)`{failingKeyword: ${t.ifClause}}`},V9={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:H9,code(t){let{gen:e,parentSchema:n,it:r}=t;n.then===void 0&&n.else===void 0&&(0,E$.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let i=w$(r,"then"),s=w$(r,"else");if(!i&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),i&&s){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else i?e.if(a,l("then")):e.if((0,Xm.not)(a),l("else"));t.pass(o,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(o,a),t.mergeValidEvaluated(f,o),d?e.assign(d,(0,Xm._)`${u}`):t.setParams({ifClause:u})}}}};function w$(t,e){let n=t.schema[e];return n!==void 0&&!(0,E$.alwaysValidSchema)(t,n)}PS.default=V9});var D$=N(NS=>{"use strict";Object.defineProperty(NS,"__esModule",{value:!0});var W9=Ne(),z9={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){e.if===void 0&&(0,W9.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};NS.default=z9});var A$=N(RS=>{"use strict";Object.defineProperty(RS,"__esModule",{value:!0});var G9=cS(),K9=c$(),Y9=lS(),X9=u$(),J9=d$(),Q9=Wm(),Z9=m$(),eJ=gS(),tJ=T$(),nJ=S$(),rJ=k$(),iJ=P$(),sJ=N$(),oJ=R$(),aJ=C$(),cJ=D$();function lJ(t=!1){let e=[rJ.default,iJ.default,sJ.default,oJ.default,aJ.default,cJ.default,Z9.default,eJ.default,Q9.default,tJ.default,nJ.default];return t?e.push(K9.default,X9.default):e.push(G9.default,Y9.default),e.push(J9.default),e}RS.default=lJ});var I$=N(wS=>{"use strict";Object.defineProperty(wS,"__esModule",{value:!0});var Ft=be(),uJ={message:({schemaCode:t})=>(0,Ft.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ft._)`{format: ${t}}`},dJ={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:uJ,code(t,e){let{gen:n,data:r,$data:i,schema:s,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;i?f():p();function f(){let m=n.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=n.const("fDef",(0,Ft._)`${m}[${o}]`),y=n.let("fType"),_=n.let("format");n.if((0,Ft._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>n.assign(y,(0,Ft._)`${h}.type || "string"`).assign(_,(0,Ft._)`${h}.validate`),()=>n.assign(y,(0,Ft._)`"string"`).assign(_,h)),t.fail$data((0,Ft.or)(v(),b()));function v(){return c.strictSchema===!1?Ft.nil:(0,Ft._)`${o} && !${_}`}function b(){let P=u.$async?(0,Ft._)`(${h}.async ? await ${_}(${r}) : ${_}(${r}))`:(0,Ft._)`${_}(${r})`,E=(0,Ft._)`(typeof ${_} == "function" ? ${P} : ${_}.test(${r}))`;return(0,Ft._)`${_} && ${_} !== true && ${y} === ${e} && !${E}`}}function p(){let m=d.formats[s];if(!m){v();return}if(m===!0)return;let[h,y,_]=b(m);h===e&&t.pass(P());function v(){if(c.strictSchema===!1){d.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function b(E){let H=E instanceof RegExp?(0,Ft.regexpCode)(E):c.code.formats?(0,Ft._)`${c.code.formats}${(0,Ft.getProperty)(s)}`:void 0,O=n.scopeValue("formats",{key:s,ref:E,code:H});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,Ft._)`${O}.validate`]:["string",E,O]}function P(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Ft._)`await ${_}(${r})`}return typeof y=="function"?(0,Ft._)`${_}(${r})`:(0,Ft._)`${_}.test(${r})`}}}};wS.default=dJ});var O$=N(ES=>{"use strict";Object.defineProperty(ES,"__esModule",{value:!0});var fJ=I$(),pJ=[fJ.default];ES.default=pJ});var M$=N(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.contentVocabulary=uc.metadataVocabulary=void 0;uc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];uc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var L$=N(CS=>{"use strict";Object.defineProperty(CS,"__esModule",{value:!0});var hJ=Vq(),mJ=i$(),gJ=A$(),yJ=O$(),x$=M$(),TJ=[hJ.default,mJ.default,(0,gJ.default)(),yJ.default,x$.metadataVocabulary,x$.contentVocabulary];CS.default=TJ});var AS=N($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});$u.dynamicAnchor=void 0;var DS=be(),vJ=Ir(),q$=Pu(),bJ=Fm(),_J={keyword:"$dynamicAnchor",schemaType:"string",code:t=>$$(t,t.schema)};function $$(t,e){let{gen:n,it:r}=t;r.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,DS._)`${vJ.default.dynamicAnchors}${(0,DS.getProperty)(e)}`,s=r.errSchemaPath==="#"?r.validateName:SJ(t);n.if((0,DS._)`!${i}`,()=>n.assign(i,s))}$u.dynamicAnchor=$$;function SJ(t){let{schemaEnv:e,schema:n,self:r}=t.it,{root:i,baseId:s,localRefs:o,meta:a}=e.root,{schemaId:c}=r.opts,l=new q$.SchemaEnv({schema:n,schemaId:c,root:i,baseId:s,localRefs:o,meta:a});return q$.compileSchema.call(r,l),(0,bJ.getValidate)(t,l)}$u.default=_J});var IS=N(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.dynamicRef=void 0;var F$=be(),kJ=Ir(),B$=Fm(),PJ={keyword:"$dynamicRef",schemaType:"string",code:t=>j$(t,t.schema)};function j$(t,e){let{gen:n,keyword:r,it:i}=t;if(e[0]!=="#")throw new Error(`"${r}" only supports hash fragment reference`);let s=e.slice(1);if(i.allErrors)o();else{let c=n.let("valid",!1);o(c),t.ok(c)}function o(c){if(i.schemaEnv.root.dynamicAnchors[s]){let l=n.let("_v",(0,F$._)`${kJ.default.dynamicAnchors}${(0,F$.getProperty)(s)}`);n.if(l,a(l,c),a(i.validateName,c))}else a(i.validateName,c)()}function a(c,l){return l?()=>n.block(()=>{(0,B$.callRef)(t,c),n.let(l,!0)}):()=>(0,B$.callRef)(t,c)}}Fu.dynamicRef=j$;Fu.default=PJ});var U$=N(OS=>{"use strict";Object.defineProperty(OS,"__esModule",{value:!0});var NJ=AS(),RJ=Ne(),wJ={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,NJ.dynamicAnchor)(t,""):(0,RJ.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};OS.default=wJ});var H$=N(MS=>{"use strict";Object.defineProperty(MS,"__esModule",{value:!0});var EJ=IS(),CJ={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,EJ.dynamicRef)(t,t.schema)};MS.default=CJ});var V$=N(xS=>{"use strict";Object.defineProperty(xS,"__esModule",{value:!0});var DJ=AS(),AJ=IS(),IJ=U$(),OJ=H$(),MJ=[DJ.default,AJ.default,IJ.default,OJ.default];xS.default=MJ});var z$=N(LS=>{"use strict";Object.defineProperty(LS,"__esModule",{value:!0});var W$=Wm(),xJ={keyword:"dependentRequired",type:"object",schemaType:"object",error:W$.error,code:t=>(0,W$.validatePropertyDeps)(t)};LS.default=xJ});var G$=N(qS=>{"use strict";Object.defineProperty(qS,"__esModule",{value:!0});var LJ=Wm(),qJ={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,LJ.validateSchemaDeps)(t)};qS.default=qJ});var K$=N($S=>{"use strict";Object.defineProperty($S,"__esModule",{value:!0});var $J=Ne(),FJ={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:n}){e.contains===void 0&&(0,$J.checkStrictMode)(n,`"${t}" without "contains" is ignored`)}};$S.default=FJ});var Y$=N(FS=>{"use strict";Object.defineProperty(FS,"__esModule",{value:!0});var BJ=z$(),jJ=G$(),UJ=K$(),HJ=[BJ.default,jJ.default,UJ.default];FS.default=HJ});var J$=N(BS=>{"use strict";Object.defineProperty(BS,"__esModule",{value:!0});var Fs=be(),X$=Ne(),VJ=Ir(),WJ={message:"must NOT have unevaluated properties",params:({params:t})=>(0,Fs._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},zJ={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:WJ,code(t){let{gen:e,schema:n,data:r,errsCount:i,it:s}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:o,props:a}=s;a instanceof Fs.Name?e.if((0,Fs._)`${a} !== true`,()=>e.forIn("key",r,d=>e.if(l(a,d),()=>c(d)))):a!==!0&&e.forIn("key",r,d=>a===void 0?c(d):e.if(u(a,d),()=>c(d))),s.props=!0,t.ok((0,Fs._)`${i} === ${VJ.default.errors}`);function c(d){if(n===!1){t.setParams({unevaluatedProperty:d}),t.error(),o||e.break();return}if(!(0,X$.alwaysValidSchema)(s,n)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:X$.Type.Str},f),o||e.if((0,Fs.not)(f),()=>e.break())}}function l(d,f){return(0,Fs._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let m in d)d[m]===!0&&p.push((0,Fs._)`${f} !== ${m}`);return(0,Fs.and)(...p)}}};BS.default=zJ});var Z$=N(jS=>{"use strict";Object.defineProperty(jS,"__esModule",{value:!0});var Lo=be(),Q$=Ne(),GJ={message:({params:{len:t}})=>(0,Lo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Lo._)`{limit: ${t}}`},KJ={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:GJ,code(t){let{gen:e,schema:n,data:r,it:i}=t,s=i.items||0;if(s===!0)return;let o=e.const("len",(0,Lo._)`${r}.length`);if(n===!1)t.setParams({len:s}),t.fail((0,Lo._)`${o} > ${s}`);else if(typeof n=="object"&&!(0,Q$.alwaysValidSchema)(i,n)){let c=e.var("valid",(0,Lo._)`${o} <= ${s}`);e.if((0,Lo.not)(c),()=>a(c,s)),t.ok(c)}i.items=!0;function a(c,l){e.forRange("i",l,o,u=>{t.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:Q$.Type.Num},c),i.allErrors||e.if((0,Lo.not)(c),()=>e.break())})}}};jS.default=KJ});var eF=N(US=>{"use strict";Object.defineProperty(US,"__esModule",{value:!0});var YJ=J$(),XJ=Z$(),JJ=[YJ.default,XJ.default];US.default=JJ});var nF=N(Jm=>{"use strict";Object.defineProperty(Jm,"__esModule",{value:!0});Jm.DiscrError=void 0;var tF;(function(t){t.Tag="tag",t.Mapping="mapping"})(tF||(Jm.DiscrError=tF={}))});var iF=N(VS=>{"use strict";Object.defineProperty(VS,"__esModule",{value:!0});var dc=be(),HS=nF(),rF=Pu(),QJ=ku(),ZJ=Ne(),e6={message:({params:{discrError:t,tagName:e}})=>t===HS.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>(0,dc._)`{error: ${t}, tag: ${n}, tagValue: ${e}}`},t6={keyword:"discriminator",type:"object",schemaType:"object",error:e6,code(t){let{gen:e,data:n,schema:r,parentSchema:i,it:s}=t,{oneOf:o}=i;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=r.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,dc._)`${n}${(0,dc.getProperty)(a)}`);e.if((0,dc._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:HS.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,dc._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:HS.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(h,dc.Name),m}function f(){var p;let m={},h=_(i),y=!0;for(let P=0;P<o.length;P++){let E=o[P];if(E?.$ref&&!(0,ZJ.schemaHasRulesButRef)(E,s.self.RULES)){let O=E.$ref;if(E=rF.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,O),E instanceof rF.SchemaEnv&&(E=E.schema),E===void 0)throw new QJ.default(s.opts.uriResolver,s.baseId,O)}let H=(p=E?.properties)===null||p===void 0?void 0:p[a];if(typeof H!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(h||_(E)),v(H,P)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return m;function _({required:P}){return Array.isArray(P)&&P.includes(a)}function v(P,E){if(P.const)b(P.const,E);else if(P.enum)for(let H of P.enum)b(H,E);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(P,E){if(typeof P!="string"||P in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[P]=E}}}};VS.default=t6});var sF=N((nEe,n6)=>{n6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/schema",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format"},{$ref:"meta/content"}],type:["object","boolean"],properties:{definitions:{$comment:"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},dependencies:{$comment:'"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"',type:"object",additionalProperties:{anyOf:[{$recursiveRef:"#"},{$ref:"meta/validation#/$defs/stringArray"}]}}}}});var oF=N((rEe,r6)=>{r6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{additionalItems:{$recursiveRef:"#"},unevaluatedItems:{$recursiveRef:"#"},items:{anyOf:[{$recursiveRef:"#"},{$ref:"#/$defs/schemaArray"}]},contains:{$recursiveRef:"#"},additionalProperties:{$recursiveRef:"#"},unevaluatedProperties:{$recursiveRef:"#"},properties:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$recursiveRef:"#"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$recursiveRef:"#"}},propertyNames:{$recursiveRef:"#"},if:{$recursiveRef:"#"},then:{$recursiveRef:"#"},else:{$recursiveRef:"#"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$recursiveRef:"#"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$recursiveRef:"#"}}}}});var aF=N((iEe,i6)=>{i6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/content",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentMediaType:{type:"string"},contentEncoding:{type:"string"},contentSchema:{$recursiveRef:"#"}}}});var cF=N((sEe,s6)=>{s6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/core",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{type:"string",format:"uri"},$anchor:{type:"string",pattern:"^[A-Za-z][-A-Za-z0-9.:_]*$"},$ref:{type:"string",format:"uri-reference"},$recursiveRef:{type:"string",format:"uri-reference"},$recursiveAnchor:{type:"boolean",default:!1},$vocabulary:{type:"object",propertyNames:{type:"string",format:"uri"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}}}}});var lF=N((oEe,o6)=>{o6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/format",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:"Format vocabulary meta-schema",type:["object","boolean"],properties:{format:{type:"string"}}}});var uF=N((aEe,a6)=>{a6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var dF=N((cEe,c6)=>{c6.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/validation",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}},const:!0,enum:{type:"array",items:!0},type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var fF=N(WS=>{"use strict";Object.defineProperty(WS,"__esModule",{value:!0});var l6=sF(),u6=oF(),d6=aF(),f6=cF(),p6=lF(),h6=uF(),m6=dF(),g6=["/properties"];function y6(t){return[l6,u6,d6,f6,e(this,p6),h6,e(this,m6)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function e(n,r){return t?n.$dataMetaSchema(r,g6):r}}WS.default=y6});var pF=N((St,GS)=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.MissingRefError=St.ValidationError=St.CodeGen=St.Name=St.nil=St.stringify=St.str=St._=St.KeywordCxt=St.Ajv2019=void 0;var T6=Fq(),v6=L$(),b6=V$(),_6=Y$(),S6=eF(),k6=iF(),P6=fF(),zS="https://json-schema.org/draft/2019-09/schema",fc=class extends T6.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(b6.default),v6.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(_6.default),this.addVocabulary(S6.default),this.opts.discriminator&&this.addKeyword(k6.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:n}=this.opts;n&&(P6.default.call(this,e),this.refs["http://json-schema.org/schema"]=zS)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(zS)?zS:void 0)}};St.Ajv2019=fc;GS.exports=St=fc;GS.exports.Ajv2019=fc;Object.defineProperty(St,"__esModule",{value:!0});St.default=fc;var N6=Su();Object.defineProperty(St,"KeywordCxt",{enumerable:!0,get:function(){return N6.KeywordCxt}});var pc=be();Object.defineProperty(St,"_",{enumerable:!0,get:function(){return pc._}});Object.defineProperty(St,"str",{enumerable:!0,get:function(){return pc.str}});Object.defineProperty(St,"stringify",{enumerable:!0,get:function(){return pc.stringify}});Object.defineProperty(St,"nil",{enumerable:!0,get:function(){return pc.nil}});Object.defineProperty(St,"Name",{enumerable:!0,get:function(){return pc.Name}});Object.defineProperty(St,"CodeGen",{enumerable:!0,get:function(){return pc.CodeGen}});var R6=Am();Object.defineProperty(St,"ValidationError",{enumerable:!0,get:function(){return R6.default}});var w6=ku();Object.defineProperty(St,"MissingRefError",{enumerable:!0,get:function(){return w6.default}})});var gc=require("path"),Be=q(Vw());var Cf=class t{constructor(e,n,r,i){this._uri=e,this._languageId=n,this._version=r,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 n=this.offsetAt(e.start),r=this.offsetAt(e.end);return this._content.substring(n,r)}return this._content}update(e,n){for(let r of e)if(t.isIncremental(r)){let i=zw(r.range),s=this.offsetAt(i.start),o=this.offsetAt(i.end);this._content=this._content.substring(0,s)+r.text+this._content.substring(o,this._content.length);let a=Math.max(i.start.line,0),c=Math.max(i.end.line,0),l=this._lineOffsets,u=Ww(r.text,!1,s);if(c-a===u.length)for(let f=0,p=u.length;f<p;f++)l[f+a+1]=u[f];else u.length<1e4?l.splice(a+1,c-a,...u):this._lineOffsets=l=l.slice(0,a+1).concat(u,l.slice(c+1));let d=r.text.length-(o-s);if(d!==0)for(let f=a+1+u.length,p=l.length;f<p;f++)l[f]=l[f]+d}else if(t.isFull(r))this._content=r.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=n}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=Ww(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let n=this.getLineOffsets(),r=0,i=n.length;if(i===0)return{line:0,character:e};for(;r<i;){let o=Math.floor((r+i)/2);n[o]>e?i=o:r=o+1}let s=r-1;return{line:s,character:e-n[s]}}offsetAt(e){let n=this.getLineOffsets();if(e.line>=n.length)return this._content.length;if(e.line<0)return 0;let r=n[e.line],i=e.line+1<n.length?n[e.line+1]:this._content.length;return Math.max(Math.min(r+e.character,i),r)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let n=e;return n!=null&&typeof n.text=="string"&&n.range!==void 0&&(n.rangeLength===void 0||typeof n.rangeLength=="number")}static isFull(e){let n=e;return n!=null&&typeof n.text=="string"&&n.range===void 0&&n.rangeLength===void 0}},Vn;(function(t){function e(i,s,o,a){return new Cf(i,s,o,a)}t.create=e;function n(i,s,o){if(i instanceof Cf)return i.update(s,o),i;throw new Error("TextDocument.update: document must be created by TextDocument.create")}t.update=n;function r(i,s){let o=i.getText(),a=oT(s.map(OU),(u,d)=>{let f=u.range.start.line-d.range.start.line;return f===0?u.range.start.character-d.range.start.character:f}),c=0,l=[];for(let u of a){let d=i.offsetAt(u.range.start);if(d<c)throw new Error("Overlapping edit");d>c&&l.push(o.substring(c,d)),u.newText.length&&l.push(u.newText),c=i.offsetAt(u.range.end)}return l.push(o.substr(c)),l.join("")}t.applyEdits=r})(Vn||(Vn={}));function oT(t,e){if(t.length<=1)return t;let n=t.length/2|0,r=t.slice(0,n),i=t.slice(n);oT(r,e),oT(i,e);let s=0,o=0,a=0;for(;s<r.length&&o<i.length;)e(r[s],i[o])<=0?t[a++]=r[s++]:t[a++]=i[o++];for(;s<r.length;)t[a++]=r[s++];for(;o<i.length;)t[a++]=i[o++];return t}function Ww(t,e,n=0){let r=e?[n]:[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);(s===13||s===10)&&(s===13&&i+1<t.length&&t.charCodeAt(i+1)===10&&i++,r.push(n+i+1))}return r}function zw(t){let e=t.start,n=t.end;return e.line>n.line||e.line===n.line&&e.character>n.character?{start:n,end:e}:t}function OU(t){let e=zw(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var Df=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],Af=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var lT=q(require("url")),tE=require("crypto"),fa=require("path"),cn=q(j());var aT=q(j());var Wn=q(j());var te=class{constructor(e){this._children=[];this.syntaxIssues=[];this.resettableIssues=[];this._firstToken=e?.start,this._lastToken=e?.end}get issues(){return[...this.syntaxIssues,...this.resettableIssues]}resetIssues(){this.resettableIssues=[],this.children.forEach(e=>e.resetIssues())}get serializeIssues(){return this.issues.map(e=>e())}get firstToken(){return this._firstToken??this._children[0].firstToken}set firstToken(e){this._firstToken=e}get lastToken(){return this._lastToken??this._children[this._children.length-1]?.lastToken??this.firstToken}set lastToken(e){this._lastToken=e}get fsPath(){return this.firstToken.fsPath}getTopMostAstNodeForFile(e){return pe(e,this.fsPath)?[this]:this.children.flatMap(n=>n.getTopMostAstNodeForFile(e))}getDocumentSymbols(e){if(!this.docSymbolsMeta)return this.children.flatMap(r=>r.getDocumentSymbols(e)??[]);if(!pe(this.fsPath,e))return[];let n=ce(this);return[{name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind,range:n,selectionRange:n,children:[...this.children.flatMap(r=>r.getDocumentSymbols(e)??[])]}]}getWorkspaceSymbols(){if(!this.docSymbolsMeta)return this.children.flatMap(i=>i.getWorkspaceSymbols()??[]);let e=this.docSymbolsMeta.kind;if(![Wn.SymbolKind.File,Wn.SymbolKind.Class,Wn.SymbolKind.Constant].some(i=>i===e))return[];let n=zn(this.fsPath),r=n?.range??ce(this);return[{location:Wn.Location.create(ue(n?.docFsPath??this.fsPath),r),name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind},...this.children.flatMap(i=>i.getWorkspaceSymbols()??[]).filter(i=>i.kind===Wn.SymbolKind.File||i.kind===Wn.SymbolKind.Class||i.kind===Wn.SymbolKind.Constant)]}buildSemanticTokens(e){this._children.forEach(n=>n.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(xi(this.semanticTokenType),Li(this.semanticTokenModifiers),this.firstToken,this.lastToken)}get children(){return this._children}get allDescendants(){return this.allDescendantsCache??=[...this._children,...this._children.flatMap(e=>e.allDescendants)],this.allDescendantsCache}addChild(e){e&&(e.parentNode=this,this._children.push(e)),this.allDescendantsCache=void 0}isAncestorOf(e){return this.children.some(n=>n===e||n.isAncestorOf(e))}toPrettyString(e){return this.toString()}toString(e){return"TODO"}get range(){return Wn.Range.create(Wn.Position.create(this.firstToken.pos.line,this.firstToken.pos.col),Wn.Position.create(this.lastToken.pos.line,this.lastToken.pos.colEnd))}get serializeURL(){return ue(this.fsPath)}serialize(e){return{url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var ge=class extends te{get firstToken(){return this.operator?this.operator.firstToken:super.firstToken}toJson(){return-1}#e;resolve(e){return this.#e??=$c(this.toString(),e),this.#e}#n;evaluate(e){return this.#n??=De(`${this.operator?this.operator.toString():""}${this.resolve(e)}`),this.#n}#r;isTrue(e){return this.#r??=De(`!!(${this.operator?this.operator.toString():""}${this.resolve(e)})`),typeof this.#r=="boolean"&&this.#r}toPrettyString(e){let n=this.evaluate(e);return`${n.toString()} /* ${this.toString()}${typeof n=="number"?` = 0x${n.toString(16)}`:""} */`}serialize(e){return{type:"EXPRESSION",value:this.toString(),evaluated:this.evaluate(e),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},Qt=class t extends ge{constructor(n,r,i){super();this.expression=n;this.wrapped=r;this.addChild(n),i&&(this.addChild(i.operator),this.addChild(i.expression),this.join=[],this.join?.push(i))}get firstToken(){return this.openBracket?this.openBracket:super.firstToken}get lastToken(){return this.closeBracket?this.closeBracket:super.lastToken}addExpression(n,r){this.addChild(n),this.addChild(r),this.join??=[],this.join?.push({operator:n,expression:r})}toString(){let n=this.children.map(r=>"radix"in r&&r.radix===16?`0x${r.toString()}`:r.toString()).join(" ");return this.wrapped?`(${n})`:`${n}`}isTrue(n){let r=`(${this.children.map(i=>i instanceof ge?i.resolve(n):i.toString()).join(" ")})`;return De(`!!(${this.operator?this.operator.toString():""}${r})`)}get flatJoin(){return this.wrapped?this.join??(this.expression instanceof t?this.expression.flatJoin:[]):[...this.expression instanceof t?this.expression.flatJoin:[],...this.join?.flatMap(n=>[{operator:n.operator,expression:n.expression instanceof t?n.expression.expression:n.expression},...n.expression instanceof t?n.expression.flatJoin:[]])??[]]}};var hi=class extends ge{constructor(n,r,i){super(r);this.value=n;this.docSymbolsMeta={name:`param${i+1}`,kind:aT.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},Ut=class extends ge{constructor(n,r){super();this.functionName=n;this.params=r;this.addChild(n),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(n){return pe(this.fsPath,n)?[{name:this.functionName.name,kind:aT.SymbolKind.Function,range:ce(this),selectionRange:ce(this),children:this.params.flatMap(r=>r?.getDocumentSymbols(n)??[])}]:[]}toString(){return`${this.functionName.toString()}(${this.params.map(n=>n?.toString()??"").join(", ")})`}isTrue(n){if(this.functionName.name==="defined"){let r=!!(this.params.length===1&&this.params[0]&&n.has(this.params[0].value));return this.operator?De(`!!(${this.operator}${r})`):r}return super.isTrue(n)}};var Wr=q(j());var Jw=q(j());var Gw=q(j());var re=class extends te{constructor(n,r){super(r);this.value=n;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:Gw.SymbolKind.String}}toString(){return`"${this.value.toString()}"`}toJson(){return this.value}serialize(){return{type:"STRING",value:this.value,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Yw=q(j());var Kw=q(j());var Zt=class extends ge{constructor(n,r,i=10){super(r);this.value=n;this.radix=i;this.docSymbolsMeta={name:this.value.toString(),kind:Kw.SymbolKind.Number},this.semanticTokenType="number",this.semanticTokenModifiers="declaration"}resolve(n){return this.value.toString()}evaluate(n){return this.value}isTrue(n){return!!this.value}toString(n){return this.value.toString(n??this.radix)}toJson(){return this.value}toPrettyString(n){let r=this.value;return this.radix===16?`0x${r.toString(16)} /* ${typeof r=="number"?`${r.toString(10)}`:""} */`:`${r.toString(10)} /* ${typeof r=="number"?`0x${r.toString(16)}`:""} */`}serialize(){return{type:"NUMBER_VALUE",value:`${this.radix===16?"0x":""}${this.toString()}`,evaluated:this.value,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var gt=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Cell Array",kind:Yw.SymbolKind.Array},this.values.forEach(r=>this.addChild(r))}toString(){return`<${this.values.map(n=>n.toString()).join(" ")}>`}toPrettyString(n){return`<${this.values.map(r=>r.toPrettyString(n)).join(" ")}>`}toJson(){if(this.values.length===1)return this.values[0].value?.toJson();if(this.values.length===2&&this.values.every(n=>n.value instanceof Zt)){let n=new ArrayBuffer(8),r=new DataView(n);return this.values.map(i=>i.value.value).forEach((i,s)=>{r.setUint32(s*4,i)}),r.getBigUint64(0)}return this.values.map(n=>n.value?.toJson()??NaN)}serialize(n){return{type:"ARRAY_VALUE",value:this.values.map(r=>r.value?.serialize(n)??null),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Xw=q(j());var or=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Byte String Value",kind:Xw.SymbolKind.Array},this.values.forEach(r=>this.addChild(r))}toString(){return`[${this.values.map(n=>n.toString(16).padStart(2,"0")).join(" ")}]`}toJson(){return this.values.map(n=>n.value?.toJson()??NaN)}serialize(){return{type:"BYTESTRING",values:this.values.map(n=>n.value?.serialize()??null),url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Ye=class extends te{constructor(n,r){super(r);this.name=n;this.semanticTokenType="property",this.semanticTokenModifiers="declaration"}toString(){return this.name}serialize(){return{value:this.name,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},je=class extends te{constructor(n,r=[]){super();this.propertyName=n;this.labels=r;this._values=void 0;this.docSymbolsMeta={name:this.propertyName?.name??"Unknown",kind:Jw.SymbolKind.Property},this.labels.forEach(i=>this.addChild(i)),this.addChild(n)}set values(n){if(this._values)throw new Error("Only one property name is allowed");this._values=n,this.addChild(n)}get values(){return this._values}get quickValues(){return this.values?.values.map(n=>n?n.value instanceof re?n.value.value:n.value instanceof gt?n.value.values.map(r=>r.value instanceof Zt?r.value.value:NaN):n.value instanceof or?n.value.values.map(r=>r.value?.value??NaN):NaN:null)}getFlatAstValues(){return this.values?.values.flatMap(n=>n?n.value instanceof re?n.value:n.value instanceof gt?n.value.values.map(r=>r.value):n.value instanceof or?n.value.values.map(r=>r.value):n.value:null)}toString(){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(n=>n?.toString()??"NULL").join(", ")??"NULL"}`:""};`}toPrettyString(n,r){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(i=>i?.toPrettyString(n)??"NULL").join(r?`,
183
+ ${" ".repeat(r)}`:", ")??"NULL"}`:""};${ro(this.fsPath)?" /* default value from binding */":""}`}serialize(n){return{name:this.propertyName?.serialize()??null,values:this.values===void 0?void 0:this.values?.values.map(r=>r?.value?.serialize(n)??null)??null,url:this.serializeURL,range:this.range,issues:[...this.serializeIssues,...this.values?.issues.map(r=>r())??[]]}}};var Qw=q(j());var En=class extends te{constructor(n,r){super();this.keyword=r;this.addChild(r),this.docSymbolsMeta={name:n,kind:Qw.SymbolKind.Function}}};var Gn=class extends En{constructor(n){super("Delete Node",n);this._nodeNameOrRef=null}set nodeNameOrRef(n){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=n,this.addChild(n)}get nodeNameOrRef(){return this._nodeNameOrRef}};var yt=class extends En{constructor(n){super("Delete Property",n);this._propertyName=null}set propertyName(n){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=n,this.addChild(n)}get propertyName(){return this._propertyName}};var Zw=q(j());var ie=class extends te{constructor(n){super();this.label=n;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:Zw.SymbolKind.Key},this.addChild(n)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}serialize(){return{type:"LABEL_REF",label:this.label?.toString()??null,nodePath:this.linksTo?.pathString??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Ue=class t extends te{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof Tt)return[this.pathName];if(!(this.parentNode instanceof t))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof t)}get deleteNodes(){return this.children.filter(e=>e instanceof Gn)}addNodeChild(e){this.addChild(e)}},Tt=class extends Ue{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Wr.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof je)}#e;get name(){return this.#e??=new xe("/",de(this.firstToken)),this.#e}get identifierAst(){return this.name}get deleteProperties(){return this.children.filter(e=>e instanceof yt)}get nodes(){return this.children.filter(e=>e instanceof He)}get pathName(){return"/"}serialize(e){return{type:"ROOT",properties:this.properties.map(n=>n.serialize(e)),nodes:this.nodes.map(n=>n.serialize(e)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&ae(this.openScope),scopeClose:this.closeScope&&ae(this.closeScope,!1)}}},Et=class extends Ue{constructor(n=[]){super();this.labels=n;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Wr.SymbolKind.Class},n.forEach(r=>{super.addChild(r)})}get serializeIssues(){return[...this.issues,...this.reference?.issues??[]].map(n=>n())}get identifierAst(){return this.reference}set reference(n){if(this._reference)throw new Error("Only on label reference is allowed");this._reference=n;let r;n instanceof ie?r=n.value:r=n?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:r??"DTC Name",kind:Wr.SymbolKind.Class},this.addChild(n)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get reference(){return this._reference}get nodes(){return this.children.filter(n=>n instanceof He)}get pathName(){if(this.reference instanceof ie&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(n=>n instanceof je)}get deleteProperties(){return this.children.filter(n=>n instanceof yt)}serialize(n){return{type:"REF",labels:this.labels.map(r=>r.serialize(n)),name:this.reference?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&ae(this.openScope),scopeClose:this.closeScope&&ae(this.closeScope,!1)}}},He=class t extends Ue{constructor(n=[],r){super();this.labels=n;this.omitIfNoRef=r;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Wr.SymbolKind.Class},r&&this.addChild(r),n.forEach(i=>{this.addChild(i)})}get identifierAst(){return this.name}get serializeIssues(){return[...this.issues,...this.name?.issues??[]].map(n=>n())}set name(n){if(this._name)throw new Error("Only on label reference is allowed");this._name=n,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:Wr.SymbolKind.Class},this.addChild(n)}get name(){return this._name}get nodes(){return this.children.filter(n=>n instanceof t)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(n=>n instanceof je)}get deleteProperties(){return this.children.filter(n=>n instanceof yt)}serialize(n){return{type:"CHILD",labels:this.labels.map(r=>r.serialize(n)),name:this.name?.serialize()??null,properties:this.properties.map(r=>r.serialize(n)),nodes:this.nodes.map(r=>r.serialize(n)),url:this.serializeURL,range:this.range,issues:this.serializeIssues,scopeOpen:this.openScope&&ae(this.openScope),scopeClose:this.closeScope&&ae(this.closeScope,!1)}}},Fc=class extends te{constructor(n,r){super(r);this.address=n;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address?.map((n,r)=>n.toString(16).padStart(r?8:0,"0")).join("")??"NaN"}serialize(){return{address:this.address,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}},xe=class extends te{constructor(n,r,i){super(r);this.name=n;this._address=i;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(n){if(this._address)throw new Error("Address can only be set once");n&&(this.lastToken=void 0,this._address=n,n.forEach(r=>this.addChild(r)))}get fullAddress(){return this._address?[...this._address.flatMap(n=>n.address)]:void 0}toString(){return this._address!==void 0?`${this.name}@${this._address.map(n=>n.toString()).join(",")}`:this.name}buildSemanticTokens(n){let r=this.firstToken;if(!r.value)return;let i={...r,pos:{...r.pos,len:this.name.length}};n(xi("type"),Li("declaration"),i,i),this.address!==void 0&&this.address.forEach(s=>{n(xi("decorator"),Li("declaration"),s.firstToken,s.lastToken),s.buildSemanticTokens(n)})}get serializeIssues(){return[...this.issues,...this._address?.flatMap(n=>n.issues)??[]].map(n=>n())}serialize(){let n=this.firstToken;return{fullName:this.toString(),name:{name:this.name,url:this.serializeURL,range:Wr.Range.create(Wr.Position.create(n.pos.line,n.pos.col),Wr.Position.create(n.pos.line,n.pos.colEnd)),issues:this.serializeIssues},address:this.address?.map(r=>r.serialize())??null,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var ar=(t,e,n=!0,r=!0)=>({start:{line:t?.pos.line??0,character:n?t?.pos.col??0:(t?.pos.col??0)+(t?.pos.len??0)},end:{line:e?.pos.line??0,character:r?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var ae=(t,e=!0)=>cn.Position.create(t.pos.line,e?t.pos.colEnd:t.pos.col),ce=t=>ar(t.firstToken,t.lastToken),xi=t=>Df.findIndex(e=>e===t),Li=t=>Af.findIndex(e=>e===t),Bc=(t,e,n)=>!pe(t.fsPath,e)||n.line<t.pos.line?!1:n.line>t.pos.line?!0:n.character>=t.pos.colEnd,uT=(t,e,n)=>pe(t.fsPath,e)?n.line<t.pos.line?!0:n.line>t.pos.line?!1:n.character<t.pos.col:!1,Cn=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!((r.pos.line<n.line||r.pos.line===n.line&&r.pos.col<=n.character)&&(i.pos.line>n.line||i.pos.line===n.line&&i.pos.colEnd>=n.character)&&pe(t.fsPath,e))},Mf=(t,e)=>{let n=(i,s)=>i.line<s.line||i.line===s.line&&i.character<=s.character,r=(i,s)=>i.line>s.line||i.line===s.line&&i.character>=s.character;return n(t.start,e.start)&&r(t.end,e.end)},nE=(t,e,n)=>{let r=t.firstToken,i=t.lastToken;return!!(t.lastToken.value!==";"&&(r.pos.line===n.line||i.pos.line===n.line)&&n.character>=i.pos.colEnd&&pe(t.fsPath,e))},rE=(t,e,n)=>{if(!t)return!1;let i=t.filter(s=>s.pos.line===n.line).at(-1);return i&&i.pos.col>=n.character?!1:e.lastToken===i};var zr=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>Cn(s,e,n));return r},jc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].find(s=>uT(s.lastToken,e,n));return r===t?void 0:r},Uc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>Bc(s.firstToken,e,n));return r===t?void 0:r},dT="#virtual",ro=t=>t.includes(dT),xf=(t,e)=>`${t}?loc=${e.start.line}:${e.start.character}-${e.end.line}:${e.end.character}${dT}`,zn=t=>{if(!ro(t))return;let[e,n]=t.split("?"),[r,i]=n.replace("loc=","").replace(dT,"").split("-"),[s,o]=r.split(":"),[a,c]=i.split(":");return{docFsPath:e,range:cn.Range.create(cn.Position.create(Number.parseInt(s),Number.parseInt(o)),cn.Position.create(Number.parseInt(a),Number.parseInt(c)))}},fT=t=>{let e=zn(t.fsPath);e&&(t.range=e.range,t.fsPath=e?.docFsPath,t.virtual=!0,t.linkedTo=t.linkedTo.map(({range:n,fsPath:r})=>{let i=zn(r);return{range:i?.range??n,fsPath:i?.docFsPath??r,templateStrings:[]}}))},z=(t,e,n=e,r,{severity:i=cn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,inclusiveStart:u,inclusiveEnd:d}={severity:cn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let f={issues:Array.isArray(t)?t:[t],range:ar(e,n,u,d),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:h,fsPath:y})=>({range:h,fsPath:y,templateStrings:[]})),tags:o,templateStrings:a,edit:c,codeActionTitle:l};fT(f);let p,m=()=>(p??={severity:f.severity,range:f.range,message:f.issues?f.issues.map(qU).join(" or "):"",source:"devicetree",tags:f.tags,data:{firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},type:"SyntaxIssue",items:f.issues,edit:f.edit,codeActionTitle:f.codeActionTitle,virtual:!!f.virtual}},p);return r?.syntaxIssues.push(m),{raw:f,diagnostic:m}},Ht=(t,e,n,r,{severity:i=cn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,linkedToTemplateStrings:u=[]}={severity:cn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let d={issues:Array.isArray(t)?t:[t],range:ar(e,n),fsPath:e.fsPath,severity:i,linkedTo:s.map(({range:m,fsPath:h},y)=>({range:m,fsPath:h,templateStrings:u.at(y)??[]})),tags:o,templateStrings:a,edit:c,codeActionTitle:l};fT(d);let f,p=()=>(f??={severity:d.severity,range:d.range,message:$U(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(m=>({message:d.issues.map(h=>FU(h,m.templateStrings)).join(" or "),location:{uri:ue(m.fsPath),range:m.range}}))]},f);return r?.resettableIssues.push(p),{raw:d,diagnostic:p}},F=(t,e,n,r,{severity:i=cn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l}={severity:cn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let u={issues:Array.isArray(t)?t:[t],range:ar(e,n),severity:i,fsPath:e.fsPath,linkedTo:s.map(({range:p,fsPath:m})=>({range:p,fsPath:m,templateStrings:[]})),tags:o,templateStrings:a,edit:c,codeActionTitle:l};fT(u);let d,f=()=>(d??={severity:u.severity,range:u.range,message:BU(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(jU).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"StandardTypeIssue",firstToken:{pos:e.pos,tokens:e.tokens,value:e.value},lastToken:{pos:n.pos,tokens:n.tokens,value:n.value},edit:u.edit,codeActionTitle:u.codeActionTitle,items:u.issues,virtual:!!u.virtual}},d);return Array.isArray(r)?r.forEach(p=>p.resettableIssues.push(f)):r?.resettableIssues.push(f),{raw:u,diagnostic:f}};function st(t,e,n,{severity:r=cn.DiagnosticSeverity.Warning,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:cn.DiagnosticSeverity.Warning,linkedTo:[],templateStrings:[],edit:[],codeActionTitle:void 0},l=n){let u={issues:Array.isArray(t)?t:[t],range:cn.Range.create(n,l),severity:r,fsPath:e,linkedTo:i.map(({range:p,fsPath:m})=>({range:p,fsPath:m,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},d;return{raw:u,diagnostic:()=>(d??={severity:u.severity,range:u.range,message:UU(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(HU).join(" or "),location:{uri:ue(p.fsPath),range:p.range}}))],source:"devicetree",tags:u.tags,data:{type:"FormattingIssues",items:u.issues,edit:u.edit,codeActionTitle:u.codeActionTitle,virtual:!!u.virtual}},d)}}var iE=(t,e)=>[...t].sort((r,i)=>{let s=e.getSortKey(r),o=e.getSortKey(i);if(s===void 0||o===void 0)throw new Error("Sort keys must be set");if(s!==o)return s-o;let a=r.lastToken,c=i.lastToken;return a.pos.line!==c.pos.line?a.pos.line-c.pos.line:a.pos.col-c.pos.col});async function Nt(t,e,n){let r=Se(t.textDocument.uri);if(!e)return[];let i=performance.now(),s=await e.getRuntime(),o,a,c=s.context.allParsers.flatMap(u=>u.injectedMacros).find(u=>Cn(u,r,t.position));return c&&(o={runtime:s,item:null,ast:zr(c,r,t.position)},a=Number.MAX_SAFE_INTEGER),o||(o=s.getDeepestAstNode(r,t.position),a=e.getSortKey(o?.ast)??e.getSortKeyFile(t.position,r)),console.log(`search: ${performance.now()-i}ms`),n(o,u=>{let d=t.position;if(pe(u.fsPath,r)){let f=u.lastToken;return f.pos.line<d.line||f.pos.line===d.line&&f.pos.colEnd<=d.character}return a!==void 0&&(e.getSortKey(u)??-1)<=a})}function de(t,e){return{start:t,end:e??t}}var U=(t,e)=>t?.tokens.some(n=>n===e),tt=(t,e)=>n=>n?.value&&(e?.caseInsensitive?t.toLowerCase()===n.value.toLowerCase():t===n.value)?"yes":e?.allowPartial?MU(t)(n):"no",Le=t=>e=>e?.tokens.some(n=>n===t)?"yes":"no",MU=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",ln=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&pe(t.fsPath,e.fsPath),Vt=(t,e)=>t?.tokens[0]===21&&e?.tokens[0]===21&&(t?.prevToken&&t.prevToken.value===e?.value||e?.prevToken&&e.prevToken.value===t?.value)?!0:!!t&&!!e&&t.pos.colEnd===e.pos.col&&ln(t,e),Lf=t=>t.map((e,n)=>({index:n,context:e,files:e.getContextFiles()})),vn=(t,e,n,r)=>{if("id"in e){let s=t?.find(o=>o.id===e.id);return s||void 0}if("name"in e){let s=t?.find(o=>o.ctxNames.includes(e.name));return s||void 0}return n?.getContextFiles().find(s=>pe(s,e.fsPath))?n:Lf(t).sort(s=>s.context.id===r?-1:0).find(s=>s.files.some(o=>pe(o,e.fsPath)))?.context},pT=(t,e)=>Lf(t).filter(r=>r.files.some(i=>pe(i,e))).map(r=>r.context),sE=t=>{let e=/^(\w+)\s+(.*)$/,n=/^(\w+)\(([^)]*)\)\s+(.*)$/,r=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.*)$/,i;if(i=r.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l=l.replace(/__VA_ARGS__/g,c.slice(a.length).join(", ")),l}}else if(i=n.exec(t)){let[,,s,o]=i,a=s.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l}}else if(i=e.exec(t)){let[,,s]=i;return s.trim()}};function xU(t){if(!t.trim())return[];let e=[],n="",r=0;for(let i=0;i<t.length;i++){let s=t[i];s===","&&r===0?(e.push(n.trim()),n=""):(s==="("?r++:s===")"&&r--,n+=s)}return n.trim()&&e.push(n.trim()),e}var LU=0,$c=(t,e)=>{let n=o=>o.replace(/\s*##\s*/g,""),r=o=>o.replace(/#(\w+)/g,(a,c)=>`"${c}"`),i=t,s;do s=i,i=n(s),i=r(i),i=i.replace(/\b(\w+)\(([^()]*(?:\([^()]*\)[^()]*)*)\)|\b(\w+)\b/g,(o,a,c,l)=>{if(a==="defined"){let u=c.split(",").map(d=>d.trim());return u[0]?e.get(u[0])?.resolver:u}else if(a&&typeof e.get(a)?.resolver=="function"){let u=xU(c).map(d=>d.trim()).map(d=>d==="__COUNTER__"?(LU++).toString():d).map(d=>$c(d,e));return(e.get(a)?.resolver)(...u)}else if(l&&typeof e.get(l)?.resolver=="string")return e.get(l)?.resolver;return o});while(i!==s);return i};function hT(t){return t.replace(/'(.)'/g,(e,n)=>n.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function De(t){try{return(0,eval)(hT(t))}catch{}return t}var ue=t=>lT.default.pathToFileURL(t).toString(),Se=t=>it(lT.default.fileURLToPath(t)),oE=(t,e)=>{let n=(0,fa.relative)(t,e);return!!n&&!n.startsWith("..")&&!(0,fa.isAbsolute)(n)},pe=(t,e)=>!t||!e?!1:t===e,it=t=>(0,fa.normalize)(process.platform==="win32"?t.toLowerCase():t),qi=t=>(0,tE.createHash)("sha256").update([it(t.dtsFile),...t.includePaths.map(it),...t.overlays.map(it),t.bindingType,...t.zephyrBindings.map(it),...t.deviceOrgBindingsMetaSchema.map(it),...t.deviceOrgTreeBindings.map(it),`showFormattingErrorAsDiagnostics-${t.showFormattingErrorAsDiagnostics}`,`disableFileWatchers-${t.disableFileWatchers}`].join(":")).digest("hex"),qU=t=>{switch(t){case 0:return"Expected value";case 1:return"Expected ';'";case 2:return"Expected '{'";case 3:return"Expected '}'";case 4:return"Expected '['";case 5:return"Expected ']'";case 12:return"Expected '>'";case 13:return"Expected '<'";case 16:return`Expected '"'`;case 17:return`Expected "'"\\`;case 24:return"Missing ':'";case 21:return"Missing '/'";case 26:return'Expected ")"';case 28:return'Missing ","';case 6:return"Expected property name";case 7:return"Expected node name";case 49:return"Node name shall start with a lower or upper case character";case 50:return"Node unit address should not start with 0x";case 51:return"Node unit address should not end with with ULL";case 8:return"Expected node address";case 9:return"Expected node path";case 48:return"Expected node path reference";case 10:return"Expected node reference";case 11:return"Expected root node name";case 14:return"Expected bytestring";case 15:return"Expected two digits for each byte in bytestring";case 20:return"Hex values are not allowed";case 18:return"Expected label name";case 19:return"Expected '/' at the start of a node path";case 23:return"Found ';' without a statement";case 25:return"Did you mean /delete-node/ or /delete-property/?";case 34:return"Did you mean /delete-node/?";case 35:return"Did you mean /delete-property/?";case 22:return"Unknown syntax";case 27:return"Expected expression";case 31:return"Expected macro identifier";case 30:return"Expected macro identifier or function like macro";case 29:return"White space is not allowed";case 32:return"Properties can only be defined in a node";case 53:return"Node name syntax can only be used inside a node definition.";case 33:return"Properties can only be deleted inside a node";case 36:return"Unable to resolve include";case 52:return"Unknown Node Address syntax";case 37:return"Expected start address";case 38:return"Expected end address";case 39:case 40:return"Expected 8|16|32|64";case 42:return"Unknown macro name";case 43:return"Expected function like macro";case 44:return"Macro expects less arguments";case 45:return"Macro expects more arguments";case 46:return"Missing #ENDIF";case 47:return"Block Unused";case 41:return"This syntax is not officially part of the DTS V0.4 standard"}},$U=t=>t.issues.map(e=>{switch(e){case 0:return`Property "${t.templateStrings[0]}" is replaced by a later definition`;case 1:return"Cannot delete a property before it has been defined";case 2:return"Node name already defined";case 5:return"Cannot delete a node before it has been defined";case 3:return`No node with that reference "${t.templateStrings[0]}" has been defined`;case 8:return`No node with name "${t.templateStrings[0]}" could be found in "/${t.templateStrings[1]}".`;case 4:return`Label name "${t.templateStrings[0]}" already defined`;case 6:return`Property "${t.templateStrings[0]}" was deleted`;case 7:return`Node "${t.templateStrings[0]}" was deleted`;case 9:return`The following node "${t.templateStrings[1]}" shall be present in "${t.templateStrings[0]}" node.`;case 10:return`The following node "${t.templateStrings[0]}" address range collides with another node. Address start: "${t.templateStrings[1]}", end: "${t.templateStrings[2]}".`}}).join(" or "),FU=(t,e)=>{switch(t){case 0:return"Property name already defined.";case 2:return"Defined here";case 4:return"Defined here";case 7:case 6:return"Deleted here";case 9:return"Node";case 10:return`Node "${e[0]}". Address start: "${e[1]}", end: "${e[2]}".`;default:return"TODO"}},BU=t=>t.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${t.templateStrings[0]}`;case 1:return"INTRO should be empty";case 8:return"INTRO can only be assigned one value";case 5:return"INTRO should be assigned a U32";case 6:return"INTRO should be assigned a U64";case 7:return"INTRO should be assigned a 'property encoded array'";case 2:return"INTRO should be assigned a string";case 3:return"INTRO should be assigned a string list";case 4:return`INTRO expects ${t.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 27:return"INTRO name is not permitted under this node";case 34:return"INTRO name is not defined in the type binding for this node";case 10:return"INTRO address value must match node address";case 12:return"INTRO should be 'cpu'";case 13:return"INTRO should be 'memory'";case 14:return"INTRO is deprecated and should not be used'";case 15:return`INTRO ${t.templateStrings[1]}'`;case 18:return"INTRO value must be unique in the entire Devicetree";case 19:return`INTRO should have format ${t.templateStrings[1]}`;case 16:return`INTRO requires property "${t.templateStrings[1]}" in node path "${t.templateStrings[2]}"`;case 17:return"Unable to resolve interrupt parent node";case 20:return`INTRO should have format ${t.templateStrings[1]}`;case 21:return"Node is disabled";case 22:return"Unable to resolve handle";case 23:return`Unable to find "${t.templateStrings[0]}" in ${t.templateStrings[1]}`;case 24:return t.templateStrings[0];case 25:return t.templateStrings[0];case 26:return t.templateStrings[0];case 28:return t.templateStrings[0];case 35:return"Unable to find mapping range for address";case 29:return`INTRO exceeds address space available for this mapping. The range ends at ${t.templateStrings[2]}, the node ends at ${t.templateStrings[1]}`;case 30:return"Map entry overlaps with others entries";case 31:return"Unable to match to a nexus map entry";case 32:return`Unknown node type "${t.templateStrings[0]}"`;case 33:return`Missing name for "${t.templateStrings[0]}" index ${t.templateStrings[1]}"`;case 36:return"Node address is missing";case 37:return`Binding should be used on bus type${t.templateStrings.length?"s":""}: ${t.templateStrings.join(" or ")}`;case 38:return"Empty ranges property should only be used when address size cells is identical to the parent node"}}).join(" or ").replace("INTRO",`Property "${t.templateStrings[0]}"`).replaceAll("INTRO ",""),jU=t=>{switch(t){case 16:case 0:return"Node";case 15:return"Ignored reason";case 18:return"Conflicting properties";case 8:return"Additional value";case 21:return"Disabled by";case 29:return"Mapping range";case 30:return"Map entry";case 31:return"Nexus map entries";case 33:return"Names property";case 35:return"Range property";default:return"TODO"}},UU=t=>t.issues.map(e=>{switch(e){case 4:return"Add end of line to end of file";case 1:return`${t.codeActionTitle}. Expecting ${t.templateStrings[0]}.`;case 0:return"Move to a new line";case 3:return"Remove trailing whitespace at the end of file.";case 2:return"Remove trailing whitespace at the end of the line.";case 5:return`Fix indentation. ${t.templateStrings.at(0)?.length===0?"No indentation expected":`Expecting ${t.templateStrings[0]}`}`;case 6:return`Move token "${t.templateStrings[0]}" next to expression`;case 7:return"Remove (...) enclosure. This expression should only be enclosed in the #define of the macro";case 8:return`Line is too long. ${t.codeActionTitle}`;case 9:return`Hex values must be lowercase. ${t.codeActionTitle}`;case 10:return"Node address is already a hex value. Remove '0x'.";case 10:return"Node address size is determined by '@size-cells', Remove 'ull'.";case 12:return`'\\' is not necessary. ${t.codeActionTitle}`}}).join(" or "),HU=t=>"TODO",aE=(t,e)=>Lt(t,e)<=0?t:e,cE=(t,e)=>Lt(t,e)>=0?t:e,Lt=(t,e)=>{let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=t[t.length-n+r]??0,s=e[e.length-n+r]??0;if(i<s)return-1;if(i>s)return 1}return 0},br=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0,c=o+a+i;r[n-1-s]=c>>>0,i=c>4294967295?1:0}return i&&r.unshift(1),r},mT=(t,e)=>{let n=Math.max(t.length,e.length),r=new Array(n).fill(0),i=0;for(let s=0;s<n;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0;o-=i,o<a?(o+=4294967296,i=1):i=0,r[n-1-s]=o-a>>>0}for(;r.length>1&&r[0]===0;)r.shift();return r},VU=(t,e)=>br(t,e),lE=(t,e)=>{let n=[];for(let r of t){let i=r.childAddress,s=r.length,o=br(i,s);if(Lt(e,i)>=0&&Lt(e,o)<0){let a=mT(e,i),c=r.parentAddress,l=VU(c,a),u=br(c,s);n.push({start:l,end:u,range:ar(r.rangeTokens.start,r.rangeTokens.end),fsPath:r.rangeTokens.start.fsPath})}}return n};function uE(t){return Array.isArray(t)&&Array.isArray(t[0])}function Hc(t){return!t||t instanceof Ut?t:Hc(t.parentNode)}function ds(t,e){let n=t.getText(),r=e.slice().sort((s,o)=>{let a=t.offsetAt(s.range.start),c=t.offsetAt(o.range.start);if(a!==c)return c-a;let l=t.offsetAt(s.range.end),u=t.offsetAt(o.range.end);if(l!==u)return u-l;let d=a===l&&s.newText.length>0,f=c===u&&o.newText.length>0;return d!==f?d?1:-1:0}),i=n;for(let s of r){let o=t.offsetAt(s.range.start),a=t.offsetAt(s.range.end);i=i.slice(0,o)+s.newText+i.slice(a)}return i}function eE(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}function dE(t,e){return eE(t.end,e.start)>0&&eE(t.start,e.end)<0}var fE=(t,e)=>{let n=pE(t,e),r=hE(t,e);n&&(t.topComment=n),r&&(t.endComment=r)},pE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.lastToken===t.firstToken.prevToken&&(i.lastToken.pos.line===t.firstToken.pos.line||i.lastToken.pos.line+1===t.firstToken.pos.line));if(!n||n.astBeforeComment)return;n.astAfterComment=t;let r=pE(n,e);return r&&(r.astAfterComment=t,n.astAfterComment=void 0),r??n},hE=(t,e)=>{let n=e.find(i=>!i.disabled&&i.firstToken.prevToken===t.lastToken&&i.firstToken.pos.line===t.lastToken.pos.line);if(!n)return;n.astBeforeComment=t;let r=hE(n,e);return r&&(r.astBeforeComment=t,n.astBeforeComment=void 0),r??n},io=(t,e,n)=>{let r=[42,44,45,36];return n||r.push(52,32,53,8,49),t.severity===cn.DiagnosticSeverity.Error&&pe(t.fsPath,e)&&!r.some(i=>t.issues.includes(i))};function qf(t){let e=t?.charAt(0);return!!e&&(e>="A"&&e<="Z"||e>="a"&&e<="z")}var $f=t=>{if(t)return t instanceof Ue?t:$f(t?.parentNode)},so=(t,e,n=0)=>{if(!e||!e.parentNode?.fsPath)return n;let r=$f(e.parentNode);return so(t,r,n+1)};function mE(t,e,n,r){let i=n-e,s=r.length,o=t.length-i+s,a=new Array(o),c=0;for(let l=0;l<e;l++,c++)a[c]=t[l];for(let l=0;l<s;l++,c++)a[c]=r[l];for(let l=n;l<t.length;l++,c++)a[c]=t[l];return a}var nl=require("fs"),Sa=require("path"),lo=q(j());var oD=require("path"),Sr=q(j());var Dn=class extends te{constructor(n,r,i,s){super();this.startLabels=n;this.value=r;this.endLabels=i;this.bits=s;this.startLabels.forEach(o=>{this.addChild(o)}),this.addChild(s),this.addChild(r),this.endLabels.forEach(o=>{this.addChild(o)})}toString(){return`${[this.value?.toString()??"NULL",...this.endLabels.map(n=>n.toString())].join(" ")}`}toPrettyString(n){return`${[this.value?.toPrettyString(n)??"NULL",...this.endLabels.map(r=>r.toString())].join(" ")}`}toJson(){return this.value?.toJson()}};var Kt=t=>t instanceof En?!0:t instanceof Ue?!1:t.parentNode?Kt(t.parentNode):!1;var gT=t=>{if(t instanceof je)return t;if(!(t instanceof Ue))return t.parentNode?gT(t.parentNode):void 0},oo=t=>!t||t instanceof je?!1:t instanceof Dn||oo(t.parentNode),pa=t=>[...t.map(e=>{if(e instanceof He||e instanceof Tt)return e.name;if(e instanceof Et)return e.reference})].filter(e=>!!e),yT=(t,e)=>e?e.parentNode===t||yT(t,e.parentNode):!1;var Ot=q(j());var gE=q(j());var Gr=class extends te{constructor(){super();this._pathParts=[]}addPath(n,r){this._pathParts.push(n),r&&this.addChild(r),this.addChild(n)}get pathParts(){return[...this._pathParts]}toString(){return this._pathParts.map(n=>n?.toString()??"<NULL>").join("/")}buildSemanticTokens(n){this._children.forEach(r=>{r instanceof xe?r.buildSemanticTokens(n):n(xi("operator"),Li("declaration"),r.firstToken,r.lastToken)})}},ot=class extends te{constructor(n){super();this.path=n;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:gE.SymbolKind.Namespace},this.addChild(n)}toString(){return`&${this.path?.toString()??"NULL"}`}toJson(){return-1}serialize(){let n=this.path?.toString();return{type:"NODE_PATH",nodePath:n==="/"?n:`/${n??""}`,url:this.serializeURL,range:this.range,issues:this.serializeIssues}}};var Y=class{constructor(e,n,r="optional",i=void 0,s,o){this.name=e;this.type=n;this.def=i;this.additionalTypeCheck=o;this.hideAutoComplete=!1;this.list=!1;this.onHover=()=>({kind:Ot.MarkupKind.Markdown,value:["### Type","**DTS native type** ",`${this.type.map(e=>e.types.join(" or ")).join(",")}
184
184
 
185
185
  `,...this.bindingType?["**Binding type** ",`${this.bindingType}
186
186
 
@@ -249,7 +249,7 @@ If a CPU/thread can be the target of an external interrupt the reg property valu
249
249
  If a CPU/thread cannot be the target of an external interrupt, then reg must be unique and out of bounds of the range addressed by the interrupt controller
250
250
  If a CPU/thread's PIR (pending interrupt reg-ister) is modifiable, a client program should modify PIR to match the reg property value.
251
251
  If PIR cannot be modified and the PIR value is distinct from the interrupt controller number space, the CPUs binding may define a binding-specific representation of PIR values if desired.`],t}var eD=()=>{let t=new Y("alignment",W("PROP_ENCODED_ARRAY"),"optional",void 0,[],(e,n)=>{let r=[],i=qe(e.ast.values),s=e.parent.sizeCells(n),o=[...Array.from({length:s},(a,c)=>`size${s>1?c:""}`)];if(t.signatureArgs=o.map(a=>Kn.create(a)),i?.length!==s){let a=e.ast.values??e.ast;r.push(F(19,a.firstToken,a.lastToken,a,{templateStrings:[e.name,`<${Array.from({length:e.parent.sizeCells(n)},()=>"size")}>`]}))}return r});return t.description=["Address boundary for alignment of allocation."],t};var tD=()=>{let t=new Y("alloc-ranges",W("PROP_ENCODED_ARRAY"),"optional",void 0,[],(e,n)=>{let r=[],i=e.parent.addressCells(n),s=e.parent.sizeCells(n),o=[...Array.from({length:i},(c,l)=>`address${i>1?l:""}`),...Array.from({length:s},(c,l)=>`size${s>1?l:""}`)];t.signatureArgs=o.map(c=>Kn.create(c)),t.signatureArgsCyclic=!0;let a=qe(e.ast.values);if(!a)return[];if(a.length===0||a.length%(i+s)!==0){let c=a.at(a.length-a.length%(s+i))??e.ast;return r.push(F(19,c.firstToken,c.lastToken,c,{templateStrings:[e.name,`<${[...Array.from({length:i},()=>"address"),...Array.from({length:s},()=>"size")].join(" ")}>`]})),r}return r});return t.description=["Specifies regions of memory that are acceptable to allocate from"],t};var nD=()=>{let t=new Y("no-map",W("EMPTY"),"optional");return t.description=[`Indicates the operating system must not create a virtual mapping of the region as part of its standard mapping of system memory, nor permit speculative access to it under
252
- any circumstances other than under the control of the device driver using the region.`],t};var rD=()=>{let t=new Y("reusable",W("EMPTY"),"optional");return t.description=["The operating system can use the memory in this region with the limitation that the device driver(s) owning the region need to be able to reclaim it back. Typically that means that the operating system can use that region to store volatile or cached data that can be otherwise regenerated or migrated elsewhere."],t};var iD=()=>{let t=new Y("size",W("PROP_ENCODED_ARRAY"),"optional",void 0,[],(e,n)=>{let r=[],i=qe(e.ast.values),s=e.parent.sizeCells(n),o=[...Array.from({length:s},(a,c)=>`size${s>1?c:""}`)];if(t.signatureArgs=o.map(a=>Kn.create(a)),i?.length!==e.parent.sizeCells(n)){let a=e.ast.values??e.ast;r.push(F(19,a.firstToken,a.lastToken,a,{templateStrings:[e.name,`<${Array.from({length:s},()=>"size")}>`]}))}return r});return t.description=["Size in bytes of memory to reserve for dynamically allocated regions."],t};function sD(){let t=bn(),e=t.properties.find(n=>n.name==="reg");return e.required=()=>"optional",t.addProperty([iD(),eD(),tD(),nD(),rD()]),t}function ao(t){switch(t?.name){case"/":return WC();case"aliases":return GC();case"memory":return KC();case"reserved-memory":return XC();case"chosen":return JC();case"cpus":return QC();case"cpu":return ZC()}return t?.parent?.name==="reserved-memory"?sD():bn()}var X=class t{constructor(e,n,r,i=null){this.bindingLoader=e;this.name=n;this.address=r;this.parent=i;this.implementations=[];this._properties=[];this._deletedProperties=[];this._deletedNodes=[];this.deletes=[];this._nodes=[];this.linkedNodeNamePaths=[];this.linkedRefLabels=[];this.interrupControlerMapping=[];this.spesifierNexusMapping=[];this.missingBinding=[];i?.addNode(this)}get definitions(){return this.implementations.filter(e=>e instanceof He||e instanceof Tt)}static toJson(e){let n={};return e.properties.forEach(r=>n[r.name]=r.ast.values?.toJson()??!0),e.nodes.forEach(r=>n[r.fullName]=t.toJson(r)),n}get disabled(){return this.getProperty("status")?.ast.quickValues?.at(0)==="disabled"}get nodeTypes(){if(this._nodeTypes)return this._nodeTypes;if(!this.bindingLoader)return this._nodeTypes=[ao(this)],this._nodeTypes;if(!this.getProperty("compatible")){let e=this.parent?.nodeType?.childNodeType?.(this);if(e)return this._nodeTypes=[e],this._nodeTypes}return this._nodeTypes=this.bindingLoader.getNodeTypes(this).type,this._nodeTypes}get nodeType(){return this.nodeTypes.find(e=>!e.onBus||this.parent?.nodeType?.bus?.some(n=>n===e.onBus))}isChildOf(e){return this.parent?this.parent===e?!0:this.parent.isChildOf(e):!1}getReferenceBy(e){return this.implementations.filter(r=>r instanceof Et).some(r=>r===e)?this:[...this._nodes,...this._deletedNodes.map(r=>r.node)].map(r=>r.getReferenceBy(e)).find(r=>r)}get nodeNameOrLabelRef(){return pa(this.implementations)}getDeepestAstNode(e,n){let r=this.implementations.find(i=>Cn(i,e,n));if(r){let i=this.deletes.map(c=>({item:this,ast:zr(c,e,n),beforeAst:Uc(c,e,n),afterAst:jc(c,e,n)})).find(c=>Cn(c.ast,e,n));if(i)return i;let s=[...this._properties.flatMap(c=>[c,...c.allReplaced]),...this._deletedProperties.flatMap(c=>[c.property,...c.property.allReplaced])].map(c=>({item:c,ast:c.ast})).find(c=>Cn(c.ast,e,n)||c.ast.lastToken.value!==";"&&nE(c.ast,e,n));if(s)return s.item.getDeepestAstNode(e,n);let o=[...this._nodes,...this._deletedNodes.map(c=>c.node)].map(c=>c.getDeepestAstNode(e,n)).find(c=>c);if(o)return o;let a=zr(r,e,n);return{item:this,ast:a,beforeAst:Uc(a,e,n),afterAst:jc(a,e,n)}}}get labels(){return this.implementations.flatMap(e=>e instanceof Tt?[]:e.labels)}get labelsMapped(){return this.labels.map(e=>({label:e,owner:this}))}get allBindingsProperties(){return[...this.properties.filter(e=>e.name==="compatible"),...this._nodes.flatMap(e=>e.allBindingsProperties)]}get allDescendantsLabels(){return[...this.labels,...this._nodes.flatMap(e=>e.allDescendantsLabels)]}get allDescendantsLabelsMapped(){return[...this.labelsMapped,...this.properties.flatMap(e=>e.labelsMapped),...this._nodes.flatMap(e=>e.allDescendantsLabelsMapped)]}getOverlappingNodeAddressesIssues(e){return this._nodes.filter(n=>!n.disabled).flatMap(n=>{let r=n.regArray(e),i=this._nodes.filter(s=>s!==n&&!s.disabled);return r?.flatMap(s=>{let o=i.flatMap(a=>a.regArray(e)?.filter(c=>Lt(c.startAddress,s.endAddress)<0&&Lt(s.startAddress,c.endAddress)<0).flatMap(c=>({reg:c,node:a}))).filter(a=>!!a);return o.length?Ht(10,s.rangeTokens.start,s.rangeTokens.end,n.properties.find(a=>a.name==="reg")?.ast??n.implementations[0],{severity:Sr.DiagnosticSeverity.Information,linkedTo:o.map(a=>({range:ar(a.reg.rangeTokens.start,a.reg.rangeTokens.end),fsPath:a.reg.rangeTokens.start.fsPath})),templateStrings:[n.fullName,`0x${s.startAddress.map((a,c)=>a.toString(16).padStart(c?8:0,"0")).join("")}`,`0x${s.endAddress.map((a,c)=>a.toString(16).padStart(c?8:0,"0")).join("")}`],linkedToTemplateStrings:o.map(a=>[a.node.fullName,`0x${a.reg.startAddress.map((c,l)=>c.toString(16).padStart(l?8:0,"0")).join("")}`,`0x${a.reg.endAddress.map((c,l)=>c.toString(16).padStart(l?8:0,"0")).join("")}`])}):[]})??[]})}getIssues(e){let n=[...this.properties.flatMap(r=>r.issues),...this._nodes.flatMap(r=>r.getIssues(e)),...this._deletedNodes.flatMap(r=>r.node.getIssues(e)),...this.deletedPropertiesIssues,...this.deletedNodesIssues,...this.missingBinding,...this.getOverlappingNodeAddressesIssues(e)];if(this.name==="/"&&this.implementations.length&&!this._nodes.some(r=>r.name==="cpus")){let r=this.implementations[this.implementations.length-1],i=r.identifierAst??r;n.push(Ht(9,i.firstToken,i.lastToken,i,{severity:Sr.DiagnosticSeverity.Error,linkedTo:this.implementations.slice(0,-1),templateStrings:["/","cpus"]}))}return n}get deletedPropertiesIssues(){return[...this._deletedProperties.flatMap(e=>[Ht(6,e.property.ast.firstToken,e.property.ast.lastToken,e.property.ast,{severity:Sr.DiagnosticSeverity.Hint,tags:[Sr.DiagnosticTag.Deprecated],linkedTo:[e.by],templateStrings:[e.property.name]}),...e.property.allReplaced.map(n=>Ht(6,n.ast.firstToken,n.ast.lastToken,n.ast,{severity:Sr.DiagnosticSeverity.Hint,linkedTo:[e.by],tags:[Sr.DiagnosticTag.Deprecated],templateStrings:[e.property.name]})),...e.property.issues])]}get deletedNodesIssues(){return this._deletedNodes.flatMap(e=>[...e.node.implementations.filter(n=>n instanceof He||n instanceof Et).flatMap(n=>{let r;return n instanceof He?r=n.name.toString():n.reference instanceof ie?r=n.reference.label.value:r=n.reference.path.pathParts.at(-1).name,Ht(7,n.firstToken,n.lastToken,n,{severity:Sr.DiagnosticSeverity.Hint,linkedTo:[e.by],tags:[Sr.DiagnosticTag.Deprecated],templateStrings:[r]})})])}get path(){return this.parent?[...this.parent.path,this.fullName]:[this.fullName]}get pathString(){return`/${this.path.slice(1).join("/")}`}get defaultProperties(){let e=(this.nodeType?.defaultProperties??[]).filter(s=>!this.getProperty(s.name)),n=this.nodes.flatMap(s=>s.defaultProperties);if(!e.length&&!n.length)return[];if(!e.length)return n;let r=this.definitions.at(-1);return[{fsPath:xf(r.firstToken.fsPath,ce(r)),text:`&{${this.pathString}} {
252
+ any circumstances other than under the control of the device driver using the region.`],t};var rD=()=>{let t=new Y("reusable",W("EMPTY"),"optional");return t.description=["The operating system can use the memory in this region with the limitation that the device driver(s) owning the region need to be able to reclaim it back. Typically that means that the operating system can use that region to store volatile or cached data that can be otherwise regenerated or migrated elsewhere."],t};var iD=()=>{let t=new Y("size",W("PROP_ENCODED_ARRAY"),"optional",void 0,[],(e,n)=>{let r=[],i=qe(e.ast.values),s=e.parent.sizeCells(n),o=[...Array.from({length:s},(a,c)=>`size${s>1?c:""}`)];if(t.signatureArgs=o.map(a=>Kn.create(a)),i?.length!==e.parent.sizeCells(n)){let a=e.ast.values??e.ast;r.push(F(19,a.firstToken,a.lastToken,a,{templateStrings:[e.name,`<${Array.from({length:s},()=>"size")}>`]}))}return r});return t.description=["Size in bytes of memory to reserve for dynamically allocated regions."],t};function sD(){let t=bn(),e=t.properties.find(n=>n.name==="reg");return e.required=()=>"optional",t.addProperty([iD(),eD(),tD(),nD(),rD()]),t}function ao(t){switch(t?.name){case"/":return WC();case"aliases":return GC();case"memory":return KC();case"reserved-memory":return XC();case"chosen":return JC();case"cpus":return QC();case"cpu":return ZC()}return t?.parent?.name==="reserved-memory"?sD():bn()}var X=class t{constructor(e,n,r,i=null){this.bindingLoader=e;this.name=n;this.address=r;this.parent=i;this.implementations=[];this._properties=[];this._deletedProperties=[];this._deletedNodes=[];this.deletes=[];this._nodes=[];this.linkedNodeNamePaths=[];this.linkedRefLabels=[];this.interrupControlerMapping=[];this.spesifierNexusMapping=[];this.missingBinding=[];i?.addNode(this)}get definitions(){return this.implementations.filter(e=>e instanceof He||e instanceof Tt)}static toJson(e){let n={};return e.properties.forEach(r=>n[r.name]=r.ast.values?.toJson()??!0),e.nodes.forEach(r=>n[r.fullName]=t.toJson(r)),n}get disabled(){return this.getProperty("status")?.ast.quickValues?.at(0)==="disabled"}get nodeTypes(){if(this._nodeTypes)return this._nodeTypes;if(!this.bindingLoader)return this._nodeTypes=[ao(this)],this._nodeTypes;if(!this.getProperty("compatible")){let e=this.parent?.nodeType?.childNodeType?.(this);if(e)return this._nodeTypes=[e],this._nodeTypes}return this._nodeTypes=this.bindingLoader.getNodeTypes(this).type,this._nodeTypes}get nodeType(){return this.nodeTypes.find(e=>!e.onBus||this.parent?.nodeType?.bus?.some(n=>n===e.onBus))}isChildOf(e){return this.parent?this.parent===e?!0:this.parent.isChildOf(e):!1}getReferenceBy(e){return this.implementations.filter(r=>r instanceof Et).some(r=>r===e)?this:[...this._nodes,...this._deletedNodes.map(r=>r.node)].map(r=>r.getReferenceBy(e)).find(r=>r)}get nodeNameOrLabelRef(){return pa(this.implementations)}getDeepestAstNode(e,n){let r=this.implementations.find(i=>Cn(i,e,n));if(r){let i=this.deletes.map(c=>({item:this,ast:zr(c,e,n),beforeAst:Uc(c,e,n),afterAst:jc(c,e,n)})).find(c=>Cn(c.ast,e,n));if(i)return i;let s=[...this._properties.flatMap(c=>[c,...c.allReplaced]),...this._deletedProperties.flatMap(c=>[c.property,...c.property.allReplaced])].map(c=>({item:c,ast:c.ast})).find(c=>Cn(c.ast,e,n)||c.ast.lastToken.value!==";"&&nE(c.ast,e,n));if(s)return s.item.getDeepestAstNode(e,n);let o=[...this._nodes,...this._deletedNodes.map(c=>c.node)].map(c=>c.getDeepestAstNode(e,n)).find(c=>c);if(o)return o;let a=zr(r,e,n);return{item:this,ast:a,beforeAst:Uc(a,e,n),afterAst:jc(a,e,n)}}}get labels(){return this.implementations.flatMap(e=>e instanceof Tt?[]:e.labels)}get labelsMapped(){return this.labels.map(e=>({label:e,owner:this}))}get allBindingsProperties(){return[...this.properties.filter(e=>e.name==="compatible"),...this._nodes.flatMap(e=>e.allBindingsProperties)]}get allDescendantsLabels(){return[...this.labels,...this._nodes.flatMap(e=>e.allDescendantsLabels)]}get allDescendantsLabelsMapped(){return[...this.labelsMapped,...this.properties.flatMap(e=>e.labelsMapped),...this._nodes.flatMap(e=>e.allDescendantsLabelsMapped)]}getOverlappingNodeAddressesIssues(e){return this._nodes.filter(n=>!n.disabled).flatMap(n=>{let r=n.regArray(e),i=this._nodes.filter(s=>s!==n&&!s.disabled);return r?.flatMap(s=>{let o=i.flatMap(a=>a.regArray(e)?.filter(c=>Lt(c.startAddress,s.endAddress)<0&&Lt(s.startAddress,c.endAddress)<0).flatMap(c=>({reg:c,node:a}))).filter(a=>!!a);return o.length?Ht(10,s.rangeTokens.start,s.rangeTokens.end,n.properties.find(a=>a.name==="reg")?.ast??n.implementations[0],{severity:Sr.DiagnosticSeverity.Information,linkedTo:o.map(a=>({range:ar(a.reg.rangeTokens.start,a.reg.rangeTokens.end),fsPath:a.reg.rangeTokens.start.fsPath})),templateStrings:[n.fullName,`0x${s.startAddress.map((a,c)=>a.toString(16).padStart(c?8:0,"0")).join("")}`,`0x${s.endAddress.map((a,c)=>a.toString(16).padStart(c?8:0,"0")).join("")}`],linkedToTemplateStrings:o.map(a=>[a.node.fullName,`0x${a.reg.startAddress.map((c,l)=>c.toString(16).padStart(l?8:0,"0")).join("")}`,`0x${a.reg.endAddress.map((c,l)=>c.toString(16).padStart(l?8:0,"0")).join("")}`])}):[]})??[]})}getIssues(e){let n=[...this.properties.flatMap(r=>r.issues),...this._nodes.flatMap(r=>r.getIssues(e)),...this._deletedNodes.flatMap(r=>r.node.getIssues(e)),...this.deletedPropertiesIssues,...this.deletedNodesIssues,...this.missingBinding,...this.getOverlappingNodeAddressesIssues(e)];if(this.name==="/"&&this.implementations.length&&!this._nodes.some(r=>r.name==="cpus")){let r=this.implementations[this.implementations.length-1],i=r.identifierAst??r;n.push(Ht(9,i.firstToken,i.lastToken,i,{severity:Sr.DiagnosticSeverity.Error,linkedTo:this.implementations.slice(0,-1),templateStrings:["/","cpus"]}))}return n}get deletedPropertiesIssues(){return[...this._deletedProperties.flatMap(e=>[Ht(6,e.property.ast.firstToken,e.property.ast.lastToken,e.property.ast,{severity:Sr.DiagnosticSeverity.Hint,tags:[Sr.DiagnosticTag.Deprecated],linkedTo:[e.by],templateStrings:[e.property.name]}),...e.property.allReplaced.map(n=>Ht(6,n.ast.firstToken,n.ast.lastToken,n.ast,{severity:Sr.DiagnosticSeverity.Hint,linkedTo:[e.by],tags:[Sr.DiagnosticTag.Deprecated],templateStrings:[e.property.name]})),...e.property.issues])]}get deletedNodesIssues(){return this._deletedNodes.flatMap(e=>[...e.node.implementations.filter(n=>n instanceof He||n instanceof Et).flatMap(n=>{let r;return n instanceof He?r=n.name.toString():n.reference instanceof ie?r=n.reference.label.value:r=n.reference.path.pathParts.at(-1).name,Ht(7,n.firstToken,n.lastToken,n,{severity:Sr.DiagnosticSeverity.Hint,linkedTo:[e.by],tags:[Sr.DiagnosticTag.Deprecated],templateStrings:[r]})})])}get path(){return this.parent?[...this.parent.path,this.fullName]:[this.fullName]}get pathString(){return`/${this.path.slice(1).join("/")}`}get defaultProperties(){let e=(this.nodeType?.defaultProperties??[]).filter(s=>!this.getProperty(s.name)&&s.name!=="#address-cells"&&s.name!=="#size-cells"),n=this.nodes.flatMap(s=>s.defaultProperties);if(!e.length&&!n.length)return[];if(!e.length)return n;let r=this.definitions.at(-1);return[{fsPath:xf(r.firstToken.fsPath,ce(r)),text:`&{${this.pathString}} {
253
253
  ${e.map(s=>{if(s.default===void 0)return;let o=Array.isArray(s.default)?s.default:[s.default];switch(s.type){case"array":case"uint8-array":case"int":return`${s.name} = <${o.map(a=>a.toString()).join(" ")}>;`;case"string":case"string-array":return`${s.name} = ${o.map(a=>`"${a.toString()}"`).join(", ")};`}}).join(`;
254
254
  `)}
255
255
  };`},...n]}get properties(){return this._properties}get deletedProperties(){return this._deletedProperties}get nodes(){return this._nodes}get deletedNodes(){return this._deletedNodes}get propertyNames(){return this._properties.map(e=>e.name)}hasNode(e,n){return this._nodes.some(r=>r.name===e&&(r.address===n||r.address?.every((i,s)=>n?.at(s)===i)))}hasProperty(e){return this._properties.some(n=>n.name===e)}getProperty(e){return this._properties.find(n=>n.name===e)}deleteNode(e,n,r){let i=this._nodes.findIndex(s=>s.name===e&&(s.address===r||r?.every((o,a)=>s.address?.at(a)===o)));i!==-1&&(this._deletedNodes.push({node:this._nodes[i],by:n}),this._nodes.splice(i,1))}get root(){return this.parent?this.parent.root:this}#e;get phandle(){if(this.#e!==void 0)return this.#e;let e=this.getProperty("phandle")?.ast.values?.values.at(0)?.value;if(e instanceof gt){let n=e.values.at(0)?.value;if(n instanceof Zt)return this.#e=n.value,this.#e}}getAllPhandle(e){return e===this.phandle?[this,...this._nodes.flatMap(n=>n.getAllPhandle(e))]:this._nodes.flatMap(n=>n.getAllPhandle(e))}getPhandle(e){if(this.phandle===e)return this;for(let n of this._nodes){let r=n.getPhandle(e);if(r)return r}}getNode(e,n,r=!0){let i=r||!!n||this._nodes.filter(o=>o.name===e).length>1,s=this._nodes.findIndex(o=>o.name===e&&(!i||o.address===n||o.address?.every((a,c)=>n?.at(c)===a)));if(s!==-1)return this._nodes[s]}deleteProperty(e,n){let r=this._properties.findIndex(i=>i.name===e);r!==-1&&(this._deletedProperties.push({property:this._properties[r],by:n}),this._properties.splice(r,1))}addNode(e){this._nodes.push(e)}addProperty(e){let n=this._properties.findIndex(r=>r.name===e.name);if(n===-1)this._properties.push(e);else{let r=this._properties.splice(n,1)[0];this._properties.push(e),e.replaces=r,r.replacedBy=e}if(e.name==="compatible")if(this.bindingLoader){let r=this.bindingLoader.getNodeTypes(this);this._nodeTypes=r.type,this.missingBinding.push(...r.issues)}else this._nodeTypes=[ao(this)]}getChild(e,n=!0){if(e.length===1&&e[0]==="/"&&this.name==="/")return this;let r=[...e];r.splice(0,1);let i=r[0].split("@"),s=i[0],o=i[1]!==void 0?i[1].split(",").map(c=>Number.parseInt(c,16)):void 0,a=this.getNode(s,o,n);return r.length===1||!a?a:a.getChild(r)}getChildFromScope(e,n){if(e.length===1&&e[0]===this.fullName)return this;if(e[0]!==this.fullName)return;let r=[...e];return r.splice(0,1),[...this._nodes,...this._deletedNodes.filter(s=>!n(s.by)).map(s=>s.node)].find(s=>s.fullName===r[0])?.getChildFromScope(r,n)}get fullName(){return this.address!==void 0?`${this.name}@${this.address.map(e=>e.toString(16)).join(",")}`:this.name}#n;regArray(e){if(this.#n!==void 0)return this.#n;let n=this.getProperty("reg");if(!n){this.#n=null;return}let r=this.parentAddressCells(e),i=this.parentSizeCells(e),s=[],o=qe(n.ast.values)?.reverse();for(;o?.length;){let a=Array.from({length:r}).map(()=>o.pop()),c=Array.from({length:i}).map(()=>o.pop());if(![...a,...c].every(f=>f instanceof ge))continue;let l=a.map(f=>f.evaluate(e)),u=c.map(f=>f.evaluate(e)),d=a.at(0)?.firstToken;!d||![...l,...u].every(f=>typeof f=="number")||s.push({startAddress:l,endAddress:br(l,u),size:u,rangeTokens:de(d,c.at(-1)?.lastToken??a.at(-1)?.lastToken)})}return this.#n=s,this.#n}#r;rangeMap(e){if(this.#r!==void 0)return this.#r;let n=this.getProperty("ranges");if(!n){this.#r=null;return}let r=this.sizeCells(e),i=this.addressCells(e),s=this.parentAddressCells(e),o=[],a=qe(n.ast.values)?.reverse();for(;a?.length;){let c=Array.from({length:i}).map(()=>a.pop()),l=Array.from({length:s}).map(()=>a.pop()),u=Array.from({length:r}).map(()=>a.pop());if(![...c,...l,...u].every(h=>h instanceof ge))continue;let d=c.map(h=>h.evaluate(e)),f=l.map(h=>h.evaluate(e)),p=u.map(h=>h.evaluate(e)),m=c.at(0)?.firstToken;!m||![...d,...f,...p].every(h=>typeof h=="number")||o.push({childAddress:d,parentAddress:f,length:p,rangeTokens:de(m,u.at(-1).lastToken)})}return this.#r=o,this.#r}#t;dmaRangeMap(e){if(this.#t!==void 0)return this.#t;let n=this.getProperty("dma-ranges");if(!n){this.#t=null;return}let r=this.sizeCells(e),i=this.addressCells(e),s=this.parentAddressCells(e),o=[],a=qe(n.ast.values)?.reverse();for(;a?.length;){let c=Array.from({length:i}).map(()=>a.pop()),l=Array.from({length:s}).map(()=>a.pop()),u=Array.from({length:r}).map(()=>a.pop());if(![...c,...l,...u].every(h=>h instanceof ge))continue;let d=c.map(h=>h.evaluate(e)),f=l.map(h=>h.evaluate(e)),p=u.map(h=>h.evaluate(e)),m=c.at(0)?.firstToken;!m||![...d,...f,...p].every(h=>typeof h=="number")||o.push({childAddress:d,parentAddress:f,length:p,rangeTokens:de(m,u.at(-1).lastToken)})}return this.#t=o,this.#t}parentAddressCells(e){return this.parent?.addressCells(e)??2}parentSizeCells(e){return this.parent?.sizeCells(e)??1}#o;addressCells(e){if(this.#o!==void 0)return this.#o;let n=this?.getProperty("#address-cells");return this.#o=n?Ve(n,0,0,e)??2:2,this.#o}#h;sizeCells(e){if(this.#h!==void 0)return this.#h;let n=this.getProperty("#size-cells");return this.#h=n?Ve(n,0,0,e)??1:1,this.#h}#a;mappedReg(e){if(this.#a!==void 0)return this.#a;let n=this.parent,r=this.regArray(e);do{let i=n?.rangeMap(e);this.#a=r?.flatMap(s=>{let o=s.startAddress,a=s.size,c=br(o,a),l={startAddress:o,startAddressRaw:o,size:a,endAddress:c,endAddressRaw:c,inMappingRange:!1,regRangeTokens:{start:s.rangeTokens.start,end:s.rangeTokens.end},missingMapping:!1};if(!i?.length)return[l];let u=lE(i,o);return u.length?u.map(d=>(l.mappedAst={range:d.range,fsPath:d.fsPath},l.startAddress=d.start,l.endAddress=br(l.startAddress,a),l.inMappingRange=Lt(l.endAddress,d.end)<=0,l.mappingEnd=d.end,{...l,mappedAst:{range:d.range,fsPath:d.fsPath},startAddress:d.start,endAddress:br(d.start,a),inMappingRange:Lt(l.endAddress,d.end)<=0,mappingEnd:d.end})):(l.missingMapping=!0,[l])}).sort((s,o)=>Lt(s.endAddress,o.endAddress))??[],r=this.#a.map(s=>({startAddress:s.startAddress,size:s.size,endAddress:s.endAddress,rangeTokens:s.regRangeTokens})),n=n?.parent}while(n&&this.#a.every(i=>!i.missingMapping&&i.inMappingRange));return this.#a}get interruptsParent(){if(this.getProperty("interrupts-extended"))return null;let e=this.bindingLoader?.type==="Zephyr",n=this.getProperty("interrupt-parent"),r=n?_r(n?.ast.values?.values.at(0),this.root):e?void 0:this.parent;return!e||n?{interruptParent:n,parentInterruptNode:r??null}:r?{interruptParent:n,parentInterruptNode:r??null}:this.parent?this.parent.interruptsParent:{parentInterruptNode:this}}getNexusMapEntryMatch(e,n,r,i=[]){let s=new te(de(r[0].firstToken,r.at(-1).lastToken)),o=this.getNexusMap(e,n);if(o){let a=[...i.map((l,u)=>l&(o.mapMask.at(u)??4294967295)),...r.map((l,u)=>{let d=l instanceof ge?l.evaluate(n):l;return(typeof d=="number"?d&(o.mapMask.at(u+i.length)??4294967295):d).toString()})].join(":"),c=o.map.find(l=>l.mappingValues.map(u=>(u instanceof ge?u.evaluate(n):u).toString()).join(":")===a);return{entry:s,match:c}}return{entry:s}}getNexusMap(e,n){let r=this.getProperty(`${e}-map`),i=qe(r?.ast.values);if(!i?.length)return;let s=this.root,o=this.getProperty(`#${e}-cells`);if(!o)return;let a=Ve(o,0,0,n);if(a==null)return;e==="interrupt"&&(a+=this.addressCells(n));let c=[],l=0;for(;l<i.length;){let f=i.slice(l,a+l),p={childCellCount:a,mappingValues:f};if(c.push(p),l+=a,i.length<l+1)break;p.nodeAst=i[l];let m=_r(p.nodeAst,s);if(!m)break;p.node=m;let h=m.getProperty(`#${e}-cells`);if(!h)return;l++;let y=Ve(h,0,0,n);if(y==null||(e==="interrupt"&&(y+=m.addressCells(n)),p.parentCellCount=y,l+=y,i.length<l))break;p.parentValues=i.slice(l-y,l)}let u=this.getProperty(`${e}-map-mask`);return{mapMask:Array.from({length:a}).map((f,p)=>(u?Ve(u,0,p,n):void 0)??4294967295),map:c}}uniqueLabels(){return Array.from(new Set(this.labels.map(e=>e.toString())))}toTooltipString(e){return`${this.uniqueLabels().join(" ")}${this.labels.length?" ":""}${this.fullName} {${this.properties.length?`
@@ -278,16 +278,16 @@ ${" ".repeat(r-1)}};`}serialize(e,n,r=()=>!0){let i=this.mappedReg(n),s=this.imp
278
278
  `).trimEnd();this.lines=r.split(`
279
279
  `);for(let i=0;i<this.lines.length;i++)this.lines[i]+=`
280
280
  `;this.lexIt()}get tokens(){return this._tokens}isWhiteSpace(){let e=this.currentChar;if(!e)return!1;let n=e.charCodeAt(0);return n===32||n===9||n===10||n===13||n===12||n===11}get endOfFile(){return this.isOnLastLine&&this.isOnLastCharOfLine}get isOnLastLine(){return this.lineNumber===this.lines.length-1}get isOnLastCharOfLine(){return this.lines[this.lineNumber].length<=this.columnNumber}moveToNextLine(){for(;!this.isOnLastLine;)if(this.columnNumber=0,this.lineNumber++,this.lines[this.lineNumber].length>0)return!0;return!1}moveOnLine(){let n=this.lines[this.lineNumber].length;return this.columnNumber>=n?this.moveToNextLine():(this.columnNumber++,this.columnNumber>=n&&this.moveToNextLine(),!0)}move(){return this.lineNumber>=this.lines.length?!1:this.moveOnLine()}get currentChar(){if(this.lineNumber>=this.lines.length)return null;let e=this.lines[this.lineNumber];return this.columnNumber>=e.length?null:e[this.columnNumber]}static{this.SYNTAX_CHARS=new Set(["^","~","|","!","\\","<",">",";","=","/","{","}","[","]","(",")","*","%","&",".",":","+","@","-","_",",","x","X","?"])}static isSyntaxChar(e){return e?t.SYNTAX_CHARS.has(e):!1}static isLetterCode(e){return e>=65&&e<=90||e>=97&&e<=122}getWord(){let e="";for(;!this.isWhiteSpace()&&(e.length&&!t.isSyntaxChar(this.currentChar)||!e.length);){if(e+=this.currentChar??"",e.length===1&&t.isSyntaxChar(this.currentChar)){this.move();break}let n=this.lineNumber;if(!this.move()||this.lineNumber!==n)return e}return this.inComment&&e==="*"&&this.currentChar==="/"&&(this.inComment=!1),this.inCommentLineStart!==void 0&&this.lineNumber!==this.inCommentLineStart&&(this.inCommentLineStart=void 0,this.inComment=!1),!this.inComment&&e==="/"&&this.currentChar==="*"&&(this.inCommentLineStart=void 0,this.inComment=!0),!this.inComment&&e==="/"&&this.currentChar==="/"&&(this.inCommentLineStart=this.lineNumber,this.inComment=!0),e}getString(e){let n=e;for(;this.currentChar!==e;){if(this.currentChar===`
281
- `){let o=this.lineNumber,a=this.columnNumber,c=n.length;this.pushToken({tokens:[21],value:n,pos:{col:a-c,line:o,len:c,colEnd:a}}),n=""}else if(this.currentChar==="\\"){let o=this.lineNumber;if(n+=this.currentChar??"",this.move())o===this.lineNumber&&(n+=this.currentChar??"");else break}else n+=this.currentChar??"";if(!this.move())break}n+=e;let r=this.lineNumber,i=this.columnNumber+1,s=n.length;this.pushToken({tokens:[21],value:n,pos:{col:i-s,line:r,len:s,colEnd:i}}),this.move()}lexIt(){for(;!this.endOfFile;){for(;this.isWhiteSpace();)this.move();let e=this.getWord();e&&this.process(e)}}static{this.SINGLE_CHAR_TOKENS=new Map([["{",[2]],["}",[3]],["(",[42]],[")",[43]],["[",[11]],["]",[12]],[";",[1]],[":",[50]],["=",[0]],[">",[4]],["<",[5]],["!",[6]],["|",[8]],["^",[9]],["&",[40,7]],["~",[10]],["/",[13]],["\\",[14]],["+",[15]],["-",[16]],["*",[17]],["%",[18]],["?",[44]],[".",[45]],["_",[48]],["@",[49]],[",",[24]]])}static{this.KEYWORD_TOKENS=new Map([["true",38],["false",39],["#define",25],["#include",26],["#line",27],["#undef",28],["#error",29],["#pragma",30],["#defined",31],["#if",32],["#ifdef",33],["#ifndef",34],["#elif",35],["#else",36],["#endif",37]])}process(e){let n=this.isString(e);if(!n){let i=t.KEYWORD_TOKENS.get(e.toLowerCase());if(i&&(n=!0,this.pushToken({tokens:[i],value:e.toLowerCase(),pos:this.generatePos(e,e.toLowerCase())}),i===39||i===38)){let s=this.tokens.length-1;if(Vt(this.tokens[s-1],this.tokens[s]))n=!1,this.tokens.pop();else return!0}}if(n||(n=this.isDigit(e)||this.isHexDigit(e)||this.isLetters(e)),!n&&e.length===1){let i=t.SINGLE_CHAR_TOKENS.get(e);if(i)return n=!0,this.pushToken({tokens:i,value:e,pos:this.generatePos(e,e)}),!0}if(n||(n=this.isHash(e)||this.unknownToken(e)),!n)throw new Error(`Lexer is not complete!!! Could not find token for "${e}"`);let r=this._tokens[this._tokens.length-1];return n&&!r?.tokens.some(i=>i===21)&&r&&r.pos.len<e.length?this.process(e.slice(r.pos.len)):!0}pushToken(e){let n={tokens:e.tokens,pos:e.pos,value:e.value,fsPath:this.fsPath},r=this._tokens[this._tokens.length-1];n.prevToken=r,r&&(r.nextToken=n),this._tokens.push(n)}isLetters(e){let n=e[0]?.charCodeAt(0);if(t.isLetterCode(n)){let r="";for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(t.isLetterCode(s))r+=e[i];else break}return this.pushToken({tokens:[47],value:r,pos:this.generatePos(e,r)}),!0}return!1}isDigit(e){let n=e[0],r=n?.charCodeAt(0);return r>=48&&r<=57?(this.pushToken({tokens:[20,19],value:n,pos:this.generatePos(e,n)}),!0):!1}isHexDigit(e){let n=e[0],r=n?.charCodeAt(0);return r>=65&&r<=70||r>=97&&r<=102?(this.pushToken({tokens:[20,47],value:n,pos:this.generatePos(e,n)}),!0):!1}isHash(e){let n="#";return e.startsWith(n)?(this.pushToken({tokens:[46],pos:this.generatePos(e,n),value:n}),!0):!1}unknownToken(e){return this.pushToken({tokens:[41],pos:this.generatePos(e," "),value:e}),!0}isString(e){if(this.inComment)return!1;let n=e[0];if(n==='"'||n==="'"){let r=e.length-1;if(this.columnNumber+1<r)throw new Error("Error while rewinding");return this.columnNumber-=r,this.getString(n),!0}return!1}generatePos(e,n){let r=this.columnNumber-e.length,i=n.length;return{line:this.lineNumber,col:r,len:i,colEnd:r+i}}};var OT=require("fs"),ba=require("path"),Qc=q(j());var ft=class extends te{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var aD=require("path"),Yf=q(j());var kr=class extends te{constructor(n,r){super();this.keyword=n;this.path=r;this.docSymbolsMeta={name:`Include ${r}`,kind:Yf.SymbolKind.File},this.addChild(n),this.addChild(r)}get resolvedPath(){return this._resolvedPath}set resolvedPath(n){this.docSymbolsMeta={name:`Include ${n}`,kind:Yf.SymbolKind.File},this._resolvedPath=n}},Ta=class extends te{constructor(n,r,i){super(i);this._path=n;this.relative=r;this.docSymbolsMeta={name:(0,aD.basename)(this.path),kind:Yf.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var cD=q(j());var pt=class extends ge{constructor(n,r){super(r);this.name=n;this.docSymbolsMeta={name:this.name.toString(),kind:cD.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var Xf=class extends te{constructor(n,r){super(r);this.operator=n;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var lD=q(j());var va=class extends ft{toString(){return"..."}},mi=class extends te{constructor(n,r){super();this.functionName=n;this.params=r;this.addChild(n),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(n){return he(this.fsPath,n)?[{name:this.functionName.name,kind:lD.SymbolKind.Function,range:ce(this),selectionRange:ce(this),children:this.params.flatMap(r=>r.getDocumentSymbols(n))}]:[]}toString(){return`${this.functionName}(${this.params.map(n=>n.toString()).join(",")})`}};var $i=class t{constructor(){this.positionStack=[];this._issues=[];this.issueLengthPositionStack=[];this.moveEndOfLine=(e,n=!0,r=!1)=>{let i=e.pos.line;if(this.currentToken?.pos.line!==i||!he(this.currentToken?.fsPath,e.fsPath))return;let s=this.currentToken,o=s;for(;this.currentToken?.pos.line===i&&he(this.currentToken?.fsPath,e.fsPath);)o=this.moveToNextToken;return n&&this._issues.push(z(22,s,o,null)),r&&o?.value==="\\"&&o.nextToken?this.moveEndOfLine(o.nextToken,n):o};this.parsing=new Promise(e=>{setTimeout(()=>{this.parse().then(e)})})}reset(){this.issueLengthPositionStack=[],this.positionStack=[],this._issues=[]}get issues(){return this._issues}get stable(){return this.parsing}get done(){return this.peekIndex()>=this.tokens.length}get moveToNextToken(){let e=this.currentToken;if(e)return this.moveStackIndex(),e}enqueueToStack(){this.issueLengthPositionStack.push(this._issues.length),this.positionStack.push(this.peekIndex())}popStack(){let e=this.issueLengthPositionStack.pop()??0;e!==this._issues.length&&this._issues.splice(e),this.positionStack.pop()}mergeStack(){let e=this.issueLengthPositionStack.pop(),n=this.positionStack.pop();if(n===void 0||e===void 0)throw new Error("Index out of bounds");this.positionStack[this.positionStack.length-1]=n}peekIndex(e=1){let n=this.positionStack.at(-1*e);if(n===void 0)throw new Error("Index out of bounds");return n}get currentToken(){return this.tokens.at(this.peekIndex())}get prevToken(){let e=this.peekIndex()-1;if(e!==-1)return this.tokens[e]}moveStackIndex(){let e=this.positionStack.length-1;if(this.positionStack[e]===void 0)throw new Error("Index out of bounds");this.positionStack[e]!==this.tokens.length&&this.positionStack[e]++}checkConcurrentTokens(e){this.enqueueToStack();let n=[];return e.every(r=>{let i=this.currentToken,s=r(i),o=!1;return s!=="no"&&i&&(n.push(i),this.moveToNextToken,o=Vt(i,this.currentToken)),s==="yes"&&o}),this.mergeStack(),n}consumeAnyConcurrentTokens(e){this.enqueueToStack();let n=[],r,i=!0;for(;e.some(s=>s(this.currentToken)==="yes"&&i);)n.push(this.currentToken),r=this.moveToNextToken,i=Vt(r,this.currentToken);return this.mergeStack(),n}getDocumentSymbols(e){return this.allAstItems.flatMap(n=>n.getDocumentSymbols(e))}getWorkspaceSymbols(){return this.allAstItems.flatMap(e=>e.getWorkspaceSymbols())}static push(e,n,r,i,s,o){if(!r||!i||!he(r.fsPath,s)||!he(i.fsPath,s))return;let a=i.pos.colEnd-r.pos.col;o.push({line:r.pos.line,char:r.pos.col,length:i===r?i.pos.len:a,tokenType:e,tokenModifiers:n})}buildSemanticTokens(e,n,r=[]){this.allAstItems.forEach(i=>{i.buildSemanticTokens((...s)=>t.push(...s,n,r))}),r.sort((i,s)=>i.line===s.line?i.char-s.char:i.line-s.line).forEach(i=>e.push(i.line,i.char,i.length,i.tokenType,i.tokenModifiers))}processCIdentifier(e,n,r=!1){this.enqueueToStack();let i=this.consumeAnyConcurrentTokens([19,47,48].map(Le));if(!i.length){this.popStack();return}if(!i?.[0]?.value.match(/^[_A-Za-z]/)){this.popStack();return}let s=i.map(a=>a.value).join(""),o=new pt(s,de(i[0],i.at(-1)));if(r&&!e.has(o.name)){this.popStack();return}return!n&&o.firstToken!==o.lastToken&&o.name!=="defined"&&(e.get(o.name)||this._issues.push(z(42,o.firstToken,o.lastToken,o))),this.mergeStack(),o}isOperator(){this.enqueueToStack();let e=this.moveToNextToken;if(!e){this.popStack();return}let n=e,r;if(U(e,40)?(r="&",U(this.currentToken,40)&&(r="&&",n=this.moveToNextToken)):U(e,6)?(r="!",U(this.currentToken,0)&&(r="!=",n=this.moveToNextToken)):U(e,10)?r="~":U(e,8)?(r="|",U(this.currentToken,8)&&(r="||",n=this.moveToNextToken)):U(e,9)?r="^":U(e,4)?(r=">",U(this.currentToken,4)?(r=">>",n=this.moveToNextToken):U(this.currentToken,0)&&(r=">=",n=this.moveToNextToken)):U(e,5)?(r="<",U(this.currentToken,5)?(r="<<",n=this.moveToNextToken):U(this.currentToken,0)&&(r="<=",n=this.moveToNextToken)):U(e,15)?r="+":U(e,16)?r="-":U(e,17)?r="*":U(e,13)?r="/":U(e,18)?r="%":U(e,46)?U(this.currentToken,46)&&(r="##",n=this.moveToNextToken):U(e,0)&&U(this.currentToken,0)&&(r="==",n=this.moveToNextToken),r){let i=new Xf(r,de(e,n));return this.mergeStack(),i}this.popStack()}parseScopedBlock(e,n,r){this.enqueueToStack();let i=this.moveToNextToken;if(!i||!e(i)){this.popStack();return}let s=this.peekIndex(),o=()=>{this.positionStack[this.positionStack.length-1]=s},a=m=>m.flatMap(h=>"items"in h?a(h.items):h),c=[i],l=[],u=[];u[0]={rewind:o,tokens:[]};let d=this.currentToken;for(;d&&!n(d);){if(r?.(d)){let m=this.peekIndex()+1,h=()=>{this.positionStack[this.positionStack.length-1]=m};c.push(d),l.push(d),u[u.length]={rewind:h,tokens:[]}}else if(e(d)){let m=this.parseScopedBlock(e,n,r);m&&(c.push(m),u[u.length-1].tokens.push(...a(m.items))),d=this.currentToken;continue}else c.push(d),u[u.length-1].tokens.push(d);this.moveToNextToken,d=this.currentToken}let f=d;f&&n(f)&&(this.moveToNextToken,c.push(f));let p={startToken:i,items:c,splitTokens:u,endToken:f,separatorTokens:l};return this.mergeStack(),p}isFunctionCall(e){this.enqueueToStack();let n=this.processCIdentifier(e,!1);if(!n){this.popStack();return}if(!Vt(n.lastToken,this.currentToken)){this.popStack();return}let r=this.processMacroCallParams();if(!r){this.popStack();return}if(n.name==="defined")r.length>1?this._issues.push(z(44,n.firstToken,n.lastToken,n)):r.length<1&&this._issues.push(z(45,n.firstToken,n.lastToken,n));else{let s=e.get(n.name)?.macro;s&&(s?.identifier instanceof mi?s.identifier.params.at(-1)instanceof va||(r.length>s.identifier.params.length?this._issues.push(z(44,n.firstToken,n.lastToken,n,{linkedTo:[s]})):r.length<s.identifier.params.length&&this._issues.push(z(45,n.firstToken,n.lastToken,n,{linkedTo:[s]}))):this._issues.push(z(43,n.firstToken,n.lastToken,n)))}let i=new Ut(n,r);return i.lastToken=this.prevToken,this.mergeStack(),i}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([tt("0"),tt("x",{caseInsensitive:!0})]);if(e.length!==2){this.popStack();return}let n=this.consumeAnyConcurrentTokens([19,20].map(Le));if(!n.length){this.popStack();return}let r=Number.parseInt(n.map(s=>s.value).join(""),16),i=new Zt(r,de(e[0],n.at(-1)),16);return this.mergeStack(),i}processDec(e=!1){this.enqueueToStack();let n;e&&(U(this.currentToken,16)||U(this.currentToken,15))&&Vt(this.currentToken,this.currentToken?.nextToken)&&(n=this.moveToNextToken);let r=this.consumeAnyConcurrentTokens([19].map(Le));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(o=>o.value).join(""),10);n&&U(n,16)&&(i=4294967295-i);let s=new Zt(i,de(n??r[0],r.at(-1)),10);return this.mergeStack(),s}processEnclosedExpression(e,n){this.enqueueToStack();let r,i;if(U(this.currentToken,42)){let s;r=this.moveToNextToken,i=r;let o=this.processExpression(e,n,!0);return o&&(s=new Qt(o,!0),o=new Qt(s,!1),s.openBracket=r),U(this.currentToken,43)?(i=this.moveToNextToken,s&&(s.closeBracket=i)):r&&this._issues.push(z(26,r,r,n)),this.mergeStack(),o}this.popStack()}processExpression(e,n,r=!1){this.enqueueToStack();let i,s;if(r&&(s=this.isOperator()),i=this.processEnclosedExpression(e,n)||this.isFunctionCall(e)||this.processCIdentifier(e,!1)||this.processHex()||this.processDec(!0),!i){this.popStack();return}if(s&&(i.operator=s),r){let o=this.isOperator();for(;o;){let a=this.processExpression(e,n,!0);a?i instanceof Qt?i.addExpression(o,a):i=new Qt(i,!1,{operator:o,expression:a}):this._issues.push(z(27,o.firstToken,o.lastToken,n)),o=this.isOperator()}}return this.mergeStack(),i}processMacroCallParams(){if(!U(this.currentToken,42))return;let e=this.parseScopedBlock(r=>!!U(r,42),r=>!!U(r,43),r=>!!U(r,24));return e?.items.length===2&&U(e.endToken,43)?[]:e?.splitTokens.map((r,i)=>{if(r.tokens.length===0)return null;let s=new hi(r.tokens.map((o,a)=>{let c=o.value;return o.pos.line===r.tokens.at(a+1)?.pos.line?c=c.padEnd(r.tokens[a+1].pos.col-o.pos.col," "):o.value==="\\"&&(c=c.slice(0,-1)),c}).join(""),de(r.tokens[0],r.tokens.at(-1)),i);return s.splitToken=e.separatorTokens.at(i),s})}};var cr=class extends te{constructor(n){super();this.comments=n;this.disabled=!1;n.forEach(this.addChild.bind(this))}toString(){return this.comments.map(n=>n.toString()).join(`
281
+ `){let o=this.lineNumber,a=this.columnNumber,c=n.length;this.pushToken({tokens:[21],value:n,pos:{col:a-c,line:o,len:c,colEnd:a}}),n=""}else if(this.currentChar==="\\"){let o=this.lineNumber;if(n+=this.currentChar??"",this.move())o===this.lineNumber&&(n+=this.currentChar??"");else break}else n+=this.currentChar??"";if(!this.move())break}n+=e;let r=this.lineNumber,i=this.columnNumber+1,s=n.length;this.pushToken({tokens:[21],value:n,pos:{col:i-s,line:r,len:s,colEnd:i}}),this.move()}lexIt(){for(;!this.endOfFile;){for(;this.isWhiteSpace();)this.move();let e=this.getWord();e&&this.process(e)}}static{this.SINGLE_CHAR_TOKENS=new Map([["{",[2]],["}",[3]],["(",[42]],[")",[43]],["[",[11]],["]",[12]],[";",[1]],[":",[50]],["=",[0]],[">",[4]],["<",[5]],["!",[6]],["|",[8]],["^",[9]],["&",[40,7]],["~",[10]],["/",[13]],["\\",[14]],["+",[15]],["-",[16]],["*",[17]],["%",[18]],["?",[44]],[".",[45]],["_",[48]],["@",[49]],[",",[24]]])}static{this.KEYWORD_TOKENS=new Map([["true",38],["false",39],["#define",25],["#include",26],["#line",27],["#undef",28],["#error",29],["#pragma",30],["#defined",31],["#if",32],["#ifdef",33],["#ifndef",34],["#elif",35],["#else",36],["#endif",37]])}process(e){let n=this.isString(e);if(!n){let i=t.KEYWORD_TOKENS.get(e.toLowerCase());if(i&&(n=!0,this.pushToken({tokens:[i],value:e.toLowerCase(),pos:this.generatePos(e,e.toLowerCase())}),i===39||i===38)){let s=this.tokens.length-1;if(Vt(this.tokens[s-1],this.tokens[s]))n=!1,this.tokens.pop();else return!0}}if(n||(n=this.isDigit(e)||this.isHexDigit(e)||this.isLetters(e)),!n&&e.length===1){let i=t.SINGLE_CHAR_TOKENS.get(e);if(i)return n=!0,this.pushToken({tokens:i,value:e,pos:this.generatePos(e,e)}),!0}if(n||(n=this.isHash(e)||this.unknownToken(e)),!n)throw new Error(`Lexer is not complete!!! Could not find token for "${e}"`);let r=this._tokens[this._tokens.length-1];return n&&!r?.tokens.some(i=>i===21)&&r&&r.pos.len<e.length?this.process(e.slice(r.pos.len)):!0}pushToken(e){let n={tokens:e.tokens,pos:e.pos,value:e.value,fsPath:this.fsPath},r=this._tokens[this._tokens.length-1];n.prevToken=r,r&&(r.nextToken=n),this._tokens.push(n)}isLetters(e){let n=e[0]?.charCodeAt(0);if(t.isLetterCode(n)){let r="";for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(t.isLetterCode(s))r+=e[i];else break}return this.pushToken({tokens:[47],value:r,pos:this.generatePos(e,r)}),!0}return!1}isDigit(e){let n=e[0],r=n?.charCodeAt(0);return r>=48&&r<=57?(this.pushToken({tokens:[20,19],value:n,pos:this.generatePos(e,n)}),!0):!1}isHexDigit(e){let n=e[0],r=n?.charCodeAt(0);return r>=65&&r<=70||r>=97&&r<=102?(this.pushToken({tokens:[20,47],value:n,pos:this.generatePos(e,n)}),!0):!1}isHash(e){let n="#";return e.startsWith(n)?(this.pushToken({tokens:[46],pos:this.generatePos(e,n),value:n}),!0):!1}unknownToken(e){return this.pushToken({tokens:[41],pos:this.generatePos(e," "),value:e}),!0}isString(e){if(this.inComment)return!1;let n=e[0];if(n==='"'||n==="'"){let r=e.length-1;if(this.columnNumber+1<r)throw new Error("Error while rewinding");return this.columnNumber-=r,this.getString(n),!0}return!1}generatePos(e,n){let r=this.columnNumber-e.length,i=n.length;return{line:this.lineNumber,col:r,len:i,colEnd:r+i}}};var OT=require("fs"),ba=require("path"),Qc=q(j());var ft=class extends te{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var aD=require("path"),Yf=q(j());var kr=class extends te{constructor(n,r){super();this.keyword=n;this.path=r;this.docSymbolsMeta={name:`Include ${r}`,kind:Yf.SymbolKind.File},this.addChild(n),this.addChild(r)}get resolvedPath(){return this._resolvedPath}set resolvedPath(n){this.docSymbolsMeta={name:`Include ${n}`,kind:Yf.SymbolKind.File},this._resolvedPath=n}},Ta=class extends te{constructor(n,r,i){super(i);this._path=n;this.relative=r;this.docSymbolsMeta={name:(0,aD.basename)(this.path),kind:Yf.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var cD=q(j());var pt=class extends ge{constructor(n,r){super(r);this.name=n;this.docSymbolsMeta={name:this.name.toString(),kind:cD.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var Xf=class extends te{constructor(n,r){super(r);this.operator=n;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var lD=q(j());var va=class extends ft{toString(){return"..."}},mi=class extends te{constructor(n,r){super();this.functionName=n;this.params=r;this.addChild(n),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(n){return pe(this.fsPath,n)?[{name:this.functionName.name,kind:lD.SymbolKind.Function,range:ce(this),selectionRange:ce(this),children:this.params.flatMap(r=>r.getDocumentSymbols(n))}]:[]}toString(){return`${this.functionName}(${this.params.map(n=>n.toString()).join(",")})`}};var $i=class t{constructor(){this.positionStack=[];this._issues=[];this.issueLengthPositionStack=[];this.moveEndOfLine=(e,n=!0,r=!1)=>{let i=e.pos.line;if(this.currentToken?.pos.line!==i||!pe(this.currentToken?.fsPath,e.fsPath))return;let s=this.currentToken,o=s;for(;this.currentToken?.pos.line===i&&pe(this.currentToken?.fsPath,e.fsPath);)o=this.moveToNextToken;return n&&this._issues.push(z(22,s,o,null)),r&&o?.value==="\\"&&o.nextToken?this.moveEndOfLine(o.nextToken,n):o};this.parsing=new Promise(e=>{setTimeout(()=>{this.parse().then(e)})})}reset(){this.issueLengthPositionStack=[],this.positionStack=[],this._issues=[]}get issues(){return this._issues}get stable(){return this.parsing}get done(){return this.peekIndex()>=this.tokens.length}get moveToNextToken(){let e=this.currentToken;if(e)return this.moveStackIndex(),e}enqueueToStack(){this.issueLengthPositionStack.push(this._issues.length),this.positionStack.push(this.peekIndex())}popStack(){let e=this.issueLengthPositionStack.pop()??0;e!==this._issues.length&&this._issues.splice(e),this.positionStack.pop()}mergeStack(){let e=this.issueLengthPositionStack.pop(),n=this.positionStack.pop();if(n===void 0||e===void 0)throw new Error("Index out of bounds");this.positionStack[this.positionStack.length-1]=n}peekIndex(e=1){let n=this.positionStack.at(-1*e);if(n===void 0)throw new Error("Index out of bounds");return n}get currentToken(){return this.tokens.at(this.peekIndex())}get prevToken(){let e=this.peekIndex()-1;if(e!==-1)return this.tokens[e]}moveStackIndex(){let e=this.positionStack.length-1;if(this.positionStack[e]===void 0)throw new Error("Index out of bounds");this.positionStack[e]!==this.tokens.length&&this.positionStack[e]++}checkConcurrentTokens(e){this.enqueueToStack();let n=[];return e.every(r=>{let i=this.currentToken,s=r(i),o=!1;return s!=="no"&&i&&(n.push(i),this.moveToNextToken,o=Vt(i,this.currentToken)),s==="yes"&&o}),this.mergeStack(),n}consumeAnyConcurrentTokens(e){this.enqueueToStack();let n=[],r,i=!0;for(;e.some(s=>s(this.currentToken)==="yes"&&i);)n.push(this.currentToken),r=this.moveToNextToken,i=Vt(r,this.currentToken);return this.mergeStack(),n}getDocumentSymbols(e){return this.allAstItems.flatMap(n=>n.getDocumentSymbols(e))}getWorkspaceSymbols(){return this.allAstItems.flatMap(e=>e.getWorkspaceSymbols())}static push(e,n,r,i,s,o){if(!r||!i||!pe(r.fsPath,s)||!pe(i.fsPath,s))return;let a=i.pos.colEnd-r.pos.col;o.push({line:r.pos.line,char:r.pos.col,length:i===r?i.pos.len:a,tokenType:e,tokenModifiers:n})}buildSemanticTokens(e,n,r=[]){this.allAstItems.forEach(i=>{i.buildSemanticTokens((...s)=>t.push(...s,n,r))}),r.sort((i,s)=>i.line===s.line?i.char-s.char:i.line-s.line).forEach(i=>e.push(i.line,i.char,i.length,i.tokenType,i.tokenModifiers))}processCIdentifier(e,n,r=!1){this.enqueueToStack();let i=this.consumeAnyConcurrentTokens([19,47,48].map(Le));if(!i.length){this.popStack();return}if(!i?.[0]?.value.match(/^[_A-Za-z]/)){this.popStack();return}let s=i.map(a=>a.value).join(""),o=new pt(s,de(i[0],i.at(-1)));if(r&&!e.has(o.name)){this.popStack();return}return!n&&o.firstToken!==o.lastToken&&o.name!=="defined"&&(e.get(o.name)||this._issues.push(z(42,o.firstToken,o.lastToken,o))),this.mergeStack(),o}isOperator(){this.enqueueToStack();let e=this.moveToNextToken;if(!e){this.popStack();return}let n=e,r;if(U(e,40)?(r="&",U(this.currentToken,40)&&(r="&&",n=this.moveToNextToken)):U(e,6)?(r="!",U(this.currentToken,0)&&(r="!=",n=this.moveToNextToken)):U(e,10)?r="~":U(e,8)?(r="|",U(this.currentToken,8)&&(r="||",n=this.moveToNextToken)):U(e,9)?r="^":U(e,4)?(r=">",U(this.currentToken,4)?(r=">>",n=this.moveToNextToken):U(this.currentToken,0)&&(r=">=",n=this.moveToNextToken)):U(e,5)?(r="<",U(this.currentToken,5)?(r="<<",n=this.moveToNextToken):U(this.currentToken,0)&&(r="<=",n=this.moveToNextToken)):U(e,15)?r="+":U(e,16)?r="-":U(e,17)?r="*":U(e,13)?r="/":U(e,18)?r="%":U(e,46)?U(this.currentToken,46)&&(r="##",n=this.moveToNextToken):U(e,0)&&U(this.currentToken,0)&&(r="==",n=this.moveToNextToken),r){let i=new Xf(r,de(e,n));return this.mergeStack(),i}this.popStack()}parseScopedBlock(e,n,r){this.enqueueToStack();let i=this.moveToNextToken;if(!i||!e(i)){this.popStack();return}let s=this.peekIndex(),o=()=>{this.positionStack[this.positionStack.length-1]=s},a=m=>m.flatMap(h=>"items"in h?a(h.items):h),c=[i],l=[],u=[];u[0]={rewind:o,tokens:[]};let d=this.currentToken;for(;d&&!n(d);){if(r?.(d)){let m=this.peekIndex()+1,h=()=>{this.positionStack[this.positionStack.length-1]=m};c.push(d),l.push(d),u[u.length]={rewind:h,tokens:[]}}else if(e(d)){let m=this.parseScopedBlock(e,n,r);m&&(c.push(m),u[u.length-1].tokens.push(...a(m.items))),d=this.currentToken;continue}else c.push(d),u[u.length-1].tokens.push(d);this.moveToNextToken,d=this.currentToken}let f=d;f&&n(f)&&(this.moveToNextToken,c.push(f));let p={startToken:i,items:c,splitTokens:u,endToken:f,separatorTokens:l};return this.mergeStack(),p}isFunctionCall(e){this.enqueueToStack();let n=this.processCIdentifier(e,!1);if(!n){this.popStack();return}if(!Vt(n.lastToken,this.currentToken)){this.popStack();return}let r=this.processMacroCallParams();if(!r){this.popStack();return}if(n.name==="defined")r.length>1?this._issues.push(z(44,n.firstToken,n.lastToken,n)):r.length<1&&this._issues.push(z(45,n.firstToken,n.lastToken,n));else{let s=e.get(n.name)?.macro;s&&(s?.identifier instanceof mi?s.identifier.params.at(-1)instanceof va||(r.length>s.identifier.params.length?this._issues.push(z(44,n.firstToken,n.lastToken,n,{linkedTo:[s]})):r.length<s.identifier.params.length&&this._issues.push(z(45,n.firstToken,n.lastToken,n,{linkedTo:[s]}))):this._issues.push(z(43,n.firstToken,n.lastToken,n)))}let i=new Ut(n,r);return i.lastToken=this.prevToken,this.mergeStack(),i}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([tt("0"),tt("x",{caseInsensitive:!0})]);if(e.length!==2){this.popStack();return}let n=this.consumeAnyConcurrentTokens([19,20].map(Le));if(!n.length){this.popStack();return}let r=Number.parseInt(n.map(s=>s.value).join(""),16),i=new Zt(r,de(e[0],n.at(-1)),16);return this.mergeStack(),i}processDec(e=!1){this.enqueueToStack();let n;e&&(U(this.currentToken,16)||U(this.currentToken,15))&&Vt(this.currentToken,this.currentToken?.nextToken)&&(n=this.moveToNextToken);let r=this.consumeAnyConcurrentTokens([19].map(Le));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(o=>o.value).join(""),10);n&&U(n,16)&&(i=4294967295-i);let s=new Zt(i,de(n??r[0],r.at(-1)),10);return this.mergeStack(),s}processEnclosedExpression(e,n){this.enqueueToStack();let r,i;if(U(this.currentToken,42)){let s;r=this.moveToNextToken,i=r;let o=this.processExpression(e,n,!0);return o&&(s=new Qt(o,!0),o=new Qt(s,!1),s.openBracket=r),U(this.currentToken,43)?(i=this.moveToNextToken,s&&(s.closeBracket=i)):r&&this._issues.push(z(26,r,r,n)),this.mergeStack(),o}this.popStack()}processExpression(e,n,r=!1){this.enqueueToStack();let i,s;if(r&&(s=this.isOperator()),i=this.processEnclosedExpression(e,n)||this.isFunctionCall(e)||this.processCIdentifier(e,!1)||this.processHex()||this.processDec(!0),!i){this.popStack();return}if(s&&(i.operator=s),r){let o=this.isOperator();for(;o;){let a=this.processExpression(e,n,!0);a?i instanceof Qt?i.addExpression(o,a):i=new Qt(i,!1,{operator:o,expression:a}):this._issues.push(z(27,o.firstToken,o.lastToken,n)),o=this.isOperator()}}return this.mergeStack(),i}processMacroCallParams(){if(!U(this.currentToken,42))return;let e=this.parseScopedBlock(r=>!!U(r,42),r=>!!U(r,43),r=>!!U(r,24));return e?.items.length===2&&U(e.endToken,43)?[]:e?.splitTokens.map((r,i)=>{if(r.tokens.length===0)return null;let s=new hi(r.tokens.map((o,a)=>{let c=o.value;return o.pos.line===r.tokens.at(a+1)?.pos.line?c=c.padEnd(r.tokens[a+1].pos.col-o.pos.col," "):o.value==="\\"&&(c=c.slice(0,-1)),c}).join(""),de(r.tokens[0],r.tokens.at(-1)),i);return s.splitToken=e.separatorTokens.at(i),s})}};var cr=class extends te{constructor(n){super();this.comments=n;this.disabled=!1;n.forEach(this.addChild.bind(this))}toString(){return this.comments.map(n=>n.toString()).join(`
282
282
  `)}},lr=class extends te{constructor(n){super(n);this.disabled=!1;this.semanticTokenType="comment",this.semanticTokenModifiers="documentation"}toString(){let n,r=this.firstToken,i="";for(;r!==this.lastToken;)i+=r?.value.padStart(r.value.length+(n?r.pos.col-n.pos.colEnd:0)," "),n=r,r=r?.nextToken;r&&(i+=r?.value.padStart(r.value.length+(n?r.pos.col-n.pos.colEnd:0)," "));let s=i.match(/^\s*(?:(?:\/\/|\/\*+)\s*)?(.*?)\s*(?:\*\/)?\s*$/s);return s?s[1]:""}};var Jf=class t extends $i{constructor(n,r=()=>An().requestTokens(this.fsPath,!0)){super();this.fsPath=n;this.getTokens=r;this.comments=[];this.tokens=[]}cleanUpComments(){let n=[];for(let r=0;r<this.tokens.length;r++){let i=t.processBlockComment(this.tokens,r)||t.processLineComment(this.tokens,r);i&&(r=i.index,n.push(...i.tokenUsed),this.comments.push(i.comment))}if(n.length>0){let r=new Set(n),i=[];for(let s=0;s<this.tokens.length;s++)r.has(s)||i.push(this.tokens[s]);this.tokens=i}}get allAstItems(){return this.comments}reset(){super.reset(),this.comments=[]}reparse(){return this.reset(),this.parse()}async parse(){this.tokens=this.getTokens(),this.cleanUpComments()}static processBlockComment(n,r){let i=[],s=()=>(i.push(r++),n[r]),o=()=>n[r],a=()=>n[r-1],c=o(),l=c;if(!c||!U(c,13)||(l=s(),!U(l,17)||c.pos.line!==l.pos.line||c.pos.col+1!==l.pos.col))return;let u=()=>!(!U(a(),17)||!U(o(),13)||!Vt(a(),o())),d=l.pos.line,f=c,p=[];l=s();do{if(o()?.pos.line!==d){let y=new lr(de(f,a()));p.push(y),d=o().pos.line??0,f=o()}l=s()}while(r<n.length&&!u());let m=new lr(de(f,o()));p.push(m);let h=new cr(p);return s(),{comment:h,tokenUsed:i,index:r-1}}static processLineComment(n,r){let i=[];if(!U(n[r],13)||n.length===r+1||!U(n[r+1],13)||!Vt(n[r],n[r+1]))return;for(;n[r].pos.line===n.at(r+1)?.pos.line;)i.push(r++);return i.push(r++),{comment:new lr(de(n[i[0]],n[i.at(-1)])),tokenUsed:i,index:r-1}}};var uD=q(j());var Qf=class extends te{constructor(n,r){super(n);this.content=r}toString(){let n=this.content.filter(r=>!U(r,14));return n.map((r,i)=>{let s=r.value;return r.pos.line===n.at(i+1)?.pos.line?s=s.padEnd(n[i+1].pos.col-r.pos.col," "):n.at(i+1)&&(s=s.padEnd(s.length+1," ")),s}).join("")}},Kc=class extends te{constructor(n,r,i){super();this.keyword=n;this.identifier=r;this.content=i;this.addChild(n),this.addChild(this.identifier),this.content&&this.addChild(this.content)}get name(){return this.identifier instanceof pt?this.identifier.name:this.identifier.functionName.name}toString(){return this.toStringCache??=[this.identifier.toString(),...this.content?[this.content?.toString()]:[]].join(" "),this.toStringCache}toMarkupContent(){return{kind:uD.MarkupKind.Markdown,value:["```cpp",`#define ${this.toString()}`,"```"].join(`
283
- `)}}};var co=class extends te{constructor(e){super(e)}},Yc=class extends te{constructor(n,r){super();this.keyword=n;this.content=r;this.active=!1;this.addChild(n)}},Xc=class extends Yc{constructor(n,r,i){super(n,i);this.identifier=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.identifier&&n.has(this.identifier.name)}},Zf=class extends Yc{constructor(n,r,i){super(n,i);this.expression=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.expression?.isTrue(n)}},ep=class extends Xc{useBlock(e){return this.identifier&&!e.has(this.identifier.name)}},Jc=class extends Yc{};var Yr=(t,e)=>{let n=t,r=[];for(;n&&(r.push(n),n!==e);)n=n.nextToken;return r},Xr=class extends te{constructor(n,r,i){super();this.ifDef=n;this.endIf=r;this.elseOption=i;this.addChild(n),i&&this.addChild(i),this.addChild(r)}get inactiveRanges(){if(this.elseOption&&!this.elseOption.active){let n=this.elseOption.firstToken,r=this.elseOption.content?.lastToken??this.endIf?.firstToken??this.lastToken;return[Qe.create(ae(n),ae(r))]}if(!this.ifDef.active){let n=this.ifDef.firstToken,r=this.ifDef.content?this.ifDef.content?.lastToken:this.elseOption?this.elseOption.firstToken:this.endIf?.lastToken;return[Qe.create(ae(n),ae(r??this.ifDef.lastToken))]}return[]}getInValidTokenRange(n){if(!this.ifDef.identifier)return new WeakSet(Yr(this.firstToken,this.lastToken));let r=this.ifDef.useBlock(n);return r?this.ifDef.active=!0:this.elseOption&&(this.elseOption.active=!0),this.getInValidTokenRangeWhenActiveBlock(r?this.ifDef:this.elseOption)}getInValidTokenRangeWhenActiveBlock(n){let r=new WeakSet,i=(this.ifDef.identifier??this.ifDef.keyword).lastToken;Yr(this.ifDef.firstToken,i).forEach(o=>r.add(o));let s=this.ifDef===n;return!s&&this.ifDef.content&&Yr(this.ifDef.content.firstToken,this.ifDef.content.lastToken).forEach(o=>r.add(o)),this.elseOption&&(Yr(this.elseOption.firstToken,this.elseOption.keyword.lastToken).forEach(o=>r.add(o)),s&&this.elseOption.content&&Yr(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(o=>r.add(o))),this.endIf&&Yr(this.endIf.firstToken,this.endIf.lastToken).forEach(o=>r.add(o)),r}},Pr=class extends te{constructor(n,r,i){super();this.ifBlocks=n;this.endIf=r;this.elseOption=i;n.forEach(s=>this.addChild(s)),i&&this.addChild(i),this.addChild(r)}getInValidTokenRange(n){let r=this.ifBlocks.find(i=>i.useBlock(n));return r?r.active=!0:this.elseOption&&(this.elseOption.active=!0),this.getInValidTokenRangeWhenActiveBlock(r||this.elseOption)}get inactiveRanges(){let n=[],r=!!this.elseOption;if(this.ifBlocks.forEach((o,a)=>{if(o.active)return;let c=a===this.ifBlocks.length-1,l=o.firstToken,u=c?r?this.elseOption.firstToken:this.lastToken:o.content?.lastToken??this.ifBlocks[a+1].firstToken??o.lastToken;n.push(Qe.create(ae(l),ae(u)))}),this.elseOption&&n.length){let o=this.elseOption.firstToken,a=this.elseOption.content?.lastToken??this.endIf?.lastToken??this.lastToken;return[Qe.create(ae(o),ae(a))]}let i=this.firstToken,s=this.lastToken;return[Qe.create(ae(i),ae(s))]}getInValidTokenRangeWhenActiveBlock(n){let r=new WeakSet,i=!1;return this.ifBlocks.forEach(s=>{let o=s.expression?.lastToken??s.keyword.lastToken;Yr(s.firstToken,o).forEach(a=>r.add(a)),!i&&s===n?i=!0:s.content&&Yr(s.content.firstToken,s.content.lastToken).forEach(a=>r.add(a))}),this.elseOption&&(Yr(this.elseOption.keyword.firstToken,this.elseOption.keyword.lastToken).forEach(s=>r.add(s)),i&&this.elseOption.content&&Yr(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(s=>r.add(s))),this.endIf&&Yr(this.endIf.firstToken,this.endIf.lastToken).forEach(s=>r.add(s)),r}};var _a=class extends $i{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.getTokens=s;this.optimizeForFormatting=o;this.tokens=[];this.nodes=[];this._comments=[];this.dtsIncludes=[];this.macroSnapShot=new Map;this.macros=new Map;this.rangesToClean=new Set;this.macroStart=!1;i&&(Array.from(i).forEach(([a,c])=>this.macroSnapShot.set(a,c)),Array.from(i).forEach(([a,c])=>this.macros.set(a,c)))}get comments(){return this._comments}removeComments(n){this._comments=this._comments.filter(r=>!n.has(r))}get currentToken(){let n=this.prevToken,r=this.peekIndex(),i=this.tokens.at(r),s=ln(n,i)||!n||U(n,14)&&n.pos.line+1===i?.pos.line;if(!(this.macroStart&&!s))return this.macroStart&&U(i,14)?(this.moveStackIndex(),this.currentToken):i}reset(n){super.reset(),this.macros.clear(),n?(this.macroSnapShot.clear(),Array.from(n).forEach(([r,i])=>this.macroSnapShot.set(r,i)),Array.from(n).forEach(([r,i])=>this.macros.set(r,i))):Array.from(this.macroSnapShot).forEach(([r,i])=>this.macros.set(r,i)),this.nodes=[],this.dtsIncludes=[],this.rangesToClean=new Set}async reparse(n){let r=this.stable;return this.parsing=new Promise(i=>{r.then(()=>{if(n&&n.size===this.macroSnapShot.size){let s=Array.from(n);if(Array.from(this.macroSnapShot).every(([o,a],c)=>{let[l,u]=s[c];return l===o&&u.macro.toString()===a.macro.toString()})){console.log("header file cache hit",this.fsPath),i();return}}this.reset(n),this.parse().then(i)})}),this.parsing}async parse(){let n=new Jf(this.fsPath,this.getTokens);if(await n.stable,this.tokens=n.tokens,this._comments=n.allAstItems,this.positionStack.push(0),this.tokens.length!==0){for(;!this.done;)await this.lineProcessor();if(this.rangesToClean.size&&!this.fsPath.endsWith(".h")&&(this.tokens=this.tokens.filter(r=>!this.rangesToClean.has(r))),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}}async lineProcessor(){if(this.enqueueToStack(),!(!this.prevToken||this.prevToken.pos.line!==this.currentToken?.pos.line||!he(this.prevToken.fsPath,this.currentToken.fsPath))){this.moveEndOfLine(this.prevToken,!1),this.mergeStack();return}let r=this.currentToken,i=await this.processInclude()||this.processDefinitions()||this.processUndef()||this.processError();this.processIfDefBlocks(),r&&this.moveEndOfLine(r,!!i),this.mergeStack()}addTokensToClean(n){for(let r=n.start;r<n.start+n.count;r++){let i=this.tokens[r];i&&this.rangesToClean.add(i)}}processDefinitions(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!U(r,25))return this.popStack(),!1;this.macroStart=!0;let i=new ft(de(r)),s=this.isFunctionDefinition()||this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(z(30,i.firstToken,i.lastToken,i)),this.mergeStack(),this.macroStart=!1,!0;let o=this.consumeDefinitionContent(),a;o.length&&(a=new Qf(de(o[0],o.at(-1)),o));let c=new Kc(i,s,a);this.macros.set(c.name,{macro:c,resolver:sE(c.toString())}),this.nodes.push(c);let l=this.peekIndex();return this.addTokensToClean({start:n,count:l-n}),this.mergeStack(),this.macroStart=!1,!0}processUndef(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!U(r,28))return this.popStack(),!1;this.macroStart=!0;let i=new ft(de(r)),s=this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(z(30,i.firstToken,i.lastToken,i)),this.mergeStack(),this.macroStart=!1,!0;let o=new Kc(i,s);this.macros.delete(s.name),this.nodes.push(o);let a=this.peekIndex();return this.addTokensToClean({start:n,count:a-n}),this.mergeStack(),this.macroStart=!1,!0}processError(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!U(r,29))return this.popStack(),!1;this.moveEndOfLine(r,!1,!0);let i=this.peekIndex();return this.addTokensToClean({start:n,count:i-n}),this.mergeStack(),!0}consumeDefinitionContent(){let n=[];for(;this.currentToken;){let r=this.moveToNextToken;r&&n.push(r)}return n}isFunctionDefinition(){this.enqueueToStack();let n=this.processCIdentifier(this.macros,!0);if(!n){this.popStack();return}let r=this.moveToNextToken;if(!U(r,42)||!Vt(n.lastToken,r)){this.popStack();return}let i=[],s=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;s;)i.push(s),!U(this.currentToken,24)&&!U(this.currentToken,43)?this._issues.push(z(28,s.firstToken,s.lastToken,s)):U(this.currentToken,43)||(r=this.moveToNextToken),s=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new mi(n,i);if(U(this.currentToken,43))r=this.moveToNextToken,o.lastToken=r;else{o.lastToken=this.prevToken;let a=i.at(-1)??o;this._issues.push(z(26,a.firstToken,a.lastToken,a))}return this.mergeStack(),o}processVariadic(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(45),Le(45),Le(45)]);if(n.length!==3){this.popStack();return}let r=new va(de(n[0],n.at(-1)));return this.mergeStack(),r}processIfDefBlocks(){let n=this.peekIndex(),r=this.parseScopedBlock(a=>!!a&&[33,34,32].some(c=>U(a,c))&&!ln(a.prevToken,a),a=>!!a&&[37].some(c=>U(a,c))&&!ln(a.prevToken,a),a=>!!a&&[36,35].some(c=>U(a,c))&&!ln(a.prevToken,a));if(!r)return;let i;U(r.startToken,32)?i=this.processIfBlock(r,(a,c,l)=>new Zf(a,c??null,l)):i=this.processIfDefBlock(r,(a,c,l)=>U(r.startToken,33)?new Xc(a,c??null,l):new ep(a,c??null,l)),this.nodes.push(i);let s=i.getInValidTokenRange(this.macros);this.tokens=this.tokens.filter(a=>!s.has(a));let o=i.inactiveRanges;this._comments.forEach(a=>{o.some(c=>Mf(c,a.range))&&(a.disabled=!0)}),[...i instanceof Pr?i.ifBlocks:[i.ifDef],...i.elseOption?[i.elseOption]:[]].forEach(a=>{!a.active&&a.content&&this._issues.push(z(47,a.content.firstToken,a.content.lastToken,a.content,{severity:Qc.DiagnosticSeverity.Hint,tags:[Qc.DiagnosticTag.Unnecessary]}))}),this.positionStack[this.positionStack.length-1]=n}processIfDefBlock(n,r){this.enqueueToStack(),this.macroStart=!0;let i=new ft(de(n.startToken));n.splitTokens[0].rewind();let s=this.processCIdentifier(this.macros,!0);s||this._issues.push(z(31,i.firstToken,i.lastToken,i)),this.macroStart=!1;let o,a=n.splitTokens[0].tokens.indexOf(s?.lastToken??i.lastToken)+1,c=n.splitTokens[0].tokens[a];a&&c&&(o=new co(de(c,n.splitTokens[0].tokens.at(-1))));let l=r(i,s??null,o??null),u;if(n.splitTokens.length>1){let p=n.separatorTokens[0],m=new ft(de(p)),h;n.splitTokens[1].tokens.length&&(h=new co(de(n.splitTokens[1].tokens[0],n.splitTokens[1].tokens.at(-1)))),u=new Jc(m,h??null)}let d;n.endToken?d=new ft(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let f=new Xr(l,d??null,u);return this.mergeStack(),f}processIfBlock(n,r){this.enqueueToStack();let i=new ft(de(n.startToken)),s=[],o;n.splitTokens.forEach((l,u)=>{l.rewind();let d=this.prevToken,f=new ft(de(d));this.macroStart=!0;let p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0);if(p instanceof pt&&p.name.toLowerCase()==="defined"&&(p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0)),this.macroStart=!1,u===n.splitTokens.length-1&&U(d,36)){let h=d,y=new ft(de(h)),_;l.tokens.length&&(_=new co(de(l.tokens[0],l.tokens.at(-1)))),o=new Jc(y,_??null)}else{p||this._issues.push(z(31,i.firstToken,i.lastToken,i));let h,y=n.splitTokens[0].tokens.indexOf(p?.lastToken??i.lastToken)+1,_=n.splitTokens[0].tokens[y];y&&_&&(h=new co(de(_,n.splitTokens[u].tokens.at(-1))));let v=r(f,p??null,h??null);s.push(v)}});let a;n.endToken?a=new ft(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let c=new Pr(s,a??null,o);return this.mergeStack(),c}get allAstItems(){return[...this.dtsIncludes,...this.nodes,...this.comments]}resolveInclude(n){if(n.path.path)return n.path.relative?[(0,ba.resolve)((0,ba.dirname)(n.fsPath),n.path.path),...this.incudes.map(r=>(0,ba.resolve)(r,n.path.path))].find(r=>(0,OT.existsSync)(r)):this.incudes.map(r=>(0,ba.resolve)(r,n.path.path)).find(r=>(0,OT.existsSync)(r))}async processInclude(){this.enqueueToStack();let n=this.peekIndex(),r=this.currentToken;if(!r)return this.popStack(),!1;let i=r,s=r;if(U(r,26))this.moveToNextToken;else{let h=this.checkConcurrentTokens([Le(13),tt("include"),Le(13)]);if(h.length!==3)return this.popStack(),!1;i=h[0],s=h.at(-1)}let o=i,a=new ft(de(i,s));r=this.moveToNextToken;let c=r,l=!!U(r,21);if(!c||!l&&!U(r,5))return o&&this.moveEndOfLine(o),this.mergeStack(),!0;let u="";if(l)u=r?.value??"";else for(;this.currentToken?.pos.line===o.pos.line&&!U(this.currentToken,4);)u+=this.currentToken?.value??"",r=this.moveToNextToken;let d=new Ta(u,l,de(c,r)),f=new kr(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!U(this.currentToken,4)?this._issues.push(z(12,f.firstToken,f.lastToken,f)):(r=this.moveToNextToken,d.lastToken=r)),this.mergeStack();let p=this.peekIndex(),m=this.resolveInclude(f);if(f.resolvedPath=m,m||this._issues.push(z(36,f.path.firstToken,f.path.lastToken,f.path,{severity:Qc.DiagnosticSeverity.Warning})),m&&!this.optimizeForFormatting){An().requestTokens(m,!0);let h=Zc().getCPreprocessorParser(m,this.incudes,this.macros,this.fsPath);await h.stable,this._issues.push(...h.issues),this.macros.clear(),Array.from(h.macros).forEach(([y,_])=>this.macros.set(y,_)),m.endsWith(".h")?this.addTokensToClean({start:n,count:p-n}):(this.tokens=mE(this.tokens,n,p,h.tokens),this.positionStack[this.positionStack.length-1]=n),this.nodes.push(...h.nodes),this.dtsIncludes.push(...h.dtsIncludes)}else this.addTokensToClean({start:n,count:p-n});return!0}};var MT,tp=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,n,r,i){e=it(e);let s=`${Array.from(r).map(l=>l[1].macro.toString()).join("::")}`,o=this.headerFiles.get(e)?.get(s);if(o)return o.reparse(r),o;console.log("No c-preprocessor cache",e);let a=new _a(e,n,r),c=this.includeOwners.get(a)??new Set;return c.add(i),this.includeOwners.set(a,c),this.headerFiles.has(e)||this.headerFiles.set(e,new Map),this.headerFiles.get(e)?.set(s,a),a}reset(e){e=it(e);let n=this.headerFiles.get(e);n&&Array.from(n).forEach(([r,i])=>{console.log("disposing c-preprocessor cache for",e),Array.from(this.includeOwners.get(i)??[]).forEach(this.reset.bind(this)),this.headerFiles.delete(e)})}};function Zc(){return MT??=new tp,MT}function dD(){MT=new tp}var xT,np=class t{constructor(){this.fileMap=new Map}static clone(e){let n=e.length;if(n===0)return[];let r=new Array(n),i;for(let s=0;s<n;s++){let o=e[s],a={tokens:o.tokens,pos:o.pos,value:o.value,fsPath:o.fsPath,prevToken:i,nextToken:void 0};i&&(i.nextToken=a),r[s]=a,i=a}return r}needsRenew(e,n){return e=it(e),this.fileMap.get(e)?.text!==n}getDocument(e,n){return Vn.create(e,"devicetree",0,n??this.fileMap.get(e)?.text??(0,el.readFileSync)(e).toString())}renewLexer(e,n){if(e=it(e),Zc().reset(e),!n&&!(0,el.existsSync)(e))return[];try{n??=(0,el.readFileSync)(e).toString();let r=new Kr(n,e);return this.fileMap.set(e,r),t.clone(r.tokens)}catch{}return[]}requestTokens(e,n){e=it(e);let r=this.fileMap.get(e)?.tokens;return!r&&n?[...this.renewLexer(e)]:t.clone(r??[])}reset(e){e=it(e),Zc().reset(e),this.fileMap.delete(e)}};function An(){return xT??=new np,xT}function fD(){xT=new np}var gi=class t{constructor(e){this.context=e;this.comments=[];this.includes=[];this.references=[];this.unlinkedDeletes=[];this.unlinkedRefNodes=[];this.globalDeletes=[];this.rootNode=new X(this.context.bindingLoader,"/");this.labelsUsedCache=new Map;this.fileTopMostAstCache=new Map}fileTopMostAsts(e){let n=this.fileTopMostAstCache.get(e);if(n)return n;let r=[...this.rootNode.implementations,...this.references,...this.unlinkedDeletes,...this.unlinkedRefNodes,...this.globalDeletes,...this.context.overlayParsers.flatMap(i=>[...i.cPreprocessorParser.allAstItems,...i.unhandledStatements.children]),...this.context.parser.cPreprocessorParser.allAstItems,...this.context.parser.unhandledStatements.children].flatMap(i=>i.getTopMostAstNodeForFile(e));return this.fileTopMostAstCache.set(e,r),r}getDeepestAstNode(e,n){let r=this.fileTopMostAsts(e),i=r.find(s=>Cn(s,e,n)||rE(An().requestTokens(e,!1),s,n));if(!i){let s=[this.context.parser,...this.context.overlayParsers].flatMap(c=>c.includes),o=(c,l)=>{let u=s.find(d=>he(d.resolvedPath,c));return u&&this.context.getSortKeyFile(l,c)===void 0?o(u.lastToken.fsPath,ae(u.lastToken)):u},a=o(e,n);a&&(i=r.at(-1)?.parentNode,e=a.fsPath,n=pD.Position.create(a.lastToken.pos.line,a.lastToken.pos.colEnd))}if(i instanceof Et){let o=this.rootNode.getReferenceBy(i)?.getDeepestAstNode(e,n);return o?{...o,runtime:this}:{item:null,runtime:this,ast:zr(i,e,n)}}else if(i instanceof Tt&&i.path){let s=this.rootNode.getDeepestAstNode(e,n);return s?{...s,runtime:this}:void 0}else if(i instanceof He&&i.path){let s=t.getNodeFromPath(i.path.slice(1),this.rootNode)?.getDeepestAstNode(e,n);return s?{...s,runtime:this}:void 0}else if(i)return{runtime:this,item:null,ast:zr(i,e,n)}}static getNodeFromPath(e,n,r=!0){if(e.length===0)return n;let i=e[0].split("@"),s=i[0],a=i.at(1)?.split(",").map(u=>Number.parseInt(u,16)),c=e.slice(1),l=n.getNode(s,a,r);return l?t.getNodeFromPath(c,l,r):void 0}resolvePath(e,n){if(!e.at(0)?.startsWith("&"))return e;let r=this.labelsUsedCache.get(e[0].slice(1));return r||(n??=this.rootNode.allDescendantsLabels,n.find(s=>s.label.value===e.at(0)?.slice(1)&&s.parentNode instanceof Ue)?.lastLinkedTo?.path)}get issues(){return this.issuesCache??=[...this.labelIssues(),...this.rootNode.getIssues(this.context.macros)],this.issuesCache}labelIssues(){let e=[],n=new Map;return this.rootNode.allDescendantsLabelsMapped.forEach(r=>{n.has(r.label.label.value)?n.get(r.label.label.value)?.push(r):n.set(r.label.label.value,[r])}),Array.from(n).forEach(r=>{let i=r[1];if(i.length>1){let s=i.find(a=>a.owner instanceof X);if(!i.every(a=>a&&a.owner===s?.owner)||!s){let a=i[i.length-1].label;e.push(Ht(4,a.firstToken,a.lastToken,a,{linkedTo:i.slice(0,-1).map(c=>c.label),templateStrings:[i.at(0).label.label.value]}))}}}),e}get typesIssues(){let e=n=>[...n.nodeType?.getIssue(this,n)??[],...n.nodes.flatMap(r=>e(r))];return this.typesIssuesCache??=e(this.rootNode),this.typesIssuesCache}getOrderedNodeAst(e){return iE(e.implementations,this.context)}};var tl=q(j());var hD=q(j());var rp=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Values",kind:hD.SymbolKind.String},this.values.forEach(r=>this.addChild(r))}toString(){return this.values.map(n=>n?.toString()).join(",")}toJson(){return this.values.length===1?this.values[0]?.toJson():this.values.map(n=>n?.toJson())}};var mD=q(j());var ip=class extends te{constructor(n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:"DTS Document version",kind:mD.SymbolKind.Function}}};var yi=class extends te{constructor(n,r){super();this.value=n;this.labels=r;this.labels.forEach(i=>{this.addChild(i)}),this.addChild(this.value)}toString(n){return`${this.labels.map(r=>r.toString()).join(" ")}${this.value?.toString(n)??"NULL"}`}toPrettyString(n){return`${this.labels.map(r=>r.toString()).join(" ")}${this.value?.toPrettyString(n)??"NULL"}`}};var gD=q(j());var sp=class extends te{constructor(n,r,i){super();this.keyword=n;this.startAddress=r;this.endAddress=i;this.addChild(n),this.docSymbolsMeta={name:"Memreserve",kind:gD.SymbolKind.Function},this.addChild(r),this.addChild(i)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var yD=q(j());var op=class extends te{constructor(n,r){super();this.keyword=n;this.bitsSize=r;this.addChild(n),this.docSymbolsMeta={name:"bits",kind:yD.SymbolKind.Function},this.addChild(r)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var Fi=class extends $i{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.tokens=[];this.others=[];this.rootDocument=new Ue;this.unhandledStatements=new Tt;this.injectedMacros=[];this.#e=!1;this.cPreprocessorParser=new _a(this.fsPath,this.incudes,i,s,o)}get issues(){return[...this._issues,...this.cPreprocessorParser.issues]}getFiles(){return[this.fsPath,...this.cPreprocessorParser.dtsIncludes.flatMap(n=>n.resolvedPath).filter(n=>!!n)]}reset(){super.reset(),this.others=[],this.rootDocument=new Ue,this._issues=[],this.unhandledStatements=new Tt,this.#e=!1}async reparse(){let n=performance.now(),r=this.stable;return this.parsing=new Promise(i=>{r.then(async()=>{this.reset(),await this.cPreprocessorParser.reparse(),await this.parse(),console.log("parsing",performance.now()-n),i()})}),this.parsing}async parse(){if(await this.cPreprocessorParser.stable,this.tokens=this.cPreprocessorParser.tokens,it(this.fsPath).endsWith(".h")||(this.positionStack.push(0),this.tokens.length===0))return;let n=async()=>{if(!(this.isDtsDocumentVersion()||this.isMemreserve()||this.isPlugin()||this.isRootNodeDefinition(this.rootDocument)||this.isDeleteNode(this.rootDocument,"Ref")||this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros)||this.isChildNode(this.rootDocument,"Ref")||this.isProperty(this.unhandledStatements)||this.isDeleteProperty(this.unhandledStatements)||this.isChildNode(this.unhandledStatements,"Name"))){let s=this.moveToNextToken;s&&(this._issues.push(z(22,s,s,null)),this.reportExtraEndStatements())}};for(;!this.done;)await n();this.fsPath.endsWith(".dtsi")||(this.unhandledStatements.nodes.forEach(s=>{this._issues.push(z(53,s.firstToken,s.lastToken,s))}),this.unhandledStatements.properties.forEach(s=>{this._issues.push(z(32,s.firstToken,s.lastToken,s))}),this.unhandledStatements.deleteProperties.forEach(s=>{this._issues.push(z(33,s.firstToken,s.lastToken,s))}));let r=this.allAstItems.flatMap(s=>[s,...s.allDescendants]),i=this.cPreprocessorParser.comments;if(i.length&&r.forEach(s=>{(s instanceof Ue||s instanceof je||s instanceof kr)&&fE(s,i)}),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}processInjectPreProcessorMacros(n){let r=this.peekIndex(),i=this.isFunctionCall(n)||this.processCIdentifier(n,!0,!0);return this.injectPreProcessorResults(n,i,r)}injectPreProcessorResults(n,r,i){let s=r?.resolve(n);if(r&&typeof s=="string"){s=hT(s);let o=xf(r.fsPath,ce(r)),a=new Set;if(this.cPreprocessorParser.comments.forEach(l=>{Cn(r,r.fsPath,l.range.start)&&a.add(l)}),this.cPreprocessorParser.removeComments(a),this.injectedMacros.push(r),r instanceof pt&&s.includes(r.name)||r instanceof Ut&&s.includes(r.functionName.name))return!0;let c=new Kr(s,o);return this.tokens.splice(i,this.peekIndex()-i,...c.tokens),this.positionStack[this.positionStack.length-1]=i,!0}}isRootNodeDefinition(n){this.enqueueToStack();let r=this.moveToNextToken,i=r;if(!r||!U(r,13))return this.popStack(),!1;if(i=this.moveToNextToken,!i||!U(i,2))return this.popStack(),!1;let s=new Tt;s.openScope=i,n.addNodeChild(s),this.processNode(s,"Name");let o=this.nodeEnd(s)??i;return s.firstToken=r,s.lastToken=o,this.mergeStack(),!0}nodeEnd(n){let r=this.currentToken;if(U(r,3))this.moveToNextToken;else{let i=this.prevToken;return i&&this._issues.push(z(3,i,i,n)),this.endStatement(n,!1)}return this.prevToken?.value==="}"&&(n.closeScope=this.prevToken),this.endStatement(n)}isNodeEnd(){return U(this.currentToken,3)||U(this.currentToken,1)}endStatement(n,r=!0){let i=this.currentToken;if(!U(i,1)){let s=this.prevToken;if(s&&r)return this._issues.push(z(1,s,s,n)),s}return this.moveToNextToken,this.reportExtraEndStatements(),i}reportExtraEndStatements(){for(;U(this.currentToken,1);){let n=this.moveToNextToken;n&&this._issues.push(z(23,n,n,null))}}processNode(n,r){if(this.done)return!1;let i=!1,s=!1;do{for(;this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros););if(s=this.isChildNode(n,r)||this.isProperty(n)||this.isDeleteNode(n,r)||this.isDeleteProperty(n),!s&&!this.isNodeEnd()&&!this.done){let o=this.moveToNextToken;o&&(this._issues.push(z(22,o,o,null)),this.reportExtraEndStatements())}else if(this.done)break;i=i||s}while(!this.isNodeEnd());return i}processOptionalLabelAssign(n=!1){let r=[],i=this.isLabelAssign(n);for(;i;)r.push(i),i=this.isLabelAssign(n);return r}isChildNode(n,r){this.enqueueToStack();let i;r==="Name"&&(i=this.isOmitIfNoRefNode());let s=this.processOptionalLabelAssign(),o,a,c=r==="Ref"?new Et(s):new He(s,i);if(r==="Ref"?(this.enqueueToStack(),a=this.processNodePathRef(c),!a||!U(this.currentToken,2)?(this.popStack(),a=void 0):this.mergeStack(),a??=this.isLabelRef(c)):r==="Name"&&(o=this.isNodeName()),!a&&!o){if(!U(this.currentToken,2))return this.popStack(),!1;c.firstToken=this.currentToken,this._issues.push(z(r==="Name"?[7]:[10,48,11],c.firstToken,this.currentToken?.nextToken,c))}let l=!1;if(a&&c instanceof Et?(c.reference=a,l=!0):o&&c instanceof He&&(l=o.address!==void 0,c.name=o),U(this.currentToken,2)){c.openScope=this.moveToNextToken;let u=!1;do u=this.processNode(c,"Name");while(u);let d=this.nodeEnd(c);c.lastToken=d}else if(l){let u=a??o;u&&this._issues.push(z(2,u.firstToken,u.lastToken,u))}else return this.popStack(),!1;return n.addNodeChild(c),this.mergeStack(),!0}processNodeAddress(n){let r=this.prevToken;this.enqueueToStack();let i=this.checkConcurrentTokens([tt("0"),tt("x",{caseInsensitive:!0})]);i.length!==2?(i=[],this.popStack()):(this._issues.push(z(50,i[0],i[1],n,{severity:tl.DiagnosticSeverity.Warning})),r=i.at(-1),this.mergeStack());let s=this.consumeAnyConcurrentTokens([19,20,48].map(Le)),o=l=>{l.length%8!==0&&(l=l.padStart(Math.ceil(l.length/8)*8,"0"));let u=[];for(let d=0;d<l.length;d+=8){let f=l.slice(d,d+8);u.push(parseInt(f,16)>>>0)}return u},a=s.length?o(s.filter(l=>l.value!=="_").map(l=>l.value).join("")):[NaN];return r&&(a.some(l=>Number.isNaN(l))?this._issues.push(z(8,r,r,n)):!Number.isNaN(a)&&!Vt(r,s[0])&&!ro(s[0].fsPath)&&this._issues.push(z(29,r,s[0],n,{inclusiveStart:!1,inclusiveEnd:!1}))),this.currentToken?.value.toUpperCase()==="ULL"&&(this._issues.push(z(51,this.currentToken,this.currentToken,n,{severity:tl.DiagnosticSeverity.Warning})),this.moveToNextToken),new Fc(a,de(i.at(0)??s[0]??this.prevToken,this.prevToken))}processNodeAddresses(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Le(49)]);if(r.length){Vt(n.lastToken,r[0])||this._issues.push(z(29,n.lastToken,r[0],n,{inclusiveStart:!1,inclusiveEnd:!1}));let i=[],s=()=>{this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros),i.push(this.processNodeAddress(n)),U(this.currentToken,24)&&(this.prevToken&&!Vt(this.prevToken,this.currentToken)&&this._issues.push(z(29,this.prevToken,this.currentToken,n,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken,s())};s();let o=this.currentToken;for(;!U(this.currentToken,2)&&!U(this.currentToken,1)&&!U(this.currentToken,3)&&!U(this.currentToken,13)&&ln(this.currentToken,i.at(-1)?.lastToken);)this.moveToNextToken;if(o&&o!==this.currentToken){this._issues.push(z(52,o,this.currentToken,n));let a=new Fc([],de(o,this.prevToken));i.push(a)}return this.mergeStack(),i}this.popStack()}isNodeName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16].map(Le));if(!n.length){this.popStack();return}let r=n.map(o=>o.value).join(""),i=new xe(r,de(n[0],n.at(-1))),s=this.processNodeAddresses(i);return i.address=s,qf(r)||this._issues.push(z(49,i.firstToken,i.lastToken,i)),this.mergeStack(),i}isPropertyName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16,44,46].map(Le));if(!n.length){this.popStack();return}let r=new Ye(n.map(i=>i.value).join(""),de(n[0],n.at(-1)));return this.mergeStack(),r}isLabelName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(Le));if(!n.length){this.popStack();return}if(!qf(n?.[0].value)){this.popStack();return}let r=n.map(s=>s.value).join(""),i=new un(r,de(n[0],n[n.length-1]));return this.mergeStack(),i}isLabelAssign(n){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,48].map(Le));if(!r.length){this.popStack();return}if(!qf(r?.[0].value)){this.popStack();return}let i=r.map(c=>c.value).join(""),s=this.currentToken,o=s&&U(s,50),a=new ps(new un(i,de(r[0],r.at(-1))),de(r[0],o?s:r.at(-1)));if(o){let c=r.at(-1);c&&(s.pos.line!==a.firstToken.pos.line||s.pos.col!==c.pos.colEnd)&&this._issues.push(z(29,c,s,a,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken}else if(n)this._issues.push(z(24,a.firstToken,a.lastToken,a));else{this.popStack();return}return this.mergeStack(),a}isProperty(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(),i=this.isPropertyName();if(!i)return this.popStack(),!1;if(U(this.currentToken,2)||U(this.currentToken,49))return this.popStack(),!1;let s=new je(i,r),o;U(this.currentToken,0)?(s.assignOperatorToken=this.moveToNextToken,o=this.processValue(n),o?.values.filter(c=>!!c).length||this._issues.push(z(0,s.firstToken,s.lastToken,s)),s.values=o??null):s.values=void 0;let a=this.endStatement(s);return s.lastToken=a,n.addNodeChild(s),this.mergeStack(),!0}isDtsDocumentVersion(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("d"),tt("ts"),Le(16),tt("v"),tt("1")]);if(n.length!==6)return this.popStack(),!1;let r=n[0],i=r,s=new ft;s.firstToken=r;let o=new ip(s);if(this.others.push(o),U(this.currentToken,13))i=this.moveToNextToken;else return s.lastToken=n.at(-1),this._issues.push(z(21,o.firstToken,o.lastToken,o)),this.mergeStack(),!0;return s.lastToken=i,o.lastToken=this.endStatement(o),this.mergeStack(),!0}isMemreserve(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("memreserve")]);if(n.length!==2)return this.popStack(),!1;let r=new ft;r.firstToken=n[0];let s=n[0];U(this.currentToken,13)?(s=this.moveToNextToken,r.lastToken=s):(r.lastToken=n.at(-1),this._issues.push(z(21,r.firstToken,r.lastToken,r)));let o=this.processHex()||this.processDec(),a=o&&(this.processHex()||this.processDec()),c=new sp(r,o,a);if(this.others.push(c),o||this._issues.push(z(37,r.firstToken,r.lastToken,r)),!a){let l=o??r;this._issues.push(z(38,l.firstToken,l.lastToken,c))}return c.lastToken=this.endStatement(c),this.mergeStack(),!0}isPlugin(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("plugin"),Le(13)]);if(n.length!==3)return this.popStack(),!1;let r=new ft(de(n[0],n.at(-1)));return r.lastToken=this.endStatement(r),this.mergeStack(),this.others.push(r),!0}processBits(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("b"),tt("its")]);if(n.length!==3){this.popStack();return}let r=new ft;r.firstToken=n[0];let s=n[0];U(this.currentToken,13)?(s=this.moveToNextToken,r.lastToken=s):(r.lastToken=n.at(-1),this._issues.push(z(21,r.firstToken,r.lastToken,r)));let o=this.processDec(),a=new op(r,o);return this.others.push(a),o?o.value!==8&&o.value!==16&&o.value!==32&&o.value!==64&&this._issues.push(z(40,o.firstToken,o.lastToken,o)):this._issues.push(z(39,r.firstToken,r.lastToken,r)),this._issues.push(z(41,a.firstToken,a.lastToken,a,{severity:tl.DiagnosticSeverity.Warning})),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("omit"),Le(16),tt("if"),Le(16),tt("no"),Le(16),tt("ref"),Le(13)]);if(n.length!==9){this.popStack();return}let r=new ft(de(n[0],n.at(-1)));return this.mergeStack(),r}isDeleteNode(n,r){this.enqueueToStack();let i=this.checkConcurrentTokens([Le(13),tt("d"),tt("e"),tt("lete",{allowPartial:!0}),Le(16),tt("node",{allowPartial:!0})]);if(!i.length)return this.popStack(),!1;let s=i[0],o=s,a=new ft;if(a.firstToken=s,i.length===1&&!U(this.currentToken,2)){this._issues.push(z(25,a.firstToken,a.lastToken,a)),a.lastToken=i.at(-1);let d=new Gn(a);return n.addNodeChild(d),this.mergeStack(),!0}let c=i.map(d=>d.value??"").join("");if(!"/delete-node/".startsWith(c)||c.endsWith("-"))return this.popStack(),!1;a.lastToken=i.at(-1),c!=="/delete-node"?this._issues.push(z(c.startsWith("/delete-n")?34:25,a.firstToken,a.lastToken,a)):U(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(z(21,a.firstToken,a.lastToken,a));let l=new Gn(a);if(ln(a.lastToken,s)){let d=this.processNodePathRef(n);d&&r==="Name"&&this._issues.push(z(7,d.firstToken,d.lastToken,d));let f=d?void 0:this.isLabelRef(n);f&&r==="Name"&&this._issues.push(z(7,f.firstToken,f.lastToken,f));let p=d||f?void 0:this.isNodeName();p&&r==="Ref"&&this._issues.push(z(10,p.firstToken,p.lastToken,p)),!d&&!p&&!f&&this._issues.push(z([7,10],l.firstToken,l.lastToken,l)),l.nodeNameOrRef=d??f??p??null}else r==="Name"?this._issues.push(z(7,a.firstToken,a.lastToken,a)):r==="Ref"&&this._issues.push(z(10,a.firstToken,a.lastToken,a));let u=this.endStatement(l);return l.lastToken=u,n.addNodeChild(l),this.mergeStack(),!0}isDeleteProperty(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Le(13),tt("d"),tt("e"),tt("lete",{allowPartial:!0}),Le(16),tt("property",{allowPartial:!0})]);if(!r.length)return this.popStack(),!1;let i=r[0],s=i,o=new ft;if(o.firstToken=i,r.length===1&&!U(this.currentToken,2)){this._issues.push(z(25,o.firstToken,o.lastToken,o)),o.lastToken=r.at(-1);let u=new yt(o);return n.addNodeChild(u),this.mergeStack(),!0}let a=r.map(u=>u.value??"").join("");if(!"/delete-property/".startsWith(a)||a.endsWith("-"))return this.popStack(),!1;o.lastToken=r.at(-1),a!=="/delete-property"?this._issues.push(z(a.startsWith("/delete-p")?35:25,o.firstToken,o.lastToken,o)):U(this.currentToken,13)?(s=this.moveToNextToken,o.lastToken=s):this._issues.push(z(21,o.firstToken,o.lastToken,o));let c=new yt(o);if(ln(o.lastToken,i)){let u=this.isPropertyName();u||this._issues.push(z(6,c.firstToken,c.lastToken,c)),c.propertyName=u??null}else this._issues.push(z(6,o.firstToken,o.lastToken,o));let l=this.endStatement(c);return c.lastToken=l,n.addNodeChild(c),this.mergeStack(),!0}isNodePathRef(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processNodePathRef(n);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&s.push(...this.processOptionalLabelAssign(!0));let o=new Dn(r,i,s);return this.mergeStack(),o}processValue(n){this.enqueueToStack();let i=(()=>{let o=()=>(this.processStringValue()||this.isNodePathRef(n)||this.isLabelRefValue(n)||this.arrayValues(n)||this.processByteStringValue()||this.isExpressionValue(n))??null,a=o();if(!a)return[];let c=[a];for(;!U(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d,f=U(this.currentToken,24);if(f)d=this.currentToken,this.moveToNextToken;else if(!ln(this.prevToken,this.currentToken))break;let p=o();if(u&&p===null&&f){let h=new te(de(u,this.currentToken));this._issues.push(z(0,h.firstToken,h.lastToken,h))}if(!f&&p===null)break;if(l&&!f&&p){let h=new te(de(l));this._issues.push(z(28,h.firstToken,h.lastToken,h))}let m=c.at(-1);m&&(m.nextValueSeparator??=d),c.push(p)}return c})();if(i.length===0){this.popStack();return}return this.mergeStack(),new rp(i)}processStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.consumeAnyConcurrentTokens([Le(21)]);if(!r.length){this.popStack();return}if(r.some(u=>u.value===void 0))throw new Error("Token must have value");let i=r.map(u=>u.value).join(`
284
- `),s=i,o=['"',"'"].some(u=>s.endsWith(u));o&&(s=s.slice(1,-1));let a=new re(s,de(r[0],r.at(-1)));o||this._issues.push(z(i.startsWith('"')?16:17,a.firstToken,a.lastToken,a));let c=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(c=this.processOptionalLabelAssign(!0));let l=new Dn(n,a,c);return this.mergeStack(),l}arrayValues(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(U(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(n)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new Dn(r,o,a,i);if(!U(this.currentToken,4))this._issues.push(z(12,c.firstToken,c.lastToken,c));else{let u=this.moveToNextToken;o&&(o.closeBracket=u)}let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=s,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.moveToNextToken,i=r;if(!U(i,11)){this.popStack();return}let s=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];s.forEach(u=>{let d=0;u.value&&u.value.firstToken===u.value.lastToken&&(d=u.value.firstToken.pos.len),d%2!==0&&this._issues.push(z(15,u.firstToken,u.lastToken,u))});let a=new or(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=r,this._issues.push(z(14,a.firstToken,a.lastToken,a,{severity:tl.DiagnosticSeverity.Information})));let c=new Dn(n,a,o);U(this.currentToken,12)?a.closeBracket=this.moveToNextToken:this._issues.push(z(5,c.firstToken,c.lastToken,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=r,a.lastToken=this.prevToken,c}processLabeledValue(n){this.enqueueToStack();let r=n(),i=[];if(!r)return this.popStack(),[];for(;r;)i.push(r),r=n();if(i.length){let s=n();s&&i.push(s)}return this.mergeStack(),i}processArrayValues(n){this.enqueueToStack();let r=this.processLabeledValue(()=>{let s=()=>this.processRefValue(n,!1)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1,n),o=this.peekIndex(),a=s();return a&&!this.cPreprocessorParser.optimizeForFormatting&&(a.value instanceof Ut&&a.value.params.every(c=>!!c)&&this.cPreprocessorParser.macros.has(a.value.functionName.name)||a.value instanceof pt&&this.cPreprocessorParser.macros.has(a.value.name))&&typeof a.value.evaluate(this.cPreprocessorParser.macros)=="string"?(this.injectPreProcessorResults(this.cPreprocessorParser.macros,a.value,o),s()):a}),i=new gt(r);return r.length===0&&(i.firstToken=this.currentToken),this.mergeStack(),i}processLabeledHex(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processHex();if(!i){this.popStack();return}let s=new yi(i,r);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),r=this.checkConcurrentTokens([20,20].map(Le));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(a=>a.value).join(""),16),s=new Zt(i,de(r[0],r.at(-1)),16),o=new yi(s,n);return this.mergeStack(),o}processLabeledDec(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processDec();if(!i){this.popStack();return}let s=new yi(i,r);return this.mergeStack(),s}processLabeledExpression(n=!0,r=n,i){this.enqueueToStack();let s=[];n&&(s=this.processOptionalLabelAssign(r));let o=this.processExpression(this.cPreprocessorParser.macros,i);if(!o){this.popStack();return}let a=new yi(o,s);return this.mergeStack(),a}isExpressionValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!1),i=this.processExpression(this.cPreprocessorParser.macros,n);if(!i){this.popStack();return}let s=this.processOptionalLabelAssign(!0),o=new Dn(r,i,s);return this.mergeStack(),o}isLabelRef(n){this.enqueueToStack();let r=this.currentToken;if(!r||!U(r,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new ie(null);return this._issues.push(z(18,r,r,n)),o.firstToken=r,this.mergeStack(),o}r&&(i.firstToken.pos.line!==r.pos.line||i.firstToken.pos.col!==r.pos.colEnd)&&this._issues.push(z(29,r,i.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));let s=new ie(i);return s.firstToken=r,this.mergeStack(),s}isLabelRefValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.isLabelRef(n);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(s=this.processOptionalLabelAssign(!0));let o=new Dn(r,i,s);return this.mergeStack(),o}processRefValue(n,r){this.enqueueToStack();let i=this.processOptionalLabelAssign(r),s=this.currentToken;if(!s||!U(s,40)){this.popStack();return}let o=this.processNodePathRef(n);if(o!==void 0){let l=new yi(o,i);return this.mergeStack(),l}let a=this.isLabelRef(n);if(a===void 0){this._issues.push(z([18,9],s,s,n));let l=new yi(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new yi(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(n=!0,r=new Gr){this.enqueueToStack();let i;if(U(this.currentToken,13))i=this.moveToNextToken;else{if(!n){this.popStack();return}this.prevToken&&this._issues.push(z(19,this.prevToken,this.prevToken,r))}let s=this.isNodeName(),o=i??this.prevToken;if(!s&&o&&!n&&this._issues.push(z(7,o,o,r)),!n||s?r.addPath(s??null,i?new te(de(i)):void 0):n&&!s&&i&&(r.addPath(new xe("/",de(i))),r.firstToken=i),n&&!i&&r.children.length===0){this.mergeStack();return}return this.processNodePath(!1,r),this.mergeStack(),r}processNodePathRef(n){this.enqueueToStack();let r=this.moveToNextToken,i=r;if(!U(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!U(i,2)){this.popStack();return}r&&!Vt(r,s)&&this._issues.push(z(29,r,s,n,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new ot(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Vt(u.lastToken,l)){this._issues.push(z(29,u.lastToken,l,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Vt(s,u?.firstToken)){this._issues.push(z(29,s,u?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}let f=o?.children[d+1];u&&f&&!Vt(u.lastToken,f.firstToken)&&this._issues.push(z(29,u.lastToken,f?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}))}),U(c,3)?this.moveToNextToken:this.prevToken&&this._issues.push(z(3,this.prevToken,this.prevToken,n)),a.firstToken=r,a.lastToken=c??this.prevToken,this.mergeStack(),a}get includes(){return this.allAstItems.filter(n=>n instanceof kr)}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties,...this.unhandledStatements.nodes]}#e;get latestSemanticTokensBuilt(){return this.#e}buildSemanticTokens(n,r){let i=[];this.injectedMacros.forEach(s=>{s.buildSemanticTokens((...o)=>$i.push(...o,r,i))}),super.buildSemanticTokens(n,r,i),this.#e=!0}};var ap=class t{constructor(e,n,r){this.settings=e;this.formattingOptions=n;this.bindingLoader=r;this._issues=[];this.overlayParsers=[];this.overlays=[];this.ctxNames_=new Set;this.sortKeys=new WeakMap;this.staleFsPaths=new Set;let i={includePaths:[],overlays:[],zephyrBindings:[],deviceOrgTreeBindings:[],deviceOrgBindingsMetaSchema:[],...e,ctxName:e.ctxName??(0,Sa.basename)(e.dtsFile),lockRenameEdits:[],showFormattingErrorAsDiagnostics:e.showFormattingErrorAsDiagnostics??!0,disableFileWatchers:e.disableFileWatchers??!1};this.isFullContext=this.settings.dtsFile.toLowerCase().endsWith(".dts"),this.overlays=i.overlays,this.overlays.filter(nl.existsSync);let s=this.isFullContext&&r?.type==="Zephyr"?[(0,Sa.join)((0,Sa.dirname)(this.settings.dtsFile),"dts"),...i.includePaths]:i.includePaths;this.parser=new Fi(i.dtsFile,s),this.ctxNames_.add(i.ctxName),this.id=qi(i),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Fi(o,s,this.parser.cPreprocessorParser.macros))??[]})}get macros(){return this.allParsers.at(-1).cPreprocessorParser.macros}get ctxNames(){return Array.from(this.ctxNames_)}addCtxName(e){this.ctxNames_.add(e)}removeCtxName(e){this.ctxNames_.delete(e)}async getContextIssues(){return[...(await this.getRuntime()).issues,...this._issues]}async getFileTree(){let e=new Map,n=i=>({fsPath:i,includes:(e.get(i)??[]).map(s=>n(s.resolvedPath??s.path))});return(await this.getRuntime()).includes.forEach(i=>{let s=e.get(i.fsPath);s||(s=[],e.set(i.fsPath,s)),s.push({path:i.path.path,resolvedPath:i.resolvedPath})}),{mainDtsPath:n(this.parser.fsPath),overlays:this.overlays.map(n)}}async stable(){await Promise.all([this.parser.stable,...this.overlayParsers.map(e=>e.stable)])}async getRuntime(){return await this.stable(),this._runtime??=this.evaluate(),this._runtime}getContextFiles(){return[...this.overlayParsers.flatMap(e=>e.getFiles()),...this.parser.getFiles()]}isInContext(e){return this.getContextFiles().some(n=>he(n,e))}getFsPathParser(e){let n=this.overlayParsers.find(r=>r.getFiles().some(i=>he(i,e)));return n??=this.parser.getFiles().some(r=>he(r,e))?this.parser:void 0,n}async getAllStableParsers(){return await this.stable(),this.allParsers}get allParsers(){return[this.parser,...this.overlayParsers]}async getDocumentLinks(e,n){if(!this.isInContext(e))return[];let i=(await this.getRuntime()).rootNode.allBindingsProperties.filter(s=>he(s.ast.fsPath,e)&&(!n||Cn(s.ast,e,n))).flatMap(s=>s.ast.values?.values.flatMap(o=>{let c=s.parent?.nodeTypes.find(l=>o?.value instanceof re&&l.compatible===o.value.value);return c?{range:ce(o.value),target:ue(c.bindingsPath)}:void 0})).filter(s=>!!s)??[];return[...this.parser.cPreprocessorParser.dtsIncludes.filter(s=>he(s.fsPath,e)&&(!n||Cn(s,e,n))).map(s=>{let o=this.parser.cPreprocessorParser.resolveInclude(s);if(o)return{range:ce(s.path),target:ue(o)}}).filter(s=>!!s)??[],...i]}linkPropertiesLabelsAndNodePaths(e){let n=s=>[...s.properties,...s.nodes.flatMap(n)],r=n(e.rootNode),i=e.rootNode.allDescendantsLabels;r.forEach(s=>s.ast.allDescendants.forEach(o=>{if(o instanceof ie){let a=e.resolvePath([`&${o.label?.value}`],i);if(a){let c=e.rootNode.getChild(a);o.linksTo=c,c?.linkedRefLabels.push(o)}else o.value&&this._issues.push(Ht(3,o.firstToken,o.lastToken,o,{templateStrings:[o.value]}))}else o instanceof Gr&&this.linkNodePath(o,e.rootNode)}))}linkNodePath(e,n){let r=n,i=e.pathParts;for(let s=0;s<i.length&&i[s];s++){let o=!1,a=i[s];if(a){let c=s===0&&a.name==="/"?n:r?.getNode(a.name,a.fullAddress,!1);a.linksTo=c,!o&&!c&&(o=!0,this._issues.push(Ht(8,a.firstToken,a.lastToken,a,{templateStrings:[a.toString(),`${e.pathParts.filter(l=>l?.linksTo).map(l=>l?.toString()).join("/")}`]}))),c?.linkedNodeNamePaths.push(a),r=c}else break}}setStaleFsPath(e){this.staleFsPaths.add(e)}async reevaluate(e){this.setStaleFsPath(e);let n=new Set;return this.staleFsPaths.forEach(r=>{let i=this.getFsPathParser(r);i&&n.add(i)}),n.size?(this.sortKeys=new WeakMap,await Promise.all(Array.from(n).map(r=>r.reparse())),this._runtime=this.evaluate(),this._runtime):this._runtime}getSortKey(e){if(e)return this.sortKeys.get(e.firstToken)}async evaluate(){let e=performance.now();await this.stable();let n=new gi(this);this.staleFsPaths.clear(),this._issues=[],this.parser.rootDocument.resetIssues(),this.processRoot(this.parser.rootDocument,n);for(let r=0;r<this.overlayParsers.length;r++)this.overlayParsers[r].rootDocument.resetIssues(),this.processRoot(this.overlayParsers[r].rootDocument,n);return await Promise.all(n.rootNode.defaultProperties.map(async r=>{let i=new Kr(r.text,r.fsPath),s=new Fi(r.fsPath,[],void 0,()=>i.tokens);await s.stable,this.processRoot(s.rootDocument,n)})),n.includes=this.parser.includes,n.comments=this.parser.cPreprocessorParser.allAstItems.filter(r=>r instanceof lr),this.allParsers.flatMap(r=>r.tokens).forEach((r,i)=>this.sortKeys.set(r,i)),this.linkPropertiesLabelsAndNodePaths(n),this.reportNodeNameAndPropertyClashes(n),console.log(`(ID: ${this.id}) evaluate`,performance.now()-e),n}getSortKeyFile(e,n){let r=this.findTokenBeforePosition(e,n),i=r,s=i?this.sortKeys.get(i):void 0;for(;i&&!s;)i=i.nextToken,s=i?this.sortKeys.get(i):void 0;if(s!==void 0)return s;for(i=r,s=i?this.sortKeys.get(i):void 0;i&&!s;)i=i.prevToken,s=i?this.sortKeys.get(i):void 0;return s}findTokenBeforePosition(e,n){let r=[this.parser,...this.overlayParsers].flatMap(i=>({parser:i,tokens:i.tokens}));for(let[i,s]of r.entries()){if(s.tokens.length===0&&s.parser.fsPath===n){let c=r[i-1];return i?c.tokens[c.tokens.length-1]:null}let o=s.tokens.find(c=>Bc(c,n,e)&&(!c.nextToken||uT(c.nextToken,n,e)));if(o)return o;let a=s.parser.includes.find(c=>c.resolvedPath===n);if(a)return a.lastToken}}reportNodeNameAndPropertyClashes(e){let n=r=>{r.properties.forEach(i=>{r.nodes.filter(o=>o.address===void 0&&o.name===i.ast.propertyName?.name&&o.definitions.at(-1)?.name).forEach(o=>{let a=o.definitions,c=a[a.length-1].name;this._issues.push(Ht(2,c.firstToken,c.lastToken,c,{linkedTo:[i.ast,...i.allReplaced.map(l=>l.ast)]}))})}),r.nodes.forEach(n)};n(e.rootNode)}processRoot(e,n){for(let r=0;r<e.children.length;r++){let i=e.children[r];this.processChild(i,n.rootNode,n)}}processChild(e,n,r){e instanceof Ue?this.processDtcBaseNode(e,n,r):e instanceof je?this.processDtcProperty(e,n,r):e instanceof Gn?this.processDeleteNode(e,n,r):e instanceof yt&&this.processDeleteProperty(e,n,r)}checkNodeUniqueNames(e,n){let r=(o,a)=>o.filter(c=>c.name===a.name&&(c.address===a.fullAddress&&c.address===void 0||Lt(c.address??[],a.fullAddress??[])===0)).map(c=>c.issueAst),i=n.nodes.map(o=>{let a=o.definitions[0];return{name:o.name,address:o.address,issueAst:a.name??a}}),s=[];e.children.forEach(o=>{if(o instanceof He&&o.name){let a=r(s.map(c=>({name:c.name,address:c.fullAddress,issueAst:c})),o.name);a.length&&this._issues.push(Ht(2,o.name.firstToken,o.name.lastToken,o.name,{linkedTo:a})),s.push(o.name)}else if(o instanceof Gn&&o.nodeNameOrRef instanceof xe){let a=o.nodeNameOrRef;r(i,a)&&(s=s.filter(c=>r(s.map(l=>({name:l.name,address:l.fullAddress,issueAst:l})),c).length))}})}getCompileCommands(){if(!(!this.settings.compileCommands||!(0,nl.existsSync)(this.settings.compileCommands)))return JSON.parse((0,nl.readFileSync)(this.settings.compileCommands).toString())}processDtcBaseNode(e,n,r){e instanceof Tt?this.processDtcRootNode(e,r):e instanceof He?this.processDtcChildNode(e,n,r):e instanceof Et&&this.processDtcRefNode(e,r)}processDtcRootNode(e,n){n.rootNode.implementations.push(e),this.checkNodeUniqueNames(e,n.rootNode),e.children.forEach(r=>this.processChild(r,n.rootNode,n))}processDtcChildNode(e,n,r){if(e.name?.name){let i=e.path?r.resolvePath(e.path):void 0,o=(i?r.rootNode.getChild(i):void 0)??new X(this.bindingLoader,e.name.name,e.name.fullAddress,n);o.implementations.push(e),e.labels.forEach(a=>a.lastLinkedTo=o),n=o,this.checkNodeUniqueNames(e,o)}e.children.forEach(i=>this.processChild(i,n,r))}processDtcRefNodeLabelRef(e,n,r){let i,s=e.resolveNodePath??(e.pathName?r.resolvePath([e.pathName]):void 0);return s?(e.resolveNodePath??=[...s],i=r.rootNode.getChild(s),n.linksTo=i,e.labels.forEach(o=>o.lastLinkedTo=i),i?.linkedRefLabels.push(n),i?.implementations.push(e),e.labels.forEach(o=>{r.labelsUsedCache.set(o.label.value,s)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):(this._issues.push(Ht(3,n.firstToken,n.lastToken,n,{templateStrings:[n.label?.value??""]})),r.unlinkedRefNodes.push(e)),i}processDtcRefNodeNodePathRef(e,n,r){let i;n.path&&this.linkNodePath(n.path,r.rootNode);let o=n.path?.pathParts.at(-1)?.linksTo?.path;return o?(e.resolveNodePath??=o,i=r.rootNode.getChild(o),e.labels.forEach(a=>a.lastLinkedTo=i),i?.implementations.push(e),e.labels.forEach(a=>{r.labelsUsedCache.set(a.label.value,o)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):r.unlinkedRefNodes.push(e),i}processDtcRefNode(e,n){let r;e.reference?e.reference instanceof ie?r=this.processDtcRefNodeLabelRef(e,e.reference,n):r=this.processDtcRefNodeNodePathRef(e,e.reference,n):n.unlinkedRefNodes.push(e),e.children.forEach(i=>this.processChild(i,r??new X(this.bindingLoader,""),n))}processDtcProperty(e,n,r){e.propertyName?.name&&n.addProperty(new Xe(e,n)),e.children.forEach(i=>this.processChild(i,n,r))}processDeleteNode(e,n,r){if(e.nodeNameOrRef instanceof xe&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!n.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress))this._issues.push(Ht(5,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef));else{n.deletes.push(e);let i=n.getNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress);e.nodeNameOrRef.linksTo=i,n.deleteNode(e.nodeNameOrRef.name,e,e.nodeNameOrRef.fullAddress),i?.labels.forEach(s=>{r.labelsUsedCache.delete(s.label.value)})}}else if(e.nodeNameOrRef instanceof ie&&e.nodeNameOrRef.value){let i=r.resolvePath([`&${e.nodeNameOrRef.value}`]),s;i?(s=r.rootNode.getChild(i),n.deletes.push(e),e.nodeNameOrRef.linksTo=s,s?.labels.forEach(o=>{r.labelsUsedCache.delete(o.label.value)}),s?.linkedRefLabels.push(e.nodeNameOrRef),s?.parent?.deleteNode(s.name,e,s.address),e.parentNode instanceof Ue&&!e.parentNode.pathName&&r.globalDeletes.push(e)):(r.unlinkedDeletes.push(e),this._issues.push(Ht(3,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef,{templateStrings:[e.nodeNameOrRef.value]})))}else if(e.nodeNameOrRef instanceof ot&&e.nodeNameOrRef.path&&!e.nodeNameOrRef.path.pathParts.some(i=>!i)){let i=r.rootNode,s=e.nodeNameOrRef.path.pathParts;for(let c=0;c<s.length&&s[c];c++){let l=s[c];if(l){let u=i?.getNode(l.name,l.fullAddress,!1);l.linksTo=u,u?.linkedNodeNamePaths.push(l),i=u}}let o=e.nodeNameOrRef.path.pathParts.find(c=>c&&!c.linksTo),a=e.nodeNameOrRef.path.pathParts.at(-1)?.linksTo;a||(r.unlinkedDeletes.push(e),o&&this._issues.push(Ht(8,o.firstToken,o.lastToken,o,{templateStrings:[o.toString(),`${e.nodeNameOrRef.path.pathParts.filter(c=>c?.linksTo).map(c=>c?.toString()).join("/")}`]}))),n.deletes.push(e),a?.labels.forEach(c=>{r.labelsUsedCache.delete(c.label.value)}),a?.parent?.deleteNode(a.name,e,a.address),e.parentNode instanceof Ue&&!e.parentNode.pathName&&r.globalDeletes.push(e)}else r.unlinkedDeletes.push(e);e.children.forEach(i=>this.processChild(i,n,r))}processDeleteProperty(e,n,r){e.propertyName?.name&&!n.hasProperty(e.propertyName.name)?this._issues.push(Ht(1,e.propertyName.firstToken,e.propertyName.lastToken,e.propertyName)):e.propertyName?.name&&(n.deletes.push(e),n.deleteProperty(e.propertyName.name,e)),e.children.forEach(i=>this.processChild(i,n,r))}static#e(e,n,r){let i=r.get(n);i||(i=[],r.set(n,i)),i.push(e)}getIssues(e,n=new Map,r=i=>{if(!(i.raw.severity===lo.DiagnosticSeverity.Hint&&i.raw.virtual))return i.raw.severity===lo.DiagnosticSeverity.Error&&!this.isFullContext&&(i.raw.severity=lo.DiagnosticSeverity.Warning),i}){return e.forEach(i=>{let s=r(i);s&&t.#e(s.diagnostic(),s.raw.fsPath,n)}),n}async getSyntaxIssues(e=new Map,n=r=>{if(r.raw.severity===lo.DiagnosticSeverity.Error&&!this.isFullContext&&!io(r.raw,r.raw.fsPath,!1)&&(r.raw.severity=lo.DiagnosticSeverity.Warning),!(r.raw.severity===lo.DiagnosticSeverity.Hint&&r.raw.virtual))return r}){return(await this.getAllStableParsers()).forEach(r=>this.getIssues(r.issues,e,n)),e}async getDiagnostics(){let e=new Map;try{await this.getSyntaxIssues(e);let n=await this.getContextIssues()??[];this.getIssues(n,e);let r=await this.getRuntime();return this.getIssues(r.typesIssues,e),e}catch(n){throw console.error(n),n}}async toFullString(){return`/dts-v1/;
283
+ `)}}};var co=class extends te{constructor(e){super(e)}},Yc=class extends te{constructor(n,r){super();this.keyword=n;this.content=r;this.active=!1;this.addChild(n)}},Xc=class extends Yc{constructor(n,r,i){super(n,i);this.identifier=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.identifier&&n.has(this.identifier.name)}},Zf=class extends Yc{constructor(n,r,i){super(n,i);this.expression=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.expression?.isTrue(n)}},ep=class extends Xc{useBlock(e){return this.identifier&&!e.has(this.identifier.name)}},Jc=class extends Yc{};var Yr=(t,e)=>{let n=t,r=[];for(;n&&(r.push(n),n!==e);)n=n.nextToken;return r},Xr=class extends te{constructor(n,r,i){super();this.ifDef=n;this.endIf=r;this.elseOption=i;this.addChild(n),i&&this.addChild(i),this.addChild(r)}get inactiveRanges(){if(this.elseOption&&!this.elseOption.active){let n=this.elseOption.firstToken,r=this.elseOption.content?.lastToken??this.endIf?.firstToken??this.lastToken;return[Qe.create(ae(n),ae(r))]}if(!this.ifDef.active){let n=this.ifDef.firstToken,r=this.ifDef.content?this.ifDef.content?.lastToken:this.elseOption?this.elseOption.firstToken:this.endIf?.lastToken;return[Qe.create(ae(n),ae(r??this.ifDef.lastToken))]}return[]}getInValidTokenRange(n){if(!this.ifDef.identifier)return new WeakSet(Yr(this.firstToken,this.lastToken));let r=this.ifDef.useBlock(n);return r?this.ifDef.active=!0:this.elseOption&&(this.elseOption.active=!0),this.getInValidTokenRangeWhenActiveBlock(r?this.ifDef:this.elseOption)}getInValidTokenRangeWhenActiveBlock(n){let r=new WeakSet,i=(this.ifDef.identifier??this.ifDef.keyword).lastToken;Yr(this.ifDef.firstToken,i).forEach(o=>r.add(o));let s=this.ifDef===n;return!s&&this.ifDef.content&&Yr(this.ifDef.content.firstToken,this.ifDef.content.lastToken).forEach(o=>r.add(o)),this.elseOption&&(Yr(this.elseOption.firstToken,this.elseOption.keyword.lastToken).forEach(o=>r.add(o)),s&&this.elseOption.content&&Yr(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(o=>r.add(o))),this.endIf&&Yr(this.endIf.firstToken,this.endIf.lastToken).forEach(o=>r.add(o)),r}},Pr=class extends te{constructor(n,r,i){super();this.ifBlocks=n;this.endIf=r;this.elseOption=i;n.forEach(s=>this.addChild(s)),i&&this.addChild(i),this.addChild(r)}getInValidTokenRange(n){let r=this.ifBlocks.find(i=>i.useBlock(n));return r?r.active=!0:this.elseOption&&(this.elseOption.active=!0),this.getInValidTokenRangeWhenActiveBlock(r||this.elseOption)}get inactiveRanges(){let n=[],r=!!this.elseOption;if(this.ifBlocks.forEach((o,a)=>{if(o.active)return;let c=a===this.ifBlocks.length-1,l=o.firstToken,u=c?r?this.elseOption.firstToken:this.lastToken:o.content?.lastToken??this.ifBlocks[a+1].firstToken??o.lastToken;n.push(Qe.create(ae(l),ae(u)))}),this.elseOption&&n.length){let o=this.elseOption.firstToken,a=this.elseOption.content?.lastToken??this.endIf?.lastToken??this.lastToken;return[Qe.create(ae(o),ae(a))]}let i=this.firstToken,s=this.lastToken;return[Qe.create(ae(i),ae(s))]}getInValidTokenRangeWhenActiveBlock(n){let r=new WeakSet,i=!1;return this.ifBlocks.forEach(s=>{let o=s.expression?.lastToken??s.keyword.lastToken;Yr(s.firstToken,o).forEach(a=>r.add(a)),!i&&s===n?i=!0:s.content&&Yr(s.content.firstToken,s.content.lastToken).forEach(a=>r.add(a))}),this.elseOption&&(Yr(this.elseOption.keyword.firstToken,this.elseOption.keyword.lastToken).forEach(s=>r.add(s)),i&&this.elseOption.content&&Yr(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(s=>r.add(s))),this.endIf&&Yr(this.endIf.firstToken,this.endIf.lastToken).forEach(s=>r.add(s)),r}};var _a=class extends $i{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.getTokens=s;this.optimizeForFormatting=o;this.tokens=[];this.nodes=[];this._comments=[];this.dtsIncludes=[];this.macroSnapShot=new Map;this.macros=new Map;this.rangesToClean=new Set;this.macroStart=!1;i&&(Array.from(i).forEach(([a,c])=>this.macroSnapShot.set(a,c)),Array.from(i).forEach(([a,c])=>this.macros.set(a,c)))}get comments(){return this._comments}removeComments(n){this._comments=this._comments.filter(r=>!n.has(r))}get currentToken(){let n=this.prevToken,r=this.peekIndex(),i=this.tokens.at(r),s=ln(n,i)||!n||U(n,14)&&n.pos.line+1===i?.pos.line;if(!(this.macroStart&&!s))return this.macroStart&&U(i,14)?(this.moveStackIndex(),this.currentToken):i}reset(n){super.reset(),this.macros.clear(),n?(this.macroSnapShot.clear(),Array.from(n).forEach(([r,i])=>this.macroSnapShot.set(r,i)),Array.from(n).forEach(([r,i])=>this.macros.set(r,i))):Array.from(this.macroSnapShot).forEach(([r,i])=>this.macros.set(r,i)),this.nodes=[],this.dtsIncludes=[],this.rangesToClean=new Set}async reparse(n){let r=this.stable;return this.parsing=new Promise(i=>{r.then(()=>{if(n&&n.size===this.macroSnapShot.size){let s=Array.from(n);if(Array.from(this.macroSnapShot).every(([o,a],c)=>{let[l,u]=s[c];return l===o&&u.macro.toString()===a.macro.toString()})){console.log("header file cache hit",this.fsPath),i();return}}this.reset(n),this.parse().then(i)})}),this.parsing}async parse(){let n=new Jf(this.fsPath,this.getTokens);if(await n.stable,this.tokens=n.tokens,this._comments=n.allAstItems,this.positionStack.push(0),this.tokens.length!==0){for(;!this.done;)await this.lineProcessor();if(this.rangesToClean.size&&!this.fsPath.endsWith(".h")&&(this.tokens=this.tokens.filter(r=>!this.rangesToClean.has(r))),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}}async lineProcessor(){if(this.enqueueToStack(),!(!this.prevToken||this.prevToken.pos.line!==this.currentToken?.pos.line||!pe(this.prevToken.fsPath,this.currentToken.fsPath))){this.moveEndOfLine(this.prevToken,!1),this.mergeStack();return}let r=this.currentToken,i=await this.processInclude()||this.processDefinitions()||this.processUndef()||this.processError();this.processIfDefBlocks(),r&&this.moveEndOfLine(r,!!i),this.mergeStack()}addTokensToClean(n){for(let r=n.start;r<n.start+n.count;r++){let i=this.tokens[r];i&&this.rangesToClean.add(i)}}processDefinitions(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!U(r,25))return this.popStack(),!1;this.macroStart=!0;let i=new ft(de(r)),s=this.isFunctionDefinition()||this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(z(30,i.firstToken,i.lastToken,i)),this.mergeStack(),this.macroStart=!1,!0;let o=this.consumeDefinitionContent(),a;o.length&&(a=new Qf(de(o[0],o.at(-1)),o));let c=new Kc(i,s,a);this.macros.set(c.name,{macro:c,resolver:sE(c.toString())}),this.nodes.push(c);let l=this.peekIndex();return this.addTokensToClean({start:n,count:l-n}),this.mergeStack(),this.macroStart=!1,!0}processUndef(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!U(r,28))return this.popStack(),!1;this.macroStart=!0;let i=new ft(de(r)),s=this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(z(30,i.firstToken,i.lastToken,i)),this.mergeStack(),this.macroStart=!1,!0;let o=new Kc(i,s);this.macros.delete(s.name),this.nodes.push(o);let a=this.peekIndex();return this.addTokensToClean({start:n,count:a-n}),this.mergeStack(),this.macroStart=!1,!0}processError(){this.enqueueToStack();let n=this.peekIndex(),r=this.moveToNextToken;if(!r||!U(r,29))return this.popStack(),!1;this.moveEndOfLine(r,!1,!0);let i=this.peekIndex();return this.addTokensToClean({start:n,count:i-n}),this.mergeStack(),!0}consumeDefinitionContent(){let n=[];for(;this.currentToken;){let r=this.moveToNextToken;r&&n.push(r)}return n}isFunctionDefinition(){this.enqueueToStack();let n=this.processCIdentifier(this.macros,!0);if(!n){this.popStack();return}let r=this.moveToNextToken;if(!U(r,42)||!Vt(n.lastToken,r)){this.popStack();return}let i=[],s=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;s;)i.push(s),!U(this.currentToken,24)&&!U(this.currentToken,43)?this._issues.push(z(28,s.firstToken,s.lastToken,s)):U(this.currentToken,43)||(r=this.moveToNextToken),s=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new mi(n,i);if(U(this.currentToken,43))r=this.moveToNextToken,o.lastToken=r;else{o.lastToken=this.prevToken;let a=i.at(-1)??o;this._issues.push(z(26,a.firstToken,a.lastToken,a))}return this.mergeStack(),o}processVariadic(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(45),Le(45),Le(45)]);if(n.length!==3){this.popStack();return}let r=new va(de(n[0],n.at(-1)));return this.mergeStack(),r}processIfDefBlocks(){let n=this.peekIndex(),r=this.parseScopedBlock(a=>!!a&&[33,34,32].some(c=>U(a,c))&&!ln(a.prevToken,a),a=>!!a&&[37].some(c=>U(a,c))&&!ln(a.prevToken,a),a=>!!a&&[36,35].some(c=>U(a,c))&&!ln(a.prevToken,a));if(!r)return;let i;U(r.startToken,32)?i=this.processIfBlock(r,(a,c,l)=>new Zf(a,c??null,l)):i=this.processIfDefBlock(r,(a,c,l)=>U(r.startToken,33)?new Xc(a,c??null,l):new ep(a,c??null,l)),this.nodes.push(i);let s=i.getInValidTokenRange(this.macros);this.tokens=this.tokens.filter(a=>!s.has(a));let o=i.inactiveRanges;this._comments.forEach(a=>{o.some(c=>Mf(c,a.range))&&(a.disabled=!0)}),[...i instanceof Pr?i.ifBlocks:[i.ifDef],...i.elseOption?[i.elseOption]:[]].forEach(a=>{!a.active&&a.content&&this._issues.push(z(47,a.content.firstToken,a.content.lastToken,a.content,{severity:Qc.DiagnosticSeverity.Hint,tags:[Qc.DiagnosticTag.Unnecessary]}))}),this.positionStack[this.positionStack.length-1]=n}processIfDefBlock(n,r){this.enqueueToStack(),this.macroStart=!0;let i=new ft(de(n.startToken));n.splitTokens[0].rewind();let s=this.processCIdentifier(this.macros,!0);s||this._issues.push(z(31,i.firstToken,i.lastToken,i)),this.macroStart=!1;let o,a=n.splitTokens[0].tokens.indexOf(s?.lastToken??i.lastToken)+1,c=n.splitTokens[0].tokens[a];a&&c&&(o=new co(de(c,n.splitTokens[0].tokens.at(-1))));let l=r(i,s??null,o??null),u;if(n.splitTokens.length>1){let p=n.separatorTokens[0],m=new ft(de(p)),h;n.splitTokens[1].tokens.length&&(h=new co(de(n.splitTokens[1].tokens[0],n.splitTokens[1].tokens.at(-1)))),u=new Jc(m,h??null)}let d;n.endToken?d=new ft(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let f=new Xr(l,d??null,u);return this.mergeStack(),f}processIfBlock(n,r){this.enqueueToStack();let i=new ft(de(n.startToken)),s=[],o;n.splitTokens.forEach((l,u)=>{l.rewind();let d=this.prevToken,f=new ft(de(d));this.macroStart=!0;let p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0);if(p instanceof pt&&p.name.toLowerCase()==="defined"&&(p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0)),this.macroStart=!1,u===n.splitTokens.length-1&&U(d,36)){let h=d,y=new ft(de(h)),_;l.tokens.length&&(_=new co(de(l.tokens[0],l.tokens.at(-1)))),o=new Jc(y,_??null)}else{p||this._issues.push(z(31,i.firstToken,i.lastToken,i));let h,y=n.splitTokens[0].tokens.indexOf(p?.lastToken??i.lastToken)+1,_=n.splitTokens[0].tokens[y];y&&_&&(h=new co(de(_,n.splitTokens[u].tokens.at(-1))));let v=r(f,p??null,h??null);s.push(v)}});let a;n.endToken?a=new ft(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let c=new Pr(s,a??null,o);return this.mergeStack(),c}get allAstItems(){return[...this.dtsIncludes,...this.nodes,...this.comments]}resolveInclude(n){if(n.path.path)return n.path.relative?[(0,ba.resolve)((0,ba.dirname)(n.fsPath),n.path.path),...this.incudes.map(r=>(0,ba.resolve)(r,n.path.path))].find(r=>(0,OT.existsSync)(r)):this.incudes.map(r=>(0,ba.resolve)(r,n.path.path)).find(r=>(0,OT.existsSync)(r))}async processInclude(){this.enqueueToStack();let n=this.peekIndex(),r=this.currentToken;if(!r)return this.popStack(),!1;let i=r,s=r;if(U(r,26))this.moveToNextToken;else{let h=this.checkConcurrentTokens([Le(13),tt("include"),Le(13)]);if(h.length!==3)return this.popStack(),!1;i=h[0],s=h.at(-1)}let o=i,a=new ft(de(i,s));r=this.moveToNextToken;let c=r,l=!!U(r,21);if(!c||!l&&!U(r,5))return o&&this.moveEndOfLine(o),this.mergeStack(),!0;let u="";if(l)u=r?.value??"";else for(;this.currentToken?.pos.line===o.pos.line&&!U(this.currentToken,4);)u+=this.currentToken?.value??"",r=this.moveToNextToken;let d=new Ta(u,l,de(c,r)),f=new kr(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!U(this.currentToken,4)?this._issues.push(z(12,f.firstToken,f.lastToken,f)):(r=this.moveToNextToken,d.lastToken=r)),this.mergeStack();let p=this.peekIndex(),m=this.resolveInclude(f);if(f.resolvedPath=m,m||this._issues.push(z(36,f.path.firstToken,f.path.lastToken,f.path,{severity:Qc.DiagnosticSeverity.Warning})),m&&!this.optimizeForFormatting){An().requestTokens(m,!0);let h=Zc().getCPreprocessorParser(m,this.incudes,this.macros,this.fsPath);await h.stable,this._issues.push(...h.issues),this.macros.clear(),Array.from(h.macros).forEach(([y,_])=>this.macros.set(y,_)),m.endsWith(".h")?this.addTokensToClean({start:n,count:p-n}):(this.tokens=mE(this.tokens,n,p,h.tokens),this.positionStack[this.positionStack.length-1]=n),this.nodes.push(...h.nodes),this.dtsIncludes.push(...h.dtsIncludes)}else this.addTokensToClean({start:n,count:p-n});return!0}};var MT,tp=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,n,r,i){e=it(e);let s=`${Array.from(r).map(l=>l[1].macro.toString()).join("::")}`,o=this.headerFiles.get(e)?.get(s);if(o)return o.reparse(r),o;console.log("No c-preprocessor cache",e);let a=new _a(e,n,r),c=this.includeOwners.get(a)??new Set;return c.add(i),this.includeOwners.set(a,c),this.headerFiles.has(e)||this.headerFiles.set(e,new Map),this.headerFiles.get(e)?.set(s,a),a}reset(e){e=it(e);let n=this.headerFiles.get(e);n&&Array.from(n).forEach(([r,i])=>{console.log("disposing c-preprocessor cache for",e),Array.from(this.includeOwners.get(i)??[]).forEach(this.reset.bind(this)),this.headerFiles.delete(e)})}};function Zc(){return MT??=new tp,MT}function dD(){MT=new tp}var xT,np=class t{constructor(){this.fileMap=new Map}static clone(e){let n=e.length;if(n===0)return[];let r=new Array(n),i;for(let s=0;s<n;s++){let o=e[s],a={tokens:o.tokens,pos:o.pos,value:o.value,fsPath:o.fsPath,prevToken:i,nextToken:void 0};i&&(i.nextToken=a),r[s]=a,i=a}return r}needsRenew(e,n){return e=it(e),this.fileMap.get(e)?.text!==n}getDocument(e,n){return Vn.create(e,"devicetree",0,n??this.fileMap.get(e)?.text??(0,el.readFileSync)(e).toString())}renewLexer(e,n){if(e=it(e),Zc().reset(e),!n&&!(0,el.existsSync)(e))return[];try{n??=(0,el.readFileSync)(e).toString();let r=new Kr(n,e);return this.fileMap.set(e,r),t.clone(r.tokens)}catch{}return[]}requestTokens(e,n){e=it(e);let r=this.fileMap.get(e)?.tokens;return!r&&n?[...this.renewLexer(e)]:t.clone(r??[])}reset(e){e=it(e),Zc().reset(e),this.fileMap.delete(e)}};function An(){return xT??=new np,xT}function fD(){xT=new np}var gi=class t{constructor(e){this.context=e;this.comments=[];this.includes=[];this.references=[];this.unlinkedDeletes=[];this.unlinkedRefNodes=[];this.globalDeletes=[];this.rootNode=new X(this.context.bindingLoader,"/");this.labelsUsedCache=new Map;this.fileTopMostAstCache=new Map}fileTopMostAsts(e){let n=this.fileTopMostAstCache.get(e);if(n)return n;let r=[...this.rootNode.implementations,...this.references,...this.unlinkedDeletes,...this.unlinkedRefNodes,...this.globalDeletes,...this.context.overlayParsers.flatMap(i=>[...i.cPreprocessorParser.allAstItems,...i.unhandledStatements.children]),...this.context.parser.cPreprocessorParser.allAstItems,...this.context.parser.unhandledStatements.children].flatMap(i=>i.getTopMostAstNodeForFile(e));return this.fileTopMostAstCache.set(e,r),r}getDeepestAstNode(e,n){let r=this.fileTopMostAsts(e),i=r.find(s=>Cn(s,e,n)||rE(An().requestTokens(e,!1),s,n));if(!i){let s=[this.context.parser,...this.context.overlayParsers].flatMap(c=>c.includes),o=(c,l)=>{let u=s.find(d=>pe(d.resolvedPath,c));return u&&this.context.getSortKeyFile(l,c)===void 0?o(u.lastToken.fsPath,ae(u.lastToken)):u},a=o(e,n);a&&(i=r.at(-1)?.parentNode,e=a.fsPath,n=pD.Position.create(a.lastToken.pos.line,a.lastToken.pos.colEnd))}if(i instanceof Et){let o=this.rootNode.getReferenceBy(i)?.getDeepestAstNode(e,n);return o?{...o,runtime:this}:{item:null,runtime:this,ast:zr(i,e,n)}}else if(i instanceof Tt&&i.path){let s=this.rootNode.getDeepestAstNode(e,n);return s?{...s,runtime:this}:void 0}else if(i instanceof He&&i.path){let s=t.getNodeFromPath(i.path.slice(1),this.rootNode)?.getDeepestAstNode(e,n);return s?{...s,runtime:this}:void 0}else if(i)return{runtime:this,item:null,ast:zr(i,e,n)}}static getNodeFromPath(e,n,r=!0){if(e.length===0)return n;let i=e[0].split("@"),s=i[0],a=i.at(1)?.split(",").map(u=>Number.parseInt(u,16)),c=e.slice(1),l=n.getNode(s,a,r);return l?t.getNodeFromPath(c,l,r):void 0}resolvePath(e,n){if(!e.at(0)?.startsWith("&"))return e;let r=this.labelsUsedCache.get(e[0].slice(1));return r||(n??=this.rootNode.allDescendantsLabels,n.find(s=>s.label.value===e.at(0)?.slice(1)&&s.parentNode instanceof Ue)?.lastLinkedTo?.path)}get issues(){return this.issuesCache??=[...this.labelIssues(),...this.rootNode.getIssues(this.context.macros)],this.issuesCache}labelIssues(){let e=[],n=new Map;return this.rootNode.allDescendantsLabelsMapped.forEach(r=>{n.has(r.label.label.value)?n.get(r.label.label.value)?.push(r):n.set(r.label.label.value,[r])}),Array.from(n).forEach(r=>{let i=r[1];if(i.length>1){let s=i.find(a=>a.owner instanceof X);if(!i.every(a=>a&&a.owner===s?.owner)||!s){let a=i[i.length-1].label;e.push(Ht(4,a.firstToken,a.lastToken,a,{linkedTo:i.slice(0,-1).map(c=>c.label),templateStrings:[i.at(0).label.label.value]}))}}}),e}get typesIssues(){let e=n=>[...n.nodeType?.getIssue(this,n)??[],...n.nodes.flatMap(r=>e(r))];return this.typesIssuesCache??=e(this.rootNode),this.typesIssuesCache}getOrderedNodeAst(e){return iE(e.implementations,this.context)}};var tl=q(j());var hD=q(j());var rp=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Values",kind:hD.SymbolKind.String},this.values.forEach(r=>this.addChild(r))}toString(){return this.values.map(n=>n?.toString()).join(",")}toJson(){return this.values.length===1?this.values[0]?.toJson():this.values.map(n=>n?.toJson())}};var mD=q(j());var ip=class extends te{constructor(n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:"DTS Document version",kind:mD.SymbolKind.Function}}};var yi=class extends te{constructor(n,r){super();this.value=n;this.labels=r;this.labels.forEach(i=>{this.addChild(i)}),this.addChild(this.value)}toString(n){return`${this.labels.map(r=>r.toString()).join(" ")}${this.value?.toString(n)??"NULL"}`}toPrettyString(n){return`${this.labels.map(r=>r.toString()).join(" ")}${this.value?.toPrettyString(n)??"NULL"}`}};var gD=q(j());var sp=class extends te{constructor(n,r,i){super();this.keyword=n;this.startAddress=r;this.endAddress=i;this.addChild(n),this.docSymbolsMeta={name:"Memreserve",kind:gD.SymbolKind.Function},this.addChild(r),this.addChild(i)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var yD=q(j());var op=class extends te{constructor(n,r){super();this.keyword=n;this.bitsSize=r;this.addChild(n),this.docSymbolsMeta={name:"bits",kind:yD.SymbolKind.Function},this.addChild(r)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var Fi=class extends $i{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.tokens=[];this.others=[];this.rootDocument=new Ue;this.unhandledStatements=new Tt;this.injectedMacros=[];this.#e=!1;this.cPreprocessorParser=new _a(this.fsPath,this.incudes,i,s,o)}get issues(){return[...this._issues,...this.cPreprocessorParser.issues]}getFiles(){return[this.fsPath,...this.cPreprocessorParser.dtsIncludes.flatMap(n=>n.resolvedPath).filter(n=>!!n)]}reset(){super.reset(),this.others=[],this.rootDocument=new Ue,this._issues=[],this.unhandledStatements=new Tt,this.#e=!1}async reparse(){let n=performance.now(),r=this.stable;return this.parsing=new Promise(i=>{r.then(async()=>{this.reset(),await this.cPreprocessorParser.reparse(),await this.parse(),console.log("parsing",performance.now()-n),i()})}),this.parsing}async parse(){if(await this.cPreprocessorParser.stable,this.tokens=this.cPreprocessorParser.tokens,it(this.fsPath).endsWith(".h")||(this.positionStack.push(0),this.tokens.length===0))return;let n=async()=>{if(!(this.isDtsDocumentVersion()||this.isMemreserve()||this.isPlugin()||this.isRootNodeDefinition(this.rootDocument)||this.isDeleteNode(this.rootDocument,"Ref")||this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros)||this.isChildNode(this.rootDocument,"Ref")||this.isProperty(this.unhandledStatements)||this.isDeleteProperty(this.unhandledStatements)||this.isChildNode(this.unhandledStatements,"Name"))){let s=this.moveToNextToken;s&&(this._issues.push(z(22,s,s,null)),this.reportExtraEndStatements())}};for(;!this.done;)await n();this.fsPath.endsWith(".dtsi")||(this.unhandledStatements.nodes.forEach(s=>{this._issues.push(z(53,s.firstToken,s.lastToken,s))}),this.unhandledStatements.properties.forEach(s=>{this._issues.push(z(32,s.firstToken,s.lastToken,s))}),this.unhandledStatements.deleteProperties.forEach(s=>{this._issues.push(z(33,s.firstToken,s.lastToken,s))}));let r=this.allAstItems.flatMap(s=>[s,...s.allDescendants]),i=this.cPreprocessorParser.comments;if(i.length&&r.forEach(s=>{(s instanceof Ue||s instanceof je||s instanceof kr)&&fE(s,i)}),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}processInjectPreProcessorMacros(n){let r=this.peekIndex(),i=this.isFunctionCall(n)||this.processCIdentifier(n,!0,!0);return this.injectPreProcessorResults(n,i,r)}injectPreProcessorResults(n,r,i){let s=r?.resolve(n);if(r&&typeof s=="string"){s=hT(s);let o=xf(r.fsPath,ce(r)),a=new Set;if(this.cPreprocessorParser.comments.forEach(l=>{Cn(r,r.fsPath,l.range.start)&&a.add(l)}),this.cPreprocessorParser.removeComments(a),this.injectedMacros.push(r),r instanceof pt&&s.includes(r.name)||r instanceof Ut&&s.includes(r.functionName.name))return!0;let c=new Kr(s,o);return this.tokens.splice(i,this.peekIndex()-i,...c.tokens),this.positionStack[this.positionStack.length-1]=i,!0}}isRootNodeDefinition(n){this.enqueueToStack();let r=this.moveToNextToken,i=r;if(!r||!U(r,13))return this.popStack(),!1;if(i=this.moveToNextToken,!i||!U(i,2))return this.popStack(),!1;let s=new Tt;s.openScope=i,n.addNodeChild(s),this.processNode(s,"Name");let o=this.nodeEnd(s)??i;return s.firstToken=r,s.lastToken=o,this.mergeStack(),!0}nodeEnd(n){let r=this.currentToken;if(U(r,3))this.moveToNextToken;else{let i=this.prevToken;return i&&this._issues.push(z(3,i,i,n)),this.endStatement(n,!1)}return this.prevToken?.value==="}"&&(n.closeScope=this.prevToken),this.endStatement(n)}isNodeEnd(){return U(this.currentToken,3)||U(this.currentToken,1)}endStatement(n,r=!0){let i=this.currentToken;if(!U(i,1)){let s=this.prevToken;if(s&&r)return this._issues.push(z(1,s,s,n)),s}return this.moveToNextToken,this.reportExtraEndStatements(),i}reportExtraEndStatements(){for(;U(this.currentToken,1);){let n=this.moveToNextToken;n&&this._issues.push(z(23,n,n,null))}}processNode(n,r){if(this.done)return!1;let i=!1,s=!1;do{for(;this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros););if(s=this.isChildNode(n,r)||this.isProperty(n)||this.isDeleteNode(n,r)||this.isDeleteProperty(n),!s&&!this.isNodeEnd()&&!this.done){let o=this.moveToNextToken;o&&(this._issues.push(z(22,o,o,null)),this.reportExtraEndStatements())}else if(this.done)break;i=i||s}while(!this.isNodeEnd());return i}processOptionalLabelAssign(n=!1){let r=[],i=this.isLabelAssign(n);for(;i;)r.push(i),i=this.isLabelAssign(n);return r}isChildNode(n,r){this.enqueueToStack();let i;r==="Name"&&(i=this.isOmitIfNoRefNode());let s=this.processOptionalLabelAssign(),o,a,c=r==="Ref"?new Et(s):new He(s,i);if(r==="Ref"?(this.enqueueToStack(),a=this.processNodePathRef(c),!a||!U(this.currentToken,2)?(this.popStack(),a=void 0):this.mergeStack(),a??=this.isLabelRef(c)):r==="Name"&&(o=this.isNodeName()),!a&&!o){if(!U(this.currentToken,2))return this.popStack(),!1;c.firstToken=this.currentToken,this._issues.push(z(r==="Name"?[7]:[10,48,11],c.firstToken,this.currentToken?.nextToken,c))}let l=!1;if(a&&c instanceof Et?(c.reference=a,l=!0):o&&c instanceof He&&(l=o.address!==void 0,c.name=o),U(this.currentToken,2)){c.openScope=this.moveToNextToken;let u=!1;do u=this.processNode(c,"Name");while(u);let d=this.nodeEnd(c);c.lastToken=d}else if(l){let u=a??o;u&&this._issues.push(z(2,u.firstToken,u.lastToken,u))}else return this.popStack(),!1;return n.addNodeChild(c),this.mergeStack(),!0}processNodeAddress(n){let r=this.prevToken;this.enqueueToStack();let i=this.checkConcurrentTokens([tt("0"),tt("x",{caseInsensitive:!0})]);i.length!==2?(i=[],this.popStack()):(this._issues.push(z(50,i[0],i[1],n,{severity:tl.DiagnosticSeverity.Warning})),r=i.at(-1),this.mergeStack());let s=this.consumeAnyConcurrentTokens([19,20,48].map(Le)),o=l=>{l.length%8!==0&&(l=l.padStart(Math.ceil(l.length/8)*8,"0"));let u=[];for(let d=0;d<l.length;d+=8){let f=l.slice(d,d+8);u.push(parseInt(f,16)>>>0)}return u},a=s.length?o(s.filter(l=>l.value!=="_").map(l=>l.value).join("")):[NaN];return r&&(a.some(l=>Number.isNaN(l))?this._issues.push(z(8,r,r,n)):!Number.isNaN(a)&&!Vt(r,s[0])&&!ro(s[0].fsPath)&&this._issues.push(z(29,r,s[0],n,{inclusiveStart:!1,inclusiveEnd:!1}))),this.currentToken?.value.toUpperCase()==="ULL"&&(this._issues.push(z(51,this.currentToken,this.currentToken,n,{severity:tl.DiagnosticSeverity.Warning})),this.moveToNextToken),new Fc(a,de(i.at(0)??s[0]??this.prevToken,this.prevToken))}processNodeAddresses(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Le(49)]);if(r.length){Vt(n.lastToken,r[0])||this._issues.push(z(29,n.lastToken,r[0],n,{inclusiveStart:!1,inclusiveEnd:!1}));let i=[],s=()=>{this.processInjectPreProcessorMacros(this.cPreprocessorParser.macros),i.push(this.processNodeAddress(n)),U(this.currentToken,24)&&(this.prevToken&&!Vt(this.prevToken,this.currentToken)&&this._issues.push(z(29,this.prevToken,this.currentToken,n,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken,s())};s();let o=this.currentToken;for(;!U(this.currentToken,2)&&!U(this.currentToken,1)&&!U(this.currentToken,3)&&!U(this.currentToken,13)&&ln(this.currentToken,i.at(-1)?.lastToken);)this.moveToNextToken;if(o&&o!==this.currentToken){this._issues.push(z(52,o,this.currentToken,n));let a=new Fc([],de(o,this.prevToken));i.push(a)}return this.mergeStack(),i}this.popStack()}isNodeName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16].map(Le));if(!n.length){this.popStack();return}let r=n.map(o=>o.value).join(""),i=new xe(r,de(n[0],n.at(-1))),s=this.processNodeAddresses(i);return i.address=s,qf(r)||this._issues.push(z(49,i.firstToken,i.lastToken,i)),this.mergeStack(),i}isPropertyName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16,44,46].map(Le));if(!n.length){this.popStack();return}let r=new Ye(n.map(i=>i.value).join(""),de(n[0],n.at(-1)));return this.mergeStack(),r}isLabelName(){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(Le));if(!n.length){this.popStack();return}if(!qf(n?.[0].value)){this.popStack();return}let r=n.map(s=>s.value).join(""),i=new un(r,de(n[0],n[n.length-1]));return this.mergeStack(),i}isLabelAssign(n){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,48].map(Le));if(!r.length){this.popStack();return}if(!qf(r?.[0].value)){this.popStack();return}let i=r.map(c=>c.value).join(""),s=this.currentToken,o=s&&U(s,50),a=new ps(new un(i,de(r[0],r.at(-1))),de(r[0],o?s:r.at(-1)));if(o){let c=r.at(-1);c&&(s.pos.line!==a.firstToken.pos.line||s.pos.col!==c.pos.colEnd)&&this._issues.push(z(29,c,s,a,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken}else if(n)this._issues.push(z(24,a.firstToken,a.lastToken,a));else{this.popStack();return}return this.mergeStack(),a}isProperty(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(),i=this.isPropertyName();if(!i)return this.popStack(),!1;if(U(this.currentToken,2)||U(this.currentToken,49))return this.popStack(),!1;let s=new je(i,r),o;U(this.currentToken,0)?(s.assignOperatorToken=this.moveToNextToken,o=this.processValue(n),o?.values.filter(c=>!!c).length||this._issues.push(z(0,s.firstToken,s.lastToken,s)),s.values=o??null):s.values=void 0;let a=this.endStatement(s);return s.lastToken=a,n.addNodeChild(s),this.mergeStack(),!0}isDtsDocumentVersion(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("d"),tt("ts"),Le(16),tt("v"),tt("1")]);if(n.length!==6)return this.popStack(),!1;let r=n[0],i=r,s=new ft;s.firstToken=r;let o=new ip(s);if(this.others.push(o),U(this.currentToken,13))i=this.moveToNextToken;else return s.lastToken=n.at(-1),this._issues.push(z(21,o.firstToken,o.lastToken,o)),this.mergeStack(),!0;return s.lastToken=i,o.lastToken=this.endStatement(o),this.mergeStack(),!0}isMemreserve(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("memreserve")]);if(n.length!==2)return this.popStack(),!1;let r=new ft;r.firstToken=n[0];let s=n[0];U(this.currentToken,13)?(s=this.moveToNextToken,r.lastToken=s):(r.lastToken=n.at(-1),this._issues.push(z(21,r.firstToken,r.lastToken,r)));let o=this.processHex()||this.processDec(),a=o&&(this.processHex()||this.processDec()),c=new sp(r,o,a);if(this.others.push(c),o||this._issues.push(z(37,r.firstToken,r.lastToken,r)),!a){let l=o??r;this._issues.push(z(38,l.firstToken,l.lastToken,c))}return c.lastToken=this.endStatement(c),this.mergeStack(),!0}isPlugin(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("plugin"),Le(13)]);if(n.length!==3)return this.popStack(),!1;let r=new ft(de(n[0],n.at(-1)));return r.lastToken=this.endStatement(r),this.mergeStack(),this.others.push(r),!0}processBits(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("b"),tt("its")]);if(n.length!==3){this.popStack();return}let r=new ft;r.firstToken=n[0];let s=n[0];U(this.currentToken,13)?(s=this.moveToNextToken,r.lastToken=s):(r.lastToken=n.at(-1),this._issues.push(z(21,r.firstToken,r.lastToken,r)));let o=this.processDec(),a=new op(r,o);return this.others.push(a),o?o.value!==8&&o.value!==16&&o.value!==32&&o.value!==64&&this._issues.push(z(40,o.firstToken,o.lastToken,o)):this._issues.push(z(39,r.firstToken,r.lastToken,r)),this._issues.push(z(41,a.firstToken,a.lastToken,a,{severity:tl.DiagnosticSeverity.Warning})),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let n=this.checkConcurrentTokens([Le(13),tt("omit"),Le(16),tt("if"),Le(16),tt("no"),Le(16),tt("ref"),Le(13)]);if(n.length!==9){this.popStack();return}let r=new ft(de(n[0],n.at(-1)));return this.mergeStack(),r}isDeleteNode(n,r){this.enqueueToStack();let i=this.checkConcurrentTokens([Le(13),tt("d"),tt("e"),tt("lete",{allowPartial:!0}),Le(16),tt("node",{allowPartial:!0})]);if(!i.length)return this.popStack(),!1;let s=i[0],o=s,a=new ft;if(a.firstToken=s,i.length===1&&!U(this.currentToken,2)){this._issues.push(z(25,a.firstToken,a.lastToken,a)),a.lastToken=i.at(-1);let d=new Gn(a);return n.addNodeChild(d),this.mergeStack(),!0}let c=i.map(d=>d.value??"").join("");if(!"/delete-node/".startsWith(c)||c.endsWith("-"))return this.popStack(),!1;a.lastToken=i.at(-1),c!=="/delete-node"?this._issues.push(z(c.startsWith("/delete-n")?34:25,a.firstToken,a.lastToken,a)):U(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(z(21,a.firstToken,a.lastToken,a));let l=new Gn(a);if(ln(a.lastToken,s)){let d=this.processNodePathRef(n);d&&r==="Name"&&this._issues.push(z(7,d.firstToken,d.lastToken,d));let f=d?void 0:this.isLabelRef(n);f&&r==="Name"&&this._issues.push(z(7,f.firstToken,f.lastToken,f));let p=d||f?void 0:this.isNodeName();p&&r==="Ref"&&this._issues.push(z(10,p.firstToken,p.lastToken,p)),!d&&!p&&!f&&this._issues.push(z([7,10],l.firstToken,l.lastToken,l)),l.nodeNameOrRef=d??f??p??null}else r==="Name"?this._issues.push(z(7,a.firstToken,a.lastToken,a)):r==="Ref"&&this._issues.push(z(10,a.firstToken,a.lastToken,a));let u=this.endStatement(l);return l.lastToken=u,n.addNodeChild(l),this.mergeStack(),!0}isDeleteProperty(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Le(13),tt("d"),tt("e"),tt("lete",{allowPartial:!0}),Le(16),tt("property",{allowPartial:!0})]);if(!r.length)return this.popStack(),!1;let i=r[0],s=i,o=new ft;if(o.firstToken=i,r.length===1&&!U(this.currentToken,2)){this._issues.push(z(25,o.firstToken,o.lastToken,o)),o.lastToken=r.at(-1);let u=new yt(o);return n.addNodeChild(u),this.mergeStack(),!0}let a=r.map(u=>u.value??"").join("");if(!"/delete-property/".startsWith(a)||a.endsWith("-"))return this.popStack(),!1;o.lastToken=r.at(-1),a!=="/delete-property"?this._issues.push(z(a.startsWith("/delete-p")?35:25,o.firstToken,o.lastToken,o)):U(this.currentToken,13)?(s=this.moveToNextToken,o.lastToken=s):this._issues.push(z(21,o.firstToken,o.lastToken,o));let c=new yt(o);if(ln(o.lastToken,i)){let u=this.isPropertyName();u||this._issues.push(z(6,c.firstToken,c.lastToken,c)),c.propertyName=u??null}else this._issues.push(z(6,o.firstToken,o.lastToken,o));let l=this.endStatement(c);return c.lastToken=l,n.addNodeChild(c),this.mergeStack(),!0}isNodePathRef(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processNodePathRef(n);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&s.push(...this.processOptionalLabelAssign(!0));let o=new Dn(r,i,s);return this.mergeStack(),o}processValue(n){this.enqueueToStack();let i=(()=>{let o=()=>(this.processStringValue()||this.isNodePathRef(n)||this.isLabelRefValue(n)||this.arrayValues(n)||this.processByteStringValue()||this.isExpressionValue(n))??null,a=o();if(!a)return[];let c=[a];for(;!U(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d,f=U(this.currentToken,24);if(f)d=this.currentToken,this.moveToNextToken;else if(!ln(this.prevToken,this.currentToken))break;let p=o();if(u&&p===null&&f){let h=new te(de(u,this.currentToken));this._issues.push(z(0,h.firstToken,h.lastToken,h))}if(!f&&p===null)break;if(l&&!f&&p){let h=new te(de(l));this._issues.push(z(28,h.firstToken,h.lastToken,h))}let m=c.at(-1);m&&(m.nextValueSeparator??=d),c.push(p)}return c})();if(i.length===0){this.popStack();return}return this.mergeStack(),new rp(i)}processStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.consumeAnyConcurrentTokens([Le(21)]);if(!r.length){this.popStack();return}if(r.some(u=>u.value===void 0))throw new Error("Token must have value");let i=r.map(u=>u.value).join(`
284
+ `),s=i,o=['"',"'"].some(u=>s.endsWith(u));o&&(s=s.slice(1,-1));let a=new re(s,de(r[0],r.at(-1)));o||this._issues.push(z(i.startsWith('"')?16:17,a.firstToken,a.lastToken,a));let c=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(c=this.processOptionalLabelAssign(!0));let l=new Dn(n,a,c);return this.mergeStack(),l}arrayValues(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(U(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(n)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new Dn(r,o,a,i);if(!U(this.currentToken,4))this._issues.push(z(12,c.firstToken,c.lastToken,c));else{let u=this.moveToNextToken;o&&(o.closeBracket=u)}let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=s,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.moveToNextToken,i=r;if(!U(i,11)){this.popStack();return}let s=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];s.forEach(u=>{let d=0;u.value&&u.value.firstToken===u.value.lastToken&&(d=u.value.firstToken.pos.len),d%2!==0&&this._issues.push(z(15,u.firstToken,u.lastToken,u))});let a=new or(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=r,this._issues.push(z(14,a.firstToken,a.lastToken,a,{severity:tl.DiagnosticSeverity.Information})));let c=new Dn(n,a,o);U(this.currentToken,12)?a.closeBracket=this.moveToNextToken:this._issues.push(z(5,c.firstToken,c.lastToken,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=r,a.lastToken=this.prevToken,c}processLabeledValue(n){this.enqueueToStack();let r=n(),i=[];if(!r)return this.popStack(),[];for(;r;)i.push(r),r=n();if(i.length){let s=n();s&&i.push(s)}return this.mergeStack(),i}processArrayValues(n){this.enqueueToStack();let r=this.processLabeledValue(()=>{let s=()=>this.processRefValue(n,!1)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1,n),o=this.peekIndex(),a=s();return a&&!this.cPreprocessorParser.optimizeForFormatting&&(a.value instanceof Ut&&a.value.params.every(c=>!!c)&&this.cPreprocessorParser.macros.has(a.value.functionName.name)||a.value instanceof pt&&this.cPreprocessorParser.macros.has(a.value.name))&&typeof a.value.evaluate(this.cPreprocessorParser.macros)=="string"?(this.injectPreProcessorResults(this.cPreprocessorParser.macros,a.value,o),s()):a}),i=new gt(r);return r.length===0&&(i.firstToken=this.currentToken),this.mergeStack(),i}processLabeledHex(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processHex();if(!i){this.popStack();return}let s=new yi(i,r);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),r=this.checkConcurrentTokens([20,20].map(Le));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(a=>a.value).join(""),16),s=new Zt(i,de(r[0],r.at(-1)),16),o=new yi(s,n);return this.mergeStack(),o}processLabeledDec(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(n),i=this.processDec();if(!i){this.popStack();return}let s=new yi(i,r);return this.mergeStack(),s}processLabeledExpression(n=!0,r=n,i){this.enqueueToStack();let s=[];n&&(s=this.processOptionalLabelAssign(r));let o=this.processExpression(this.cPreprocessorParser.macros,i);if(!o){this.popStack();return}let a=new yi(o,s);return this.mergeStack(),a}isExpressionValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!1),i=this.processExpression(this.cPreprocessorParser.macros,n);if(!i){this.popStack();return}let s=this.processOptionalLabelAssign(!0),o=new Dn(r,i,s);return this.mergeStack(),o}isLabelRef(n){this.enqueueToStack();let r=this.currentToken;if(!r||!U(r,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new ie(null);return this._issues.push(z(18,r,r,n)),o.firstToken=r,this.mergeStack(),o}r&&(i.firstToken.pos.line!==r.pos.line||i.firstToken.pos.col!==r.pos.colEnd)&&this._issues.push(z(29,r,i.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));let s=new ie(i);return s.firstToken=r,this.mergeStack(),s}isLabelRefValue(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.isLabelRef(n);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(s=this.processOptionalLabelAssign(!0));let o=new Dn(r,i,s);return this.mergeStack(),o}processRefValue(n,r){this.enqueueToStack();let i=this.processOptionalLabelAssign(r),s=this.currentToken;if(!s||!U(s,40)){this.popStack();return}let o=this.processNodePathRef(n);if(o!==void 0){let l=new yi(o,i);return this.mergeStack(),l}let a=this.isLabelRef(n);if(a===void 0){this._issues.push(z([18,9],s,s,n));let l=new yi(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new yi(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(n=!0,r=new Gr){this.enqueueToStack();let i;if(U(this.currentToken,13))i=this.moveToNextToken;else{if(!n){this.popStack();return}this.prevToken&&this._issues.push(z(19,this.prevToken,this.prevToken,r))}let s=this.isNodeName(),o=i??this.prevToken;if(!s&&o&&!n&&this._issues.push(z(7,o,o,r)),!n||s?r.addPath(s??null,i?new te(de(i)):void 0):n&&!s&&i&&(r.addPath(new xe("/",de(i))),r.firstToken=i),n&&!i&&r.children.length===0){this.mergeStack();return}return this.processNodePath(!1,r),this.mergeStack(),r}processNodePathRef(n){this.enqueueToStack();let r=this.moveToNextToken,i=r;if(!U(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!U(i,2)){this.popStack();return}r&&!Vt(r,s)&&this._issues.push(z(29,r,s,n,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new ot(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Vt(u.lastToken,l)){this._issues.push(z(29,u.lastToken,l,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Vt(s,u?.firstToken)){this._issues.push(z(29,s,u?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}let f=o?.children[d+1];u&&f&&!Vt(u.lastToken,f.firstToken)&&this._issues.push(z(29,u.lastToken,f?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}))}),U(c,3)?this.moveToNextToken:this.prevToken&&this._issues.push(z(3,this.prevToken,this.prevToken,n)),a.firstToken=r,a.lastToken=c??this.prevToken,this.mergeStack(),a}get includes(){return this.allAstItems.filter(n=>n instanceof kr)}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties,...this.unhandledStatements.nodes]}#e;get latestSemanticTokensBuilt(){return this.#e}buildSemanticTokens(n,r){let i=[];this.injectedMacros.forEach(s=>{s.buildSemanticTokens((...o)=>$i.push(...o,r,i))}),super.buildSemanticTokens(n,r,i),this.#e=!0}};var ap=class t{constructor(e,n,r){this.settings=e;this.formattingOptions=n;this.bindingLoader=r;this._issues=[];this.overlayParsers=[];this.overlays=[];this.ctxNames_=new Set;this.sortKeys=new WeakMap;this.staleFsPaths=new Set;let i={includePaths:[],overlays:[],zephyrBindings:[],deviceOrgTreeBindings:[],deviceOrgBindingsMetaSchema:[],...e,ctxName:e.ctxName??(0,Sa.basename)(e.dtsFile),lockRenameEdits:[],showFormattingErrorAsDiagnostics:e.showFormattingErrorAsDiagnostics??!0,disableFileWatchers:e.disableFileWatchers??!1};this.isFullContext=this.settings.dtsFile.toLowerCase().endsWith(".dts"),this.overlays=i.overlays,this.overlays.filter(nl.existsSync);let s=this.isFullContext&&r?.type==="Zephyr"?[(0,Sa.join)((0,Sa.dirname)(this.settings.dtsFile),"dts"),...i.includePaths]:i.includePaths;this.parser=new Fi(i.dtsFile,s),this.ctxNames_.add(i.ctxName),this.id=qi(i),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Fi(o,s,this.parser.cPreprocessorParser.macros))??[]})}get macros(){return this.allParsers.at(-1).cPreprocessorParser.macros}get ctxNames(){return Array.from(this.ctxNames_)}addCtxName(e){this.ctxNames_.add(e)}removeCtxName(e){this.ctxNames_.delete(e)}async getContextIssues(){return[...(await this.getRuntime()).issues,...this._issues]}async getFileTree(){let e=new Map,n=i=>({fsPath:i,includes:(e.get(i)??[]).map(s=>n(s.resolvedPath??s.path))});return(await this.getRuntime()).includes.forEach(i=>{let s=e.get(i.fsPath);s||(s=[],e.set(i.fsPath,s)),s.push({path:i.path.path,resolvedPath:i.resolvedPath})}),{mainDtsPath:n(this.parser.fsPath),overlays:this.overlays.map(n)}}async stable(){await Promise.all([this.parser.stable,...this.overlayParsers.map(e=>e.stable)])}async getRuntime(){return await this.stable(),this._runtime??=this.evaluate(),this._runtime}getContextFiles(){return[...this.overlayParsers.flatMap(e=>e.getFiles()),...this.parser.getFiles()]}isInContext(e){return this.getContextFiles().some(n=>pe(n,e))}getFsPathParser(e){let n=this.overlayParsers.find(r=>r.getFiles().some(i=>pe(i,e)));return n??=this.parser.getFiles().some(r=>pe(r,e))?this.parser:void 0,n}async getAllStableParsers(){return await this.stable(),this.allParsers}get allParsers(){return[this.parser,...this.overlayParsers]}async getDocumentLinks(e,n){if(!this.isInContext(e))return[];let i=(await this.getRuntime()).rootNode.allBindingsProperties.filter(s=>pe(s.ast.fsPath,e)&&(!n||Cn(s.ast,e,n))).flatMap(s=>s.ast.values?.values.flatMap(o=>{let c=s.parent?.nodeTypes.find(l=>o?.value instanceof re&&l.compatible===o.value.value);return c?{range:ce(o.value),target:ue(c.bindingsPath)}:void 0})).filter(s=>!!s)??[];return[...this.parser.cPreprocessorParser.dtsIncludes.filter(s=>pe(s.fsPath,e)&&(!n||Cn(s,e,n))).map(s=>{let o=this.parser.cPreprocessorParser.resolveInclude(s);if(o)return{range:ce(s.path),target:ue(o)}}).filter(s=>!!s)??[],...i]}linkPropertiesLabelsAndNodePaths(e){let n=s=>[...s.properties,...s.nodes.flatMap(n)],r=n(e.rootNode),i=e.rootNode.allDescendantsLabels;r.forEach(s=>s.ast.allDescendants.forEach(o=>{if(o instanceof ie){let a=e.resolvePath([`&${o.label?.value}`],i);if(a){let c=e.rootNode.getChild(a);o.linksTo=c,c?.linkedRefLabels.push(o)}else o.value&&this._issues.push(Ht(3,o.firstToken,o.lastToken,o,{templateStrings:[o.value]}))}else o instanceof Gr&&this.linkNodePath(o,e.rootNode)}))}linkNodePath(e,n){let r=n,i=e.pathParts;for(let s=0;s<i.length&&i[s];s++){let o=!1,a=i[s];if(a){let c=s===0&&a.name==="/"?n:r?.getNode(a.name,a.fullAddress,!1);a.linksTo=c,!o&&!c&&(o=!0,this._issues.push(Ht(8,a.firstToken,a.lastToken,a,{templateStrings:[a.toString(),`${e.pathParts.filter(l=>l?.linksTo).map(l=>l?.toString()).join("/")}`]}))),c?.linkedNodeNamePaths.push(a),r=c}else break}}setStaleFsPath(e){this.staleFsPaths.add(e)}async reevaluate(e){this.setStaleFsPath(e);let n=new Set;return this.staleFsPaths.forEach(r=>{let i=this.getFsPathParser(r);i&&n.add(i)}),n.size?(this.sortKeys=new WeakMap,await Promise.all(Array.from(n).map(r=>r.reparse())),this._runtime=this.evaluate(),this._runtime):this._runtime}getSortKey(e){if(e)return this.sortKeys.get(e.firstToken)}async evaluate(){let e=performance.now();await this.stable();let n=new gi(this);this.staleFsPaths.clear(),this._issues=[],this.parser.rootDocument.resetIssues(),this.processRoot(this.parser.rootDocument,n);for(let i=0;i<this.overlayParsers.length;i++)this.overlayParsers[i].rootDocument.resetIssues(),this.processRoot(this.overlayParsers[i].rootDocument,n);let r=await Promise.all(n.rootNode.defaultProperties.map(async i=>{let s=new Kr(i.text,i.fsPath),o=new Fi(i.fsPath,[],void 0,()=>s.tokens);return await o.stable,this.processRoot(o.rootDocument,n),o}));return n.includes=this.parser.includes,n.comments=this.parser.cPreprocessorParser.allAstItems.filter(i=>i instanceof lr),[...this.allParsers,...r].flatMap(i=>i.tokens).forEach((i,s)=>this.sortKeys.set(i,s)),this.linkPropertiesLabelsAndNodePaths(n),this.reportNodeNameAndPropertyClashes(n),console.log(`(ID: ${this.id}) evaluate`,performance.now()-e),n}getSortKeyFile(e,n){let r=this.findTokenBeforePosition(e,n),i=r,s=i?this.sortKeys.get(i):void 0;for(;i&&!s;)i=i.nextToken,s=i?this.sortKeys.get(i):void 0;if(s!==void 0)return s;for(i=r,s=i?this.sortKeys.get(i):void 0;i&&!s;)i=i.prevToken,s=i?this.sortKeys.get(i):void 0;return s}findTokenBeforePosition(e,n){let r=[this.parser,...this.overlayParsers].flatMap(i=>({parser:i,tokens:i.tokens}));for(let[i,s]of r.entries()){if(s.tokens.length===0&&pe(s.parser.fsPath,n)){let c=r[i-1];return i?c.tokens[c.tokens.length-1]:void 0}let o=s.tokens.find((c,l)=>Bc(c,n,e)&&(l===s.tokens.length-1||!c.nextToken||uT(c.nextToken,n,e)));if(o)return o;let a=s.parser.includes.find(c=>c.resolvedPath===n);if(a)return a.lastToken}}reportNodeNameAndPropertyClashes(e){let n=r=>{r.properties.forEach(i=>{r.nodes.filter(o=>o.address===void 0&&o.name===i.ast.propertyName?.name&&o.definitions.at(-1)?.name).forEach(o=>{let a=o.definitions,c=a[a.length-1].name;this._issues.push(Ht(2,c.firstToken,c.lastToken,c,{linkedTo:[i.ast,...i.allReplaced.map(l=>l.ast)]}))})}),r.nodes.forEach(n)};n(e.rootNode)}processRoot(e,n){for(let r=0;r<e.children.length;r++){let i=e.children[r];this.processChild(i,n.rootNode,n)}}processChild(e,n,r){e instanceof Ue?this.processDtcBaseNode(e,n,r):e instanceof je?this.processDtcProperty(e,n,r):e instanceof Gn?this.processDeleteNode(e,n,r):e instanceof yt&&this.processDeleteProperty(e,n,r)}checkNodeUniqueNames(e,n){let r=(o,a)=>o.filter(c=>c.name===a.name&&(c.address===a.fullAddress&&c.address===void 0||Lt(c.address??[],a.fullAddress??[])===0)).map(c=>c.issueAst),i=n.nodes.map(o=>{let a=o.definitions[0];return{name:o.name,address:o.address,issueAst:a.name??a}}),s=[];e.children.forEach(o=>{if(o instanceof He&&o.name){let a=r(s.map(c=>({name:c.name,address:c.fullAddress,issueAst:c})),o.name);a.length&&this._issues.push(Ht(2,o.name.firstToken,o.name.lastToken,o.name,{linkedTo:a})),s.push(o.name)}else if(o instanceof Gn&&o.nodeNameOrRef instanceof xe){let a=o.nodeNameOrRef;r(i,a)&&(s=s.filter(c=>r(s.map(l=>({name:l.name,address:l.fullAddress,issueAst:l})),c).length))}})}getCompileCommands(){if(!(!this.settings.compileCommands||!(0,nl.existsSync)(this.settings.compileCommands)))return JSON.parse((0,nl.readFileSync)(this.settings.compileCommands).toString())}processDtcBaseNode(e,n,r){e instanceof Tt?this.processDtcRootNode(e,r):e instanceof He?this.processDtcChildNode(e,n,r):e instanceof Et&&this.processDtcRefNode(e,r)}processDtcRootNode(e,n){n.rootNode.implementations.push(e),this.checkNodeUniqueNames(e,n.rootNode),e.children.forEach(r=>this.processChild(r,n.rootNode,n))}processDtcChildNode(e,n,r){if(e.name?.name){let i=e.path?r.resolvePath(e.path):void 0,o=(i?r.rootNode.getChild(i):void 0)??new X(this.bindingLoader,e.name.name,e.name.fullAddress,n);o.implementations.push(e),e.labels.forEach(a=>a.lastLinkedTo=o),n=o,this.checkNodeUniqueNames(e,o)}e.children.forEach(i=>this.processChild(i,n,r))}processDtcRefNodeLabelRef(e,n,r){let i,s=e.resolveNodePath??(e.pathName?r.resolvePath([e.pathName]):void 0);return s?(e.resolveNodePath??=[...s],i=r.rootNode.getChild(s),n.linksTo=i,e.labels.forEach(o=>o.lastLinkedTo=i),i?.linkedRefLabels.push(n),i?.implementations.push(e),e.labels.forEach(o=>{r.labelsUsedCache.set(o.label.value,s)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):(this._issues.push(Ht(3,n.firstToken,n.lastToken,n,{templateStrings:[n.label?.value??""]})),r.unlinkedRefNodes.push(e)),i}processDtcRefNodeNodePathRef(e,n,r){let i;n.path&&this.linkNodePath(n.path,r.rootNode);let o=n.path?.pathParts.at(-1)?.linksTo?.path;return o?(e.resolveNodePath??=o,i=r.rootNode.getChild(o),e.labels.forEach(a=>a.lastLinkedTo=i),i?.implementations.push(e),e.labels.forEach(a=>{r.labelsUsedCache.set(a.label.value,o)}),i?(r.references.push(e),this.checkNodeUniqueNames(e,i)):r.unlinkedRefNodes.push(e)):r.unlinkedRefNodes.push(e),i}processDtcRefNode(e,n){let r;e.reference?e.reference instanceof ie?r=this.processDtcRefNodeLabelRef(e,e.reference,n):r=this.processDtcRefNodeNodePathRef(e,e.reference,n):n.unlinkedRefNodes.push(e),e.children.forEach(i=>this.processChild(i,r??new X(this.bindingLoader,""),n))}processDtcProperty(e,n,r){e.propertyName?.name&&n.addProperty(new Xe(e,n)),e.children.forEach(i=>this.processChild(i,n,r))}processDeleteNode(e,n,r){if(e.nodeNameOrRef instanceof xe&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!n.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress))this._issues.push(Ht(5,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef));else{n.deletes.push(e);let i=n.getNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress);e.nodeNameOrRef.linksTo=i,n.deleteNode(e.nodeNameOrRef.name,e,e.nodeNameOrRef.fullAddress),i?.labels.forEach(s=>{r.labelsUsedCache.delete(s.label.value)})}}else if(e.nodeNameOrRef instanceof ie&&e.nodeNameOrRef.value){let i=r.resolvePath([`&${e.nodeNameOrRef.value}`]),s;i?(s=r.rootNode.getChild(i),n.deletes.push(e),e.nodeNameOrRef.linksTo=s,s?.labels.forEach(o=>{r.labelsUsedCache.delete(o.label.value)}),s?.linkedRefLabels.push(e.nodeNameOrRef),s?.parent?.deleteNode(s.name,e,s.address),e.parentNode instanceof Ue&&!e.parentNode.pathName&&r.globalDeletes.push(e)):(r.unlinkedDeletes.push(e),this._issues.push(Ht(3,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef,{templateStrings:[e.nodeNameOrRef.value]})))}else if(e.nodeNameOrRef instanceof ot&&e.nodeNameOrRef.path&&!e.nodeNameOrRef.path.pathParts.some(i=>!i)){let i=r.rootNode,s=e.nodeNameOrRef.path.pathParts;for(let c=0;c<s.length&&s[c];c++){let l=s[c];if(l){let u=i?.getNode(l.name,l.fullAddress,!1);l.linksTo=u,u?.linkedNodeNamePaths.push(l),i=u}}let o=e.nodeNameOrRef.path.pathParts.find(c=>c&&!c.linksTo),a=e.nodeNameOrRef.path.pathParts.at(-1)?.linksTo;a||(r.unlinkedDeletes.push(e),o&&this._issues.push(Ht(8,o.firstToken,o.lastToken,o,{templateStrings:[o.toString(),`${e.nodeNameOrRef.path.pathParts.filter(c=>c?.linksTo).map(c=>c?.toString()).join("/")}`]}))),n.deletes.push(e),a?.labels.forEach(c=>{r.labelsUsedCache.delete(c.label.value)}),a?.parent?.deleteNode(a.name,e,a.address),e.parentNode instanceof Ue&&!e.parentNode.pathName&&r.globalDeletes.push(e)}else r.unlinkedDeletes.push(e);e.children.forEach(i=>this.processChild(i,n,r))}processDeleteProperty(e,n,r){e.propertyName?.name&&!n.hasProperty(e.propertyName.name)?this._issues.push(Ht(1,e.propertyName.firstToken,e.propertyName.lastToken,e.propertyName)):e.propertyName?.name&&(n.deletes.push(e),n.deleteProperty(e.propertyName.name,e)),e.children.forEach(i=>this.processChild(i,n,r))}static#e(e,n,r){let i=r.get(n);i||(i=[],r.set(n,i)),i.push(e)}getIssues(e,n=new Map,r=i=>{if(!(i.raw.severity===lo.DiagnosticSeverity.Hint&&i.raw.virtual))return i.raw.severity===lo.DiagnosticSeverity.Error&&!this.isFullContext&&(i.raw.severity=lo.DiagnosticSeverity.Warning),i}){return e.forEach(i=>{let s=r(i);s&&t.#e(s.diagnostic(),s.raw.fsPath,n)}),n}async getSyntaxIssues(e=new Map,n=r=>{if(r.raw.severity===lo.DiagnosticSeverity.Error&&!this.isFullContext&&!io(r.raw,r.raw.fsPath,!1)&&(r.raw.severity=lo.DiagnosticSeverity.Warning),!(r.raw.severity===lo.DiagnosticSeverity.Hint&&r.raw.virtual))return r}){return(await this.getAllStableParsers()).forEach(r=>this.getIssues(r.issues,e,n)),e}async getDiagnostics(){let e=new Map;try{await this.getSyntaxIssues(e);let n=await this.getContextIssues()??[];this.getIssues(n,e);let r=await this.getRuntime();return this.getIssues(r.typesIssues,e),e}catch(n){throw console.error(n),n}}async toFullString(){return`/dts-v1/;
285
285
 
286
286
  ${(await this.getRuntime()).rootNode.toFullString((await this.getAllStableParsers()).at(-1).cPreprocessorParser.macros,this.settings.cwd)}`}async serialize(){let e={};return await this.stable,await this.getDiagnostics(),(await this?.getRuntime())?.rootNode.serialize(e,(await this.getAllStableParsers()).at(-1).cPreprocessorParser.macros),e}};var TD=require("fs"),ka=require("path"),Ct=q(j());function GU(t){if(!t||!(t.ast instanceof Ta))return[];let e=r=>r.flatMap(i=>{try{return(0,TD.readdirSync)(i,{withFileTypes:!0,recursive:!0}).filter(s=>s.name.toLowerCase().endsWith(".dtsi")||s.name.toLowerCase().endsWith(".h")).map(s=>({label:`${(0,ka.join)((0,ka.relative)(i,s.parentPath),s.name)}`,kind:Ct.CompletionItemKind.File}))}catch{return[]}});if(t.ast.relative)return e([(0,ka.dirname)(t.ast.fsPath)]);let n=t.runtime.context.settings.includePaths??[];return e(n)}var cp=(t,e)=>[...t.labels.filter(e),...t.deletedNodes.filter(n=>!e(n.by)).flatMap(n=>cp(n.node,e)),...t.nodes.flatMap(n=>cp(n,e))],LT=(t,e)=>[...t.labels,...t.deletedNodes.filter(n=>!e(n.by)).flatMap(n=>LT(n.node,e)),...t.nodes.flatMap(n=>LT(n,e))];function KU(t,e){if(!t||!(t.item instanceof Xe)||!(t.ast instanceof ie))return[];let n=i=>LT(i,e),r=new Map;return n(t.runtime.rootNode).forEach(i=>r.set(i.label.value,i)),Array.from(r).map(([,i])=>({label:`${i.label.value}`,kind:Ct.CompletionItemKind.Method,documentation:i.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function YU(t,e){if(!t||t.item!==null||!(t.ast instanceof ie)||!(t.ast.parentNode instanceof Et))return[];let n=r=>cp(r,e).filter(i=>e(i));return[...Array.from(new Set(n(t.runtime.rootNode).map(r=>r.label.value))).map(r=>({label:r,insertText:t.ast.lastToken.nextToken?.value==="{"?r:`${r} {
287
287
  $1
288
288
  };`,kind:Ct.CompletionItemKind.Value,insertTextFormat:Ct.InsertTextFormat.Snippet}))]}function XU(t,e){let n=s=>s?s.parentNode instanceof Et||s.parentNode instanceof Tt||s.parentNode instanceof He?!1:n(s.parentNode):!0;if(!t||t.item!==null||!Kt(t.ast)||!n(t.ast))return[];let r=s=>cp(s,e).filter(o=>e(o));if(t.ast instanceof ft)return r(t.runtime.rootNode).length?[{label:"/delete-node/",insertText:"/delete-node/ $1;",kind:Ct.CompletionItemKind.Keyword,insertTextFormat:Ct.InsertTextFormat.Snippet,sortText:"~",command:{command:"editor.action.triggerSuggest",title:"Re-trigger suggestions"}}]:t.runtime.rootNode.nodes.length?[{label:"/delete-node/ &{}",insertText:"/delete-node/ {/$1};",kind:Ct.CompletionItemKind.Keyword,insertTextFormat:Ct.InsertTextFormat.Snippet,sortText:"~",command:{command:"editor.action.triggerSuggest",title:"Re-trigger suggestions"}}]:[];let i=new Map;return r(t.runtime.rootNode).forEach(s=>i.set(s.label.value,s)),Array.from(i).map(([,s])=>({label:t.ast instanceof ie?`${s.label.value}`:`&${s.label.value}`,kind:Ct.CompletionItemKind.Variable,documentation:s.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function JU(t,e){if(!t||!(t.item instanceof X)||t.item===null||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof En)||t.beforeAst?.parentNode instanceof yt))return[];let n=r=>[...r.nodes,...r.deletedNodes.filter(i=>!e(i.by)).map(i=>i.node)].flatMap(i=>({node:i,astNodes:i.implementations.filter(s=>s instanceof He)})).filter(i=>i.astNodes.some(e));return t.ast instanceof xe||t.ast instanceof Gn||t.beforeAst?.parentNode instanceof Gn?n(t.item).map(r=>({label:`${r.astNodes.at(0)?.name?.toString()}`,kind:Ct.CompletionItemKind.Variable,documentation:r.node.toMarkupContent(t.runtime.context.macros)})):n(t.item).length?[{label:"/delete-node/",insertText:"/delete-node/ $1;",kind:Ct.CompletionItemKind.Keyword,insertTextFormat:Ct.InsertTextFormat.Snippet,sortText:"~",command:{command:"editor.action.triggerSuggest",title:"Re-trigger suggestions"}}]:[]}function QU(t,e){if(!t||!(t.item instanceof X)||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof En)||t.beforeAst?.parentNode instanceof Gn))return[];let n=r=>[...r.properties,...r.deletedProperties.filter(i=>!e(i.by)).map(i=>i.property)].flatMap(i=>[i,...i.allReplaced]).filter(i=>e(i.ast));if(t.ast instanceof Ye||t.ast instanceof yt||t.beforeAst?.parentNode instanceof yt){let r=new Map;return n(t.item).forEach(i=>r.set(i.name,i)),Array.from(r).map(([,i])=>({label:`${i.name}`,kind:Ct.CompletionItemKind.Variable,documentation:i.ast.toPrettyString(t.runtime.context.macros)}))}return n(t.item).length?[{label:"/delete-property/",insertText:"/delete-property/ $1;",kind:Ct.CompletionItemKind.Keyword,sortText:"~",insertTextFormat:Ct.InsertTextFormat.Snippet,command:{command:"editor.action.triggerSuggest",title:"Re-trigger suggestions"}}]:[]}function ZU(t,e){let n=t?.ast instanceof Gr?t.ast:t?.ast.parentNode;if(!t||!n||!(n instanceof Gr))return[];let r=n.pathParts.slice(0,-1);if(r.some(o=>!o))return[];let i=r.map(o=>o.toString());return(()=>{let o=t.runtime.rootNode.getChildFromScope(["/",...i],e);return[...o?.nodes.filter(a=>!Kt(t.ast)||a.definitions.some(e))??[],...o?.deletedNodes.filter(a=>!e(a.by)).map(a=>a.node)??[]]})().map(o=>({label:`/${[...i,o.fullName].join("/")}`,kind:Ct.CompletionItemKind.Variable,documentation:o.toMarkupContent(t.runtime.context.macros)}))}function eH(t){return!t||!(t.item instanceof Xe&&t.item.ast.assignOperatorToken)||t.ast instanceof re?[]:!oo(t?.ast)&&!(t.ast instanceof je&&t.item.ast.values===null)&&!oo(t.beforeAst)&&!oo(t.afterAst)?[]:t.item.parent.nodeType instanceof bt?Array.from([t.runtime.context.parser,...t.runtime.context.overlayParsers].at(-1)?.cPreprocessorParser.macros??[]).map(([,r])=>r.macro.identifier instanceof mi?{label:`${r.macro.identifier.toString()}`,insertText:`${r.macro.name}(${r.macro.identifier.params.map((i,s)=>i instanceof pt?`$${s+1}`:"").join(", ")})`,kind:Ct.CompletionItemKind.Function,sortText:`~${r.macro.name}`,insertTextFormat:Ct.InsertTextFormat.Snippet}:{label:r.macro.identifier.name,kind:Ct.CompletionItemKind.Variable,sortText:`~${r.macro.name}`}):[]}function tH(t,e){return!t?.item||!(t.ast instanceof Ye&&t.ast.parentNode instanceof je||t.ast instanceof Tt)?[]:(t.item instanceof X?t.item:t.item.parent).nodes.filter(r=>{let i=r.definitions.at(-1);return i&&e(i)}).map(r=>r.name?.toString()).filter(r=>r).map(r=>({label:`${r}`,insertText:`${r} {
289
289
  $1
290
- };`,kind:Ct.CompletionItemKind.Class,sortText:`!${r}`,insertTextFormat:Ct.InsertTextFormat.Snippet}))}async function vD(t,e){return Nt(t,e,(n,r)=>[...QU(n,r),...JU(n,r),...XU(n,r),...ZU(n,r),...YU(n,r),...KU(n,r),...GU(n),...eH(n),...tH(n,r)])}var Up=q(j());var _D=require("child_process");var qT=t=>/[A-Za-z0-9_]/.test(t);function nH(t,e){let n=[];for(let r=0;r<e;r++){let i=t[r];i==="("?n.push(r):i===")"&&n.pop()}return n.length?n[n.length-1]:void 0}function bD(t,e){let n=1;for(let r=e+1;r<t.length;r++){let i=t[r];if(i==="(")n++;else if(i===")"&&(n--,n===0))return r}}function SD(t,e,n){let r=[],i=0,s=!1,o=!1,a=e;for(let f=e;f<n;f++){let p=t[f];if(p==="'"&&!o)s=!s;else if(p==='"'&&!s)o=!o;else if(!s&&!o){if(p==="(")i++;else if(p===")")i--;else if(p===","&&i===0){let m=a,h=f,y=m,_=h;for(;y<_&&/\s/.test(t[y]);)y++;for(;_>y&&/\s/.test(t[_-1]);)_--;r.push({start:m,end:h,text:t.slice(y,_)}),a=f+1}}}let c=a,l=n,u=c,d=l;for(;u<d&&/\s/.test(t[u]);)u++;for(;d>u&&/\s/.test(t[d-1]);)d--;return r.push({start:c,end:l,text:t.slice(u,d)}),r}function $T(t){let e=t.trim(),n=/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/.exec(e);if(!n)return{macro:e};let r=n[1],i=n[2],s=SD(i,0,i.length),o={macro:r,args:[]};return o.args=s.map(a=>{let c=$T(a.text);return c.parent=o,c}),o}function Bi(t,e){let n=t.getText(),r=t.offsetAt(e),i=r,s=r;for(;i>0&&qT(n[i-1]);)i--;for(;s<n.length&&qT(n[s]);)s++;if(n[s]==="("){let y=bD(n,s);y!==void 0&&(s=y+1)}let o=n.slice(i,s),a=o.trim().length?$T(o):void 0,c=nH(n,r);if(c===void 0)return a;let l=bD(n,c);if(l===void 0||!(c<r&&r<=l))return a;let u=c,d=u;for(;d>0&&qT(n[d-1]);)d--;let f=n.slice(d,u);if(!f)return a;let p=SD(n,c+1,l),m={macro:f,args:[]};m.args=p.map(y=>{let _=$T(y.text);return _.parent=m,_});let h=-1;for(let y=0;y<p.length;y++){let _=p[y];if(r>=_.start&&r<=_.end){h=y;break}}if(h>=0){let y=m.args[h];return y.argIndexInParent=h,y}return m}function rH(t,e,n){let i=t.getText().split(/\r?\n/),s=new RegExp(`^\\s*#\\s*define\\s+(${e})\\b(\\s*\\([^)]*\\))?\\s*(.*)$`);for(let o=Math.min(n.line,i.length-1);o>=0;o--){let a=i[o],c=s.exec(a);if(c){let l=a.indexOf(c[0]),u=a.indexOf(c[3],l);return en.create(o,u>=0?u:a.length)}}}async function hs(t,e,n,r){let i=kD(t,e,n);if(i)return i;let s=await sH(e,r,Se(t.uri));if(s)return[s,n]}function kD(t,e,n){if(e.startsWith("DT_"))return;let r=rH(t,e,n);if(!r)return;let i=Bi(t,r);if(i)return[i,r]}var iH=(t,e)=>new Promise(n=>{let r=(0,_D.spawn)(t,e,{stdio:["ignore","pipe","pipe"]}),i="";r.stdout.on("data",s=>{i+=s.toString()}),r.on("close",s=>{n(s?"":i)})});async function sH(t,e,n){let r=e.getCompileCommands()?.find(s=>he(s.file,n));if(!r)return;let i=`${r.command.replace(/-(o|c)\s+\S+/g,"")} -E -dM ${r.file}`;try{let[s,...o]=i.split(" "),a=await iH(s,o.filter(u=>!!u)),c=Vn.create(`macros://${r.file}`,"devicetree",0,a),l=kD(c,t,c.positionAt(a.length-1));if(l)return l[0]}catch(s){console.error(s)}}function Z(t){return t.toLowerCase().replace(/[@,-\.]/g,"_")}var rl=q(j());async function PD({macro:t,context:e}){if(t.macro&&"DT_ALIAS".startsWith(t.macro))return[{label:"DT_ALIAS(...)",insertText:"DT_ALIAS($1)",kind:rl.CompletionItemKind.Function,insertTextFormat:rl.InsertTextFormat.Snippet}];if(t.parent?.macro!=="DT_ALIAS"||t.argIndexInParent!==0)return[];let n=await e.getRuntime();return n.rootNode.getNode("aliases")?.properties.map(r=>{let i=r.ast.getFlatAstValues()?.at(0),s;return i instanceof ie?s=i.linksTo:i instanceof Gr&&(s=i.pathParts.at(-1)?.linksTo),{label:Z(r.name),kind:rl.CompletionItemKind.Property,documentation:s?.toMarkupContent(n.context.macros)}})??[]}var il=q(j());async function _n(t,e,n){if(!t)return;let i=t?.properties.find(s=>Z(s.name)===e)?.ast.getFlatAstValues();return i?.length===0?!0:i?.map(s=>{if(s instanceof ot)return s.path?.pathParts.at(-1)?.linksTo;if(s instanceof ie)return s.linksTo;if(s instanceof re)return s.value;if(s instanceof ge){let o=s.evaluate(n.macros);return typeof o=="number"?o:s.toString()}})}async function lp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PROP"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:n,position:r});return o?_n(o,s[1].macro,n):void 0}async function ND(t,e){let n=await lp(t,e);if(typeof n=="boolean")return;let r=n?.at(0);if(n?.length===1&&r instanceof X)return r}async function RD(t,e,n,r){if(n=typeof n=="number"?n:De(n),typeof n!="number")return;let i=await _n(t,e,r);if(i===!0)return!0;if(!i)return;let s=i.at(n);if(s)return i.length===1&&i[0]instanceof X?i[0]:s}async function up({document:t,macro:e,context:n,position:r},i){if(!(e.macro!=="DT_PROP_BY_IDX"||e.args?.length!==3))return RD(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro,n)}async function wD(t,e){let n=await up(t,e);if(typeof n!="boolean"&&n instanceof X)return n}async function Yn(t,{document:e,context:n,macro:r,position:i},s){return t||(await s({document:e,macro:r,context:n,position:i})??r.macro)}async function dp(t,e,n,r){return Yn(await _n(t,e,n.context),n,r)}async function Pa({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_PROP_OR"||e.args?.length!==3)return;let[s,o,a]=e.args,c=await i({document:t,macro:s,context:n,position:r});return await dp(c,o.macro,{macro:a,document:t,context:n,position:r},i)}async function ED(t,e){let n=await Pa(t,e);if(n instanceof X)return n;if(typeof n=="boolean")return;let r=n?.at(0);if(n?.length===1&&r instanceof X)return r}async function CD(t){let e=t?.nodeType?.onBus,n=t?.parent?.nodeType?.bus;return t&&n?.length&&n?.some(r=>r===e)?t.parent??void 0:void 0}async function fp(t,e){let n=t.macro.args;if(t.macro.macro!=="DT_BUS"||n?.length!==1)return;let r=await e({...t,macro:n[0]});return await CD(r)}async function pp(t,e){let n=(await t.getRuntime()).rootNode.getChild(["/","chosen"]);if(!n)return;let s=n?.properties.find(o=>Z(o.name)===e)?.ast.getFlatAstValues()?.at(0);if(s instanceof ie)return s.linksTo;if(s instanceof ot)return s.path?.pathParts.at(-1)?.linksTo}async function hp(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_CHOSEN"||e?.length!==1))return await pp(t.context,e[0].macro)}async function mp(t,e){let n=await e?.getRuntime();if(n){let r=gi.getNodeFromPath(["aliases"],n.rootNode,!0),i=r?.properties.find(o=>Z(o.name)===t);if(!i)return;let s=i.ast.getFlatAstValues();return s?.[0]instanceof re?r=n.rootNode.getChild(s[0].value.split("/")):s?.[0]instanceof ie?r=s[0].linksTo:s?.[0]instanceof ot&&(r=s[0].path?.pathParts.at(-1)?.linksTo),r}}async function gp({macro:t,context:e}){if(!(t.macro!=="DT_ALIAS"||t.args?.length!==1))return mp(t.args[0].macro,e)}async function DD(t,e){return t?.nodes.find(n=>Z(n.name)===e)}async function yp({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_CHILD"||e.args?.length!==2)return;let s=await i({document:t,macro:e.args[0],context:n,position:r});return DD(s,e.args[1].macro)}var FT=(t,e)=>t.nodes.filter(n=>!n.disabled&&n.nodeType).flatMap(n=>[n.nodeType.compatible,...Array.from(n.nodeType.extends)].filter(r=>!!r).map(r=>Z(r)).includes(e)?[n,...FT(n,e)]:FT(n,e));async function AD(t,e){let n=await e?.getRuntime();if(n)return FT(n.rootNode,t)}async function BT({macro:t,context:e}){if(!(t.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.args?.length!==1))return AD(t.args[0].macro,e)}async function ID(t){return(await BT(t))?.at(0)}async function OD(t){return t?.parent?.parent??void 0}async function Tp({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_GPARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:n,position:r});return OD(s)}var jT=(t,e)=>t.nodes.filter(n=>n.nodeType).sort((n,r)=>n.disabled===r.disabled?0:n.disabled?1:-1).flatMap(n=>[n.nodeType.compatible,...Array.from(n.nodeType.extends)].filter(r=>!!r).map(r=>Z(r)).includes(e)?[n,...jT(n,e)]:jT(n,e));async function MD(t,e,n){let r=await n?.getRuntime();if(r)return jT(r.rootNode,e).at(t)}async function vp({macro:t,context:e}){if(t.macro!=="DT_INST"||t.args?.length!==2)return;let n=De(t.args[0].macro);if(typeof n=="number")return MD(n,t.args[1].macro,e)}async function xD(t,e){let n=await e?.getRuntime(),r=n?.resolvePath([`&${t.trim()}`]);if(n&&r)return gi.getNodeFromPath(r.slice(1),n.rootNode,!0)}async function bp({macro:t,context:e}){if(!(t.macro!=="DT_NODELABEL"||t.args?.length!==1))return xD(t.args[0].macro,e)}async function LD(t){return t?.parent??void 0}async function _p({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_PARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:n,position:r});return LD(s)}var qD=(t,e)=>{if(!e.length)return t;let n=e.splice(0,1)[0],r=t.nodes.find(i=>Z(i.fullName)===n);return r?qD(r,e):void 0};async function Sp(t,e){let n=await e?.getRuntime();if(n)return qD(n.rootNode,t)}async function kp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_PATH"||!n?.length))return Sp(n.map(r=>r.macro),e)}async function Pp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_ROOT"||n?.length))return(await e.getRuntime()).rootNode}async function Na(t,e,n){let r=t?.properties.find(c=>Z(c.name)===e);if(!r)return;let i=r?.ast.quickValues?.at(n),s=r.parent.nodeType;if(Array.isArray(i)||!s||!(s instanceof bt))return;let a=s.properties.find(c=>c.getNameMatch(r.name))?.values(r).findIndex(c=>c===i)??-1;return a===-1?void 0:a}async function Np(t,e,n,r,i){return Yn(await Na(t,e,n),r,i)}async function Rp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_BY_IDX_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:n,position:r}),a=De(s[2].macro);if(typeof a=="number")return await Np(o,s[1].macro,a,{macro:s[3],document:t,context:n,position:r},i)}async function wp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return await Np(o,s[1].macro,0,{macro:s[2],document:t,context:n,position:r},i)}async function ms(t,e,n,r,i){let s=t?.properties.find(d=>Z(d.name)===e),o=s?.parent.nodeType;if(!o||!(o instanceof bt))return;if(typeof n=="string"){let d=s.nexusMapsTo.at(0)?.specifierSpace;if(n=(d?s.parent.getProperty(`${d}-names`)?.ast.quickValues:void 0)?.findIndex(p=>typeof p=="string"&&p.toLowerCase()===n)??-1,n===-1)return}let a=s.nexusMapsTo.at(n),l=a?.target.nodeType?.cellsValues?.find(d=>a.specifierSpace&&d.specifier===a.specifierSpace)?.values?.indexOf(r);if(l===void 0||l===-1)return;let u=a?.mappingValuesAst.at(l);if(u instanceof ge){let d=u.evaluate(i.macros);return typeof d!="number"?u.toString():d}}async function Ra(t,e,n,r,i,s){return Yn(await ms(t,e,n,r,i.context),i,s)}async function Ep({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHA_BY_IDX_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:n,position:r}),a=De(s[2].macro);if(typeof a=="number")return Ra(o,s[1].macro,a,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Cp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHA_BY_NAME_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ra(o,s[1].macro,s[2].macro,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Ti(t,e,n=0){let r=t?.properties.find(s=>Z(s.name)===e);if(n=typeof n=="number"?n:De(n??"0"),typeof n!="number")return;let i=r?.ast.getFlatAstValues()?.at(n);if(i instanceof ie)return i.linksTo;if(i instanceof ot)return i.path?.pathParts.at(-1)?.linksTo}async function gs({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHANDLE"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ti(o,s[1].macro,0)}async function vi({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ti(o,s[1].macro,s.at(2)?.macro)}async function $D(t,e,n){let r=t?.properties.find(l=>Z(l.name)===e);if(!r)return;let i=r.parent.nodeType;if(!i||!(i instanceof bt))return;let s=r.nexusMapsTo.at(0)?.specifierSpace,a=(s?r.parent.getProperty(`${s}-names`)?.ast.quickValues:void 0)?.findIndex(l=>typeof l=="string"&&l.toLowerCase()===n)??-1;return a===-1?void 0:r.nexusMapsTo.at(a)?.target}async function Dp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_NAME"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return await $D(o,s[1].macro,s[2].macro)}async function Ap({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHA_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ra(o,s[1].macro,0,s[2].macro,{macro:s[3],document:t,context:n,position:r},i)}async function Ip({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_PROP_BY_PHANDLE_IDX_OR"||e.args?.length!==5)return;let s=await Ti(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro);return dp(s,e.args[3].macro,{macro:e.args[4],document:t,context:n,position:r},i)}async function Op(t,e){if(!t)return;let n=t?.properties.find(r=>Z(r.name)===e);return n?.nexusMapsTo.length?n.nexusMapsTo.length:n?.ast.getFlatAstValues()?.length}async function FD(t,e,n,r){if(t)return Yn(await Op(t,e),n,r)}async function Mp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PROP_LEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return o?FD(o,s[1].macro,{macro:s[2],document:t,context:n,position:r},i):void 0}async function wa(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof re)return Z(r[0].value)}async function BD(t,e,n,r){if(t)return Yn(await wa(t,e),n,r)}async function xp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return BD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function Lp(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof re)return r[0].value}async function jD(t,e,n,r){if(t)return Yn(await Lp(t,e),n,r)}async function qp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return jD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function $p(t,e){return(await wa(t,e))?.toUpperCase()}async function UD(t,e,n,r){if(t)return Yn(await $p(t,e),n,r)}async function Fp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return UD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}function Jr(t){return async(e,n)=>{let r=await t(e,n);if(r instanceof X)return r}}async function x({macro:t,document:e,context:n,position:r}){["DT_ALIAS","DT_NODELABEL"].some(a=>a===t.parent?.macro)||t.parent?.macro==="DT_CHILD"&&t.argIndexInParent===1?t=t.parent:t.parent?.macro==="DT_HAS_ALIAS"?(t=t.parent,t.macro="DT_ALIAS"):t.parent?.macro==="DT_PATH"&&(t.parent.args=t.parent.args?.slice(0,(t.argIndexInParent??0)+1)??[],t=t.parent);let s=await[fp,hp,gp,yp,ID,Tp,vp,bp,_p,kp,gs,vi,Dp,wD,ND,ED,Pp,Jr(Rp),Jr(wp),Jr(Ep),Jr(Cp),Jr(Ap),Jr(Ip),Jr(Mp),Jr(Pa),Jr(xp),Jr(qp),Jr(Fp)].reduce((a,c)=>a.then(l=>l||c({macro:t,document:e,context:n,position:r},x)),Promise.resolve(void 0));if(s)return Array.isArray(s)?s.at(0):s;let o=await hs(e,t.macro,r,n);if(o)return x({document:e,macro:o[0],context:n,position:r})}async function HD({macro:t,document:e,context:n,position:r}){return t.macro&&t.macro&&"DT_CHILD".startsWith(t.macro)?[{label:"DT_CHILD(...)",insertText:"DT_CHILD($1, $2)",kind:il.CompletionItemKind.Function,insertTextFormat:il.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_CHILD"||t.argIndexInParent!==1||!t.parent.args?.length?[]:(await x({document:e,macro:t.parent.args[0],context:n,position:r}))?.nodes.map(s=>({label:Z(s.fullName),kind:il.CompletionItemKind.Class,documentation:s.toMarkupContent(n.macros)}))??[]}var sl=q(j());function VD({macro:t,context:e}){return t.macro&&"DT_COMPAT_GET_ANY_STATUS_OKAY".startsWith(t.macro)?[{label:"DT_COMPAT_GET_ANY_STATUS_OKAY(...)",insertText:"DT_COMPAT_GET_ANY_STATUS_OKAY($1)",kind:sl.CompletionItemKind.Function,insertTextFormat:sl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.argIndexInParent!==0?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:sl.CompletionItemKind.Property}))??[]}var ol=q(j());function WD({macro:t,context:e}){return t.macro&&"DT_INST".startsWith(t.macro)?[{label:"DT_INST(...)",insertText:"DT_INST($1, $2)",kind:ol.CompletionItemKind.Function,insertTextFormat:ol.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_INST"||t.argIndexInParent!==1?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:ol.CompletionItemKind.Property}))??[]}var al=q(j());async function zD({macro:t,context:e}){if(t.macro&&"DT_NODELABEL".startsWith(t.macro))return[{label:"DT_NODELABEL(...)",insertText:"DT_NODELABEL($1)",kind:al.CompletionItemKind.Function,insertTextFormat:al.InsertTextFormat.Snippet}];let n=await e.getRuntime();return t.parent?.macro!=="DT_NODELABEL"||t.argIndexInParent!==0?[]:await Promise.all(n.rootNode.allDescendantsLabels.map(async r=>({label:r.label.value,kind:al.CompletionItemKind.Property,documentation:r.lastLinkedTo?.toMarkupContent(n.context.macros)}))??[])}var cl=q(j());async function GD({macro:t,context:e}){return t.macro&&t.macro&&"DT_PATH".startsWith(t.macro)?[{label:"DT_PATH(...)",insertText:"DT_PATH($1)",kind:cl.CompletionItemKind.Function,insertTextFormat:cl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_PATH"||!t.parent.args?.length?[]:(await Sp(t.parent.args.slice(0,-1).map(r=>r.macro),e))?.nodes.map(r=>({label:Z(r.fullName),kind:cl.CompletionItemKind.Class,documentation:r.toMarkupContent(e.macros)}))??[]}var KD=q(j());async function YD({macro:t,context:e}){if(t.macro&&t.macro&&"DT_ROOT".startsWith(t.macro)){let n=await e.getRuntime();return[{label:"DT_ROOT",kind:KD.CompletionItemKind.Class,documentation:n.rootNode.toMarkupContent(n.context.macros)}]}return[]}var Bp=q(j());function XD({macro:t}){return t.macro&&t.macro&&"DT_SAME_NODE".startsWith(t.macro)?[{label:"DT_SAME_NODE(...)",insertText:"DT_SAME_NODE($1, $2)",kind:Bp.CompletionItemKind.Snippet,insertTextFormat:Bp.InsertTextFormat.Snippet}]:[]}var ll=q(j());async function J({macro:t,document:e,position:n,context:r},i,s,o,a,c=l=>x({document:e,macro:l,context:r,position:n})){if(t.macro&&t.macro&&i.startsWith(t.macro))return[{label:`${i}(...)`,insertText:`${i}(${Array(o).map((d,f)=>`${f+1}`).join(", ")})`,kind:ll.CompletionItemKind.Function,insertTextFormat:ll.InsertTextFormat.Snippet}];if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let l=await c(t.parent.args[0]);return(a?l?.properties.filter(a):l?.properties)?.map(d=>({label:Z(d.name),kind:ll.CompletionItemKind.Property,documentation:d.toPrettyString(r.macros)}))??[]}async function JD(t){return J(t,"DT_ENUM_HAS_VALUE",1,3)}async function QD(t){return J(t,"DT_ENUM_HAS_VALUE_BY_IDX",1,4)}async function ZD(t){return J(t,"DT_ENUM_IDX",1,2)}async function eA(t){return J(t,"DT_ENUM_IDX_BY_IDX",1,3)}async function tA(t){return J(t,"DT_ENUM_IDX_BY_IDX_OR",1,4)}async function nA(t){return J(t,"DT_ENUM_IDX_OR",1,3)}var rA=q(j());async function ji({macro:t,document:e,context:n,position:r},i,s,o){if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let c=(await x({document:e,macro:t.parent.args[0],context:n,position:r}))?.properties.find(f=>Z(f.name)===t.parent?.args?.at(1)?.macro),l=0;if(typeof o=="string"){let f=c?.nexusMapsTo.at(0)?.specifierSpace;if(l=(f?c.parent.getProperty(`${f}-names`)?.ast.quickValues:void 0)?.findIndex(m=>typeof m=="string"&&m.toLowerCase()===o)??-1,l===-1)return[]}let u=c?.nexusMapsTo.at(l);return u?.target.nodeType?.cellsValues?.find(f=>u.specifierSpace&&f.specifier===u.specifierSpace)?.values.map(f=>({label:Z(f),kind:rA.CompletionItemKind.Property}))??[]}async function iA(t){return t.macro.argIndexInParent===2?ji(t,"DT_PHA",2,0):J(t,"DT_PHA",1,3,e=>!!e.nexusMapsTo.length)}var sA=q(j());async function oH({document:t,macro:e,position:n,context:r},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await x({document:t,macro:e.parent.args[0],context:r,position:n}))?.properties.find(a=>Z(a.name)===e.parent?.args?.at(1)?.macro);return Array(o?.nexusMapsTo.length??0)?.map((a,c)=>({label:c.toString(),kind:sA.CompletionItemKind.Property}))??[]}async function oA(t){if(t.macro.argIndexInParent===2)return oH(t,"DT_PHA_BY_IDX");if(t.macro.argIndexInParent===3){let e=t.macro.parent?.args?De(t.macro.parent.args[2].macro):void 0;return typeof e!="number"?[]:ji(t,"DT_PHA_BY_IDX",3,e)}return J(t,"DT_PHA_BY_IDX",1,3,e=>!!e.nexusMapsTo.length)}var aA=q(j());async function ul({document:t,macro:e,context:n,position:r},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await x({document:t,macro:e.parent.args[0],context:n,position:r}))?.properties.find(l=>Z(l.name)===e.parent?.args?.at(1)?.macro),a=o?.nexusMapsTo.at(0)?.specifierSpace;return(a?o.parent.getProperty(`${a}-names`)?.ast.quickValues:void 0)?.filter(l=>typeof l=="string")?.map(l=>({label:l,kind:aA.CompletionItemKind.Property}))??[]}async function cA(t){let{macro:e}=t;return e.argIndexInParent===2?ul(t,"DT_PHA_BY_NAME"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?ji(t,"DT_PHA_BY_NAME",3,e.parent.args[2].macro):[]:J(t,"DT_PHA_BY_NAME",1,3,n=>!!n.nexusMapsTo.length)}async function lA(t){let{macro:e}=t;return e.argIndexInParent===2?ul(t,"DT_PHA_BY_NAME_OR"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?ji(t,"DT_PHA_BY_NAME_OR",3,e.parent.args[2].macro):[]:J(t,"DT_PHA_BY_NAME_OR",1,3,n=>!!n.nexusMapsTo.length)}async function uA(t){let{macro:e}=t;return e.argIndexInParent===2?ji(t,"DT_PHA_OR",2,0):J(t,"DT_PHA_OR",1,3,n=>!!n.nexusMapsTo.length)}async function jp(t){return J(t,"DT_PHANDLE",1,2,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof ie||n instanceof ot))}async function Ea(t){return J(t,"DT_PHANDLE_BY_IDX",1,3,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof ie||n instanceof ot))}async function dA(t){let{macro:e}=t;return e.argIndexInParent===2?ul(t,"DT_PHANDLE_BY_NAME"):J(t,"DT_PHANDLE_BY_NAME",1,3,n=>!!n.ast.getFlatAstValues()?.some(r=>r instanceof ie||r instanceof ot))}async function fA(t){return J(t,"DT_PROP",1,2,e=>!e.nexusMapsTo.length)}async function pA(t){return J(t,"DT_PROP_BY_IDX",1,3,e=>!e.nexusMapsTo.length)}async function hA(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX"?Ea({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):J(t,"DT_PROP_BY_PHANDLE_IDX",3,4,n=>!n.nexusMapsTo.length,()=>vi({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function mA(t){let{macro:e}=t;return e.argIndexInParent===1&&e.parent?.macro==="DT_PROP_BY_PHANDLE"?jp({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE"}:void 0}}):J(t,"DT_PROP_BY_PHANDLE",2,3,n=>!n.nexusMapsTo.length,()=>gs({...t,macro:{macro:"DT_PHANDLE",args:e.parent?.args?.slice(0,2)}},x))}async function gA(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX_OR"?Ea({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):J(t,"DT_PROP_BY_PHANDLE_IDX_OR",3,5,n=>!n.nexusMapsTo.length,()=>vi({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function yA(t){return J(t,"DT_PROP_HAS_IDX",1,3,e=>!e.nexusMapsTo.length)}async function TA(t){return J(t,"DT_PROP_HAS_NAME",1,3,e=>!e.nexusMapsTo.length)}async function vA(t){return J(t,"DT_PROP_LAST",1,2,e=>!e.nexusMapsTo.length)}async function bA(t){return J(t,"DT_PROP_LEN",1,2,e=>!e.nexusMapsTo.length)}async function _A(t){return J(t,"DT_PROP_LEN_OR",1,2,e=>!e.nexusMapsTo.length)}async function SA(t){return J(t,"DT_PROP_OR",1,2,e=>!e.nexusMapsTo.length)}async function kA(t){return J(t,"DT_STRING_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function PA(t){return J(t,"DT_STRING_TOKEN_BY_IDX",1,3,e=>{let n=e.ast.getFlatAstValues();return!!n?.length&&n.every(r=>r instanceof re)})}async function NA(t){return J(t,"DT_STRING_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function RA(t){return J(t,"DT_STRING_UNQUOTED",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function wA(t){return J(t,"DT_STRING_UNQUOTED_BY_IDX",1,3,e=>{let n=e.ast.getFlatAstValues();return!!n?.length&&n.every(r=>r instanceof re)})}async function EA(t){return J(t,"DT_STRING_UNQUOTED_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function CA(t){return J(t,"DT_STRING_UPPER_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function DA(t){return J(t,"DT_STRING_UPPER_TOKEN_BY_IDX",1,3,e=>{let n=e.ast.getFlatAstValues();return!!n?.length&&n.every(r=>r instanceof re)})}async function AA(t){return J(t,"DT_STRING_UPPER_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}var dl=q(j());async function IA({macro:t,context:e}){return t.parent?.macro==="DT_ON_BUS"&&t.argIndexInParent===1?e.bindingLoader?.getBusTypes().map(n=>({label:Z(n),kind:dl.CompletionItemKind.Enum}))??[]:t.macro&&"DT_ON_BUS".startsWith(t.macro)?[{label:"DT_ON_BUS(...)",insertText:"DT_ON_BUS($1, $2)",kind:dl.CompletionItemKind.Function,insertTextFormat:dl.InsertTextFormat.Snippet}]:[]}async function OA(t){return J(t,"DT_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}async function MA(t){return J(t,"DT_HAS_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}var aH=["DT_BUS","DT_CHILD_NUM","DT_CHILD_NUM_STATUS_OKAY","DT_GPARENT","DT_HAS_ALIAS","DT_NODE_CHILD_IDX","DT_NODE_FULL_NAME","DT_NODE_FULL_NAME_TOKEN","DT_NODE_FULL_NAME_UNQUOTED","DT_NODE_FULL_NAME_UPPER_TOKEN","DT_NODE_HASH","DT_NODE_PATH","DT_NODELABEL_STRING_ARRAY","DT_PARENT"];async function xA(t,e,n){if(!n)return[];let r=Bi(n,t.position);return r?(await Promise.all([IA,OA,MA,PD,HD,VD,WD,cH,zD,GD,YD,XD,QD,JD,eA,tA,ZD,nA,oA,cA,lA,iA,Ea,dA,jp,uA,pA,mA,hA,gA,fA,yA,TA,vA,bA,_A,SA,kA,PA,NA,RA,wA,EA,CA,DA,AA].flatMap(async i=>await i({document:n,context:e,macro:r,position:t.position})))).flat():[]}function cH({macro:t}){return t.macro?aH.filter(e=>e.startsWith(t.macro)).map(e=>({label:`${e}(...)`,insertText:`${e}($1)`,kind:Up.CompletionItemKind.Function,insertTextFormat:Up.InsertTextFormat.Snippet})):[]}var Nr=q(j());function lH(t){if(!t||t.item===null||!(t.ast instanceof Ye))return[];let e=r=>r.replacedBy?e(r.replacedBy):r,n=r=>{let i=r.parent.deletedProperties.find(s=>s.property===r)?.by;return[r.ast,...r.allReplaced.map(s=>s.ast),...i?[i]:[]].map(s=>{let o=zn(s.fsPath);if(o)return Nr.Location.create(ue(o.docFsPath),o.range);if(s instanceof je)return Nr.Location.create(ue(s.fsPath),ce(s.propertyName??s));if(s instanceof yt)return Nr.Location.create(ue(s.fsPath),ce(s.propertyName??s))}).filter(s=>s)};if(t.item instanceof Xe&&t.ast instanceof Ye)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function uH(t){if(!t)return[];let e=n=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"&&t.runtime.rootNode.getChild(a[0].split("/"))===n)return!0}).map(o=>o.ast)??[],s=n.parent?.deletedNodes.filter(o=>o.node===n&&(o.by.nodeNameOrRef instanceof xe?o.by.nodeNameOrRef!==t.ast:!n.linkedRefLabels.some(a=>a!==t.ast))).map(o=>o.by.nodeNameOrRef)??[];return[...i,...n.linkedRefLabels,...n.linkedNodeNamePaths,...n.definitions,...s].map(o=>{let a=o&&zn(o?.fsPath);if(a)return Nr.Location.create(ue(a.docFsPath),a.range);if(o instanceof Tt)return Nr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof He)return Nr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof xe)return Nr.Location.create(ue(o.fsPath),ce(o));if(o instanceof xe)return Nr.Location.create(ue(o.fsPath),ce(o));if(o instanceof ie)return Nr.Location.create(ue(o.fsPath),ce(o.label??o));if(o instanceof je)return Nr.Location.create(ue((o.values??o)?.fsPath),ce(o.values??o))}).filter(o=>o)};if(t.item instanceof X&&!Kt(t.ast))return e(t.item);if(t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo)return e(t.ast.parentNode.linksTo);if(t.ast instanceof xe&&t.ast.linksTo)return Kt(t.ast)?[...e(t.ast.linksTo),Nr.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo);if(t?.ast instanceof re&&t.item instanceof Xe&&t.item.parent.name==="aliases"){let n=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(n)return e(n)}return[]}async function LA(t,e){return Nt(t,e,n=>[...uH(n),...lH(n)])}var Ui=q(j());function qA(t){if(!t||t.item===null||!(t.ast instanceof Ye))return[];let e=r=>r.replacedBy?e(r.replacedBy):r,n=r=>[r.ast,...r.allReplaced.map(i=>i.ast),r.parent.deletedProperties.find(i=>i.property===r)?.by??[]].map(i=>{if((i instanceof je||i instanceof yt)&&i.propertyName)return Ui.Location.create(ue(i.fsPath),ce(i.propertyName))}).filter(i=>i);if(t.item instanceof Xe&&t.ast instanceof Ye)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function $A(t,e){if(!e||!(e.ast instanceof un))return[];"newName"in t&&(e.ast.parentNode instanceof ie&&t.newName.startsWith("&")?t.newName=t.newName.slice(1):e.ast.parentNode instanceof ps&&t.newName.endsWith(":")&&(t.newName=t.newName.slice(0,-1)));let n=e.ast.value,r=i=>[...i.implementations.filter(s=>s instanceof He||s instanceof Et).flatMap(s=>s.labels.map(o=>o.label)),...i.linkedRefLabels.map(s=>s.label)].filter(s=>s?.value===n).map(s=>{if(s)return Ui.Location.create(ue(s.fsPath),ce(s))}).filter(s=>s);return e.item instanceof X&&!Kt(e.ast)?r(e.item):e.ast instanceof un&&e.ast.parentNode instanceof ie&&e.ast.parentNode.linksTo?r(e.ast.parentNode.linksTo):[]}function FA(t){if(!t||!(t.ast instanceof xe)||t.ast instanceof xe&&t.ast.linksTo===t.runtime.rootNode)return[];let e=n=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"){let c=t.runtime.rootNode.getChild(a[0].split("/"));if(c?.isChildOf(n)||c===n)return!0}}).map(o=>o.ast)??[],s=n.parent?.deletedNodes.filter(o=>o.node===n&&o.by.nodeNameOrRef!==t.ast).map(o=>o.by.nodeNameOrRef)??[];return[...i,...n.linkedNodeNamePaths,...n.definitions,...s].map(o=>{if(o instanceof He&&o.name)return Ui.Location.create(ue(o.fsPath),ce(o.name));if(o instanceof xe)return Ui.Location.create(ue(o.fsPath),ce(o));if(o instanceof je&&o.values?.values[0]?.value&&o.values?.values[0]?.value instanceof re){let a=o.values.values[0].value,c=ce(a),l=a.value.split("/"),u=n.path,d=l.slice(0,u.length-1).join("/").length+1,f=a.value.length-l.slice(0,u.length).join("/").length;return c.start.character+=1+d,c.end.character-=1+f,Ui.Location.create(ue(o.values.values[0].fsPath),c)}}).filter(o=>o)};return t.item instanceof X&&!Kt(t.ast)?e(t.item):t.ast instanceof xe&&t.ast.linksTo?Kt(t.ast)?[...e(t.ast.linksTo),Ui.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo):[]}async function BA(t,e){let n={};return(await Nt(t,e,i=>[...FA(i),...$A(t,i),...qA(i)])).forEach(i=>{n[i.uri]??=[],n[i.uri].push(Ui.TextEdit.replace(i.range,t.newName))}),{changes:n}}async function jA(t,e){let n=await Nt(t,e,r=>[...FA(r),...$A(t,r),...qA(r)]);if(n.some(r=>e?.settings.lockRenameEdits?.some(i=>Se(r.uri).startsWith(i))))throw new Error('Path is locked by user setting "lockRenameEdits"');if(n.some(r=>ro(r.uri)))throw new Error("Item was generated using a MACRO.");return{defaultBehavior:!!n.length}}var Da=q(j());var Ca=t=>t.implementations.map(e=>{let n=zn(e.fsPath);return n?Da.Location.create(ue(n.docFsPath),n.range):Da.Location.create(ue(e.fsPath),ce(e))}).filter(e=>e),UA=t=>t.replacedBy?UA(t.replacedBy):t,Hp=t=>[t.ast,...t.allReplaced.map(e=>e.ast)].map(e=>{let n=zn(e.fsPath);return n?Da.Location.create(ue(n.docFsPath),n.range):Da.Location.create(ue(e.fsPath),ce(e.propertyName??e))}).filter(e=>e);function dH(t){if(!t||t.item===null||!(t.ast instanceof Ye))return[];if(t.item instanceof Xe&&t.ast instanceof Ye)return Hp(UA(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let e=t.item.deletedProperties.find(n=>n.by===t.ast.parentNode)?.property;if(e)return Hp(e)}return[]}function fH(t){if(!t)return[];if(t.item instanceof X&&!Kt(t.ast))return Ca(t.item);if(t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo)return Ca(t.ast.parentNode.linksTo);if(t.ast instanceof xe&&t.ast.linksTo)return Ca(t.ast.linksTo);if(t?.ast instanceof re&&t.item instanceof Xe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Ca(e)}return[]}function pH(t){if(t?.ast instanceof pt||t?.ast instanceof hi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof pt?t.ast.name:t.ast.value);if(e)return[Da.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))]}return[]}async function HA(t,e){return Nt(t,e,n=>[...fH(n),...dH(n),...pH(n)])}var hH=["DT_PROP","DT_PROP_LEN","DT_PROP_LEN_OR","DT_PROP_HAS_IDX","DT_PROP_HAS_NAME","DT_PROP_BY_IDX","DT_PROP_LAST","DT_PROP_OR","DT_ENUM_IDX_BY_IDX","DT_ENUM_IDX","DT_ENUM_IDX_BY_IDX_OR","DT_ENUM_IDX_OR","DT_ENUM_HAS_VALUE_BY_IDX","DT_ENUM_HAS_VALUE","DT_STRING_TOKEN","DT_STRING_TOKEN_OR","DT_STRING_UPPER_TOKEN","DT_STRING_UPPER_TOKEN_OR","DT_STRING_UNQUOTED","DT_STRING_UNQUOTED_OR","DT_STRING_TOKEN_BY_IDX","DT_STRING_UPPER_TOKEN_BY_IDX","DT_STRING_UNQUOTED_BY_IDX","DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR","DT_PROP_BY_PHANDLE","DT_PHA_BY_IDX","DT_PHA_BY_IDX_OR","DT_PHA","DT_PHA_OR","DT_PHA_BY_NAME","DT_PHA_BY_NAME_OR","DT_PHANDLE_BY_NAME","DT_PHANDLE_BY_IDX","DT_PHANDLE"];async function Vp({macro:t,document:e,context:n,position:r}){if(hH.some(i=>i===t.parent?.macro)&&t.argIndexInParent===1&&t.parent?.args?.[0])return(await x({document:e,context:n,position:r,macro:t.parent.args[0]}))?.properties.find(s=>Z(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===2&&t.parent?.args?.[0]&&t.parent?.args?.[1])return(await gs({document:e,context:n,position:r,macro:{macro:"DT_PHANDLE",args:t.parent.args.slice(0,2)}},x))?.properties.find(s=>Z(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===3&&t.parent?.args?.[0]&&t.parent?.args?.[1]&&t.parent?.args?.[3])return(await vi({document:e,context:n,position:r,macro:{macro:"DT_PHANDLE_BY_IDX",args:t.parent.args.slice(0,3)}},x))?.properties.find(s=>Z(s.name)===t.macro);if(["DT_CHOSEN","DT_HAS_CHOSEN"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===0&&t.parent?.args?.[0])return(await n.getRuntime()).rootNode.getChild(["/","chosen"])?.properties.find(i=>Z(i.name)===t.macro)}async function VA(t,e,n){if(!n)return;let r=Bi(n,t.position);return WA(r,t.position,e,n)}async function WA(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Ca(i);let s=await Vp({document:r,macro:t,context:n,position:e});if(s)return Hp(s);let o=await hs(r,t.macro,e,n);if(o)return WA(o[0],o[1],n,r)}var ys=q(j());var Aa=t=>{let e=t.definitions.at(0),n=e&&zn(e.fsPath);return n?ys.Location.create(ue(n.docFsPath),n.range):e?ys.Location.create(ue(e.fsPath),ce(e)):void 0},Wp=t=>t.replaces?Wp(t.replaces):t,zA=t=>{let e=Wp(t),n=zn(e.ast.fsPath);return n?ys.Location.create(ue(n.docFsPath),n.range):e?ys.Location.create(ue(e.ast.fsPath),ce(e.ast)):void 0};function mH(t){if(!t||t.item===null||!(t.ast instanceof Ye))return;let e=n=>{let r=zn(n.ast.fsPath);return r?ys.Location.create(ue(r.docFsPath),r.range):ys.Location.create(ue(n.ast.fsPath),ce(n.ast.propertyName??n.ast))};if(t.item instanceof Xe&&t.ast instanceof Ye)return e(Wp(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let n=t.item.deletedProperties.find(r=>r.by===t.ast.parentNode)?.property;if(n)return e(Wp(n))}}function gH(t){if(t){if(t.item instanceof X&&!Kt(t.ast))return Aa(t.item);if(t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo)return Aa(t.ast.parentNode.linksTo);if(t.ast instanceof xe&&t.ast.linksTo)return Aa(t.ast.linksTo);if(t?.ast instanceof re&&t.item instanceof Xe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Aa(e)}}}function yH(t){if(t?.ast instanceof pt||t?.ast instanceof hi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof pt?t.ast.name:t.ast.value);if(e)return ys.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))}}async function GA(t,e){return(await Nt(t,e,n=>[gH(n)||mH(n)||yH(n)])).at(0)}async function KA(t,e,n){if(!n)return;let r=Bi(n,t.position);return YA(r,t.position,e,n)}async function YA(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Aa(i);let s=await Vp({document:r,macro:t,context:n,position:e});if(s)return zA(s);let o=await hs(r,t.macro,e,n);if(o)return YA(o[0],o[1],n,r)}var fe=q(j());var TH=(t,e,n,r,i)=>{switch(n){case 1:return[{title:"Add semicolon",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),";")]}}}];case 2:return[{title:"Add open curly",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character)," {")]}}}];case 29:return[{title:"Remove white space",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(fe.Range.create(fe.Position.create(r.range.start.line,t.pos.colEnd),fe.Position.create(r.range.end.line,e.pos.col)),"")]}}}];case 3:return[{title:"Add close curly",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),"}")]}}}];case 19:return[{title:"Add '/'",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),"/")]}}}];case 28:return[{title:"Add comma",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),",")]}}}];case 21:return[{title:"Add '/'",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),"/")]}}}];case 23:return[{title:"Remove ';'",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.del(r.range)]}}}];case 34:return[{title:"Complete Keyword '/delete-node/",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-node/")]}}}];case 35:return[{title:"Complete Keyword '/delete-property/",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-property/")]}}}];case 25:return[{title:"Complete Keyword '/delete-property/",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-property/")]}}},{title:"Complete Keyword '/delete-node/",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-node/")]}}}];case 12:return[{title:"Add '>'",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),">")]}}}];default:return}},vH=(t,e,n,r,i)=>{if(!r?.length)return[];switch(t){case 0:return[{title:i??`Add Property "${r[0].newText.split("=",1)[0].replace(";","").trim()}"`,diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 27:return[{title:i??"Remove Property",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 26:return[{title:i??"TODO",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 36:return[{title:i??"TODO",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 25:return r?[{title:i??"TODO",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}]:[];default:return}},bH=(t,e,n,r)=>n?.length?[{title:r??"TODO",diagnostics:[t],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[e]:n}}}]:[];function XA(t){let e=t.context.diagnostics.flatMap(a=>{let c=a.data;if(c?.virtual)return[];switch(c?.type){case"FormattingIssues":return bH(a,t.textDocument.uri,c.edit?Array.isArray(c.edit)?c.edit:[c.edit]:void 0,c.codeActionTitle);case"SyntaxIssue":return c?.items.flatMap(l=>TH(c.firstToken,c.lastToken,l,a,t.textDocument.uri));case"StandardTypeIssue":return c?.items.flatMap(l=>vH(l,a,t.textDocument.uri,c.edit?Array.isArray(c.edit)?c.edit:[c.edit]:void 0,c.codeActionTitle))}}).filter(a=>!!a),n=e.filter(a=>a.kind===fe.CodeActionKind.SourceFixAll),r=e.filter(a=>a.title.startsWith("Add Property")),i=e.filter(a=>a.kind!==fe.CodeActionKind.SourceFixAll),s=n.flatMap(a=>a.edit?.changes?.[t.textDocument.uri]??[]),o=new Map;return r.forEach(a=>{let c=a.edit.changes[t.textDocument.uri][0],l=c.range.start.line,u=c.range.start.character;o.has(`${l}:${u}`)||o.set(`${l}:${u}`,[]),o.get(`${l}:${u}`)?.push(c)}),[...i,...n.map(a=>({...a,kind:fe.CodeActionKind.QuickFix})),...s.length?[{title:"Fix All",kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:s}}}]:[],...Array.from(o.values()).flatMap(a=>a.length>1?{title:"Add All Missing Properties",kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:a}}}:[])]}var ee=q(j());function JA(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}var QA=(t,e)=>e.some(n=>JA(t,n.start)>=0&&JA(t,n.end)<=0),_H=async(t,e,n)=>{let r=en.create(t.pos.line,t.pos.col),i=n.find(s=>Cn(s,e,r));if(i)return zr(i,e,r)},uo=(t,e)=>{let n=en.create(e.length-1,e.at(-1)?.length??0),r=[],i;return t.filter(o=>(o instanceof cr||o instanceof lr)&&/^dts-format (on|off)$/.test(o.toString().trim())).sort((o,a)=>o.firstToken.pos.line-a.firstToken.pos.line).forEach(o=>{let a=o.toString().trim();if(a==="dts-format off")i={start:en.create(o.firstToken.pos.line,o instanceof cr?o.firstToken.pos.colEnd:0)};else if(a==="dts-format on"&&i){let c=en.create(o.lastToken.pos.line,o instanceof cr?o.lastToken.pos.colEnd-1:e[o.lastToken.pos.line-1].length);r.push(Qe.create(i.start,c)),i=void 0}}),i&&r.push(Qe.create(i.start,n)),r},fo=(t,e,n)=>{let r=t.length?n.filter(i=>(Array.isArray(i.raw.edit)?i.raw.edit:i.raw.edit?[i.raw.edit]:void 0)?.every(o=>!QA(o.range.start,t)&&!QA(o.range.end,t))):n;return"range"in e&&(r=r.filter(i=>Mf(e.range,i.raw.range))),r},Ia=(t,e)=>async n=>{let r=t.filter(a=>!(a instanceof kr)&&!(a instanceof lr)&&!(a instanceof cr)&&!(a instanceof Xr)&&!(a instanceof Pr)),i=await _H(n.firstToken,e,r);if(!i||i===n||n.allDescendants.some(a=>a===i))return{level:0};let s=$f(i);return{level:so(e,s),inAst:i}},In=(t,e)=>{if(t.insertSpaces)return"".padStart(e," ");let n=Math.floor(e/t.tabSize),r=e%t.tabSize;return`${"".padStart(n," ")}${"".padStart(r," ")}`},Rr=(t,e,n="")=>`${"".padStart(t*e.length,e)}${n}`,ZA=t=>{let e=t.parentNode;if(!(!e||!(e instanceof ge)))return!(e instanceof Qt)||!e.openBracket?ZA(e):e};function po(t,e,n,r,i,s,o=!1){if(!o&&ln(e.firstToken,t.firstToken))return r[e.firstToken.pos.line].slice(0,e.firstToken.pos.col).replace(/^\s+/,f=>f.replace(/\t/g," ".repeat(n.tabSize))).length-n.tabSize*i;let a=ZA(e);if(!a)return s;let l=po(t,a,n,r,i,s);return!o&&ln(e.firstToken,a.firstToken)?l+=e.firstToken.pos.col-a.firstToken.pos.col:a instanceof Qt&&a.openBracket&&++l,l}var Mt=q(j());function Ts(t,e,n,r){if(!ln(t,e)){let o=e.prevToken;for(;t!==o;){if(o&&ln(t,o)&&Ts(t,o,n,r))return!0;o=o?.prevToken}return null}return r[t.pos.line].slice(0,e.pos.colEnd).replace(/^\s+/,o=>o.replace(/\t/g," ".repeat(n.tabSize))).length>n.wordWrapColumn}async function fl(t,e,n,r,i,s,o=[]){let a=r.split(`
290
+ };`,kind:Ct.CompletionItemKind.Class,sortText:`!${r}`,insertTextFormat:Ct.InsertTextFormat.Snippet}))}async function vD(t,e){return Nt(t,e,(n,r)=>[...QU(n,r),...JU(n,r),...XU(n,r),...ZU(n,r),...YU(n,r),...KU(n,r),...GU(n),...eH(n),...tH(n,r)])}var Up=q(j());var _D=require("child_process");var qT=t=>/[A-Za-z0-9_]/.test(t);function nH(t,e){let n=[];for(let r=0;r<e;r++){let i=t[r];i==="("?n.push(r):i===")"&&n.pop()}return n.length?n[n.length-1]:void 0}function bD(t,e){let n=1;for(let r=e+1;r<t.length;r++){let i=t[r];if(i==="(")n++;else if(i===")"&&(n--,n===0))return r}}function SD(t,e,n){let r=[],i=0,s=!1,o=!1,a=e;for(let f=e;f<n;f++){let p=t[f];if(p==="'"&&!o)s=!s;else if(p==='"'&&!s)o=!o;else if(!s&&!o){if(p==="(")i++;else if(p===")")i--;else if(p===","&&i===0){let m=a,h=f,y=m,_=h;for(;y<_&&/\s/.test(t[y]);)y++;for(;_>y&&/\s/.test(t[_-1]);)_--;r.push({start:m,end:h,text:t.slice(y,_)}),a=f+1}}}let c=a,l=n,u=c,d=l;for(;u<d&&/\s/.test(t[u]);)u++;for(;d>u&&/\s/.test(t[d-1]);)d--;return r.push({start:c,end:l,text:t.slice(u,d)}),r}function $T(t){let e=t.trim(),n=/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/.exec(e);if(!n)return{macro:e};let r=n[1],i=n[2],s=SD(i,0,i.length),o={macro:r,args:[]};return o.args=s.map(a=>{let c=$T(a.text);return c.parent=o,c}),o}function Bi(t,e){let n=t.getText(),r=t.offsetAt(e),i=r,s=r;for(;i>0&&qT(n[i-1]);)i--;for(;s<n.length&&qT(n[s]);)s++;if(n[s]==="("){let y=bD(n,s);y!==void 0&&(s=y+1)}let o=n.slice(i,s),a=o.trim().length?$T(o):void 0,c=nH(n,r);if(c===void 0)return a;let l=bD(n,c);if(l===void 0||!(c<r&&r<=l))return a;let u=c,d=u;for(;d>0&&qT(n[d-1]);)d--;let f=n.slice(d,u);if(!f)return a;let p=SD(n,c+1,l),m={macro:f,args:[]};m.args=p.map(y=>{let _=$T(y.text);return _.parent=m,_});let h=-1;for(let y=0;y<p.length;y++){let _=p[y];if(r>=_.start&&r<=_.end){h=y;break}}if(h>=0){let y=m.args[h];return y.argIndexInParent=h,y}return m}function rH(t,e,n){let i=t.getText().split(/\r?\n/),s=new RegExp(`^\\s*#\\s*define\\s+(${e})\\b(\\s*\\([^)]*\\))?\\s*(.*)$`);for(let o=Math.min(n.line,i.length-1);o>=0;o--){let a=i[o],c=s.exec(a);if(c){let l=a.indexOf(c[0]),u=a.indexOf(c[3],l);return en.create(o,u>=0?u:a.length)}}}async function hs(t,e,n,r){let i=kD(t,e,n);if(i)return i;let s=await sH(e,r,Se(t.uri));if(s)return[s,n]}function kD(t,e,n){if(e.startsWith("DT_"))return;let r=rH(t,e,n);if(!r)return;let i=Bi(t,r);if(i)return[i,r]}var iH=(t,e)=>new Promise(n=>{let r=(0,_D.spawn)(t,e,{stdio:["ignore","pipe","pipe"]}),i="";r.stdout.on("data",s=>{i+=s.toString()}),r.on("close",s=>{n(s?"":i)})});async function sH(t,e,n){let r=e.getCompileCommands()?.find(s=>pe(s.file,n));if(!r)return;let i=`${r.command.replace(/-(o|c)\s+\S+/g,"")} -E -dM ${r.file}`;try{let[s,...o]=i.split(" "),a=await iH(s,o.filter(u=>!!u)),c=Vn.create(`macros://${r.file}`,"devicetree",0,a),l=kD(c,t,c.positionAt(a.length-1));if(l)return l[0]}catch(s){console.error(s)}}function Z(t){return t.toLowerCase().replace(/[@,-\.]/g,"_")}var rl=q(j());async function PD({macro:t,context:e}){if(t.macro&&"DT_ALIAS".startsWith(t.macro))return[{label:"DT_ALIAS(...)",insertText:"DT_ALIAS($1)",kind:rl.CompletionItemKind.Function,insertTextFormat:rl.InsertTextFormat.Snippet}];if(t.parent?.macro!=="DT_ALIAS"||t.argIndexInParent!==0)return[];let n=await e.getRuntime();return n.rootNode.getNode("aliases")?.properties.map(r=>{let i=r.ast.getFlatAstValues()?.at(0),s;return i instanceof ie?s=i.linksTo:i instanceof Gr&&(s=i.pathParts.at(-1)?.linksTo),{label:Z(r.name),kind:rl.CompletionItemKind.Property,documentation:s?.toMarkupContent(n.context.macros)}})??[]}var il=q(j());async function _n(t,e,n){if(!t)return;let i=t?.properties.find(s=>Z(s.name)===e)?.ast.getFlatAstValues();return i?.length===0?!0:i?.map(s=>{if(s instanceof ot)return s.path?.pathParts.at(-1)?.linksTo;if(s instanceof ie)return s.linksTo;if(s instanceof re)return s.value;if(s instanceof ge){let o=s.evaluate(n.macros);return typeof o=="number"?o:s.toString()}})}async function lp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PROP"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:n,position:r});return o?_n(o,s[1].macro,n):void 0}async function ND(t,e){let n=await lp(t,e);if(typeof n=="boolean")return;let r=n?.at(0);if(n?.length===1&&r instanceof X)return r}async function RD(t,e,n,r){if(n=typeof n=="number"?n:De(n),typeof n!="number")return;let i=await _n(t,e,r);if(i===!0)return!0;if(!i)return;let s=i.at(n);if(s)return i.length===1&&i[0]instanceof X?i[0]:s}async function up({document:t,macro:e,context:n,position:r},i){if(!(e.macro!=="DT_PROP_BY_IDX"||e.args?.length!==3))return RD(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro,n)}async function wD(t,e){let n=await up(t,e);if(typeof n!="boolean"&&n instanceof X)return n}async function Yn(t,{document:e,context:n,macro:r,position:i},s){return t||(await s({document:e,macro:r,context:n,position:i})??r.macro)}async function dp(t,e,n,r){return Yn(await _n(t,e,n.context),n,r)}async function Pa({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_PROP_OR"||e.args?.length!==3)return;let[s,o,a]=e.args,c=await i({document:t,macro:s,context:n,position:r});return await dp(c,o.macro,{macro:a,document:t,context:n,position:r},i)}async function ED(t,e){let n=await Pa(t,e);if(n instanceof X)return n;if(typeof n=="boolean")return;let r=n?.at(0);if(n?.length===1&&r instanceof X)return r}async function CD(t){let e=t?.nodeType?.onBus,n=t?.parent?.nodeType?.bus;return t&&n?.length&&n?.some(r=>r===e)?t.parent??void 0:void 0}async function fp(t,e){let n=t.macro.args;if(t.macro.macro!=="DT_BUS"||n?.length!==1)return;let r=await e({...t,macro:n[0]});return await CD(r)}async function pp(t,e){let n=(await t.getRuntime()).rootNode.getChild(["/","chosen"]);if(!n)return;let s=n?.properties.find(o=>Z(o.name)===e)?.ast.getFlatAstValues()?.at(0);if(s instanceof ie)return s.linksTo;if(s instanceof ot)return s.path?.pathParts.at(-1)?.linksTo}async function hp(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_CHOSEN"||e?.length!==1))return await pp(t.context,e[0].macro)}async function mp(t,e){let n=await e?.getRuntime();if(n){let r=gi.getNodeFromPath(["aliases"],n.rootNode,!0),i=r?.properties.find(o=>Z(o.name)===t);if(!i)return;let s=i.ast.getFlatAstValues();return s?.[0]instanceof re?r=n.rootNode.getChild(s[0].value.split("/")):s?.[0]instanceof ie?r=s[0].linksTo:s?.[0]instanceof ot&&(r=s[0].path?.pathParts.at(-1)?.linksTo),r}}async function gp({macro:t,context:e}){if(!(t.macro!=="DT_ALIAS"||t.args?.length!==1))return mp(t.args[0].macro,e)}async function DD(t,e){return t?.nodes.find(n=>Z(n.name)===e)}async function yp({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_CHILD"||e.args?.length!==2)return;let s=await i({document:t,macro:e.args[0],context:n,position:r});return DD(s,e.args[1].macro)}var FT=(t,e)=>t.nodes.filter(n=>!n.disabled&&n.nodeType).flatMap(n=>[n.nodeType.compatible,...Array.from(n.nodeType.extends)].filter(r=>!!r).map(r=>Z(r)).includes(e)?[n,...FT(n,e)]:FT(n,e));async function AD(t,e){let n=await e?.getRuntime();if(n)return FT(n.rootNode,t)}async function BT({macro:t,context:e}){if(!(t.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.args?.length!==1))return AD(t.args[0].macro,e)}async function ID(t){return(await BT(t))?.at(0)}async function OD(t){return t?.parent?.parent??void 0}async function Tp({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_GPARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:n,position:r});return OD(s)}var jT=(t,e)=>t.nodes.filter(n=>n.nodeType).sort((n,r)=>n.disabled===r.disabled?0:n.disabled?1:-1).flatMap(n=>[n.nodeType.compatible,...Array.from(n.nodeType.extends)].filter(r=>!!r).map(r=>Z(r)).includes(e)?[n,...jT(n,e)]:jT(n,e));async function MD(t,e,n){let r=await n?.getRuntime();if(r)return jT(r.rootNode,e).at(t)}async function vp({macro:t,context:e}){if(t.macro!=="DT_INST"||t.args?.length!==2)return;let n=De(t.args[0].macro);if(typeof n=="number")return MD(n,t.args[1].macro,e)}async function xD(t,e){let n=await e?.getRuntime(),r=n?.resolvePath([`&${t.trim()}`]);if(n&&r)return gi.getNodeFromPath(r.slice(1),n.rootNode,!0)}async function bp({macro:t,context:e}){if(!(t.macro!=="DT_NODELABEL"||t.args?.length!==1))return xD(t.args[0].macro,e)}async function LD(t){return t?.parent??void 0}async function _p({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_PARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:n,position:r});return LD(s)}var qD=(t,e)=>{if(!e.length)return t;let n=e.splice(0,1)[0],r=t.nodes.find(i=>Z(i.fullName)===n);return r?qD(r,e):void 0};async function Sp(t,e){let n=await e?.getRuntime();if(n)return qD(n.rootNode,t)}async function kp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_PATH"||!n?.length))return Sp(n.map(r=>r.macro),e)}async function Pp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_ROOT"||n?.length))return(await e.getRuntime()).rootNode}async function Na(t,e,n){let r=t?.properties.find(c=>Z(c.name)===e);if(!r)return;let i=r?.ast.quickValues?.at(n),s=r.parent.nodeType;if(Array.isArray(i)||!s||!(s instanceof bt))return;let a=s.properties.find(c=>c.getNameMatch(r.name))?.values(r).findIndex(c=>c===i)??-1;return a===-1?void 0:a}async function Np(t,e,n,r,i){return Yn(await Na(t,e,n),r,i)}async function Rp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_BY_IDX_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:n,position:r}),a=De(s[2].macro);if(typeof a=="number")return await Np(o,s[1].macro,a,{macro:s[3],document:t,context:n,position:r},i)}async function wp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return await Np(o,s[1].macro,0,{macro:s[2],document:t,context:n,position:r},i)}async function ms(t,e,n,r,i){let s=t?.properties.find(d=>Z(d.name)===e),o=s?.parent.nodeType;if(!o||!(o instanceof bt))return;if(typeof n=="string"){let d=s.nexusMapsTo.at(0)?.specifierSpace;if(n=(d?s.parent.getProperty(`${d}-names`)?.ast.quickValues:void 0)?.findIndex(p=>typeof p=="string"&&p.toLowerCase()===n)??-1,n===-1)return}let a=s.nexusMapsTo.at(n),l=a?.target.nodeType?.cellsValues?.find(d=>a.specifierSpace&&d.specifier===a.specifierSpace)?.values?.indexOf(r);if(l===void 0||l===-1)return;let u=a?.mappingValuesAst.at(l);if(u instanceof ge){let d=u.evaluate(i.macros);return typeof d!="number"?u.toString():d}}async function Ra(t,e,n,r,i,s){return Yn(await ms(t,e,n,r,i.context),i,s)}async function Ep({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHA_BY_IDX_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:n,position:r}),a=De(s[2].macro);if(typeof a=="number")return Ra(o,s[1].macro,a,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Cp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHA_BY_NAME_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ra(o,s[1].macro,s[2].macro,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Ti(t,e,n=0){let r=t?.properties.find(s=>Z(s.name)===e);if(n=typeof n=="number"?n:De(n??"0"),typeof n!="number")return;let i=r?.ast.getFlatAstValues()?.at(n);if(i instanceof ie)return i.linksTo;if(i instanceof ot)return i.path?.pathParts.at(-1)?.linksTo}async function gs({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHANDLE"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ti(o,s[1].macro,0)}async function vi({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ti(o,s[1].macro,s.at(2)?.macro)}async function $D(t,e,n){let r=t?.properties.find(l=>Z(l.name)===e);if(!r)return;let i=r.parent.nodeType;if(!i||!(i instanceof bt))return;let s=r.nexusMapsTo.at(0)?.specifierSpace,a=(s?r.parent.getProperty(`${s}-names`)?.ast.quickValues:void 0)?.findIndex(l=>typeof l=="string"&&l.toLowerCase()===n)??-1;return a===-1?void 0:r.nexusMapsTo.at(a)?.target}async function Dp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_NAME"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return await $D(o,s[1].macro,s[2].macro)}async function Ap({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PHA_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:n,position:r});return Ra(o,s[1].macro,0,s[2].macro,{macro:s[3],document:t,context:n,position:r},i)}async function Ip({document:t,macro:e,context:n,position:r},i){if(e.macro!=="DT_PROP_BY_PHANDLE_IDX_OR"||e.args?.length!==5)return;let s=await Ti(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro);return dp(s,e.args[3].macro,{macro:e.args[4],document:t,context:n,position:r},i)}async function Op(t,e){if(!t)return;let n=t?.properties.find(r=>Z(r.name)===e);return n?.nexusMapsTo.length?n.nexusMapsTo.length:n?.ast.getFlatAstValues()?.length}async function FD(t,e,n,r){if(t)return Yn(await Op(t,e),n,r)}async function Mp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_PROP_LEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return o?FD(o,s[1].macro,{macro:s[2],document:t,context:n,position:r},i):void 0}async function wa(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof re)return Z(r[0].value)}async function BD(t,e,n,r){if(t)return Yn(await wa(t,e),n,r)}async function xp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return BD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function Lp(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof re)return r[0].value}async function jD(t,e,n,r){if(t)return Yn(await Lp(t,e),n,r)}async function qp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return jD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function $p(t,e){return(await wa(t,e))?.toUpperCase()}async function UD(t,e,n,r){if(t)return Yn(await $p(t,e),n,r)}async function Fp({document:t,macro:e,context:n,position:r},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return UD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}function Jr(t){return async(e,n)=>{let r=await t(e,n);if(r instanceof X)return r}}async function x({macro:t,document:e,context:n,position:r}){["DT_ALIAS","DT_NODELABEL"].some(a=>a===t.parent?.macro)||t.parent?.macro==="DT_CHILD"&&t.argIndexInParent===1?t=t.parent:t.parent?.macro==="DT_HAS_ALIAS"?(t=t.parent,t.macro="DT_ALIAS"):t.parent?.macro==="DT_PATH"&&(t.parent.args=t.parent.args?.slice(0,(t.argIndexInParent??0)+1)??[],t=t.parent);let s=await[fp,hp,gp,yp,ID,Tp,vp,bp,_p,kp,gs,vi,Dp,wD,ND,ED,Pp,Jr(Rp),Jr(wp),Jr(Ep),Jr(Cp),Jr(Ap),Jr(Ip),Jr(Mp),Jr(Pa),Jr(xp),Jr(qp),Jr(Fp)].reduce((a,c)=>a.then(l=>l||c({macro:t,document:e,context:n,position:r},x)),Promise.resolve(void 0));if(s)return Array.isArray(s)?s.at(0):s;let o=await hs(e,t.macro,r,n);if(o)return x({document:e,macro:o[0],context:n,position:r})}async function HD({macro:t,document:e,context:n,position:r}){return t.macro&&t.macro&&"DT_CHILD".startsWith(t.macro)?[{label:"DT_CHILD(...)",insertText:"DT_CHILD($1, $2)",kind:il.CompletionItemKind.Function,insertTextFormat:il.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_CHILD"||t.argIndexInParent!==1||!t.parent.args?.length?[]:(await x({document:e,macro:t.parent.args[0],context:n,position:r}))?.nodes.map(s=>({label:Z(s.fullName),kind:il.CompletionItemKind.Class,documentation:s.toMarkupContent(n.macros)}))??[]}var sl=q(j());function VD({macro:t,context:e}){return t.macro&&"DT_COMPAT_GET_ANY_STATUS_OKAY".startsWith(t.macro)?[{label:"DT_COMPAT_GET_ANY_STATUS_OKAY(...)",insertText:"DT_COMPAT_GET_ANY_STATUS_OKAY($1)",kind:sl.CompletionItemKind.Function,insertTextFormat:sl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.argIndexInParent!==0?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:sl.CompletionItemKind.Property}))??[]}var ol=q(j());function WD({macro:t,context:e}){return t.macro&&"DT_INST".startsWith(t.macro)?[{label:"DT_INST(...)",insertText:"DT_INST($1, $2)",kind:ol.CompletionItemKind.Function,insertTextFormat:ol.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_INST"||t.argIndexInParent!==1?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:ol.CompletionItemKind.Property}))??[]}var al=q(j());async function zD({macro:t,context:e}){if(t.macro&&"DT_NODELABEL".startsWith(t.macro))return[{label:"DT_NODELABEL(...)",insertText:"DT_NODELABEL($1)",kind:al.CompletionItemKind.Function,insertTextFormat:al.InsertTextFormat.Snippet}];let n=await e.getRuntime();return t.parent?.macro!=="DT_NODELABEL"||t.argIndexInParent!==0?[]:await Promise.all(n.rootNode.allDescendantsLabels.map(async r=>({label:r.label.value,kind:al.CompletionItemKind.Property,documentation:r.lastLinkedTo?.toMarkupContent(n.context.macros)}))??[])}var cl=q(j());async function GD({macro:t,context:e}){return t.macro&&t.macro&&"DT_PATH".startsWith(t.macro)?[{label:"DT_PATH(...)",insertText:"DT_PATH($1)",kind:cl.CompletionItemKind.Function,insertTextFormat:cl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_PATH"||!t.parent.args?.length?[]:(await Sp(t.parent.args.slice(0,-1).map(r=>r.macro),e))?.nodes.map(r=>({label:Z(r.fullName),kind:cl.CompletionItemKind.Class,documentation:r.toMarkupContent(e.macros)}))??[]}var KD=q(j());async function YD({macro:t,context:e}){if(t.macro&&t.macro&&"DT_ROOT".startsWith(t.macro)){let n=await e.getRuntime();return[{label:"DT_ROOT",kind:KD.CompletionItemKind.Class,documentation:n.rootNode.toMarkupContent(n.context.macros)}]}return[]}var Bp=q(j());function XD({macro:t}){return t.macro&&t.macro&&"DT_SAME_NODE".startsWith(t.macro)?[{label:"DT_SAME_NODE(...)",insertText:"DT_SAME_NODE($1, $2)",kind:Bp.CompletionItemKind.Snippet,insertTextFormat:Bp.InsertTextFormat.Snippet}]:[]}var ll=q(j());async function J({macro:t,document:e,position:n,context:r},i,s,o,a,c=l=>x({document:e,macro:l,context:r,position:n})){if(t.macro&&t.macro&&i.startsWith(t.macro))return[{label:`${i}(...)`,insertText:`${i}(${Array(o).map((d,f)=>`${f+1}`).join(", ")})`,kind:ll.CompletionItemKind.Function,insertTextFormat:ll.InsertTextFormat.Snippet}];if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let l=await c(t.parent.args[0]);return(a?l?.properties.filter(a):l?.properties)?.map(d=>({label:Z(d.name),kind:ll.CompletionItemKind.Property,documentation:d.toPrettyString(r.macros)}))??[]}async function JD(t){return J(t,"DT_ENUM_HAS_VALUE",1,3)}async function QD(t){return J(t,"DT_ENUM_HAS_VALUE_BY_IDX",1,4)}async function ZD(t){return J(t,"DT_ENUM_IDX",1,2)}async function eA(t){return J(t,"DT_ENUM_IDX_BY_IDX",1,3)}async function tA(t){return J(t,"DT_ENUM_IDX_BY_IDX_OR",1,4)}async function nA(t){return J(t,"DT_ENUM_IDX_OR",1,3)}var rA=q(j());async function ji({macro:t,document:e,context:n,position:r},i,s,o){if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let c=(await x({document:e,macro:t.parent.args[0],context:n,position:r}))?.properties.find(f=>Z(f.name)===t.parent?.args?.at(1)?.macro),l=0;if(typeof o=="string"){let f=c?.nexusMapsTo.at(0)?.specifierSpace;if(l=(f?c.parent.getProperty(`${f}-names`)?.ast.quickValues:void 0)?.findIndex(m=>typeof m=="string"&&m.toLowerCase()===o)??-1,l===-1)return[]}let u=c?.nexusMapsTo.at(l);return u?.target.nodeType?.cellsValues?.find(f=>u.specifierSpace&&f.specifier===u.specifierSpace)?.values.map(f=>({label:Z(f),kind:rA.CompletionItemKind.Property}))??[]}async function iA(t){return t.macro.argIndexInParent===2?ji(t,"DT_PHA",2,0):J(t,"DT_PHA",1,3,e=>!!e.nexusMapsTo.length)}var sA=q(j());async function oH({document:t,macro:e,position:n,context:r},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await x({document:t,macro:e.parent.args[0],context:r,position:n}))?.properties.find(a=>Z(a.name)===e.parent?.args?.at(1)?.macro);return Array(o?.nexusMapsTo.length??0)?.map((a,c)=>({label:c.toString(),kind:sA.CompletionItemKind.Property}))??[]}async function oA(t){if(t.macro.argIndexInParent===2)return oH(t,"DT_PHA_BY_IDX");if(t.macro.argIndexInParent===3){let e=t.macro.parent?.args?De(t.macro.parent.args[2].macro):void 0;return typeof e!="number"?[]:ji(t,"DT_PHA_BY_IDX",3,e)}return J(t,"DT_PHA_BY_IDX",1,3,e=>!!e.nexusMapsTo.length)}var aA=q(j());async function ul({document:t,macro:e,context:n,position:r},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await x({document:t,macro:e.parent.args[0],context:n,position:r}))?.properties.find(l=>Z(l.name)===e.parent?.args?.at(1)?.macro),a=o?.nexusMapsTo.at(0)?.specifierSpace;return(a?o.parent.getProperty(`${a}-names`)?.ast.quickValues:void 0)?.filter(l=>typeof l=="string")?.map(l=>({label:l,kind:aA.CompletionItemKind.Property}))??[]}async function cA(t){let{macro:e}=t;return e.argIndexInParent===2?ul(t,"DT_PHA_BY_NAME"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?ji(t,"DT_PHA_BY_NAME",3,e.parent.args[2].macro):[]:J(t,"DT_PHA_BY_NAME",1,3,n=>!!n.nexusMapsTo.length)}async function lA(t){let{macro:e}=t;return e.argIndexInParent===2?ul(t,"DT_PHA_BY_NAME_OR"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?ji(t,"DT_PHA_BY_NAME_OR",3,e.parent.args[2].macro):[]:J(t,"DT_PHA_BY_NAME_OR",1,3,n=>!!n.nexusMapsTo.length)}async function uA(t){let{macro:e}=t;return e.argIndexInParent===2?ji(t,"DT_PHA_OR",2,0):J(t,"DT_PHA_OR",1,3,n=>!!n.nexusMapsTo.length)}async function jp(t){return J(t,"DT_PHANDLE",1,2,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof ie||n instanceof ot))}async function Ea(t){return J(t,"DT_PHANDLE_BY_IDX",1,3,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof ie||n instanceof ot))}async function dA(t){let{macro:e}=t;return e.argIndexInParent===2?ul(t,"DT_PHANDLE_BY_NAME"):J(t,"DT_PHANDLE_BY_NAME",1,3,n=>!!n.ast.getFlatAstValues()?.some(r=>r instanceof ie||r instanceof ot))}async function fA(t){return J(t,"DT_PROP",1,2,e=>!e.nexusMapsTo.length)}async function pA(t){return J(t,"DT_PROP_BY_IDX",1,3,e=>!e.nexusMapsTo.length)}async function hA(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX"?Ea({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):J(t,"DT_PROP_BY_PHANDLE_IDX",3,4,n=>!n.nexusMapsTo.length,()=>vi({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function mA(t){let{macro:e}=t;return e.argIndexInParent===1&&e.parent?.macro==="DT_PROP_BY_PHANDLE"?jp({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE"}:void 0}}):J(t,"DT_PROP_BY_PHANDLE",2,3,n=>!n.nexusMapsTo.length,()=>gs({...t,macro:{macro:"DT_PHANDLE",args:e.parent?.args?.slice(0,2)}},x))}async function gA(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX_OR"?Ea({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):J(t,"DT_PROP_BY_PHANDLE_IDX_OR",3,5,n=>!n.nexusMapsTo.length,()=>vi({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function yA(t){return J(t,"DT_PROP_HAS_IDX",1,3,e=>!e.nexusMapsTo.length)}async function TA(t){return J(t,"DT_PROP_HAS_NAME",1,3,e=>!e.nexusMapsTo.length)}async function vA(t){return J(t,"DT_PROP_LAST",1,2,e=>!e.nexusMapsTo.length)}async function bA(t){return J(t,"DT_PROP_LEN",1,2,e=>!e.nexusMapsTo.length)}async function _A(t){return J(t,"DT_PROP_LEN_OR",1,2,e=>!e.nexusMapsTo.length)}async function SA(t){return J(t,"DT_PROP_OR",1,2,e=>!e.nexusMapsTo.length)}async function kA(t){return J(t,"DT_STRING_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function PA(t){return J(t,"DT_STRING_TOKEN_BY_IDX",1,3,e=>{let n=e.ast.getFlatAstValues();return!!n?.length&&n.every(r=>r instanceof re)})}async function NA(t){return J(t,"DT_STRING_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function RA(t){return J(t,"DT_STRING_UNQUOTED",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function wA(t){return J(t,"DT_STRING_UNQUOTED_BY_IDX",1,3,e=>{let n=e.ast.getFlatAstValues();return!!n?.length&&n.every(r=>r instanceof re)})}async function EA(t){return J(t,"DT_STRING_UNQUOTED_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function CA(t){return J(t,"DT_STRING_UPPER_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}async function DA(t){return J(t,"DT_STRING_UPPER_TOKEN_BY_IDX",1,3,e=>{let n=e.ast.getFlatAstValues();return!!n?.length&&n.every(r=>r instanceof re)})}async function AA(t){return J(t,"DT_STRING_UPPER_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof re})}var dl=q(j());async function IA({macro:t,context:e}){return t.parent?.macro==="DT_ON_BUS"&&t.argIndexInParent===1?e.bindingLoader?.getBusTypes().map(n=>({label:Z(n),kind:dl.CompletionItemKind.Enum}))??[]:t.macro&&"DT_ON_BUS".startsWith(t.macro)?[{label:"DT_ON_BUS(...)",insertText:"DT_ON_BUS($1, $2)",kind:dl.CompletionItemKind.Function,insertTextFormat:dl.InsertTextFormat.Snippet}]:[]}async function OA(t){return J(t,"DT_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}async function MA(t){return J(t,"DT_HAS_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}var aH=["DT_BUS","DT_CHILD_NUM","DT_CHILD_NUM_STATUS_OKAY","DT_GPARENT","DT_HAS_ALIAS","DT_NODE_CHILD_IDX","DT_NODE_FULL_NAME","DT_NODE_FULL_NAME_TOKEN","DT_NODE_FULL_NAME_UNQUOTED","DT_NODE_FULL_NAME_UPPER_TOKEN","DT_NODE_HASH","DT_NODE_PATH","DT_NODELABEL_STRING_ARRAY","DT_PARENT"];async function xA(t,e,n){if(!n)return[];let r=Bi(n,t.position);return r?(await Promise.all([IA,OA,MA,PD,HD,VD,WD,cH,zD,GD,YD,XD,QD,JD,eA,tA,ZD,nA,oA,cA,lA,iA,Ea,dA,jp,uA,pA,mA,hA,gA,fA,yA,TA,vA,bA,_A,SA,kA,PA,NA,RA,wA,EA,CA,DA,AA].flatMap(async i=>await i({document:n,context:e,macro:r,position:t.position})))).flat():[]}function cH({macro:t}){return t.macro?aH.filter(e=>e.startsWith(t.macro)).map(e=>({label:`${e}(...)`,insertText:`${e}($1)`,kind:Up.CompletionItemKind.Function,insertTextFormat:Up.InsertTextFormat.Snippet})):[]}var Nr=q(j());function lH(t){if(!t||t.item===null||!(t.ast instanceof Ye))return[];let e=r=>r.replacedBy?e(r.replacedBy):r,n=r=>{let i=r.parent.deletedProperties.find(s=>s.property===r)?.by;return[r.ast,...r.allReplaced.map(s=>s.ast),...i?[i]:[]].map(s=>{let o=zn(s.fsPath);if(o)return Nr.Location.create(ue(o.docFsPath),o.range);if(s instanceof je)return Nr.Location.create(ue(s.fsPath),ce(s.propertyName??s));if(s instanceof yt)return Nr.Location.create(ue(s.fsPath),ce(s.propertyName??s))}).filter(s=>s)};if(t.item instanceof Xe&&t.ast instanceof Ye)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function uH(t){if(!t)return[];let e=n=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"&&t.runtime.rootNode.getChild(a[0].split("/"))===n)return!0}).map(o=>o.ast)??[],s=n.parent?.deletedNodes.filter(o=>o.node===n&&(o.by.nodeNameOrRef instanceof xe?o.by.nodeNameOrRef!==t.ast:!n.linkedRefLabels.some(a=>a!==t.ast))).map(o=>o.by.nodeNameOrRef)??[];return[...i,...n.linkedRefLabels,...n.linkedNodeNamePaths,...n.definitions,...s].map(o=>{let a=o&&zn(o?.fsPath);if(a)return Nr.Location.create(ue(a.docFsPath),a.range);if(o instanceof Tt)return Nr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof He)return Nr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof xe)return Nr.Location.create(ue(o.fsPath),ce(o));if(o instanceof xe)return Nr.Location.create(ue(o.fsPath),ce(o));if(o instanceof ie)return Nr.Location.create(ue(o.fsPath),ce(o.label??o));if(o instanceof je)return Nr.Location.create(ue((o.values??o)?.fsPath),ce(o.values??o))}).filter(o=>o)};if(t.item instanceof X&&!Kt(t.ast))return e(t.item);if(t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo)return e(t.ast.parentNode.linksTo);if(t.ast instanceof xe&&t.ast.linksTo)return Kt(t.ast)?[...e(t.ast.linksTo),Nr.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo);if(t?.ast instanceof re&&t.item instanceof Xe&&t.item.parent.name==="aliases"){let n=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(n)return e(n)}return[]}async function LA(t,e){return Nt(t,e,n=>[...uH(n),...lH(n)])}var Ui=q(j());function qA(t){if(!t||t.item===null||!(t.ast instanceof Ye))return[];let e=r=>r.replacedBy?e(r.replacedBy):r,n=r=>[r.ast,...r.allReplaced.map(i=>i.ast),r.parent.deletedProperties.find(i=>i.property===r)?.by??[]].map(i=>{if((i instanceof je||i instanceof yt)&&i.propertyName)return Ui.Location.create(ue(i.fsPath),ce(i.propertyName))}).filter(i=>i);if(t.item instanceof Xe&&t.ast instanceof Ye)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function $A(t,e){if(!e||!(e.ast instanceof un))return[];"newName"in t&&(e.ast.parentNode instanceof ie&&t.newName.startsWith("&")?t.newName=t.newName.slice(1):e.ast.parentNode instanceof ps&&t.newName.endsWith(":")&&(t.newName=t.newName.slice(0,-1)));let n=e.ast.value,r=i=>[...i.implementations.filter(s=>s instanceof He||s instanceof Et).flatMap(s=>s.labels.map(o=>o.label)),...i.linkedRefLabels.map(s=>s.label)].filter(s=>s?.value===n).map(s=>{if(s)return Ui.Location.create(ue(s.fsPath),ce(s))}).filter(s=>s);return e.item instanceof X&&!Kt(e.ast)?r(e.item):e.ast instanceof un&&e.ast.parentNode instanceof ie&&e.ast.parentNode.linksTo?r(e.ast.parentNode.linksTo):[]}function FA(t){if(!t||!(t.ast instanceof xe)||t.ast instanceof xe&&t.ast.linksTo===t.runtime.rootNode)return[];let e=n=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"){let c=t.runtime.rootNode.getChild(a[0].split("/"));if(c?.isChildOf(n)||c===n)return!0}}).map(o=>o.ast)??[],s=n.parent?.deletedNodes.filter(o=>o.node===n&&o.by.nodeNameOrRef!==t.ast).map(o=>o.by.nodeNameOrRef)??[];return[...i,...n.linkedNodeNamePaths,...n.definitions,...s].map(o=>{if(o instanceof He&&o.name)return Ui.Location.create(ue(o.fsPath),ce(o.name));if(o instanceof xe)return Ui.Location.create(ue(o.fsPath),ce(o));if(o instanceof je&&o.values?.values[0]?.value&&o.values?.values[0]?.value instanceof re){let a=o.values.values[0].value,c=ce(a),l=a.value.split("/"),u=n.path,d=l.slice(0,u.length-1).join("/").length+1,f=a.value.length-l.slice(0,u.length).join("/").length;return c.start.character+=1+d,c.end.character-=1+f,Ui.Location.create(ue(o.values.values[0].fsPath),c)}}).filter(o=>o)};return t.item instanceof X&&!Kt(t.ast)?e(t.item):t.ast instanceof xe&&t.ast.linksTo?Kt(t.ast)?[...e(t.ast.linksTo),Ui.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo):[]}async function BA(t,e){let n={};return(await Nt(t,e,i=>[...FA(i),...$A(t,i),...qA(i)])).forEach(i=>{n[i.uri]??=[],n[i.uri].push(Ui.TextEdit.replace(i.range,t.newName))}),{changes:n}}async function jA(t,e){let n=await Nt(t,e,r=>[...FA(r),...$A(t,r),...qA(r)]);if(n.some(r=>e?.settings.lockRenameEdits?.some(i=>Se(r.uri).startsWith(i))))throw new Error('Path is locked by user setting "lockRenameEdits"');if(n.some(r=>ro(r.uri)))throw new Error("Item was generated using a MACRO.");return{defaultBehavior:!!n.length}}var Da=q(j());var Ca=t=>t.implementations.map(e=>{let n=zn(e.fsPath);return n?Da.Location.create(ue(n.docFsPath),n.range):Da.Location.create(ue(e.fsPath),ce(e))}).filter(e=>e),UA=t=>t.replacedBy?UA(t.replacedBy):t,Hp=t=>[t.ast,...t.allReplaced.map(e=>e.ast)].map(e=>{let n=zn(e.fsPath);return n?Da.Location.create(ue(n.docFsPath),n.range):Da.Location.create(ue(e.fsPath),ce(e.propertyName??e))}).filter(e=>e);function dH(t){if(!t||t.item===null||!(t.ast instanceof Ye))return[];if(t.item instanceof Xe&&t.ast instanceof Ye)return Hp(UA(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let e=t.item.deletedProperties.find(n=>n.by===t.ast.parentNode)?.property;if(e)return Hp(e)}return[]}function fH(t){if(!t)return[];if(t.item instanceof X&&!Kt(t.ast))return Ca(t.item);if(t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo)return Ca(t.ast.parentNode.linksTo);if(t.ast instanceof xe&&t.ast.linksTo)return Ca(t.ast.linksTo);if(t?.ast instanceof re&&t.item instanceof Xe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Ca(e)}return[]}function pH(t){if(t?.ast instanceof pt||t?.ast instanceof hi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof pt?t.ast.name:t.ast.value);if(e)return[Da.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))]}return[]}async function HA(t,e){return Nt(t,e,n=>[...fH(n),...dH(n),...pH(n)])}var hH=["DT_PROP","DT_PROP_LEN","DT_PROP_LEN_OR","DT_PROP_HAS_IDX","DT_PROP_HAS_NAME","DT_PROP_BY_IDX","DT_PROP_LAST","DT_PROP_OR","DT_ENUM_IDX_BY_IDX","DT_ENUM_IDX","DT_ENUM_IDX_BY_IDX_OR","DT_ENUM_IDX_OR","DT_ENUM_HAS_VALUE_BY_IDX","DT_ENUM_HAS_VALUE","DT_STRING_TOKEN","DT_STRING_TOKEN_OR","DT_STRING_UPPER_TOKEN","DT_STRING_UPPER_TOKEN_OR","DT_STRING_UNQUOTED","DT_STRING_UNQUOTED_OR","DT_STRING_TOKEN_BY_IDX","DT_STRING_UPPER_TOKEN_BY_IDX","DT_STRING_UNQUOTED_BY_IDX","DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR","DT_PROP_BY_PHANDLE","DT_PHA_BY_IDX","DT_PHA_BY_IDX_OR","DT_PHA","DT_PHA_OR","DT_PHA_BY_NAME","DT_PHA_BY_NAME_OR","DT_PHANDLE_BY_NAME","DT_PHANDLE_BY_IDX","DT_PHANDLE"];async function Vp({macro:t,document:e,context:n,position:r}){if(hH.some(i=>i===t.parent?.macro)&&t.argIndexInParent===1&&t.parent?.args?.[0])return(await x({document:e,context:n,position:r,macro:t.parent.args[0]}))?.properties.find(s=>Z(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===2&&t.parent?.args?.[0]&&t.parent?.args?.[1])return(await gs({document:e,context:n,position:r,macro:{macro:"DT_PHANDLE",args:t.parent.args.slice(0,2)}},x))?.properties.find(s=>Z(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===3&&t.parent?.args?.[0]&&t.parent?.args?.[1]&&t.parent?.args?.[3])return(await vi({document:e,context:n,position:r,macro:{macro:"DT_PHANDLE_BY_IDX",args:t.parent.args.slice(0,3)}},x))?.properties.find(s=>Z(s.name)===t.macro);if(["DT_CHOSEN","DT_HAS_CHOSEN"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===0&&t.parent?.args?.[0])return(await n.getRuntime()).rootNode.getChild(["/","chosen"])?.properties.find(i=>Z(i.name)===t.macro)}async function VA(t,e,n){if(!n)return;let r=Bi(n,t.position);return WA(r,t.position,e,n)}async function WA(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Ca(i);let s=await Vp({document:r,macro:t,context:n,position:e});if(s)return Hp(s);let o=await hs(r,t.macro,e,n);if(o)return WA(o[0],o[1],n,r)}var ys=q(j());var Aa=t=>{let e=t.definitions.at(0),n=e&&zn(e.fsPath);return n?ys.Location.create(ue(n.docFsPath),n.range):e?ys.Location.create(ue(e.fsPath),ce(e)):void 0},Wp=t=>t.replaces?Wp(t.replaces):t,zA=t=>{let e=Wp(t),n=zn(e.ast.fsPath);return n?ys.Location.create(ue(n.docFsPath),n.range):e?ys.Location.create(ue(e.ast.fsPath),ce(e.ast)):void 0};function mH(t){if(!t||t.item===null||!(t.ast instanceof Ye))return;let e=n=>{let r=zn(n.ast.fsPath);return r?ys.Location.create(ue(r.docFsPath),r.range):ys.Location.create(ue(n.ast.fsPath),ce(n.ast.propertyName??n.ast))};if(t.item instanceof Xe&&t.ast instanceof Ye)return e(Wp(t.item));if(t.item instanceof X&&t.ast instanceof Ye&&t.ast.parentNode instanceof yt){let n=t.item.deletedProperties.find(r=>r.by===t.ast.parentNode)?.property;if(n)return e(Wp(n))}}function gH(t){if(t){if(t.item instanceof X&&!Kt(t.ast))return Aa(t.item);if(t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo)return Aa(t.ast.parentNode.linksTo);if(t.ast instanceof xe&&t.ast.linksTo)return Aa(t.ast.linksTo);if(t?.ast instanceof re&&t.item instanceof Xe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Aa(e)}}}function yH(t){if(t?.ast instanceof pt||t?.ast instanceof hi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof pt?t.ast.name:t.ast.value);if(e)return ys.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))}}async function GA(t,e){return(await Nt(t,e,n=>[gH(n)||mH(n)||yH(n)])).at(0)}async function KA(t,e,n){if(!n)return;let r=Bi(n,t.position);return YA(r,t.position,e,n)}async function YA(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Aa(i);let s=await Vp({document:r,macro:t,context:n,position:e});if(s)return zA(s);let o=await hs(r,t.macro,e,n);if(o)return YA(o[0],o[1],n,r)}var fe=q(j());var TH=(t,e,n,r,i)=>{switch(n){case 1:return[{title:"Add semicolon",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),";")]}}}];case 2:return[{title:"Add open curly",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character)," {")]}}}];case 29:return[{title:"Remove white space",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(fe.Range.create(fe.Position.create(r.range.start.line,t.pos.colEnd),fe.Position.create(r.range.end.line,e.pos.col)),"")]}}}];case 3:return[{title:"Add close curly",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),"}")]}}}];case 19:return[{title:"Add '/'",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),"/")]}}}];case 28:return[{title:"Add comma",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),",")]}}}];case 21:return[{title:"Add '/'",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),"/")]}}}];case 23:return[{title:"Remove ';'",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.del(r.range)]}}}];case 34:return[{title:"Complete Keyword '/delete-node/",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-node/")]}}}];case 35:return[{title:"Complete Keyword '/delete-property/",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-property/")]}}}];case 25:return[{title:"Complete Keyword '/delete-property/",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-property/")]}}},{title:"Complete Keyword '/delete-node/",diagnostics:[r],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.replace(r.range,"/delete-node/")]}}}];case 12:return[{title:"Add '>'",diagnostics:[r],kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[fe.TextEdit.insert(fe.Position.create(r.range.end.line,r.range.end.character),">")]}}}];default:return}},vH=(t,e,n,r,i)=>{if(!r?.length)return[];switch(t){case 0:return[{title:i??`Add Property "${r[0].newText.split("=",1)[0].replace(";","").trim()}"`,diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 27:return[{title:i??"Remove Property",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 26:return[{title:i??"TODO",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 36:return[{title:i??"TODO",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 25:return r?[{title:i??"TODO",diagnostics:[e],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}]:[];default:return}},bH=(t,e,n,r)=>n?.length?[{title:r??"TODO",diagnostics:[t],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[e]:n}}}]:[];function XA(t){let e=t.context.diagnostics.flatMap(a=>{let c=a.data;if(c?.virtual)return[];switch(c?.type){case"FormattingIssues":return bH(a,t.textDocument.uri,c.edit?Array.isArray(c.edit)?c.edit:[c.edit]:void 0,c.codeActionTitle);case"SyntaxIssue":return c?.items.flatMap(l=>TH(c.firstToken,c.lastToken,l,a,t.textDocument.uri));case"StandardTypeIssue":return c?.items.flatMap(l=>vH(l,a,t.textDocument.uri,c.edit?Array.isArray(c.edit)?c.edit:[c.edit]:void 0,c.codeActionTitle))}}).filter(a=>!!a),n=e.filter(a=>a.kind===fe.CodeActionKind.SourceFixAll),r=e.filter(a=>a.title.startsWith("Add Property")),i=e.filter(a=>a.kind!==fe.CodeActionKind.SourceFixAll),s=n.flatMap(a=>a.edit?.changes?.[t.textDocument.uri]??[]),o=new Map;return r.forEach(a=>{let c=a.edit.changes[t.textDocument.uri][0],l=c.range.start.line,u=c.range.start.character;o.has(`${l}:${u}`)||o.set(`${l}:${u}`,[]),o.get(`${l}:${u}`)?.push(c)}),[...i,...n.map(a=>({...a,kind:fe.CodeActionKind.QuickFix})),...s.length?[{title:"Fix All",kind:fe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:s}}}]:[],...Array.from(o.values()).flatMap(a=>a.length>1?{title:"Add All Missing Properties",kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:a}}}:[])]}var ee=q(j());function JA(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}var QA=(t,e)=>e.some(n=>JA(t,n.start)>=0&&JA(t,n.end)<=0),_H=async(t,e,n)=>{let r=en.create(t.pos.line,t.pos.col),i=n.find(s=>Cn(s,e,r));if(i)return zr(i,e,r)},uo=(t,e)=>{let n=en.create(e.length-1,e.at(-1)?.length??0),r=[],i;return t.filter(o=>(o instanceof cr||o instanceof lr)&&/^dts-format (on|off)$/.test(o.toString().trim())).sort((o,a)=>o.firstToken.pos.line-a.firstToken.pos.line).forEach(o=>{let a=o.toString().trim();if(a==="dts-format off")i={start:en.create(o.firstToken.pos.line,o instanceof cr?o.firstToken.pos.colEnd:0)};else if(a==="dts-format on"&&i){let c=en.create(o.lastToken.pos.line,o instanceof cr?o.lastToken.pos.colEnd-1:e[o.lastToken.pos.line-1].length);r.push(Qe.create(i.start,c)),i=void 0}}),i&&r.push(Qe.create(i.start,n)),r},fo=(t,e,n)=>{let r=t.length?n.filter(i=>(Array.isArray(i.raw.edit)?i.raw.edit:i.raw.edit?[i.raw.edit]:void 0)?.every(o=>!QA(o.range.start,t)&&!QA(o.range.end,t))):n;return"range"in e&&(r=r.filter(i=>Mf(e.range,i.raw.range))),r},Ia=(t,e)=>async n=>{let r=t.filter(a=>!(a instanceof kr)&&!(a instanceof lr)&&!(a instanceof cr)&&!(a instanceof Xr)&&!(a instanceof Pr)),i=await _H(n.firstToken,e,r);if(!i||i===n||n.allDescendants.some(a=>a===i))return{level:0};let s=$f(i);return{level:so(e,s),inAst:i}},In=(t,e)=>{if(t.insertSpaces)return"".padStart(e," ");let n=Math.floor(e/t.tabSize),r=e%t.tabSize;return`${"".padStart(n," ")}${"".padStart(r," ")}`},Rr=(t,e,n="")=>`${"".padStart(t*e.length,e)}${n}`,ZA=t=>{let e=t.parentNode;if(!(!e||!(e instanceof ge)))return!(e instanceof Qt)||!e.openBracket?ZA(e):e};function po(t,e,n,r,i,s,o=!1){if(!o&&ln(e.firstToken,t.firstToken))return r[e.firstToken.pos.line].slice(0,e.firstToken.pos.col).replace(/^\s+/,f=>f.replace(/\t/g," ".repeat(n.tabSize))).length-n.tabSize*i;let a=ZA(e);if(!a)return s;let l=po(t,a,n,r,i,s);return!o&&ln(e.firstToken,a.firstToken)?l+=e.firstToken.pos.col-a.firstToken.pos.col:a instanceof Qt&&a.openBracket&&++l,l}var Mt=q(j());function Ts(t,e,n,r){if(!ln(t,e)){let o=e.prevToken;for(;t!==o;){if(o&&ln(t,o)&&Ts(t,o,n,r))return!0;o=o?.prevToken}return null}return r[t.pos.line].slice(0,e.pos.colEnd).replace(/^\s+/,o=>o.replace(/\t/g," ".repeat(n.tabSize))).length>n.wordWrapColumn}async function fl(t,e,n,r,i,s,o=[]){let a=r.split(`
291
291
  `),c=uo(e,a),l=r;o.push(...await SH(t,e,n,a,s));let u=fo(c,t,o);switch(l=ds(Vn.create(n,"devicetree",0,r),u.flatMap(d=>d.raw.edit).filter(d=>!!d)),i){case"New Text":return l;case"File Diagnostics":return u}}async function SH(t,e,n,r,i){let s=Ia(e,n);return(await Promise.all(e.flatMap(async a=>await t0(t,a,n,s,r,i)))).flat()}var t0=async(t,e,n,r,i,s,o=0)=>{let a=t.options.tabSize,c=t.options.insertSpaces,l=c?" ".repeat(a):" ",u={tabSize:a,insertSpaces:c,singleIndent:l,wordWrapColumn:t.options.wordWrapColumn};return e instanceof Ue?kH(t,e,n,o,u,s,i,r):e instanceof je?NH(e,o,u,s,i,l):[]},kH=async(t,e,n,r,i,s,o,a)=>{let c=[];if(e instanceof He||e instanceof Et){let l=await PH(e.labels,r,i,o,i.singleIndent);if(l.length>0)c.push(...l);else{let u=e instanceof He?e.name:e.reference;u&&Ts(u.firstToken,e.openScope??u.lastToken,i,o)&&c.push(st(8,n,ae(u.firstToken,!1),{edit:[Mt.TextEdit.replace(Mt.Range.create(ae(u.firstToken.prevToken),ae(u.firstToken,!1)),`
292
292
  ${Rr(r,i.singleIndent)}`)],codeActionTitle:`Move ...${u.toString()}... to a new line`}))}}return c.push(...(await Promise.all(e.children.flatMap(l=>t0(t,l,n,a,o,s,r+1)))).flat()),c},PH=(t,e,n,r,i)=>{let s=t.findIndex(c=>Ts(c.firstToken,c.lastToken,n,r));if(s===-1)return[];let o=t[s],a=t.find((c,l)=>l>s&&c.firstToken.pos.line!==o.lastToken.pos.line);return[st(8,o.firstToken.fsPath,ae(o.firstToken,!1),{edit:[Mt.TextEdit.replace(Mt.Range.create(ae(o.firstToken.prevToken),ae(o.firstToken,!1)),`
293
293
  ${Rr(e,i)}`),...a?[Mt.TextEdit.replace(Mt.Range.create(ae(a.firstToken.prevToken),ae(a.firstToken,!1))," ")]:[]],codeActionTitle:`Move ...${o.toString()}... to a new line`})]},NH=(t,e,n,r,i,s)=>Ts(t.firstToken,t.lastToken,n,i)===!1?[]:t.values?RH(t,t.propertyName?.name.length??0,t.values,e,n,r,i,s,t.lastToken):[],RH=(t,e,n,r,i,s,o,a,c)=>{for(let[l,u]of n.values.entries()){if(!u)continue;let d=wH(e,u,n.values,l,r,i,s,o,a,l===n.values.length-1&&u.lastToken.nextToken===c?c:void 0);if(d)return d}return[]},zp=t=>t instanceof gt||t instanceof or&&t.openBracket?t.openBracket??t.firstToken:t.firstToken,wH=(t,e,n,r,i,s,o,a,c,l)=>{let u=e.nextValueSeparator??l??e.lastToken,d=Ts(e.firstToken,u,s,a);if(d===!1)return;if(d===null){let v=e.value;return v instanceof gt||v instanceof or?e0(e,t,v,i,s,o,a,c,u):v instanceof ge?Gp(e,t,v,i,s,o,a,c):[]}let f=a[e.firstToken.pos.line].substring(0,e.firstToken.pos.col),p=Math.trunc((t+3)/s.tabSize),m=(t+3)%s.tabSize,h=p+m+i,y=f.trimStart()!==""?i+t+3:h;if(e.firstToken.pos.col===y){let v=e.value;return v instanceof gt||v instanceof or?e0(e,t,v,i,s,o,a,c,u):v instanceof ge?Gp(e,t,v,i,s,o,a,c):void 0}let _=n.slice(r).find(v=>v?.firstToken.pos.line!==e.firstToken.pos.line);return[st(8,e.firstToken.fsPath,ae(e.firstToken,!1),{edit:[Mt.TextEdit.replace(Mt.Range.create(ae(e.firstToken.prevToken),ae(e.firstToken,!1)),`
@@ -301,7 +301,7 @@ ${Rr(r,a,In(i,H))}`),...O?[Mt.TextEdit.replace(Mt.Range.create(ae(O.expression.f
301
301
  `),u=uo(e,l),d=s;c.push(...await $H(t,e,n,r,i,l,a));let f=fo(u,t,c);switch(d=ds(Vn.create(i,"devicetree",0,s),f.flatMap(p=>p.raw.edit).filter(p=>!!p)),o){case"New Text":return d;case"File Diagnostics":return f;case"Both":return{text:d,diagnostic:f}}}async function $H(t,e,n,r,i,s,o){let a=Ia(e,i),c=(await Promise.all(e.flatMap(async u=>await o0(t,u,i,a,s,n,r,o)))).flat();if(t.options.insertFinalNewline&&s.at(-1)?.trim()!==""){let u=ee.TextEdit.insert(ee.Position.create(s.length,s[s.length-1].length),`
302
302
  `);c.push(st(4,i,ee.Position.create(s.length,0),{edit:u,codeActionTitle:"Insert new line"}))}if(t.options.trimFinalNewlines){let u=0;for(;s.at(-(1+u))?.trim()==="";)u++;if(u>1){let d=s.length-1,f=ee.TextEdit.del(ee.Range.create(ee.Position.create(s.length-u,0),ee.Position.create(d,0)));c.push(st(3,i,ee.Position.create(d,0),{edit:f,codeActionTitle:"Remove trailing EOF lines"}))}}let l=c.flatMap(u=>u.raw.edit).filter(u=>!!u);if(t.options.trimTrailingWhitespace){let u=FH(s,l,i);c.push(...u)}return c}var FH=(t,e,n)=>{let r=[];return t.forEach((i,s)=>{let o=i.endsWith("\r")?i.slice(0,-1):i,a=o.trimEnd();if(a.length!==o.length){let c=ee.Range.create(ee.Position.create(s,a.length),ee.Position.create(s,o.length));e.some(l=>dE(c,l.range))||r.push(st(2,n,c.start,{edit:ee.TextEdit.del(c),codeActionTitle:"Remove whitespace"},c.end))}}),r},Jp=(t,e=1,n=!1,r=t.prevToken)=>{if(r){let i=t.pos.line-r.pos.line,s=i-e;if(s&&(i!==2&&e!==0||e===0||n)){let o=ee.Position.create(r.pos.line,r.pos.colEnd),a=ee.Position.create(t.pos.line,e?0:t.pos.col),c=ee.TextEdit.replace(ee.Range.create(o,a),`
303
303
  `.repeat(e));return st(1,t.fsPath,o,{edit:c,codeActionTitle:s<0?"Insert new lines":"Remove unnecessary new lines",templateStrings:[e.toString()]},a)}}else if(t.pos.line){let i=ee.Position.create(0,0),s=ee.Position.create(t.pos.line,0),o=ee.TextEdit.del(ee.Range.create(i,s));return st(1,t.fsPath,i,{edit:o,codeActionTitle:"Remove unnecessary new lines",templateStrings:["0"]},s)}},r0=(t,e,n,r="",i=1)=>{let s=t.pos.line===t.prevToken?.pos.line;if(t.prevToken&&s){let o=ee.Position.create(t.prevToken.pos.line,t.prevToken.pos.colEnd),a=ee.Position.create(t.pos.line,t.pos.col),c=ee.TextEdit.replace(ee.Range.create(o,a),`${`
304
- `.repeat(i)}${"".padStart(e*n.length,n)}${r}`);return st(0,t.fsPath,o,{edit:c,codeActionTitle:"Move to new line"},a)}},VT=(t,e,n,r,i="")=>{let s=Rr(e,n,i),o=ee.Position.create(t.pos.line,0),a=ee.Position.create(t.pos.line,t.pos.col),c=ee.Range.create(o,a),l=ZH(r,c);if(s===l)return[];let u=ee.TextEdit.replace(c,s);return[st(5,t.fsPath,o,{edit:u,codeActionTitle:"Fix indentation",templateStrings:[s.replaceAll(" ","\xB7").replaceAll(" ","\u2192")]},a)]},Rt=(t,e,n=1,r=!1)=>{if(!t.nextToken)return[];if(t.nextToken?.pos.line!==t.pos.line){if(r)return[];let c=Jp(t.nextToken,0);if(!c)throw new Error("remove new LinesEdit must be defined");return n&&(c.raw.edit.newText=`${" ".repeat(n)}${c.raw.edit.newText}`),[c]}if(n===0){if(t.nextToken.pos.col===t.pos.colEnd)return[];let c=ee.Position.create(t.pos.line,t.pos.colEnd),l=ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),u=ee.TextEdit.del(ee.Range.create(c,l));return[st(1,t.fsPath,c,{edit:u,codeActionTitle:"Remove space(s)",templateStrings:["0"]},l)]}if(t.pos.colEnd===t.nextToken.pos.col){let c=ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),l=ee.TextEdit.insert(c," ".repeat(n));return[st(1,t.fsPath,c,{edit:l,codeActionTitle:"Insert Space(s)",templateStrings:[n.toString()]})]}let i=t.nextToken.pos.col-t.pos.colEnd;if(i===n&&e[t.pos.line].slice(t.pos.colEnd,t.nextToken.pos.col)===" ".repeat(n))return[];let s=ee.Position.create(t.pos.line,t.pos.colEnd),o=ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),a=ee.TextEdit.replace(ee.Range.create(s,o)," ".repeat(n));return[st(1,t.fsPath,s,{edit:a,codeActionTitle:i>n?"Remove space(s)":"Insert space(s)",templateStrings:[n.toString()]},o)]},hl=(t,e,n,r,i)=>t.slice(1).flatMap(s=>i&&s.firstToken.prevToken||s.firstToken.pos.line===s.firstToken.prevToken?.pos.line?Rt(s.firstToken.prevToken,e):On(s.firstToken,n,r,e,void 0,1,!0)),BH=async(t,e,n,r,i,s,o,a,c,l)=>{let u=[],d=e.topComment||e.firstToken.prevToken?.value==="{"&&!e.topComment?1:WT(e.firstToken,r);if(u.push(...On(e.firstToken,s,o,c,void 0,d,!0)),e instanceof He||e instanceof Et)if(u.push(...hl(e.labels,c,s,o,!1)),e instanceof He){e.name?.address?.length&&e.name.address.every(p=>p.toString()!=="")&&e.name.address.forEach(p=>{let m=c[p.firstToken.pos.line].slice(p.firstToken.pos.col,p.lastToken.pos.colEnd),h=m.toLowerCase(),y=h.match(/^(?:0x)?([0-9a-f]+)(?:ull)?$/i)?.at(1),_=[];h.startsWith("0x")&&_.push(10),h.endsWith("ull")&&_.push(11),y!==m&&_.push(9),y&&_.length&&u.push(st(_,p.fsPath,ae(p.firstToken,!1),{edit:ee.TextEdit.replace(ce(p),y),codeActionTitle:`Change to '${y}'`},ae(p.lastToken)))}),e.labels.length&&e.name&&(e.name.firstToken.pos.line!==e.name.firstToken.prevToken?.pos.line?u.push(...On(e.name.firstToken,s,o,c,void 0,1,!0)):u.push(...Rt(e.name.firstToken.prevToken,c)));let f=e.name&&e.openScope?Rt(e.name.lastToken,c):[];u.push(...f)}else{e.labels.length&&e.reference?.firstToken.prevToken&&u.push(...Rt(e.reference.firstToken.prevToken,c));let f=e.reference&&e.openScope?Rt(e.reference.lastToken,c):[];u.push(...f)}else e instanceof Tt&&e.firstToken.value==="/"&&e.openScope&&u.push(...Rt(e.firstToken,c,1));return u.push(...(await Promise.all(e.children.flatMap(f=>o0(t,f,i,l,c,n,r,a,s+1)))).flat()),e.closeScope&&(e.openScope&&e.closeScope.prevToken===e.openScope?u.push(...Rt(e.openScope,c,0)):u.push(...On(e.closeScope,s,o,c,void 0,1,!0))),e.lastToken.value===";"&&e.closeScope&&u.push(...Qp(e.closeScope,e.lastToken)),u},jH=(t,e,n,r,i,s,o)=>{let a=[];if(a.push(...hl(e.labels,o,n,r.singleIndent,!0)),e.labels.length&&e.value?.firstToken.prevToken&&a.push(...Rt(e.value.firstToken.prevToken,o)),e.value instanceof Zt){let c=o[e.value.firstToken.pos.line].slice(e.value.firstToken.pos.col,e.value.lastToken.pos.colEnd),l=c.toLowerCase();l!==c&&a.push(st(9,e.value.fsPath,ae(e.value.firstToken,!1),{edit:ee.TextEdit.replace(ce(e.value),l),codeActionTitle:`Change to '${l}'`},ae(e.value.lastToken)))}if(e.firstToken.prevToken)if(e.firstToken.pos.line!==e.firstToken.prevToken?.pos.line&&e.firstToken.prevToken!==s){let c=Jp(e.firstToken,1,!0);c&&a.push(c),a.push(...VT(e.firstToken,n,r.singleIndent,o,In(r,t+4)))}else a.push(...Rt(e.firstToken.prevToken,o,s&&e.firstToken.prevToken===s?0:1));return e.value instanceof ge&&a.push(...Xp(e.value,o,n,r,i,t+4)),a},UH=(t,e,n,r,i,s)=>{let o=[];return e instanceof gt||e instanceof or?e.openBracket&&e.openBracket?.nextToken===e.closeBracket?o.push(...Rt(e.openBracket,s,0)):(o.push(...e.values.flatMap(a=>jH(t,a,n,r,i,e.openBracket,s))),e.closeBracket?.prevToken&&(e.values.at(-1)?.lastToken===e.closeBracket?.prevToken||e.closeBracket?.prevToken.value==="/"&&e.closeBracket?.prevToken?.prevToken?.value==="*"?o.push(...Rt(e.closeBracket.prevToken,s,0)):o.push(...On(e.closeBracket,n,r.singleIndent,s,In(r,t+3),1,!0)))):e instanceof ge&&o.push(...Xp(e,s,n,r,i,t)),o},Xp=(t,e,n,r,i,s)=>t instanceof Ut?HH(t,e):t instanceof Qt?VH(t,e,n,r,i,s):[],HH=(t,e)=>{let n=[];return n.push(...Rt(t.functionName.lastToken,e,0)),t.lastToken.value===")"&&t.lastToken.prevToken&&n.push(...Rt(t.lastToken.prevToken,e,0)),n},VH=(t,e,n,r,i,s)=>{let o=[];if(t.openBracket&&t.openBracket.nextToken&&o.push(...Rt(t.openBracket,e,0)),o.push(...Xp(t.expression,e,n,r,i,s)),t.join?.forEach(a=>{a.operator.firstToken.prevToken&&o.push(...Rt(a.operator.firstToken.prevToken,e)),a.expression.firstToken.prevToken?.pos.line===a.expression.firstToken.pos.line?o.push(...Rt(a.expression.firstToken.prevToken,e)):o.push(...On(a.expression.firstToken,n,r.singleIndent,e,In(r,s),void 0,void 0,!i.runExpressionIndentationCheck)),o.push(...Xp(a.expression,e,n,r,i,s))}),!t.join?.length&&!(t.expression instanceof Qt)&&(t.expression instanceof Ut||t.expression instanceof pt)){let a=[];if(t.openBracket){let c=ee.Position.create(t.openBracket.pos.line,t.openBracket.pos.col),l=ee.Position.create(t.openBracket.pos.line,t.openBracket.pos.colEnd);a.push(ee.TextEdit.del(ee.Range.create(c,l)))}if(t.closeBracket){let c=ee.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.col),l=ee.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.colEnd);a.push(ee.TextEdit.del(ee.Range.create(c,l)))}o.push(st(7,t.fsPath,a[0].range.start,{edit:a,codeActionTitle:"Remove (...)"},a[a.length-1].range.end))}return t.closeBracket&&t.closeBracket.prevToken&&o.push(...Rt(t.closeBracket.prevToken,e,0)),o},WH=(t,e,n,r,i,s)=>{let o=[];return o.push(...hl(e.startLabels,s,n,r.singleIndent,!0)),o.push(...UH(t,e.value,n,r,i,s)),o.push(...hl(e.endLabels,s,n,r.singleIndent,!0)),o},zH=(t,e,n,r,i,s,o)=>{let a=[];return e.values.forEach((c,l)=>{if(!c)return[];let u=c.firstToken.prevToken,d=l?e.values.at(l-1):void 0;if(u)if(u.pos.line===c.firstToken.pos.line)if(u.value===","&&d?.lastToken.pos.line!==c.firstToken.pos.line&&u.prevToken?.pos.line!==c.firstToken.pos.line){let f=r0(c.firstToken,n,r.singleIndent,In(r,t+3));f&&a.push(f)}else a.push(...Rt(u,s,1));else if(o&&c.firstToken.prevToken===o)a.push(...Rt(o,s));else{let f=Jp(c.firstToken,1,!0);f&&a.push(f),a.push(...VT(c.firstToken,n,r.singleIndent,s,In(r,t+3)))}a.push(...WH(t,c,n,r,i,s)),c.nextValueSeparator&&a.push(...Qp(c.lastToken,c.nextValueSeparator))}),a},GH=(t,e,n,r,i)=>{let s=[],{force:o,newLines:a}=s0(t,t.firstToken);return s.push(...On(t.firstToken,e,n.singleIndent,i,void 0,a,o)),s.push(...hl(t.labels,i,e,n.singleIndent,!0)),t.labels.length&&t.propertyName?.firstToken.prevToken&&s.push(...Rt(t.propertyName.firstToken.prevToken,i)),t.values&&(t.propertyName&&s.push(...Rt(t.propertyName?.lastToken,i)),s.push(...zH(t.propertyName?.name.length??0,t.values,e,n,r,i,t.assignOperatorToken))),t.lastToken.value===";"&&s.push(...Qp(t.children[t.children.length-1].lastToken,t.lastToken)),s},On=(t,e,n,r,i,s,o,a=!0)=>{let c=[],l=r0(t,e,n,i,s);if(l)c.push(l);else{let u=Jp(t,s,o);u&&c.push(u),a&&c.push(...VT(t,e,n,r,i))}return c},Qp=(t,e)=>{if(t.pos.line===e.pos.line&&t.pos.colEnd+1===e.pos.colEnd)return[];if(t.nextToken===e){let s=ee.Position.create(t.pos.line,t.pos.colEnd),o=ee.Position.create(e.pos.line,e.pos.col),a=ee.TextEdit.del(ee.Range.create(s,o));return[st(1,t.fsPath,s,{edit:a,codeActionTitle:"Remove white space",templateStrings:["0"]},o)]}let n=ee.Position.create(t.pos.line,t.pos.colEnd),r=ee.Position.create(e.pos.line,e.pos.colEnd),i=[ee.TextEdit.insert(n,e.value),ee.TextEdit.del(ee.Range.create(ee.Position.create(e.prevToken?.pos.line??e.pos.line,e.prevToken?.pos.colEnd??e.pos.col),r))];return[st(6,t.fsPath,n,{edit:i,codeActionTitle:"Move token",templateStrings:[e.value]},r)]},KH=(t,e,n,r)=>{let i=[];i.push(...On(t.firstToken,e,n,r));let s=Rt(t.keyword.lastToken,r);return i.push(...s),t.lastToken.value===";"&&i.push(...Qp(t.children[t.children.length-1].lastToken,t.lastToken)),i},YH=(t,e,n,r)=>{if(!he(t.fsPath,e))return[];let i=[];i.push(...On(t.firstToken,0,n,r));let s=Rt(t.keyword.lastToken,r);return i.push(...s),i},XH=(t,e,n,r,i,s)=>t.comments.length===1&&t.firstToken.pos.line===t.firstToken.prevToken?.pos.line?[]:t.comments.flatMap((o,a)=>JH(o,t,e,n,r,i,a?a===t.comments.length-1?"last":"comment":"first",s)),i0=(t,e,n="")=>{let r=e?gT(e):void 0;if(!r)return n;let i=oo(e),s=r.propertyName?.name.length??0;return`${`${In(t,s+(i?4:3)+(n.length-n.trimStart().length))}`}${n.trimStart()}`},WT=(t,e)=>{let n=e.flatMap(r=>r instanceof Xr?[r.ifDef.identifier?.lastToken.nextToken,r.elseOption?.keyword.lastToken.nextToken]:[...r.ifBlocks.map(i=>i.expression?.lastToken.nextToken),r.elseOption?.lastToken.nextToken]).some(r=>r===t);return t.prevToken?.value==="{"||n?1:2},s0=(t,e)=>{let n=t.parentNode instanceof Ue?t.parentNode:void 0,r=n?.children.indexOf(t)??-1;if(r===0&&n?.openScope===e.prevToken)return{newLines:1,force:!0};let i=r>0&&n?.children[r-1];return i instanceof Ue&&t.firstToken.prevToken===(i.endComment??i).lastToken?{newLines:2,force:!0}:{newLines:void 0,force:void 0}},JH=(t,e,n,r,i,s,o,a)=>{if(!t.firstToken.prevToken)return On(t.firstToken,r?.level??0,i,s);if(t.firstToken.pos.line===t.firstToken.prevToken?.pos.line)return Rt(t.firstToken.prevToken,s,1);if(r===void 0)return[];let c,l;if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof Ue)c=!0,l=WT(e.firstToken,n);else if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof je){let{force:m,newLines:h}=s0(e.astAfterComment,e.firstToken);c=m,l=h}let u=e.astAfterComment instanceof kr?0:r.level,d=[],f="",p=t.toString();switch(o==="last"&&p.trim()!==""&&t.lastToken.prevToken&&(o="comment",d.push(...On(t.lastToken.prevToken,u,i,s," "))),o){case"comment":f=t.firstToken.value==="*"?" ":" * ";break;case"first":break;case"last":f=" ";break}return r?.inAst instanceof Ue?d.push(...On(t.firstToken,u,i,s,f,l,c)):d.push(...On(t.firstToken,u,i,s,i0(a,r?.inAst,f),l,c)),d},QH=(t,e,n,r,i,s)=>{if(!t.firstToken.prevToken)return On(t.firstToken,n?.level??0,r,i);if(t.firstToken.pos.line===t.firstToken.prevToken.pos.line)return[];let a,c;return!t.astBeforeComment&&t.astAfterComment instanceof Ue&&(a=!0,c=WT(t.firstToken,e)),On(t.firstToken,n?.level??0,r,i,i0(s,n?.inAst),c,a)},o0=async(t,e,n,r,i,s,o,a,c=0)=>{let l=t.options.tabSize,u=t.options.insertSpaces,d=u?" ".repeat(l):" ",f={tabSize:l,insertSpaces:u,singleIndent:d,wordWrapColumn:t.options.wordWrapColumn};return e instanceof Ue?BH(t,e,s,o,n,c,d,a,i,r):e instanceof je?GH(e,c,f,a,i):e instanceof En?KH(e,c,d,i):e instanceof kr?YH(e,n,d,i):e instanceof lr&&!e.disabled?QH(e,o,await r(e),d,i,f):e instanceof cr&&!e.disabled?XH(e,o,await r(e),d,i,f):[]};function ZH(t,e){let n=t[e.start.line],r=t[e.end.line];if(e.start.line===e.end.line)return n.substring(e.start.character,e.end.character);let i=t.slice(e.start.line+1,e.end.line);return[n.substring(e.start.character),...i,r.substring(0,e.end.character)].join(`
304
+ `.repeat(i)}${"".padStart(e*n.length,n)}${r}`);return st(0,t.fsPath,o,{edit:c,codeActionTitle:"Move to new line"},a)}},VT=(t,e,n,r,i="")=>{let s=Rr(e,n,i),o=ee.Position.create(t.pos.line,0),a=ee.Position.create(t.pos.line,t.pos.col),c=ee.Range.create(o,a),l=ZH(r,c);if(s===l)return[];let u=ee.TextEdit.replace(c,s);return[st(5,t.fsPath,o,{edit:u,codeActionTitle:"Fix indentation",templateStrings:[s.replaceAll(" ","\xB7").replaceAll(" ","\u2192")]},a)]},Rt=(t,e,n=1,r=!1)=>{if(!t.nextToken)return[];if(t.nextToken?.pos.line!==t.pos.line){if(r)return[];let c=Jp(t.nextToken,0);if(!c)throw new Error("remove new LinesEdit must be defined");return n&&(c.raw.edit.newText=`${" ".repeat(n)}${c.raw.edit.newText}`),[c]}if(n===0){if(t.nextToken.pos.col===t.pos.colEnd)return[];let c=ee.Position.create(t.pos.line,t.pos.colEnd),l=ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),u=ee.TextEdit.del(ee.Range.create(c,l));return[st(1,t.fsPath,c,{edit:u,codeActionTitle:"Remove space(s)",templateStrings:["0"]},l)]}if(t.pos.colEnd===t.nextToken.pos.col){let c=ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),l=ee.TextEdit.insert(c," ".repeat(n));return[st(1,t.fsPath,c,{edit:l,codeActionTitle:"Insert Space(s)",templateStrings:[n.toString()]})]}let i=t.nextToken.pos.col-t.pos.colEnd;if(i===n&&e[t.pos.line].slice(t.pos.colEnd,t.nextToken.pos.col)===" ".repeat(n))return[];let s=ee.Position.create(t.pos.line,t.pos.colEnd),o=ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),a=ee.TextEdit.replace(ee.Range.create(s,o)," ".repeat(n));return[st(1,t.fsPath,s,{edit:a,codeActionTitle:i>n?"Remove space(s)":"Insert space(s)",templateStrings:[n.toString()]},o)]},hl=(t,e,n,r,i)=>t.slice(1).flatMap(s=>i&&s.firstToken.prevToken||s.firstToken.pos.line===s.firstToken.prevToken?.pos.line?Rt(s.firstToken.prevToken,e):On(s.firstToken,n,r,e,void 0,1,!0)),BH=async(t,e,n,r,i,s,o,a,c,l)=>{let u=[],d=e.topComment||e.firstToken.prevToken?.value==="{"&&!e.topComment?1:WT(e.firstToken,r);if(u.push(...On(e.firstToken,s,o,c,void 0,d,!0)),e instanceof He||e instanceof Et)if(u.push(...hl(e.labels,c,s,o,!1)),e instanceof He){e.name?.address?.length&&e.name.address.every(p=>p.toString()!=="")&&e.name.address.forEach(p=>{let m=c[p.firstToken.pos.line].slice(p.firstToken.pos.col,p.lastToken.pos.colEnd),h=m.toLowerCase(),y=h.match(/^(?:0x)?([0-9a-f]+)(?:ull)?$/i)?.at(1),_=[];h.startsWith("0x")&&_.push(10),h.endsWith("ull")&&_.push(11),y!==m&&_.push(9),y&&_.length&&u.push(st(_,p.fsPath,ae(p.firstToken,!1),{edit:ee.TextEdit.replace(ce(p),y),codeActionTitle:`Change to '${y}'`},ae(p.lastToken)))}),e.labels.length&&e.name&&(e.name.firstToken.pos.line!==e.name.firstToken.prevToken?.pos.line?u.push(...On(e.name.firstToken,s,o,c,void 0,1,!0)):u.push(...Rt(e.name.firstToken.prevToken,c)));let f=e.name&&e.openScope?Rt(e.name.lastToken,c):[];u.push(...f)}else{e.labels.length&&e.reference?.firstToken.prevToken&&u.push(...Rt(e.reference.firstToken.prevToken,c));let f=e.reference&&e.openScope?Rt(e.reference.lastToken,c):[];u.push(...f)}else e instanceof Tt&&e.firstToken.value==="/"&&e.openScope&&u.push(...Rt(e.firstToken,c,1));return u.push(...(await Promise.all(e.children.flatMap(f=>o0(t,f,i,l,c,n,r,a,s+1)))).flat()),e.closeScope&&(e.openScope&&e.closeScope.prevToken===e.openScope?u.push(...Rt(e.openScope,c,0)):u.push(...On(e.closeScope,s,o,c,void 0,1,!0))),e.lastToken.value===";"&&e.closeScope&&u.push(...Qp(e.closeScope,e.lastToken)),u},jH=(t,e,n,r,i,s,o)=>{let a=[];if(a.push(...hl(e.labels,o,n,r.singleIndent,!0)),e.labels.length&&e.value?.firstToken.prevToken&&a.push(...Rt(e.value.firstToken.prevToken,o)),e.value instanceof Zt){let c=o[e.value.firstToken.pos.line].slice(e.value.firstToken.pos.col,e.value.lastToken.pos.colEnd),l=c.toLowerCase();l!==c&&a.push(st(9,e.value.fsPath,ae(e.value.firstToken,!1),{edit:ee.TextEdit.replace(ce(e.value),l),codeActionTitle:`Change to '${l}'`},ae(e.value.lastToken)))}if(e.firstToken.prevToken)if(e.firstToken.pos.line!==e.firstToken.prevToken?.pos.line&&e.firstToken.prevToken!==s){let c=Jp(e.firstToken,1,!0);c&&a.push(c),a.push(...VT(e.firstToken,n,r.singleIndent,o,In(r,t+4)))}else a.push(...Rt(e.firstToken.prevToken,o,s&&e.firstToken.prevToken===s?0:1));return e.value instanceof ge&&a.push(...Xp(e.value,o,n,r,i,t+4)),a},UH=(t,e,n,r,i,s)=>{let o=[];return e instanceof gt||e instanceof or?e.openBracket&&e.openBracket?.nextToken===e.closeBracket?o.push(...Rt(e.openBracket,s,0)):(o.push(...e.values.flatMap(a=>jH(t,a,n,r,i,e.openBracket,s))),e.closeBracket?.prevToken&&(e.values.at(-1)?.lastToken===e.closeBracket?.prevToken||e.closeBracket?.prevToken.value==="/"&&e.closeBracket?.prevToken?.prevToken?.value==="*"?o.push(...Rt(e.closeBracket.prevToken,s,0)):o.push(...On(e.closeBracket,n,r.singleIndent,s,In(r,t+3),1,!0)))):e instanceof ge&&o.push(...Xp(e,s,n,r,i,t)),o},Xp=(t,e,n,r,i,s)=>t instanceof Ut?HH(t,e):t instanceof Qt?VH(t,e,n,r,i,s):[],HH=(t,e)=>{let n=[];return n.push(...Rt(t.functionName.lastToken,e,0)),t.lastToken.value===")"&&t.lastToken.prevToken&&n.push(...Rt(t.lastToken.prevToken,e,0)),n},VH=(t,e,n,r,i,s)=>{let o=[];if(t.openBracket&&t.openBracket.nextToken&&o.push(...Rt(t.openBracket,e,0)),o.push(...Xp(t.expression,e,n,r,i,s)),t.join?.forEach(a=>{a.operator.firstToken.prevToken&&o.push(...Rt(a.operator.firstToken.prevToken,e)),a.expression.firstToken.prevToken?.pos.line===a.expression.firstToken.pos.line?o.push(...Rt(a.expression.firstToken.prevToken,e)):o.push(...On(a.expression.firstToken,n,r.singleIndent,e,In(r,s),void 0,void 0,!i.runExpressionIndentationCheck)),o.push(...Xp(a.expression,e,n,r,i,s))}),!t.join?.length&&!(t.expression instanceof Qt)&&(t.expression instanceof Ut||t.expression instanceof pt)){let a=[];if(t.openBracket){let c=ee.Position.create(t.openBracket.pos.line,t.openBracket.pos.col),l=ee.Position.create(t.openBracket.pos.line,t.openBracket.pos.colEnd);a.push(ee.TextEdit.del(ee.Range.create(c,l)))}if(t.closeBracket){let c=ee.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.col),l=ee.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.colEnd);a.push(ee.TextEdit.del(ee.Range.create(c,l)))}o.push(st(7,t.fsPath,a[0].range.start,{edit:a,codeActionTitle:"Remove (...)"},a[a.length-1].range.end))}return t.closeBracket&&t.closeBracket.prevToken&&o.push(...Rt(t.closeBracket.prevToken,e,0)),o},WH=(t,e,n,r,i,s)=>{let o=[];return o.push(...hl(e.startLabels,s,n,r.singleIndent,!0)),o.push(...UH(t,e.value,n,r,i,s)),o.push(...hl(e.endLabels,s,n,r.singleIndent,!0)),o},zH=(t,e,n,r,i,s,o)=>{let a=[];return e.values.forEach((c,l)=>{if(!c)return[];let u=c.firstToken.prevToken,d=l?e.values.at(l-1):void 0;if(u)if(u.pos.line===c.firstToken.pos.line)if(u.value===","&&d?.lastToken.pos.line!==c.firstToken.pos.line&&u.prevToken?.pos.line!==c.firstToken.pos.line){let f=r0(c.firstToken,n,r.singleIndent,In(r,t+3));f&&a.push(f)}else a.push(...Rt(u,s,1));else if(o&&c.firstToken.prevToken===o)a.push(...Rt(o,s));else{let f=Jp(c.firstToken,1,!0);f&&a.push(f),a.push(...VT(c.firstToken,n,r.singleIndent,s,In(r,t+3)))}a.push(...WH(t,c,n,r,i,s)),c.nextValueSeparator&&a.push(...Qp(c.lastToken,c.nextValueSeparator))}),a},GH=(t,e,n,r,i)=>{let s=[],{force:o,newLines:a}=s0(t,t.firstToken);return s.push(...On(t.firstToken,e,n.singleIndent,i,void 0,a,o)),s.push(...hl(t.labels,i,e,n.singleIndent,!0)),t.labels.length&&t.propertyName?.firstToken.prevToken&&s.push(...Rt(t.propertyName.firstToken.prevToken,i)),t.values&&(t.propertyName&&s.push(...Rt(t.propertyName?.lastToken,i)),s.push(...zH(t.propertyName?.name.length??0,t.values,e,n,r,i,t.assignOperatorToken))),t.lastToken.value===";"&&s.push(...Qp(t.children[t.children.length-1].lastToken,t.lastToken)),s},On=(t,e,n,r,i,s,o,a=!0)=>{let c=[],l=r0(t,e,n,i,s);if(l)c.push(l);else{let u=Jp(t,s,o);u&&c.push(u),a&&c.push(...VT(t,e,n,r,i))}return c},Qp=(t,e)=>{if(t.pos.line===e.pos.line&&t.pos.colEnd+1===e.pos.colEnd)return[];if(t.nextToken===e){let s=ee.Position.create(t.pos.line,t.pos.colEnd),o=ee.Position.create(e.pos.line,e.pos.col),a=ee.TextEdit.del(ee.Range.create(s,o));return[st(1,t.fsPath,s,{edit:a,codeActionTitle:"Remove white space",templateStrings:["0"]},o)]}let n=ee.Position.create(t.pos.line,t.pos.colEnd),r=ee.Position.create(e.pos.line,e.pos.colEnd),i=[ee.TextEdit.insert(n,e.value),ee.TextEdit.del(ee.Range.create(ee.Position.create(e.prevToken?.pos.line??e.pos.line,e.prevToken?.pos.colEnd??e.pos.col),r))];return[st(6,t.fsPath,n,{edit:i,codeActionTitle:"Move token",templateStrings:[e.value]},r)]},KH=(t,e,n,r)=>{let i=[];i.push(...On(t.firstToken,e,n,r));let s=Rt(t.keyword.lastToken,r);return i.push(...s),t.lastToken.value===";"&&i.push(...Qp(t.children[t.children.length-1].lastToken,t.lastToken)),i},YH=(t,e,n,r)=>{if(!pe(t.fsPath,e))return[];let i=[];i.push(...On(t.firstToken,0,n,r));let s=Rt(t.keyword.lastToken,r);return i.push(...s),i},XH=(t,e,n,r,i,s)=>t.comments.length===1&&t.firstToken.pos.line===t.firstToken.prevToken?.pos.line?[]:t.comments.flatMap((o,a)=>JH(o,t,e,n,r,i,a?a===t.comments.length-1?"last":"comment":"first",s)),i0=(t,e,n="")=>{let r=e?gT(e):void 0;if(!r)return n;let i=oo(e),s=r.propertyName?.name.length??0;return`${`${In(t,s+(i?4:3)+(n.length-n.trimStart().length))}`}${n.trimStart()}`},WT=(t,e)=>{let n=e.flatMap(r=>r instanceof Xr?[r.ifDef.identifier?.lastToken.nextToken,r.elseOption?.keyword.lastToken.nextToken]:[...r.ifBlocks.map(i=>i.expression?.lastToken.nextToken),r.elseOption?.lastToken.nextToken]).some(r=>r===t);return t.prevToken?.value==="{"||n?1:2},s0=(t,e)=>{let n=t.parentNode instanceof Ue?t.parentNode:void 0,r=n?.children.indexOf(t)??-1;if(r===0&&n?.openScope===e.prevToken)return{newLines:1,force:!0};let i=r>0&&n?.children[r-1];return i instanceof Ue&&t.firstToken.prevToken===(i.endComment??i).lastToken?{newLines:2,force:!0}:{newLines:void 0,force:void 0}},JH=(t,e,n,r,i,s,o,a)=>{if(!t.firstToken.prevToken)return On(t.firstToken,r?.level??0,i,s);if(t.firstToken.pos.line===t.firstToken.prevToken?.pos.line)return Rt(t.firstToken.prevToken,s,1);if(r===void 0)return[];let c,l;if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof Ue)c=!0,l=WT(e.firstToken,n);else if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof je){let{force:m,newLines:h}=s0(e.astAfterComment,e.firstToken);c=m,l=h}let u=e.astAfterComment instanceof kr?0:r.level,d=[],f="",p=t.toString();switch(o==="last"&&p.trim()!==""&&t.lastToken.prevToken&&(o="comment",d.push(...On(t.lastToken.prevToken,u,i,s," "))),o){case"comment":f=t.firstToken.value==="*"?" ":" * ";break;case"first":break;case"last":f=" ";break}return r?.inAst instanceof Ue?d.push(...On(t.firstToken,u,i,s,f,l,c)):d.push(...On(t.firstToken,u,i,s,i0(a,r?.inAst,f),l,c)),d},QH=(t,e,n,r,i,s)=>{if(!t.firstToken.prevToken)return On(t.firstToken,n?.level??0,r,i);if(t.firstToken.pos.line===t.firstToken.prevToken.pos.line)return[];let a,c;return!t.astBeforeComment&&t.astAfterComment instanceof Ue&&(a=!0,c=WT(t.firstToken,e)),On(t.firstToken,n?.level??0,r,i,i0(s,n?.inAst),c,a)},o0=async(t,e,n,r,i,s,o,a,c=0)=>{let l=t.options.tabSize,u=t.options.insertSpaces,d=u?" ".repeat(l):" ",f={tabSize:l,insertSpaces:u,singleIndent:d,wordWrapColumn:t.options.wordWrapColumn};return e instanceof Ue?BH(t,e,s,o,n,c,d,a,i,r):e instanceof je?GH(e,c,f,a,i):e instanceof En?KH(e,c,d,i):e instanceof kr?YH(e,n,d,i):e instanceof lr&&!e.disabled?QH(e,o,await r(e),d,i,f):e instanceof cr&&!e.disabled?XH(e,o,await r(e),d,i,f):[]};function ZH(t,e){let n=t[e.start.line],r=t[e.end.line];if(e.start.line===e.end.line)return n.substring(e.start.character,e.end.character);let i=t.slice(e.start.line+1,e.end.line);return[n.substring(e.start.character),...i,r.substring(0,e.end.character)].join(`
305
305
  `)}var a0=q(j());var Zp=t=>!t||t instanceof je?!1:t instanceof Dn||Zp(t.parentNode);function eV(t){if(!t||!(t.item instanceof Xe&&t.item.ast.assignOperatorToken))return[];let e=Zp(t?.ast);if(!e&&!(t.ast instanceof je&&t.item.ast.values===null)&&!Zp(t.beforeAst)&&!Zp(t.afterAst))return[];let n=-1;if(t.item.ast.values===null?n=0:n=(t.item.ast.values?.values.findIndex(i=>i&&yT(i,t.beforeAst))??-1)+1,n===-1&&(n=0),t.item.name==="compatible"){let s=t.item.parent.nodeTypes.filter(c=>c).at(-1),o=t.item.ast.quickValues,a;return s instanceof bt&&s.extends.size&&(a=Array.from(s.extends).filter(c=>!o||!o.includes(c))),o?.filter(c=>c)?.length&&!a?[]:(a??=t.runtime.context.bindingLoader?.getBindings()??[],a.filter(c=>!o||!o.includes(c)).map(c=>({label:`"${c}"`,kind:a0.CompletionItemKind.Variable,insertText:e?c:`"${c}"`})))}let r=t.item.parent.nodeType;return r instanceof bt?r.properties.find(i=>i.name===t.item?.name)?.getPropertyCompletionItems(t.item,n,e)??[]:[]}function tV(t){if(!t||!(t.item instanceof Xe&&t.ast instanceof Ye&&t.item.ast.values==null||t.item instanceof X)||Kt(t.ast)||t.beforeAst?.parentNode instanceof En)return[];let e=n=>n.nodeType?.getPropertyListCompletionItems(n)??[];return t.item instanceof Xe?e(t.item.parent):e(t.item)}async function c0(t,e){return Nt(t,e,n=>[...eV(n),...tV(n)])}var eh=q(j());async function nV(t){if(t?.ast instanceof pt||t?.ast instanceof hi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t?.ast instanceof pt?t.ast.name:t.ast.value);if(e){let n=Hc(t.ast),r=(await t.runtime.context.getAllStableParsers()).at(-1);if(n){let i=n?.evaluate(r.cPreprocessorParser.macros);return{contents:{kind:eh.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${i}${typeof i=="number"?` (0x${i.toString(16)})`:""}`,"```"].join(`
306
306
  `)},range:ce(t.ast)}}return{contents:{kind:eh.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${t.ast?.evaluate(r.cPreprocessorParser.macros)}`,"```"].join(`
307
307
  `)},range:ce(t.ast)}}}}async function rV(t){if(!t)return;let e=(await t.runtime.context.getAllStableParsers()).at(-1);if(t?.ast instanceof xe){let n=t.ast.linksTo;if(n)return{contents:n.toMarkupContent(e.cPreprocessorParser.macros),range:ce(t.ast)}}if(t?.ast.parentNode instanceof ie){let n=t.ast.parentNode.linksTo;if(n)return{contents:n.toMarkupContent(e.cPreprocessorParser.macros),range:ce(t.ast)}}if(t?.ast instanceof re&&t.item instanceof Xe&&t.item.parent.name==="aliases"){let n=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(n)return{contents:n.toMarkupContent(e.cPreprocessorParser.macros),range:ce(t.ast)}}if(t?.item instanceof X)return{contents:t.item.toMarkupContent(e.cPreprocessorParser.macros),range:ce(t.ast)}}function iV(t){if(t?.item instanceof Xe&&t.ast instanceof Ye){let e=t.item.onHover(),n=t.item.parent.nodeType?.getOnPropertyHover(t.item.name);if(e||n)return{contents:{kind:eh.MarkupKind.Markdown,value:`${e?.value??""}
@@ -321,8 +321,8 @@ ${r}`]})]:[]}else if(e.keyword==="maxItems"||e.keyword==="minItems"){let a=s.get
321
321
  ${JSON.stringify(e)}
322
322
  ${r}`]})];let o=i.node.implementations[0]instanceof Tt?i.node.implementations[0]:i.node.implementations[0].identifierAst??i.node.implementations[0];return[F(25,o.firstToken,o.lastToken,o,{templateStrings:[`${e.message??"NO MESSAGE"}:
323
323
  ${JSON.stringify(e)}
324
- ${r}`]})]},L6=(t,e)=>hF(t,e.split("/").filter(n=>n)),hF=(t,e)=>{if(e.length===0)return{node:t,remainingInstancePath:""};let n=e[0].split("@"),r=n[0],i=n.at(1)?.split(",").map(o=>Number.parseInt(o,16)),s=t.getNode(r,i);return s?hF(s,e.slice(1)):{node:t,property:t.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var QS=class t{constructor(){this.schemaIdValidators=new Map;this.ajvMap=new Map}static getNodeCompatible(e){let r=e.getProperty("compatible")?.ast.values;if(!r?.values.some(i=>!(i?.value instanceof re)))return r?.values.map(i=>(i?.value).value)}parseMetaSchema(e,n){To.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,YS.resolve)(e,i);try{let s=JS.default.parse((0,XS.readFileSync)(i,"utf-8"));n.addMetaSchema(s),this.schemaIdValidators.set(s.$id,i)}catch{}})}parseBindings(e,n){To.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,YS.resolve)(e,i);try{let s=JS.default.parse((0,XS.readFileSync)(i,"utf-8"));n.addSchema(s),this.schemaIdValidators.set(s.$id,i)}catch(s){console.warn(i,s.message)}})}getNodeTypes(e,n,r){let i=`${e.join(";")}::${n.join(";")}`,s=this.ajvMap.get(i);return s||(s=new gF.default({strict:!1,strictSchema:!1,strictNumbers:!1}),s.addMetaSchema(KS),this.ajvMap.set(i,s),e.forEach(c=>this.parseMetaSchema(c,s)),n.forEach(c=>this.parseBindings(c,s))),t.getNodeCompatible(r)?.map(c=>{try{let l=Array.from(this.schemaIdValidators.keys()).find(f=>f.endsWith(`/${c}.yaml#`));if(!l)return;let u=new Qm(s,l);u.bindingsPath=this.schemaIdValidators.get(l),u.compatible=c;let d=s.getSchema(l);return u.description=(d?.schema).description,u.examples=(d?.schema).examples,u.maintainers=(d?.schema).maintainers,u}catch(l){console.warn(l.message)}}).filter(c=>c)??[]}getBindings(){return Array.from(this.schemaIdValidators.keys())}},mF,ZS=()=>(mF??=new QS,mF);var Bs=q(require("path")),kF=require("fs"),PF=q(require("path")),NF=q(Yb());var Lr=q(j());var yF=()=>{let t=new Y("nonposted-mmio",W("EMPTY"),"optional");return t.description=["Specifies that direct children of this bus should use non-posted memory accesses (i.e. a non-posted mapping mode) for MMIO ranges."],t};function TF(){let t=bn();t.noMismatchPropertiesAllowed=!0;let e=t.properties.find(r=>r.name==="compatible");e.required=()=>"required";let n=t.properties.find(r=>r.name==="ranges");return n.required=()=>"required",t.addProperty(yF()),t}var vF=t=>{switch(t){case"string":return W("STRING");case"int":return W("U32");case"boolean":return W("EMPTY");case"array":return W("PROP_ENCODED_ARRAY");case"uint8-array":return W("BYTESTRING");case"string-array":return W("STRINGLIST");case"phandle":return W("U32");case"phandles":return W("PROP_ENCODED_ARRAY");case"phandle-array":return W("PROP_ENCODED_ARRAY");case"path":return W(["STRING","U32"]);case"compound":return W("ANY");default:return W("ANY")}},bF=(t,e)=>{switch(t){case"string":return typeof e=="string"?e:void 0;case"int":return typeof e=="number"?e:void 0;case"boolean":return;case"array":return Array.isArray(e)&&e.every(n=>typeof n=="number")?e:void 0;case"uint8-array":return Array.isArray(e)&&e.every(n=>typeof n=="number")?e:void 0;case"string-array":return Array.isArray(e)&&e.every(n=>typeof n=="string")?e:void 0;case"phandle":return;case"phandles":return;case"phandle-array":return;case"path":return;case"compound":return}},Zm=(t,e)=>{if(Object.entries(e.properties??{}).forEach(([n,r])=>{r.name=n}),e.extends??=[],e=e.include.reduce((n,r)=>{let i=t.find(s=>(0,Bs.basename)(s.filePath)===r.name);if(i){let s=r["property-blocklist"],o=r["property-allowlist"];e.extends?.push(...n.include.map(c=>(0,Bs.basename)(c.name,".yaml")));let a=r["child-binding"];return n.include=n.include.filter(c=>c!==r),RF(t,i,n,s,o,a)??n}return console.warn(`Unable to find ${r.name}`),n},e),e["child-binding"]&&(e["child-binding"].include=wF(e["child-binding"].include),e["child-binding"]=Zm(t,e["child-binding"]),e["child-binding"]&&(e["child-binding"].isChildBinding=!0,e["child-binding"].filePath=e.filePath)),!e.include.length)return e},RF=(t,e,n,r=[],i,s)=>{let o=Zm(t,e),a=Zm(t,n);if(!o||!a)return;let c=new Set;Object.keys(o?.properties??{}).forEach(p=>c.add(p)),Object.keys(a?.properties??{}).forEach(p=>c.add(p));let l={};Array.from(c).forEach(p=>{let m=r?.some(y=>y===p)||i&&!i.some(y=>y===p)?void 0:o.properties?.[p]??void 0,h=a.properties?.[p]??void 0;(m||h)&&(l={...l,[p]:{...m??{},...h}})}),a.properties=l,a.extends??=[],a.extends.push(...o.extends??[]);let u=new Set;return Object.keys(o).filter(p=>p.endsWith("-cells")).forEach(p=>u.add(p)),Object.keys(o).filter(p=>p.endsWith("-cells")).forEach(p=>u.add(p)),Array.from(u).forEach(p=>{let m=o[p]??[],h=a[p]??[];a[p]=Array.from([...m,...h])}),a["on-bus"]??=o["on-bus"],a.bus?a.bus.push(...o.bus??[]):a.bus=o.bus,o["child-binding"]&&(a["child-binding"]??={filePath:a.filePath,include:[],rawInclude:[],isChildBinding:!0},RF(t,o["child-binding"],a["child-binding"]??{filePath:a.filePath,include:[],rawInclude:[],isChildBinding:!0},s?.["property-blocklist"],s?.["property-allowlist"],s?.["child-binding"])),a},wF=t=>t?typeof t=="string"?[{name:t}]:t.map(e=>typeof e!="string"?e:{name:e}):[],ek=class t{constructor(){this.typeCache=new Map;this.processedFolders=new Set;this.zephyrBindingCache=new Map;this.contextBindingFiles=new WeakMap}static getCompatibleKeys(e,n){return!n||!n.nodeType?.bus?.length?[e]:[...n.nodeType.bus.map(r=>`${e}::${r}`),e]}getBaseZephyrType(e){let n=e.split(":");return Array.from(this.zephyrBindingCache.keys()).filter(i=>n.some(s=>i.startsWith(s))).flatMap(i=>this.zephyrBindingCache.get(i)).find(i=>i.filePath.endsWith(`${Bs.default.sep}base.yaml`))}getBaseNodeType(e,n){let r=this.getBaseZephyrType(n),i=r?eg(r,e):void 0;if(i){i.warnMismatchProperties=!1;let s=i.properties.find(o=>o.name==="compatible");s&&(s.required=()=>"optional")}return i}static getNodeCompatible(e){let i=e.getProperty("compatible")?.ast.values?.values.filter(s=>s&&s.value instanceof re);if(i?.length)return i.map(s=>s?.value?{name:s.value.value,ast:s.value}:void 0)}getNodeTypes(e,n){let r=t.getNodeCompatible(e)?.filter(a=>!!a),i=r?.flatMap(a=>t.getCompatibleKeys(a.name,e.parent).map(c=>this.typeCache.get(n)?.get(c)?.(e)).filter(c=>!!c))??[];if(!i.length){let a=n.split(":"),l=Array.from(this.zephyrBindingCache.keys()).filter(d=>a.some(f=>d.startsWith(f))).flatMap(d=>this.zephyrBindingCache.get(d)).find(d=>(0,Bs.basename)(d.filePath)==="base.yaml"),u=l?eg(l,e):void 0;if(u){u.warnMismatchProperties=!1;let d=u.properties.find(f=>f.name==="compatible");d&&(d.required=()=>"optional")}return{type:[u??ao(e)],issues:[]}}let s=this.getBusTypes(),o=r?.flatMap(a=>{let c=t.getCompatibleKeys(a.name,e.parent).some(l=>this.typeCache.get(n)?.has(l));if(!c){let l=s.filter(u=>this.typeCache.get(n)?.has(`${a.name}::${u}`));if(l.length)return F(37,a.ast.firstToken,a.ast.lastToken,a.ast,{templateStrings:l})}return c?[]:[F(32,a.ast.firstToken,a.ast.lastToken,a.ast,{severity:Lr.DiagnosticSeverity.Hint,tags:[Lr.DiagnosticTag.Unnecessary],templateStrings:[a.name]})]})??[];return{type:i.length?i:[ao(e)],issues:o}}loadTypeAndCache(e,n){e=Array.isArray(e)?e:[e];let r=e.filter(o=>this.processedFolders.has(o)).flatMap(o=>Array.from(this.zephyrBindingCache.entries()).flatMap(([a,c])=>a.startsWith(o)?[c]:[]));r.push(...e.filter(o=>!this.processedFolders.has(o)).flatMap(o=>(this.processedFolders.add(o),To.sync("**/*.yaml",{cwd:o,ignore:"test/*"}).map(c=>{if(c=(0,Bs.resolve)(o,c),this.zephyrBindingCache.has(c))return this.zephyrBindingCache.get(c);try{let l=NF.default.parse((0,kF.readFileSync)(c,"utf-8")),u=wF(l?.include),d={...l,bus:l.bus?Array.isArray(l.bus)?l.bus:[l.bus]:void 0,include:u,rawInclude:[...u],filePath:c};return this.zephyrBindingCache.set(c,d),d}catch(l){console.warn(l)}}).filter(c=>!!c))));let i=r.map(o=>Zm(r,o)).filter(o=>!!o&&!o.include.length),s=this.typeCache.get(n);if(s||(s=new Map,this.typeCache.set(n,s)),i.forEach(o=>{let a=this.contextBindingFiles.get(o);a?a.push(n):this.contextBindingFiles.set(o,[n])}),q6(i,s),!s.has("simple-bus")){let o=this.getBaseZephyrType(n);if(o){let a=$6(o);s.set("simple-bus",()=>a)}}}getBindings(e){return Array.from(this.typeCache.get(e)?.keys()??[]).map(n=>n.split("::",1)[0])}getZephyrContextBinding(e){return Array.from(this.zephyrBindingCache.values()).filter(n=>this.contextBindingFiles.get(n)?.includes(e))}getBusTypes(){let e=Array.from(this.zephyrBindingCache.values()).flatMap(n=>n.bus?.filter(r=>!!r)??[]).filter(n=>!!n);return Array.from(new Set(e))}getDocumentLinks(e,n){let r=this.zephyrBindingCache.get(Se(e.uri));if(!r)return[];let i=e.getText();return r.rawInclude.map(o=>{let c=new RegExp(o.name).exec(i);if(c){let l=e.positionAt(c.index),u=e.positionAt(c.index+c[0].length),d=Array.from(this.zephyrBindingCache.keys()).find(f=>f.endsWith(`${PF.default.sep}${o.name}`)&&n.some(p=>f.startsWith(p)));return d?{range:Lr.Range.create(l,u),target:ue(d)}:void 0}}).filter(o=>!!o)}resetCache(e){this.typeCache.delete(e)}},_F,js=()=>(_F??=new ek,_F),q6=(t,e)=>t.forEach(n=>{n.compatible&&e.set(n["on-bus"]?`${n.compatible}::${n["on-bus"]}`:n.compatible,r=>eg(n,r))}),eg=(t,e)=>{let n=ao(e);n.compatible=t.compatible,n.description=t.description,n.bindingsPath=t.filePath,n.zephyrBinding=t,n.bus=typeof t.bus=="string"?[t.bus]:Array.from(new Set(t.bus)),n.onBus=t["on-bus"],t.extends?.forEach(s=>n.extends.add(s)),n.warnMismatchProperties=!0;let i=Object.keys(t).filter(s=>s.endsWith("-cells")).map(s=>({specifier:s.replace(/-cells$/,""),values:t[s]}));if(n.cellsValues=i,Object.entries(t.properties??{}).forEach(([s,o])=>{EF(n,s,o)}),t["child-binding"]){let s=t["child-binding"];n.childNodeType=o=>{let a=eg(s,o);return a.hasParentBinding=!0,a}}return n},$6=t=>{let e=TF();e.bus=typeof t.bus=="string"?[t.bus]:Array.from(new Set(t.bus)),e.onBus=t["on-bus"],t.extends?.forEach(i=>e.extends.add(i)),e.warnMismatchProperties=!0;let r=Object.keys(t).filter(i=>i.endsWith("-cells")).map(i=>({specifier:i.replace(/-cells$/,""),values:t[i]}));return e.cellsValues=r,Object.entries(t.properties??{}).forEach(([i,s])=>{EF(e,i,s)}),e},EF=(t,e,n)=>{let r=t.properties.find(i=>i.getNameMatch(e));if(r&&typeof r.name=="string"){r.name!=="reg"?r.required=()=>n.required?"required":"optional":n.required&&(r.required=()=>"required"),r.values=()=>n.enum??[],r.constValue=bF(n.type,n.const),r.bindingType=n.type;let i=r.additionalTypeCheck;r.additionalTypeCheck=(s,o)=>[...SF(n,e,r)(s,o),...i?.(s,o)??[]]}else{let i=n.type==="compound"?r?.type:vF(n.type);i??=vF(n.type);let s=new Y(e,i,n.required?"required":"optional",void 0,n.enum);s.additionalTypeCheck=(o,a)=>{let c=[...r?.additionalTypeCheck?.(o,a)??[],...SF(n,e,s)(o,a)];return s.signatureArgs??=r?.signatureArgs,s.signatureArgsCyclic??=!!r?.signatureArgsCyclic,c},s.description=n.description?[n.description]:r?.description,s.bindingType=n.type,s.constValue=bF(n.type,n.const),t.addProperty(s)}},SF=(t,e,n)=>{let r=t;return(i,s)=>{let o=i.parent.root,a=[];if(r.const){let l=i.ast.getFlatAstValues();if(l?.length==1&&l.every(u=>u instanceof ge)){let u=l.map(p=>p.evaluate(s)),d=Array.isArray(r.const)?r.const:[r.const];if(!(d.length===u.length&&u.every((p,m)=>typeof p=="number"&&Number.isNaN(p)||d[m]===p))){let p=i.ast.values??i.ast;a.push(F(24,p.firstToken,p.lastToken,p,{templateStrings:[`Binding expects values to be "${r.type}" with value: ${r.const}`]}))}}}if(r.deprecated&&a.push(F(14,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Lr.DiagnosticSeverity.Warning,tags:[Lr.DiagnosticTag.Deprecated],templateStrings:[i.name]})),(r.type==="phandle"||r.type==="phandles"||r.type==="path")&&qe(i.ast.values)?.forEach(u=>{_r(u,o)||a.push(F(22,u.firstToken,u.lastToken,u))}),r.type==="path"&&i.ast.values?.values.at(0)?.value instanceof re){let l=i.ast.values?.values.at(0)?.value,u=[];l.value.split("/").every(d=>{let f=o.getNode(d);return f?u.push(d):a.push(F(23,l.firstToken,l.lastToken,l,{templateStrings:[d,`/${u.join("/")}`]})),!f})}let c=i.name.match(/^(.*)-(\d+)$/);if(r.type==="phandles"&&c){let l="";e.endsWith("-gpios")?l="gpio":l=r["specifier-space"]??c[1];let u=Number.parseInt(c[2],10),d=i.parent.getProperty(`${l}-names`);d&&(d.ast.quickValues?.at(u)||a.push(F(33,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Lr.DiagnosticSeverity.Warning,linkedTo:[d.ast],templateStrings:[i.name,u.toString()]})))}if(r.type==="phandle-array"){let l=qe(i.ast.values),u=0,d=[],f=0;for(;l&&u<l.length;){let p=l.at(u),m=_r(p,o);if(!m){let O=p??i.ast;a.push(F(22,O.firstToken,O.lastToken,O));break}let h="";e.endsWith("-gpios")?h="gpio":h=r["specifier-space"]??e.slice(0,-1);let y=m.getProperty(`#${h}-cells`);if(!y){a.push(F(16,i.ast.firstToken,i.ast.lastToken,i.ast,{linkedTo:[...m.nodeNameOrLabelRef],templateStrings:[i.name,`#${h}-cells`,`/${m.path.slice(1).join("/")}`]}));break}let _=y?Ve(y,0,0,s)??0:0,v=m.nodeType?.cellsValues?.find(O=>O.specifier===h)?.values;if(d.push([`${f}_phandle`,...v?.map(O=>`${f}_${O}`)??[],...Array.from({length:_-(v?.length??0)},(O,B)=>`${f}_cell${_-(v?.length??0)?B:""}`)]),1+_>l.length-u){let O=p??i.ast;a.push(F(19,O.firstToken,O.lastToken,O,{templateStrings:[i.name,`<${d.at(-1).join(" ")}>`]}));break}u+=1+_;let b=l.slice(u-_,u),P={mappingValuesAst:b,specifierSpace:h,cellCount:_,target:m};i.nexusMapsTo.push(P);let E=m.getProperty(`${h}-map`);if(E){let O=m.getNexusMapEntryMatch(h,s,b);O?.match?P.mapItem=O.match:a.push(F(31,O.entry.firstToken,O.entry.lastToken,O.entry,{linkedTo:[E.ast]}))}b.every(O=>O instanceof ge)&&m.spesifierNexusMapping.push({expressions:b,node:i.parent,property:i,specifierSpace:h});let H=i.parent.getProperty(`${h}-names`);p&&H&&(H.ast.quickValues?.at(f)||a.push(F(33,p.firstToken,l[u-1]?.lastToken,i.ast,{severity:Lr.DiagnosticSeverity.Warning,linkedTo:[H.ast],templateStrings:[i.name,f.toString()]}))),f++}d.push([`${f}_phandle`,`${f}_cell...`]),n.signatureArgs=d.map(p=>p.map(m=>Lr.ParameterInformation.create(m)))}return a}};var Bu=new Map,CF=(t,e)=>{let n=t.zephyrBindings.join(":");return e==="Zephyr"&&(Bu.set(n,(Bu.get(n)??0)+1),js().loadTypeAndCache(t.zephyrBindings,n)),{files:t,type:e,getNodeTypes:r=>{switch(e){case"Zephyr":return js().getNodeTypes(r,n);case"DevicetreeOrg":return{type:ZS().getNodeTypes(t.deviceOrgBindingsMetaSchema,t.deviceOrgTreeBindings,r),issues:[]}}},getBindings:()=>{switch(e){case"Zephyr":return js().getBindings(n);case"DevicetreeOrg":return ZS().getBindings()}},getZephyrContextBinding:()=>{switch(e){case"Zephyr":return js().getZephyrContextBinding(n)}},getBusTypes:()=>{switch(e){case"Zephyr":return js().getBusTypes();case"DevicetreeOrg":return[]}},getDocumentLinks(r){if(!r)return[];switch(e){case"Zephyr":return js().getDocumentLinks(r,t.zephyrBindings);case"DevicetreeOrg":return[]}},dispose:()=>{if(e==="Zephyr"){let r=Bu.get(n)??0;r<=1?(Bu.delete(n),js().resetCache(n)):Bu.set(n,r-1)}}}};var tg=q(j());var F6=t=>!t.lastToken.prevToken||!t.lastToken.prevToken.prevToken?[]:[{startLine:t.firstToken.pos.line,startCharacter:t.firstToken.pos.col,endLine:t.lastToken.prevToken.prevToken.pos.line,endCharacter:t.lastToken.prevToken.prevToken.pos.col,kind:tg.FoldingRangeKind.Comment}],tk=t=>!t.openScope||!t.closeScope?.prevToken?t.nodes.flatMap(tk):[{startLine:t.openScope.pos.line,startCharacter:t.openScope.pos.col,endLine:t.closeScope.prevToken.pos.line,endCharacter:t.closeScope.prevToken.pos.col,kind:tg.FoldingRangeKind.Region},...t.nodes.flatMap(tk)],DF=t=>{let e=[];return[...t instanceof Pr?t.ifBlocks.map(n=>({start:(n.expression??n.keyword).lastToken,end:n.content?.lastToken??(n.expression??n.keyword).lastToken})):[{start:(t.ifDef.identifier??t.ifDef.keyword).lastToken,end:t.ifDef.content?.lastToken}],t.elseOption?{start:t.elseOption.keyword.lastToken,end:t.elseOption.content?.lastToken}:null].forEach(n=>{!n||!n.end||e.push({startLine:n.start.pos.line,startCharacter:n.start.pos.col,endLine:n.end.pos.line,endCharacter:n.end.pos.colEnd,kind:tg.FoldingRangeKind.Region})}),e},B6=t=>t instanceof Ue?tk(t):t instanceof Xr||t instanceof Pr?DF(t):t instanceof cr?F6(t):[];function AF(t,e){return e.allAstItems.flatMap(n=>[n,...n.allDescendants]).filter(n=>he(n.fsPath,t)).flatMap(B6)}var OF=require("fs"),MF=require("path"),wn=q(j());function j6(t){if(!t||!(t.ast instanceof xe)&&!(t.ast instanceof un))return[];let e=n=>n.nodeType?.bindingsPath?[wn.Location.create(ue(n.nodeType.bindingsPath),wn.Range.create(wn.Position.create(0,0),wn.Position.create(0,0)))]:[];return t.item instanceof X&&!Kt(t.ast)?e(t.item):t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo?e(t.ast.parentNode.linksTo):t.ast instanceof xe&&t.ast.linksTo?e(t.ast.linksTo):[]}function U6(t){if(!t||!t.item||!(t.ast instanceof Ye)||t.runtime.context.bindingLoader?.type!=="Zephyr")return[];let e=t.item instanceof Xe?t.item.parent:t.item,n=e.nodeType instanceof bt?e.nodeType.zephyrBinding:void 0;if(!n)return[];let r=IF(t.ast.name,n);if(r)return[wn.Location.create(ue(n.filePath),r)];let i=(t.runtime.context.bindingLoader?.getZephyrContextBinding?.()??[]).filter(s=>n.extends?.some(o=>(0,MF.basename)(s.filePath)===`${o}.yaml`));for(let s of i){let o=IF(t.ast.name,s);if(o)return[wn.Location.create(ue(s.filePath),o)]}return[wn.Location.create(ue(n.filePath),wn.Range.create(wn.Position.create(0,0),wn.Position.create(0,0)))]}async function xF(t,e){return Nt(t,e,n=>[...j6(n),...U6(n)])}function IF(t,e){let n=e.filePath,r=(0,OF.readFileSync)(n,"utf8");return H6(r,new RegExp(`(${t}|"${t}")\\s*:`))}function H6(t,e){let n=t.match(e);if(!n)return;let r=n.index;if(r===void 0)return;let i=t.slice(0,r),s=i.split(`
324
+ ${r}`]})]},L6=(t,e)=>hF(t,e.split("/").filter(n=>n)),hF=(t,e)=>{if(e.length===0)return{node:t,remainingInstancePath:""};let n=e[0].split("@"),r=n[0],i=n.at(1)?.split(",").map(o=>Number.parseInt(o,16)),s=t.getNode(r,i);return s?hF(s,e.slice(1)):{node:t,property:t.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var QS=class t{constructor(){this.schemaIdValidators=new Map;this.ajvMap=new Map}static getNodeCompatible(e){let r=e.getProperty("compatible")?.ast.values;if(!r?.values.some(i=>!(i?.value instanceof re)))return r?.values.map(i=>(i?.value).value)}parseMetaSchema(e,n){To.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,YS.resolve)(e,i);try{let s=JS.default.parse((0,XS.readFileSync)(i,"utf-8"));n.addMetaSchema(s),this.schemaIdValidators.set(s.$id,i)}catch{}})}parseBindings(e,n){To.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,YS.resolve)(e,i);try{let s=JS.default.parse((0,XS.readFileSync)(i,"utf-8"));n.addSchema(s),this.schemaIdValidators.set(s.$id,i)}catch(s){console.warn(i,s.message)}})}getNodeTypes(e,n,r){let i=`${e.join(";")}::${n.join(";")}`,s=this.ajvMap.get(i);return s||(s=new gF.default({strict:!1,strictSchema:!1,strictNumbers:!1}),s.addMetaSchema(KS),this.ajvMap.set(i,s),e.forEach(c=>this.parseMetaSchema(c,s)),n.forEach(c=>this.parseBindings(c,s))),t.getNodeCompatible(r)?.map(c=>{try{let l=Array.from(this.schemaIdValidators.keys()).find(f=>f.endsWith(`/${c}.yaml#`));if(!l)return;let u=new Qm(s,l);u.bindingsPath=this.schemaIdValidators.get(l),u.compatible=c;let d=s.getSchema(l);return u.description=(d?.schema).description,u.examples=(d?.schema).examples,u.maintainers=(d?.schema).maintainers,u}catch(l){console.warn(l.message)}}).filter(c=>c)??[]}getBindings(){return Array.from(this.schemaIdValidators.keys())}},mF,ZS=()=>(mF??=new QS,mF);var Bs=q(require("path")),kF=require("fs"),PF=q(require("path")),NF=q(Yb());var Lr=q(j());var yF=()=>{let t=new Y("nonposted-mmio",W("EMPTY"),"optional");return t.description=["Specifies that direct children of this bus should use non-posted memory accesses (i.e. a non-posted mapping mode) for MMIO ranges."],t};function TF(){let t=bn();t.noMismatchPropertiesAllowed=!0;let e=t.properties.find(r=>r.name==="compatible");e.required=()=>"required";let n=t.properties.find(r=>r.name==="ranges");return n.required=()=>"required",t.addProperty(yF()),t}var vF=t=>{switch(t){case"string":return W("STRING");case"int":return W("U32");case"boolean":return W("EMPTY");case"array":return W("PROP_ENCODED_ARRAY");case"uint8-array":return W("BYTESTRING");case"string-array":return W("STRINGLIST");case"phandle":return W("U32");case"phandles":return W("PROP_ENCODED_ARRAY");case"phandle-array":return W("PROP_ENCODED_ARRAY");case"path":return W(["STRING","U32"]);case"compound":return W("ANY");default:return W("ANY")}},bF=(t,e)=>{switch(t){case"string":return typeof e=="string"?e:void 0;case"int":return typeof e=="number"?e:void 0;case"boolean":return;case"array":return Array.isArray(e)&&e.every(n=>typeof n=="number")?e:void 0;case"uint8-array":return Array.isArray(e)&&e.every(n=>typeof n=="number")?e:void 0;case"string-array":return Array.isArray(e)&&e.every(n=>typeof n=="string")?e:void 0;case"phandle":return;case"phandles":return;case"phandle-array":return;case"path":return;case"compound":return}},Zm=(t,e)=>{if(Object.entries(e.properties??{}).forEach(([n,r])=>{r.name=n}),e.extends??=[],e=e.include.reduce((n,r)=>{let i=t.find(s=>(0,Bs.basename)(s.filePath)===r.name);if(i){let s=r["property-blocklist"],o=r["property-allowlist"];e.extends?.push(...n.include.map(c=>(0,Bs.basename)(c.name,".yaml")));let a=r["child-binding"];return n.include=n.include.filter(c=>c!==r),RF(t,i,n,s,o,a)??n}return console.warn(`Unable to find ${r.name}`),n},e),e["child-binding"]&&(e["child-binding"].include=wF(e["child-binding"].include),e["child-binding"]=Zm(t,e["child-binding"]),e["child-binding"]&&(e["child-binding"].isChildBinding=!0,e["child-binding"].filePath=e.filePath)),!e.include.length)return e},RF=(t,e,n,r=[],i,s)=>{let o=Zm(t,e),a=Zm(t,n);if(!o||!a)return;let c=new Set;Object.keys(o?.properties??{}).forEach(p=>c.add(p)),Object.keys(a?.properties??{}).forEach(p=>c.add(p));let l={};Array.from(c).forEach(p=>{let m=r?.some(y=>y===p)||i&&!i.some(y=>y===p)?void 0:o.properties?.[p]??void 0,h=a.properties?.[p]??void 0;(m||h)&&(l={...l,[p]:{...m??{},...h}})}),a.properties=l,a.extends??=[],a.extends.push(...o.extends??[]);let u=new Set;return Object.keys(o).filter(p=>p.endsWith("-cells")).forEach(p=>u.add(p)),Object.keys(o).filter(p=>p.endsWith("-cells")).forEach(p=>u.add(p)),Array.from(u).forEach(p=>{let m=o[p]??[],h=a[p]??[];a[p]=Array.from([...m,...h])}),a["on-bus"]??=o["on-bus"],a.bus?a.bus.push(...o.bus??[]):a.bus=o.bus,o["child-binding"]&&(a["child-binding"]??={filePath:a.filePath,include:[],rawInclude:[],isChildBinding:!0},RF(t,o["child-binding"],a["child-binding"]??{filePath:a.filePath,include:[],rawInclude:[],isChildBinding:!0},s?.["property-blocklist"],s?.["property-allowlist"],s?.["child-binding"])),a},wF=t=>t?typeof t=="string"?[{name:t}]:t.map(e=>typeof e!="string"?e:{name:e}):[],ek=class t{constructor(){this.typeCache=new Map;this.processedFolders=new Set;this.zephyrBindingCache=new Map;this.contextBindingFiles=new WeakMap}static getCompatibleKeys(e,n){return!n||!n.nodeType?.bus?.length?[e]:[...n.nodeType.bus.map(r=>`${e}::${r}`),e]}getBaseZephyrType(e){let n=e.split(":");return Array.from(this.zephyrBindingCache.keys()).filter(i=>n.some(s=>i.startsWith(s))).flatMap(i=>this.zephyrBindingCache.get(i)).find(i=>i.filePath.endsWith(`${Bs.default.sep}base.yaml`))}getBaseNodeType(e,n){let r=this.getBaseZephyrType(n),i=r?eg(r,e):void 0;if(i){i.warnMismatchProperties=!1;let s=i.properties.find(o=>o.name==="compatible");s&&(s.required=()=>"optional")}return i}static getNodeCompatible(e){let i=e.getProperty("compatible")?.ast.values?.values.filter(s=>s&&s.value instanceof re);if(i?.length)return i.map(s=>s?.value?{name:s.value.value,ast:s.value}:void 0)}getNodeTypes(e,n){let r=t.getNodeCompatible(e)?.filter(a=>!!a),i=r?.flatMap(a=>t.getCompatibleKeys(a.name,e.parent).map(c=>this.typeCache.get(n)?.get(c)?.(e)).filter(c=>!!c))??[];if(!i.length){let a=n.split(":"),l=Array.from(this.zephyrBindingCache.keys()).filter(d=>a.some(f=>d.startsWith(f))).flatMap(d=>this.zephyrBindingCache.get(d)).find(d=>(0,Bs.basename)(d.filePath)==="base.yaml"),u=l?eg(l,e):void 0;if(u){u.warnMismatchProperties=!1;let d=u.properties.find(f=>f.name==="compatible");d&&(d.required=()=>"optional")}return{type:[u??ao(e)],issues:[]}}let s=this.getBusTypes(),o=r?.flatMap(a=>{let c=t.getCompatibleKeys(a.name,e.parent).some(l=>this.typeCache.get(n)?.has(l));if(!c){let l=s.filter(u=>this.typeCache.get(n)?.has(`${a.name}::${u}`));if(l.length)return F(37,a.ast.firstToken,a.ast.lastToken,a.ast,{templateStrings:l})}return c?[]:[F(32,a.ast.firstToken,a.ast.lastToken,a.ast,{severity:Lr.DiagnosticSeverity.Hint,tags:[Lr.DiagnosticTag.Unnecessary],templateStrings:[a.name]})]})??[];return{type:i.length?i:[ao(e)],issues:o}}loadTypeAndCache(e,n){e=Array.isArray(e)?e:[e];let r=e.filter(o=>this.processedFolders.has(o)).flatMap(o=>Array.from(this.zephyrBindingCache.entries()).flatMap(([a,c])=>a.startsWith(o)?[c]:[]));r.push(...e.filter(o=>!this.processedFolders.has(o)).flatMap(o=>(this.processedFolders.add(o),To.sync("**/*.yaml",{cwd:o,ignore:"test/*"}).map(c=>{if(c=(0,Bs.resolve)(o,c),this.zephyrBindingCache.has(c))return this.zephyrBindingCache.get(c);try{let l=NF.default.parse((0,kF.readFileSync)(c,"utf-8")),u=wF(l?.include),d={...l,bus:l.bus?Array.isArray(l.bus)?l.bus:[l.bus]:void 0,include:u,rawInclude:[...u],filePath:c};return this.zephyrBindingCache.set(c,d),d}catch(l){console.warn(l)}}).filter(c=>!!c))));let i=r.map(o=>Zm(r,o)).filter(o=>!!o&&!o.include.length),s=this.typeCache.get(n);if(s||(s=new Map,this.typeCache.set(n,s)),i.forEach(o=>{let a=this.contextBindingFiles.get(o);a?a.push(n):this.contextBindingFiles.set(o,[n])}),q6(i,s),!s.has("simple-bus")){let o=this.getBaseZephyrType(n);if(o){let a=$6(o);s.set("simple-bus",()=>a)}}}getBindings(e){return Array.from(this.typeCache.get(e)?.keys()??[]).map(n=>n.split("::",1)[0])}getZephyrContextBinding(e){return Array.from(this.zephyrBindingCache.values()).filter(n=>this.contextBindingFiles.get(n)?.includes(e))}getBusTypes(){let e=Array.from(this.zephyrBindingCache.values()).flatMap(n=>n.bus?.filter(r=>!!r)??[]).filter(n=>!!n);return Array.from(new Set(e))}getDocumentLinks(e,n){let r=this.zephyrBindingCache.get(Se(e.uri));if(!r)return[];let i=e.getText();return r.rawInclude.map(o=>{let c=new RegExp(o.name).exec(i);if(c){let l=e.positionAt(c.index),u=e.positionAt(c.index+c[0].length),d=Array.from(this.zephyrBindingCache.keys()).find(f=>f.endsWith(`${PF.default.sep}${o.name}`)&&n.some(p=>f.startsWith(p)));return d?{range:Lr.Range.create(l,u),target:ue(d)}:void 0}}).filter(o=>!!o)}resetCache(e){this.typeCache.delete(e)}},_F,js=()=>(_F??=new ek,_F),q6=(t,e)=>t.forEach(n=>{n.compatible&&e.set(n["on-bus"]?`${n.compatible}::${n["on-bus"]}`:n.compatible,r=>eg(n,r))}),eg=(t,e)=>{let n=ao(e);n.compatible=t.compatible,n.description=t.description,n.bindingsPath=t.filePath,n.zephyrBinding=t,n.bus=typeof t.bus=="string"?[t.bus]:Array.from(new Set(t.bus)),n.onBus=t["on-bus"],t.extends?.forEach(s=>n.extends.add(s)),n.warnMismatchProperties=!0;let i=Object.keys(t).filter(s=>s.endsWith("-cells")).map(s=>({specifier:s.replace(/-cells$/,""),values:t[s]}));if(n.cellsValues=i,Object.entries(t.properties??{}).forEach(([s,o])=>{EF(n,s,o)}),t["child-binding"]){let s=t["child-binding"];n.childNodeType=o=>{let a=eg(s,o);return a.hasParentBinding=!0,a}}return n},$6=t=>{let e=TF();e.bus=typeof t.bus=="string"?[t.bus]:Array.from(new Set(t.bus)),e.onBus=t["on-bus"],t.extends?.forEach(i=>e.extends.add(i)),e.warnMismatchProperties=!0;let r=Object.keys(t).filter(i=>i.endsWith("-cells")).map(i=>({specifier:i.replace(/-cells$/,""),values:t[i]}));return e.cellsValues=r,Object.entries(t.properties??{}).forEach(([i,s])=>{EF(e,i,s)}),e},EF=(t,e,n)=>{let r=t.properties.find(i=>i.getNameMatch(e));if(r&&typeof r.name=="string"){r.name!=="reg"?r.required=()=>n.required?"required":"optional":n.required&&(r.required=()=>"required"),r.values=()=>n.enum??[],r.constValue=bF(n.type,n.const),r.bindingType=n.type;let i=r.additionalTypeCheck;r.additionalTypeCheck=(s,o)=>[...SF(n,e,r)(s,o),...i?.(s,o)??[]]}else{let i=n.type==="compound"?r?.type:vF(n.type);i??=vF(n.type);let s=new Y(e,i,n.required?"required":"optional",void 0,n.enum);s.additionalTypeCheck=(o,a)=>{let c=[...r?.additionalTypeCheck?.(o,a)??[],...SF(n,e,s)(o,a)];return s.signatureArgs??=r?.signatureArgs,s.signatureArgsCyclic??=!!r?.signatureArgsCyclic,c},s.description=n.description?[n.description]:r?.description,s.bindingType=n.type,s.constValue=bF(n.type,n.const),t.addProperty(s)}},SF=(t,e,n)=>{let r=t;return(i,s)=>{let o=i.parent.root,a=[];if(r.const){let l=i.ast.getFlatAstValues();if(l?.length==1&&l.every(u=>u instanceof ge)){let u=l.map(p=>p.evaluate(s)),d=Array.isArray(r.const)?r.const:[r.const];if(!(d.length===u.length&&u.every((p,m)=>typeof p=="number"&&Number.isNaN(p)||d[m]===p))){let p=i.ast.values??i.ast;a.push(F(24,p.firstToken,p.lastToken,p,{templateStrings:[`Binding expects values to be "${r.type}" with value: ${r.const}`]}))}}}if(r.deprecated&&a.push(F(14,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Lr.DiagnosticSeverity.Warning,tags:[Lr.DiagnosticTag.Deprecated],templateStrings:[i.name]})),(r.type==="phandle"||r.type==="phandles"||r.type==="path")&&qe(i.ast.values)?.forEach(u=>{_r(u,o)||a.push(F(22,u.firstToken,u.lastToken,u))}),r.type==="path"&&i.ast.values?.values.at(0)?.value instanceof re){let l=i.ast.values?.values.at(0)?.value,u=[];l.value.split("/").every(d=>{let f=o.getNode(d);return f?u.push(d):a.push(F(23,l.firstToken,l.lastToken,l,{templateStrings:[d,`/${u.join("/")}`]})),!f})}let c=i.name.match(/^(.*)-(\d+)$/);if(r.type==="phandles"&&c){let l="";e.endsWith("-gpios")?l="gpio":l=r["specifier-space"]??c[1];let u=Number.parseInt(c[2],10),d=i.parent.getProperty(`${l}-names`);d&&(d.ast.quickValues?.at(u)||a.push(F(33,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Lr.DiagnosticSeverity.Warning,linkedTo:[d.ast],templateStrings:[i.name,u.toString()]})))}if(r.type==="phandle-array"){let l=qe(i.ast.values),u=0,d=[],f=0;for(;l&&u<l.length;){let p=l.at(u),m=_r(p,o);if(!m){let O=p??i.ast;a.push(F(22,O.firstToken,O.lastToken,O));break}let h="";e.endsWith("-gpios")?h="gpio":h=r["specifier-space"]??e.slice(0,-1);let y=m.getProperty(`#${h}-cells`);if(!y){a.push(F(16,i.ast.firstToken,i.ast.lastToken,i.ast,{linkedTo:[...m.nodeNameOrLabelRef],templateStrings:[i.name,`#${h}-cells`,`/${m.path.slice(1).join("/")}`]}));break}let _=y?Ve(y,0,0,s)??0:0,v=m.nodeType?.cellsValues?.find(O=>O.specifier===h)?.values;if(d.push([`${f}_phandle`,...v?.map(O=>`${f}_${O}`)??[],...Array.from({length:_-(v?.length??0)},(O,B)=>`${f}_cell${_-(v?.length??0)?B:""}`)]),1+_>l.length-u){let O=p??i.ast;a.push(F(19,O.firstToken,O.lastToken,O,{templateStrings:[i.name,`<${d.at(-1).join(" ")}>`]}));break}u+=1+_;let b=l.slice(u-_,u),P={mappingValuesAst:b,specifierSpace:h,cellCount:_,target:m};i.nexusMapsTo.push(P);let E=m.getProperty(`${h}-map`);if(E){let O=m.getNexusMapEntryMatch(h,s,b);O?.match?P.mapItem=O.match:a.push(F(31,O.entry.firstToken,O.entry.lastToken,O.entry,{linkedTo:[E.ast]}))}b.every(O=>O instanceof ge)&&m.spesifierNexusMapping.push({expressions:b,node:i.parent,property:i,specifierSpace:h});let H=i.parent.getProperty(`${h}-names`);p&&H&&(H.ast.quickValues?.at(f)||a.push(F(33,p.firstToken,l[u-1]?.lastToken,i.ast,{severity:Lr.DiagnosticSeverity.Warning,linkedTo:[H.ast],templateStrings:[i.name,f.toString()]}))),f++}d.push([`${f}_phandle`,`${f}_cell...`]),n.signatureArgs=d.map(p=>p.map(m=>Lr.ParameterInformation.create(m)))}return a}};var Bu=new Map,CF=(t,e)=>{let n=t.zephyrBindings.join(":");return e==="Zephyr"&&(Bu.set(n,(Bu.get(n)??0)+1),js().loadTypeAndCache(t.zephyrBindings,n)),{files:t,type:e,getNodeTypes:r=>{switch(e){case"Zephyr":return js().getNodeTypes(r,n);case"DevicetreeOrg":return{type:ZS().getNodeTypes(t.deviceOrgBindingsMetaSchema,t.deviceOrgTreeBindings,r),issues:[]}}},getBindings:()=>{switch(e){case"Zephyr":return js().getBindings(n);case"DevicetreeOrg":return ZS().getBindings()}},getZephyrContextBinding:()=>{switch(e){case"Zephyr":return js().getZephyrContextBinding(n)}},getBusTypes:()=>{switch(e){case"Zephyr":return js().getBusTypes();case"DevicetreeOrg":return[]}},getDocumentLinks(r){if(!r)return[];switch(e){case"Zephyr":return js().getDocumentLinks(r,t.zephyrBindings);case"DevicetreeOrg":return[]}},dispose:()=>{if(e==="Zephyr"){let r=Bu.get(n)??0;r<=1?(Bu.delete(n),js().resetCache(n)):Bu.set(n,r-1)}}}};var tg=q(j());var F6=t=>!t.lastToken.prevToken||!t.lastToken.prevToken.prevToken?[]:[{startLine:t.firstToken.pos.line,startCharacter:t.firstToken.pos.col,endLine:t.lastToken.prevToken.prevToken.pos.line,endCharacter:t.lastToken.prevToken.prevToken.pos.col,kind:tg.FoldingRangeKind.Comment}],tk=t=>!t.openScope||!t.closeScope?.prevToken?t.nodes.flatMap(tk):[{startLine:t.openScope.pos.line,startCharacter:t.openScope.pos.col,endLine:t.closeScope.prevToken.pos.line,endCharacter:t.closeScope.prevToken.pos.col,kind:tg.FoldingRangeKind.Region},...t.nodes.flatMap(tk)],DF=t=>{let e=[];return[...t instanceof Pr?t.ifBlocks.map(n=>({start:(n.expression??n.keyword).lastToken,end:n.content?.lastToken??(n.expression??n.keyword).lastToken})):[{start:(t.ifDef.identifier??t.ifDef.keyword).lastToken,end:t.ifDef.content?.lastToken}],t.elseOption?{start:t.elseOption.keyword.lastToken,end:t.elseOption.content?.lastToken}:null].forEach(n=>{!n||!n.end||e.push({startLine:n.start.pos.line,startCharacter:n.start.pos.col,endLine:n.end.pos.line,endCharacter:n.end.pos.colEnd,kind:tg.FoldingRangeKind.Region})}),e},B6=t=>t instanceof Ue?tk(t):t instanceof Xr||t instanceof Pr?DF(t):t instanceof cr?F6(t):[];function AF(t,e){return e.allAstItems.flatMap(n=>[n,...n.allDescendants]).filter(n=>pe(n.fsPath,t)).flatMap(B6)}var OF=require("fs"),MF=require("path"),wn=q(j());function j6(t){if(!t||!(t.ast instanceof xe)&&!(t.ast instanceof un))return[];let e=n=>n.nodeType?.bindingsPath?[wn.Location.create(ue(n.nodeType.bindingsPath),wn.Range.create(wn.Position.create(0,0),wn.Position.create(0,0)))]:[];return t.item instanceof X&&!Kt(t.ast)?e(t.item):t.ast instanceof un&&t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo?e(t.ast.parentNode.linksTo):t.ast instanceof xe&&t.ast.linksTo?e(t.ast.linksTo):[]}function U6(t){if(!t||!t.item||!(t.ast instanceof Ye)||t.runtime.context.bindingLoader?.type!=="Zephyr")return[];let e=t.item instanceof Xe?t.item.parent:t.item,n=e.nodeType instanceof bt?e.nodeType.zephyrBinding:void 0;if(!n)return[];let r=IF(t.ast.name,n);if(r)return[wn.Location.create(ue(n.filePath),r)];let i=(t.runtime.context.bindingLoader?.getZephyrContextBinding?.()??[]).filter(s=>n.extends?.some(o=>(0,MF.basename)(s.filePath)===`${o}.yaml`));for(let s of i){let o=IF(t.ast.name,s);if(o)return[wn.Location.create(ue(s.filePath),o)]}return[wn.Location.create(ue(n.filePath),wn.Range.create(wn.Position.create(0,0),wn.Position.create(0,0)))]}async function xF(t,e){return Nt(t,e,n=>[...j6(n),...U6(n)])}function IF(t,e){let n=e.filePath,r=(0,OF.readFileSync)(n,"utf8");return H6(r,new RegExp(`(${t}|"${t}")\\s*:`))}function H6(t,e){let n=t.match(e);if(!n)return;let r=n.index;if(r===void 0)return;let i=t.slice(0,r),s=i.split(`
325
325
  `).length-1,o=i.lastIndexOf(`
326
326
  `),a=o===-1?r+1:r-o,c=a+n[0].length;return wn.Range.create(wn.Position.create(s,a),wn.Position.create(s,c))}var hc=require("fs");var V6=(t,e)=>{let n=(0,hc.readFileSync)(t).toString();if(An().needsRenew(t,n))An().renewLexer(t,n),e(t);else return console.log("file changed event has the same text, skipping.",t)},ng=class{constructor(e,n,r){this.file=e;this.cb=n;this.isFileDirty=r}#e=0;watch(){if(this.count++,this.count===1){console.log("create watch for",this.file);let e=this.file,n=this.cb;this.onChange=()=>{if(console.log("onChange - file watcher",e),this.isFileDirty()){console.log("onChange - file is dirty, skipping");return}V6(e,n)},(0,hc.watchFile)(e,this.onChange)}}unwatch(){this.count===1&&(console.log("dispose watch for",this.file),(0,hc.unwatchFile)(this.file,this.onChange),this.onChange=void 0),this.count--}get count(){return this.#e}set count(e){this.#e=e,e<0&&(this.#e=0,console.warn("unwatching an un watched file",this.file))}};var sn=q(require("path")),nk=require("fs");var li=t=>{if(t)return Array.isArray(t)?t:[t]},W6=t=>({...t,deviceOrgBindingsMetaSchema:li(t.deviceOrgBindingsMetaSchema),deviceOrgTreeBindings:li(t.deviceOrgTreeBindings),includePaths:li(t.includePaths),lockRenameEdits:li(t.lockRenameEdits),zephyrBindings:li(t.zephyrBindings),overlays:li(t.overlays)}),LF=t=>({...t,defaultDeviceOrgBindingsMetaSchema:li(t.defaultDeviceOrgBindingsMetaSchema),defaultDeviceOrgTreeBindings:li(t.defaultDeviceOrgTreeBindings),defaultIncludePaths:li(t.defaultIncludePaths),defaultLockRenameEdits:li(t.defaultLockRenameEdits),defaultZephyrBindings:li(t.defaultZephyrBindings),contexts:t.contexts?.map(W6)}),qr=async(t,e=[],n)=>{let r=n?e.map(s=>Se(s.uri)).find(s=>oE(s,n)):void 0;return[...e.at(0)?[{replace:"${workspaceFolder}",fsPath:r??Se(e[0].uri)}]:[],...e.map(s=>({replace:`\${workspaceFolder:${s.name}}`,fsPath:Se(s.uri)}))].forEach(s=>t=t.replaceAll(s.replace,s.fsPath)),t},Us={defaultBindingType:"Zephyr",defaultZephyrBindings:[],defaultIncludePaths:[],defaultDeviceOrgBindingsMetaSchema:[],defaultDeviceOrgTreeBindings:[],contexts:[],defaultLockRenameEdits:[],allowAdhocContexts:!0,autoChangeContext:!0,defaultShowFormattingErrorAsDiagnostics:!0,disableFileWatchers:!1},rk=async(t,e,n)=>{let r=await qr(t.cwd??"${workspaceFolder}",n,t.dtsFile)??e.cwd,i=await Promise.all((t.includePaths??e.defaultIncludePaths).map(p=>qr(p,n,t.dtsFile))),s=await Promise.all((t.zephyrBindings??e.defaultZephyrBindings).map(p=>qr(p,n,t.dtsFile))),o=t.bindingType??e.defaultBindingType,a=await Promise.all((t.deviceOrgTreeBindings??e.defaultDeviceOrgTreeBindings).map(p=>qr(p,n,t.dtsFile))),c=await Promise.all((t.deviceOrgBindingsMetaSchema??e.defaultDeviceOrgBindingsMetaSchema).map(p=>qr(p,n,t.dtsFile))),l=await Promise.all((t.lockRenameEdits??e.defaultLockRenameEdits).map(p=>qr(p,n,t.dtsFile)));r&&o==="Zephyr"&&(!s||s.length===0)&&(s=["./zephyr/dts/bindings"]);let u=t.dtsFile,d=t.overlays??[],f=t.compileCommands;return r&&(s=s.map(p=>(0,sn.resolve)(r,p)).filter(p=>(0,nk.existsSync)(p)),a=a?.map(p=>(0,sn.resolve)(r,p)),c=c.map(p=>(0,sn.resolve)(r,p)),i=i.map(p=>(0,sn.resolve)(r,p)),u=(0,sn.resolve)(r,u),d=d.map(p=>(0,sn.resolve)(r,p)),l=l.map(p=>(0,sn.resolve)(r,p)),f=f?(0,sn.resolve)(r,f):void 0),{ctxName:t.ctxName??(0,sn.basename)(u),cwd:r?it(r):void 0,includePaths:i.map(it),zephyrBindings:s.map(it),bindingType:o,deviceOrgTreeBindings:a.map(it),deviceOrgBindingsMetaSchema:c.map(it),dtsFile:it(u),overlays:d.map(it),lockRenameEdits:l.map(it),compileCommands:f?it(f):void 0,showFormattingErrorAsDiagnostics:t.showFormattingErrorAsDiagnostics??e.defaultShowFormattingErrorAsDiagnostics,disableFileWatchers:t.disableFileWatchers??e.disableFileWatchers}},ju=async(t,e)=>{let n=t.cwd?await qr(t.cwd,e):void 0,r=t.defaultBindingType,i=t.defaultDeviceOrgBindingsMetaSchema=await Promise.all((t.defaultDeviceOrgBindingsMetaSchema??[]).map(d=>qr(d,e))),s=t.defaultDeviceOrgTreeBindings=await Promise.all((t.defaultDeviceOrgTreeBindings??[]).map(d=>qr(d,e))),o=t.defaultIncludePaths=await Promise.all((t.defaultIncludePaths??[]).map(d=>qr(d,e))),a=t.defaultZephyrBindings=await Promise.all((t.defaultZephyrBindings??[]).map(d=>qr(d,e))),c=t.defaultLockRenameEdits=await Promise.all((t.defaultLockRenameEdits??[]).map(d=>qr(d,e)));n&&(o=t.defaultIncludePaths=(t.defaultIncludePaths??[]).map(d=>(0,sn.resolve)(n,d)),r==="Zephyr"&&!t.defaultZephyrBindings&&(a=["./zephyr/dts/bindings"]),a=a.map(d=>(0,sn.resolve)(n,d)),i=i.map(d=>(0,sn.resolve)(n,d)),s=(t.defaultDeviceOrgTreeBindings??[]).map(d=>(0,sn.resolve)(n,d)),c=c.map(d=>(0,sn.resolve)(n,d)));let l={cwd:n,defaultDeviceOrgBindingsMetaSchema:i,defaultDeviceOrgTreeBindings:s,defaultIncludePaths:o,defaultZephyrBindings:a,defaultLockRenameEdits:c,defaultBindingType:r,autoChangeContext:t.autoChangeContext??Us.autoChangeContext,allowAdhocContexts:t.allowAdhocContexts??Us.allowAdhocContexts,defaultShowFormattingErrorAsDiagnostics:t.defaultShowFormattingErrorAsDiagnostics??Us.defaultShowFormattingErrorAsDiagnostics,disableFileWatchers:t.disableFileWatchers??!1},u=(await Promise.all(t.contexts?.map(d=>rk(d,l,e))??[])).filter(d=>[d.dtsFile,...d.overlays].every(f=>(0,nk.existsSync)(f)&&sn.default.isAbsolute(f)));return{...l,contexts:u}};var qF=t=>`DT_PROP(${ik(t.parent)}, ${t.name.replaceAll("-","_")}))`,$F=t=>t.parent.labels.map(e=>`DT_PROP(DT_NODELABEL(${e.label.toString()}), ${t.name.replaceAll("-","_")})`);var ik=t=>`DT_PATH(${t.path.slice(1).map(e=>e.replace("@","_").replaceAll("-","_")).join(",")})`,FF=t=>t.labels.map(e=>`DT_NODELABEL(${e.label.toString()})`),BF=t=>{let e=[];return gi.getNodeFromPath(["aliases"],t.root)?.properties.filter(i=>{if(i.ast.quickValues?.at(0)===t.pathString)return!0;let s=i.ast.values?.values.at(0)?.value;if(s instanceof ie&&s.linksTo===t||s instanceof ot&&s.path?.pathParts.at(-1)?.linksTo===t)return!0})?.forEach(i=>e.push(`DT_ALIAS(${i.name.replaceAll("-","_")})`)),e};function z6(t,e){if(!t||!(t.item instanceof Xe)||!(t.ast instanceof Ye))return[];let n=[];return e.settings.bindingType==="Zephyr"&&(n.push({type:"dt_zephyr_macro_prop_node_path",data:qF(t.item)}),$F(t.item).forEach(r=>{n.push({type:"dt_zephyr_macro_prop_node_label",data:r})})),n}function G6(t,e){if(!t||t.item===null)return[];let n;if(t.item instanceof X?n=t.item:t.ast.parentNode instanceof ie&&t.ast.parentNode.linksTo?n=t.ast.parentNode.linksTo:t.ast instanceof xe&&t.ast.linksTo&&(n=t.ast.linksTo),!n)return[];let r=[{type:"path",data:n.pathString}];return e.settings.bindingType==="Zephyr"&&(FF(n).forEach(i=>{r.push({type:"dt_zephyr_macro_node_label",data:i})}),r.push({type:"dt_zephyr_macro_node_path",data:ik(n)}),BF(n).forEach(i=>{r.push({type:"dt_zephyr_macro_prop_node_alias",data:i})})),r}async function jF(t,e){return e?Nt(t,e,n=>[...G6(n,e),...z6(n,e)]):[]}var UF=q(j());function K6(t){return!t||!(t.item instanceof Xe)?void 0:t.item.parent.nodeType?.getSignatureHelp?.(t.item,t.ast,t.beforeAst,t.afterAst)}async function Y6(t){let e=Hc(t?.ast);if(!e||!e.params.length||!t?.ast||t.ast===e.functionName)return;let r=(await t.runtime.context.getAllStableParsers()).at(-1).cPreprocessorParser.macros.get(e.functionName.name)?.macro.identifier;if(!r||!(r instanceof mi))return;let i=r.params.map(o=>({label:o instanceof pt?o.name:"..."})),s=e.params.find(o=>o&&(t.ast===o||o.isAncestorOf(t.ast)));return s??=t.afterAst?e.params.find(o=>o&&(t.afterAst===o||o.isAncestorOf(t.afterAst))):void 0,s??=t.beforeAst?e.params.find(o=>o&&(t.beforeAst===o||o.isAncestorOf(t.beforeAst))):void 0,{signatures:[UF.SignatureInformation.create(`${e.functionName.name}(${i.map(o=>o.label).join(", ")})`,void 0,...i.flat())],activeSignature:0,activeParameter:s?e.params.indexOf(s):void 0}}async function HF(t,e){if(e)return(await Nt(t,e,async n=>[await Y6(n)||K6(n)])).at(0)}var VF=require("timers"),WF=require("events");var sk=class extends WF.EventEmitter{constructor(e=3e3,n=1e3){super(),this.thresholdBytes=e*1024*1024,this.interval=(0,VF.setInterval)(()=>{let r=process.memoryUsage().heapUsed;r>this.thresholdBytes&&this.emit("thresholdExceeded",{usedMb:(r/1024/1024).toFixed(2),thresholdMb:e})},n)}stop(){clearInterval(this.interval)}},X6=new sk(3e3),zF=()=>{X6.on("thresholdExceeded",({usedMb:t,thresholdMb:e})=>{console.warn(`[HeapMonitor] Heap usage exceeded ${e}MB: ${t}MB used`),fD(),dD()})};var GF=t=>`0x${t.map((e,n)=>e.toString(16).padStart(n?8:0,"0")).join("")}`;function ok(t,e){let n=e.nodePath,r=e.labels.at(0),i=e.nodePath.split("/").pop()??e.nodePath,s=r?`${r} (${i})`:i,o=t.children.filter(c=>{let l=br(e.start,e.size),u=br(c.start,c.size),d=Lt(e.start,c.start)>=0,f=Lt(l,u)<=0,p=Lt(e.start,c.start)===0&&Lt(e.size,c.size)===0;return d&&f&&!p});if(o.length>0){let c=o.find(l=>n.startsWith(`${l.name}/`)||n===l.name);if(c){ok(c,e);return}for(let l of o)ok(l,e);return}let a=t.children.find(c=>c.name===s);a?(a.start=aE(a.start,e.start),a.size=cE(a.size,mT(br(e.start,e.size),a.start))):(a={name:s,start:e.start,size:e.size,children:[]},t.children.push(a))}function J6(t){let e={};for(let n of t){let r={name:n.name,children:[]};for(let i of n.partitions)ok(r,i);e[n.name]=r}return e}function KF(t,e="",n=!0){let r={};for(let d of t.children){let f=`${d.start}-${d.size}`;r[f]||(r[f]=[]),r[f].push(d)}let i="",s=e?n?"\u2514\u2500 ":"\u251C\u2500 ":"",o=[];"start"in t&&t.start&&o.push(`start: ${GF(t.start)}`),"size"in t&&t.size&&o.push(`size: ${GF(t.size)}`);let a=o.length>0?` [${o.join(", ")}]`:"",c=t.name;i+=`${e}${s}${c} ${a}
327
327
  `;let l=e+(n?" ":"\u2502 "),u=Object.keys(r);return u.forEach((d,f)=>{let p=r[d],m=Array.from(new Set(p.map(v=>v.name))).join(", "),h={};p.forEach(v=>{v.children.forEach(b=>{let P=`${b.start}-${b.size}-${b.name}`;h[P]=b})});let y=Object.values(h),_={name:m,start:p[0].start,size:p[0].size,children:y};i+=KF(_,l,f===u.length-1)}),i}function YF(t){return J6(t)}function XF(t){return Object.values(t).map(e=>KF(e)).join(`
328
- `)}var Ee=[],le,Hs,rg=new WeakMap,Uu=new Map;zF();var sg=new Map,QF=t=>{t.settings.disableFileWatchers||t.getContextFiles().forEach(e=>{Uu.has(e)||Uu.set(e,new ng(e,fk,()=>{let n=Ku(e),r=sg.get(e);return!n||r===void 0?!1:r!==n.version})),Uu.get(e)?.watch()})},uk=async t=>{let e=Ee.indexOf(t);if(e===-1)return;Vu(t,void 0,!0),rg.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let n=await Ws(t);if(Q.sendNotification("devicetree/contextDeleted",{ctxNames:t.ctxNames.map(r=>r.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:n.type}),Ee.splice(e,1),await mk(),t===le&&(le=void 0,Ee.length)){let r=Hs?vn(Ee,{fsPath:Hs}):void 0;r??=Ee[0],console.log("Active context was deleted. Forcing active to",r.id),await hn({id:r.id},!0)}t.settings.disableFileWatchers||t.getContextFiles().map(r=>{Uu.get(r)?.unwatch()}),setTimeout(async()=>{await Ce();let r=new Set(Ee.flatMap(i=>i.getContextFiles()));t.getContextFiles().map(i=>{r.has(i)||An().reset(i)})},2e3),t.bindingLoader?.dispose()},Q6=t=>{let e=rg.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},Ce=async()=>{await Promise.all(Ee.map(Q6))},dk=async(t,e)=>(await ZF(e)).indexOf(t)!==-1,ZF=async t=>{let e=await eB(t);return Ee.filter(n=>!e.some(r=>r===n))},eB=async t=>{let e=await lk(t);return Ee.filter(n=>e.contexts.find(r=>qi(r)===n.id))},Z6=async t=>{let e=await sQ(t);return Ee.filter(n=>e.contexts.find(r=>qi(r)===n.id))},eQ=async(t,e)=>(await Z6(e)).indexOf(t)!==-1,tQ=async(t,e)=>{if(t===e)return!0;let n=(await t.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath),r=(await e.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath);return r.some(i=>he(i.resolvedPath,t.parser.fsPath))&&n.length?n.every(i=>r.some(s=>s.resolvedPath===i.resolvedPath&&s.firstToken.pos.col===i.firstToken.pos.col&&s.firstToken.pos.len===i.firstToken.pos.len&&s.firstToken.pos.line===i.firstToken.pos.line&&s.lastToken.pos.col===i.lastToken.pos.col&&s.lastToken.pos.len===i.lastToken.pos.len&&s.lastToken.pos.line===i.lastToken.pos.line)):e.getContextFiles().some(i=>he(i,t.parser.fsPath))},nQ=async t=>{if(!await dk(t))return;let e=await ZF(),n=await eB(),r=await Lf(e);if(Ee.indexOf(t)===-1)return;let i=await Promise.all(r.flatMap(a=>[...n,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await tQ(a.context,c)})))),s=t.getContextFiles(),o=r.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==t&&he(a.context.parser.fsPath,t.parser.fsPath)&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&await Promise.all(o.map(uk))},Q=(0,Be.createConnection)(Be.ProposedFeatures.all),on=new Be.TextDocuments(Vn),tB=!1,ig=!1,nB=!1,rB=!1,iB=!1,ak;Q.onInitialize(async t=>{ak=t.workspaceFolders??[],Q.console.log(`[Server(${process.pid}) ${ak?.at(0)?.uri} Version 0.8.1 ] Started and initialize received`);let e=t.capabilities;tB=!!(e.workspace&&e.workspace.configuration),ig=!!(e.workspace&&e.workspace.workspaceFolders),nB=!!e.workspace?.diagnostics?.refreshSupport,rB=!!e.workspace?.semanticTokens?.refreshSupport,iB=!!e.workspace?.foldingRange?.refreshSupport;let n={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:Be.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[Be.CodeActionKind.QuickFix,Be.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:Df,tokenModifiers:Af},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,documentRangeFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return ig&&(n.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),await cB(t.initializationOptions),n});var ck,rQ={tabSize:8,insertSpaces:!1,trimTrailingWhitespace:!0,insertFinalNewline:!0,wordWrapColumn:100};Q.onInitialized(async()=>{if(tB&&(Q.client.register(Be.DidChangeConfigurationNotification.type,{}),!ck)){let t=await Q.workspace.getConfiguration("editor").catch(()=>{}),e=await Q.workspace.getConfiguration("[devicetree]").catch(()=>{}),n={tabSize:e?.["editor.tabSize"],insertSpaces:e?.["editor.insertSpaces"],trimFinalNewlines:e?.["editor.trimFinalNewlines"],trimTrailingWhitespace:e?.["editor.trimTrailingWhitespace"],insertFinalNewline:e?.["editor.insertFinalNewline"],wordWrapColumn:e?.["editor.wordWrapColumn"]};(t||n)&&(ck={...t,...n})}ig&&Q.workspace.onDidChangeWorkspaceFolders(async t=>{Q.console.log("Workspace folder change event received"),await Gu()})});Q.onRequest("workspace/workspaceFolders",async()=>ak??null);var iQ=async t=>{let e=sB();return e={...Us,...e},ju(e,t??await zu())},lk=async t=>{let e=aQ();return e={...Us,...e},ju(e,t??await zu())},sQ=async t=>{let e=cQ();return e={...Us,...e},ju(e,t??await zu())},Wu=async t=>{let e=oQ();return e={...Us,...e},ju(e,t??await zu())},zu=async()=>ig?await Q.workspace.getWorkspaceFolders()??[]:[],JF=async t=>{let e=vn(Ee,{id:qi(t)});if(e)return e.ctxNames.includes(t.ctxName)||console.log(`(ID: ${e.id}) Adding name ${t.ctxName} for [${e.ctxNames.join(",")}]`),e.addCtxName(t.ctxName),e;let n=qi(t);console.log(`(ID: ${n}) New context [${t.ctxName}]`),console.log(`(ID: ${n}) Settings: ${JSON.stringify(t,void 0," ")}`);let r=(0,gc.join)((0,gc.dirname)(t.dtsFile),"dts","bindings"),i=new ap(t,ck??rQ,t.bindingType?CF({zephyrBindings:t.zephyrBindings?[r,...t.zephyrBindings]:[r],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ee.push(i);let s=performance.now();await i.stable(),console.log(`(ID: ${n}) New context took ${performance.now()-s}ms to start [${t.ctxName}]`),QF(i);let o=await Ws(i);return Q.sendNotification("devicetree/contextCreated",{ctxNames:i.ctxNames.map(a=>a.toString()),id:i.id,...await i.getFileTree(),settings:i.settings,active:i===le,type:o.type}),await nQ(i),await mk(),i},Gu=async()=>{let t=await lk(),e=await Wu();e.allowAdhocContexts||(e=await lk());let n=e.contexts.map(qi),r=Ee.filter(i=>!n.includes(i.id));await Promise.all(r.map(uk)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await JF(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await iQ()).contexts?.reduce((s,o)=>s.then(async()=>{vn(Ee,{fsPath:o.dtsFile})||await JF(o)}),Promise.resolve()),setTimeout(async()=>{Hs?await hn({fsPath:Hs}):!le&&Ee.length&&(console.log(`No active context using first context (ID: ${Ee[0].id}) [${Ee[0].ctxNames.join(",")}]`),await hn({id:Ee[0].id}))})},$r,Vs,Hu=new Map,mc=new Map,oQ=()=>!Vs&&!$r?void 0:{...Vs,...$r,contexts:[...$r?.contexts??[],...Array.from(mc.values()),...Array.from(Hu.values())]},sB=()=>!Vs&&!$r?void 0:{...Vs,...$r,contexts:[...Array.from(Hu.values())]},aQ=()=>!Vs&&!$r?void 0:{...Vs,...$r,contexts:[...$r?.contexts??[],...Array.from(mc.values())]},cQ=()=>!Vs&&!$r?void 0:{...$r,contexts:[...$r?.contexts??[]]};function lQ(t){let e={...t};for(let n in e)e[n]===null&&delete e[n];return e}var oB=async()=>{let t=await Wu();console.log("Resolved settings",JSON.stringify(t,void 0," ")),Q.sendNotification("devicetree/settingsChanged",t),await Gu(),Ce().then(()=>{nB&&Q.languages.diagnostics.refresh()})},uQ=async()=>{let t=le?.getContextFiles();await Promise.all(Array.from(on.keys()).filter(zt).map(async e=>{t?.some(n=>he(n,Se(e)))||await Q.sendDiagnostics({uri:e,version:on.get(e)?.version,diagnostics:[{severity:Be.DiagnosticSeverity.Information,range:Be.Range.create(Be.Position.create(0,0),Be.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},fk=async t=>{let e=pT(Ee,t);if(e.length)e.sort((n,r)=>n===le?-1:r===le?1:0).forEach(n=>{rg.get(n)?.abort.abort(),le===n&&Q.sendNotification("devicetree/activeContextBusyNotification",n.id),Q.sendNotification("devicetree/contextBusyNotification",n.id);let r=new AbortController,i=new Promise(s=>{setTimeout(async()=>{if(n.setStaleFsPath(t),r.signal.aborted){console.log("Abort parsing due to new request"),s();return}let o=performance.now(),a=le===n,c=a?aB(n):[],l=n.getContextFiles();if(await n.reevaluate(t),QF(n),l.forEach(p=>Uu.get(p)?.unwatch()),a&&gk(n)?.length&&(pk(n).then(p=>{let m=p.items.map(h=>({uri:h.uri,version:h.version??void 0,diagnostics:h.items}));Vu(n,c.filter(h=>m.every(y=>y.uri!==h.uri))),m.forEach(h=>{Q.sendDiagnostics(h)}),Yu.set(n,!0)}),Hs)){let p=n.getFsPathParser(Hs);p&&setTimeout(()=>{p.latestSemanticTokensBuilt||Q.languages.semanticTokens.refresh()},50)}let[u,d]=await Promise.all([Ws(n),n.getFileTree()]),f={ctxNames:n.ctxNames.map(p=>p.toString()),id:n.id,...d,settings:n.settings,active:a,type:u.type};le===n&&Q.sendNotification("devicetree/activeContextStableNotification",f),Q.sendNotification("devicetree/contextStableNotification",f),s(),console.log("reevaluate",performance.now()-o)})});rg.set(n,{abort:r,promise:i})});else{if((await Wu()).allowAdhocContexts===!1)return;await Gu(),await hn({fsPath:t})}},dQ=t=>on.keys().find(e=>he(Se(e),t)),Ku=t=>{let e=dQ(t);if(e)return on.get(e)},aB=t=>t.getContextFiles().map(e=>({uri:ue(e),version:Ku(e)?.version,diagnostics:[]})),Yu=new WeakMap,Vu=async(t,e=aB(t),n=!1)=>{if(!n&&t!==le)return;let r=performance.now();await Promise.all(e.filter(i=>t===le||!le?.getContextFiles().some(s=>he(Se(i.uri),s))).map(i=>Q.sendDiagnostics({uri:i.uri,version:on.get(i.uri)?.version,diagnostics:[]}))),Yu.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-r)},pk=async t=>{await t.stable();let e=performance.now(),n=await t.getDiagnostics(),r=await Promise.all(t.getContextFiles().map(async i=>{let s=Ku(i),o=[];return s&&t.settings.showFormattingErrorAsDiagnostics&&o.push(...(await ho({textDocument:s,options:t.formattingOptions},s.getText(),"File Diagnostics").catch(()=>[])).map(a=>a.diagnostic())),{uri:ue(i),kind:Be.DocumentDiagnosticReportKind.Full,items:[...n.get(i)??[],...o],version:s?.version??null}}));return console.log(`(ID: ${t.id})`,"workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-e),{items:[...r]}},hk=async t=>{let{items:e}=await pk(t);e.map(n=>({uri:n.uri,version:n.version??void 0,diagnostics:n.items})).forEach(async n=>{Q.sendDiagnostics(n)}),Yu.set(t,!0)},mk=async()=>{let t=await Promise.all(Ee.map(e=>Ws(e)));console.log("======== Context List ========"),t.forEach(e=>{console.log(`(ID: ${e.ctx.id}) [${e.ctx.ctxNames.join(",")}]`,`[${e.type}]`,le===e.ctx?" [ACTIVE]":"")}),console.log("==============================")},Ws=async(t,e)=>{let n=await dk(t,e),r=!n&&await eQ(t,e);return{ctx:t,type:n?"Ad Hoc":r?"User":"3rd Party"}},hn=async(t,e=!1)=>{if("fsPath"in t){if(!zt(t.fsPath))return!1;Hs=t.fsPath,console.log("Active File Uri",Hs)}let n=await Wu();if(le&&!e&&!n.autoChangeContext||(await Ce(),!e&&le?.getContextFiles().find(o=>"fsPath"in t&&he(o,t.fsPath))))return!1;let r=le,i=vn(Ee,t),s=r!==i;return s&&(r&&Vu(r),le=i,i?(Ws(i).then(async o=>{let a=await i.getFileTree();!i||i!==le&&!Ee.includes(i)||Q.sendNotification("devicetree/newActiveContext",{ctxNames:i.ctxNames.map(c=>c.toString()),id:i.id,...a,settings:i.settings,active:le===i,type:o.type})}),gk(i)?.length&&hk(i),await mk()):Q.sendNotification("devicetree/newActiveContext",void 0)),iB&&Q.languages.foldingRange.refresh(),rB&&Q.languages.semanticTokens.refresh(),s},zt=t=>[".dts",".dtsi",".dtso",".overlay"].some(e=>t.endsWith(e));on.listen(Q);var gk=t=>t?.getContextFiles()?.filter(e=>Ku(e));on.onDidSave(t=>{sg.set(Se(t.document.uri),t.document.version)});on.onDidClose(async t=>{let e=Se(t.document.uri);if(!zt(e))return;sg.delete(e);let n=pT(Ee,e);if(n.length===0){Hu.delete(e),Q.sendDiagnostics({uri:t.document.uri,version:on.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(n.map(async r=>{!!gk(r)?.filter(s=>s!==e).length?le?.getContextFiles().some(s=>he(s,e))?le?.getContextFiles().some(s=>he(s,e))&&(await Vu(le),await hk(le)):Q.sendDiagnostics({uri:t.document.uri,version:on.get(t.document.uri)?.version,diagnostics:[]}):await dk(r)?(await uk(r),Hu.delete(r.settings.dtsFile)):Vu(r)}))});on.onDidOpen(async t=>{let e=Se(t.document.uri);if(!zt(e))return;sg.set(e,t.document.version),await Ce(),uQ();let n=vn(Ee,{fsPath:e});if(console.log("onDidOpen",n?.id,e),n)n!==le?await hn({id:n.id}):n===le&&(!Yu.get(n)||n.getContextFiles().some(r=>!he(r,e)))&&await hk(n);else{let r={ctxName:(0,gc.basename)(e),dtsFile:e};Hu.set(e,r),await fk(e)}});on.onDidChangeContent(async t=>{let e=Se(t.document.uri);if(!zt(e))return;let n=t.document.getText(),r=An();r.needsRenew(e,n)&&(console.log("Content changed",e),r.renewLexer(e,n),await fk(e))});var cB=async t=>{t?.settings?.devicetree&&($r=LF(lQ(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await oB())};Q.onDidChangeConfiguration(async t=>{await cB(t)});Q.listen();Q.languages.diagnostics.onWorkspace(async()=>{await Ce();let t=le;return t?pk(t).finally(()=>{Yu.set(t,!0)}):{items:[]}});Q.onDidChangeWatchedFiles(t=>{Q.console.log("We received a file change event")});Q.onCompletion(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return xA(t,le,on.get(t.textDocument.uri));if(!zt(e))return[];await Ce(),hn({fsPath:e});let n=$n(e);return n?[...await vD(t,n),...await c0(t,n)]:[]});Q.onCompletionResolve(t=>t);var $n=t=>{let e=sB();return vn(Ee,{fsPath:t},le,e?.preferredContext)};Q.onDocumentSymbol(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return[];await Ce();let n=$n(e);return n?n.getFsPathParser(e)?.getDocumentSymbols(e):[]});Q.onWorkspaceSymbol(async()=>{await Ce();let t=le;return t?(await t.getAllStableParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});Q.languages.semanticTokens.on(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return{data:[]};try{await Ce();let n=$n(e),r=new Be.SemanticTokensBuilder,i=n?.isInContext(e);return!n||!i?{data:[]}:((await n.getAllStableParsers()).forEach(s=>s.buildSemanticTokens(r,e)),r.build())}catch(n){throw console.log(n),n}});Q.onDocumentLinks(async t=>{await Ce();let e=Se(t.textDocument.uri);return zt(e)?$n(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&le?le.bindingLoader?.getDocumentLinks?.(on.get(t.textDocument.uri))??[]:[]});Q.onPrepareRename(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return jA(t,n)});Q.onRenameRequest(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return BA(t,n)});Q.onReferences(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return LA(t,n)});Q.onDefinition(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return VA(t,le,on.get(t.textDocument.uri));if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e),r=(await n?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>Be.Location.create(i.target,i.range))??[];return r.length?r:HA(t,n)});Q.onDeclaration(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return KA(t,le,on.get(t.textDocument.uri));if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return GA(t,n)});Q.onCodeAction(async t=>{let e=Se(t.textDocument.uri);if(zt(e))return XA(t)});var lB=async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);if(!n)return[];if((await n.getSyntaxIssues(void 0,l=>io(l.raw,e,!1)?l:void 0)).get(e)?.length)return[];let i=on.get(t.textDocument.uri)??An().getDocument(e),s=i.getText(),o=await ho(t,s,"New Text").catch(()=>s);if(o===s)return[];let a=i.lineCount-1,c=i.getText({start:{line:a,character:0},end:{line:a+1,character:0}}).length;return[Be.TextEdit.replace(Be.Range.create(Be.Position.create(0,0),Be.Position.create(i.lineCount,c)),o)]};Q.onDocumentRangeFormatting(lB);Q.onDocumentFormatting(lB);Q.onHover(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return AO(t,le,on.get(t.textDocument.uri));if(!zt(e))return;await Ce();let n=$n(e);return(await l0(t,n)).at(0)});Q.onFoldingRanges(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce();let n=$n(e),r=n?.isInContext(e);if(!n||!r)return[];let i=(await n.getAllStableParsers()).find(s=>s.getFiles().some(o=>o===e));return i?AF(e,i):[]});Q.onTypeDefinition(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return xF(t,n)});Q.onSignatureHelp(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return HF(t,n)});Q.onRequest("devicetree/getContexts",async()=>(await Ce(),Promise.all(Ee.map(async t=>{let e=await Ws(t);return{ctxNames:t.ctxNames.map(n=>n.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:e.type}}))));Q.onRequest("devicetree/setActive",async t=>(await Ce(),console.log("devicetree/setActive",t),await hn(t,!0)));Q.onRequest("devicetree/getActiveContext",async()=>{if(await Ce(),console.log("devicetree/getActiveContext"),!le)return;let t=await Ws(le);return le?{ctxNames:le.ctxNames.map(e=>e.toString()),id:le.id,...await le.getFileTree(),settings:le.settings,active:!0,type:t.type}:void 0});Q.onRequest("devicetree/setDefaultSettings",async t=>{await Ce(),Vs=t,console.log("Integration Settings",t),await oB()});Q.onRequest("devicetree/requestContext",async t=>{await Ce();let e=await zu(),n=await Wu(e),r=await rk(t,n,e);console.log("devicetree/requestContext",r);let i=qi(r),s=Array.from(mc).find(([,c])=>c.ctxName===t.ctxName);if(s){let c=s[0].split(":",1)[0];vn(Ee,{name:t.ctxName.toString()})?.removeCtxName(t.ctxName),console.log(`Removing integration context with ID ${c} and name ${t.ctxName}`),mc.delete(s[0])}mc.set(`${i}:${t.ctxName}`,t),await Gu();let o=Ee.find(c=>c.id===i);if(!o)throw new Error("Failed to create context");let a=await Ws(o,e);return{ctxNames:o.ctxNames.map(c=>c.toString()),id:i,...await o.getFileTree(),settings:o.settings,active:!0,type:a.type}});Q.onRequest("devicetree/removeContext",async({id:t,name:e})=>{await Ce(),mc.delete(`${t}:${e}`);let n=vn(Ee,{id:t});if(n){if(n.removeCtxName(e),n.ctxNames.length){console.log("Context will not be deleted as it is still in use by others");return}await Gu()}});Q.onRequest("devicetree/compiledDtsOutput",async t=>{if(await Ce(),!t)return;let e=vn(Ee,{id:t});if(!e)return;let n=await e.toFullString();return ho({textDocument:{uri:ue(e.settings.dtsFile)},options:e.formattingOptions},n,"New Text").catch(()=>n)});Q.onRequest("devicetree/serializedContext",async t=>{if(await Ce(),!t)return;let e=vn(Ee,{id:t}),n=performance.now();return e?.serialize().finally(()=>{console.info("serializedContext",performance.now()-n)})});Q.onRequest("devicetree/activePath",async t=>{if(await Ce(),!le)return;let e=n=>{if(n?.item)return n.item instanceof X?{nodePath:n.item.pathString}:{nodePath:n.item.parent.pathString,propertyName:n.item.name}};return(await Nt(t,le,n=>[e(n)])).at(0)});Q.onRequest("devicetree/customActions",async t=>(await Ce(),jF(t,le)));Q.onRequest("devicetree/activeFsPath",async t=>{await Ce(),hn({fsPath:t})});Q.onRequest("devicetree/formattingText",async t=>{let e=Se(t.textDocument.uri),n=Ku(e)??An().getDocument(e,t.text),r=await ho(t,n.getText(),"Both");return{text:r.text,diagnostics:r.diagnostic.map(i=>i.diagnostic())}});Q.onRequest("devicetree/formatTextEdits",async t=>{await Ce();let e=An().getDocument(Se(t.textDocument.uri),t.text),n=e.positionAt(e.getText().length),r=Be.TextEdit.replace(Be.Range.create(Be.Position.create(0,0),n),""),i=ds(e,t.edits),o=await ho({...t,ranges:void 0},i,"New Text").catch(()=>i);return r.newText=o,r});Q.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await Ce();let n=Se(t);hn({fsPath:n});let r=$n(n);if(!r)return[];let i=e?(await r.getDiagnostics()).get(n):(await r.getSyntaxIssues(void 0,s=>io(s.raw,n,!!e)?s:void 0)).get(n);if(i?.length)return i});Q.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await Ce();let n=vn(Ee,{id:e});return n?t.map(r=>{let i=$c(r,n.macros),s=De(i);return{macro:r,evaluated:typeof s=="number"?s:i}}):[]});Q.onRequest("devicetree/memoryViews",async({ctxId:t})=>{let e=vn(Ee,{id:t});if(!e)return;await e?.stable();let n=await e.getRuntime(),r=n.rootNode.getMemoryViews(n.context.macros).sort((o,a)=>Lt(o.start,a.start)),i=new Map;r.forEach(o=>{let a=i.get(o.name),c={nodePath:o.nodePath,labels:o.labels,start:o.start,size:o.size};a?a.partitions.push(c):i.set(o.name,{name:o.name,partitions:[c]})});let s=YF(Array.from(i.values()));return{trees:s,treeStr:XF(s)}});Q.onRequest("devicetree/zephyrTypeBindings",async t=>(await Ce(),t?vn(Ee,{id:t})?.bindingLoader?.getZephyrContextBinding():void 0));Q.onRequest("devicetree/contextMacroNames",async t=>{if(await Ce(),!t)return;let e=vn(Ee,{id:t});return Array.from(e?.macros.keys()??[])});Q.onRequest("devicetree/locationScopedInformation",async t=>{await Ce();let e=vn(Ee,{id:t.id}),n=Se(t.textDocument.uri);if(!(!e||!e.isInContext(n)))return new Promise(async r=>{let i=await e.getRuntime(),s=await Nt(t,e,(o,a)=>{let c=i.context.macros,l={};if(!o?.item)return i.rootNode.serialize(l,c,a),[{inNode:!1,inScope:l,parentNode:i.rootNode.pathString}];let u=null;return o.item instanceof X?u=o.item:u=o.item?.parent,u.serialize(l,i.context.macros,a),[{inNode:!0,inScope:l,parentNode:u.pathString}]});r(s[0])})});
328
+ `)}var Ee=[],le,Hs,rg=new WeakMap,Uu=new Map;zF();var sg=new Map,QF=t=>{t.settings.disableFileWatchers||t.getContextFiles().forEach(e=>{Uu.has(e)||Uu.set(e,new ng(e,fk,()=>{let n=Ku(e),r=sg.get(e);return!n||r===void 0?!1:r!==n.version})),Uu.get(e)?.watch()})},uk=async t=>{let e=Ee.indexOf(t);if(e===-1)return;Vu(t,void 0,!0),rg.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let n=await Ws(t);if(Q.sendNotification("devicetree/contextDeleted",{ctxNames:t.ctxNames.map(r=>r.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:n.type}),Ee.splice(e,1),await mk(),t===le&&(le=void 0,Ee.length)){let r=Hs?vn(Ee,{fsPath:Hs}):void 0;r??=Ee[0],console.log("Active context was deleted. Forcing active to",r.id),await hn({id:r.id},!0)}t.settings.disableFileWatchers||t.getContextFiles().map(r=>{Uu.get(r)?.unwatch()}),setTimeout(async()=>{await Ce();let r=new Set(Ee.flatMap(i=>i.getContextFiles()));t.getContextFiles().map(i=>{r.has(i)||An().reset(i)})},2e3),t.bindingLoader?.dispose()},Q6=t=>{let e=rg.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},Ce=async()=>{await Promise.all(Ee.map(Q6))},dk=async(t,e)=>(await ZF(e)).indexOf(t)!==-1,ZF=async t=>{let e=await eB(t);return Ee.filter(n=>!e.some(r=>r===n))},eB=async t=>{let e=await lk(t);return Ee.filter(n=>e.contexts.find(r=>qi(r)===n.id))},Z6=async t=>{let e=await sQ(t);return Ee.filter(n=>e.contexts.find(r=>qi(r)===n.id))},eQ=async(t,e)=>(await Z6(e)).indexOf(t)!==-1,tQ=async(t,e)=>{if(t===e)return!0;let n=(await t.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath),r=(await e.getAllStableParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath);return r.some(i=>pe(i.resolvedPath,t.parser.fsPath))&&n.length?n.every(i=>r.some(s=>s.resolvedPath===i.resolvedPath&&s.firstToken.pos.col===i.firstToken.pos.col&&s.firstToken.pos.len===i.firstToken.pos.len&&s.firstToken.pos.line===i.firstToken.pos.line&&s.lastToken.pos.col===i.lastToken.pos.col&&s.lastToken.pos.len===i.lastToken.pos.len&&s.lastToken.pos.line===i.lastToken.pos.line)):e.getContextFiles().some(i=>pe(i,t.parser.fsPath))},nQ=async t=>{if(!await dk(t))return;let e=await ZF(),n=await eB(),r=await Lf(e);if(Ee.indexOf(t)===-1)return;let i=await Promise.all(r.flatMap(a=>[...n,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await tQ(a.context,c)})))),s=t.getContextFiles(),o=r.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==t&&pe(a.context.parser.fsPath,t.parser.fsPath)&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&await Promise.all(o.map(uk))},Q=(0,Be.createConnection)(Be.ProposedFeatures.all),on=new Be.TextDocuments(Vn),tB=!1,ig=!1,nB=!1,rB=!1,iB=!1,ak;Q.onInitialize(async t=>{ak=t.workspaceFolders??[],Q.console.log(`[Server(${process.pid}) ${ak?.at(0)?.uri} Version 0.8.3 ] Started and initialize received`);let e=t.capabilities;tB=!!(e.workspace&&e.workspace.configuration),ig=!!(e.workspace&&e.workspace.workspaceFolders),nB=!!e.workspace?.diagnostics?.refreshSupport,rB=!!e.workspace?.semanticTokens?.refreshSupport,iB=!!e.workspace?.foldingRange?.refreshSupport;let n={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:Be.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[Be.CodeActionKind.QuickFix,Be.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:Df,tokenModifiers:Af},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,documentRangeFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return ig&&(n.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),await cB(t.initializationOptions),n});var ck,rQ={tabSize:8,insertSpaces:!1,trimTrailingWhitespace:!0,insertFinalNewline:!0,wordWrapColumn:100};Q.onInitialized(async()=>{if(tB&&(Q.client.register(Be.DidChangeConfigurationNotification.type,{}),!ck)){let t=await Q.workspace.getConfiguration("editor").catch(()=>{}),e=await Q.workspace.getConfiguration("[devicetree]").catch(()=>{}),n={tabSize:e?.["editor.tabSize"],insertSpaces:e?.["editor.insertSpaces"],trimFinalNewlines:e?.["editor.trimFinalNewlines"],trimTrailingWhitespace:e?.["editor.trimTrailingWhitespace"],insertFinalNewline:e?.["editor.insertFinalNewline"],wordWrapColumn:e?.["editor.wordWrapColumn"]};(t||n)&&(ck={...t,...n})}ig&&Q.workspace.onDidChangeWorkspaceFolders(async t=>{Q.console.log("Workspace folder change event received"),await Gu()})});Q.onRequest("workspace/workspaceFolders",async()=>ak??null);var iQ=async t=>{let e=sB();return e={...Us,...e},ju(e,t??await zu())},lk=async t=>{let e=aQ();return e={...Us,...e},ju(e,t??await zu())},sQ=async t=>{let e=cQ();return e={...Us,...e},ju(e,t??await zu())},Wu=async t=>{let e=oQ();return e={...Us,...e},ju(e,t??await zu())},zu=async()=>ig?await Q.workspace.getWorkspaceFolders()??[]:[],JF=async t=>{let e=vn(Ee,{id:qi(t)});if(e)return e.ctxNames.includes(t.ctxName)||console.log(`(ID: ${e.id}) Adding name ${t.ctxName} for [${e.ctxNames.join(",")}]`),e.addCtxName(t.ctxName),e;let n=qi(t);console.log(`(ID: ${n}) New context [${t.ctxName}]`),console.log(`(ID: ${n}) Settings: ${JSON.stringify(t,void 0," ")}`);let r=(0,gc.join)((0,gc.dirname)(t.dtsFile),"dts","bindings"),i=new ap(t,ck??rQ,t.bindingType?CF({zephyrBindings:t.zephyrBindings?[r,...t.zephyrBindings]:[r],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ee.push(i);let s=performance.now();await i.stable(),console.log(`(ID: ${n}) New context took ${performance.now()-s}ms to start [${t.ctxName}]`),QF(i);let o=await Ws(i);return Q.sendNotification("devicetree/contextCreated",{ctxNames:i.ctxNames.map(a=>a.toString()),id:i.id,...await i.getFileTree(),settings:i.settings,active:i===le,type:o.type}),await nQ(i),await mk(),i},Gu=async()=>{let t=await lk(),e=await Wu();e.allowAdhocContexts||(e=await lk());let n=e.contexts.map(qi),r=Ee.filter(i=>!n.includes(i.id));await Promise.all(r.map(uk)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await JF(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await iQ()).contexts?.reduce((s,o)=>s.then(async()=>{vn(Ee,{fsPath:o.dtsFile})||await JF(o)}),Promise.resolve()),setTimeout(async()=>{Hs?await hn({fsPath:Hs}):!le&&Ee.length&&(console.log(`No active context using first context (ID: ${Ee[0].id}) [${Ee[0].ctxNames.join(",")}]`),await hn({id:Ee[0].id}))})},$r,Vs,Hu=new Map,mc=new Map,oQ=()=>!Vs&&!$r?void 0:{...Vs,...$r,contexts:[...$r?.contexts??[],...Array.from(mc.values()),...Array.from(Hu.values())]},sB=()=>!Vs&&!$r?void 0:{...Vs,...$r,contexts:[...Array.from(Hu.values())]},aQ=()=>!Vs&&!$r?void 0:{...Vs,...$r,contexts:[...$r?.contexts??[],...Array.from(mc.values())]},cQ=()=>!Vs&&!$r?void 0:{...$r,contexts:[...$r?.contexts??[]]};function lQ(t){let e={...t};for(let n in e)e[n]===null&&delete e[n];return e}var oB=async()=>{let t=await Wu();console.log("Resolved settings",JSON.stringify(t,void 0," ")),Q.sendNotification("devicetree/settingsChanged",t),await Gu(),Ce().then(()=>{nB&&Q.languages.diagnostics.refresh()})},uQ=async()=>{let t=le?.getContextFiles();await Promise.all(Array.from(on.keys()).filter(zt).map(async e=>{t?.some(n=>pe(n,Se(e)))||await Q.sendDiagnostics({uri:e,version:on.get(e)?.version,diagnostics:[{severity:Be.DiagnosticSeverity.Information,range:Be.Range.create(Be.Position.create(0,0),Be.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},fk=async t=>{let e=pT(Ee,t);if(e.length)e.sort((n,r)=>n===le?-1:r===le?1:0).forEach(n=>{rg.get(n)?.abort.abort(),le===n&&Q.sendNotification("devicetree/activeContextBusyNotification",n.id),Q.sendNotification("devicetree/contextBusyNotification",n.id);let r=new AbortController,i=new Promise(s=>{setTimeout(async()=>{if(n.setStaleFsPath(t),r.signal.aborted){console.log("Abort parsing due to new request"),s();return}let o=performance.now(),a=le===n,c=a?aB(n):[],l=n.getContextFiles();if(await n.reevaluate(t),QF(n),l.forEach(p=>Uu.get(p)?.unwatch()),a&&gk(n)?.length&&(pk(n).then(p=>{let m=p.items.map(h=>({uri:h.uri,version:h.version??void 0,diagnostics:h.items}));Vu(n,c.filter(h=>m.every(y=>y.uri!==h.uri))),m.forEach(h=>{Q.sendDiagnostics(h)}),Yu.set(n,!0)}),Hs)){let p=n.getFsPathParser(Hs);p&&setTimeout(()=>{p.latestSemanticTokensBuilt||Q.languages.semanticTokens.refresh()},50)}let[u,d]=await Promise.all([Ws(n),n.getFileTree()]),f={ctxNames:n.ctxNames.map(p=>p.toString()),id:n.id,...d,settings:n.settings,active:a,type:u.type};le===n&&Q.sendNotification("devicetree/activeContextStableNotification",f),Q.sendNotification("devicetree/contextStableNotification",f),s(),console.log("reevaluate",performance.now()-o)})});rg.set(n,{abort:r,promise:i})});else{if((await Wu()).allowAdhocContexts===!1)return;await Gu(),await hn({fsPath:t})}},dQ=t=>on.keys().find(e=>pe(Se(e),t)),Ku=t=>{let e=dQ(t);if(e)return on.get(e)},aB=t=>t.getContextFiles().map(e=>({uri:ue(e),version:Ku(e)?.version,diagnostics:[]})),Yu=new WeakMap,Vu=async(t,e=aB(t),n=!1)=>{if(!n&&t!==le)return;let r=performance.now();await Promise.all(e.filter(i=>t===le||!le?.getContextFiles().some(s=>pe(Se(i.uri),s))).map(i=>Q.sendDiagnostics({uri:i.uri,version:on.get(i.uri)?.version,diagnostics:[]}))),Yu.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-r)},pk=async t=>{await t.stable();let e=performance.now(),n=await t.getDiagnostics(),r=await Promise.all(t.getContextFiles().map(async i=>{let s=Ku(i),o=[];return s&&t.settings.showFormattingErrorAsDiagnostics&&o.push(...(await ho({textDocument:s,options:t.formattingOptions},s.getText(),"File Diagnostics").catch(()=>[])).map(a=>a.diagnostic())),{uri:ue(i),kind:Be.DocumentDiagnosticReportKind.Full,items:[...n.get(i)??[],...o],version:s?.version??null}}));return console.log(`(ID: ${t.id})`,"workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-e),{items:[...r]}},hk=async t=>{let{items:e}=await pk(t);e.map(n=>({uri:n.uri,version:n.version??void 0,diagnostics:n.items})).forEach(async n=>{Q.sendDiagnostics(n)}),Yu.set(t,!0)},mk=async()=>{let t=await Promise.all(Ee.map(e=>Ws(e)));console.log("======== Context List ========"),t.forEach(e=>{console.log(`(ID: ${e.ctx.id}) [${e.ctx.ctxNames.join(",")}]`,`[${e.type}]`,le===e.ctx?" [ACTIVE]":"")}),console.log("==============================")},Ws=async(t,e)=>{let n=await dk(t,e),r=!n&&await eQ(t,e);return{ctx:t,type:n?"Ad Hoc":r?"User":"3rd Party"}},hn=async(t,e=!1)=>{if("fsPath"in t){if(!zt(t.fsPath))return!1;Hs=t.fsPath,console.log("Active File Uri",Hs)}let n=await Wu();if(le&&!e&&!n.autoChangeContext||(await Ce(),!e&&le?.getContextFiles().find(o=>"fsPath"in t&&pe(o,t.fsPath))))return!1;let r=le,i=vn(Ee,t),s=r!==i;return s&&(r&&Vu(r),le=i,i?(Ws(i).then(async o=>{let a=await i.getFileTree();!i||i!==le&&!Ee.includes(i)||Q.sendNotification("devicetree/newActiveContext",{ctxNames:i.ctxNames.map(c=>c.toString()),id:i.id,...a,settings:i.settings,active:le===i,type:o.type})}),gk(i)?.length&&hk(i),await mk()):Q.sendNotification("devicetree/newActiveContext",void 0)),iB&&Q.languages.foldingRange.refresh(),rB&&Q.languages.semanticTokens.refresh(),s},zt=t=>[".dts",".dtsi",".dtso",".overlay"].some(e=>t.endsWith(e));on.listen(Q);var gk=t=>t?.getContextFiles()?.filter(e=>Ku(e));on.onDidSave(t=>{sg.set(Se(t.document.uri),t.document.version)});on.onDidClose(async t=>{let e=Se(t.document.uri);if(!zt(e))return;sg.delete(e);let n=pT(Ee,e);if(n.length===0){Hu.delete(e),Q.sendDiagnostics({uri:t.document.uri,version:on.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(n.map(async r=>{!!gk(r)?.filter(s=>s!==e).length?le?.getContextFiles().some(s=>pe(s,e))?le?.getContextFiles().some(s=>pe(s,e))&&(await Vu(le),await hk(le)):Q.sendDiagnostics({uri:t.document.uri,version:on.get(t.document.uri)?.version,diagnostics:[]}):await dk(r)?(await uk(r),Hu.delete(r.settings.dtsFile)):Vu(r)}))});on.onDidOpen(async t=>{let e=Se(t.document.uri);if(!zt(e))return;sg.set(e,t.document.version),await Ce(),uQ();let n=vn(Ee,{fsPath:e});if(console.log("onDidOpen",n?.id,e),n)n!==le?await hn({id:n.id}):n===le&&(!Yu.get(n)||n.getContextFiles().some(r=>!pe(r,e)))&&await hk(n);else{let r={ctxName:(0,gc.basename)(e),dtsFile:e};Hu.set(e,r),await fk(e)}});on.onDidChangeContent(async t=>{let e=Se(t.document.uri);if(!zt(e))return;let n=t.document.getText(),r=An();r.needsRenew(e,n)&&(console.log("Content changed",e),r.renewLexer(e,n),await fk(e))});var cB=async t=>{t?.settings?.devicetree&&($r=LF(lQ(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await oB())};Q.onDidChangeConfiguration(async t=>{await cB(t)});Q.listen();Q.languages.diagnostics.onWorkspace(async()=>{await Ce();let t=le;return t?pk(t).finally(()=>{Yu.set(t,!0)}):{items:[]}});Q.onDidChangeWatchedFiles(t=>{Q.console.log("We received a file change event")});Q.onCompletion(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return xA(t,le,on.get(t.textDocument.uri));if(!zt(e))return[];await Ce(),hn({fsPath:e});let n=$n(e);return n?[...await vD(t,n),...await c0(t,n)]:[]});Q.onCompletionResolve(t=>t);var $n=t=>{let e=sB();return vn(Ee,{fsPath:t},le,e?.preferredContext)};Q.onDocumentSymbol(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return[];await Ce();let n=$n(e);return n?n.getFsPathParser(e)?.getDocumentSymbols(e):[]});Q.onWorkspaceSymbol(async()=>{await Ce();let t=le;return t?(await t.getAllStableParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});Q.languages.semanticTokens.on(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return{data:[]};try{await Ce();let n=$n(e),r=new Be.SemanticTokensBuilder,i=n?.isInContext(e);return!n||!i?{data:[]}:((await n.getAllStableParsers()).forEach(s=>s.buildSemanticTokens(r,e)),r.build())}catch(n){throw console.log(n),n}});Q.onDocumentLinks(async t=>{await Ce();let e=Se(t.textDocument.uri);return zt(e)?$n(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&le?le.bindingLoader?.getDocumentLinks?.(on.get(t.textDocument.uri))??[]:[]});Q.onPrepareRename(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return jA(t,n)});Q.onRenameRequest(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return BA(t,n)});Q.onReferences(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return LA(t,n)});Q.onDefinition(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return VA(t,le,on.get(t.textDocument.uri));if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e),r=(await n?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>Be.Location.create(i.target,i.range))??[];return r.length?r:HA(t,n)});Q.onDeclaration(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return KA(t,le,on.get(t.textDocument.uri));if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return GA(t,n)});Q.onCodeAction(async t=>{let e=Se(t.textDocument.uri);if(zt(e))return XA(t)});var lB=async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);if(!n)return[];if((await n.getSyntaxIssues(void 0,l=>io(l.raw,e,!1)?l:void 0)).get(e)?.length)return[];let i=on.get(t.textDocument.uri)??An().getDocument(e),s=i.getText(),o=await ho(t,s,"New Text").catch(()=>s);if(o===s)return[];let a=i.lineCount-1,c=i.getText({start:{line:a,character:0},end:{line:a+1,character:0}}).length;return[Be.TextEdit.replace(Be.Range.create(Be.Position.create(0,0),Be.Position.create(i.lineCount,c)),o)]};Q.onDocumentRangeFormatting(lB);Q.onDocumentFormatting(lB);Q.onHover(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return AO(t,le,on.get(t.textDocument.uri));if(!zt(e))return;await Ce();let n=$n(e);return(await l0(t,n)).at(0)});Q.onFoldingRanges(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce();let n=$n(e),r=n?.isInContext(e);if(!n||!r)return[];let i=(await n.getAllStableParsers()).find(s=>s.getFiles().some(o=>o===e));return i?AF(e,i):[]});Q.onTypeDefinition(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return xF(t,n)});Q.onSignatureHelp(async t=>{let e=Se(t.textDocument.uri);if(!zt(e))return;await Ce(),hn({fsPath:e});let n=$n(e);return HF(t,n)});Q.onRequest("devicetree/getContexts",async()=>(await Ce(),Promise.all(Ee.map(async t=>{let e=await Ws(t);return{ctxNames:t.ctxNames.map(n=>n.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:le===t,type:e.type}}))));Q.onRequest("devicetree/setActive",async t=>(await Ce(),console.log("devicetree/setActive",t),await hn(t,!0)));Q.onRequest("devicetree/getActiveContext",async()=>{if(await Ce(),console.log("devicetree/getActiveContext"),!le)return;let t=await Ws(le);return le?{ctxNames:le.ctxNames.map(e=>e.toString()),id:le.id,...await le.getFileTree(),settings:le.settings,active:!0,type:t.type}:void 0});Q.onRequest("devicetree/setDefaultSettings",async t=>{await Ce(),Vs=t,console.log("Integration Settings",t),await oB()});Q.onRequest("devicetree/requestContext",async t=>{await Ce();let e=await zu(),n=await Wu(e),r=await rk(t,n,e);console.log("devicetree/requestContext",r);let i=qi(r),s=Array.from(mc).find(([,c])=>c.ctxName===t.ctxName);if(s){let c=s[0].split(":",1)[0];vn(Ee,{name:t.ctxName.toString()})?.removeCtxName(t.ctxName),console.log(`Removing integration context with ID ${c} and name ${t.ctxName}`),mc.delete(s[0])}mc.set(`${i}:${t.ctxName}`,t),await Gu();let o=Ee.find(c=>c.id===i);if(!o)throw new Error("Failed to create context");let a=await Ws(o,e);return{ctxNames:o.ctxNames.map(c=>c.toString()),id:i,...await o.getFileTree(),settings:o.settings,active:!0,type:a.type}});Q.onRequest("devicetree/removeContext",async({id:t,name:e})=>{await Ce(),mc.delete(`${t}:${e}`);let n=vn(Ee,{id:t});if(n){if(n.removeCtxName(e),n.ctxNames.length){console.log("Context will not be deleted as it is still in use by others");return}await Gu()}});Q.onRequest("devicetree/compiledDtsOutput",async t=>{if(await Ce(),!t)return;let e=vn(Ee,{id:t});if(!e)return;let n=await e.toFullString();return ho({textDocument:{uri:ue(e.settings.dtsFile)},options:e.formattingOptions},n,"New Text").catch(()=>n)});Q.onRequest("devicetree/serializedContext",async t=>{if(await Ce(),!t)return;let e=vn(Ee,{id:t}),n=performance.now();return e?.serialize().finally(()=>{console.info("serializedContext",performance.now()-n)})});Q.onRequest("devicetree/activePath",async t=>{if(await Ce(),!le)return;let e=n=>{if(n?.item)return n.item instanceof X?{nodePath:n.item.pathString}:{nodePath:n.item.parent.pathString,propertyName:n.item.name}};return(await Nt(t,le,n=>[e(n)])).at(0)});Q.onRequest("devicetree/customActions",async t=>(await Ce(),jF(t,le)));Q.onRequest("devicetree/activeFsPath",async t=>{await Ce(),hn({fsPath:t})});Q.onRequest("devicetree/formattingText",async t=>{let e=Se(t.textDocument.uri),n=Ku(e)??An().getDocument(e,t.text),r=await ho(t,n.getText(),"Both");return{text:r.text,diagnostics:r.diagnostic.map(i=>i.diagnostic())}});Q.onRequest("devicetree/formatTextEdits",async t=>{await Ce();let e=An().getDocument(Se(t.textDocument.uri),t.text),n=e.positionAt(e.getText().length),r=Be.TextEdit.replace(Be.Range.create(Be.Position.create(0,0),n),""),i=ds(e,t.edits),o=await ho({...t,ranges:void 0},i,"New Text").catch(()=>i);return r.newText=o,r});Q.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await Ce();let n=Se(t);hn({fsPath:n});let r=$n(n);if(!r)return[];let i=e?(await r.getDiagnostics()).get(n):(await r.getSyntaxIssues(void 0,s=>io(s.raw,n,!!e)?s:void 0)).get(n);if(i?.length)return i});Q.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await Ce();let n=vn(Ee,{id:e});return n?t.map(r=>{let i=$c(r,n.macros),s=De(i);return{macro:r,evaluated:typeof s=="number"?s:i}}):[]});Q.onRequest("devicetree/memoryViews",async({ctxId:t})=>{let e=vn(Ee,{id:t});if(!e)return;await e?.stable();let n=await e.getRuntime(),r=n.rootNode.getMemoryViews(n.context.macros).sort((o,a)=>Lt(o.start,a.start)),i=new Map;r.forEach(o=>{let a=i.get(o.name),c={nodePath:o.nodePath,labels:o.labels,start:o.start,size:o.size};a?a.partitions.push(c):i.set(o.name,{name:o.name,partitions:[c]})});let s=YF(Array.from(i.values()));return{trees:s,treeStr:XF(s)}});Q.onRequest("devicetree/zephyrTypeBindings",async t=>(await Ce(),t?vn(Ee,{id:t})?.bindingLoader?.getZephyrContextBinding():void 0));Q.onRequest("devicetree/contextMacroNames",async t=>{if(await Ce(),!t)return;let e=vn(Ee,{id:t});return Array.from(e?.macros.keys()??[])});Q.onRequest("devicetree/locationScopedInformation",async t=>{await Ce();let e=vn(Ee,{id:t.id}),n=Se(t.textDocument.uri);if(!(!e||!e.isInContext(n)))return new Promise(async r=>{let i=await e.getRuntime(),s=await Nt(t,e,(o,a)=>{let c=i.context.macros,l={};if(!o?.item)return i.rootNode.serialize(l,c,a),[{inNode:!1,inScope:l,parentNode:i.rootNode.pathString}];let u=null;return o.item instanceof X?u=o.item:u=o.item?.parent,u.serialize(l,i.context.macros,a),[{inNode:!0,inScope:l,parentNode:u.pathString}]});r(s[0])})});