devicetree-language-server 0.8.6 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_LICENSES.txt +1 -1
- package/dist/server.js +11 -11
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -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 T3({gen:t,parentData:e,parentDataProperty:n},r){t.if((0,_e._)`${e} !== undefined`,()=>t.assign((0,_e._)`${e}[${n}]`,r))}function N_(t,e,n,r=ac.Correct){let i=r===ac.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===ac.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)}}In.checkDataType=N_;function R_(t,e,n,r){if(t.length===1)return N_(t[0],e,n,r);let i,s=(0,H1.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,N_(o,e,n,r));return i}In.checkDataTypes=R_;var v3={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,_e._)`{type: ${t}}`:(0,_e._)`{type: ${e}}`};function w_(t){let e=b3(t);(0,p3.reportError)(e,v3)}In.reportTypeError=w_;function b3(t){let{gen:e,data:n,schema:r}=t,i=(0,H1.schemaRefOrVal)(t,r,"type");return{gen:e,keyword:"type",data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:t}}});var G1=N(Am=>{"use strict";Object.defineProperty(Am,"__esModule",{value:!0});Am.assignDefaults=void 0;var cc=be(),_3=De();function S3(t,e){let{properties:n,items:r}=t.schema;if(e==="object"&&n)for(let i in n)z1(t,i,n[i].default);else e==="array"&&Array.isArray(r)&&r.forEach((i,s)=>z1(t,s,i.default))}Am.assignDefaults=S3;function z1(t,e,n){let{gen:r,compositeRule:i,data:s,opts:o}=t;if(n===void 0)return;let a=(0,cc._)`${s}${(0,cc.getProperty)(e)}`;if(i){(0,_3.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,cc._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,cc._)`${c} || ${a} === null || ${a} === ""`),r.if(c,(0,cc._)`${a} = ${(0,cc.stringify)(n)}`)}});var Br=N(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.validateUnion=st.validateArray=st.usePattern=st.callValidateCode=st.schemaProperties=st.allSchemaProperties=st.noPropertyInData=st.propertyInData=st.isOwnProperty=st.hasPropFunc=st.reportMissingProp=st.checkMissingProp=st.checkReportMissingProp=void 0;var kt=be(),E_=De(),Bs=Fr(),k3=De();function P3(t,e){let{gen:n,data:r,it:i}=t;n.if(D_(n,r,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,kt._)`${e}`},!0),t.error()})}st.checkReportMissingProp=P3;function N3({gen:t,data:e,it:{opts:n}},r,i){return(0,kt.or)(...r.map(s=>(0,kt.and)(D_(t,e,s,n.ownProperties),(0,kt._)`${i} = ${s}`)))}st.checkMissingProp=N3;function R3(t,e){t.setParams({missingProperty:e},!0),t.error()}st.reportMissingProp=R3;function K1(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,kt._)`Object.prototype.hasOwnProperty`})}st.hasPropFunc=K1;function C_(t,e,n){return(0,kt._)`${K1(t)}.call(${e}, ${n})`}st.isOwnProperty=C_;function w3(t,e,n,r){let i=(0,kt._)`${e}${(0,kt.getProperty)(n)} !== undefined`;return r?(0,kt._)`${i} && ${C_(t,e,n)}`:i}st.propertyInData=w3;function D_(t,e,n,r){let i=(0,kt._)`${e}${(0,kt.getProperty)(n)} === undefined`;return r?(0,kt.or)(i,(0,kt.not)(C_(t,e,n))):i}st.noPropertyInData=D_;function Y1(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}st.allSchemaProperties=Y1;function E3(t,e){return Y1(e).filter(n=>!(0,E_.alwaysValidSchema)(t,e[n]))}st.schemaProperties=E3;function C3({schemaCode:t,data:e,it:{gen:n,topSchemaRef:r,schemaPath:i,errorPath:s},it:o},a,c,l){let u=l?(0,kt._)`${t}, ${e}, ${r}${i}`:e,d=[[Bs.default.instancePath,(0,kt.strConcat)(Bs.default.instancePath,s)],[Bs.default.parentData,o.parentData],[Bs.default.parentDataProperty,o.parentDataProperty],[Bs.default.rootData,Bs.default.rootData]];o.opts.dynamicRef&&d.push([Bs.default.dynamicAnchors,Bs.default.dynamicAnchors]);let f=(0,kt._)`${u}, ${n.object(...d)}`;return c!==kt.nil?(0,kt._)`${a}.call(${c}, ${f})`:(0,kt._)`${a}(${f})`}st.callValidateCode=C3;var D3=(0,kt._)`new RegExp`;function A3({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,kt._)`${i.code==="new RegExp"?D3:(0,k3.useFunc)(t,i)}(${n}, ${r})`})}st.usePattern=A3;function I3(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,kt._)`${n}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:r,dataProp:l,dataPropType:E_.Type.Num},s),e.if((0,kt.not)(s),a)})}}st.validateArray=I3;function O3(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,E_.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,kt._)`${o} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,kt.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}st.validateUnion=O3});var Q1=N(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.validateKeywordUsage=Ii.validSchemaType=Ii.funcKeywordCode=Ii.macroKeywordCode=void 0;var jn=be(),Mo=Fr(),M3=Br(),x3=vu();function L3(t,e){let{gen:n,keyword:r,schema:i,parentSchema:s,it:o}=t,a=e.macro.call(o.self,i,s,o),c=J1(n,r,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let l=n.name("valid");t.subschema({schema:a,schemaPath:jn.nil,errSchemaPath:`${o.errSchemaPath}/${r}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}Ii.macroKeywordCode=L3;function q3(t,e){var n;let{gen:r,keyword:i,schema:s,parentSchema:o,$data:a,it:c}=t;F3(c,e);let l=!a&&e.compile?e.compile.call(c.self,s,o,c):e.validate,u=J1(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&&X1(t),y(()=>t.error());else{let _=e.async?p():m();e.modifying&&X1(t),y(()=>$3(t,_))}}function p(){let _=r.let("ruleErrs",null);return r.try(()=>h((0,jn._)`await `),b=>r.assign(d,!1).if((0,jn._)`${b} instanceof ${c.ValidationError}`,()=>r.assign(_,(0,jn._)`${b}.errors`),()=>r.throw(b))),_}function m(){let _=(0,jn._)`${u}.errors`;return r.assign(_,null),h(jn.nil),_}function h(_=e.async?(0,jn._)`await `:jn.nil){let b=c.opts.passContext?Mo.default.this:Mo.default.self,v=!("compile"in e&&!a||e.schema===!1);r.assign(d,(0,jn._)`${_}${(0,M3.callValidateCode)(t,u,b,v)}`,e.modifying)}function y(_){var b;r.if((0,jn.not)((b=e.valid)!==null&&b!==void 0?b:d),_)}}Ii.funcKeywordCode=q3;function X1(t){let{gen:e,data:n,it:r}=t;e.if(r.parentData,()=>e.assign(n,(0,jn._)`${r.parentData}[${r.parentDataProperty}]`))}function $3(t,e){let{gen:n}=t;n.if((0,jn._)`Array.isArray(${e})`,()=>{n.assign(Mo.default.vErrors,(0,jn._)`${Mo.default.vErrors} === null ? ${e} : ${Mo.default.vErrors}.concat(${e})`).assign(Mo.default.errors,(0,jn._)`${Mo.default.vErrors}.length`),(0,x3.extendErrors)(t)},()=>t.error())}function F3({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function J1(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,jn.stringify)(n)})}function B3(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")}Ii.validSchemaType=B3;function j3({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)}}Ii.validateKeywordUsage=j3});var eq=N(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.extendSubschemaMode=js.extendSubschemaData=js.getSubschema=void 0;var Oi=be(),Z1=De();function U3(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,Oi._)`${t.schemaPath}${(0,Oi.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[n],schemaPath:(0,Oi._)`${t.schemaPath}${(0,Oi.getProperty)(e)}${(0,Oi.getProperty)(n)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Z1.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')}js.getSubschema=U3;function H3(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,Oi._)`${e.data}${(0,Oi.getProperty)(n)}`,!0);c(f),t.errorPath=(0,Oi.str)`${l}${(0,Z1.getErrorPath)(n,r,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Oi._)`${n}`,t.dataPathArr=[...u,t.parentDataProperty]}if(i!==void 0){let l=i instanceof Oi.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]}}js.extendSubschemaData=H3;function V3(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}js.extendSubschemaMode=V3});var A_=N((jwe,tq)=>{"use strict";tq.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 rq=N((Uwe,nq)=>{"use strict";var Us=nq.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(){};Im(e,r,i,t,"",t)};Us.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Us.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Us.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Us.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 Im(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 Us.arrayKeywords)for(var f=0;f<d.length;f++)Im(t,e,n,d[f],i+"/"+u+"/"+f,s,i,u,r,f)}else if(u in Us.propsKeywords){if(d&&typeof d=="object")for(var p in d)Im(t,e,n,d[p],i+"/"+u+"/"+W3(p),s,i,u,r,p)}else(u in Us.keywords||t.allKeys&&!(u in Us.skipKeywords))&&Im(t,e,n,d,i+"/"+u,s,i,u,r)}n(r,i,s,o,a,c,l)}}function W3(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var _u=N(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.getSchemaRefs=ar.resolveUrl=ar.normalizeId=ar._getFullPath=ar.getFullPath=ar.inlineRef=void 0;var z3=De(),G3=A_(),K3=rq(),Y3=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?!I_(t):e?iq(t)<=e:!1}ar.inlineRef=X3;var J3=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function I_(t){for(let e in t){if(J3.has(e))return!0;let n=t[e];if(Array.isArray(n)&&n.some(I_)||typeof n=="object"&&I_(n))return!0}return!1}function iq(t){let e=0;for(let n in t){if(n==="$ref")return 1/0;if(e++,!Y3.has(n)&&(typeof t[n]=="object"&&(0,z3.eachItem)(t[n],r=>e+=iq(r)),e===1/0))return 1/0}return e}function sq(t,e="",n){n!==!1&&(e=lc(e));let r=t.parse(e);return oq(t,r)}ar.getFullPath=sq;function oq(t,e){return t.serialize(e).split("#")[0]+"#"}ar._getFullPath=oq;var Q3=/#\/?$/;function lc(t){return t?t.replace(Q3,""):""}ar.normalizeId=lc;function Z3(t,e,n){return n=lc(n),t.resolve(e,n)}ar.resolveUrl=Z3;var eX=/^[a-z_][-a-z0-9._]*$/i;function tX(t,e){if(typeof t=="boolean")return{};let{schemaId:n,uriResolver:r}=this.opts,i=lc(t[n]||e),s={"":i},o=sq(r,i,!1),a={},c=new Set;return K3(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])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[f]=y;function _(v){let P=this.opts.uriResolver.resolve;if(v=lc(y?P(y,v):v),c.has(v))throw u(v);c.add(v);let R=this.refs[v];return typeof R=="string"&&(R=this.refs[R]),typeof R=="object"?l(d,R.schema,v):v!==lc(h)&&(v[0]==="#"?(l(d,a[v],v),a[v]=d):this.refs[v]=h),v}function b(v){if(typeof v=="string"){if(!eX.test(v))throw new Error(`invalid anchor "${v}"`);_.call(this,`#${v}`)}}}),a;function l(d,f,p){if(f!==void 0&&!G3(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}ar.getSchemaRefs=tX});var Pu=N(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.getData=Hs.KeywordCxt=Hs.validateFunctionCode=void 0;var dq=B1(),aq=bu(),M_=P_(),Om=bu(),nX=G1(),ku=Q1(),O_=eq(),oe=be(),me=Fr(),rX=_u(),ts=De(),Su=vu();function iX(t){if(hq(t)&&(mq(t),pq(t))){aX(t);return}fq(t,()=>(0,dq.topBoolOrEmptySchema)(t))}Hs.validateFunctionCode=iX;function fq({gen:t,validateName:e,schema:n,schemaEnv:r,opts:i},s){i.code.es5?t.func(e,(0,oe._)`${me.default.data}, ${me.default.valCxt}`,r.$async,()=>{t.code((0,oe._)`"use strict"; ${cq(n,i)}`),oX(t,i),t.code(s)}):t.func(e,(0,oe._)`${me.default.data}, ${sX(i)}`,r.$async,()=>t.code(cq(n,i)).code(s))}function sX(t){return(0,oe._)`{${me.default.instancePath}="", ${me.default.parentData}, ${me.default.parentDataProperty}, ${me.default.rootData}=${me.default.data}${t.dynamicRef?(0,oe._)`, ${me.default.dynamicAnchors}={}`:oe.nil}}={}`}function oX(t,e){t.if(me.default.valCxt,()=>{t.var(me.default.instancePath,(0,oe._)`${me.default.valCxt}.${me.default.instancePath}`),t.var(me.default.parentData,(0,oe._)`${me.default.valCxt}.${me.default.parentData}`),t.var(me.default.parentDataProperty,(0,oe._)`${me.default.valCxt}.${me.default.parentDataProperty}`),t.var(me.default.rootData,(0,oe._)`${me.default.valCxt}.${me.default.rootData}`),e.dynamicRef&&t.var(me.default.dynamicAnchors,(0,oe._)`${me.default.valCxt}.${me.default.dynamicAnchors}`)},()=>{t.var(me.default.instancePath,(0,oe._)`""`),t.var(me.default.parentData,(0,oe._)`undefined`),t.var(me.default.parentDataProperty,(0,oe._)`undefined`),t.var(me.default.rootData,me.default.data),e.dynamicRef&&t.var(me.default.dynamicAnchors,(0,oe._)`{}`)})}function aX(t){let{schema:e,opts:n,gen:r}=t;fq(t,()=>{n.$comment&&e.$comment&&yq(t),fX(t),r.let(me.default.vErrors,null),r.let(me.default.errors,0),n.unevaluated&&cX(t),gq(t),mX(t)})}function cX(t){let{gen:e,validateName:n}=t;t.evaluated=e.const("evaluated",(0,oe._)`${n}.evaluated`),e.if((0,oe._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,oe._)`${t.evaluated}.props`,(0,oe._)`undefined`)),e.if((0,oe._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,oe._)`${t.evaluated}.items`,(0,oe._)`undefined`))}function cq(t,e){let n=typeof t=="object"&&t[e.schemaId];return n&&(e.code.source||e.code.process)?(0,oe._)`/*# sourceURL=${n} */`:oe.nil}function lX(t,e){if(hq(t)&&(mq(t),pq(t))){uX(t,e);return}(0,dq.boolOrEmptySchema)(t,e)}function pq({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 hq(t){return typeof t.schema!="boolean"}function uX(t,e){let{schema:n,gen:r,opts:i}=t;i.$comment&&n.$comment&&yq(t),pX(t),hX(t);let s=r.const("_errs",me.default.errors);gq(t,s),r.var(e,(0,oe._)`${s} === ${me.default.errors}`)}function mq(t){(0,ts.checkUnknownRules)(t),dX(t)}function gq(t,e){if(t.opts.jtd)return lq(t,[],!1,e);let n=(0,aq.getSchemaTypes)(t.schema),r=(0,aq.coerceAndCheckDataType)(t,n);lq(t,n,!r,e)}function dX(t){let{schema:e,errSchemaPath:n,opts:r,self:i}=t;e.$ref&&r.ignoreKeywordsWithRef&&(0,ts.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function fX(t){let{schema:e,opts:n}=t;e.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,ts.checkStrictMode)(t,"default is ignored in the schema root")}function pX(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,rX.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function hX(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function yq({gen:t,schemaEnv:e,schema:n,errSchemaPath:r,opts:i}){let s=n.$comment;if(i.$comment===!0)t.code((0,oe._)`${me.default.self}.logger.log(${s})`);else if(typeof i.$comment=="function"){let o=(0,oe.str)`${r}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,oe._)`${me.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function mX(t){let{gen:e,schemaEnv:n,validateName:r,ValidationError:i,opts:s}=t;n.$async?e.if((0,oe._)`${me.default.errors} === 0`,()=>e.return(me.default.data),()=>e.throw((0,oe._)`new ${i}(${me.default.vErrors})`)):(e.assign((0,oe._)`${r}.errors`,me.default.vErrors),s.unevaluated&&gX(t),e.return((0,oe._)`${me.default.errors} === 0`))}function gX({gen:t,evaluated:e,props:n,items:r}){n instanceof oe.Name&&t.assign((0,oe._)`${e}.props`,n),r instanceof oe.Name&&t.assign((0,oe._)`${e}.items`,r)}function lq(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,ts.schemaHasRulesButRef)(s,u))){i.block(()=>vq(t,"$ref",u.all.$ref.definition));return}c.jtd||yX(t,e),i.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,M_.shouldUseGroup)(s,f)&&(f.type?(i.if((0,Om.checkDataType)(f.type,o,c.strictNumbers)),uq(t,f),e.length===1&&e[0]===f.type&&n&&(i.else(),(0,Om.reportTypeError)(t)),i.endIf()):uq(t,f),a||i.if((0,oe._)`${me.default.errors} === ${r||0}`))}}function uq(t,e){let{gen:n,schema:r,opts:{useDefaults:i}}=t;i&&(0,nX.assignDefaults)(t,e.type),n.block(()=>{for(let s of e.rules)(0,M_.shouldUseRule)(r,s)&&vq(t,s.keyword,s.definition,e.type)})}function yX(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(TX(t,e),t.opts.allowUnionTypes||vX(t,e),bX(t,t.dataTypes))}function TX(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(n=>{Tq(t.dataTypes,n)||x_(t,`type "${n}" not allowed by context "${t.dataTypes.join(",")}"`)}),SX(t,e)}}function vX(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&x_(t,"use allowUnionTypes to allow union type keyword")}function bX(t,e){let n=t.self.RULES.all;for(let r in n){let i=n[r];if(typeof i=="object"&&(0,M_.shouldUseRule)(t.schema,i)){let{type:s}=i.definition;s.length&&!s.some(o=>_X(e,o))&&x_(t,`missing type "${s.join(",")}" for keyword "${r}"`)}}}function _X(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Tq(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function SX(t,e){let n=[];for(let r of t.dataTypes)Tq(e,r)?n.push(r):e.includes("integer")&&r==="number"&&n.push("integer");t.dataTypes=n}function x_(t,e){let n=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${n}" (strictTypes)`,(0,ts.checkStrictMode)(t,e,t.opts.strictTypes)}var Mm=class{constructor(e,n,r){if((0,ku.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,ts.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",bq(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ku.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,oe.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,oe.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,oe._)`${n} !== undefined && (${(0,oe.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?Su.reportExtraError:Su.reportError)(this,this.def.error,n)}$dataError(){(0,Su.reportError)(this,this.def.$dataError||Su.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Su.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=oe.nil){this.gen.block(()=>{this.check$data(e,r),n()})}check$data(e=oe.nil,n=oe.nil){if(!this.$data)return;let{gen:r,schemaCode:i,schemaType:s,def:o}=this;r.if((0,oe.or)((0,oe._)`${i} === undefined`,n)),e!==oe.nil&&r.assign(e,!0),(s.length||o.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==oe.nil&&r.assign(e,!1)),r.else()}invalid$data(){let{gen:e,schemaCode:n,schemaType:r,def:i,it:s}=this;return(0,oe.or)(o(),a());function o(){if(r.length){if(!(n instanceof oe.Name))throw new Error("ajv implementation error");let c=Array.isArray(r)?r:[r];return(0,oe._)`${(0,Om.checkDataTypes)(c,n,s.opts.strictNumbers,Om.DataType.Wrong)}`}return oe.nil}function a(){if(i.validateSchema){let c=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,oe._)`!${c}(${n})`}return oe.nil}}subschema(e,n){let r=(0,O_.getSubschema)(this.it,e);(0,O_.extendSubschemaData)(r,this.it,e),(0,O_.extendSubschemaMode)(r,e);let i={...this.it,...r,items:void 0,props:void 0};return lX(i,n),i}mergeEvaluated(e,n){let{it:r,gen:i}=this;r.opts.unevaluated&&(r.props!==!0&&e.props!==void 0&&(r.props=ts.mergeEvaluated.props(i,e.props,r.props,n)),r.items!==!0&&e.items!==void 0&&(r.items=ts.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,oe.Name)),!0}};Hs.KeywordCxt=Mm;function vq(t,e,n,r){let i=new Mm(t,n,e);"code"in n?n.code(i,r):i.$data&&n.validate?(0,ku.funcKeywordCode)(i,n):"macro"in n?(0,ku.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,ku.funcKeywordCode)(i,n)}var kX=/^\/(?:[^~]|~0|~1)*$/,PX=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function bq(t,{dataLevel:e,dataNames:n,dataPathArr:r}){let i,s;if(t==="")return me.default.rootData;if(t[0]==="/"){if(!kX.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,s=me.default.rootData}else{let l=PX.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,oe._)`${s}${(0,oe.getProperty)((0,ts.unescapeJsonPointer)(l))}`,o=(0,oe._)`${o} && ${s}`);return o;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}Hs.getData=bq});var xm=N(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var L_=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};q_.default=L_});var Nu=N(B_=>{"use strict";Object.defineProperty(B_,"__esModule",{value:!0});var $_=_u(),F_=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,$_.resolveUrl)(e,n,r),this.missingSchema=(0,$_.normalizeId)((0,$_.getFullPath)(e,this.missingRef))}};B_.default=F_});var Ru=N(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.resolveSchema=jr.getCompilingSchema=jr.resolveRef=jr.compileSchema=jr.SchemaEnv=void 0;var fi=be(),NX=xm(),xo=Fr(),pi=_u(),_q=De(),RX=Pu(),uc=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,pi.normalizeId)(r?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=r?.$async,this.refs={}}};jr.SchemaEnv=uc;function U_(t){let e=Sq.call(this,t);if(e)return e;let n=(0,pi.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:r,lines:i}=this.opts.code,{ownProperties:s}=this.opts,o=new fi.CodeGen(this.scope,{es5:r,lines:i,ownProperties:s}),a;t.$async&&(a=o.scopeValue("Error",{ref:NX.default,code:(0,fi._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let l={gen:o,allErrors:this.opts.allErrors,data:xo.default.data,parentData:xo.default.parentData,parentDataProperty:xo.default.parentDataProperty,dataNames:[xo.default.data],dataPathArr:[fi.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,fi.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:n,baseId:t.baseId||n,schemaPath:fi.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,fi._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,RX.validateFunctionCode)(l),o.optimize(this.opts.code.optimize);let d=o.toString();u=`${o.scopeRefs(xo.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${xo.default.self}`,`${xo.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 fi.Name?void 0:m,items:h instanceof fi.Name?void 0:h,dynamicProps:m instanceof fi.Name,dynamicItems:h instanceof fi.Name},p.source&&(p.source.evaluated=(0,fi.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)}}jr.compileSchema=U_;function wX(t,e,n){var r;n=(0,pi.resolveUrl)(this.opts.uriResolver,e,n);let i=t.refs[n];if(i)return i;let s=DX.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 uc({schema:o,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[n]=EX.call(this,s)}jr.resolveRef=wX;function EX(t){return(0,pi.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:U_.call(this,t)}function Sq(t){for(let e of this._compilations)if(CX(e,t))return e}jr.getCompilingSchema=Sq;function CX(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function DX(t,e){let n;for(;typeof(n=this.refs[e])=="string";)e=n;return n||this.schemas[e]||Lm.call(this,t,e)}function Lm(t,e){let n=this.opts.uriResolver.parse(e),r=(0,pi._getFullPath)(this.opts.uriResolver,n),i=(0,pi.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&r===i)return j_.call(this,n,t);let s=(0,pi.normalizeId)(r),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=Lm.call(this,t,o);return typeof a?.schema!="object"?void 0:j_.call(this,n,a)}if(typeof o?.schema=="object"){if(o.validate||U_.call(this,o),s===(0,pi.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,l=a[c];return l&&(i=(0,pi.resolveUrl)(this.opts.uriResolver,i,l)),new uc({schema:a,schemaId:c,root:t,baseId:i})}return j_.call(this,n,o)}}jr.resolveSchema=Lm;var AX=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function j_(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,_q.unescapeFragment)(a)];if(c===void 0)return;n=c;let l=typeof n=="object"&&n[this.opts.schemaId];!AX.has(a)&&l&&(e=(0,pi.resolveUrl)(this.opts.uriResolver,e,l))}let s;if(typeof n!="boolean"&&n.$ref&&!(0,_q.schemaHasRulesButRef)(n,this.RULES)){let a=(0,pi.resolveUrl)(this.opts.uriResolver,e,n.$ref);s=Lm.call(this,r,a)}let{schemaId:o}=this.opts;if(s=s||new uc({schema:n,schemaId:o,root:r,baseId:e}),s.schema!==s.root.schema)return s}});var kq=N((Kwe,IX)=>{IX.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 Nq=N((Ywe,Pq)=>{"use strict";var OX={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};Pq.exports={HEX:OX}});var Oq=N((Xwe,Iq)=>{"use strict";var{HEX:MX}=Nq(),xX=/^(?:(?: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 Cq(t){if(Aq(t,".")<3)return{host:t,isIPV4:!1};let e=t.match(xX)||[],[n]=e;return n?{host:qX(n,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function H_(t,e=!1){let n="",r=!0;for(let i of t){if(MX[i]===void 0)return;i!=="0"&&r===!0&&(r=!1),r||(n+=i)}return e&&n.length===0&&(n="0"),n}function LX(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=H_(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(H_(i))),n.address=r.join(""),n}function Dq(t){if(Aq(t,":")<2)return{host:t,isIPV6:!1};let e=LX(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 qX(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 Aq(t,e){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}var Rq=/^\.\.?\//u,wq=/^\/\.(?:\/|$)/u,Eq=/^\/\.\.(?:\/|$)/u,$X=/^\/?(?:.|\n)*?(?=\/|$)/u;function FX(t){let e=[];for(;t.length;)if(t.match(Rq))t=t.replace(Rq,"");else if(t.match(wq))t=t.replace(wq,"/");else if(t.match(Eq))t=t.replace(Eq,"/"),e.pop();else if(t==="."||t==="..")t="";else{let n=t.match($X);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 BX(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 jX(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let n=unescape(t.host),r=Cq(n);if(r.isIPV4)n=r.host;else{let i=Dq(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}Iq.exports={recomposeAuthority:jX,normalizeComponentEncoding:BX,removeDotSegments:FX,normalizeIPv4:Cq,normalizeIPv6:Dq,stringArrayToHexStripped:H_}});var Fq=N((Jwe,$q)=>{"use strict";var UX=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,HX=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function Mq(t){return typeof t.secure=="boolean"?t.secure:String(t.scheme).toLowerCase()==="wss"}function xq(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Lq(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 VX(t){return t.secure=Mq(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function WX(t){if((t.port===(Mq(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 zX(t,e){if(!t.path)return t.error="URN can not be parsed",t;let n=t.path.match(HX);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=V_[i];t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function GX(t,e){let n=e.scheme||t.scheme||"urn",r=t.nid.toLowerCase(),i=`${n}:${e.nid||r}`,s=V_[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 KX(t,e){let n=t;return n.uuid=n.nss,n.nss=void 0,!e.tolerant&&(!n.uuid||!UX.test(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function YX(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var qq={scheme:"http",domainHost:!0,parse:xq,serialize:Lq},XX={scheme:"https",domainHost:qq.domainHost,parse:xq,serialize:Lq},qm={scheme:"ws",domainHost:!0,parse:VX,serialize:WX},JX={scheme:"wss",domainHost:qm.domainHost,parse:qm.parse,serialize:qm.serialize},QX={scheme:"urn",parse:zX,serialize:GX,skipNormalize:!0},ZX={scheme:"urn:uuid",parse:KX,serialize:YX,skipNormalize:!0},V_={http:qq,https:XX,ws:qm,wss:JX,urn:QX,"urn:uuid":ZX};$q.exports=V_});var jq=N((Qwe,Fm)=>{"use strict";var{normalizeIPv6:e4,normalizeIPv4:t4,removeDotSegments:wu,recomposeAuthority:n4,normalizeComponentEncoding:$m}=Oq(),W_=Fq();function r4(t,e){return typeof t=="string"?t=Mi(ns(t,e),e):typeof t=="object"&&(t=ns(Mi(t,e),e)),t}function i4(t,e,n){let r=Object.assign({scheme:"null"},n),i=Bq(ns(t,r),ns(e,r),r,!0);return Mi(i,{...r,skipEscape:!0})}function Bq(t,e,n,r){let i={};return r||(t=ns(Mi(t,n),n),e=ns(Mi(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=wu(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=wu(e.path||""),i.query=e.query):(e.path?(e.path.charAt(0)==="/"?i.path=wu(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=wu(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 s4(t,e,n){return typeof t=="string"?(t=unescape(t),t=Mi($m(ns(t,n),!0),{...n,skipEscape:!0})):typeof t=="object"&&(t=Mi($m(t,!0),{...n,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=Mi($m(ns(e,n),!0),{...n,skipEscape:!0})):typeof e=="object"&&(e=Mi($m(e,!0),{...n,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function Mi(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=W_[(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=n4(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=wu(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 o4=Array.from({length:127},(t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function a4(t){let e=0;for(let n=0,r=t.length;n<r;++n)if(e=t.charCodeAt(n),e>126||o4[e])return!0;return!1}var c4=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function ns(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(c4);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=t4(r.host);if(c.isIPV4===!1){let l=e4(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=W_[(n.scheme||r.scheme||"").toLowerCase()];if(!n.unicodeSupport&&(!a||!a.unicodeSupport)&&r.host&&(n.domainHost||a&&a.domainHost)&&s===!1&&a4(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 z_={SCHEMES:W_,normalize:r4,resolve:i4,resolveComponents:Bq,equal:s4,serialize:Mi,parse:ns};Fm.exports=z_;Fm.exports.default=z_;Fm.exports.fastUri=z_});var Hq=N(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});var Uq=jq();Uq.code='require("ajv/dist/runtime/uri").default';G_.default=Uq});var Jq=N(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.CodeGen=yn.Name=yn.nil=yn.stringify=yn.str=yn._=yn.KeywordCxt=void 0;var l4=Pu();Object.defineProperty(yn,"KeywordCxt",{enumerable:!0,get:function(){return l4.KeywordCxt}});var dc=be();Object.defineProperty(yn,"_",{enumerable:!0,get:function(){return dc._}});Object.defineProperty(yn,"str",{enumerable:!0,get:function(){return dc.str}});Object.defineProperty(yn,"stringify",{enumerable:!0,get:function(){return dc.stringify}});Object.defineProperty(yn,"nil",{enumerable:!0,get:function(){return dc.nil}});Object.defineProperty(yn,"Name",{enumerable:!0,get:function(){return dc.Name}});Object.defineProperty(yn,"CodeGen",{enumerable:!0,get:function(){return dc.CodeGen}});var u4=xm(),Kq=Nu(),d4=k_(),Eu=Ru(),f4=be(),Cu=_u(),Bm=bu(),Y_=De(),Vq=kq(),p4=Hq(),Yq=(t,e)=>new RegExp(t,e);Yq.code="new RegExp";var h4=["removeAdditional","useDefaults","coerceTypes"],m4=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g4={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."},y4={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Wq=200;function T4(t){var e,n,r,i,s,o,a,c,l,u,d,f,p,m,h,y,_,b,v,P,R,q,O,F,ke;let Ze=t.strict,Ct=(e=t.code)===null||e===void 0?void 0:e.optimize,Pe=Ct===!0||Ct===void 0?1:Ct||0,un=(r=(n=t.code)===null||n===void 0?void 0:n.regExp)!==null&&r!==void 0?r:Yq,bn=(i=t.uriResolver)!==null&&i!==void 0?i:p4.default;return{strictSchema:(o=(s=t.strictSchema)!==null&&s!==void 0?s:Ze)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Ze)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:Ze)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:Ze)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:Ze)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:Pe,regExp:un}:{optimize:Pe,regExp:un},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:Wq,loopEnum:(y=t.loopEnum)!==null&&y!==void 0?y:Wq,meta:(_=t.meta)!==null&&_!==void 0?_:!0,messages:(b=t.messages)!==null&&b!==void 0?b:!0,inlineRefs:(v=t.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(P=t.schemaId)!==null&&P!==void 0?P:"$id",addUsedSchema:(R=t.addUsedSchema)!==null&&R!==void 0?R:!0,validateSchema:(q=t.validateSchema)!==null&&q!==void 0?q:!0,validateFormats:(O=t.validateFormats)!==null&&O!==void 0?O:!0,unicodeRegExp:(F=t.unicodeRegExp)!==null&&F!==void 0?F:!0,int32range:(ke=t.int32range)!==null&&ke!==void 0?ke:!0,uriResolver:bn}}var Du=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...T4(e)};let{es5:n,lines:r}=this.opts.code;this.scope=new f4.ValueScope({scope:{},prefixes:m4,es5:n,lines:r}),this.logger=P4(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,d4.getRules)(),zq.call(this,g4,e,"NOT SUPPORTED"),zq.call(this,y4,e,"DEPRECATED","warn"),this._metaOpts=S4.call(this),e.formats&&b4.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&_4.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),v4.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:n,schemaId:r}=this.opts,i=Vq;r==="id"&&(i={...Vq},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 Kq.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,Cu.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=Gq.call(this,e))=="string";)e=n;if(n===void 0){let{schemaId:r}=this.opts,i=new Eu.SchemaEnv({schema:{},schemaId:r});if(n=Eu.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=Gq.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,Cu.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(R4.call(this,r,n),!n)return(0,Y_.eachItem)(r,s=>K_.call(this,s)),this;E4.call(this,n);let i={...n,type:(0,Bm.getJSONTypes)(n.type),schemaType:(0,Bm.getJSONTypes)(n.schemaType)};return(0,Y_.eachItem)(r,i.type.length===0?s=>K_.call(this,s,i):s=>i.type.forEach(o=>K_.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]=Xq(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,Cu.normalizeId)(o||r);let l=Cu.getSchemaRefs.call(this,e,r);return c=new Eu.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):Eu.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{Eu.compileSchema.call(this,e)}finally{this.opts=n}}};Du.ValidationError=u4.default;Du.MissingRefError=Kq.default;yn.default=Du;function zq(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 Gq(t){return t=(0,Cu.normalizeId)(t),this.schemas[t]||this.refs[t]}function v4(){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 b4(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function _4(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 S4(){let t={...this.opts};for(let e of h4)delete t[e];return t}var k4={log(){},warn(){},error(){}};function P4(t){if(t===!1)return k4;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 N4=/^[a-z_$][a-z0-9_$:-]*$/i;function R4(t,e){let{RULES:n}=this;if((0,Y_.eachItem)(t,r=>{if(n.keywords[r])throw new Error(`Keyword ${r} is already defined`);if(!N4.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 K_(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,Bm.getJSONTypes)(e.type),schemaType:(0,Bm.getJSONTypes)(e.schemaType)}};e.before?w4.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 w4(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 E4(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Xq(e)),t.validateSchema=this.compile(e,!0))}var C4={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Xq(t){return{anyOf:[t,C4]}}});var Qq=N(X_=>{"use strict";Object.defineProperty(X_,"__esModule",{value:!0});var D4={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};X_.default=D4});var Hm=N(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.callRef=Lo.getValidate=void 0;var A4=Nu(),Zq=Br(),cr=be(),fc=Fr(),e$=Ru(),jm=De(),I4={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=e$.resolveRef.call(c,l,i,n);if(u===void 0)throw new A4.default(r.opts.uriResolver,i,n);if(u instanceof e$.SchemaEnv)return f(u);return p(u);function d(){if(s===l)return Um(t,o,s,s.$async);let m=e.scopeValue("root",{ref:l});return Um(t,(0,cr._)`${m}.validate`,l,l.$async)}function f(m){let h=t$(t,m);Um(t,h,m,m.$async)}function p(m){let h=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,cr.stringify)(m)}:{ref:m}),y=e.name("valid"),_=t.subschema({schema:m,dataTypes:[],schemaPath:cr.nil,topSchemaRef:h,errSchemaPath:n},y);t.mergeEvaluated(_),t.ok(y)}}};function t$(t,e){let{gen:n}=t;return e.validate?n.scopeValue("validate",{ref:e.validate}):(0,cr._)`${n.scopeValue("wrapper",{ref:e})}.validate`}Lo.getValidate=t$;function Um(t,e,n,r){let{gen:i,it:s}=t,{allErrors:o,schemaEnv:a,opts:c}=s,l=c.passContext?fc.default.this:cr.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,cr._)`await ${(0,Zq.callValidateCode)(t,e,l)}`),p(e),o||i.assign(m,!0)},h=>{i.if((0,cr._)`!(${h} instanceof ${s.ValidationError})`,()=>i.throw(h)),f(h),o||i.assign(m,!1)}),t.ok(m)}function d(){t.result((0,Zq.callValidateCode)(t,e,l),()=>p(e),()=>f(e))}function f(m){let h=(0,cr._)`${m}.errors`;i.assign(fc.default.vErrors,(0,cr._)`${fc.default.vErrors} === null ? ${h} : ${fc.default.vErrors}.concat(${h})`),i.assign(fc.default.errors,(0,cr._)`${fc.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=jm.mergeEvaluated.props(i,y.props,s.props));else{let _=i.var("props",(0,cr._)`${m}.evaluated.props`);s.props=jm.mergeEvaluated.props(i,_,s.props,cr.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=jm.mergeEvaluated.items(i,y.items,s.items));else{let _=i.var("items",(0,cr._)`${m}.evaluated.items`);s.items=jm.mergeEvaluated.items(i,_,s.items,cr.Name)}}}Lo.callRef=Um;Lo.default=I4});var n$=N(J_=>{"use strict";Object.defineProperty(J_,"__esModule",{value:!0});var O4=Qq(),M4=Hm(),x4=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",O4.default,M4.default];J_.default=x4});var r$=N(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});var Vm=be(),Vs=Vm.operators,Wm={maximum:{okStr:"<=",ok:Vs.LTE,fail:Vs.GT},minimum:{okStr:">=",ok:Vs.GTE,fail:Vs.LT},exclusiveMaximum:{okStr:"<",ok:Vs.LT,fail:Vs.GTE},exclusiveMinimum:{okStr:">",ok:Vs.GT,fail:Vs.LTE}},L4={message:({keyword:t,schemaCode:e})=>(0,Vm.str)`must be ${Wm[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Vm._)`{comparison: ${Wm[t].okStr}, limit: ${e}}`},q4={keyword:Object.keys(Wm),type:"number",schemaType:"number",$data:!0,error:L4,code(t){let{keyword:e,data:n,schemaCode:r}=t;t.fail$data((0,Vm._)`${n} ${Wm[e].fail} ${r} || isNaN(${n})`)}};Q_.default=q4});var i$=N(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});var Au=be(),$4={message:({schemaCode:t})=>(0,Au.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Au._)`{multipleOf: ${t}}`},F4={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:$4,code(t){let{gen:e,data:n,schemaCode:r,it:i}=t,s=i.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,Au._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,Au._)`${o} !== parseInt(${o})`;t.fail$data((0,Au._)`(${r} === 0 || (${o} = ${n}/${r}, ${a}))`)}};Z_.default=F4});var o$=N(eS=>{"use strict";Object.defineProperty(eS,"__esModule",{value:!0});function s$(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}eS.default=s$;s$.code='require("ajv/dist/runtime/ucs2length").default'});var a$=N(tS=>{"use strict";Object.defineProperty(tS,"__esModule",{value:!0});var qo=be(),B4=De(),j4=o$(),U4={message({keyword:t,schemaCode:e}){let n=t==="maxLength"?"more":"fewer";return(0,qo.str)`must NOT have ${n} than ${e} characters`},params:({schemaCode:t})=>(0,qo._)`{limit: ${t}}`},H4={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:U4,code(t){let{keyword:e,data:n,schemaCode:r,it:i}=t,s=e==="maxLength"?qo.operators.GT:qo.operators.LT,o=i.opts.unicode===!1?(0,qo._)`${n}.length`:(0,qo._)`${(0,B4.useFunc)(t.gen,j4.default)}(${n})`;t.fail$data((0,qo._)`${o} ${s} ${r}`)}};tS.default=H4});var c$=N(nS=>{"use strict";Object.defineProperty(nS,"__esModule",{value:!0});var V4=Br(),W4=De(),pc=be(),z4={message:({schemaCode:t})=>(0,pc.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,pc._)`{pattern: ${t}}`},G4={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:z4,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,pc._)`new RegExp`:(0,W4.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,pc._)`${l}(${s}, ${a}).test(${n})`),()=>e.assign(u,!1)),t.fail$data((0,pc._)`!${u}`)}else{let c=(0,V4.usePattern)(t,i);t.fail$data((0,pc._)`!${c}.test(${n})`)}}};nS.default=G4});var l$=N(rS=>{"use strict";Object.defineProperty(rS,"__esModule",{value:!0});var Iu=be(),K4={message({keyword:t,schemaCode:e}){let n=t==="maxProperties"?"more":"fewer";return(0,Iu.str)`must NOT have ${n} than ${e} properties`},params:({schemaCode:t})=>(0,Iu._)`{limit: ${t}}`},Y4={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:K4,code(t){let{keyword:e,data:n,schemaCode:r}=t,i=e==="maxProperties"?Iu.operators.GT:Iu.operators.LT;t.fail$data((0,Iu._)`Object.keys(${n}).length ${i} ${r}`)}};rS.default=Y4});var u$=N(iS=>{"use strict";Object.defineProperty(iS,"__esModule",{value:!0});var Ou=Br(),Mu=be(),X4=De(),J4={message:({params:{missingProperty:t}})=>(0,Mu.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Mu._)`{missingProperty: ${t}}`},Q4={keyword:"required",type:"object",schemaType:"array",$data:!0,error:J4,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(Mu.nil,d);else for(let p of n)(0,Ou.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,Ou.checkMissingProp)(t,n,p)),(0,Ou.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",r,p=>{t.setParams({missingProperty:p}),e.if((0,Ou.noPropertyInData)(e,i,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,r,()=>{e.assign(m,(0,Ou.propertyInData)(e,i,p,a.ownProperties)),e.if((0,Mu.not)(m),()=>{t.error(),e.break()})},Mu.nil)}}};iS.default=Q4});var d$=N(sS=>{"use strict";Object.defineProperty(sS,"__esModule",{value:!0});var xu=be(),Z4={message({keyword:t,schemaCode:e}){let n=t==="maxItems"?"more":"fewer";return(0,xu.str)`must NOT have ${n} than ${e} items`},params:({schemaCode:t})=>(0,xu._)`{limit: ${t}}`},e9={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Z4,code(t){let{keyword:e,data:n,schemaCode:r}=t,i=e==="maxItems"?xu.operators.GT:xu.operators.LT;t.fail$data((0,xu._)`${n}.length ${i} ${r}`)}};sS.default=e9});var zm=N(oS=>{"use strict";Object.defineProperty(oS,"__esModule",{value:!0});var f$=A_();f$.code='require("ajv/dist/runtime/equal").default';oS.default=f$});var p$=N(cS=>{"use strict";Object.defineProperty(cS,"__esModule",{value:!0});var aS=bu(),Tn=be(),t9=De(),n9=zm(),r9={message:({params:{i:t,j:e}})=>(0,Tn.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Tn._)`{i: ${t}, j: ${e}}`},i9={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:r9,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,aS.getSchemaTypes)(s.items):[];t.block$data(c,u,(0,Tn._)`${o} === false`),t.ok(c);function u(){let m=e.let("i",(0,Tn._)`${n}.length`),h=e.let("j");t.setParams({i:m,j:h}),e.assign(c,!0),e.if((0,Tn._)`${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,aS.checkDataTypes)(l,y,a.opts.strictNumbers,aS.DataType.Wrong),b=e.const("indices",(0,Tn._)`{}`);e.for((0,Tn._)`;${m}--;`,()=>{e.let(y,(0,Tn._)`${n}[${m}]`),e.if(_,(0,Tn._)`continue`),l.length>1&&e.if((0,Tn._)`typeof ${y} == "string"`,(0,Tn._)`${y} += "_"`),e.if((0,Tn._)`typeof ${b}[${y}] == "number"`,()=>{e.assign(h,(0,Tn._)`${b}[${y}]`),t.error(),e.assign(c,!1).break()}).code((0,Tn._)`${b}[${y}] = ${m}`)})}function p(m,h){let y=(0,t9.useFunc)(e,n9.default),_=e.name("outer");e.label(_).for((0,Tn._)`;${m}--;`,()=>e.for((0,Tn._)`${h} = ${m}; ${h}--;`,()=>e.if((0,Tn._)`${y}(${n}[${m}], ${n}[${h}])`,()=>{t.error(),e.assign(c,!1).break(_)})))}}};cS.default=i9});var h$=N(uS=>{"use strict";Object.defineProperty(uS,"__esModule",{value:!0});var lS=be(),s9=De(),o9=zm(),a9={message:"must be equal to constant",params:({schemaCode:t})=>(0,lS._)`{allowedValue: ${t}}`},c9={keyword:"const",$data:!0,error:a9,code(t){let{gen:e,data:n,$data:r,schemaCode:i,schema:s}=t;r||s&&typeof s=="object"?t.fail$data((0,lS._)`!${(0,s9.useFunc)(e,o9.default)}(${n}, ${i})`):t.fail((0,lS._)`${s} !== ${n}`)}};uS.default=c9});var m$=N(dS=>{"use strict";Object.defineProperty(dS,"__esModule",{value:!0});var Lu=be(),l9=De(),u9=zm(),d9={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Lu._)`{allowedValues: ${t}}`},f9={keyword:"enum",schemaType:"array",$data:!0,error:d9,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,l9.useFunc)(e,u9.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,Lu.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,Lu._)`${l()}(${n}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,m){let h=i[m];return typeof h=="object"&&h!==null?(0,Lu._)`${l()}(${n}, ${p}[${m}])`:(0,Lu._)`${n} === ${h}`}}};dS.default=f9});var g$=N(fS=>{"use strict";Object.defineProperty(fS,"__esModule",{value:!0});var p9=r$(),h9=i$(),m9=a$(),g9=c$(),y9=l$(),T9=u$(),v9=d$(),b9=p$(),_9=h$(),S9=m$(),k9=[p9.default,h9.default,m9.default,g9.default,y9.default,T9.default,v9.default,b9.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_9.default,S9.default];fS.default=k9});var hS=N(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});qu.validateAdditionalItems=void 0;var $o=be(),pS=De(),P9={message:({params:{len:t}})=>(0,$o.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,$o._)`{limit: ${t}}`},N9={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:P9,code(t){let{parentSchema:e,it:n}=t,{items:r}=e;if(!Array.isArray(r)){(0,pS.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}y$(t,r)}};function y$(t,e){let{gen:n,schema:r,data:i,keyword:s,it:o}=t;o.items=!0;let a=n.const("len",(0,$o._)`${i}.length`);if(r===!1)t.setParams({len:e.length}),t.pass((0,$o._)`${a} <= ${e.length}`);else if(typeof r=="object"&&!(0,pS.alwaysValidSchema)(o,r)){let l=n.var("valid",(0,$o._)`${a} <= ${e.length}`);n.if((0,$o.not)(l),()=>c(l)),t.ok(l)}function c(l){n.forRange("i",e.length,a,u=>{t.subschema({keyword:s,dataProp:u,dataPropType:pS.Type.Num},l),o.allErrors||n.if((0,$o.not)(l),()=>n.break())})}}qu.validateAdditionalItems=y$;qu.default=N9});var mS=N($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});$u.validateTuple=void 0;var T$=be(),Gm=De(),R9=Br(),w9={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:n}=t;if(Array.isArray(e))return v$(t,"additionalItems",e);n.items=!0,!(0,Gm.alwaysValidSchema)(n,e)&&t.ok((0,R9.validateArray)(t))}};function v$(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=Gm.mergeEvaluated.items(r,n.length,a.items));let c=r.name("valid"),l=r.const("len",(0,T$._)`${s}.length`);n.forEach((d,f)=>{(0,Gm.alwaysValidSchema)(a,d)||(r.if((0,T$._)`${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,Gm.checkStrictMode)(a,y,f.strictTuples)}}}$u.validateTuple=v$;$u.default=w9});var b$=N(gS=>{"use strict";Object.defineProperty(gS,"__esModule",{value:!0});var E9=mS(),C9={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,E9.validateTuple)(t,"items")};gS.default=C9});var S$=N(yS=>{"use strict";Object.defineProperty(yS,"__esModule",{value:!0});var _$=be(),D9=De(),A9=Br(),I9=hS(),O9={message:({params:{len:t}})=>(0,_$.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,_$._)`{limit: ${t}}`},M9={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:O9,code(t){let{schema:e,parentSchema:n,it:r}=t,{prefixItems:i}=n;r.items=!0,!(0,D9.alwaysValidSchema)(r,e)&&(i?(0,I9.validateAdditionalItems)(t,i):t.ok((0,A9.validateArray)(t)))}};yS.default=M9});var k$=N(TS=>{"use strict";Object.defineProperty(TS,"__esModule",{value:!0});var Ur=be(),Km=De(),x9={message:({params:{min:t,max:e}})=>e===void 0?(0,Ur.str)`must contain at least ${t} valid item(s)`:(0,Ur.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Ur._)`{minContains: ${t}}`:(0,Ur._)`{minContains: ${t}, maxContains: ${e}}`},L9={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:x9,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,Ur._)`${i}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,Km.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,Km.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Km.alwaysValidSchema)(s,n)){let h=(0,Ur._)`${u} >= ${o}`;a!==void 0&&(h=(0,Ur._)`${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,Ur._)`${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:Km.Type.Num,compositeRule:!0},h),y()})}function m(h){e.code((0,Ur._)`${h}++`),a===void 0?e.if((0,Ur._)`${h} >= ${o}`,()=>e.assign(d,!0).break()):(e.if((0,Ur._)`${h} > ${a}`,()=>e.assign(d,!1).break()),o===1?e.assign(d,!0):e.if((0,Ur._)`${h} >= ${o}`,()=>e.assign(d,!0)))}}};TS.default=L9});var Ym=N(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.validateSchemaDeps=xi.validatePropertyDeps=xi.error=void 0;var vS=be(),q9=De(),Fu=Br();xi.error={message:({params:{property:t,depsCount:e,deps:n}})=>{let r=e===1?"property":"properties";return(0,vS.str)`must have ${r} ${n} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:n,missingProperty:r}})=>(0,vS._)`{property: ${t},
|
|
180
180
|
missingProperty: ${r},
|
|
181
181
|
depsCount: ${e},
|
|
182
|
-
deps: ${n}}`};var $9={keyword:"dependencies",type:"object",schemaType:"object",error:xi.error,code(t){let[e,n]=F9(t);P$(t,e),N$(t,n)}};function F9({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 P$(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,Fu.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,Fu.checkReportMissingProp)(t,l)}):(n.if((0,vS._)`${c} && (${(0,Fu.checkMissingProp)(t,a,s)})`),(0,Fu.reportMissingProp)(t,s),n.else())}}xi.validatePropertyDeps=P$;function N$(t,e=t.schema){let{gen:n,data:r,keyword:i,it:s}=t,o=n.name("valid");for(let a in e)(0,q9.alwaysValidSchema)(s,e[a])||(n.if((0,Fu.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))}xi.validateSchemaDeps=N$;xi.default=$9});var w$=N(bS=>{"use strict";Object.defineProperty(bS,"__esModule",{value:!0});var R$=be(),B9=De(),j9={message:"property name must be valid",params:({params:t})=>(0,R$._)`{propertyName: ${t.propertyName}}`},U9={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:j9,code(t){let{gen:e,schema:n,data:r,it:i}=t;if((0,B9.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,R$.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};bS.default=U9});var SS=N(_S=>{"use strict";Object.defineProperty(_S,"__esModule",{value:!0});var Xm=Br(),hi=be(),H9=Fr(),Jm=De(),V9={message:"must NOT have additional properties",params:({params:t})=>(0,hi._)`{additionalProperty: ${t.additionalProperty}}`},W9={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:V9,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,Jm.alwaysValidSchema)(o,n))return;let l=(0,Xm.allSchemaProperties)(r.properties),u=(0,Xm.allSchemaProperties)(r.patternProperties);d(),t.ok((0,hi._)`${s} === ${H9.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 b=(0,Jm.schemaRefOrVal)(o,r.properties,"properties");_=(0,Xm.isOwnProperty)(e,b,y)}else l.length?_=(0,hi.or)(...l.map(b=>(0,hi._)`${y} === ${b}`)):_=hi.nil;return u.length&&(_=(0,hi.or)(_,...u.map(b=>(0,hi._)`${(0,Xm.usePattern)(t,b)}.test(${y})`))),(0,hi.not)(_)}function p(y){e.code((0,hi._)`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,Jm.alwaysValidSchema)(o,n)){let _=e.name("valid");c.removeAdditional==="failing"?(h(y,_,!1),e.if((0,hi.not)(_),()=>{t.reset(),p(y)})):(h(y,_),a||e.if((0,hi.not)(_),()=>e.break()))}}function h(y,_,b){let v={keyword:"additionalProperties",dataProp:y,dataPropType:Jm.Type.Str};b===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,_)}}};_S.default=W9});var D$=N(PS=>{"use strict";Object.defineProperty(PS,"__esModule",{value:!0});var z9=Pu(),E$=Br(),kS=De(),C$=SS(),G9={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&&C$.default.code(new z9.KeywordCxt(s,C$.default,"additionalProperties"));let o=(0,E$.allSchemaProperties)(n);for(let d of o)s.definedProperties.add(d);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=kS.mergeEvaluated.props(e,(0,kS.toHash)(o),s.props));let a=o.filter(d=>!(0,kS.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,E$.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)}}};PS.default=G9});var M$=N(NS=>{"use strict";Object.defineProperty(NS,"__esModule",{value:!0});var A$=Br(),Qm=be(),I$=De(),O$=De(),K9={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,A$.allSchemaProperties)(n),c=a.filter(h=>(0,I$.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 Qm.Name)&&(s.props=(0,O$.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,I$.checkStrictMode)(s,`property ${y} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",r,y=>{e.if((0,Qm._)`${(0,A$.usePattern)(t,h)}.test(${y})`,()=>{let _=c.includes(h);_||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:y,dataPropType:O$.Type.Str},u),s.opts.unevaluated&&d!==!0?e.assign((0,Qm._)`${d}[${y}]`,!0):!_&&!s.allErrors&&e.if((0,Qm.not)(u),()=>e.break())})})}}};NS.default=K9});var x$=N(RS=>{"use strict";Object.defineProperty(RS,"__esModule",{value:!0});var Y9=De(),X9={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:n,it:r}=t;if((0,Y9.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"}};RS.default=X9});var L$=N(wS=>{"use strict";Object.defineProperty(wS,"__esModule",{value:!0});var J9=Br(),Q9={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:J9.validateUnion,error:{message:"must match a schema in anyOf"}};wS.default=Q9});var q$=N(ES=>{"use strict";Object.defineProperty(ES,"__esModule",{value:!0});var Zm=be(),Z9=De(),eJ={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Zm._)`{passingSchemas: ${t.passing}}`},tJ={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:eJ,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,Z9.alwaysValidSchema)(i,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Zm._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Zm._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Zm.Name)})})}}};ES.default=tJ});var $$=N(CS=>{"use strict";Object.defineProperty(CS,"__esModule",{value:!0});var nJ=De(),rJ={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,nJ.alwaysValidSchema)(r,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};CS.default=rJ});var j$=N(DS=>{"use strict";Object.defineProperty(DS,"__esModule",{value:!0});var eg=be(),B$=De(),iJ={message:({params:t})=>(0,eg.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,eg._)`{failingKeyword: ${t.ifClause}}`},sJ={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:iJ,code(t){let{gen:e,parentSchema:n,it:r}=t;n.then===void 0&&n.else===void 0&&(0,B$.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let i=F$(r,"then"),s=F$(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,eg.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,eg._)`${u}`):t.setParams({ifClause:u})}}}};function F$(t,e){let n=t.schema[e];return n!==void 0&&!(0,B$.alwaysValidSchema)(t,n)}DS.default=sJ});var U$=N(AS=>{"use strict";Object.defineProperty(AS,"__esModule",{value:!0});var oJ=De(),aJ={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){e.if===void 0&&(0,oJ.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};AS.default=aJ});var H$=N(IS=>{"use strict";Object.defineProperty(IS,"__esModule",{value:!0});var cJ=hS(),lJ=b$(),uJ=mS(),dJ=S$(),fJ=k$(),pJ=Ym(),hJ=w$(),mJ=SS(),gJ=D$(),yJ=M$(),TJ=x$(),vJ=L$(),bJ=q$(),_J=$$(),SJ=j$(),kJ=U$();function PJ(t=!1){let e=[TJ.default,vJ.default,bJ.default,_J.default,SJ.default,kJ.default,hJ.default,mJ.default,pJ.default,gJ.default,yJ.default];return t?e.push(lJ.default,dJ.default):e.push(cJ.default,uJ.default),e.push(fJ.default),e}IS.default=PJ});var V$=N(OS=>{"use strict";Object.defineProperty(OS,"__esModule",{value:!0});var jt=be(),NJ={message:({schemaCode:t})=>(0,jt.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,jt._)`{format: ${t}}`},RJ={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:NJ,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,jt._)`${m}[${o}]`),y=n.let("fType"),_=n.let("format");n.if((0,jt._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>n.assign(y,(0,jt._)`${h}.type || "string"`).assign(_,(0,jt._)`${h}.validate`),()=>n.assign(y,(0,jt._)`"string"`).assign(_,h)),t.fail$data((0,jt.or)(b(),v()));function b(){return c.strictSchema===!1?jt.nil:(0,jt._)`${o} && !${_}`}function v(){let P=u.$async?(0,jt._)`(${h}.async ? await ${_}(${r}) : ${_}(${r}))`:(0,jt._)`${_}(${r})`,R=(0,jt._)`(typeof ${_} == "function" ? ${P} : ${_}.test(${r}))`;return(0,jt._)`${_} && ${_} !== true && ${y} === ${e} && !${R}`}}function p(){let m=d.formats[s];if(!m){b();return}if(m===!0)return;let[h,y,_]=v(m);h===e&&t.pass(P());function b(){if(c.strictSchema===!1){d.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function v(R){let q=R instanceof RegExp?(0,jt.regexpCode)(R):c.code.formats?(0,jt._)`${c.code.formats}${(0,jt.getProperty)(s)}`:void 0,O=n.scopeValue("formats",{key:s,ref:R,code:q});return typeof R=="object"&&!(R instanceof RegExp)?[R.type||"string",R.validate,(0,jt._)`${O}.validate`]:["string",R,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,jt._)`await ${_}(${r})`}return typeof y=="function"?(0,jt._)`${_}(${r})`:(0,jt._)`${_}.test(${r})`}}}};OS.default=RJ});var W$=N(MS=>{"use strict";Object.defineProperty(MS,"__esModule",{value:!0});var wJ=V$(),EJ=[wJ.default];MS.default=EJ});var z$=N(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.contentVocabulary=hc.metadataVocabulary=void 0;hc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];hc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var K$=N(xS=>{"use strict";Object.defineProperty(xS,"__esModule",{value:!0});var CJ=n$(),DJ=g$(),AJ=H$(),IJ=W$(),G$=z$(),OJ=[CJ.default,DJ.default,(0,AJ.default)(),IJ.default,G$.metadataVocabulary,G$.contentVocabulary];xS.default=OJ});var qS=N(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});Bu.dynamicAnchor=void 0;var LS=be(),MJ=Fr(),Y$=Ru(),xJ=Hm(),LJ={keyword:"$dynamicAnchor",schemaType:"string",code:t=>X$(t,t.schema)};function X$(t,e){let{gen:n,it:r}=t;r.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,LS._)`${MJ.default.dynamicAnchors}${(0,LS.getProperty)(e)}`,s=r.errSchemaPath==="#"?r.validateName:qJ(t);n.if((0,LS._)`!${i}`,()=>n.assign(i,s))}Bu.dynamicAnchor=X$;function qJ(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 Y$.SchemaEnv({schema:n,schemaId:c,root:i,baseId:s,localRefs:o,meta:a});return Y$.compileSchema.call(r,l),(0,xJ.getValidate)(t,l)}Bu.default=LJ});var $S=N(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});ju.dynamicRef=void 0;var J$=be(),$J=Fr(),Q$=Hm(),FJ={keyword:"$dynamicRef",schemaType:"string",code:t=>Z$(t,t.schema)};function Z$(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,J$._)`${$J.default.dynamicAnchors}${(0,J$.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,Q$.callRef)(t,c),n.let(l,!0)}):()=>(0,Q$.callRef)(t,c)}}ju.dynamicRef=Z$;ju.default=FJ});var eF=N(FS=>{"use strict";Object.defineProperty(FS,"__esModule",{value:!0});var BJ=qS(),jJ=De(),UJ={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,BJ.dynamicAnchor)(t,""):(0,jJ.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};FS.default=UJ});var tF=N(BS=>{"use strict";Object.defineProperty(BS,"__esModule",{value:!0});var HJ=$S(),VJ={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,HJ.dynamicRef)(t,t.schema)};BS.default=VJ});var nF=N(jS=>{"use strict";Object.defineProperty(jS,"__esModule",{value:!0});var WJ=qS(),zJ=$S(),GJ=eF(),KJ=tF(),YJ=[WJ.default,zJ.default,GJ.default,KJ.default];jS.default=YJ});var iF=N(US=>{"use strict";Object.defineProperty(US,"__esModule",{value:!0});var rF=Ym(),XJ={keyword:"dependentRequired",type:"object",schemaType:"object",error:rF.error,code:t=>(0,rF.validatePropertyDeps)(t)};US.default=XJ});var sF=N(HS=>{"use strict";Object.defineProperty(HS,"__esModule",{value:!0});var JJ=Ym(),QJ={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,JJ.validateSchemaDeps)(t)};HS.default=QJ});var oF=N(VS=>{"use strict";Object.defineProperty(VS,"__esModule",{value:!0});var ZJ=De(),e6={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:n}){e.contains===void 0&&(0,ZJ.checkStrictMode)(n,`"${t}" without "contains" is ignored`)}};VS.default=e6});var aF=N(WS=>{"use strict";Object.defineProperty(WS,"__esModule",{value:!0});var t6=iF(),n6=sF(),r6=oF(),i6=[t6.default,n6.default,r6.default];WS.default=i6});var lF=N(zS=>{"use strict";Object.defineProperty(zS,"__esModule",{value:!0});var Ws=be(),cF=De(),s6=Fr(),o6={message:"must NOT have unevaluated properties",params:({params:t})=>(0,Ws._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},a6={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:o6,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 Ws.Name?e.if((0,Ws._)`${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,Ws._)`${i} === ${s6.default.errors}`);function c(d){if(n===!1){t.setParams({unevaluatedProperty:d}),t.error(),o||e.break();return}if(!(0,cF.alwaysValidSchema)(s,n)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:cF.Type.Str},f),o||e.if((0,Ws.not)(f),()=>e.break())}}function l(d,f){return(0,Ws._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let m in d)d[m]===!0&&p.push((0,Ws._)`${f} !== ${m}`);return(0,Ws.and)(...p)}}};zS.default=a6});var dF=N(GS=>{"use strict";Object.defineProperty(GS,"__esModule",{value:!0});var Fo=be(),uF=De(),c6={message:({params:{len:t}})=>(0,Fo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Fo._)`{limit: ${t}}`},l6={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:c6,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,Fo._)`${r}.length`);if(n===!1)t.setParams({len:s}),t.fail((0,Fo._)`${o} > ${s}`);else if(typeof n=="object"&&!(0,uF.alwaysValidSchema)(i,n)){let c=e.var("valid",(0,Fo._)`${o} <= ${s}`);e.if((0,Fo.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:uF.Type.Num},c),i.allErrors||e.if((0,Fo.not)(c),()=>e.break())})}}};GS.default=l6});var fF=N(KS=>{"use strict";Object.defineProperty(KS,"__esModule",{value:!0});var u6=lF(),d6=dF(),f6=[u6.default,d6.default];KS.default=f6});var hF=N(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});tg.DiscrError=void 0;var pF;(function(t){t.Tag="tag",t.Mapping="mapping"})(pF||(tg.DiscrError=pF={}))});var gF=N(XS=>{"use strict";Object.defineProperty(XS,"__esModule",{value:!0});var mc=be(),YS=hF(),mF=Ru(),p6=Nu(),h6=De(),m6={message:({params:{discrError:t,tagName:e}})=>t===YS.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>(0,mc._)`{error: ${t}, tag: ${n}, tagValue: ${e}}`},g6={keyword:"discriminator",type:"object",schemaType:"object",error:m6,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,mc._)`${n}${(0,mc.getProperty)(a)}`);e.if((0,mc._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:YS.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,mc._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:YS.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,mc.Name),m}function f(){var p;let m={},h=_(i),y=!0;for(let P=0;P<o.length;P++){let R=o[P];if(R?.$ref&&!(0,h6.schemaHasRulesButRef)(R,s.self.RULES)){let O=R.$ref;if(R=mF.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,O),R instanceof mF.SchemaEnv&&(R=R.schema),R===void 0)throw new p6.default(s.opts.uriResolver,s.baseId,O)}let q=(p=R?.properties)===null||p===void 0?void 0:p[a];if(typeof q!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(h||_(R)),b(q,P)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return m;function _({required:P}){return Array.isArray(P)&&P.includes(a)}function b(P,R){if(P.const)v(P.const,R);else if(P.enum)for(let q of P.enum)v(q,R);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(P,R){if(typeof P!="string"||P in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[P]=R}}}};XS.default=g6});var yF=N((QEe,y6)=>{y6.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 TF=N((ZEe,T6)=>{T6.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 vF=N((eCe,v6)=>{v6.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 bF=N((tCe,b6)=>{b6.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 _F=N((nCe,_6)=>{_6.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 SF=N((rCe,S6)=>{S6.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 kF=N((iCe,k6)=>{k6.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 PF=N(JS=>{"use strict";Object.defineProperty(JS,"__esModule",{value:!0});var P6=yF(),N6=TF(),R6=vF(),w6=bF(),E6=_F(),C6=SF(),D6=kF(),A6=["/properties"];function I6(t){return[P6,N6,R6,w6,e(this,E6),C6,e(this,D6)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function e(n,r){return t?n.$dataMetaSchema(r,A6):r}}JS.default=I6});var NF=N((Pt,ZS)=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.MissingRefError=Pt.ValidationError=Pt.CodeGen=Pt.Name=Pt.nil=Pt.stringify=Pt.str=Pt._=Pt.KeywordCxt=Pt.Ajv2019=void 0;var O6=Jq(),M6=K$(),x6=nF(),L6=aF(),q6=fF(),$6=gF(),F6=PF(),QS="https://json-schema.org/draft/2019-09/schema",gc=class extends O6.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(x6.default),M6.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(L6.default),this.addVocabulary(q6.default),this.opts.discriminator&&this.addKeyword($6.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:n}=this.opts;n&&(F6.default.call(this,e),this.refs["http://json-schema.org/schema"]=QS)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(QS)?QS:void 0)}};Pt.Ajv2019=gc;ZS.exports=Pt=gc;ZS.exports.Ajv2019=gc;Object.defineProperty(Pt,"__esModule",{value:!0});Pt.default=gc;var B6=Pu();Object.defineProperty(Pt,"KeywordCxt",{enumerable:!0,get:function(){return B6.KeywordCxt}});var yc=be();Object.defineProperty(Pt,"_",{enumerable:!0,get:function(){return yc._}});Object.defineProperty(Pt,"str",{enumerable:!0,get:function(){return yc.str}});Object.defineProperty(Pt,"stringify",{enumerable:!0,get:function(){return yc.stringify}});Object.defineProperty(Pt,"nil",{enumerable:!0,get:function(){return yc.nil}});Object.defineProperty(Pt,"Name",{enumerable:!0,get:function(){return yc.Name}});Object.defineProperty(Pt,"CodeGen",{enumerable:!0,get:function(){return yc.CodeGen}});var j6=xm();Object.defineProperty(Pt,"ValidationError",{enumerable:!0,get:function(){return j6.default}});var U6=Nu();Object.defineProperty(Pt,"MissingRefError",{enumerable:!0,get:function(){return U6.default}})});var bc=require("path"),He=L(Xw());var If=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=Qw(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=Jw(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=Jw(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}},Vt;(function(t){function e(i,s,o,a){return new If(i,s,o,a)}t.create=e;function n(i,s,o){if(i instanceof If)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=lT(s.map(WU),(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})(Vt||(Vt={}));function lT(t,e){if(t.length<=1)return t;let n=t.length/2|0,r=t.slice(0,n),i=t.slice(n);lT(r,e),lT(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 Jw(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 Qw(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 WU(t){let e=Qw(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var Of=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],Mf=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var dT=L(require("url")),aE=require("crypto"),ga=require("path"),pn=L(U());var uT=L(U());var Kn=L(U());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 fe(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(!fe(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(![Kn.SymbolKind.File,Kn.SymbolKind.Class,Kn.SymbolKind.Constant].some(i=>i===e))return[];let n=Yn(this.fsPath),r=n?.range??ce(this);return[{location:Kn.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===Kn.SymbolKind.File||i.kind===Kn.SymbolKind.Class||i.kind===Kn.SymbolKind.Constant)]}buildSemanticTokens(e){this._children.forEach(n=>n.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(Ui(this.semanticTokenType),Hi(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 Kn.Range.create(Kn.Position.create(this.firstToken.pos.line,this.firstToken.pos.col),Kn.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??=Uc(this.toString(),e),this.#e}#n;evaluate(e){return this.#n??=Me(`${this.operator?this.operator.toString():""}${this.resolve(e)}`),this.#n}#r;isTrue(e){return this.#r??=Me(`!!(${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}}},tn=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 Me(`!!(${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 bi=class extends ge{constructor(n,r,i){super(r);this.value=n;this.docSymbolsMeta={name:`param${i+1}`,kind:uT.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},Wt=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 fe(this.fsPath,n)?[{name:this.functionName.name,kind:uT.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?Me(`!!(${this.operator}${r})`):r}return super.isTrue(n)}};var Qr=L(U());var rE=L(U());var Zw=L(U());var ie=class extends te{constructor(n,r){super(r);this.value=n;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:Zw.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 tE=L(U());var eE=L(U());var nn=class extends ge{constructor(n,r,i=10){super(r);this.value=n;this.radix=i;this.docSymbolsMeta={name:this.value.toString(),kind:eE.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 bt=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Cell Array",kind:tE.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 nn)){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 nE=L(U());var fr=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Byte String Value",kind:nE.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 Je=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}}},Ne=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:rE.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 ie?n.value.value:n.value instanceof bt?n.value.values.map(r=>r.value instanceof nn?r.value.value:NaN):n.value instanceof fr?n.value.values.map(r=>r.value?.value??NaN):NaN:null)}getFlatAstValues(){return this.values?.values.flatMap(n=>n?n.value instanceof ie?n.value:n.value instanceof bt?n.value.values.map(r=>r.value):n.value instanceof fr?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"}`:""};${lo(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 iE=L(U());var fn=class extends te{constructor(n,r){super();this.keyword=r;this.addChild(r),this.docSymbolsMeta={name:n,kind:iE.SymbolKind.Function}}};var Xn=class extends fn{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 at=class extends fn{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 sE=L(U());var se=class extends te{constructor(n){super();this.label=n;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:sE.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 we=class t extends te{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof nt)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 Xn)}addNodeChild(e){this.addChild(e)}},nt=class extends we{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Qr.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ne)}#e;get name(){return this.#e??=new $e("/",de(this.firstToken)),this.#e}get identifierAst(){return this.name}get deleteProperties(){return this.children.filter(e=>e instanceof at)}get nodes(){return this.children.filter(e=>e instanceof Ee)}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&&ne(this.openScope),scopeClose:this.closeScope&&ne(this.closeScope,!1)}}},ct=class extends we{constructor(n=[]){super();this.labels=n;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Qr.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 se?r=n.value:r=n?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:r??"DTC Name",kind:Qr.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 Ee)}get pathName(){if(this.reference instanceof se&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(n=>n instanceof Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof at)}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&&ne(this.openScope),scopeClose:this.closeScope&&ne(this.closeScope,!1)}}},Ee=class t extends we{constructor(n=[],r){super();this.labels=n;this.omitIfNoRef=r;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Qr.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:Qr.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 Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof at)}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&&ne(this.openScope),scopeClose:this.closeScope&&ne(this.closeScope,!1)}}},Hc=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}}},$e=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(Ui("type"),Hi("declaration"),i,i),this.address!==void 0&&this.address.forEach(s=>{n(Ui("decorator"),Hi("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:Qr.Range.create(Qr.Position.create(n.pos.line,n.pos.col),Qr.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 rn=(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 ne=(t,e=!0)=>pn.Position.create(t.pos.line,e?t.pos.colEnd:t.pos.col),ce=t=>rn(t.firstToken,t.lastToken),Ui=t=>Of.findIndex(e=>e===t),Hi=t=>Mf.findIndex(e=>e===t),gs=(t,e,n)=>!fe(t.fsPath,e)||n.line<t.pos.line?!1:n.line>t.pos.line?!0:n.character>=t.pos.colEnd,fT=(t,e,n)=>fe(t.fsPath,e)?n.line<t.pos.line?!0:n.line>t.pos.line?!1:n.character<t.pos.col:!1,Xt=(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)&&fe(t.fsPath,e))},qf=(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)},cE=(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&&fe(t.fsPath,e))},lE=(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=>Xt(s,e,n));return r},Vc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].find(s=>fT(s.lastToken,e,n));return r===t?void 0:r},Wc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>gs(s.firstToken,e,n));return r===t?void 0:r},pT="#virtual",lo=t=>t.includes(pT),$f=(t,e)=>`${t}?loc=${e.start.line}:${e.start.character}-${e.end.line}:${e.end.character}${pT}`,Yn=t=>{if(!lo(t))return;let[e,n]=t.split("?"),[r,i]=n.replace("loc=","").replace(pT,"").split("-"),[s,o]=r.split(":"),[a,c]=i.split(":");return{docFsPath:e,range:pn.Range.create(pn.Position.create(Number.parseInt(s),Number.parseInt(o)),pn.Position.create(Number.parseInt(a),Number.parseInt(c)))}},hT=t=>{let e=Yn(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=Yn(r);return{range:i?.range??n,fsPath:i?.docFsPath??r,templateStrings:[]}}))},z=(t,e,n=e,r,{severity:i=pn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,inclusiveStart:u,inclusiveEnd:d}={severity:pn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let f={issues:Array.isArray(t)?t:[t],range:rn(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};hT(f);let p,m=()=>(p??={severity:f.severity,range:f.range,message:f.issues?f.issues.map(YU).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}},zt=(t,e,n,r,{severity:i=pn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,linkedToTemplateStrings:u=[]}={severity:pn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let d={issues:Array.isArray(t)?t:[t],range:rn(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};hT(d);let f,p=()=>(f??={severity:d.severity,range:d.range,message:XU(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(m=>({message:d.issues.map(h=>JU(h,m.templateStrings)).join(" or "),location:{uri:ue(m.fsPath),range:m.range}}))]},f);return r?.resettableIssues.push(p),{raw:d,diagnostic:p}},j=(t,e,n,r,{severity:i=pn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l}={severity:pn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let u={issues:Array.isArray(t)?t:[t],range:rn(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};hT(u);let d,f=()=>(d??={severity:u.severity,range:u.range,message:QU(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(ZU).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 Ve(t,e,n,{severity:r=pn.DiagnosticSeverity.Warning,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:pn.DiagnosticSeverity.Warning,linkedTo:[],templateStrings:[],edit:[],codeActionTitle:void 0},l=n){let u={issues:Array.isArray(t)?t:[t],range:pn.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:eH(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(tH).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 uE=(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 wt(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=>Xt(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(fe(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 H=(t,e)=>t?.tokens.some(n=>n===e),it=(t,e)=>n=>n?.value&&(e?.caseInsensitive?t.toLowerCase()===n.value.toLowerCase():t===n.value)?"yes":e?.allowPartial?zU(t)(n):"no",Fe=t=>e=>e?.tokens.some(n=>n===t)?"yes":"no",zU=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",hn=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&fe(t.fsPath,e.fsPath),Gt=(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&&hn(t,e),Ff=t=>t.map((e,n)=>({index:n,context:e,files:e.getContextFiles()})),Nn=(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=>fe(s,e.fsPath))?n:Ff(t).sort(s=>s.context.id===r?-1:0).find(s=>s.files.some(o=>fe(o,e.fsPath)))?.context},mT=(t,e)=>Ff(t).filter(r=>r.files.some(i=>fe(i,e))).map(r=>r.context),dE=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 GU(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 KU=0,Uc=(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=GU(c).map(d=>d.trim()).map(d=>d==="__COUNTER__"?(KU++).toString():d).map(d=>Uc(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 gT(t){return t.replace(/'(.)'/g,(e,n)=>n.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Me(t){try{return(0,eval)(gT(t))}catch{}return t}var ue=t=>dT.default.pathToFileURL(t).toString(),Se=t=>lt(dT.default.fileURLToPath(t)),fE=(t,e)=>{let n=(0,ga.relative)(t,e);return!!n&&!n.startsWith("..")&&!(0,ga.isAbsolute)(n)},fe=(t,e)=>!t||!e?!1:t===e,lt=t=>(0,ga.normalize)(process.platform==="win32"?t.toLowerCase():t),Vi=t=>(0,aE.createHash)("sha256").update([lt(t.dtsFile),...t.includePaths.map(lt),...t.overlays.map(lt),t.bindingType,...t.zephyrBindings.map(lt),...t.deviceOrgBindingsMetaSchema.map(lt),...t.deviceOrgTreeBindings.map(lt),`showFormattingErrorAsDiagnostics-${t.showFormattingErrorAsDiagnostics}`,`disableFileWatchers-${t.disableFileWatchers}`].join(":")).digest("hex"),YU=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"}},XU=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 "),JU=(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"}},QU=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 ",""),ZU=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"}},eH=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 11:return"Node address size is determined by '@size-cells', Remove 'ull'.";case 12:return`'\\' is not necessary. ${t.codeActionTitle}`;case 13:return`Node does not contribute anything. ${t.codeActionTitle}`;case 14:return`Property is redefined in same closure. ${t.codeActionTitle}`;case 15:return`${t.codeActionTitle}`}}).join(" or "),tH=t=>"TODO",pE=(t,e)=>At(t,e)<=0?t:e,hE=(t,e)=>At(t,e)>=0?t:e,At=(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},Nr=(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},yT=(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},nH=(t,e)=>Nr(t,e),mE=(t,e)=>{let n=[];for(let r of t){let i=r.childAddress,s=r.length,o=Nr(i,s);if(At(e,i)>=0&&At(e,o)<0){let a=yT(e,i),c=r.parentAddress,l=nH(c,a),u=Nr(c,s);n.push({start:l,end:u,range:rn(r.rangeTokens.start,r.rangeTokens.end),fsPath:r.rangeTokens.start.fsPath})}}return n};function gE(t){return Array.isArray(t)&&Array.isArray(t[0])}function zc(t){return!t||t instanceof Wt?t:zc(t.parentNode)}function Jn(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 oE(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 yE(t,e){return oE(t.end,e.start)>0&&oE(t.start,e.end)<0}var TE=(t,e)=>{let n=vE(t,e),r=bE(t,e);n&&(t.topComment=n),r&&(t.endComment=r)},vE=(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=vE(n,e);return r&&(r.astAfterComment=t,n.astAfterComment=void 0),r??n},bE=(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=bE(n,e);return r&&(r.astBeforeComment=t,n.astBeforeComment=void 0),r??n},uo=(t,e,n)=>{let r=[42,44,45,36];return n||r.push(52,32,53,8,49),t.severity===pn.DiagnosticSeverity.Error&&fe(t.fsPath,e)&&!r.some(i=>t.issues.includes(i))};function Bf(t){let e=t?.charAt(0);return!!e&&(e>="A"&&e<="Z"||e>="a"&&e<="z")}var jf=t=>{if(t)return t instanceof we?t:jf(t?.parentNode)},fo=(t,e,n=0)=>{if(!e||!e.parentNode?.fsPath)return n;let r=jf(e.parentNode);return fo(t,r,n+1)};function _E(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}function SE(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):""}var sl=require("fs"),Na=require("path"),go=L(U());var pD=require("path"),wr=L(U());var Mn=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 Jt=t=>t instanceof fn?!0:t instanceof we?!1:t.parentNode?Jt(t.parentNode):!1;var TT=t=>{if(t instanceof Ne)return t;if(!(t instanceof we))return t.parentNode?TT(t.parentNode):void 0},po=t=>!t||t instanceof Ne?!1:t instanceof Mn||po(t.parentNode),ya=t=>[...t.map(e=>{if(e instanceof Ee||e instanceof nt)return e.name;if(e instanceof ct)return e.reference})].filter(e=>!!e),vT=(t,e)=>e?e.parentNode===t||vT(t,e.parentNode):!1;var Lt=L(U());var kE=L(U());var ei=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 $e?r.buildSemanticTokens(n):n(Ui("operator"),Hi("declaration"),r.firstToken,r.lastToken)})}},ut=class extends te{constructor(n){super();this.path=n;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:kE.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:Lt.MarkupKind.Markdown,value:["### Type","**DTS native type** ",`${this.type.map(e=>e.types.join(" or ")).join(",")}
|
|
182
|
+
deps: ${n}}`};var $9={keyword:"dependencies",type:"object",schemaType:"object",error:xi.error,code(t){let[e,n]=F9(t);P$(t,e),N$(t,n)}};function F9({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 P$(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,Fu.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,Fu.checkReportMissingProp)(t,l)}):(n.if((0,vS._)`${c} && (${(0,Fu.checkMissingProp)(t,a,s)})`),(0,Fu.reportMissingProp)(t,s),n.else())}}xi.validatePropertyDeps=P$;function N$(t,e=t.schema){let{gen:n,data:r,keyword:i,it:s}=t,o=n.name("valid");for(let a in e)(0,q9.alwaysValidSchema)(s,e[a])||(n.if((0,Fu.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))}xi.validateSchemaDeps=N$;xi.default=$9});var w$=N(bS=>{"use strict";Object.defineProperty(bS,"__esModule",{value:!0});var R$=be(),B9=De(),j9={message:"property name must be valid",params:({params:t})=>(0,R$._)`{propertyName: ${t.propertyName}}`},U9={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:j9,code(t){let{gen:e,schema:n,data:r,it:i}=t;if((0,B9.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,R$.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};bS.default=U9});var SS=N(_S=>{"use strict";Object.defineProperty(_S,"__esModule",{value:!0});var Xm=Br(),hi=be(),H9=Fr(),Jm=De(),V9={message:"must NOT have additional properties",params:({params:t})=>(0,hi._)`{additionalProperty: ${t.additionalProperty}}`},W9={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:V9,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,Jm.alwaysValidSchema)(o,n))return;let l=(0,Xm.allSchemaProperties)(r.properties),u=(0,Xm.allSchemaProperties)(r.patternProperties);d(),t.ok((0,hi._)`${s} === ${H9.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 b=(0,Jm.schemaRefOrVal)(o,r.properties,"properties");_=(0,Xm.isOwnProperty)(e,b,y)}else l.length?_=(0,hi.or)(...l.map(b=>(0,hi._)`${y} === ${b}`)):_=hi.nil;return u.length&&(_=(0,hi.or)(_,...u.map(b=>(0,hi._)`${(0,Xm.usePattern)(t,b)}.test(${y})`))),(0,hi.not)(_)}function p(y){e.code((0,hi._)`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,Jm.alwaysValidSchema)(o,n)){let _=e.name("valid");c.removeAdditional==="failing"?(h(y,_,!1),e.if((0,hi.not)(_),()=>{t.reset(),p(y)})):(h(y,_),a||e.if((0,hi.not)(_),()=>e.break()))}}function h(y,_,b){let v={keyword:"additionalProperties",dataProp:y,dataPropType:Jm.Type.Str};b===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,_)}}};_S.default=W9});var D$=N(PS=>{"use strict";Object.defineProperty(PS,"__esModule",{value:!0});var z9=Pu(),E$=Br(),kS=De(),C$=SS(),G9={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&&C$.default.code(new z9.KeywordCxt(s,C$.default,"additionalProperties"));let o=(0,E$.allSchemaProperties)(n);for(let d of o)s.definedProperties.add(d);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=kS.mergeEvaluated.props(e,(0,kS.toHash)(o),s.props));let a=o.filter(d=>!(0,kS.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,E$.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)}}};PS.default=G9});var M$=N(NS=>{"use strict";Object.defineProperty(NS,"__esModule",{value:!0});var A$=Br(),Qm=be(),I$=De(),O$=De(),K9={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,A$.allSchemaProperties)(n),c=a.filter(h=>(0,I$.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 Qm.Name)&&(s.props=(0,O$.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,I$.checkStrictMode)(s,`property ${y} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",r,y=>{e.if((0,Qm._)`${(0,A$.usePattern)(t,h)}.test(${y})`,()=>{let _=c.includes(h);_||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:y,dataPropType:O$.Type.Str},u),s.opts.unevaluated&&d!==!0?e.assign((0,Qm._)`${d}[${y}]`,!0):!_&&!s.allErrors&&e.if((0,Qm.not)(u),()=>e.break())})})}}};NS.default=K9});var x$=N(RS=>{"use strict";Object.defineProperty(RS,"__esModule",{value:!0});var Y9=De(),X9={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:n,it:r}=t;if((0,Y9.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"}};RS.default=X9});var L$=N(wS=>{"use strict";Object.defineProperty(wS,"__esModule",{value:!0});var J9=Br(),Q9={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:J9.validateUnion,error:{message:"must match a schema in anyOf"}};wS.default=Q9});var q$=N(ES=>{"use strict";Object.defineProperty(ES,"__esModule",{value:!0});var Zm=be(),Z9=De(),eJ={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Zm._)`{passingSchemas: ${t.passing}}`},tJ={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:eJ,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,Z9.alwaysValidSchema)(i,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Zm._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Zm._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Zm.Name)})})}}};ES.default=tJ});var $$=N(CS=>{"use strict";Object.defineProperty(CS,"__esModule",{value:!0});var nJ=De(),rJ={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,nJ.alwaysValidSchema)(r,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};CS.default=rJ});var j$=N(DS=>{"use strict";Object.defineProperty(DS,"__esModule",{value:!0});var eg=be(),B$=De(),iJ={message:({params:t})=>(0,eg.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,eg._)`{failingKeyword: ${t.ifClause}}`},sJ={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:iJ,code(t){let{gen:e,parentSchema:n,it:r}=t;n.then===void 0&&n.else===void 0&&(0,B$.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let i=F$(r,"then"),s=F$(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,eg.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,eg._)`${u}`):t.setParams({ifClause:u})}}}};function F$(t,e){let n=t.schema[e];return n!==void 0&&!(0,B$.alwaysValidSchema)(t,n)}DS.default=sJ});var U$=N(AS=>{"use strict";Object.defineProperty(AS,"__esModule",{value:!0});var oJ=De(),aJ={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){e.if===void 0&&(0,oJ.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};AS.default=aJ});var H$=N(IS=>{"use strict";Object.defineProperty(IS,"__esModule",{value:!0});var cJ=hS(),lJ=b$(),uJ=mS(),dJ=S$(),fJ=k$(),pJ=Ym(),hJ=w$(),mJ=SS(),gJ=D$(),yJ=M$(),TJ=x$(),vJ=L$(),bJ=q$(),_J=$$(),SJ=j$(),kJ=U$();function PJ(t=!1){let e=[TJ.default,vJ.default,bJ.default,_J.default,SJ.default,kJ.default,hJ.default,mJ.default,pJ.default,gJ.default,yJ.default];return t?e.push(lJ.default,dJ.default):e.push(cJ.default,uJ.default),e.push(fJ.default),e}IS.default=PJ});var V$=N(OS=>{"use strict";Object.defineProperty(OS,"__esModule",{value:!0});var jt=be(),NJ={message:({schemaCode:t})=>(0,jt.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,jt._)`{format: ${t}}`},RJ={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:NJ,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,jt._)`${m}[${o}]`),y=n.let("fType"),_=n.let("format");n.if((0,jt._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>n.assign(y,(0,jt._)`${h}.type || "string"`).assign(_,(0,jt._)`${h}.validate`),()=>n.assign(y,(0,jt._)`"string"`).assign(_,h)),t.fail$data((0,jt.or)(b(),v()));function b(){return c.strictSchema===!1?jt.nil:(0,jt._)`${o} && !${_}`}function v(){let P=u.$async?(0,jt._)`(${h}.async ? await ${_}(${r}) : ${_}(${r}))`:(0,jt._)`${_}(${r})`,R=(0,jt._)`(typeof ${_} == "function" ? ${P} : ${_}.test(${r}))`;return(0,jt._)`${_} && ${_} !== true && ${y} === ${e} && !${R}`}}function p(){let m=d.formats[s];if(!m){b();return}if(m===!0)return;let[h,y,_]=v(m);h===e&&t.pass(P());function b(){if(c.strictSchema===!1){d.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function v(R){let q=R instanceof RegExp?(0,jt.regexpCode)(R):c.code.formats?(0,jt._)`${c.code.formats}${(0,jt.getProperty)(s)}`:void 0,O=n.scopeValue("formats",{key:s,ref:R,code:q});return typeof R=="object"&&!(R instanceof RegExp)?[R.type||"string",R.validate,(0,jt._)`${O}.validate`]:["string",R,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,jt._)`await ${_}(${r})`}return typeof y=="function"?(0,jt._)`${_}(${r})`:(0,jt._)`${_}.test(${r})`}}}};OS.default=RJ});var W$=N(MS=>{"use strict";Object.defineProperty(MS,"__esModule",{value:!0});var wJ=V$(),EJ=[wJ.default];MS.default=EJ});var z$=N(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.contentVocabulary=hc.metadataVocabulary=void 0;hc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];hc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var K$=N(xS=>{"use strict";Object.defineProperty(xS,"__esModule",{value:!0});var CJ=n$(),DJ=g$(),AJ=H$(),IJ=W$(),G$=z$(),OJ=[CJ.default,DJ.default,(0,AJ.default)(),IJ.default,G$.metadataVocabulary,G$.contentVocabulary];xS.default=OJ});var qS=N(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});Bu.dynamicAnchor=void 0;var LS=be(),MJ=Fr(),Y$=Ru(),xJ=Hm(),LJ={keyword:"$dynamicAnchor",schemaType:"string",code:t=>X$(t,t.schema)};function X$(t,e){let{gen:n,it:r}=t;r.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,LS._)`${MJ.default.dynamicAnchors}${(0,LS.getProperty)(e)}`,s=r.errSchemaPath==="#"?r.validateName:qJ(t);n.if((0,LS._)`!${i}`,()=>n.assign(i,s))}Bu.dynamicAnchor=X$;function qJ(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 Y$.SchemaEnv({schema:n,schemaId:c,root:i,baseId:s,localRefs:o,meta:a});return Y$.compileSchema.call(r,l),(0,xJ.getValidate)(t,l)}Bu.default=LJ});var $S=N(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});ju.dynamicRef=void 0;var J$=be(),$J=Fr(),Q$=Hm(),FJ={keyword:"$dynamicRef",schemaType:"string",code:t=>Z$(t,t.schema)};function Z$(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,J$._)`${$J.default.dynamicAnchors}${(0,J$.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,Q$.callRef)(t,c),n.let(l,!0)}):()=>(0,Q$.callRef)(t,c)}}ju.dynamicRef=Z$;ju.default=FJ});var eF=N(FS=>{"use strict";Object.defineProperty(FS,"__esModule",{value:!0});var BJ=qS(),jJ=De(),UJ={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,BJ.dynamicAnchor)(t,""):(0,jJ.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};FS.default=UJ});var tF=N(BS=>{"use strict";Object.defineProperty(BS,"__esModule",{value:!0});var HJ=$S(),VJ={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,HJ.dynamicRef)(t,t.schema)};BS.default=VJ});var nF=N(jS=>{"use strict";Object.defineProperty(jS,"__esModule",{value:!0});var WJ=qS(),zJ=$S(),GJ=eF(),KJ=tF(),YJ=[WJ.default,zJ.default,GJ.default,KJ.default];jS.default=YJ});var iF=N(US=>{"use strict";Object.defineProperty(US,"__esModule",{value:!0});var rF=Ym(),XJ={keyword:"dependentRequired",type:"object",schemaType:"object",error:rF.error,code:t=>(0,rF.validatePropertyDeps)(t)};US.default=XJ});var sF=N(HS=>{"use strict";Object.defineProperty(HS,"__esModule",{value:!0});var JJ=Ym(),QJ={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,JJ.validateSchemaDeps)(t)};HS.default=QJ});var oF=N(VS=>{"use strict";Object.defineProperty(VS,"__esModule",{value:!0});var ZJ=De(),e6={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:n}){e.contains===void 0&&(0,ZJ.checkStrictMode)(n,`"${t}" without "contains" is ignored`)}};VS.default=e6});var aF=N(WS=>{"use strict";Object.defineProperty(WS,"__esModule",{value:!0});var t6=iF(),n6=sF(),r6=oF(),i6=[t6.default,n6.default,r6.default];WS.default=i6});var lF=N(zS=>{"use strict";Object.defineProperty(zS,"__esModule",{value:!0});var Ws=be(),cF=De(),s6=Fr(),o6={message:"must NOT have unevaluated properties",params:({params:t})=>(0,Ws._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},a6={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:o6,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 Ws.Name?e.if((0,Ws._)`${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,Ws._)`${i} === ${s6.default.errors}`);function c(d){if(n===!1){t.setParams({unevaluatedProperty:d}),t.error(),o||e.break();return}if(!(0,cF.alwaysValidSchema)(s,n)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:cF.Type.Str},f),o||e.if((0,Ws.not)(f),()=>e.break())}}function l(d,f){return(0,Ws._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let m in d)d[m]===!0&&p.push((0,Ws._)`${f} !== ${m}`);return(0,Ws.and)(...p)}}};zS.default=a6});var dF=N(GS=>{"use strict";Object.defineProperty(GS,"__esModule",{value:!0});var Fo=be(),uF=De(),c6={message:({params:{len:t}})=>(0,Fo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Fo._)`{limit: ${t}}`},l6={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:c6,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,Fo._)`${r}.length`);if(n===!1)t.setParams({len:s}),t.fail((0,Fo._)`${o} > ${s}`);else if(typeof n=="object"&&!(0,uF.alwaysValidSchema)(i,n)){let c=e.var("valid",(0,Fo._)`${o} <= ${s}`);e.if((0,Fo.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:uF.Type.Num},c),i.allErrors||e.if((0,Fo.not)(c),()=>e.break())})}}};GS.default=l6});var fF=N(KS=>{"use strict";Object.defineProperty(KS,"__esModule",{value:!0});var u6=lF(),d6=dF(),f6=[u6.default,d6.default];KS.default=f6});var hF=N(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});tg.DiscrError=void 0;var pF;(function(t){t.Tag="tag",t.Mapping="mapping"})(pF||(tg.DiscrError=pF={}))});var gF=N(XS=>{"use strict";Object.defineProperty(XS,"__esModule",{value:!0});var mc=be(),YS=hF(),mF=Ru(),p6=Nu(),h6=De(),m6={message:({params:{discrError:t,tagName:e}})=>t===YS.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>(0,mc._)`{error: ${t}, tag: ${n}, tagValue: ${e}}`},g6={keyword:"discriminator",type:"object",schemaType:"object",error:m6,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,mc._)`${n}${(0,mc.getProperty)(a)}`);e.if((0,mc._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:YS.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,mc._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:YS.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,mc.Name),m}function f(){var p;let m={},h=_(i),y=!0;for(let P=0;P<o.length;P++){let R=o[P];if(R?.$ref&&!(0,h6.schemaHasRulesButRef)(R,s.self.RULES)){let O=R.$ref;if(R=mF.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,O),R instanceof mF.SchemaEnv&&(R=R.schema),R===void 0)throw new p6.default(s.opts.uriResolver,s.baseId,O)}let q=(p=R?.properties)===null||p===void 0?void 0:p[a];if(typeof q!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(h||_(R)),b(q,P)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return m;function _({required:P}){return Array.isArray(P)&&P.includes(a)}function b(P,R){if(P.const)v(P.const,R);else if(P.enum)for(let q of P.enum)v(q,R);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(P,R){if(typeof P!="string"||P in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[P]=R}}}};XS.default=g6});var yF=N((QEe,y6)=>{y6.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 TF=N((ZEe,T6)=>{T6.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 vF=N((eCe,v6)=>{v6.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 bF=N((tCe,b6)=>{b6.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 _F=N((nCe,_6)=>{_6.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 SF=N((rCe,S6)=>{S6.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 kF=N((iCe,k6)=>{k6.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 PF=N(JS=>{"use strict";Object.defineProperty(JS,"__esModule",{value:!0});var P6=yF(),N6=TF(),R6=vF(),w6=bF(),E6=_F(),C6=SF(),D6=kF(),A6=["/properties"];function I6(t){return[P6,N6,R6,w6,e(this,E6),C6,e(this,D6)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function e(n,r){return t?n.$dataMetaSchema(r,A6):r}}JS.default=I6});var NF=N((Pt,ZS)=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.MissingRefError=Pt.ValidationError=Pt.CodeGen=Pt.Name=Pt.nil=Pt.stringify=Pt.str=Pt._=Pt.KeywordCxt=Pt.Ajv2019=void 0;var O6=Jq(),M6=K$(),x6=nF(),L6=aF(),q6=fF(),$6=gF(),F6=PF(),QS="https://json-schema.org/draft/2019-09/schema",gc=class extends O6.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(x6.default),M6.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(L6.default),this.addVocabulary(q6.default),this.opts.discriminator&&this.addKeyword($6.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:n}=this.opts;n&&(F6.default.call(this,e),this.refs["http://json-schema.org/schema"]=QS)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(QS)?QS:void 0)}};Pt.Ajv2019=gc;ZS.exports=Pt=gc;ZS.exports.Ajv2019=gc;Object.defineProperty(Pt,"__esModule",{value:!0});Pt.default=gc;var B6=Pu();Object.defineProperty(Pt,"KeywordCxt",{enumerable:!0,get:function(){return B6.KeywordCxt}});var yc=be();Object.defineProperty(Pt,"_",{enumerable:!0,get:function(){return yc._}});Object.defineProperty(Pt,"str",{enumerable:!0,get:function(){return yc.str}});Object.defineProperty(Pt,"stringify",{enumerable:!0,get:function(){return yc.stringify}});Object.defineProperty(Pt,"nil",{enumerable:!0,get:function(){return yc.nil}});Object.defineProperty(Pt,"Name",{enumerable:!0,get:function(){return yc.Name}});Object.defineProperty(Pt,"CodeGen",{enumerable:!0,get:function(){return yc.CodeGen}});var j6=xm();Object.defineProperty(Pt,"ValidationError",{enumerable:!0,get:function(){return j6.default}});var U6=Nu();Object.defineProperty(Pt,"MissingRefError",{enumerable:!0,get:function(){return U6.default}})});var bc=require("path"),He=L(Xw());var If=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=Qw(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=Jw(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=Jw(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}},Vt;(function(t){function e(i,s,o,a){return new If(i,s,o,a)}t.create=e;function n(i,s,o){if(i instanceof If)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=lT(s.map(WU),(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})(Vt||(Vt={}));function lT(t,e){if(t.length<=1)return t;let n=t.length/2|0,r=t.slice(0,n),i=t.slice(n);lT(r,e),lT(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 Jw(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 Qw(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 WU(t){let e=Qw(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var Of=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],Mf=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var dT=L(require("url")),aE=require("crypto"),ga=require("path"),pn=L(U());var uT=L(U());var Kn=L(U());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(![Kn.SymbolKind.File,Kn.SymbolKind.Class,Kn.SymbolKind.Constant].some(i=>i===e))return[];let n=Yn(this.fsPath),r=n?.range??ce(this);return[{location:Kn.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===Kn.SymbolKind.File||i.kind===Kn.SymbolKind.Class||i.kind===Kn.SymbolKind.Constant)]}buildSemanticTokens(e){this._children.forEach(n=>n.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(Ui(this.semanticTokenType),Hi(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 Kn.Range.create(Kn.Position.create(this.firstToken.pos.line,this.firstToken.pos.col),Kn.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??=Uc(this.toString(),e),this.#e}#n;evaluate(e){return this.#n??=Me(`${this.operator?this.operator.toString():""}${this.resolve(e)}`),this.#n}#r;isTrue(e){return this.#r??=Me(`!!(${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}}},tn=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 Me(`!!(${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 bi=class extends ge{constructor(n,r,i){super(r);this.value=n;this.docSymbolsMeta={name:`param${i+1}`,kind:uT.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},Wt=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:uT.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?Me(`!!(${this.operator}${r})`):r}return super.isTrue(n)}};var Qr=L(U());var rE=L(U());var Zw=L(U());var ie=class extends te{constructor(n,r){super(r);this.value=n;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:Zw.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 tE=L(U());var eE=L(U());var nn=class extends ge{constructor(n,r,i=10){super(r);this.value=n;this.radix=i;this.docSymbolsMeta={name:this.value.toString(),kind:eE.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 bt=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Cell Array",kind:tE.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 nn)){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 nE=L(U());var fr=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Byte String Value",kind:nE.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 Je=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}}},Ne=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:rE.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 ie?n.value.value:n.value instanceof bt?n.value.values.map(r=>r.value instanceof nn?r.value.value:NaN):n.value instanceof fr?n.value.values.map(r=>r.value?.value??NaN):NaN:null)}getFlatAstValues(){return this.values?.values.flatMap(n=>n?n.value instanceof ie?n.value:n.value instanceof bt?n.value.values.map(r=>r.value):n.value instanceof fr?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"}`:""};${lo(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 iE=L(U());var fn=class extends te{constructor(n,r){super();this.keyword=r;this.addChild(r),this.docSymbolsMeta={name:n,kind:iE.SymbolKind.Function}}};var Xn=class extends fn{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 at=class extends fn{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 sE=L(U());var se=class extends te{constructor(n){super();this.label=n;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:sE.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 we=class t extends te{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof nt)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 Xn)}addNodeChild(e){this.addChild(e)}},nt=class extends we{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Qr.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ne)}#e;get name(){return this.#e??=new $e("/",de(this.firstToken)),this.#e}get identifierAst(){return this.name}get deleteProperties(){return this.children.filter(e=>e instanceof at)}get nodes(){return this.children.filter(e=>e instanceof Ee)}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&&ne(this.openScope),scopeClose:this.closeScope&&ne(this.closeScope,!1)}}},ct=class extends we{constructor(n=[]){super();this.labels=n;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Qr.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 se?r=n.value:r=n?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:r??"DTC Name",kind:Qr.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 Ee)}get pathName(){if(this.reference instanceof se&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(n=>n instanceof Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof at)}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&&ne(this.openScope),scopeClose:this.closeScope&&ne(this.closeScope,!1)}}},Ee=class t extends we{constructor(n=[],r){super();this.labels=n;this.omitIfNoRef=r;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Qr.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:Qr.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 Ne)}get deleteProperties(){return this.children.filter(n=>n instanceof at)}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&&ne(this.openScope),scopeClose:this.closeScope&&ne(this.closeScope,!1)}}},Hc=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}}},$e=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(Ui("type"),Hi("declaration"),i,i),this.address!==void 0&&this.address.forEach(s=>{n(Ui("decorator"),Hi("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:Qr.Range.create(Qr.Position.create(n.pos.line,n.pos.col),Qr.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 rn=(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 ne=(t,e=!0)=>pn.Position.create(t.pos.line,e?t.pos.colEnd:t.pos.col),ce=t=>rn(t.firstToken,t.lastToken),Ui=t=>Of.findIndex(e=>e===t),Hi=t=>Mf.findIndex(e=>e===t),gs=(t,e,n)=>!pe(t.fsPath,e)||n.line<t.pos.line?!1:n.line>t.pos.line?!0:n.character>=t.pos.colEnd,fT=(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,Xt=(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))},qf=(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)},cE=(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))},lE=(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=>Xt(s,e,n));return r},Vc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].find(s=>fT(s.lastToken,e,n));return r===t?void 0:r},Wc=(t,e,n)=>{let r=t,i=t;for(;i;)r=i,i=[...r.children].reverse().find(s=>gs(s.firstToken,e,n));return r===t?void 0:r},pT="#virtual",lo=t=>t.includes(pT),$f=(t,e)=>`${t}?loc=${e.start.line}:${e.start.character}-${e.end.line}:${e.end.character}${pT}`,Yn=t=>{if(!lo(t))return;let[e,n]=t.split("?"),[r,i]=n.replace("loc=","").replace(pT,"").split("-"),[s,o]=r.split(":"),[a,c]=i.split(":");return{docFsPath:e,range:pn.Range.create(pn.Position.create(Number.parseInt(s),Number.parseInt(o)),pn.Position.create(Number.parseInt(a),Number.parseInt(c)))}},hT=t=>{let e=Yn(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=Yn(r);return{range:i?.range??n,fsPath:i?.docFsPath??r,templateStrings:[]}}))},z=(t,e,n=e,r,{severity:i=pn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,inclusiveStart:u,inclusiveEnd:d}={severity:pn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let f={issues:Array.isArray(t)?t:[t],range:rn(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};hT(f);let p,m=()=>(p??={severity:f.severity,range:f.range,message:f.issues?f.issues.map(YU).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}},zt=(t,e,n,r,{severity:i=pn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l,linkedToTemplateStrings:u=[]}={severity:pn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let d={issues:Array.isArray(t)?t:[t],range:rn(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};hT(d);let f,p=()=>(f??={severity:d.severity,range:d.range,message:XU(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(m=>({message:d.issues.map(h=>JU(h,m.templateStrings)).join(" or "),location:{uri:ue(m.fsPath),range:m.range}}))]},f);return r?.resettableIssues.push(p),{raw:d,diagnostic:p}},j=(t,e,n,r,{severity:i=pn.DiagnosticSeverity.Error,linkedTo:s=[],tags:o,templateStrings:a=[],edit:c,codeActionTitle:l}={severity:pn.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let u={issues:Array.isArray(t)?t:[t],range:rn(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};hT(u);let d,f=()=>(d??={severity:u.severity,range:u.range,message:QU(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(ZU).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 Ve(t,e,n,{severity:r=pn.DiagnosticSeverity.Warning,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:pn.DiagnosticSeverity.Warning,linkedTo:[],templateStrings:[],edit:[],codeActionTitle:void 0},l=n){let u={issues:Array.isArray(t)?t:[t],range:pn.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:eH(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(tH).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 uE=(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 wt(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=>Xt(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 H=(t,e)=>t?.tokens.some(n=>n===e),it=(t,e)=>n=>n?.value&&(e?.caseInsensitive?t.toLowerCase()===n.value.toLowerCase():t===n.value)?"yes":e?.allowPartial?zU(t)(n):"no",Fe=t=>e=>e?.tokens.some(n=>n===t)?"yes":"no",zU=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",hn=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&pe(t.fsPath,e.fsPath),Gt=(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&&hn(t,e),Ff=t=>t.map((e,n)=>({index:n,context:e,files:e.getContextFiles()})),Nn=(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:Ff(t).sort(s=>s.context.id===r?-1:0).find(s=>s.files.some(o=>pe(o,e.fsPath)))?.context},mT=(t,e)=>Ff(t).filter(r=>r.files.some(i=>pe(i,e))).map(r=>r.context),dE=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 GU(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 KU=0,Uc=(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=GU(c).map(d=>d.trim()).map(d=>d==="__COUNTER__"?(KU++).toString():d).map(d=>Uc(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 gT(t){return t.replace(/'(.)'/g,(e,n)=>n.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Me(t){try{return(0,eval)(gT(t))}catch{}return t}var ue=t=>dT.default.pathToFileURL(t).toString(),Se=t=>lt(dT.default.fileURLToPath(t)),fE=(t,e)=>{let n=(0,ga.relative)(t,e);return!!n&&!n.startsWith("..")&&!(0,ga.isAbsolute)(n)},pe=(t,e)=>!t||!e?!1:t===e,lt=t=>(0,ga.normalize)(process.platform==="win32"?t.toLowerCase():t),Vi=t=>(0,aE.createHash)("sha256").update([lt(t.dtsFile),...t.includePaths.map(lt),...t.overlays.map(lt),t.bindingType,...t.zephyrBindings.map(lt),...t.deviceOrgBindingsMetaSchema.map(lt),...t.deviceOrgTreeBindings.map(lt),`showFormattingErrorAsDiagnostics-${t.showFormattingErrorAsDiagnostics}`,`disableFileWatchers-${t.disableFileWatchers}`].join(":")).digest("hex"),YU=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"}},XU=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 "),JU=(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"}},QU=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 ",""),ZU=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"}},eH=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 11:return"Node address size is determined by '@size-cells', Remove 'ull'.";case 12:return`'\\' is not necessary. ${t.codeActionTitle}`;case 13:return`Node does not contribute anything. ${t.codeActionTitle}`;case 14:return`Property is redefined in same closure. ${t.codeActionTitle}`;case 15:return`${t.codeActionTitle}`}}).join(" or "),tH=t=>"TODO",pE=(t,e)=>At(t,e)<=0?t:e,hE=(t,e)=>At(t,e)>=0?t:e,At=(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},Nr=(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},yT=(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},nH=(t,e)=>Nr(t,e),mE=(t,e)=>{let n=[];for(let r of t){let i=r.childAddress,s=r.length,o=Nr(i,s);if(At(e,i)>=0&&At(e,o)<0){let a=yT(e,i),c=r.parentAddress,l=nH(c,a),u=Nr(c,s);n.push({start:l,end:u,range:rn(r.rangeTokens.start,r.rangeTokens.end),fsPath:r.rangeTokens.start.fsPath})}}return n};function gE(t){return Array.isArray(t)&&Array.isArray(t[0])}function zc(t){return!t||t instanceof Wt?t:zc(t.parentNode)}function Jn(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 oE(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 yE(t,e){return oE(t.end,e.start)>0&&oE(t.start,e.end)<0}var TE=(t,e)=>{let n=vE(t,e),r=bE(t,e);n&&(t.topComment=n),r&&(t.endComment=r)},vE=(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=vE(n,e);return r&&(r.astAfterComment=t,n.astAfterComment=void 0),r??n},bE=(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=bE(n,e);return r&&(r.astBeforeComment=t,n.astBeforeComment=void 0),r??n},uo=(t,e,n)=>{let r=[42,44,45,36];return n||r.push(52,32,53,8,49),t.severity===pn.DiagnosticSeverity.Error&&pe(t.fsPath,e)&&!r.some(i=>t.issues.includes(i))};function Bf(t){let e=t?.charAt(0);return!!e&&(e>="A"&&e<="Z"||e>="a"&&e<="z")}var jf=t=>{if(t)return t instanceof we?t:jf(t?.parentNode)},fo=(t,e,n=0)=>{if(!e||!e.parentNode?.fsPath)return n;let r=jf(e.parentNode);return fo(t,r,n+1)};function _E(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}function SE(t){return t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):""}var sl=require("fs"),Na=require("path"),go=L(U());var pD=require("path"),wr=L(U());var Mn=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 Jt=t=>t instanceof fn?!0:t instanceof we?!1:t.parentNode?Jt(t.parentNode):!1;var TT=t=>{if(t instanceof Ne)return t;if(!(t instanceof we))return t.parentNode?TT(t.parentNode):void 0},po=t=>!t||t instanceof Ne?!1:t instanceof Mn||po(t.parentNode),ya=t=>[...t.map(e=>{if(e instanceof Ee||e instanceof nt)return e.name;if(e instanceof ct)return e.reference})].filter(e=>!!e),vT=(t,e)=>e?e.parentNode===t||vT(t,e.parentNode):!1;var Lt=L(U());var kE=L(U());var ei=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 $e?r.buildSemanticTokens(n):n(Ui("operator"),Hi("declaration"),r.firstToken,r.lastToken)})}},ut=class extends te{constructor(n){super();this.path=n;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:kE.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:Lt.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
|
|
|
@@ -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(Gt(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 xT=require("fs"),ka=require("path"),tl=L(U());var gt=class extends te{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var hD=require("path"),Qf=L(U());var Er=class extends te{constructor(n,r){super();this.keyword=n;this.path=r;this.docSymbolsMeta={name:`Include ${r}`,kind:Qf.SymbolKind.File},this.addChild(n),this.addChild(r)}get resolvedPath(){return this._resolvedPath}set resolvedPath(n){this.docSymbolsMeta={name:`Include ${n}`,kind:Qf.SymbolKind.File},this._resolvedPath=n}},_a=class extends te{constructor(n,r,i){super(i);this._path=n;this.relative=r;this.docSymbolsMeta={name:(0,hD.basename)(this.path),kind:Qf.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var mD=L(U());var yt=class extends ge{constructor(n,r){super(r);this.name=n;this.docSymbolsMeta={name:this.name.toString(),kind:mD.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var Zf=class extends te{constructor(n,r){super(r);this.operator=n;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var gD=L(U());var Sa=class extends gt{toString(){return"..."}},Si=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 fe(this.fsPath,n)?[{name:this.functionName.name,kind:gD.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 Wi=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||!fe(this.currentToken?.fsPath,e.fsPath))return;let s=this.currentToken,o=s;for(;this.currentToken?.pos.line===i&&fe(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=Gt(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=Gt(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||!fe(r.fsPath,s)||!fe(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(Fe));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 yt(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(H(e,40)?(r="&",H(this.currentToken,40)&&(r="&&",n=this.moveToNextToken)):H(e,6)?(r="!",H(this.currentToken,0)&&(r="!=",n=this.moveToNextToken)):H(e,10)?r="~":H(e,8)?(r="|",H(this.currentToken,8)&&(r="||",n=this.moveToNextToken)):H(e,9)?r="^":H(e,4)?(r=">",H(this.currentToken,4)?(r=">>",n=this.moveToNextToken):H(this.currentToken,0)&&(r=">=",n=this.moveToNextToken)):H(e,5)?(r="<",H(this.currentToken,5)?(r="<<",n=this.moveToNextToken):H(this.currentToken,0)&&(r="<=",n=this.moveToNextToken)):H(e,15)?r="+":H(e,16)?r="-":H(e,17)?r="*":H(e,13)?r="/":H(e,18)?r="%":H(e,46)?H(this.currentToken,46)&&(r="##",n=this.moveToNextToken):H(e,0)&&H(this.currentToken,0)&&(r="==",n=this.moveToNextToken),r){let i=new Zf(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(!Gt(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 Si?s.identifier.params.at(-1)instanceof Sa||(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 Wt(n,r);return i.lastToken=this.prevToken,this.mergeStack(),i}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([it("0"),it("x",{caseInsensitive:!0})]);if(e.length!==2){this.popStack();return}let n=this.consumeAnyConcurrentTokens([19,20].map(Fe));if(!n.length){this.popStack();return}let r=Number.parseInt(n.map(s=>s.value).join(""),16),i=new nn(r,de(e[0],n.at(-1)),16);return this.mergeStack(),i}processDec(e=!1){this.enqueueToStack();let n;e&&(H(this.currentToken,16)||H(this.currentToken,15))&&Gt(this.currentToken,this.currentToken?.nextToken)&&(n=this.moveToNextToken);let r=this.consumeAnyConcurrentTokens([19].map(Fe));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(o=>o.value).join(""),10);n&&H(n,16)&&(i=4294967295-i);let s=new nn(i,de(n??r[0],r.at(-1)),10);return this.mergeStack(),s}processEnclosedExpression(e,n){this.enqueueToStack();let r,i;if(H(this.currentToken,42)){let s;r=this.moveToNextToken,i=r;let o=this.processExpression(e,n,!0);return o&&(s=new tn(o,!0),o=new tn(s,!1),s.openBracket=r),H(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 tn?i.addExpression(o,a):i=new tn(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(!H(this.currentToken,42))return;let e=this.parseScopedBlock(r=>!!H(r,42),r=>!!H(r,43),r=>!!H(r,24));return e?.items.length===2&&H(e.endToken,43)?[]:e?.splitTokens.map((r,i)=>{if(r.tokens.length===0)return null;let s=new bi(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 pr=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(Gt(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 xT=require("fs"),ka=require("path"),tl=L(U());var gt=class extends te{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var hD=require("path"),Qf=L(U());var Er=class extends te{constructor(n,r){super();this.keyword=n;this.path=r;this.docSymbolsMeta={name:`Include ${r}`,kind:Qf.SymbolKind.File},this.addChild(n),this.addChild(r)}get resolvedPath(){return this._resolvedPath}set resolvedPath(n){this.docSymbolsMeta={name:`Include ${n}`,kind:Qf.SymbolKind.File},this._resolvedPath=n}},_a=class extends te{constructor(n,r,i){super(i);this._path=n;this.relative=r;this.docSymbolsMeta={name:(0,hD.basename)(this.path),kind:Qf.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var mD=L(U());var yt=class extends ge{constructor(n,r){super(r);this.name=n;this.docSymbolsMeta={name:this.name.toString(),kind:mD.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var Zf=class extends te{constructor(n,r){super(r);this.operator=n;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var gD=L(U());var Sa=class extends gt{toString(){return"..."}},Si=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:gD.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 Wi=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=Gt(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=Gt(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(Fe));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 yt(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(H(e,40)?(r="&",H(this.currentToken,40)&&(r="&&",n=this.moveToNextToken)):H(e,6)?(r="!",H(this.currentToken,0)&&(r="!=",n=this.moveToNextToken)):H(e,10)?r="~":H(e,8)?(r="|",H(this.currentToken,8)&&(r="||",n=this.moveToNextToken)):H(e,9)?r="^":H(e,4)?(r=">",H(this.currentToken,4)?(r=">>",n=this.moveToNextToken):H(this.currentToken,0)&&(r=">=",n=this.moveToNextToken)):H(e,5)?(r="<",H(this.currentToken,5)?(r="<<",n=this.moveToNextToken):H(this.currentToken,0)&&(r="<=",n=this.moveToNextToken)):H(e,15)?r="+":H(e,16)?r="-":H(e,17)?r="*":H(e,13)?r="/":H(e,18)?r="%":H(e,46)?H(this.currentToken,46)&&(r="##",n=this.moveToNextToken):H(e,0)&&H(this.currentToken,0)&&(r="==",n=this.moveToNextToken),r){let i=new Zf(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(!Gt(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 Si?s.identifier.params.at(-1)instanceof Sa||(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 Wt(n,r);return i.lastToken=this.prevToken,this.mergeStack(),i}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([it("0"),it("x",{caseInsensitive:!0})]);if(e.length!==2){this.popStack();return}let n=this.consumeAnyConcurrentTokens([19,20].map(Fe));if(!n.length){this.popStack();return}let r=Number.parseInt(n.map(s=>s.value).join(""),16),i=new nn(r,de(e[0],n.at(-1)),16);return this.mergeStack(),i}processDec(e=!1){this.enqueueToStack();let n;e&&(H(this.currentToken,16)||H(this.currentToken,15))&&Gt(this.currentToken,this.currentToken?.nextToken)&&(n=this.moveToNextToken);let r=this.consumeAnyConcurrentTokens([19].map(Fe));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(o=>o.value).join(""),10);n&&H(n,16)&&(i=4294967295-i);let s=new nn(i,de(n??r[0],r.at(-1)),10);return this.mergeStack(),s}processEnclosedExpression(e,n){this.enqueueToStack();let r,i;if(H(this.currentToken,42)){let s;r=this.moveToNextToken,i=r;let o=this.processExpression(e,n,!0);return o&&(s=new tn(o,!0),o=new tn(s,!1),s.openBracket=r),H(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 tn?i.addExpression(o,a):i=new tn(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(!H(this.currentToken,42))return;let e=this.parseScopedBlock(r=>!!H(r,42),r=>!!H(r,43),r=>!!H(r,24));return e?.items.length===2&&H(e.endToken,43)?[]:e?.splitTokens.map((r,i)=>{if(r.tokens.length===0)return null;let s=new bi(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 pr=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
|
`)}},hr=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 ep=class t extends Wi{constructor(n,r=()=>xn().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||!H(c,13)||(l=s(),!H(l,17)||c.pos.line!==l.pos.line||c.pos.col+1!==l.pos.col))return;let u=()=>!(!H(a(),17)||!H(o(),13)||!Gt(a(),o())),d=l.pos.line,f=c,p=[];l=s();do{if(o()?.pos.line!==d){let y=new hr(de(f,a()));p.push(y),d=o().pos.line??0,f=o()}l=s()}while(r<n.length&&!u());let m=new hr(de(f,o()));p.push(m);let h=new pr(p);return s(),{comment:h,tokenUsed:i,index:r-1}}static processLineComment(n,r){let i=[];if(!H(n[r],13)||n.length===r+1||!H(n[r+1],13)||!Gt(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 hr(de(n[i[0]],n[i.at(-1)])),tokenUsed:i,index:r-1}}};var yD=L(U());var tp=class extends te{constructor(n,r){super(n);this.content=r}toString(){let n=this.content.filter(r=>!H(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("")}},Jc=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 yt?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:yD.MarkupKind.Markdown,value:["```cpp",`#define ${this.toString()}`,"```"].join(`
|
|
283
|
-
`)}}};var mo=class extends te{constructor(e){super(e)}},Qc=class extends te{constructor(n,r){super();this.keyword=n;this.content=r;this.active=!1;this.addChild(n)}},Zc=class extends Qc{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)}},np=class extends Qc{constructor(n,r,i){super(n,i);this.expression=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.expression?.isTrue(n)}},rp=class extends Zc{useBlock(e){return this.identifier&&!e.has(this.identifier.name)}},el=class extends Qc{};var ti=(t,e)=>{let n=t,r=[];for(;n&&(r.push(n),n!==e);)n=n.nextToken;return r},mr=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[Ye.create(ne(n),ne(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[Ye.create(ne(n),ne(r??this.ifDef.lastToken))]}return[]}getInValidTokenRange(n){if(!this.ifDef.identifier)return new WeakSet(ti(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;ti(this.ifDef.firstToken,i).forEach(o=>r.add(o));let s=this.ifDef===n;return!s&&this.ifDef.content&&ti(this.ifDef.content.firstToken,this.ifDef.content.lastToken).forEach(o=>r.add(o)),this.elseOption&&(ti(this.elseOption.firstToken,this.elseOption.keyword.lastToken).forEach(o=>r.add(o)),s&&this.elseOption.content&&ti(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(o=>r.add(o))),this.endIf&&ti(this.endIf.firstToken,this.endIf.lastToken).forEach(o=>r.add(o)),r}},er=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(Ye.create(ne(l),ne(u)))}),this.elseOption&&n.length){let o=this.elseOption.firstToken,a=this.elseOption.content?.lastToken??this.endIf?.lastToken??this.lastToken;return[Ye.create(ne(o),ne(a))]}let i=this.firstToken,s=this.lastToken;return[Ye.create(ne(i),ne(s))]}getInValidTokenRangeWhenActiveBlock(n){let r=new WeakSet,i=!1;return this.ifBlocks.forEach(s=>{let o=s.expression?.lastToken??s.keyword.lastToken;ti(s.firstToken,o).forEach(a=>r.add(a)),!i&&s===n?i=!0:s.content&&ti(s.content.firstToken,s.content.lastToken).forEach(a=>r.add(a))}),this.elseOption&&(ti(this.elseOption.keyword.firstToken,this.elseOption.keyword.lastToken).forEach(s=>r.add(s)),i&&this.elseOption.content&&ti(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(s=>r.add(s))),this.endIf&&ti(this.endIf.firstToken,this.endIf.lastToken).forEach(s=>r.add(s)),r}};var Pa=class extends Wi{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=hn(n,i)||!n||H(n,14)&&n.pos.line+1===i?.pos.line;if(!(this.macroStart&&!s))return this.macroStart&&H(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 ep(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||!fe(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||!H(r,25))return this.popStack(),!1;this.macroStart=!0;let i=new gt(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 tp(de(o[0],o.at(-1)),o));let c=new Jc(i,s,a);this.macros.set(c.name,{macro:c,resolver:dE(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||!H(r,28))return this.popStack(),!1;this.macroStart=!0;let i=new gt(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 Jc(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||!H(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(!H(r,42)||!Gt(n.lastToken,r)){this.popStack();return}let i=[],s=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;s;)i.push(s),!H(this.currentToken,24)&&!H(this.currentToken,43)?this._issues.push(z(28,s.firstToken,s.lastToken,s)):H(this.currentToken,43)||(r=this.moveToNextToken),s=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new Si(n,i);if(H(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([Fe(45),Fe(45),Fe(45)]);if(n.length!==3){this.popStack();return}let r=new Sa(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=>H(a,c))&&!hn(a.prevToken,a),a=>!!a&&[37].some(c=>H(a,c))&&!hn(a.prevToken,a),a=>!!a&&[36,35].some(c=>H(a,c))&&!hn(a.prevToken,a));if(!r)return;let i;H(r.startToken,32)?i=this.processIfBlock(r,(a,c,l)=>new np(a,c??null,l)):i=this.processIfDefBlock(r,(a,c,l)=>H(r.startToken,33)?new Zc(a,c??null,l):new rp(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=>qf(c,a.range))&&(a.disabled=!0)}),[...i instanceof er?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:tl.DiagnosticSeverity.Hint,tags:[tl.DiagnosticTag.Unnecessary]}))}),this.positionStack[this.positionStack.length-1]=n}processIfDefBlock(n,r){this.enqueueToStack(),this.macroStart=!0;let i=new gt(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 mo(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 gt(de(p)),h;n.splitTokens[1].tokens.length&&(h=new mo(de(n.splitTokens[1].tokens[0],n.splitTokens[1].tokens.at(-1)))),u=new el(m,h??null)}let d;n.endToken?d=new gt(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let f=new mr(l,d??null,u);return this.mergeStack(),f}processIfBlock(n,r){this.enqueueToStack();let i=new gt(de(n.startToken)),s=[],o;n.splitTokens.forEach((l,u)=>{l.rewind();let d=this.prevToken,f=new gt(de(d));this.macroStart=!0;let p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0);if(p instanceof yt&&p.name.toLowerCase()==="defined"&&(p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0)),this.macroStart=!1,u===n.splitTokens.length-1&&H(d,36)){let h=d,y=new gt(de(h)),_;l.tokens.length&&(_=new mo(de(l.tokens[0],l.tokens.at(-1)))),o=new el(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 mo(de(_,n.splitTokens[u].tokens.at(-1))));let b=r(f,p??null,h??null);s.push(b)}});let a;n.endToken?a=new gt(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let c=new er(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,ka.resolve)((0,ka.dirname)(n.fsPath),n.path.path),...this.incudes.map(r=>(0,ka.resolve)(r,n.path.path))].find(r=>(0,xT.existsSync)(r)):this.incudes.map(r=>(0,ka.resolve)(r,n.path.path)).find(r=>(0,xT.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(H(r,26))this.moveToNextToken;else{let h=this.checkConcurrentTokens([Fe(13),it("include"),Fe(13)]);if(h.length!==3)return this.popStack(),!1;i=h[0],s=h.at(-1)}let o=i,a=new gt(de(i,s));r=this.moveToNextToken;let c=r,l=!!H(r,21);if(!c||!l&&!H(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&&!H(this.currentToken,4);)u+=this.currentToken?.value??"",r=this.moveToNextToken;let d=new _a(u,l,de(c,r)),f=new Er(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!H(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:tl.DiagnosticSeverity.Warning})),m&&!this.optimizeForFormatting){xn().requestTokens(m,!0);let h=nl().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=_E(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 LT,ip=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,n,r,i){e=lt(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 Pa(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=lt(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 nl(){return LT??=new ip,LT}function TD(){LT=new ip}var qT,sp=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=lt(e),this.fileMap.get(e)?.text!==n}getDocument(e,n){return Vt.create(e,"devicetree",0,n??this.fileMap.get(e)?.text??(0,rl.readFileSync)(e).toString())}renewLexer(e,n){if(e=lt(e),nl().reset(e),!n&&!(0,rl.existsSync)(e))return[];try{n??=(0,rl.readFileSync)(e).toString();let r=new Zn(n,e);return this.fileMap.set(e,r),t.clone(r.tokens)}catch{}return[]}requestTokens(e,n){e=lt(e);let r=this.fileMap.get(e)?.tokens;return!r&&n?[...this.renewLexer(e)]:t.clone(r??[])}reset(e){e=lt(e),nl().reset(e),this.fileMap.delete(e)}};function xn(){return qT??=new sp,qT}function vD(){qT=new sp}var ki=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=>Xt(s,e,n)||lE(xn().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=>fe(d.resolvedPath,c));return u&&this.context.getSortKeyFile(l,c)===void 0?o(u.lastToken.fsPath,ne(u.lastToken)):u},a=o(e,n);a&&(i=r.at(-1)?.parentNode,e=a.fsPath,n=bD.Position.create(a.lastToken.pos.line,a.lastToken.pos.colEnd))}if(i instanceof ct){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 nt&&i.path){let s=this.rootNode.getDeepestAstNode(e,n);return s?{...s,runtime:this}:void 0}else if(i instanceof Ee&&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 we)?.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(zt(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 uE(e.implementations,this.context)}};var il=L(U());var _D=L(U());var op=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Values",kind:_D.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 SD=L(U());var ap=class extends te{constructor(n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:"DTS Document version",kind:SD.SymbolKind.Function}}};var Pi=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 kD=L(U());var cp=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:kD.SymbolKind.Function},this.addChild(r),this.addChild(i)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var PD=L(U());var lp=class extends te{constructor(n,r){super();this.keyword=n;this.bitsSize=r;this.addChild(n),this.docSymbolsMeta={name:"bits",kind:PD.SymbolKind.Function},this.addChild(r)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var Cr=class extends Wi{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.tokens=[];this.others=[];this.rootDocument=new we;this.unhandledStatements=new nt;this.injectedMacros=[];this.#e=!1;this.cPreprocessorParser=new Pa(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 we,this._issues=[],this.unhandledStatements=new nt,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,lt(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 we||s instanceof Ne||s instanceof Er)&&TE(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=gT(s);let o=$f(r.fsPath,ce(r)),a=new Set;if(this.cPreprocessorParser.comments.forEach(l=>{Xt(r,r.fsPath,l.range.start)&&a.add(l)}),this.cPreprocessorParser.removeComments(a),this.injectedMacros.push(r),r instanceof yt&&s.includes(r.name)||r instanceof Wt&&s.includes(r.functionName.name))return!0;let c=new Zn(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||!H(r,13))return this.popStack(),!1;if(i=this.moveToNextToken,!i||!H(i,2))return this.popStack(),!1;let s=new nt;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(H(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 H(this.currentToken,3)||H(this.currentToken,1)}endStatement(n,r=!0){let i=this.currentToken;if(!H(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(;H(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 ct(s):new Ee(s,i);if(r==="Ref"?(this.enqueueToStack(),a=this.processNodePathRef(c),!a||!H(this.currentToken,2)?(this.popStack(),a=void 0):this.mergeStack(),a??=this.isLabelRef(c)):r==="Name"&&(o=this.isNodeName()),!a&&!o){if(!H(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 ct?(c.reference=a,l=!0):o&&c instanceof Ee&&(l=o.address!==void 0,c.name=o),H(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([it("0"),it("x",{caseInsensitive:!0})]);i.length!==2?(i=[],this.popStack()):(this._issues.push(z(50,i[0],i[1],n,{severity:il.DiagnosticSeverity.Warning})),r=i.at(-1),this.mergeStack());let s=this.consumeAnyConcurrentTokens([19,20,48].map(Fe)),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)&&!Gt(r,s[0])&&!lo(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:il.DiagnosticSeverity.Warning})),this.moveToNextToken),new Hc(a,de(i.at(0)??s[0]??this.prevToken,this.prevToken))}processNodeAddresses(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Fe(49)]);if(r.length){Gt(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)),H(this.currentToken,24)&&(this.prevToken&&!Gt(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(;!H(this.currentToken,2)&&!H(this.currentToken,1)&&!H(this.currentToken,3)&&!H(this.currentToken,13)&&hn(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 Hc([],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(Fe));if(!n.length){this.popStack();return}let r=n.map(o=>o.value).join(""),i=new $e(r,de(n[0],n.at(-1))),s=this.processNodeAddresses(i);return i.address=s,Bf(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(Fe));if(!n.length){this.popStack();return}let r=new Je(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(Fe));if(!n.length){this.popStack();return}if(!Bf(n?.[0].value)){this.popStack();return}let r=n.map(s=>s.value).join(""),i=new mn(r,de(n[0],n[n.length-1]));return this.mergeStack(),i}isLabelAssign(n){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,48].map(Fe));if(!r.length){this.popStack();return}if(!Bf(r?.[0].value)){this.popStack();return}let i=r.map(c=>c.value).join(""),s=this.currentToken,o=s&&H(s,50),a=new Ts(new mn(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(H(this.currentToken,2)||H(this.currentToken,49))return this.popStack(),!1;let s=new Ne(i,r),o;H(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([Fe(13),it("d"),it("ts"),Fe(16),it("v"),it("1")]);if(n.length!==6)return this.popStack(),!1;let r=n[0],i=r,s=new gt;s.firstToken=r;let o=new ap(s);if(this.others.push(o),H(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([Fe(13),it("memreserve")]);if(n.length!==2)return this.popStack(),!1;let r=new gt;r.firstToken=n[0];let s=n[0];H(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 cp(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([Fe(13),it("plugin"),Fe(13)]);if(n.length!==3)return this.popStack(),!1;let r=new gt(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([Fe(13),it("b"),it("its")]);if(n.length!==3){this.popStack();return}let r=new gt;r.firstToken=n[0];let s=n[0];H(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 lp(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:il.DiagnosticSeverity.Warning})),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(13),it("omit"),Fe(16),it("if"),Fe(16),it("no"),Fe(16),it("ref"),Fe(13)]);if(n.length!==9){this.popStack();return}let r=new gt(de(n[0],n.at(-1)));return this.mergeStack(),r}isDeleteNode(n,r){this.enqueueToStack();let i=this.checkConcurrentTokens([Fe(13),it("d"),it("e"),it("lete",{allowPartial:!0}),Fe(16),it("node",{allowPartial:!0})]);if(!i.length)return this.popStack(),!1;let s=i[0],o=s,a=new gt;if(a.firstToken=s,i.length===1&&!H(this.currentToken,2)){this._issues.push(z(25,a.firstToken,a.lastToken,a)),a.lastToken=i.at(-1);let d=new Xn(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)):H(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(z(21,a.firstToken,a.lastToken,a));let l=new Xn(a);if(hn(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([Fe(13),it("d"),it("e"),it("lete",{allowPartial:!0}),Fe(16),it("property",{allowPartial:!0})]);if(!r.length)return this.popStack(),!1;let i=r[0],s=i,o=new gt;if(o.firstToken=i,r.length===1&&!H(this.currentToken,2)){this._issues.push(z(25,o.firstToken,o.lastToken,o)),o.lastToken=r.at(-1);let u=new at(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)):H(this.currentToken,13)?(s=this.moveToNextToken,o.lastToken=s):this._issues.push(z(21,o.firstToken,o.lastToken,o));let c=new at(o);if(hn(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 Mn(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(;!H(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d,f=H(this.currentToken,24);if(f)d=this.currentToken,this.moveToNextToken;else if(!hn(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 op(i)}processStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.consumeAnyConcurrentTokens([Fe(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 ie(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 Mn(n,a,c);return this.mergeStack(),l}arrayValues(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(H(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(n)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new Mn(r,o,a,i);if(!H(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(!H(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 fr(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=r,this._issues.push(z(14,a.firstToken,a.lastToken,a,{severity:il.DiagnosticSeverity.Information})));let c=new Mn(n,a,o);H(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 Wt&&a.value.params.every(c=>!!c)&&this.cPreprocessorParser.macros.has(a.value.functionName.name)||a.value instanceof yt&&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 bt(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 Pi(i,r);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),r=this.checkConcurrentTokens([20,20].map(Fe));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(a=>a.value).join(""),16),s=new nn(i,de(r[0],r.at(-1)),16),o=new Pi(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 Pi(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 Pi(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 Mn(r,i,s);return this.mergeStack(),o}isLabelRef(n){this.enqueueToStack();let r=this.currentToken;if(!r||!H(r,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new se(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 se(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 Mn(r,i,s);return this.mergeStack(),o}processRefValue(n,r){this.enqueueToStack();let i=this.processOptionalLabelAssign(r),s=this.currentToken;if(!s||!H(s,40)){this.popStack();return}let o=this.processNodePathRef(n);if(o!==void 0){let l=new Pi(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 Pi(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new Pi(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(n=!0,r=new ei){this.enqueueToStack();let i;if(H(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 $e("/",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(!H(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!H(i,2)){this.popStack();return}r&&!Gt(r,s)&&this._issues.push(z(29,r,s,n,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new ut(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Gt(u.lastToken,l)){this._issues.push(z(29,u.lastToken,l,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Gt(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&&!Gt(u.lastToken,f.firstToken)&&this._issues.push(z(29,u.lastToken,f?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}))}),H(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 Er)}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)=>Wi.push(...o,r,i))}),super.buildSemanticTokens(n,r,i),this.#e=!0}};var up=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={...e,ctxName:e.ctxName??(0,Na.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(sl.existsSync);let s=this.isFullContext&&r?.type==="Zephyr"?[(0,Na.join)((0,Na.dirname)(this.settings.dtsFile),"dts"),...i.includePaths]:i.includePaths;this.parser=new Cr(i.dtsFile,s),this.ctxNames_.add(i.ctxName),this.id=Vi(i),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Cr(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=>fe(n,e))}getFsPathParser(e){let n=this.overlayParsers.find(r=>r.getFiles().some(i=>fe(i,e)));return n??=this.parser.getFiles().some(r=>fe(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=>fe(s.ast.fsPath,e)&&(!n||Xt(s.ast,e,n))).flatMap(s=>s.ast.values?.values.flatMap(o=>{let c=s.parent?.nodeTypes.find(l=>o?.value instanceof ie&&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=>fe(s.fsPath,e)&&(!n||Xt(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 se){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(zt(3,o.firstToken,o.lastToken,o,{templateStrings:[o.value]}))}else o instanceof ei&&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(zt(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 ki(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 Zn(i.text,i.fsPath),o=new Cr(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 hr),[...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&&fe(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)=>gs(c,n,e)&&(l===s.tokens.length-1||!c.nextToken||fT(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(zt(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 we?this.processDtcBaseNode(e,n,r):e instanceof Ne?this.processDtcProperty(e,n,r):e instanceof Xn?this.processDeleteNode(e,n,r):e instanceof at&&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||At(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 Ee&&o.name){let a=r(s.map(c=>({name:c.name,address:c.fullAddress,issueAst:c})),o.name);a.length&&this._issues.push(zt(2,o.name.firstToken,o.name.lastToken,o.name,{linkedTo:a})),s.push(o.name)}else if(o instanceof Xn&&o.nodeNameOrRef instanceof $e){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,sl.existsSync)(this.settings.compileCommands)))return JSON.parse((0,sl.readFileSync)(this.settings.compileCommands).toString())}processDtcBaseNode(e,n,r){e instanceof nt?this.processDtcRootNode(e,r):e instanceof Ee?this.processDtcChildNode(e,n,r):e instanceof ct&&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(zt(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 se?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 Qe(e,n)),e.children.forEach(i=>this.processChild(i,n,r))}processDeleteNode(e,n,r){if(e.nodeNameOrRef instanceof $e&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!n.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress))this._issues.push(zt(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 se&&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 we&&!e.parentNode.pathName&&r.globalDeletes.push(e)):(r.unlinkedDeletes.push(e),this._issues.push(zt(3,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef,{templateStrings:[e.nodeNameOrRef.value]})))}else if(e.nodeNameOrRef instanceof ut&&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(zt(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 we&&!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(zt(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===go.DiagnosticSeverity.Hint&&i.raw.virtual))return i.raw.severity===go.DiagnosticSeverity.Error&&!this.isFullContext&&(i.raw.severity=go.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===go.DiagnosticSeverity.Error&&!this.isFullContext&&!uo(r.raw,r.raw.fsPath,!1)&&(r.raw.severity=go.DiagnosticSeverity.Warning),!(r.raw.severity===go.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 mo=class extends te{constructor(e){super(e)}},Qc=class extends te{constructor(n,r){super();this.keyword=n;this.content=r;this.active=!1;this.addChild(n)}},Zc=class extends Qc{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)}},np=class extends Qc{constructor(n,r,i){super(n,i);this.expression=r;this.addChild(r),this.addChild(i)}useBlock(n){return this.expression?.isTrue(n)}},rp=class extends Zc{useBlock(e){return this.identifier&&!e.has(this.identifier.name)}},el=class extends Qc{};var ti=(t,e)=>{let n=t,r=[];for(;n&&(r.push(n),n!==e);)n=n.nextToken;return r},mr=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[Ye.create(ne(n),ne(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[Ye.create(ne(n),ne(r??this.ifDef.lastToken))]}return[]}getInValidTokenRange(n){if(!this.ifDef.identifier)return new WeakSet(ti(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;ti(this.ifDef.firstToken,i).forEach(o=>r.add(o));let s=this.ifDef===n;return!s&&this.ifDef.content&&ti(this.ifDef.content.firstToken,this.ifDef.content.lastToken).forEach(o=>r.add(o)),this.elseOption&&(ti(this.elseOption.firstToken,this.elseOption.keyword.lastToken).forEach(o=>r.add(o)),s&&this.elseOption.content&&ti(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(o=>r.add(o))),this.endIf&&ti(this.endIf.firstToken,this.endIf.lastToken).forEach(o=>r.add(o)),r}},er=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(Ye.create(ne(l),ne(u)))}),this.elseOption&&n.length){let o=this.elseOption.firstToken,a=this.elseOption.content?.lastToken??this.endIf?.lastToken??this.lastToken;return[Ye.create(ne(o),ne(a))]}let i=this.firstToken,s=this.lastToken;return[Ye.create(ne(i),ne(s))]}getInValidTokenRangeWhenActiveBlock(n){let r=new WeakSet,i=!1;return this.ifBlocks.forEach(s=>{let o=s.expression?.lastToken??s.keyword.lastToken;ti(s.firstToken,o).forEach(a=>r.add(a)),!i&&s===n?i=!0:s.content&&ti(s.content.firstToken,s.content.lastToken).forEach(a=>r.add(a))}),this.elseOption&&(ti(this.elseOption.keyword.firstToken,this.elseOption.keyword.lastToken).forEach(s=>r.add(s)),i&&this.elseOption.content&&ti(this.elseOption.content.firstToken,this.elseOption.content.lastToken).forEach(s=>r.add(s))),this.endIf&&ti(this.endIf.firstToken,this.endIf.lastToken).forEach(s=>r.add(s)),r}};var Pa=class extends Wi{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=hn(n,i)||!n||H(n,14)&&n.pos.line+1===i?.pos.line;if(!(this.macroStart&&!s))return this.macroStart&&H(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 ep(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||!H(r,25))return this.popStack(),!1;this.macroStart=!0;let i=new gt(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 tp(de(o[0],o.at(-1)),o));let c=new Jc(i,s,a);this.macros.set(c.name,{macro:c,resolver:dE(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||!H(r,28))return this.popStack(),!1;this.macroStart=!0;let i=new gt(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 Jc(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||!H(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(!H(r,42)||!Gt(n.lastToken,r)){this.popStack();return}let i=[],s=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;s;)i.push(s),!H(this.currentToken,24)&&!H(this.currentToken,43)?this._issues.push(z(28,s.firstToken,s.lastToken,s)):H(this.currentToken,43)||(r=this.moveToNextToken),s=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new Si(n,i);if(H(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([Fe(45),Fe(45),Fe(45)]);if(n.length!==3){this.popStack();return}let r=new Sa(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=>H(a,c))&&!hn(a.prevToken,a),a=>!!a&&[37].some(c=>H(a,c))&&!hn(a.prevToken,a),a=>!!a&&[36,35].some(c=>H(a,c))&&!hn(a.prevToken,a));if(!r)return;let i;H(r.startToken,32)?i=this.processIfBlock(r,(a,c,l)=>new np(a,c??null,l)):i=this.processIfDefBlock(r,(a,c,l)=>H(r.startToken,33)?new Zc(a,c??null,l):new rp(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=>qf(c,a.range))&&(a.disabled=!0)}),[...i instanceof er?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:tl.DiagnosticSeverity.Hint,tags:[tl.DiagnosticTag.Unnecessary]}))}),this.positionStack[this.positionStack.length-1]=n}processIfDefBlock(n,r){this.enqueueToStack(),this.macroStart=!0;let i=new gt(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 mo(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 gt(de(p)),h;n.splitTokens[1].tokens.length&&(h=new mo(de(n.splitTokens[1].tokens[0],n.splitTokens[1].tokens.at(-1)))),u=new el(m,h??null)}let d;n.endToken?d=new gt(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let f=new mr(l,d??null,u);return this.mergeStack(),f}processIfBlock(n,r){this.enqueueToStack();let i=new gt(de(n.startToken)),s=[],o;n.splitTokens.forEach((l,u)=>{l.rewind();let d=this.prevToken,f=new gt(de(d));this.macroStart=!0;let p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0);if(p instanceof yt&&p.name.toLowerCase()==="defined"&&(p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0)),this.macroStart=!1,u===n.splitTokens.length-1&&H(d,36)){let h=d,y=new gt(de(h)),_;l.tokens.length&&(_=new mo(de(l.tokens[0],l.tokens.at(-1)))),o=new el(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 mo(de(_,n.splitTokens[u].tokens.at(-1))));let b=r(f,p??null,h??null);s.push(b)}});let a;n.endToken?a=new gt(de(n.endToken)):this._issues.push(z(46,i.firstToken,i.lastToken,i));let c=new er(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,ka.resolve)((0,ka.dirname)(n.fsPath),n.path.path),...this.incudes.map(r=>(0,ka.resolve)(r,n.path.path))].find(r=>(0,xT.existsSync)(r)):this.incudes.map(r=>(0,ka.resolve)(r,n.path.path)).find(r=>(0,xT.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(H(r,26))this.moveToNextToken;else{let h=this.checkConcurrentTokens([Fe(13),it("include"),Fe(13)]);if(h.length!==3)return this.popStack(),!1;i=h[0],s=h.at(-1)}let o=i,a=new gt(de(i,s));r=this.moveToNextToken;let c=r,l=!!H(r,21);if(!c||!l&&!H(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&&!H(this.currentToken,4);)u+=this.currentToken?.value??"",r=this.moveToNextToken;let d=new _a(u,l,de(c,r)),f=new Er(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!H(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:tl.DiagnosticSeverity.Warning})),m&&!this.optimizeForFormatting){xn().requestTokens(m,!0);let h=nl().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=_E(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 LT,ip=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,n,r,i){e=lt(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 Pa(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=lt(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 nl(){return LT??=new ip,LT}function TD(){LT=new ip}var qT,sp=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=lt(e),this.fileMap.get(e)?.text!==n}getDocument(e,n){return Vt.create(e,"devicetree",0,n??this.fileMap.get(e)?.text??(0,rl.readFileSync)(e).toString())}renewLexer(e,n){if(e=lt(e),nl().reset(e),!n&&!(0,rl.existsSync)(e))return[];try{n??=(0,rl.readFileSync)(e).toString();let r=new Zn(n,e);return this.fileMap.set(e,r),t.clone(r.tokens)}catch{}return[]}requestTokens(e,n){e=lt(e);let r=this.fileMap.get(e)?.tokens;return!r&&n?[...this.renewLexer(e)]:t.clone(r??[])}reset(e){e=lt(e),nl().reset(e),this.fileMap.delete(e)}};function xn(){return qT??=new sp,qT}function vD(){qT=new sp}var ki=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=>Xt(s,e,n)||lE(xn().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,ne(u.lastToken)):u},a=o(e,n);a&&(i=r.at(-1)?.parentNode,e=a.fsPath,n=bD.Position.create(a.lastToken.pos.line,a.lastToken.pos.colEnd))}if(i instanceof ct){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 nt&&i.path){let s=this.rootNode.getDeepestAstNode(e,n);return s?{...s,runtime:this}:void 0}else if(i instanceof Ee&&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 we)?.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(zt(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 uE(e.implementations,this.context)}};var il=L(U());var _D=L(U());var op=class extends te{constructor(n){super();this.values=n;this.docSymbolsMeta={name:"Values",kind:_D.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 SD=L(U());var ap=class extends te{constructor(n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:"DTS Document version",kind:SD.SymbolKind.Function}}};var Pi=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 kD=L(U());var cp=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:kD.SymbolKind.Function},this.addChild(r),this.addChild(i)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var PD=L(U());var lp=class extends te{constructor(n,r){super();this.keyword=n;this.bitsSize=r;this.addChild(n),this.docSymbolsMeta={name:"bits",kind:PD.SymbolKind.Function},this.addChild(r)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var Cr=class extends Wi{constructor(n,r,i,s,o){super();this.fsPath=n;this.incudes=r;this.tokens=[];this.others=[];this.rootDocument=new we;this.unhandledStatements=new nt;this.injectedMacros=[];this.#e=!1;this.cPreprocessorParser=new Pa(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 we,this._issues=[],this.unhandledStatements=new nt,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,lt(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 we||s instanceof Ne||s instanceof Er)&&TE(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=gT(s);let o=$f(r.fsPath,ce(r)),a=new Set;if(this.cPreprocessorParser.comments.forEach(l=>{Xt(r,r.fsPath,l.range.start)&&a.add(l)}),this.cPreprocessorParser.removeComments(a),this.injectedMacros.push(r),r instanceof yt&&s.includes(r.name)||r instanceof Wt&&s.includes(r.functionName.name))return!0;let c=new Zn(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||!H(r,13))return this.popStack(),!1;if(i=this.moveToNextToken,!i||!H(i,2))return this.popStack(),!1;let s=new nt;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(H(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 H(this.currentToken,3)||H(this.currentToken,1)}endStatement(n,r=!0){let i=this.currentToken;if(!H(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(;H(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 ct(s):new Ee(s,i);if(r==="Ref"?(this.enqueueToStack(),a=this.processNodePathRef(c),!a||!H(this.currentToken,2)?(this.popStack(),a=void 0):this.mergeStack(),a??=this.isLabelRef(c)):r==="Name"&&(o=this.isNodeName()),!a&&!o){if(!H(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 ct?(c.reference=a,l=!0):o&&c instanceof Ee&&(l=o.address!==void 0,c.name=o),H(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([it("0"),it("x",{caseInsensitive:!0})]);i.length!==2?(i=[],this.popStack()):(this._issues.push(z(50,i[0],i[1],n,{severity:il.DiagnosticSeverity.Warning})),r=i.at(-1),this.mergeStack());let s=this.consumeAnyConcurrentTokens([19,20,48].map(Fe)),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)&&!Gt(r,s[0])&&!lo(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:il.DiagnosticSeverity.Warning})),this.moveToNextToken),new Hc(a,de(i.at(0)??s[0]??this.prevToken,this.prevToken))}processNodeAddresses(n){this.enqueueToStack();let r=this.checkConcurrentTokens([Fe(49)]);if(r.length){Gt(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)),H(this.currentToken,24)&&(this.prevToken&&!Gt(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(;!H(this.currentToken,2)&&!H(this.currentToken,1)&&!H(this.currentToken,3)&&!H(this.currentToken,13)&&hn(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 Hc([],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(Fe));if(!n.length){this.popStack();return}let r=n.map(o=>o.value).join(""),i=new $e(r,de(n[0],n.at(-1))),s=this.processNodeAddresses(i);return i.address=s,Bf(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(Fe));if(!n.length){this.popStack();return}let r=new Je(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(Fe));if(!n.length){this.popStack();return}if(!Bf(n?.[0].value)){this.popStack();return}let r=n.map(s=>s.value).join(""),i=new mn(r,de(n[0],n[n.length-1]));return this.mergeStack(),i}isLabelAssign(n){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,48].map(Fe));if(!r.length){this.popStack();return}if(!Bf(r?.[0].value)){this.popStack();return}let i=r.map(c=>c.value).join(""),s=this.currentToken,o=s&&H(s,50),a=new Ts(new mn(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(H(this.currentToken,2)||H(this.currentToken,49))return this.popStack(),!1;let s=new Ne(i,r),o;H(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([Fe(13),it("d"),it("ts"),Fe(16),it("v"),it("1")]);if(n.length!==6)return this.popStack(),!1;let r=n[0],i=r,s=new gt;s.firstToken=r;let o=new ap(s);if(this.others.push(o),H(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([Fe(13),it("memreserve")]);if(n.length!==2)return this.popStack(),!1;let r=new gt;r.firstToken=n[0];let s=n[0];H(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 cp(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([Fe(13),it("plugin"),Fe(13)]);if(n.length!==3)return this.popStack(),!1;let r=new gt(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([Fe(13),it("b"),it("its")]);if(n.length!==3){this.popStack();return}let r=new gt;r.firstToken=n[0];let s=n[0];H(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 lp(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:il.DiagnosticSeverity.Warning})),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let n=this.checkConcurrentTokens([Fe(13),it("omit"),Fe(16),it("if"),Fe(16),it("no"),Fe(16),it("ref"),Fe(13)]);if(n.length!==9){this.popStack();return}let r=new gt(de(n[0],n.at(-1)));return this.mergeStack(),r}isDeleteNode(n,r){this.enqueueToStack();let i=this.checkConcurrentTokens([Fe(13),it("d"),it("e"),it("lete",{allowPartial:!0}),Fe(16),it("node",{allowPartial:!0})]);if(!i.length)return this.popStack(),!1;let s=i[0],o=s,a=new gt;if(a.firstToken=s,i.length===1&&!H(this.currentToken,2)){this._issues.push(z(25,a.firstToken,a.lastToken,a)),a.lastToken=i.at(-1);let d=new Xn(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)):H(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(z(21,a.firstToken,a.lastToken,a));let l=new Xn(a);if(hn(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([Fe(13),it("d"),it("e"),it("lete",{allowPartial:!0}),Fe(16),it("property",{allowPartial:!0})]);if(!r.length)return this.popStack(),!1;let i=r[0],s=i,o=new gt;if(o.firstToken=i,r.length===1&&!H(this.currentToken,2)){this._issues.push(z(25,o.firstToken,o.lastToken,o)),o.lastToken=r.at(-1);let u=new at(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)):H(this.currentToken,13)?(s=this.moveToNextToken,o.lastToken=s):this._issues.push(z(21,o.firstToken,o.lastToken,o));let c=new at(o);if(hn(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 Mn(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(;!H(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d,f=H(this.currentToken,24);if(f)d=this.currentToken,this.moveToNextToken;else if(!hn(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 op(i)}processStringValue(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),r=this.consumeAnyConcurrentTokens([Fe(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 ie(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 Mn(n,a,c);return this.mergeStack(),l}arrayValues(n){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(H(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(n)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new Mn(r,o,a,i);if(!H(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(!H(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 fr(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=r,this._issues.push(z(14,a.firstToken,a.lastToken,a,{severity:il.DiagnosticSeverity.Information})));let c=new Mn(n,a,o);H(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 Wt&&a.value.params.every(c=>!!c)&&this.cPreprocessorParser.macros.has(a.value.functionName.name)||a.value instanceof yt&&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 bt(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 Pi(i,r);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),r=this.checkConcurrentTokens([20,20].map(Fe));if(!r.length){this.popStack();return}let i=Number.parseInt(r.map(a=>a.value).join(""),16),s=new nn(i,de(r[0],r.at(-1)),16),o=new Pi(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 Pi(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 Pi(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 Mn(r,i,s);return this.mergeStack(),o}isLabelRef(n){this.enqueueToStack();let r=this.currentToken;if(!r||!H(r,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new se(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 se(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 Mn(r,i,s);return this.mergeStack(),o}processRefValue(n,r){this.enqueueToStack();let i=this.processOptionalLabelAssign(r),s=this.currentToken;if(!s||!H(s,40)){this.popStack();return}let o=this.processNodePathRef(n);if(o!==void 0){let l=new Pi(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 Pi(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new Pi(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(n=!0,r=new ei){this.enqueueToStack();let i;if(H(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 $e("/",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(!H(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!H(i,2)){this.popStack();return}r&&!Gt(r,s)&&this._issues.push(z(29,r,s,n,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new ut(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Gt(u.lastToken,l)){this._issues.push(z(29,u.lastToken,l,n,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Gt(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&&!Gt(u.lastToken,f.firstToken)&&this._issues.push(z(29,u.lastToken,f?.firstToken,n,{inclusiveStart:!1,inclusiveEnd:!1}))}),H(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 Er)}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)=>Wi.push(...o,r,i))}),super.buildSemanticTokens(n,r,i),this.#e=!0}};var up=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={...e,ctxName:e.ctxName??(0,Na.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(sl.existsSync);let s=this.isFullContext&&r?.type==="Zephyr"?[(0,Na.join)((0,Na.dirname)(this.settings.dtsFile),"dts"),...i.includePaths]:i.includePaths;this.parser=new Cr(i.dtsFile,s),this.ctxNames_.add(i.ctxName),this.id=Vi(i),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Cr(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||Xt(s.ast,e,n))).flatMap(s=>s.ast.values?.values.flatMap(o=>{let c=s.parent?.nodeTypes.find(l=>o?.value instanceof ie&&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||Xt(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 se){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(zt(3,o.firstToken,o.lastToken,o,{templateStrings:[o.value]}))}else o instanceof ei&&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(zt(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 ki(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 Zn(i.text,i.fsPath),o=new Cr(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 hr),[...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)=>gs(c,n,e)&&(l===s.tokens.length-1||!c.nextToken||fT(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(zt(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 we?this.processDtcBaseNode(e,n,r):e instanceof Ne?this.processDtcProperty(e,n,r):e instanceof Xn?this.processDeleteNode(e,n,r):e instanceof at&&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||At(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 Ee&&o.name){let a=r(s.map(c=>({name:c.name,address:c.fullAddress,issueAst:c})),o.name);a.length&&this._issues.push(zt(2,o.name.firstToken,o.name.lastToken,o.name,{linkedTo:a})),s.push(o.name)}else if(o instanceof Xn&&o.nodeNameOrRef instanceof $e){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,sl.existsSync)(this.settings.compileCommands)))return JSON.parse((0,sl.readFileSync)(this.settings.compileCommands).toString())}processDtcBaseNode(e,n,r){e instanceof nt?this.processDtcRootNode(e,r):e instanceof Ee?this.processDtcChildNode(e,n,r):e instanceof ct&&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(zt(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 se?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 Qe(e,n)),e.children.forEach(i=>this.processChild(i,n,r))}processDeleteNode(e,n,r){if(e.nodeNameOrRef instanceof $e&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!n.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress))this._issues.push(zt(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 se&&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 we&&!e.parentNode.pathName&&r.globalDeletes.push(e)):(r.unlinkedDeletes.push(e),this._issues.push(zt(3,e.nodeNameOrRef.firstToken,e.nodeNameOrRef.lastToken,e.nodeNameOrRef,{templateStrings:[e.nodeNameOrRef.value]})))}else if(e.nodeNameOrRef instanceof ut&&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(zt(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 we&&!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(zt(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===go.DiagnosticSeverity.Hint&&i.raw.virtual))return i.raw.severity===go.DiagnosticSeverity.Error&&!this.isFullContext&&(i.raw.severity=go.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===go.DiagnosticSeverity.Error&&!this.isFullContext&&!uo(r.raw,r.raw.fsPath,!1)&&(r.raw.severity=go.DiagnosticSeverity.Warning),!(r.raw.severity===go.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 ND=require("fs"),Ra=require("path"),It=L(U());function sH(t){if(!t||!(t.ast instanceof _a))return[];let e=r=>r.flatMap(i=>{try{return(0,ND.readdirSync)(i,{withFileTypes:!0,recursive:!0}).filter(s=>s.name.toLowerCase().endsWith(".dtsi")||s.name.toLowerCase().endsWith(".h")).map(s=>({label:`${(0,Ra.join)((0,Ra.relative)(i,s.parentPath),s.name)}`,kind:It.CompletionItemKind.File}))}catch{return[]}});if(t.ast.relative)return e([(0,Ra.dirname)(t.ast.fsPath)]);let n=t.runtime.context.settings.includePaths??[];return e(n)}var dp=(t,e)=>[...t.labels.filter(e),...t.deletedNodes.filter(n=>!e(n.by)).flatMap(n=>dp(n.node,e)),...t.nodes.flatMap(n=>dp(n,e))],$T=(t,e)=>[...t.labels,...t.deletedNodes.filter(n=>!e(n.by)).flatMap(n=>$T(n.node,e)),...t.nodes.flatMap(n=>$T(n,e))];function oH(t,e){if(!t||!(t.item instanceof Qe)||!(t.ast instanceof se))return[];let n=i=>$T(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:It.CompletionItemKind.Method,documentation:i.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function aH(t,e){if(!t||t.item!==null||!(t.ast instanceof se)||!(t.ast.parentNode instanceof ct))return[];let n=r=>dp(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:It.CompletionItemKind.Value,insertTextFormat:It.InsertTextFormat.Snippet}))]}function cH(t,e){let n=s=>s?s.parentNode instanceof ct||s.parentNode instanceof nt||s.parentNode instanceof Ee?!1:n(s.parentNode):!0;if(!t||t.item!==null||!Jt(t.ast)||!n(t.ast))return[];let r=s=>dp(s,e).filter(o=>e(o));if(t.ast instanceof gt)return r(t.runtime.rootNode).length?[{label:"/delete-node/",insertText:"/delete-node/ $1;",kind:It.CompletionItemKind.Keyword,insertTextFormat:It.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:It.CompletionItemKind.Keyword,insertTextFormat:It.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 se?`${s.label.value}`:`&${s.label.value}`,kind:It.CompletionItemKind.Variable,documentation:s.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function lH(t,e){if(!t||!(t.item instanceof X)||t.item===null||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof fn)||t.beforeAst?.parentNode instanceof at))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 Ee)})).filter(i=>i.astNodes.some(e));return t.ast instanceof $e||t.ast instanceof Xn||t.beforeAst?.parentNode instanceof Xn?n(t.item).map(r=>({label:`${r.astNodes.at(0)?.name?.toString()}`,kind:It.CompletionItemKind.Variable,documentation:r.node.toMarkupContent(t.runtime.context.macros)})):n(t.item).length?[{label:"/delete-node/",insertText:"/delete-node/ $1;",kind:It.CompletionItemKind.Keyword,insertTextFormat:It.InsertTextFormat.Snippet,sortText:"~",command:{command:"editor.action.triggerSuggest",title:"Re-trigger suggestions"}}]:[]}function uH(t,e){if(!t||!(t.item instanceof X)||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof fn)||t.beforeAst?.parentNode instanceof Xn))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 Je||t.ast instanceof at||t.beforeAst?.parentNode instanceof at){let r=new Map;return n(t.item).forEach(i=>r.set(i.name,i)),Array.from(r).map(([,i])=>({label:`${i.name}`,kind:It.CompletionItemKind.Variable,documentation:i.ast.toPrettyString(t.runtime.context.macros)}))}return n(t.item).length?[{label:"/delete-property/",insertText:"/delete-property/ $1;",kind:It.CompletionItemKind.Keyword,sortText:"~",insertTextFormat:It.InsertTextFormat.Snippet,command:{command:"editor.action.triggerSuggest",title:"Re-trigger suggestions"}}]:[]}function dH(t,e){let n=t?.ast instanceof ei?t.ast:t?.ast.parentNode;if(!t||!n||!(n instanceof ei))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=>!Jt(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:It.CompletionItemKind.Variable,documentation:o.toMarkupContent(t.runtime.context.macros)}))}function fH(t){return!t||!(t.item instanceof Qe&&t.item.ast.assignOperatorToken)||t.ast instanceof ie?[]:!po(t?.ast)&&!(t.ast instanceof Ne&&t.item.ast.values===null)&&!po(t.beforeAst)&&!po(t.afterAst)?[]:t.item.parent.nodeType instanceof St?Array.from([t.runtime.context.parser,...t.runtime.context.overlayParsers].at(-1)?.cPreprocessorParser.macros??[]).map(([,r])=>r.macro.identifier instanceof Si?{label:`${r.macro.identifier.toString()}`,insertText:`${r.macro.name}(${r.macro.identifier.params.map((i,s)=>i instanceof yt?`$${s+1}`:"").join(", ")})`,kind:It.CompletionItemKind.Function,sortText:`~${r.macro.name}`,insertTextFormat:It.InsertTextFormat.Snippet}:{label:r.macro.identifier.name,kind:It.CompletionItemKind.Variable,sortText:`~${r.macro.name}`}):[]}function pH(t,e){return!t?.item||!(t.ast instanceof Je&&t.ast.parentNode instanceof Ne||t.ast instanceof nt)?[]:(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:It.CompletionItemKind.Class,sortText:`!${r}`,insertTextFormat:It.InsertTextFormat.Snippet}))}async function RD(t,e){return wt(t,e,(n,r)=>[...uH(n,r),...lH(n,r),...cH(n,r),...dH(n,r),...aH(n,r),...oH(n,r),...sH(n),...fH(n),...pH(n,r)])}var Wp=L(U());var ED=require("child_process");var FT=t=>/[A-Za-z0-9_]/.test(t);function hH(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 wD(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 CD(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 BT(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=CD(i,0,i.length),o={macro:r,args:[]};return o.args=s.map(a=>{let c=BT(a.text);return c.parent=o,c}),o}function zi(t,e){let n=t.getText(),r=t.offsetAt(e),i=r,s=r;for(;i>0&&FT(n[i-1]);)i--;for(;s<n.length&&FT(n[s]);)s++;if(n[s]==="("){let y=wD(n,s);y!==void 0&&(s=y+1)}let o=n.slice(i,s),a=o.trim().length?BT(o):void 0,c=hH(n,r);if(c===void 0)return a;let l=wD(n,c);if(l===void 0||!(c<r&&r<=l))return a;let u=c,d=u;for(;d>0&&FT(n[d-1]);)d--;let f=n.slice(d,u);if(!f)return a;let p=CD(n,c+1,l),m={macro:f,args:[]};m.args=p.map(y=>{let _=BT(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 mH(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 dt.create(o,u>=0?u:a.length)}}}async function vs(t,e,n,r){let i=DD(t,e,n);if(i)return i;let s=await yH(e,r,Se(t.uri));if(s)return[s,n]}function DD(t,e,n){if(e.startsWith("DT_"))return;let r=mH(t,e,n);if(!r)return;let i=zi(t,r);if(i)return[i,r]}var gH=(t,e)=>new Promise(n=>{let r=(0,ED.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 yH(t,e,n){let r=e.getCompileCommands()?.find(s=>fe(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 gH(s,o.filter(u=>!!u)),c=Vt.create(`macros://${r.file}`,"devicetree",0,a),l=DD(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 ol=L(U());async function AD({macro:t,context:e}){if(t.macro&&"DT_ALIAS".startsWith(t.macro))return[{label:"DT_ALIAS(...)",insertText:"DT_ALIAS($1)",kind:ol.CompletionItemKind.Function,insertTextFormat:ol.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 se?s=i.linksTo:i instanceof ei&&(s=i.pathParts.at(-1)?.linksTo),{label:Z(r.name),kind:ol.CompletionItemKind.Property,documentation:s?.toMarkupContent(n.context.macros)}})??[]}var al=L(U());async function wn(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 ut)return s.path?.pathParts.at(-1)?.linksTo;if(s instanceof se)return s.linksTo;if(s instanceof ie)return s.value;if(s instanceof ge){let o=s.evaluate(n.macros);return typeof o=="number"?o:s.toString()}})}async function fp({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?wn(o,s[1].macro,n):void 0}async function ID(t,e){let n=await fp(t,e);if(typeof n=="boolean")return;let r=n?.at(0);if(n?.length===1&&r instanceof X)return r}async function OD(t,e,n,r){if(n=typeof n=="number"?n:Me(n),typeof n!="number")return;let i=await wn(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 pp({document:t,macro:e,context:n,position:r},i){if(!(e.macro!=="DT_PROP_BY_IDX"||e.args?.length!==3))return OD(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro,n)}async function MD(t,e){let n=await pp(t,e);if(typeof n!="boolean"&&n instanceof X)return n}async function tr(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 hp(t,e,n,r){return tr(await wn(t,e,n.context),n,r)}async function wa({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 hp(c,o.macro,{macro:a,document:t,context:n,position:r},i)}async function xD(t,e){let n=await wa(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 LD(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 mp(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 LD(r)}async function gp(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 se)return s.linksTo;if(s instanceof ut)return s.path?.pathParts.at(-1)?.linksTo}async function yp(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_CHOSEN"||e?.length!==1))return await gp(t.context,e[0].macro)}async function Tp(t,e){let n=await e?.getRuntime();if(n){let r=ki.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 ie?r=n.rootNode.getChild(s[0].value.split("/")):s?.[0]instanceof se?r=s[0].linksTo:s?.[0]instanceof ut&&(r=s[0].path?.pathParts.at(-1)?.linksTo),r}}async function vp({macro:t,context:e}){if(!(t.macro!=="DT_ALIAS"||t.args?.length!==1))return Tp(t.args[0].macro,e)}async function qD(t,e){return t?.nodes.find(n=>Z(n.name)===e)}async function bp({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 qD(s,e.args[1].macro)}var jT=(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,...jT(n,e)]:jT(n,e));async function $D(t,e){let n=await e?.getRuntime();if(n)return jT(n.rootNode,t)}async function UT({macro:t,context:e}){if(!(t.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.args?.length!==1))return $D(t.args[0].macro,e)}async function FD(t){return(await UT(t))?.at(0)}async function BD(t){return t?.parent?.parent??void 0}async function _p({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 BD(s)}var HT=(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,...HT(n,e)]:HT(n,e));async function jD(t,e,n){let r=await n?.getRuntime();if(r)return HT(r.rootNode,e).at(t)}async function Sp({macro:t,context:e}){if(t.macro!=="DT_INST"||t.args?.length!==2)return;let n=Me(t.args[0].macro);if(typeof n=="number")return jD(n,t.args[1].macro,e)}async function UD(t,e){let n=await e?.getRuntime(),r=n?.resolvePath([`&${t.trim()}`]);if(n&&r)return ki.getNodeFromPath(r.slice(1),n.rootNode,!0)}async function kp({macro:t,context:e}){if(!(t.macro!=="DT_NODELABEL"||t.args?.length!==1))return UD(t.args[0].macro,e)}async function HD(t){return t?.parent??void 0}async function Pp({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 HD(s)}var VD=(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?VD(r,e):void 0};async function Np(t,e){let n=await e?.getRuntime();if(n)return VD(n.rootNode,t)}async function Rp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_PATH"||!n?.length))return Np(n.map(r=>r.macro),e)}async function wp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_ROOT"||n?.length))return(await e.getRuntime()).rootNode}async function Ea(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 St))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 Ep(t,e,n,r,i){return tr(await Ea(t,e,n),r,i)}async function Cp({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=Me(s[2].macro);if(typeof a=="number")return await Ep(o,s[1].macro,a,{macro:s[3],document:t,context:n,position:r},i)}async function Dp({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 Ep(o,s[1].macro,0,{macro:s[2],document:t,context:n,position:r},i)}async function bs(t,e,n,r,i){let s=t?.properties.find(d=>Z(d.name)===e),o=s?.parent.nodeType;if(!o||!(o instanceof St))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 Ca(t,e,n,r,i,s){return tr(await bs(t,e,n,r,i.context),i,s)}async function Ap({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=Me(s[2].macro);if(typeof a=="number")return Ca(o,s[1].macro,a,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Ip({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 Ca(o,s[1].macro,s[2].macro,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Ni(t,e,n=0){let r=t?.properties.find(s=>Z(s.name)===e);if(n=typeof n=="number"?n:Me(n??"0"),typeof n!="number")return;let i=r?.ast.getFlatAstValues()?.at(n);if(i instanceof se)return i.linksTo;if(i instanceof ut)return i.path?.pathParts.at(-1)?.linksTo}async function _s({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 Ni(o,s[1].macro,0)}async function Ri({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 Ni(o,s[1].macro,s.at(2)?.macro)}async function WD(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 St))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 Op({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 WD(o,s[1].macro,s[2].macro)}async function Mp({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 Ca(o,s[1].macro,0,s[2].macro,{macro:s[3],document:t,context:n,position:r},i)}async function xp({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 Ni(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro);return hp(s,e.args[3].macro,{macro:e.args[4],document:t,context:n,position:r},i)}async function Lp(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 zD(t,e,n,r){if(t)return tr(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_PROP_LEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return o?zD(o,s[1].macro,{macro:s[2],document:t,context:n,position:r},i):void 0}async function Da(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof ie)return Z(r[0].value)}async function GD(t,e,n,r){if(t)return tr(await Da(t,e),n,r)}async function $p({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 GD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function Fp(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof ie)return r[0].value}async function KD(t,e,n,r){if(t)return tr(await Fp(t,e),n,r)}async function Bp({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 KD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function jp(t,e){return(await Da(t,e))?.toUpperCase()}async function YD(t,e,n,r){if(t)return tr(await jp(t,e),n,r)}async function Up({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 YD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}function ni(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[mp,yp,vp,bp,FD,_p,Sp,kp,Pp,Rp,_s,Ri,Op,MD,ID,xD,wp,ni(Cp),ni(Dp),ni(Ap),ni(Ip),ni(Mp),ni(xp),ni(qp),ni(wa),ni($p),ni(Bp),ni(Up)].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 vs(e,t.macro,r,n);if(o)return x({document:e,macro:o[0],context:n,position:r})}async function XD({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:al.CompletionItemKind.Function,insertTextFormat:al.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:al.CompletionItemKind.Class,documentation:s.toMarkupContent(n.macros)}))??[]}var cl=L(U());function JD({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:cl.CompletionItemKind.Function,insertTextFormat:cl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.argIndexInParent!==0?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:cl.CompletionItemKind.Property}))??[]}var ll=L(U());function QD({macro:t,context:e}){return t.macro&&"DT_INST".startsWith(t.macro)?[{label:"DT_INST(...)",insertText:"DT_INST($1, $2)",kind:ll.CompletionItemKind.Function,insertTextFormat:ll.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_INST"||t.argIndexInParent!==1?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:ll.CompletionItemKind.Property}))??[]}var ul=L(U());async function ZD({macro:t,context:e}){if(t.macro&&"DT_NODELABEL".startsWith(t.macro))return[{label:"DT_NODELABEL(...)",insertText:"DT_NODELABEL($1)",kind:ul.CompletionItemKind.Function,insertTextFormat:ul.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:ul.CompletionItemKind.Property,documentation:r.lastLinkedTo?.toMarkupContent(n.context.macros)}))??[])}var dl=L(U());async function eA({macro:t,context:e}){return t.macro&&t.macro&&"DT_PATH".startsWith(t.macro)?[{label:"DT_PATH(...)",insertText:"DT_PATH($1)",kind:dl.CompletionItemKind.Function,insertTextFormat:dl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_PATH"||!t.parent.args?.length?[]:(await Np(t.parent.args.slice(0,-1).map(r=>r.macro),e))?.nodes.map(r=>({label:Z(r.fullName),kind:dl.CompletionItemKind.Class,documentation:r.toMarkupContent(e.macros)}))??[]}var tA=L(U());async function nA({macro:t,context:e}){if(t.macro&&t.macro&&"DT_ROOT".startsWith(t.macro)){let n=await e.getRuntime();return[{label:"DT_ROOT",kind:tA.CompletionItemKind.Class,documentation:n.rootNode.toMarkupContent(n.context.macros)}]}return[]}var Hp=L(U());function rA({macro:t}){return t.macro&&t.macro&&"DT_SAME_NODE".startsWith(t.macro)?[{label:"DT_SAME_NODE(...)",insertText:"DT_SAME_NODE($1, $2)",kind:Hp.CompletionItemKind.Snippet,insertTextFormat:Hp.InsertTextFormat.Snippet}]:[]}var fl=L(U());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:fl.CompletionItemKind.Function,insertTextFormat:fl.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:fl.CompletionItemKind.Property,documentation:d.toPrettyString(r.macros)}))??[]}async function iA(t){return J(t,"DT_ENUM_HAS_VALUE",1,3)}async function sA(t){return J(t,"DT_ENUM_HAS_VALUE_BY_IDX",1,4)}async function oA(t){return J(t,"DT_ENUM_IDX",1,2)}async function aA(t){return J(t,"DT_ENUM_IDX_BY_IDX",1,3)}async function cA(t){return J(t,"DT_ENUM_IDX_BY_IDX_OR",1,4)}async function lA(t){return J(t,"DT_ENUM_IDX_OR",1,3)}var uA=L(U());async function Gi({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:uA.CompletionItemKind.Property}))??[]}async function dA(t){return t.macro.argIndexInParent===2?Gi(t,"DT_PHA",2,0):J(t,"DT_PHA",1,3,e=>!!e.nexusMapsTo.length)}var fA=L(U());async function TH({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:fA.CompletionItemKind.Property}))??[]}async function pA(t){if(t.macro.argIndexInParent===2)return TH(t,"DT_PHA_BY_IDX");if(t.macro.argIndexInParent===3){let e=t.macro.parent?.args?Me(t.macro.parent.args[2].macro):void 0;return typeof e!="number"?[]:Gi(t,"DT_PHA_BY_IDX",3,e)}return J(t,"DT_PHA_BY_IDX",1,3,e=>!!e.nexusMapsTo.length)}var hA=L(U());async function pl({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:hA.CompletionItemKind.Property}))??[]}async function mA(t){let{macro:e}=t;return e.argIndexInParent===2?pl(t,"DT_PHA_BY_NAME"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Gi(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 gA(t){let{macro:e}=t;return e.argIndexInParent===2?pl(t,"DT_PHA_BY_NAME_OR"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Gi(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 yA(t){let{macro:e}=t;return e.argIndexInParent===2?Gi(t,"DT_PHA_OR",2,0):J(t,"DT_PHA_OR",1,3,n=>!!n.nexusMapsTo.length)}async function Vp(t){return J(t,"DT_PHANDLE",1,2,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof se||n instanceof ut))}async function Aa(t){return J(t,"DT_PHANDLE_BY_IDX",1,3,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof se||n instanceof ut))}async function TA(t){let{macro:e}=t;return e.argIndexInParent===2?pl(t,"DT_PHANDLE_BY_NAME"):J(t,"DT_PHANDLE_BY_NAME",1,3,n=>!!n.ast.getFlatAstValues()?.some(r=>r instanceof se||r instanceof ut))}async function vA(t){return J(t,"DT_PROP",1,2,e=>!e.nexusMapsTo.length)}async function bA(t){return J(t,"DT_PROP_BY_IDX",1,3,e=>!e.nexusMapsTo.length)}async function _A(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX"?Aa({...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,()=>Ri({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function SA(t){let{macro:e}=t;return e.argIndexInParent===1&&e.parent?.macro==="DT_PROP_BY_PHANDLE"?Vp({...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,()=>_s({...t,macro:{macro:"DT_PHANDLE",args:e.parent?.args?.slice(0,2)}},x))}async function kA(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX_OR"?Aa({...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,()=>Ri({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function PA(t){return J(t,"DT_PROP_HAS_IDX",1,3,e=>!e.nexusMapsTo.length)}async function NA(t){return J(t,"DT_PROP_HAS_NAME",1,3,e=>!e.nexusMapsTo.length)}async function RA(t){return J(t,"DT_PROP_LAST",1,2,e=>!e.nexusMapsTo.length)}async function wA(t){return J(t,"DT_PROP_LEN",1,2,e=>!e.nexusMapsTo.length)}async function EA(t){return J(t,"DT_PROP_LEN_OR",1,2,e=>!e.nexusMapsTo.length)}async function CA(t){return J(t,"DT_PROP_OR",1,2,e=>!e.nexusMapsTo.length)}async function DA(t){return J(t,"DT_STRING_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function AA(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 ie)})}async function IA(t){return J(t,"DT_STRING_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function OA(t){return J(t,"DT_STRING_UNQUOTED",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function MA(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 ie)})}async function xA(t){return J(t,"DT_STRING_UNQUOTED_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function LA(t){return J(t,"DT_STRING_UPPER_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function qA(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 ie)})}async function $A(t){return J(t,"DT_STRING_UPPER_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}var hl=L(U());async function FA({macro:t,context:e}){return t.parent?.macro==="DT_ON_BUS"&&t.argIndexInParent===1?e.bindingLoader?.getBusTypes().map(n=>({label:Z(n),kind:hl.CompletionItemKind.Enum}))??[]:t.macro&&"DT_ON_BUS".startsWith(t.macro)?[{label:"DT_ON_BUS(...)",insertText:"DT_ON_BUS($1, $2)",kind:hl.CompletionItemKind.Function,insertTextFormat:hl.InsertTextFormat.Snippet}]:[]}async function BA(t){return J(t,"DT_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}async function jA(t){return J(t,"DT_HAS_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}var vH=["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 UA(t,e,n){if(!n)return[];let r=zi(n,t.position);return r?(await Promise.all([FA,BA,jA,AD,XD,JD,QD,bH,ZD,eA,nA,rA,sA,iA,aA,cA,oA,lA,pA,mA,gA,dA,Aa,TA,Vp,yA,bA,SA,_A,kA,vA,PA,NA,RA,wA,EA,CA,DA,AA,IA,OA,MA,xA,LA,qA,$A].flatMap(async i=>await i({document:n,context:e,macro:r,position:t.position})))).flat():[]}function bH({macro:t}){return t.macro?vH.filter(e=>e.startsWith(t.macro)).map(e=>({label:`${e}(...)`,insertText:`${e}($1)`,kind:Wp.CompletionItemKind.Function,insertTextFormat:Wp.InsertTextFormat.Snippet})):[]}var Dr=L(U());function _H(t){if(!t||t.item===null||!(t.ast instanceof Je))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=Yn(s.fsPath);if(o)return Dr.Location.create(ue(o.docFsPath),o.range);if(s instanceof Ne)return Dr.Location.create(ue(s.fsPath),ce(s.propertyName??s));if(s instanceof at)return Dr.Location.create(ue(s.fsPath),ce(s.propertyName??s))}).filter(s=>s)};if(t.item instanceof Qe&&t.ast instanceof Je)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function SH(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 $e?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&&Yn(o?.fsPath);if(a)return Dr.Location.create(ue(a.docFsPath),a.range);if(o instanceof nt)return Dr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof Ee)return Dr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof $e)return Dr.Location.create(ue(o.fsPath),ce(o));if(o instanceof $e)return Dr.Location.create(ue(o.fsPath),ce(o));if(o instanceof se)return Dr.Location.create(ue(o.fsPath),ce(o.label??o));if(o instanceof Ne)return Dr.Location.create(ue((o.values??o)?.fsPath),ce(o.values??o))}).filter(o=>o)};if(t.item instanceof X&&!Jt(t.ast))return e(t.item);if(t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return e(t.ast.parentNode.linksTo);if(t.ast instanceof $e&&t.ast.linksTo)return Jt(t.ast)?[...e(t.ast.linksTo),Dr.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Qe&&t.item.parent.name==="aliases"){let n=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(n)return e(n)}return[]}async function HA(t,e){return wt(t,e,n=>[...SH(n),..._H(n)])}var Ki=L(U());function VA(t){if(!t||t.item===null||!(t.ast instanceof Je))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 Ne||i instanceof at)&&i.propertyName)return Ki.Location.create(ue(i.fsPath),ce(i.propertyName))}).filter(i=>i);if(t.item instanceof Qe&&t.ast instanceof Je)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function WA(t,e){if(!e||!(e.ast instanceof mn))return[];"newName"in t&&(e.ast.parentNode instanceof se&&t.newName.startsWith("&")?t.newName=t.newName.slice(1):e.ast.parentNode instanceof Ts&&t.newName.endsWith(":")&&(t.newName=t.newName.slice(0,-1)));let n=e.ast.value,r=i=>[...i.implementations.filter(s=>s instanceof Ee||s instanceof ct).flatMap(s=>s.labels.map(o=>o.label)),...i.linkedRefLabels.map(s=>s.label)].filter(s=>s?.value===n).map(s=>{if(s)return Ki.Location.create(ue(s.fsPath),ce(s))}).filter(s=>s);return e.item instanceof X&&!Jt(e.ast)?r(e.item):e.ast instanceof mn&&e.ast.parentNode instanceof se&&e.ast.parentNode.linksTo?r(e.ast.parentNode.linksTo):[]}function zA(t){if(!t||!(t.ast instanceof $e)||t.ast instanceof $e&&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 Ee&&o.name)return Ki.Location.create(ue(o.fsPath),ce(o.name));if(o instanceof $e)return Ki.Location.create(ue(o.fsPath),ce(o));if(o instanceof Ne&&o.values?.values[0]?.value&&o.values?.values[0]?.value instanceof ie){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,Ki.Location.create(ue(o.values.values[0].fsPath),c)}}).filter(o=>o)};return t.item instanceof X&&!Jt(t.ast)?e(t.item):t.ast instanceof $e&&t.ast.linksTo?Jt(t.ast)?[...e(t.ast.linksTo),Ki.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo):[]}async function GA(t,e){let n={};return(await wt(t,e,i=>[...zA(i),...WA(t,i),...VA(i)])).forEach(i=>{n[i.uri]??=[],n[i.uri].push(Ki.TextEdit.replace(i.range,t.newName))}),{changes:n}}async function KA(t,e){let n=await wt(t,e,r=>[...zA(r),...WA(t,r),...VA(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=>lo(r.uri)))throw new Error("Item was generated using a MACRO.");return{defaultBehavior:!!n.length}}var Oa=L(U());var Ia=t=>t.implementations.map(e=>{let n=Yn(e.fsPath);return n?Oa.Location.create(ue(n.docFsPath),n.range):Oa.Location.create(ue(e.fsPath),ce(e))}).filter(e=>e),YA=t=>t.replacedBy?YA(t.replacedBy):t,zp=t=>[t.ast,...t.allReplaced.map(e=>e.ast)].map(e=>{let n=Yn(e.fsPath);return n?Oa.Location.create(ue(n.docFsPath),n.range):Oa.Location.create(ue(e.fsPath),ce(e.propertyName??e))}).filter(e=>e);function kH(t){if(!t||t.item===null||!(t.ast instanceof Je))return[];if(t.item instanceof Qe&&t.ast instanceof Je)return zp(YA(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let e=t.item.deletedProperties.find(n=>n.by===t.ast.parentNode)?.property;if(e)return zp(e)}return[]}function PH(t){if(!t)return[];if(t.item instanceof X&&!Jt(t.ast))return Ia(t.item);if(t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return Ia(t.ast.parentNode.linksTo);if(t.ast instanceof $e&&t.ast.linksTo)return Ia(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Qe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Ia(e)}return[]}function NH(t){if(t?.ast instanceof yt||t?.ast instanceof bi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof yt?t.ast.name:t.ast.value);if(e)return[Oa.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))]}return[]}async function XA(t,e){return wt(t,e,n=>[...PH(n),...kH(n),...NH(n)])}var RH=["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 Gp({macro:t,document:e,context:n,position:r}){if(RH.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 _s({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 Ri({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 JA(t,e,n){if(!n)return;let r=zi(n,t.position);return QA(r,t.position,e,n)}async function QA(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Ia(i);let s=await Gp({document:r,macro:t,context:n,position:e});if(s)return zp(s);let o=await vs(r,t.macro,e,n);if(o)return QA(o[0],o[1],n,r)}var Ss=L(U());var Ma=t=>{let e=t.definitions.at(0),n=e&&Yn(e.fsPath);return n?Ss.Location.create(ue(n.docFsPath),n.range):e?Ss.Location.create(ue(e.fsPath),ce(e)):void 0},Kp=t=>t.replaces?Kp(t.replaces):t,ZA=t=>{let e=Kp(t),n=Yn(e.ast.fsPath);return n?Ss.Location.create(ue(n.docFsPath),n.range):e?Ss.Location.create(ue(e.ast.fsPath),ce(e.ast)):void 0};function wH(t){if(!t||t.item===null||!(t.ast instanceof Je))return;let e=n=>{let r=Yn(n.ast.fsPath);return r?Ss.Location.create(ue(r.docFsPath),r.range):Ss.Location.create(ue(n.ast.fsPath),ce(n.ast.propertyName??n.ast))};if(t.item instanceof Qe&&t.ast instanceof Je)return e(Kp(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let n=t.item.deletedProperties.find(r=>r.by===t.ast.parentNode)?.property;if(n)return e(Kp(n))}}function EH(t){if(t){if(t.item instanceof X&&!Jt(t.ast))return Ma(t.item);if(t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return Ma(t.ast.parentNode.linksTo);if(t.ast instanceof $e&&t.ast.linksTo)return Ma(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Qe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Ma(e)}}}function CH(t){if(t?.ast instanceof yt||t?.ast instanceof bi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof yt?t.ast.name:t.ast.value);if(e)return Ss.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))}}async function e0(t,e){return(await wt(t,e,n=>[EH(n)||wH(n)||CH(n)])).at(0)}async function t0(t,e,n){if(!n)return;let r=zi(n,t.position);return n0(r,t.position,e,n)}async function n0(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Ma(i);let s=await Gp({document:r,macro:t,context:n,position:e});if(s)return ZA(s);let o=await vs(r,t.macro,e,n);if(o)return n0(o[0],o[1],n,r)}var pe=L(U());var DH=(t,e,n,r,i)=>{switch(n){case 1:return[{title:"Add semicolon",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.insert(pe.Position.create(r.range.end.line,r.range.end.character),";")]}}}];case 2:return[{title:"Add open curly",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.insert(pe.Position.create(r.range.end.line,r.range.end.character)," {")]}}}];case 29:return[{title:"Remove white space",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.replace(pe.Range.create(pe.Position.create(r.range.start.line,t.pos.colEnd),pe.Position.create(r.range.end.line,e.pos.col)),"")]}}}];case 3:return[{title:"Add close curly",diagnostics:[r],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.insert(pe.Position.create(r.range.end.line,r.range.end.character),"}")]}}}];case 19:return[{title:"Add '/'",diagnostics:[r],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.insert(pe.Position.create(r.range.end.line,r.range.end.character),"/")]}}}];case 28:return[{title:"Add comma",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.insert(pe.Position.create(r.range.end.line,r.range.end.character),",")]}}}];case 21:return[{title:"Add '/'",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.insert(pe.Position.create(r.range.end.line,r.range.end.character),"/")]}}}];case 23:return[{title:"Remove ';'",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.del(r.range)]}}}];case 34:return[{title:"Complete Keyword '/delete-node/",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.replace(r.range,"/delete-node/")]}}}];case 35:return[{title:"Complete Keyword '/delete-property/",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.replace(r.range,"/delete-property/")]}}}];case 25:return[{title:"Complete Keyword '/delete-property/",diagnostics:[r],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.replace(r.range,"/delete-property/")]}}},{title:"Complete Keyword '/delete-node/",diagnostics:[r],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.replace(r.range,"/delete-node/")]}}}];case 12:return[{title:"Add '>'",diagnostics:[r],kind:pe.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[pe.TextEdit.insert(pe.Position.create(r.range.end.line,r.range.end.character),">")]}}}];default:return}},AH=(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:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 27:return[{title:i??"Remove Property",diagnostics:[e],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 26:return[{title:i??"TODO",diagnostics:[e],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 36:return[{title:i??"TODO",diagnostics:[e],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}];case 25:return r?[{title:i??"TODO",diagnostics:[e],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[n]:r}}}]:[];default:return}},IH=(t,e,n,r)=>n?.length?[{title:r??"TODO",diagnostics:[t],kind:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[e]:n}}}]:[];function r0(t){let e=t.context.diagnostics.flatMap(a=>{let c=a.data;if(c?.virtual)return[];switch(c?.type){case"FormattingIssues":return IH(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=>DH(c.firstToken,c.lastToken,l,a,t.textDocument.uri));case"StandardTypeIssue":return c?.items.flatMap(l=>AH(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===pe.CodeActionKind.SourceFixAll),r=e.filter(a=>a.title.startsWith("Add Property")),i=e.filter(a=>a.kind!==pe.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:pe.CodeActionKind.QuickFix})),...s.length?[{title:"Fix All",kind:pe.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:pe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:a}}}:[])]}var ee=L(U());function i0(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 ml=(t,e)=>e.some(n=>i0(t,n.start)>=0&&i0(t,n.end)<=0),OH=async(t,e,n)=>{let r=dt.create(t.pos.line,t.pos.col),i=n.find(s=>Xt(s,e,r));if(i)return Zr(i,e,r)},Ar=(t,e)=>{let n=dt.create(e.length-1,e.at(-1)?.length??0),r=[],i;return t.filter(o=>(o instanceof pr||o instanceof hr)&&/^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:dt.create(o.firstToken.pos.line,o instanceof pr?o.firstToken.pos.colEnd:0)};else if(a==="dts-format on"&&i){let c=dt.create(o.lastToken.pos.line,o instanceof pr?o.lastToken.pos.colEnd-1:e[o.lastToken.pos.line-1].length);r.push(Ye.create(i.start,c)),i=void 0}}),i&&r.push(Ye.create(i.start,n)),r},xa=async(t,e,n)=>(await VT(t,e,n))?.allAstItems,VT=async(t,e,n)=>{if(e!==n){let r=new Cr(t,[],void 0,()=>new Zn(n,t).tokens,!0);return await r.stable,r}},Ir=(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=>!ml(o.range.start,t)&&!ml(o.range.end,t))):n;return"range"in e&&(r=r.filter(i=>qf(e.range,i.raw.range))),r},La=(t,e)=>async n=>{let r=t.filter(a=>!(a instanceof Er)&&!(a instanceof hr)&&!(a instanceof pr)&&!(a instanceof mr)&&!(a instanceof er)),i=await OH(n.firstToken,e,r);if(!i||i===n||n.allDescendants.some(a=>a===i))return{level:0};let s=jf(i);return{level:fo(e,s),inAst:i}},Ln=(t,e)=>{if(t.insertSpaces)return"".padStart(e," ");let n=Math.floor(e/t.tabSize),r=e%t.tabSize;return`${"".padStart(n," ")}${"".padStart(r," ")}`},Or=(t,e,n="")=>`${"".padStart(t*e.length,e)}${n}`,s0=t=>{let e=t.parentNode;if(!(!e||!(e instanceof ge)))return!(e instanceof tn)||!e.openBracket?s0(e):e};function yo(t,e,n,r,i,s,o=!1){if(!o&&hn(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=s0(e);if(!a)return s;let l=yo(t,a,n,r,i,s);return!o&&hn(e.firstToken,a.firstToken)?l+=e.firstToken.pos.col-a.firstToken.pos.col:a instanceof tn&&a.openBracket&&++l,l}var ri=(t,e,n)=>t[e]??n,Yp=t=>({baseFormattingRules:ri(t,"baseFormattingRules",!0),removeMacroMultiline:ri(t,"removeMacroMultiline",!0),wrapLongLines:ri(t,"wrapLongLines",!0),indentExpressions:ri(t,"indentExpressions",!0),removeEmptyReferences:ri(t,"removeEmptyReferences",!0),removeEmptyRoots:ri(t,"removeEmptyRoots",!1),removeEmptyNodes:ri(t,"removeEmptyNodes",!1),removeDuplicateProperties:ri(t,"removeDuplicateProperties",!0),sortNodesAndProperties:ri(t,"sortNodesAndProperties",!1),sortNodesNodesBy:ri(t,"sortNodesNodesBy","none"),sortPropertiesAlphabetically:ri(t,"sortPropertiesAlphabetically",!1)});var qt=L(U());function ks(t,e,n,r){if(!hn(t,e)){let o=e.prevToken;for(;t!==o;){if(o&&hn(t,o)&&ks(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 WT(t,e,n,r,i,s,o=[]){let a=r.split(`
|
|
290
|
+
};`,kind:It.CompletionItemKind.Class,sortText:`!${r}`,insertTextFormat:It.InsertTextFormat.Snippet}))}async function RD(t,e){return wt(t,e,(n,r)=>[...uH(n,r),...lH(n,r),...cH(n,r),...dH(n,r),...aH(n,r),...oH(n,r),...sH(n),...fH(n),...pH(n,r)])}var Wp=L(U());var ED=require("child_process");var FT=t=>/[A-Za-z0-9_]/.test(t);function hH(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 wD(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 CD(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 BT(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=CD(i,0,i.length),o={macro:r,args:[]};return o.args=s.map(a=>{let c=BT(a.text);return c.parent=o,c}),o}function zi(t,e){let n=t.getText(),r=t.offsetAt(e),i=r,s=r;for(;i>0&&FT(n[i-1]);)i--;for(;s<n.length&&FT(n[s]);)s++;if(n[s]==="("){let y=wD(n,s);y!==void 0&&(s=y+1)}let o=n.slice(i,s),a=o.trim().length?BT(o):void 0,c=hH(n,r);if(c===void 0)return a;let l=wD(n,c);if(l===void 0||!(c<r&&r<=l))return a;let u=c,d=u;for(;d>0&&FT(n[d-1]);)d--;let f=n.slice(d,u);if(!f)return a;let p=CD(n,c+1,l),m={macro:f,args:[]};m.args=p.map(y=>{let _=BT(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 mH(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 dt.create(o,u>=0?u:a.length)}}}async function vs(t,e,n,r){let i=DD(t,e,n);if(i)return i;let s=await yH(e,r,Se(t.uri));if(s)return[s,n]}function DD(t,e,n){if(e.startsWith("DT_"))return;let r=mH(t,e,n);if(!r)return;let i=zi(t,r);if(i)return[i,r]}var gH=(t,e)=>new Promise(n=>{let r=(0,ED.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 yH(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 gH(s,o.filter(u=>!!u)),c=Vt.create(`macros://${r.file}`,"devicetree",0,a),l=DD(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 ol=L(U());async function AD({macro:t,context:e}){if(t.macro&&"DT_ALIAS".startsWith(t.macro))return[{label:"DT_ALIAS(...)",insertText:"DT_ALIAS($1)",kind:ol.CompletionItemKind.Function,insertTextFormat:ol.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 se?s=i.linksTo:i instanceof ei&&(s=i.pathParts.at(-1)?.linksTo),{label:Z(r.name),kind:ol.CompletionItemKind.Property,documentation:s?.toMarkupContent(n.context.macros)}})??[]}var al=L(U());async function wn(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 ut)return s.path?.pathParts.at(-1)?.linksTo;if(s instanceof se)return s.linksTo;if(s instanceof ie)return s.value;if(s instanceof ge){let o=s.evaluate(n.macros);return typeof o=="number"?o:s.toString()}})}async function fp({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?wn(o,s[1].macro,n):void 0}async function ID(t,e){let n=await fp(t,e);if(typeof n=="boolean")return;let r=n?.at(0);if(n?.length===1&&r instanceof X)return r}async function OD(t,e,n,r){if(n=typeof n=="number"?n:Me(n),typeof n!="number")return;let i=await wn(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 pp({document:t,macro:e,context:n,position:r},i){if(!(e.macro!=="DT_PROP_BY_IDX"||e.args?.length!==3))return OD(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro,n)}async function MD(t,e){let n=await pp(t,e);if(typeof n!="boolean"&&n instanceof X)return n}async function tr(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 hp(t,e,n,r){return tr(await wn(t,e,n.context),n,r)}async function wa({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 hp(c,o.macro,{macro:a,document:t,context:n,position:r},i)}async function xD(t,e){let n=await wa(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 LD(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 mp(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 LD(r)}async function gp(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 se)return s.linksTo;if(s instanceof ut)return s.path?.pathParts.at(-1)?.linksTo}async function yp(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_CHOSEN"||e?.length!==1))return await gp(t.context,e[0].macro)}async function Tp(t,e){let n=await e?.getRuntime();if(n){let r=ki.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 ie?r=n.rootNode.getChild(s[0].value.split("/")):s?.[0]instanceof se?r=s[0].linksTo:s?.[0]instanceof ut&&(r=s[0].path?.pathParts.at(-1)?.linksTo),r}}async function vp({macro:t,context:e}){if(!(t.macro!=="DT_ALIAS"||t.args?.length!==1))return Tp(t.args[0].macro,e)}async function qD(t,e){return t?.nodes.find(n=>Z(n.name)===e)}async function bp({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 qD(s,e.args[1].macro)}var jT=(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,...jT(n,e)]:jT(n,e));async function $D(t,e){let n=await e?.getRuntime();if(n)return jT(n.rootNode,t)}async function UT({macro:t,context:e}){if(!(t.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.args?.length!==1))return $D(t.args[0].macro,e)}async function FD(t){return(await UT(t))?.at(0)}async function BD(t){return t?.parent?.parent??void 0}async function _p({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 BD(s)}var HT=(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,...HT(n,e)]:HT(n,e));async function jD(t,e,n){let r=await n?.getRuntime();if(r)return HT(r.rootNode,e).at(t)}async function Sp({macro:t,context:e}){if(t.macro!=="DT_INST"||t.args?.length!==2)return;let n=Me(t.args[0].macro);if(typeof n=="number")return jD(n,t.args[1].macro,e)}async function UD(t,e){let n=await e?.getRuntime(),r=n?.resolvePath([`&${t.trim()}`]);if(n&&r)return ki.getNodeFromPath(r.slice(1),n.rootNode,!0)}async function kp({macro:t,context:e}){if(!(t.macro!=="DT_NODELABEL"||t.args?.length!==1))return UD(t.args[0].macro,e)}async function HD(t){return t?.parent??void 0}async function Pp({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 HD(s)}var VD=(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?VD(r,e):void 0};async function Np(t,e){let n=await e?.getRuntime();if(n)return VD(n.rootNode,t)}async function Rp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_PATH"||!n?.length))return Np(n.map(r=>r.macro),e)}async function wp({macro:t,context:e}){let n=t.args;if(!(t.macro!=="DT_ROOT"||n?.length))return(await e.getRuntime()).rootNode}async function Ea(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 St))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 Ep(t,e,n,r,i){return tr(await Ea(t,e,n),r,i)}async function Cp({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=Me(s[2].macro);if(typeof a=="number")return await Ep(o,s[1].macro,a,{macro:s[3],document:t,context:n,position:r},i)}async function Dp({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 Ep(o,s[1].macro,0,{macro:s[2],document:t,context:n,position:r},i)}async function bs(t,e,n,r,i){let s=t?.properties.find(d=>Z(d.name)===e),o=s?.parent.nodeType;if(!o||!(o instanceof St))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 Ca(t,e,n,r,i,s){return tr(await bs(t,e,n,r,i.context),i,s)}async function Ap({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=Me(s[2].macro);if(typeof a=="number")return Ca(o,s[1].macro,a,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Ip({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 Ca(o,s[1].macro,s[2].macro,s[3].macro,{macro:s[4],document:t,context:n,position:r},i)}async function Ni(t,e,n=0){let r=t?.properties.find(s=>Z(s.name)===e);if(n=typeof n=="number"?n:Me(n??"0"),typeof n!="number")return;let i=r?.ast.getFlatAstValues()?.at(n);if(i instanceof se)return i.linksTo;if(i instanceof ut)return i.path?.pathParts.at(-1)?.linksTo}async function _s({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 Ni(o,s[1].macro,0)}async function Ri({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 Ni(o,s[1].macro,s.at(2)?.macro)}async function WD(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 St))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 Op({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 WD(o,s[1].macro,s[2].macro)}async function Mp({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 Ca(o,s[1].macro,0,s[2].macro,{macro:s[3],document:t,context:n,position:r},i)}async function xp({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 Ni(await i({document:t,macro:e.args[0],context:n,position:r}),e.args[1].macro,e.args[2].macro);return hp(s,e.args[3].macro,{macro:e.args[4],document:t,context:n,position:r},i)}async function Lp(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 zD(t,e,n,r){if(t)return tr(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_PROP_LEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:n,position:r});return o?zD(o,s[1].macro,{macro:s[2],document:t,context:n,position:r},i):void 0}async function Da(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof ie)return Z(r[0].value)}async function GD(t,e,n,r){if(t)return tr(await Da(t,e),n,r)}async function $p({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 GD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function Fp(t,e){if(!t)return;let r=t?.properties.find(i=>Z(i.name)===e)?.ast.getFlatAstValues();if(r?.length===1&&r[0]instanceof ie)return r[0].value}async function KD(t,e,n,r){if(t)return tr(await Fp(t,e),n,r)}async function Bp({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 KD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}async function jp(t,e){return(await Da(t,e))?.toUpperCase()}async function YD(t,e,n,r){if(t)return tr(await jp(t,e),n,r)}async function Up({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 YD(o,s[1].macro,{document:t,macro:s[2],context:n,position:r},i)}function ni(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[mp,yp,vp,bp,FD,_p,Sp,kp,Pp,Rp,_s,Ri,Op,MD,ID,xD,wp,ni(Cp),ni(Dp),ni(Ap),ni(Ip),ni(Mp),ni(xp),ni(qp),ni(wa),ni($p),ni(Bp),ni(Up)].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 vs(e,t.macro,r,n);if(o)return x({document:e,macro:o[0],context:n,position:r})}async function XD({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:al.CompletionItemKind.Function,insertTextFormat:al.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:al.CompletionItemKind.Class,documentation:s.toMarkupContent(n.macros)}))??[]}var cl=L(U());function JD({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:cl.CompletionItemKind.Function,insertTextFormat:cl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.argIndexInParent!==0?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:cl.CompletionItemKind.Property}))??[]}var ll=L(U());function QD({macro:t,context:e}){return t.macro&&"DT_INST".startsWith(t.macro)?[{label:"DT_INST(...)",insertText:"DT_INST($1, $2)",kind:ll.CompletionItemKind.Function,insertTextFormat:ll.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_INST"||t.argIndexInParent!==1?[]:e.bindingLoader?.getBindings().map(n=>({label:Z(n),kind:ll.CompletionItemKind.Property}))??[]}var ul=L(U());async function ZD({macro:t,context:e}){if(t.macro&&"DT_NODELABEL".startsWith(t.macro))return[{label:"DT_NODELABEL(...)",insertText:"DT_NODELABEL($1)",kind:ul.CompletionItemKind.Function,insertTextFormat:ul.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:ul.CompletionItemKind.Property,documentation:r.lastLinkedTo?.toMarkupContent(n.context.macros)}))??[])}var dl=L(U());async function eA({macro:t,context:e}){return t.macro&&t.macro&&"DT_PATH".startsWith(t.macro)?[{label:"DT_PATH(...)",insertText:"DT_PATH($1)",kind:dl.CompletionItemKind.Function,insertTextFormat:dl.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_PATH"||!t.parent.args?.length?[]:(await Np(t.parent.args.slice(0,-1).map(r=>r.macro),e))?.nodes.map(r=>({label:Z(r.fullName),kind:dl.CompletionItemKind.Class,documentation:r.toMarkupContent(e.macros)}))??[]}var tA=L(U());async function nA({macro:t,context:e}){if(t.macro&&t.macro&&"DT_ROOT".startsWith(t.macro)){let n=await e.getRuntime();return[{label:"DT_ROOT",kind:tA.CompletionItemKind.Class,documentation:n.rootNode.toMarkupContent(n.context.macros)}]}return[]}var Hp=L(U());function rA({macro:t}){return t.macro&&t.macro&&"DT_SAME_NODE".startsWith(t.macro)?[{label:"DT_SAME_NODE(...)",insertText:"DT_SAME_NODE($1, $2)",kind:Hp.CompletionItemKind.Snippet,insertTextFormat:Hp.InsertTextFormat.Snippet}]:[]}var fl=L(U());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:fl.CompletionItemKind.Function,insertTextFormat:fl.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:fl.CompletionItemKind.Property,documentation:d.toPrettyString(r.macros)}))??[]}async function iA(t){return J(t,"DT_ENUM_HAS_VALUE",1,3)}async function sA(t){return J(t,"DT_ENUM_HAS_VALUE_BY_IDX",1,4)}async function oA(t){return J(t,"DT_ENUM_IDX",1,2)}async function aA(t){return J(t,"DT_ENUM_IDX_BY_IDX",1,3)}async function cA(t){return J(t,"DT_ENUM_IDX_BY_IDX_OR",1,4)}async function lA(t){return J(t,"DT_ENUM_IDX_OR",1,3)}var uA=L(U());async function Gi({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:uA.CompletionItemKind.Property}))??[]}async function dA(t){return t.macro.argIndexInParent===2?Gi(t,"DT_PHA",2,0):J(t,"DT_PHA",1,3,e=>!!e.nexusMapsTo.length)}var fA=L(U());async function TH({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:fA.CompletionItemKind.Property}))??[]}async function pA(t){if(t.macro.argIndexInParent===2)return TH(t,"DT_PHA_BY_IDX");if(t.macro.argIndexInParent===3){let e=t.macro.parent?.args?Me(t.macro.parent.args[2].macro):void 0;return typeof e!="number"?[]:Gi(t,"DT_PHA_BY_IDX",3,e)}return J(t,"DT_PHA_BY_IDX",1,3,e=>!!e.nexusMapsTo.length)}var hA=L(U());async function pl({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:hA.CompletionItemKind.Property}))??[]}async function mA(t){let{macro:e}=t;return e.argIndexInParent===2?pl(t,"DT_PHA_BY_NAME"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Gi(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 gA(t){let{macro:e}=t;return e.argIndexInParent===2?pl(t,"DT_PHA_BY_NAME_OR"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Gi(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 yA(t){let{macro:e}=t;return e.argIndexInParent===2?Gi(t,"DT_PHA_OR",2,0):J(t,"DT_PHA_OR",1,3,n=>!!n.nexusMapsTo.length)}async function Vp(t){return J(t,"DT_PHANDLE",1,2,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof se||n instanceof ut))}async function Aa(t){return J(t,"DT_PHANDLE_BY_IDX",1,3,e=>!!e.ast.getFlatAstValues()?.some(n=>n instanceof se||n instanceof ut))}async function TA(t){let{macro:e}=t;return e.argIndexInParent===2?pl(t,"DT_PHANDLE_BY_NAME"):J(t,"DT_PHANDLE_BY_NAME",1,3,n=>!!n.ast.getFlatAstValues()?.some(r=>r instanceof se||r instanceof ut))}async function vA(t){return J(t,"DT_PROP",1,2,e=>!e.nexusMapsTo.length)}async function bA(t){return J(t,"DT_PROP_BY_IDX",1,3,e=>!e.nexusMapsTo.length)}async function _A(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX"?Aa({...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,()=>Ri({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function SA(t){let{macro:e}=t;return e.argIndexInParent===1&&e.parent?.macro==="DT_PROP_BY_PHANDLE"?Vp({...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,()=>_s({...t,macro:{macro:"DT_PHANDLE",args:e.parent?.args?.slice(0,2)}},x))}async function kA(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX_OR"?Aa({...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,()=>Ri({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},x))}async function PA(t){return J(t,"DT_PROP_HAS_IDX",1,3,e=>!e.nexusMapsTo.length)}async function NA(t){return J(t,"DT_PROP_HAS_NAME",1,3,e=>!e.nexusMapsTo.length)}async function RA(t){return J(t,"DT_PROP_LAST",1,2,e=>!e.nexusMapsTo.length)}async function wA(t){return J(t,"DT_PROP_LEN",1,2,e=>!e.nexusMapsTo.length)}async function EA(t){return J(t,"DT_PROP_LEN_OR",1,2,e=>!e.nexusMapsTo.length)}async function CA(t){return J(t,"DT_PROP_OR",1,2,e=>!e.nexusMapsTo.length)}async function DA(t){return J(t,"DT_STRING_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function AA(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 ie)})}async function IA(t){return J(t,"DT_STRING_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function OA(t){return J(t,"DT_STRING_UNQUOTED",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function MA(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 ie)})}async function xA(t){return J(t,"DT_STRING_UNQUOTED_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function LA(t){return J(t,"DT_STRING_UPPER_TOKEN",1,2,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}async function qA(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 ie)})}async function $A(t){return J(t,"DT_STRING_UPPER_TOKEN_OR",1,3,e=>{let n=e.ast.getFlatAstValues();return n?.length===1&&n[0]instanceof ie})}var hl=L(U());async function FA({macro:t,context:e}){return t.parent?.macro==="DT_ON_BUS"&&t.argIndexInParent===1?e.bindingLoader?.getBusTypes().map(n=>({label:Z(n),kind:hl.CompletionItemKind.Enum}))??[]:t.macro&&"DT_ON_BUS".startsWith(t.macro)?[{label:"DT_ON_BUS(...)",insertText:"DT_ON_BUS($1, $2)",kind:hl.CompletionItemKind.Function,insertTextFormat:hl.InsertTextFormat.Snippet}]:[]}async function BA(t){return J(t,"DT_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}async function jA(t){return J(t,"DT_HAS_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}var vH=["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 UA(t,e,n){if(!n)return[];let r=zi(n,t.position);return r?(await Promise.all([FA,BA,jA,AD,XD,JD,QD,bH,ZD,eA,nA,rA,sA,iA,aA,cA,oA,lA,pA,mA,gA,dA,Aa,TA,Vp,yA,bA,SA,_A,kA,vA,PA,NA,RA,wA,EA,CA,DA,AA,IA,OA,MA,xA,LA,qA,$A].flatMap(async i=>await i({document:n,context:e,macro:r,position:t.position})))).flat():[]}function bH({macro:t}){return t.macro?vH.filter(e=>e.startsWith(t.macro)).map(e=>({label:`${e}(...)`,insertText:`${e}($1)`,kind:Wp.CompletionItemKind.Function,insertTextFormat:Wp.InsertTextFormat.Snippet})):[]}var Dr=L(U());function _H(t){if(!t||t.item===null||!(t.ast instanceof Je))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=Yn(s.fsPath);if(o)return Dr.Location.create(ue(o.docFsPath),o.range);if(s instanceof Ne)return Dr.Location.create(ue(s.fsPath),ce(s.propertyName??s));if(s instanceof at)return Dr.Location.create(ue(s.fsPath),ce(s.propertyName??s))}).filter(s=>s)};if(t.item instanceof Qe&&t.ast instanceof Je)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function SH(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 $e?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&&Yn(o?.fsPath);if(a)return Dr.Location.create(ue(a.docFsPath),a.range);if(o instanceof nt)return Dr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof Ee)return Dr.Location.create(ue(o.fsPath),ce(o.name??o));if(o instanceof $e)return Dr.Location.create(ue(o.fsPath),ce(o));if(o instanceof $e)return Dr.Location.create(ue(o.fsPath),ce(o));if(o instanceof se)return Dr.Location.create(ue(o.fsPath),ce(o.label??o));if(o instanceof Ne)return Dr.Location.create(ue((o.values??o)?.fsPath),ce(o.values??o))}).filter(o=>o)};if(t.item instanceof X&&!Jt(t.ast))return e(t.item);if(t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return e(t.ast.parentNode.linksTo);if(t.ast instanceof $e&&t.ast.linksTo)return Jt(t.ast)?[...e(t.ast.linksTo),Dr.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Qe&&t.item.parent.name==="aliases"){let n=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(n)return e(n)}return[]}async function HA(t,e){return wt(t,e,n=>[...SH(n),..._H(n)])}var Ki=L(U());function VA(t){if(!t||t.item===null||!(t.ast instanceof Je))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 Ne||i instanceof at)&&i.propertyName)return Ki.Location.create(ue(i.fsPath),ce(i.propertyName))}).filter(i=>i);if(t.item instanceof Qe&&t.ast instanceof Je)return n(e(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let r=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(r)return n(r)}return[]}function WA(t,e){if(!e||!(e.ast instanceof mn))return[];"newName"in t&&(e.ast.parentNode instanceof se&&t.newName.startsWith("&")?t.newName=t.newName.slice(1):e.ast.parentNode instanceof Ts&&t.newName.endsWith(":")&&(t.newName=t.newName.slice(0,-1)));let n=e.ast.value,r=i=>[...i.implementations.filter(s=>s instanceof Ee||s instanceof ct).flatMap(s=>s.labels.map(o=>o.label)),...i.linkedRefLabels.map(s=>s.label)].filter(s=>s?.value===n).map(s=>{if(s)return Ki.Location.create(ue(s.fsPath),ce(s))}).filter(s=>s);return e.item instanceof X&&!Jt(e.ast)?r(e.item):e.ast instanceof mn&&e.ast.parentNode instanceof se&&e.ast.parentNode.linksTo?r(e.ast.parentNode.linksTo):[]}function zA(t){if(!t||!(t.ast instanceof $e)||t.ast instanceof $e&&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 Ee&&o.name)return Ki.Location.create(ue(o.fsPath),ce(o.name));if(o instanceof $e)return Ki.Location.create(ue(o.fsPath),ce(o));if(o instanceof Ne&&o.values?.values[0]?.value&&o.values?.values[0]?.value instanceof ie){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,Ki.Location.create(ue(o.values.values[0].fsPath),c)}}).filter(o=>o)};return t.item instanceof X&&!Jt(t.ast)?e(t.item):t.ast instanceof $e&&t.ast.linksTo?Jt(t.ast)?[...e(t.ast.linksTo),Ki.Location.create(ue(t.ast.fsPath),ce(t.ast))]:e(t.ast.linksTo):[]}async function GA(t,e){let n={};return(await wt(t,e,i=>[...zA(i),...WA(t,i),...VA(i)])).forEach(i=>{n[i.uri]??=[],n[i.uri].push(Ki.TextEdit.replace(i.range,t.newName))}),{changes:n}}async function KA(t,e){let n=await wt(t,e,r=>[...zA(r),...WA(t,r),...VA(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=>lo(r.uri)))throw new Error("Item was generated using a MACRO.");return{defaultBehavior:!!n.length}}var Oa=L(U());var Ia=t=>t.implementations.map(e=>{let n=Yn(e.fsPath);return n?Oa.Location.create(ue(n.docFsPath),n.range):Oa.Location.create(ue(e.fsPath),ce(e))}).filter(e=>e),YA=t=>t.replacedBy?YA(t.replacedBy):t,zp=t=>[t.ast,...t.allReplaced.map(e=>e.ast)].map(e=>{let n=Yn(e.fsPath);return n?Oa.Location.create(ue(n.docFsPath),n.range):Oa.Location.create(ue(e.fsPath),ce(e.propertyName??e))}).filter(e=>e);function kH(t){if(!t||t.item===null||!(t.ast instanceof Je))return[];if(t.item instanceof Qe&&t.ast instanceof Je)return zp(YA(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let e=t.item.deletedProperties.find(n=>n.by===t.ast.parentNode)?.property;if(e)return zp(e)}return[]}function PH(t){if(!t)return[];if(t.item instanceof X&&!Jt(t.ast))return Ia(t.item);if(t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return Ia(t.ast.parentNode.linksTo);if(t.ast instanceof $e&&t.ast.linksTo)return Ia(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Qe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Ia(e)}return[]}function NH(t){if(t?.ast instanceof yt||t?.ast instanceof bi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof yt?t.ast.name:t.ast.value);if(e)return[Oa.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))]}return[]}async function XA(t,e){return wt(t,e,n=>[...PH(n),...kH(n),...NH(n)])}var RH=["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 Gp({macro:t,document:e,context:n,position:r}){if(RH.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 _s({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 Ri({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 JA(t,e,n){if(!n)return;let r=zi(n,t.position);return QA(r,t.position,e,n)}async function QA(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Ia(i);let s=await Gp({document:r,macro:t,context:n,position:e});if(s)return zp(s);let o=await vs(r,t.macro,e,n);if(o)return QA(o[0],o[1],n,r)}var Ss=L(U());var Ma=t=>{let e=t.definitions.at(0),n=e&&Yn(e.fsPath);return n?Ss.Location.create(ue(n.docFsPath),n.range):e?Ss.Location.create(ue(e.fsPath),ce(e)):void 0},Kp=t=>t.replaces?Kp(t.replaces):t,ZA=t=>{let e=Kp(t),n=Yn(e.ast.fsPath);return n?Ss.Location.create(ue(n.docFsPath),n.range):e?Ss.Location.create(ue(e.ast.fsPath),ce(e.ast)):void 0};function wH(t){if(!t||t.item===null||!(t.ast instanceof Je))return;let e=n=>{let r=Yn(n.ast.fsPath);return r?Ss.Location.create(ue(r.docFsPath),r.range):Ss.Location.create(ue(n.ast.fsPath),ce(n.ast.propertyName??n.ast))};if(t.item instanceof Qe&&t.ast instanceof Je)return e(Kp(t.item));if(t.item instanceof X&&t.ast instanceof Je&&t.ast.parentNode instanceof at){let n=t.item.deletedProperties.find(r=>r.by===t.ast.parentNode)?.property;if(n)return e(Kp(n))}}function EH(t){if(t){if(t.item instanceof X&&!Jt(t.ast))return Ma(t.item);if(t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return Ma(t.ast.parentNode.linksTo);if(t.ast instanceof $e&&t.ast.linksTo)return Ma(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Qe&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return Ma(e)}}}function CH(t){if(t?.ast instanceof yt||t?.ast instanceof bi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof yt?t.ast.name:t.ast.value);if(e)return Ss.Location.create(ue(e.macro.fsPath),ce(e.macro.identifier))}}async function e0(t,e){return(await wt(t,e,n=>[EH(n)||wH(n)||CH(n)])).at(0)}async function t0(t,e,n){if(!n)return;let r=zi(n,t.position);return n0(r,t.position,e,n)}async function n0(t,e,n,r){if(!t?.macro)return;let i=await x({document:r,macro:t,context:n,position:e});if(i)return Ma(i);let s=await Gp({document:r,macro:t,context:n,position:e});if(s)return ZA(s);let o=await vs(r,t.macro,e,n);if(o)return n0(o[0],o[1],n,r)}var fe=L(U());var DH=(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}},AH=(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}},IH=(t,e,n,r)=>n?.length?[{title:r??"TODO",diagnostics:[t],kind:fe.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[e]:n}}}]:[];function r0(t){let e=t.context.diagnostics.flatMap(a=>{let c=a.data;if(c?.virtual)return[];switch(c?.type){case"FormattingIssues":return IH(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=>DH(c.firstToken,c.lastToken,l,a,t.textDocument.uri));case"StandardTypeIssue":return c?.items.flatMap(l=>AH(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=L(U());function i0(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 ml=(t,e)=>e.some(n=>i0(t,n.start)>=0&&i0(t,n.end)<=0),OH=async(t,e,n)=>{let r=dt.create(t.pos.line,t.pos.col),i=n.find(s=>Xt(s,e,r));if(i)return Zr(i,e,r)},Ar=(t,e)=>{let n=dt.create(e.length-1,e.at(-1)?.length??0),r=[],i;return t.filter(o=>(o instanceof pr||o instanceof hr)&&/^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:dt.create(o.firstToken.pos.line,o instanceof pr?o.firstToken.pos.colEnd:0)};else if(a==="dts-format on"&&i){let c=dt.create(o.lastToken.pos.line,o instanceof pr?o.lastToken.pos.colEnd-1:e[o.lastToken.pos.line-1].length);r.push(Ye.create(i.start,c)),i=void 0}}),i&&r.push(Ye.create(i.start,n)),r},xa=async(t,e,n)=>(await VT(t,e,n))?.allAstItems,VT=async(t,e,n)=>{if(e!==n){let r=new Cr(t,[],void 0,()=>new Zn(n,t).tokens,!0);return await r.stable,r}},Ir=(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=>!ml(o.range.start,t)&&!ml(o.range.end,t))):n;return"range"in e&&(r=r.filter(i=>qf(e.range,i.raw.range))),r},La=(t,e)=>async n=>{let r=t.filter(a=>!(a instanceof Er)&&!(a instanceof hr)&&!(a instanceof pr)&&!(a instanceof mr)&&!(a instanceof er)),i=await OH(n.firstToken,e,r);if(!i||i===n||n.allDescendants.some(a=>a===i))return{level:0};let s=jf(i);return{level:fo(e,s),inAst:i}},Ln=(t,e)=>{if(t.insertSpaces)return"".padStart(e," ");let n=Math.floor(e/t.tabSize),r=e%t.tabSize;return`${"".padStart(n," ")}${"".padStart(r," ")}`},Or=(t,e,n="")=>`${"".padStart(t*e.length,e)}${n}`,s0=t=>{let e=t.parentNode;if(!(!e||!(e instanceof ge)))return!(e instanceof tn)||!e.openBracket?s0(e):e};function yo(t,e,n,r,i,s,o=!1){if(!o&&hn(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=s0(e);if(!a)return s;let l=yo(t,a,n,r,i,s);return!o&&hn(e.firstToken,a.firstToken)?l+=e.firstToken.pos.col-a.firstToken.pos.col:a instanceof tn&&a.openBracket&&++l,l}var ri=(t,e,n)=>t[e]??n,Yp=t=>({baseFormattingRules:ri(t,"baseFormattingRules",!0),removeMacroMultiline:ri(t,"removeMacroMultiline",!0),wrapLongLines:ri(t,"wrapLongLines",!0),indentExpressions:ri(t,"indentExpressions",!0),removeEmptyReferences:ri(t,"removeEmptyReferences",!0),removeEmptyRoots:ri(t,"removeEmptyRoots",!1),removeEmptyNodes:ri(t,"removeEmptyNodes",!1),removeDuplicateProperties:ri(t,"removeDuplicateProperties",!0),sortNodesAndProperties:ri(t,"sortNodesAndProperties",!1),sortNodesNodesBy:ri(t,"sortNodesNodesBy","none"),sortPropertiesAlphabetically:ri(t,"sortPropertiesAlphabetically",!1)});var qt=L(U());function ks(t,e,n,r){if(!hn(t,e)){let o=e.prevToken;for(;t!==o;){if(o&&hn(t,o)&&ks(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 WT(t,e,n,r,i,s,o=[]){let a=r.split(`
|
|
291
291
|
`),c=Ar(e,a),l=r;o.push(...await MH(t,e,n,a,s));let u=Ir(c,t,o);switch(l=Jn(Vt.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 MH(t,e,n,r,i){let s=La(e,n);return(await Promise.all(e.flatMap(async a=>await a0(t,a,n,s,r,i)))).flat()}var a0=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 we?xH(t,e,n,o,u,s,i,r):e instanceof Ne?qH(e,o,u,s,i,l):[]},xH=async(t,e,n,r,i,s,o,a)=>{let c=[];if(e instanceof Ee||e instanceof ct){let l=await LH(e.labels,r,i,o,i.singleIndent);if(l.length>0)c.push(...l);else{let u=e instanceof Ee?e.name:e.reference;u&&ks(u.firstToken,e.openScope??u.lastToken,i,o)&&c.push(Ve(8,n,ne(u.firstToken,!1),{edit:[qt.TextEdit.replace(qt.Range.create(ne(u.firstToken.prevToken),ne(u.firstToken,!1)),`
|
|
292
292
|
${Or(r,i.singleIndent)}`)],codeActionTitle:`Move ...${u.toString()}... to a new line`}))}}return c.push(...(await Promise.all(e.children.flatMap(l=>a0(t,l,n,a,o,s,r+1)))).flat()),c},LH=(t,e,n,r,i)=>{let s=t.findIndex(c=>ks(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[Ve(8,o.firstToken.fsPath,ne(o.firstToken,!1),{edit:[qt.TextEdit.replace(qt.Range.create(ne(o.firstToken.prevToken),ne(o.firstToken,!1)),`
|
|
293
293
|
${Or(e,i)}`),...a?[qt.TextEdit.replace(qt.Range.create(ne(a.firstToken.prevToken),ne(a.firstToken,!1))," ")]:[]],codeActionTitle:`Move ...${o.toString()}... to a new line`})]},qH=(t,e,n,r,i,s)=>ks(t.firstToken,t.lastToken,n,i)===!1?[]:t.values?$H(t,t.propertyName?.name.length??0,t.values,e,n,r,i,s,t.lastToken):[],$H=(t,e,n,r,i,s,o,a,c)=>{for(let[l,u]of n.values.entries()){if(!u)continue;let d=FH(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[]},Xp=t=>t instanceof bt||t instanceof fr&&t.openBracket?t.openBracket??t.firstToken:t.firstToken,FH=(t,e,n,r,i,s,o,a,c,l)=>{let u=e.nextValueSeparator??l??e.lastToken,d=ks(e.firstToken,u,s,a);if(d===!1)return;if(d===null){let b=e.value;return b instanceof bt||b instanceof fr?o0(e,t,b,i,s,o,a,c,u):b instanceof ge?Jp(e,t,b,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 b=e.value;return b instanceof bt||b instanceof fr?o0(e,t,b,i,s,o,a,c,u):b instanceof ge?Jp(e,t,b,i,s,o,a,c):void 0}let _=n.slice(r).find(b=>b?.firstToken.pos.line!==e.firstToken.pos.line);return[Ve(8,e.firstToken.fsPath,ne(e.firstToken,!1),{edit:[qt.TextEdit.replace(qt.Range.create(ne(e.firstToken.prevToken),ne(e.firstToken,!1)),`
|
|
@@ -298,14 +298,14 @@ ${Or(r,a,Ln(i,q))}`),...O?[qt.TextEdit.replace(qt.Range.create(ne(O.expression.f
|
|
|
298
298
|
`),a=Ar(e,o),c=r,l=await BH(t,o,e,n,s),u=Ir(a,t,l);switch(c=Jn(Vt.create(n,"devicetree",0,r),u.flatMap(d=>d.raw.edit).filter(d=>!!d)),i){case"New Text":return c;case"File Diagnostics":return u}}async function BH(t,e,n,r,i){let s=La(n,r);return(await Promise.all(n.flatMap(async a=>await c0(t,e,a,r,s,i)))).flat()}var c0=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 n instanceof we?jH(t,e,n,r,o,s,i):n instanceof Ne?UH(n,o,u,e,l):[]},jH=async(t,e,n,r,i,s,o)=>{let a=[];return a.push(...(await Promise.all(n.children.flatMap(c=>c0(t,e,c,r,o,s,i+1)))).flat()),a},UH=(t,e,n,r,i)=>t.firstToken.pos.line===t.lastToken.pos.line?[]:t.values?HH(t.propertyName?.name.length??0,t.values,e,n,r,i):[],HH=(t,e,n,r,i,s)=>e.values.flatMap(o=>o?VH(t,o,n,r,i,s):[]),VH=(t,e,n,r,i,s)=>{let o=e.value;return o instanceof bt?zH(e,t,o,n,r,i,s)??[]:o instanceof Wt?Qp(e,t,o,r,i,s,n):[]},Qp=(t,e,n,r,i,s,o)=>{let a=yo(t,n,r,i,o,e+4);return n.params.flatMap(c=>WH(c,r,i,s,o,a+n.functionName.name.length+1))},WH=(t,e,n,r,i,s)=>{if(!t)return[];let o=t.firstToken.value==="\\"?t.firstToken.nextToken:t.firstToken;if(!o||o.pos.line===o.prevToken?.pos.line)return[];let a=n[o?.pos.line].slice(0,o.pos.col),c=Or(i,r,Ln(e,s));if(a===c)return[];let l=ii.Position.create(o.pos.line,0),u=ii.Position.create(o.pos.line,o.pos.col),d=ii.Range.create(l,u),f=ii.TextEdit.replace(d,c);return[Ve(5,t.fsPath,l,{edit:f,codeActionTitle:"Fix indentation",templateStrings:[c.replaceAll(" ","\xB7").replaceAll(" ","\u2192")]},u)]},zH=(t,e,n,r,i,s,o)=>{for(let[a,c]of n.values.entries()){if(c.value instanceof tn){let u=new Map;return c.value.allDescendants.forEach(f=>{f instanceof ge&&!(f.parentNode instanceof Wt)&&u.set(f.firstToken,f)}),Array.from(u.values()).flatMap(f=>GH(t,e,f,i,s,o,r))}if(c.value instanceof Wt)return Qp(t,e,c.value,i,s,o,r)}return[]},GH=(t,e,n,r,i,s,o)=>{if(n.firstToken.pos.line===n.firstToken.prevToken?.pos.line)return n instanceof Wt?Qp(t,e,n,r,i,s,o):[];let a=yo(t,n,r,i,o,e+4);if(!a)return[];let c=Or(o,s,Ln(r,a));if(i[n.firstToken.pos.line].slice(0,n.firstToken.pos.col)===c)return n instanceof Wt?Qp(t,e,n,r,i,s,o):[];let u=ii.Position.create(n.firstToken.pos.line,0),d=ii.Position.create(n.firstToken.pos.line,n.firstToken.pos.col),f=ii.Range.create(u,d),p=ii.TextEdit.replace(f,c);return[Ve(5,n.fsPath,u,{edit:p,codeActionTitle:"Fix indentation",templateStrings:[c.replaceAll(" ","\xB7").replaceAll(" ","\u2192")]},d)]};var l0=L(U());async function GT(t,e,n,r,i,s){let o=r.split(`
|
|
299
299
|
`),a=Ar(e,o),c=r,l=await KH(e,s),u=Ir(a,t,l);switch(c=Jn(Vt.create(n,"devicetree",0,r),u.flatMap(d=>d.raw.edit).filter(d=>!!d)),i){case"New Text":return c;case"File Diagnostics":return u}}async function KH(t,e){return(await Promise.all(t.flatMap(n=>[n,...n.allDescendants]).flatMap(async n=>{if(e.removeEmptyReferences&&n instanceof ct&&!n.labels.length&&n.openScope?.nextToken===n.closeScope||e.removeEmptyNodes&&n instanceof Ee&&!n.labels.length&&n.openScope?.nextToken===n.closeScope||e.removeEmptyRoots&&n instanceof nt&&n.openScope?.nextToken===n.closeScope){let r=n.topComment?.firstToken??n.firstToken,i=n.endComment?.lastToken??n.lastToken;return r.prevToken?.prevToken&&(r.prevToken.prevToken.nextToken=void 0),i.nextToken&&(i.nextToken=void 0),[Ve(13,n.fsPath,ne(r,!1),{edit:l0.TextEdit.del(rn(r.prevToken,i,!r.prevToken)),codeActionTitle:"Delete node"},ne(i))]}}))).flat().filter(n=>!!n)}var KT=L(U());async function YT(t,e,n,r,i,s){let o=r.split(`
|
|
300
300
|
`),a=Ar(e,o),c=r,l=await YH(e,s),u=Ir(a,t,l);switch(c=Jn(Vt.create(n,"devicetree",0,r),u.flatMap(d=>d.raw.edit).filter(d=>!!d)),i){case"New Text":return c;case"File Diagnostics":return u}}async function YH(t,e){return(await Promise.all(t.flatMap(n=>[n,...n.allDescendants]).flatMap(async n=>{if(e.removeEmptyReferences&&n instanceof we){let r=new Map;return n.children.forEach((i,s)=>{if(i instanceof Ne){let o=i.propertyName.name,a=r.get(o);a||(a=[],r.set(o,a));let c;for(let l=s+1;l<n.children.length;l++){let u=n.children[l];if(u instanceof Ne&&u.propertyName.name===o)break;if(u instanceof at){c=u;break}}a.push({property:i,delete:c})}}),Array.from(r.values()).flatMap(i=>{if(i.length>1)return i.slice(0,-1).flatMap(s=>{let o=s.property.topComment?.firstToken??s.property.firstToken,a=s.property.endComment?.lastToken??s.property.lastToken,c=[];if(c.push(KT.TextEdit.del(rn(o.prevToken,a,!o.prevToken))),s.delete){let l=s.delete.firstToken,u=s.delete.lastToken;c.push(KT.TextEdit.del(rn(l.prevToken,u,!l.prevToken)))}return Ve(14,s.property.fsPath,ne(o,!1),{edit:c,codeActionTitle:"Delete property"},ne(a))})})}}))).flat().filter(n=>!!n)}async function Zp(t,e,n,r,i,s,o){let a=r.split(`
|
|
301
|
-
`),c=Ar(e,a),l=e.flatMap(d=>d instanceof we?f0(t,d,n,s,o,a,c):[]),u=Jn(Vt.create(n,"devicetree",0,r),Ir(c,t,l).flatMap(d=>d.raw.edit).filter(d=>!!d));if(l.flatMap(d=>d.raw.edit).filter(d=>!!d).length){let d=new Cr(n,[],void 0,()=>new Zn(u,n).tokens,!0);switch(await d.stable,i){case"New Text":return Zp(t,d.allAstItems,n,u,"New Text",d.includes,d.cPreprocessorParser.allAstItems.filter(f=>f instanceof mr||f instanceof er));case"File Diagnostics":return l}}switch(i){case"New Text":return u;case"File Diagnostics":return l}}function f0(t,e,n,r,i,s,o){if(
|
|
301
|
+
`),c=Ar(e,a),l=e.flatMap(d=>d instanceof we?f0(t,d,n,s,o,a,c):[]),u=Jn(Vt.create(n,"devicetree",0,r),Ir(c,t,l).flatMap(d=>d.raw.edit).filter(d=>!!d));if(l.flatMap(d=>d.raw.edit).filter(d=>!!d).length){let d=new Cr(n,[],void 0,()=>new Zn(u,n).tokens,!0);switch(await d.stable,i){case"New Text":return Zp(t,d.allAstItems,n,u,"New Text",d.includes,d.cPreprocessorParser.allAstItems.filter(f=>f instanceof mr||f instanceof er));case"File Diagnostics":return l}}switch(i){case"New Text":return u;case"File Diagnostics":return l}}function f0(t,e,n,r,i,s,o){if(i.some(f=>Xt(e,n,dt.create(f.firstToken.pos.line,f.firstToken.pos.col))||Xt(e,n,dt.create(f.lastToken.pos.line,f.lastToken.pos.colEnd))))return[];let a=[{prop:[],nodes:[],asFound:[]}],c=[],l=r.filter(f=>Xt(e,n,dt.create(f.firstToken.pos.line,f.firstToken.pos.col)));e.children.forEach(f=>{let p=l.filter(m=>gs(f.firstToken,n,dt.create(m.firstToken.pos.line,m.firstToken.pos.col)));p.length!==l.length&&l.length&&(a.push({prop:[],nodes:[],asFound:[]}),l=p),f instanceof Ne?(a.at(-1)?.prop.push(f),a.at(-1)?.asFound.push(f)):f instanceof Ee?(a.at(-1)?.nodes.push(f),a.at(-1)?.asFound.push(f)):f instanceof fn&&a.push({prop:[],nodes:[],asFound:[]})});let u=f=>({start:f.topComment??f,end:f.endComment??f}),d=Yp(t.options);return a.forEach(f=>{let p=[...f.prop].sort((R,q)=>XH(R,q,d.sortPropertiesAlphabetically)),m=d.sortNodesNodesBy?[...f.nodes].sort((R,q)=>d.sortNodesNodesBy==="name"?R.name?.value.localeCompare(q.name?.value??"")??0:d.sortNodesNodesBy==="address"?At(R.name?.address?.at(0)?.address??[0],q.name?.address?.at(0)?.address??[0]):0):[...f.nodes],h=[...p,...m];if(!h.length||h.every((R,q)=>!h.at(q+1)||gs(R.lastToken,n,dt.create(h.at(q+1).firstToken.pos.line,h.at(q+1).firstToken.pos.col))))return;let{start:y}=u(f.asFound[0]),_=dt.create(y.firstToken.prevToken?.pos.line??y.firstToken.pos.line,y.firstToken.prevToken?.pos.colEnd??y.firstToken.pos.col),b=h.map(R=>{let{start:q,end:O}=u(R),F=q.firstToken.prevToken?.pos.line??q.firstToken.pos.line,ke=q.firstToken.prevToken?.pos.colEnd??q.firstToken.pos.col,Ze=O.lastToken.pos.line,Ct=O.lastToken?.pos.colEnd,Pe=F===Ze,un="";if(Pe)un=s[F].slice(ke,Ct);else{let bn=s.slice(F,Ze+1);bn[0]=bn[0].slice(ke),bn[bn.length-1]=bn[bn.length-1].slice(0,Ct),un=bn.join(`
|
|
302
302
|
`)}return{delete:_i.del(Ye.create(dt.create(F,ke),dt.create(Ze,Ct))),insert:_i.insert(_,un),item:R,text:un}}),v=o.length?b.filter(R=>!ml(R.delete.range.start,o)&&!ml(R.delete.range.end,o)):b,P=e instanceof ct?e.reference:e instanceof Ee||e instanceof nt?e.name:void 0;v.length&&c.push(Ve(15,n,ne(P?.firstToken??e.firstToken,!1),{edit:b.length===v.length?[...v.map(R=>R.delete),_i.insert(_,v.map(R=>R.text).join(""))]:[],codeActionTitle:`Sort child items. Expected order: ${h.map(R=>R instanceof Ne?`${R.propertyName.name}`:`${R.path?.at(-1)} { ... };`).join(", ")}`},ne(P?.lastToken??e.openScope??e.firstToken)))}),c.length?c:e.children.flatMap(f=>f instanceof we?f0(t,f,n,r,i,s,o):[])}var u0={compatible:0,reg:1,ranges:2,status:99};function d0(t){return u0.hasOwnProperty(t)?u0[t]:t.includes(",")?4:3}function XH(t,e,n){let r=d0(t.propertyName?.name??""),i=d0(e.propertyName?.name??"");return r!==i?r-i:n?t.propertyName.name.localeCompare(e.propertyName.name):0}var p0=(t,e,n)=>!!t.split(`
|
|
303
|
-
`).find(r=>r.replace(/^\s+/,i=>i.replace(/\t/g," ".repeat(e))).trimEnd().length>n);async function Ps(t,e,n,r,i=[],s=[]){let o=Se(t.textDocument.uri);r??=new Zn(e,o).tokens;let a=[...r],c=new Cr(o,[],void 0,()=>r,!0);await c.stable;let l=c.issues.filter(m=>uo(m.raw,o,!1));if(l?.length)throw new ee.ResponseError(ee.ErrorCodes.InternalError,"Unable to format. File has syntax issues.",l.map(m=>m.diagnostic()));let u=typeof t.options.wordWrapColumn=="number"?t.options.wordWrapColumn:100,d=await JH({...t,options:{...t.options,wordWrapColumn:u}},c,i,s,a,e),f=Yp(t.options);if(f.removeMacroMultiline){let m=new Set;Array.from(c.cPreprocessorParser.macros.values()).filter(h=>h.macro.firstToken.pos.line!==h.macro.lastToken.pos.line).forEach(h=>{Array.from({length:h.macro.lastToken.pos.line-h.macro.firstToken.pos.line+1},(y,_)=>h.macro.firstToken.pos.line+_).forEach(y=>m.add(y))}),await QH(o,e,m,d)}if(n==="New Text"){let m=e;if(f.removeDuplicateProperties){let h="";do{h=m;let y=await xa(o,e,h)??c.allAstItems;m=await YT({...t,options:{...t.options,wordWrapColumn:u}},y,o,m,n,f)}while(m!==h)}if(f.sortNodesAndProperties){let h="";do{h=m;let y=await VT(o,e,h)??c;m=await Zp({...t,options:{...t.options,wordWrapColumn:u}},y.allAstItems,o,m,n,y.includes,i)}while(m!==h)}if(f.removeEmptyReferences||f.removeEmptyRoots||f.removeEmptyNodes){let h="";do{h=m;let y=await xa(o,e,h)??c.allAstItems;m=await GT({...t,options:{...t.options,wordWrapColumn:u}},y,o,m,n,f)}while(m!==h)}if(f.baseFormattingRules){let h=await xa(o,e,m)??c.allAstItems,y=await h0({...t,options:{...t.options,wordWrapColumn:u}},h,c.includes,i,o,m,n,f,d);d=[],m=y}if(f.indentExpressions){let h=await xa(o,e,m)??c.allAstItems;m=await zT({...t,options:{...t.options,wordWrapColumn:u}},h,o,m,n,f)}if(f.wrapLongLines&&p0(m,t.options.tabSize,u)){let h="";do{h=m;let y=await xa(o,e,h)??c.allAstItems;m=await WT({...t,options:{...t.options,wordWrapColumn:u}},y,o,h,"New Text",f,[...d])}while(h!==m)}return m}let p=[];if(f.removeDuplicateProperties){let m=await YT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f);p.push(...m)}if(f.sortNodesAndProperties){let m=await Zp({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,c.includes,i);p.push(...m)}if(f.removeEmptyReferences||f.removeEmptyRoots||f.removeEmptyNodes){let m=await GT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f);p.push(...m)}if(f.baseFormattingRules){let m=await h0({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,c.includes,i,o,e,n,f,[...d]);p.push(...m)}if(f.indentExpressions){let m=await zT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f);p.push(...m)}return f.wrapLongLines&&p0(e,t.options.tabSize,u)&&p.push(...await WT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f,[...d])),p}var JH=async(t,e,n,r,i,s)=>{let o=e.cPreprocessorParser.allAstItems.filter(p=>p instanceof mr),a=e.cPreprocessorParser.allAstItems.filter(p=>p instanceof er),c=o.filter(p=>n.every(m=>p.firstToken.pos.line!==m.firstToken.pos.line)),l=a.filter(p=>n.every(m=>p.firstToken.pos.line!==m.firstToken.pos.line));n.push(...c),n.push(...l);let u=[...o.map(p=>p.ifDef.active?p.elseOption?{block:p,branch:p.elseOption}:void 0:{block:p,branch:p.ifDef}),...a.flatMap(p=>{let m=p.ifBlocks.find(y=>y.active),h=p.ifBlocks.filter(y=>!y.active).map(y=>({block:p,branch:y}));return!m&&p.elseOption&&h.push({block:p,branch:p.elseOption}),h})].filter(p=>!!p),d=p=>{let m=p.block.getInValidTokenRangeWhenActiveBlock(p.branch),h=i.filter(_=>!m.has(_)),y=p.block.range;return r.push(p.branch),Ps({...t,range:y,options:{...t.options,sortNodesAndProperties:!1}},s,"File Diagnostics",h,n,r)},f=[];return await u.filter(p=>r.every(m=>m.firstToken.pos.line!==p.block.firstToken.pos.line)).reduce((p,m)=>p.then(async()=>{f.push(...await d(m))}),Promise.resolve()),f};async function QH(t,e,n,r=[]){e.split(`
|
|
303
|
+
`).find(r=>r.replace(/^\s+/,i=>i.replace(/\t/g," ".repeat(e))).trimEnd().length>n);async function Ps(t,e,n,r,i=[],s=[]){let o=Se(t.textDocument.uri);r??=new Zn(e,o).tokens;let a=[...r],c=new Cr(o,[],void 0,()=>r,!0);await c.stable,t.options.tabSize??=8,t.options.insertSpaces??=!1;let l=c.issues.filter(m=>uo(m.raw,o,!1));if(l?.length)throw new ee.ResponseError(ee.ErrorCodes.InternalError,"Unable to format. File has syntax issues.",l.map(m=>m.diagnostic()));let u=typeof t.options.wordWrapColumn=="number"?t.options.wordWrapColumn:100,d=await JH({...t,options:{...t.options,wordWrapColumn:u}},c,i,s,a,e),f=Yp(t.options);if(f.removeMacroMultiline){let m=new Set;Array.from(c.cPreprocessorParser.macros.values()).filter(h=>h.macro.firstToken.pos.line!==h.macro.lastToken.pos.line).forEach(h=>{Array.from({length:h.macro.lastToken.pos.line-h.macro.firstToken.pos.line+1},(y,_)=>h.macro.firstToken.pos.line+_).forEach(y=>m.add(y))}),await QH(o,e,m,d)}if(n==="New Text"){let m=e;if(f.removeDuplicateProperties){let h="";do{h=m;let y=await xa(o,e,h)??c.allAstItems;m=await YT({...t,options:{...t.options,wordWrapColumn:u}},y,o,m,n,f)}while(m!==h)}if(f.sortNodesAndProperties){let h="";do{h=m;let y=await VT(o,e,h)??c;m=await Zp({...t,options:{...t.options,wordWrapColumn:u}},y.allAstItems,o,m,n,y.includes,i)}while(m!==h)}if(f.removeEmptyReferences||f.removeEmptyRoots||f.removeEmptyNodes){let h="";do{h=m;let y=await xa(o,e,h)??c.allAstItems;m=await GT({...t,options:{...t.options,wordWrapColumn:u}},y,o,m,n,f)}while(m!==h)}if(f.baseFormattingRules){let h=await xa(o,e,m)??c.allAstItems,y=await h0({...t,options:{...t.options,wordWrapColumn:u}},h,c.includes,i,o,m,n,f,d);d=[],m=y}if(f.indentExpressions){let h=await xa(o,e,m)??c.allAstItems;m=await zT({...t,options:{...t.options,wordWrapColumn:u}},h,o,m,n,f)}if(f.wrapLongLines&&p0(m,t.options.tabSize,u)){let h="";do{h=m;let y=await xa(o,e,h)??c.allAstItems;m=await WT({...t,options:{...t.options,wordWrapColumn:u}},y,o,h,"New Text",f,[...d])}while(h!==m)}return m}let p=[];if(f.removeDuplicateProperties){let m=await YT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f);p.push(...m)}if(f.sortNodesAndProperties){let m=await Zp({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,c.includes,i);p.push(...m)}if(f.removeEmptyReferences||f.removeEmptyRoots||f.removeEmptyNodes){let m=await GT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f);p.push(...m)}if(f.baseFormattingRules){let m=await h0({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,c.includes,i,o,e,n,f,[...d]);p.push(...m)}if(f.indentExpressions){let m=await zT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f);p.push(...m)}return f.wrapLongLines&&p0(e,t.options.tabSize,u)&&p.push(...await WT({...t,options:{...t.options,wordWrapColumn:u}},c.allAstItems,o,e,n,f,[...d])),p}var JH=async(t,e,n,r,i,s)=>{let o=e.cPreprocessorParser.allAstItems.filter(p=>p instanceof mr),a=e.cPreprocessorParser.allAstItems.filter(p=>p instanceof er),c=o.filter(p=>n.every(m=>p.firstToken.pos.line!==m.firstToken.pos.line)),l=a.filter(p=>n.every(m=>p.firstToken.pos.line!==m.firstToken.pos.line));n.push(...c),n.push(...l);let u=[...o.map(p=>p.ifDef.active?p.elseOption?{block:p,branch:p.elseOption}:void 0:{block:p,branch:p.ifDef}),...a.flatMap(p=>{let m=p.ifBlocks.find(y=>y.active),h=p.ifBlocks.filter(y=>!y.active).map(y=>({block:p,branch:y}));return!m&&p.elseOption&&h.push({block:p,branch:p.elseOption}),h})].filter(p=>!!p),d=p=>{let m=p.block.getInValidTokenRangeWhenActiveBlock(p.branch),h=i.filter(_=>!m.has(_)),y=p.block.range;return r.push(p.branch),Ps({...t,range:y,options:{...t.options,sortNodesAndProperties:!1}},s,"File Diagnostics",h,n,r)},f=[];return await u.filter(p=>r.every(m=>m.firstToken.pos.line!==p.block.firstToken.pos.line)).reduce((p,m)=>p.then(async()=>{f.push(...await d(m))}),Promise.resolve()),f};async function QH(t,e,n,r=[]){e.split(`
|
|
304
304
|
`).forEach((s,o)=>{if(s.trimEnd().endsWith("\\")&&!n.has(o)){let a=s.slice(0,s.lastIndexOf("\\")-1).trimEnd(),c=ee.Range.create(ee.Position.create(o,a.length),ee.Position.create(o,s.length));r.push(Ve(12,t,c.start,{edit:ee.TextEdit.del(c),codeActionTitle:"Remove \\"},c.end))}})}async function h0(t,e,n,r,i,s,o,a,c=[]){let l=s.split(`
|
|
305
305
|
`),u=Ar(e,l),d=s;c.push(...await ZH(t,e,n,r,i,l,a));let f=Ir(u,t,c);switch(d=Jn(Vt.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}}async function ZH(t,e,n,r,i,s,o){let a=La(e,i),c=(await Promise.all(e.flatMap(async u=>await T0(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),`
|
|
306
306
|
`);c.push(Ve(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(Ve(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=eV(s,l,i);c.push(...u)}return c}var eV=(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=>yE(c,l.range))||r.push(Ve(2,n,c.start,{edit:ee.TextEdit.del(c),codeActionTitle:"Remove whitespace"},c.end))}}),r},th=(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),`
|
|
307
307
|
`.repeat(e));return Ve(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 Ve(1,t.fsPath,i,{edit:o,codeActionTitle:"Remove unnecessary new lines",templateStrings:["0"]},s)}},m0=(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),`${`
|
|
308
|
-
`.repeat(i)}${"".padStart(e*n.length,n)}${r}`);return Ve(0,t.fsPath,o,{edit:c,codeActionTitle:"Move to new line"},a)}},XT=(t,e,n,r,i="")=>{let s=Or(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=hV(r,c);if(s===l)return[];let u=ee.TextEdit.replace(c,s);return[Ve(5,t.fsPath,o,{edit:u,codeActionTitle:"Fix indentation",templateStrings:[s.replaceAll(" ","\xB7").replaceAll(" ","\u2192")]},a)]},Et=(t,e,n=1,r=!1)=>{if(!t.nextToken)return[];if(t.nextToken?.pos.line!==t.pos.line){if(r)return[];let c=th(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[Ve(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[Ve(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[Ve(1,t.fsPath,s,{edit:a,codeActionTitle:i>n?"Remove space(s)":"Insert space(s)",templateStrings:[n.toString()]},o)]},gl=(t,e,n,r,i)=>t.slice(1).flatMap(s=>i&&s.firstToken.prevToken||s.firstToken.pos.line===s.firstToken.prevToken?.pos.line?Et(s.firstToken.prevToken,e):qn(s.firstToken,n,r,e,void 0,1,!0)),tV=async(t,e,n,r,i,s,o,a,c,l)=>{let u=[],d=e.topComment||e.firstToken.prevToken?.value==="{"&&!e.topComment?1:JT(e.firstToken,r);if(u.push(...qn(e.firstToken,s,o,c,void 0,d,!0)),e instanceof Ee||e instanceof ct)if(u.push(...gl(e.labels,c,s,o,!1)),e instanceof Ee){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(Ve(_,p.fsPath,ne(p.firstToken,!1),{edit:ee.TextEdit.replace(ce(p),y),codeActionTitle:`Change to '${y}'`},ne(p.lastToken)))}),e.labels.length&&e.name&&(e.name.firstToken.pos.line!==e.name.firstToken.prevToken?.pos.line?u.push(...qn(e.name.firstToken,s,o,c,void 0,1,!0)):u.push(...Et(e.name.firstToken.prevToken,c)));let f=e.name&&e.openScope?Et(e.name.lastToken,c):[];u.push(...f)}else{e.labels.length&&e.reference?.firstToken.prevToken&&u.push(...Et(e.reference.firstToken.prevToken,c));let f=e.reference&&e.openScope?Et(e.reference.lastToken,c):[];u.push(...f)}else e instanceof nt&&e.firstToken.value==="/"&&e.openScope&&u.push(...Et(e.firstToken,c,1));return u.push(...(await Promise.all(e.children.flatMap(f=>T0(t,f,i,l,c,n,r,a,s+1)))).flat()),e.closeScope&&(e.openScope&&e.closeScope.prevToken===e.openScope?u.push(...Et(e.openScope,c,0)):u.push(...qn(e.closeScope,s,o,c,void 0,1,!0))),e.lastToken.value===";"&&e.closeScope&&u.push(...nh(e.closeScope,e.lastToken)),u},nV=(t,e,n,r,i,s,o)=>{let a=[];if(a.push(...gl(e.labels,o,n,r.singleIndent,!0)),e.labels.length&&e.value?.firstToken.prevToken&&a.push(...Et(e.value.firstToken.prevToken,o)),e.value instanceof nn){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(Ve(9,e.value.fsPath,ne(e.value.firstToken,!1),{edit:ee.TextEdit.replace(ce(e.value),l),codeActionTitle:`Change to '${l}'`},ne(e.value.lastToken)))}if(e.firstToken.prevToken)if(e.firstToken.pos.line!==e.firstToken.prevToken?.pos.line&&e.firstToken.prevToken!==s){let c=th(e.firstToken,1,!0);c&&a.push(c),a.push(...XT(e.firstToken,n,r.singleIndent,o,Ln(r,t+4)))}else a.push(...Et(e.firstToken.prevToken,o,s&&e.firstToken.prevToken===s?0:1));return e.value instanceof ge&&a.push(...eh(e.value,o,n,r,i,t+4)),a},rV=(t,e,n,r,i,s)=>{let o=[];return e instanceof bt||e instanceof fr?e.openBracket&&e.openBracket?.nextToken===e.closeBracket?o.push(...Et(e.openBracket,s,0)):(o.push(...e.values.flatMap(a=>nV(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(...Et(e.closeBracket.prevToken,s,0)):o.push(...qn(e.closeBracket,n,r.singleIndent,s,Ln(r,t+3),1,!0)))):e instanceof ge&&o.push(...eh(e,s,n,r,i,t)),o},eh=(t,e,n,r,i,s)=>t instanceof Wt?iV(t,e):t instanceof tn?sV(t,e,n,r,i,s):[],iV=(t,e)=>{let n=[];return n.push(...Et(t.functionName.lastToken,e,0)),t.lastToken.value===")"&&t.lastToken.prevToken&&n.push(...Et(t.lastToken.prevToken,e,0)),n},sV=(t,e,n,r,i,s)=>{let o=[];if(t.openBracket&&t.openBracket.nextToken&&o.push(...Et(t.openBracket,e,0)),o.push(...eh(t.expression,e,n,r,i,s)),t.join?.forEach(a=>{a.operator.firstToken.prevToken&&o.push(...Et(a.operator.firstToken.prevToken,e)),a.expression.firstToken.prevToken?.pos.line===a.expression.firstToken.pos.line?o.push(...Et(a.expression.firstToken.prevToken,e)):o.push(...qn(a.expression.firstToken,n,r.singleIndent,e,Ln(r,s),void 0,void 0,!i.indentExpressions)),o.push(...eh(a.expression,e,n,r,i,s))}),!t.join?.length&&!(t.expression instanceof tn)&&(t.expression instanceof Wt||t.expression instanceof yt)){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(Ve(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(...Et(t.closeBracket.prevToken,e,0)),o},oV=(t,e,n,r,i,s)=>{let o=[];return o.push(...gl(e.startLabels,s,n,r.singleIndent,!0)),o.push(...rV(t,e.value,n,r,i,s)),o.push(...gl(e.endLabels,s,n,r.singleIndent,!0)),o},aV=(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=m0(c.firstToken,n,r.singleIndent,Ln(r,t+3));f&&a.push(f)}else a.push(...Et(u,s,1));else if(o&&c.firstToken.prevToken===o)a.push(...Et(o,s));else{let f=th(c.firstToken,1,!0);f&&a.push(f),a.push(...XT(c.firstToken,n,r.singleIndent,s,Ln(r,t+3)))}a.push(...oV(t,c,n,r,i,s)),c.nextValueSeparator&&a.push(...nh(c.lastToken,c.nextValueSeparator))}),a},cV=(t,e,n,r,i)=>{let s=[],{force:o,newLines:a}=y0(t,t.firstToken);return s.push(...qn(t.firstToken,e,n.singleIndent,i,void 0,a,o)),s.push(...gl(t.labels,i,e,n.singleIndent,!0)),t.labels.length&&t.propertyName?.firstToken.prevToken&&s.push(...Et(t.propertyName.firstToken.prevToken,i)),t.values&&(t.propertyName&&s.push(...Et(t.propertyName?.lastToken,i)),s.push(...aV(t.propertyName?.name.length??0,t.values,e,n,r,i,t.assignOperatorToken))),t.lastToken.value===";"&&s.push(...nh(t.children[t.children.length-1].lastToken,t.lastToken)),s},qn=(t,e,n,r,i,s,o,a=!0)=>{let c=[],l=m0(t,e,n,i,s);if(l)c.push(l);else{let u=th(t,s,o);u&&c.push(u),a&&c.push(...XT(t,e,n,r,i))}return c},nh=(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[Ve(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[Ve(6,t.fsPath,n,{edit:i,codeActionTitle:"Move token",templateStrings:[e.value]},r)]},lV=(t,e,n,r)=>{let i=[];i.push(...qn(t.firstToken,e,n,r));let s=Et(t.keyword.lastToken,r);return i.push(...s),t.lastToken.value===";"&&i.push(...nh(t.children[t.children.length-1].lastToken,t.lastToken)),i},uV=(t,e,n,r)=>{if(!fe(t.fsPath,e))return[];let i=[];i.push(...qn(t.firstToken,0,n,r));let s=Et(t.keyword.lastToken,r);return i.push(...s),i},dV=(t,e,n,r,i,s)=>t.comments.length===1&&t.firstToken.pos.line===t.firstToken.prevToken?.pos.line?[]:t.comments.flatMap((o,a)=>fV(o,t,e,n,r,i,a?a===t.comments.length-1?"last":"comment":"first",s)),g0=(t,e,n="")=>{let r=e?TT(e):void 0;if(!r)return n;let i=po(e),s=r.propertyName?.name.length??0;return`${`${Ln(t,s+(i?4:3)+(n.length-n.trimStart().length))}`}${n.trimStart()}`},JT=(t,e)=>{let n=e.flatMap(r=>r instanceof mr?[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},y0=(t,e)=>{let n=t.parentNode instanceof we?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 we&&t.firstToken.prevToken===(i.endComment??i).lastToken?{newLines:2,force:!0}:{newLines:void 0,force:void 0}},fV=(t,e,n,r,i,s,o,a)=>{if(!t.firstToken.prevToken)return qn(t.firstToken,r?.level??0,i,s);if(t.firstToken.pos.line===t.firstToken.prevToken?.pos.line)return Et(t.firstToken.prevToken,s,1);if(r===void 0)return[];let c,l;if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof we)c=!0,l=JT(e.firstToken,n);else if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof Ne){let{force:m,newLines:h}=y0(e.astAfterComment,e.firstToken);c=m,l=h}let u=e.astAfterComment instanceof Er?0:r.level,d=[],f="",p=t.toString();switch(o==="last"&&p.trim()!==""&&t.lastToken.prevToken&&(o="comment",d.push(...qn(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 we?d.push(...qn(t.firstToken,u,i,s,f,l,c)):d.push(...qn(t.firstToken,u,i,s,g0(a,r?.inAst,f),l,c)),d},pV=(t,e,n,r,i,s)=>{if(!t.firstToken.prevToken)return qn(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 we&&(a=!0,c=JT(t.firstToken,e)),qn(t.firstToken,n?.level??0,r,i,g0(s,n?.inAst),c,a)},T0=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 we?tV(t,e,s,o,n,c,d,a,i,r):e instanceof Ne?cV(e,c,f,a,i):e instanceof fn?lV(e,c,d,i):e instanceof Er?uV(e,n,d,i):e instanceof hr&&!e.disabled?pV(e,o,await r(e),d,i,f):e instanceof pr&&!e.disabled?dV(e,o,await r(e),d,i,f):[]};function hV(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(`
|
|
308
|
+
`.repeat(i)}${"".padStart(e*n.length,n)}${r}`);return Ve(0,t.fsPath,o,{edit:c,codeActionTitle:"Move to new line"},a)}},XT=(t,e,n,r,i="")=>{let s=Or(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=hV(r,c);if(s===l)return[];let u=ee.TextEdit.replace(c,s);return[Ve(5,t.fsPath,o,{edit:u,codeActionTitle:"Fix indentation",templateStrings:[s.replaceAll(" ","\xB7").replaceAll(" ","\u2192")]},a)]},Et=(t,e,n=1,r=!1)=>{if(!t.nextToken)return[];if(t.nextToken?.pos.line!==t.pos.line){if(r)return[];let c=th(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[Ve(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[Ve(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[Ve(1,t.fsPath,s,{edit:a,codeActionTitle:i>n?"Remove space(s)":"Insert space(s)",templateStrings:[n.toString()]},o)]},gl=(t,e,n,r,i)=>t.slice(1).flatMap(s=>i&&s.firstToken.prevToken||s.firstToken.pos.line===s.firstToken.prevToken?.pos.line?Et(s.firstToken.prevToken,e):qn(s.firstToken,n,r,e,void 0,1,!0)),tV=async(t,e,n,r,i,s,o,a,c,l)=>{let u=[],d=e.topComment||e.firstToken.prevToken?.value==="{"&&!e.topComment?1:JT(e.firstToken,r);if(u.push(...qn(e.firstToken,s,o,c,void 0,d,!0)),e instanceof Ee||e instanceof ct)if(u.push(...gl(e.labels,c,s,o,!1)),e instanceof Ee){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(Ve(_,p.fsPath,ne(p.firstToken,!1),{edit:ee.TextEdit.replace(ce(p),y),codeActionTitle:`Change to '${y}'`},ne(p.lastToken)))}),e.labels.length&&e.name&&(e.name.firstToken.pos.line!==e.name.firstToken.prevToken?.pos.line?u.push(...qn(e.name.firstToken,s,o,c,void 0,1,!0)):u.push(...Et(e.name.firstToken.prevToken,c)));let f=e.name&&e.openScope?Et(e.name.lastToken,c):[];u.push(...f)}else{e.labels.length&&e.reference?.firstToken.prevToken&&u.push(...Et(e.reference.firstToken.prevToken,c));let f=e.reference&&e.openScope?Et(e.reference.lastToken,c):[];u.push(...f)}else e instanceof nt&&e.firstToken.value==="/"&&e.openScope&&u.push(...Et(e.firstToken,c,1));return u.push(...(await Promise.all(e.children.flatMap(f=>T0(t,f,i,l,c,n,r,a,s+1)))).flat()),e.closeScope&&(e.openScope&&e.closeScope.prevToken===e.openScope?u.push(...Et(e.openScope,c,0)):u.push(...qn(e.closeScope,s,o,c,void 0,1,!0))),e.lastToken.value===";"&&e.closeScope&&u.push(...nh(e.closeScope,e.lastToken)),u},nV=(t,e,n,r,i,s,o)=>{let a=[];if(a.push(...gl(e.labels,o,n,r.singleIndent,!0)),e.labels.length&&e.value?.firstToken.prevToken&&a.push(...Et(e.value.firstToken.prevToken,o)),e.value instanceof nn){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(Ve(9,e.value.fsPath,ne(e.value.firstToken,!1),{edit:ee.TextEdit.replace(ce(e.value),l),codeActionTitle:`Change to '${l}'`},ne(e.value.lastToken)))}if(e.firstToken.prevToken)if(e.firstToken.pos.line!==e.firstToken.prevToken?.pos.line&&e.firstToken.prevToken!==s){let c=th(e.firstToken,1,!0);c&&a.push(c),a.push(...XT(e.firstToken,n,r.singleIndent,o,Ln(r,t+4)))}else a.push(...Et(e.firstToken.prevToken,o,s&&e.firstToken.prevToken===s?0:1));return e.value instanceof ge&&a.push(...eh(e.value,o,n,r,i,t+4)),a},rV=(t,e,n,r,i,s)=>{let o=[];return e instanceof bt||e instanceof fr?e.openBracket&&e.openBracket?.nextToken===e.closeBracket?o.push(...Et(e.openBracket,s,0)):(o.push(...e.values.flatMap(a=>nV(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(...Et(e.closeBracket.prevToken,s,0)):o.push(...qn(e.closeBracket,n,r.singleIndent,s,Ln(r,t+3),1,!0)))):e instanceof ge&&o.push(...eh(e,s,n,r,i,t)),o},eh=(t,e,n,r,i,s)=>t instanceof Wt?iV(t,e):t instanceof tn?sV(t,e,n,r,i,s):[],iV=(t,e)=>{let n=[];return n.push(...Et(t.functionName.lastToken,e,0)),t.lastToken.value===")"&&t.lastToken.prevToken&&n.push(...Et(t.lastToken.prevToken,e,0)),n},sV=(t,e,n,r,i,s)=>{let o=[];if(t.openBracket&&t.openBracket.nextToken&&o.push(...Et(t.openBracket,e,0)),o.push(...eh(t.expression,e,n,r,i,s)),t.join?.forEach(a=>{a.operator.firstToken.prevToken&&o.push(...Et(a.operator.firstToken.prevToken,e)),a.expression.firstToken.prevToken?.pos.line===a.expression.firstToken.pos.line?o.push(...Et(a.expression.firstToken.prevToken,e)):o.push(...qn(a.expression.firstToken,n,r.singleIndent,e,Ln(r,s),void 0,void 0,!i.indentExpressions)),o.push(...eh(a.expression,e,n,r,i,s))}),!t.join?.length&&!(t.expression instanceof tn)&&(t.expression instanceof Wt||t.expression instanceof yt)){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(Ve(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(...Et(t.closeBracket.prevToken,e,0)),o},oV=(t,e,n,r,i,s)=>{let o=[];return o.push(...gl(e.startLabels,s,n,r.singleIndent,!0)),o.push(...rV(t,e.value,n,r,i,s)),o.push(...gl(e.endLabels,s,n,r.singleIndent,!0)),o},aV=(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=m0(c.firstToken,n,r.singleIndent,Ln(r,t+3));f&&a.push(f)}else a.push(...Et(u,s,1));else if(o&&c.firstToken.prevToken===o)a.push(...Et(o,s));else{let f=th(c.firstToken,1,!0);f&&a.push(f),a.push(...XT(c.firstToken,n,r.singleIndent,s,Ln(r,t+3)))}a.push(...oV(t,c,n,r,i,s)),c.nextValueSeparator&&a.push(...nh(c.lastToken,c.nextValueSeparator))}),a},cV=(t,e,n,r,i)=>{let s=[],{force:o,newLines:a}=y0(t,t.firstToken);return s.push(...qn(t.firstToken,e,n.singleIndent,i,void 0,a,o)),s.push(...gl(t.labels,i,e,n.singleIndent,!0)),t.labels.length&&t.propertyName?.firstToken.prevToken&&s.push(...Et(t.propertyName.firstToken.prevToken,i)),t.values&&(t.propertyName&&s.push(...Et(t.propertyName?.lastToken,i)),s.push(...aV(t.propertyName?.name.length??0,t.values,e,n,r,i,t.assignOperatorToken))),t.lastToken.value===";"&&s.push(...nh(t.children[t.children.length-1].lastToken,t.lastToken)),s},qn=(t,e,n,r,i,s,o,a=!0)=>{let c=[],l=m0(t,e,n,i,s);if(l)c.push(l);else{let u=th(t,s,o);u&&c.push(u),a&&c.push(...XT(t,e,n,r,i))}return c},nh=(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[Ve(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[Ve(6,t.fsPath,n,{edit:i,codeActionTitle:"Move token",templateStrings:[e.value]},r)]},lV=(t,e,n,r)=>{let i=[];i.push(...qn(t.firstToken,e,n,r));let s=Et(t.keyword.lastToken,r);return i.push(...s),t.lastToken.value===";"&&i.push(...nh(t.children[t.children.length-1].lastToken,t.lastToken)),i},uV=(t,e,n,r)=>{if(!pe(t.fsPath,e))return[];let i=[];i.push(...qn(t.firstToken,0,n,r));let s=Et(t.keyword.lastToken,r);return i.push(...s),i},dV=(t,e,n,r,i,s)=>t.comments.length===1&&t.firstToken.pos.line===t.firstToken.prevToken?.pos.line?[]:t.comments.flatMap((o,a)=>fV(o,t,e,n,r,i,a?a===t.comments.length-1?"last":"comment":"first",s)),g0=(t,e,n="")=>{let r=e?TT(e):void 0;if(!r)return n;let i=po(e),s=r.propertyName?.name.length??0;return`${`${Ln(t,s+(i?4:3)+(n.length-n.trimStart().length))}`}${n.trimStart()}`},JT=(t,e)=>{let n=e.flatMap(r=>r instanceof mr?[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},y0=(t,e)=>{let n=t.parentNode instanceof we?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 we&&t.firstToken.prevToken===(i.endComment??i).lastToken?{newLines:2,force:!0}:{newLines:void 0,force:void 0}},fV=(t,e,n,r,i,s,o,a)=>{if(!t.firstToken.prevToken)return qn(t.firstToken,r?.level??0,i,s);if(t.firstToken.pos.line===t.firstToken.prevToken?.pos.line)return Et(t.firstToken.prevToken,s,1);if(r===void 0)return[];let c,l;if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof we)c=!0,l=JT(e.firstToken,n);else if(o==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof Ne){let{force:m,newLines:h}=y0(e.astAfterComment,e.firstToken);c=m,l=h}let u=e.astAfterComment instanceof Er?0:r.level,d=[],f="",p=t.toString();switch(o==="last"&&p.trim()!==""&&t.lastToken.prevToken&&(o="comment",d.push(...qn(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 we?d.push(...qn(t.firstToken,u,i,s,f,l,c)):d.push(...qn(t.firstToken,u,i,s,g0(a,r?.inAst,f),l,c)),d},pV=(t,e,n,r,i,s)=>{if(!t.firstToken.prevToken)return qn(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 we&&(a=!0,c=JT(t.firstToken,e)),qn(t.firstToken,n?.level??0,r,i,g0(s,n?.inAst),c,a)},T0=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 we?tV(t,e,s,o,n,c,d,a,i,r):e instanceof Ne?cV(e,c,f,a,i):e instanceof fn?lV(e,c,d,i):e instanceof Er?uV(e,n,d,i):e instanceof hr&&!e.disabled?pV(e,o,await r(e),d,i,f):e instanceof pr&&!e.disabled?dV(e,o,await r(e),d,i,f):[]};function hV(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(`
|
|
309
309
|
`)}var v0=L(U());var rh=t=>!t||t instanceof Ne?!1:t instanceof Mn||rh(t.parentNode);function mV(t){if(!t||!(t.item instanceof Qe&&t.item.ast.assignOperatorToken))return[];let e=rh(t?.ast);if(!e&&!(t.ast instanceof Ne&&t.item.ast.values===null)&&!rh(t.beforeAst)&&!rh(t.afterAst))return[];let n=-1;if(t.item.ast.values===null?n=0:n=(t.item.ast.values?.values.findIndex(i=>i&&vT(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 o?.some(c=>c)&&s instanceof St&&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:v0.CompletionItemKind.Variable,insertText:e?c:`"${c}"`})))}let r=t.item.parent.nodeType;return r instanceof St?r.properties.find(i=>i.name===t.item?.name)?.getPropertyCompletionItems(t.item,n,e)??[]:[]}function gV(t){if(!t||!(t.item instanceof Qe&&t.ast instanceof Je&&t.item.ast.values==null||t.item instanceof X)||Jt(t.ast)||t.beforeAst?.parentNode instanceof fn)return[];let e=n=>n.nodeType?.getPropertyListCompletionItems(n)??[];return t.item instanceof Qe?e(t.item.parent):e(t.item)}async function b0(t,e){return wt(t,e,n=>[...mV(n),...gV(n)])}var ih=L(U());async function yV(t){if(t?.ast instanceof yt||t?.ast instanceof bi){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t?.ast instanceof yt?t.ast.name:t.ast.value);if(e){let n=zc(t.ast),r=(await t.runtime.context.getAllStableParsers()).at(-1);if(n){let i=n?.evaluate(r.cPreprocessorParser.macros);return{contents:{kind:ih.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${i}${typeof i=="number"?` (0x${i.toString(16)})`:""}`,"```"].join(`
|
|
310
310
|
`)},range:ce(t.ast)}}return{contents:{kind:ih.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${t.ast?.evaluate(r.cPreprocessorParser.macros)}`,"```"].join(`
|
|
311
311
|
`)},range:ce(t.ast)}}}}async function TV(t){if(!t)return;let e=(await t.runtime.context.getAllStableParsers()).at(-1);if(t?.ast instanceof $e){let n=t.ast.linksTo;if(n)return{contents:n.toMarkupContent(e.cPreprocessorParser.macros),range:ce(t.ast)}}if(t?.ast.parentNode instanceof se){let n=t.ast.parentNode.linksTo;if(n)return{contents:n.toMarkupContent(e.cPreprocessorParser.macros),range:ce(t.ast)}}if(t?.ast instanceof ie&&t.item instanceof Qe&&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 vV(t){if(t?.item instanceof Qe&&t.ast instanceof Je){let e=t.item.onHover(),n=t.item.parent.nodeType?.getOnPropertyHover(t.item.name);if(e||n)return{contents:{kind:ih.MarkupKind.Markdown,value:`${e?.value??""}
|
|
@@ -325,8 +325,8 @@ ${r}`]})]:[]}else if(e.keyword==="maxItems"||e.keyword==="minItems"){let a=s.get
|
|
|
325
325
|
${JSON.stringify(e)}
|
|
326
326
|
${r}`]})];let o=i.node.implementations[0]instanceof nt?i.node.implementations[0]:i.node.implementations[0].identifierAst??i.node.implementations[0];return[j(25,o.firstToken,o.lastToken,o,{templateStrings:[`${e.message??"NO MESSAGE"}:
|
|
327
327
|
${JSON.stringify(e)}
|
|
328
|
-
${r}`]})]},J6=(t,e)=>RF(t,e.split("/").filter(n=>n)),RF=(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?RF(s,e.slice(1)):{node:t,property:t.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var ik=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 ie)))return r?.values.map(i=>(i?.value).value)}parseMetaSchema(e,n){_o.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,tk.resolve)(e,i);try{let s=rk.default.parse((0,nk.readFileSync)(i,"utf-8"));n.addMetaSchema(s),this.schemaIdValidators.set(s.$id,i)}catch{}})}parseBindings(e,n){_o.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,tk.resolve)(e,i);try{let s=rk.default.parse((0,nk.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 EF.default({strict:!1,strictSchema:!1,strictNumbers:!1}),s.addMetaSchema(ek),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 ng(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())}},wF,sk=()=>(wF??=new ik,wF);var zs=L(require("path")),xF=require("fs"),LF=L(require("path")),qF=L(t_());var Hr=L(U());var CF=()=>{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 DF(){let t=Rn();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(CF()),t}var AF=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")}},IF=(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}},rg=(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,zs.basename)(s.filePath)===r.name);if(i){let s=r["property-blocklist"],o=r["property-allowlist"];e.extends?.push(...n.include.map(c=>(0,zs.basename)(c.name,".yaml")));let a=r["child-binding"];return n.include=n.include.filter(c=>c!==r),$F(t,i,n,s,o,a)??n}return console.warn(`Unable to find ${r.name}`),n},e),e["child-binding"]&&(e["child-binding"].include=FF(e["child-binding"].include),e["child-binding"]=rg(t,e["child-binding"]),e["child-binding"]&&(e["child-binding"].isChildBinding=!0,e["child-binding"].filePath=e.filePath)),!e.include.length)return e},$F=(t,e,n,r=[],i,s)=>{let o=rg(t,e),a=rg(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},$F(t,o["child-binding"],a["child-binding"]??{filePath:a.filePath,include:[],rawInclude:[],isChildBinding:!0},s?.["property-blocklist"],s?.["property-allowlist"],s?.["child-binding"])),a},FF=t=>t?typeof t=="string"?[{name:t}]:t.map(e=>typeof e!="string"?e:{name:e}):[],ok=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(`${zs.default.sep}base.yaml`))}getBaseNodeType(e,n){let r=this.getBaseZephyrType(n),i=r?Uu(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 ie);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,zs.basename)(d.filePath)==="base.yaml"),u;if(l&&e.pathString==="/zephyr,user"){let d={...l,properties:{handle:{name:"handle",type:"phandle"},handles:{name:"handles",type:"phandles"},boolean:{name:"boolean",type:"boolean"},bytes:{name:"bytes",type:"uint8-array"},number:{name:"number",type:"int"},numbers:{name:"numbers",type:"array"},string:{name:"string",type:"string"},strings:{name:"strings",type:"string-array"}}};e.properties.forEach(f=>{f.name.endsWith("-gpios")&&(d.properties[f.name]={name:f.name,type:"phandle-array"})}),u=Uu(d,e)}if(u??=l?Uu(l,e):void 0,u){u.warnMismatchProperties=!1;let d=u.properties.find(f=>f.name==="compatible");d&&(d.required=()=>"optional")}return{type:[u??ho(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 j(37,a.ast.firstToken,a.ast.lastToken,a.ast,{templateStrings:l})}return c?[]:[j(32,a.ast.firstToken,a.ast.lastToken,a.ast,{severity:Hr.DiagnosticSeverity.Hint,tags:[Hr.DiagnosticTag.Unnecessary],templateStrings:[a.name]})]})??[];return{type:i.length?i:[ho(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),_o.sync("**/*.yaml",{cwd:o,ignore:"test/*"}).map(c=>{if(c=(0,zs.resolve)(o,c),this.zephyrBindingCache.has(c))return this.zephyrBindingCache.get(c);try{let l=qF.default.parse((0,xF.readFileSync)(c,"utf-8")),u=FF(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=>rg(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=Z6(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(`${LF.default.sep}${o.name}`)&&n.some(p=>f.startsWith(p)));return d?{range:Hr.Range.create(l,u),target:ue(d)}:void 0}}).filter(o=>!!o)}resetCache(e){this.typeCache.delete(e)}},OF,Gs=()=>(OF??=new ok,OF),Q6=(t,e)=>t.forEach(n=>{n.compatible&&e.set(n["on-bus"]?`${n.compatible}::${n["on-bus"]}`:n.compatible,r=>Uu(n,r))}),Uu=(t,e)=>{let n=ho(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])=>{BF(n,s,o)}),t["child-binding"]){let s=t["child-binding"];n.childNodeType=o=>{let a=Uu(s,o);return a.hasParentBinding=!0,a}}return n},Z6=t=>{let e=DF();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])=>{BF(e,i,s)}),e},BF=(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=IF(n.type,n.const),r.bindingType=n.type;let i=r.additionalTypeCheck;r.additionalTypeCheck=(s,o)=>[...MF(n,e,r)(s,o),...i?.(s,o)??[]]}else{let i=n.type==="compound"?r?.type:AF(n.type);i??=AF(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)??[],...MF(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=IF(n.type,n.const),t.addProperty(s)}},MF=(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(j(24,p.firstToken,p.lastToken,p,{templateStrings:[`Binding expects values to be "${r.type}" with value: ${r.const}`]}))}}}if(r.deprecated&&a.push(j(14,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Hr.DiagnosticSeverity.Warning,tags:[Hr.DiagnosticTag.Deprecated],templateStrings:[i.name]})),(r.type==="phandle"||r.type==="phandles"||r.type==="path")&&Be(i.ast.values)?.forEach(u=>{Rr(u,o)||a.push(j(22,u.firstToken,u.lastToken,u))}),r.type==="path"&&i.ast.values?.values.at(0)?.value instanceof ie){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(j(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(j(33,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Hr.DiagnosticSeverity.Warning,linkedTo:[d.ast],templateStrings:[i.name,u.toString()]})))}if(r.type==="phandle-array"){let l=Be(i.ast.values),u=0,d=[],f=0;for(;l&&u<l.length;){let p=l.at(u),m=Rr(p,o);if(!m){let O=p??i.ast;a.push(j(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(j(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?We(y,0,0,s)??0:0,b=m.nodeType?.cellsValues?.find(O=>O.specifier===h)?.values;if(d.push([`${f}_phandle`,...b?.map(O=>`${f}_${O}`)??[],...Array.from({length:_-(b?.length??0)},(O,F)=>`${f}_cell${_-(b?.length??0)?F:""}`)]),1+_>l.length-u){let O=p??i.ast;a.push(j(19,O.firstToken,O.lastToken,O,{templateStrings:[i.name,`<${d.at(-1).join(" ")}>`]}));break}u+=1+_;let v=l.slice(u-_,u),P={mappingValuesAst:v,specifierSpace:h,cellCount:_,target:m};i.nexusMapsTo.push(P);let R=m.getProperty(`${h}-map`);if(R){let O=m.getNexusMapEntryMatch(h,s,v);O?.match?P.mapItem=O.match:a.push(j(31,O.entry.firstToken,O.entry.lastToken,O.entry,{linkedTo:[R.ast]}))}v.every(O=>O instanceof ge)&&m.spesifierNexusMapping.push({expressions:v,node:i.parent,property:i,specifierSpace:h});let q=i.parent.getProperty(`${h}-names`);p&&q&&(q.ast.quickValues?.at(f)||a.push(j(33,p.firstToken,l[u-1]?.lastToken,i.ast,{severity:Hr.DiagnosticSeverity.Warning,linkedTo:[q.ast],templateStrings:[i.name,f.toString()]}))),f++}d.push([`${f}_phandle`,`${f}_cell...`]),n.signatureArgs=d.map(p=>p.map(m=>Hr.ParameterInformation.create(m)))}return a}};var Hu=new Map,jF=(t,e)=>{let n=t.zephyrBindings.join(":");return e==="Zephyr"&&(Hu.set(n,(Hu.get(n)??0)+1),Gs().loadTypeAndCache(t.zephyrBindings,n)),{files:t,type:e,getNodeTypes:r=>{switch(e){case"Zephyr":return Gs().getNodeTypes(r,n);case"DevicetreeOrg":return{type:sk().getNodeTypes(t.deviceOrgBindingsMetaSchema,t.deviceOrgTreeBindings,r),issues:[]}}},getBindings:()=>{switch(e){case"Zephyr":return Gs().getBindings(n);case"DevicetreeOrg":return sk().getBindings()}},getZephyrContextBinding:()=>{switch(e){case"Zephyr":return Gs().getZephyrContextBinding(n)}},getBusTypes:()=>{switch(e){case"Zephyr":return Gs().getBusTypes();case"DevicetreeOrg":return[]}},getDocumentLinks(r){if(!r)return[];switch(e){case"Zephyr":return Gs().getDocumentLinks(r,t.zephyrBindings);case"DevicetreeOrg":return[]}},dispose:()=>{if(e==="Zephyr"){let r=Hu.get(n)??0;r<=1?(Hu.delete(n),Gs().resetCache(n)):Hu.set(n,r-1)}}}};var ig=L(U());var eQ=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:ig.FoldingRangeKind.Comment}],ak=t=>!t.openScope||!t.closeScope?.prevToken?t.nodes.flatMap(ak):[{startLine:t.openScope.pos.line,startCharacter:t.openScope.pos.col,endLine:t.closeScope.prevToken.pos.line,endCharacter:t.closeScope.prevToken.pos.col,kind:ig.FoldingRangeKind.Region},...t.nodes.flatMap(ak)],UF=t=>{let e=[];return[...t instanceof er?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:ig.FoldingRangeKind.Region})}),e},tQ=t=>t instanceof we?ak(t):t instanceof mr||t instanceof er?UF(t):t instanceof pr?eQ(t):[];function HF(t,e){return e.allAstItems.flatMap(n=>[n,...n.allDescendants]).filter(n=>fe(n.fsPath,t)).flatMap(tQ)}var WF=require("fs"),zF=require("path"),On=L(U());function nQ(t){if(!t||!(t.ast instanceof $e)&&!(t.ast instanceof mn))return[];let e=n=>n.nodeType?.bindingsPath?[On.Location.create(ue(n.nodeType.bindingsPath),On.Range.create(On.Position.create(0,0),On.Position.create(0,0)))]:[];return t.item instanceof X&&!Jt(t.ast)?e(t.item):t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo?e(t.ast.parentNode.linksTo):t.ast instanceof $e&&t.ast.linksTo?e(t.ast.linksTo):[]}function rQ(t){if(!t||!t.item||!(t.ast instanceof Je)||t.runtime.context.bindingLoader?.type!=="Zephyr")return[];let e=t.item instanceof Qe?t.item.parent:t.item,n=e.nodeType instanceof St?e.nodeType.zephyrBinding:void 0;if(!n)return[];let r=VF(t.ast.name,n);if(r)return[On.Location.create(ue(n.filePath),r)];let i=(t.runtime.context.bindingLoader?.getZephyrContextBinding?.()??[]).filter(s=>n.extends?.some(o=>(0,zF.basename)(s.filePath)===`${o}.yaml`));for(let s of i){let o=VF(t.ast.name,s);if(o)return[On.Location.create(ue(s.filePath),o)]}return[On.Location.create(ue(n.filePath),On.Range.create(On.Position.create(0,0),On.Position.create(0,0)))]}async function GF(t,e){return wt(t,e,n=>[...nQ(n),...rQ(n)])}function VF(t,e){let n=e.filePath,r=(0,WF.readFileSync)(n,"utf8");return iQ(r,new RegExp(`(${t}|"${t}")\\s*:`))}function iQ(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(`
|
|
328
|
+
${r}`]})]},J6=(t,e)=>RF(t,e.split("/").filter(n=>n)),RF=(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?RF(s,e.slice(1)):{node:t,property:t.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var ik=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 ie)))return r?.values.map(i=>(i?.value).value)}parseMetaSchema(e,n){_o.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,tk.resolve)(e,i);try{let s=rk.default.parse((0,nk.readFileSync)(i,"utf-8"));n.addMetaSchema(s),this.schemaIdValidators.set(s.$id,i)}catch{}})}parseBindings(e,n){_o.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,tk.resolve)(e,i);try{let s=rk.default.parse((0,nk.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 EF.default({strict:!1,strictSchema:!1,strictNumbers:!1}),s.addMetaSchema(ek),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 ng(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())}},wF,sk=()=>(wF??=new ik,wF);var zs=L(require("path")),xF=require("fs"),LF=L(require("path")),qF=L(t_());var Hr=L(U());var CF=()=>{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 DF(){let t=Rn();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(CF()),t}var AF=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")}},IF=(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}},rg=(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,zs.basename)(s.filePath)===r.name);if(i){let s=r["property-blocklist"],o=r["property-allowlist"];e.extends?.push(...n.include.map(c=>(0,zs.basename)(c.name,".yaml")));let a=r["child-binding"];return n.include=n.include.filter(c=>c!==r),$F(t,i,n,s,o,a)??n}return console.warn(`Unable to find ${r.name}`),n},e),e["child-binding"]&&(e["child-binding"].include=FF(e["child-binding"].include),e["child-binding"]=rg(t,e["child-binding"]),e["child-binding"]&&(e["child-binding"].isChildBinding=!0,e["child-binding"].filePath=e.filePath)),!e.include.length)return e},$F=(t,e,n,r=[],i,s)=>{let o=rg(t,e),a=rg(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},$F(t,o["child-binding"],a["child-binding"]??{filePath:a.filePath,include:[],rawInclude:[],isChildBinding:!0},s?.["property-blocklist"],s?.["property-allowlist"],s?.["child-binding"])),a},FF=t=>t?typeof t=="string"?[{name:t}]:t.map(e=>typeof e!="string"?e:{name:e}):[],ok=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(`${zs.default.sep}base.yaml`))}getBaseNodeType(e,n){let r=this.getBaseZephyrType(n),i=r?Uu(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 ie);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,zs.basename)(d.filePath)==="base.yaml"),u;if(l&&e.pathString==="/zephyr,user"){let d={...l,properties:{handle:{name:"handle",type:"phandle"},handles:{name:"handles",type:"phandles"},boolean:{name:"boolean",type:"boolean"},bytes:{name:"bytes",type:"uint8-array"},number:{name:"number",type:"int"},numbers:{name:"numbers",type:"array"},string:{name:"string",type:"string"},strings:{name:"strings",type:"string-array"}}};e.properties.forEach(f=>{f.name.endsWith("-gpios")&&(d.properties[f.name]={name:f.name,type:"phandle-array"})}),u=Uu(d,e)}if(u??=l?Uu(l,e):void 0,u){u.warnMismatchProperties=!1;let d=u.properties.find(f=>f.name==="compatible");d&&(d.required=()=>"optional")}return{type:[u??ho(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 j(37,a.ast.firstToken,a.ast.lastToken,a.ast,{templateStrings:l})}return c?[]:[j(32,a.ast.firstToken,a.ast.lastToken,a.ast,{severity:Hr.DiagnosticSeverity.Hint,tags:[Hr.DiagnosticTag.Unnecessary],templateStrings:[a.name]})]})??[];return{type:i.length?i:[ho(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),_o.sync("**/*.yaml",{cwd:o,ignore:"test/*"}).map(c=>{if(c=(0,zs.resolve)(o,c),this.zephyrBindingCache.has(c))return this.zephyrBindingCache.get(c);try{let l=qF.default.parse((0,xF.readFileSync)(c,"utf-8")),u=FF(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=>rg(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=Z6(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(`${LF.default.sep}${o.name}`)&&n.some(p=>f.startsWith(p)));return d?{range:Hr.Range.create(l,u),target:ue(d)}:void 0}}).filter(o=>!!o)}resetCache(e){this.typeCache.delete(e)}},OF,Gs=()=>(OF??=new ok,OF),Q6=(t,e)=>t.forEach(n=>{n.compatible&&e.set(n["on-bus"]?`${n.compatible}::${n["on-bus"]}`:n.compatible,r=>Uu(n,r))}),Uu=(t,e)=>{let n=ho(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])=>{BF(n,s,o)}),t["child-binding"]){let s=t["child-binding"];n.childNodeType=o=>{let a=Uu(s,o);return a.hasParentBinding=!0,a}}return n},Z6=t=>{let e=DF();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])=>{BF(e,i,s)}),e},BF=(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=IF(n.type,n.const),r.bindingType=n.type;let i=r.additionalTypeCheck;r.additionalTypeCheck=(s,o)=>[...MF(n,e,r)(s,o),...i?.(s,o)??[]]}else{let i=n.type==="compound"?r?.type:AF(n.type);i??=AF(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)??[],...MF(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=IF(n.type,n.const),t.addProperty(s)}},MF=(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(j(24,p.firstToken,p.lastToken,p,{templateStrings:[`Binding expects values to be "${r.type}" with value: ${r.const}`]}))}}}if(r.deprecated&&a.push(j(14,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Hr.DiagnosticSeverity.Warning,tags:[Hr.DiagnosticTag.Deprecated],templateStrings:[i.name]})),(r.type==="phandle"||r.type==="phandles"||r.type==="path")&&Be(i.ast.values)?.forEach(u=>{Rr(u,o)||a.push(j(22,u.firstToken,u.lastToken,u))}),r.type==="path"&&i.ast.values?.values.at(0)?.value instanceof ie){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(j(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(j(33,i.ast.firstToken,i.ast.lastToken,i.ast,{severity:Hr.DiagnosticSeverity.Warning,linkedTo:[d.ast],templateStrings:[i.name,u.toString()]})))}if(r.type==="phandle-array"){let l=Be(i.ast.values),u=0,d=[],f=0;for(;l&&u<l.length;){let p=l.at(u),m=Rr(p,o);if(!m){let O=p??i.ast;a.push(j(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(j(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?We(y,0,0,s)??0:0,b=m.nodeType?.cellsValues?.find(O=>O.specifier===h)?.values;if(d.push([`${f}_phandle`,...b?.map(O=>`${f}_${O}`)??[],...Array.from({length:_-(b?.length??0)},(O,F)=>`${f}_cell${_-(b?.length??0)?F:""}`)]),1+_>l.length-u){let O=p??i.ast;a.push(j(19,O.firstToken,O.lastToken,O,{templateStrings:[i.name,`<${d.at(-1).join(" ")}>`]}));break}u+=1+_;let v=l.slice(u-_,u),P={mappingValuesAst:v,specifierSpace:h,cellCount:_,target:m};i.nexusMapsTo.push(P);let R=m.getProperty(`${h}-map`);if(R){let O=m.getNexusMapEntryMatch(h,s,v);O?.match?P.mapItem=O.match:a.push(j(31,O.entry.firstToken,O.entry.lastToken,O.entry,{linkedTo:[R.ast]}))}v.every(O=>O instanceof ge)&&m.spesifierNexusMapping.push({expressions:v,node:i.parent,property:i,specifierSpace:h});let q=i.parent.getProperty(`${h}-names`);p&&q&&(q.ast.quickValues?.at(f)||a.push(j(33,p.firstToken,l[u-1]?.lastToken,i.ast,{severity:Hr.DiagnosticSeverity.Warning,linkedTo:[q.ast],templateStrings:[i.name,f.toString()]}))),f++}d.push([`${f}_phandle`,`${f}_cell...`]),n.signatureArgs=d.map(p=>p.map(m=>Hr.ParameterInformation.create(m)))}return a}};var Hu=new Map,jF=(t,e)=>{let n=t.zephyrBindings.join(":");return e==="Zephyr"&&(Hu.set(n,(Hu.get(n)??0)+1),Gs().loadTypeAndCache(t.zephyrBindings,n)),{files:t,type:e,getNodeTypes:r=>{switch(e){case"Zephyr":return Gs().getNodeTypes(r,n);case"DevicetreeOrg":return{type:sk().getNodeTypes(t.deviceOrgBindingsMetaSchema,t.deviceOrgTreeBindings,r),issues:[]}}},getBindings:()=>{switch(e){case"Zephyr":return Gs().getBindings(n);case"DevicetreeOrg":return sk().getBindings()}},getZephyrContextBinding:()=>{switch(e){case"Zephyr":return Gs().getZephyrContextBinding(n)}},getBusTypes:()=>{switch(e){case"Zephyr":return Gs().getBusTypes();case"DevicetreeOrg":return[]}},getDocumentLinks(r){if(!r)return[];switch(e){case"Zephyr":return Gs().getDocumentLinks(r,t.zephyrBindings);case"DevicetreeOrg":return[]}},dispose:()=>{if(e==="Zephyr"){let r=Hu.get(n)??0;r<=1?(Hu.delete(n),Gs().resetCache(n)):Hu.set(n,r-1)}}}};var ig=L(U());var eQ=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:ig.FoldingRangeKind.Comment}],ak=t=>!t.openScope||!t.closeScope?.prevToken?t.nodes.flatMap(ak):[{startLine:t.openScope.pos.line,startCharacter:t.openScope.pos.col,endLine:t.closeScope.prevToken.pos.line,endCharacter:t.closeScope.prevToken.pos.col,kind:ig.FoldingRangeKind.Region},...t.nodes.flatMap(ak)],UF=t=>{let e=[];return[...t instanceof er?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:ig.FoldingRangeKind.Region})}),e},tQ=t=>t instanceof we?ak(t):t instanceof mr||t instanceof er?UF(t):t instanceof pr?eQ(t):[];function HF(t,e){return e.allAstItems.flatMap(n=>[n,...n.allDescendants]).filter(n=>pe(n.fsPath,t)).flatMap(tQ)}var WF=require("fs"),zF=require("path"),On=L(U());function nQ(t){if(!t||!(t.ast instanceof $e)&&!(t.ast instanceof mn))return[];let e=n=>n.nodeType?.bindingsPath?[On.Location.create(ue(n.nodeType.bindingsPath),On.Range.create(On.Position.create(0,0),On.Position.create(0,0)))]:[];return t.item instanceof X&&!Jt(t.ast)?e(t.item):t.ast instanceof mn&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo?e(t.ast.parentNode.linksTo):t.ast instanceof $e&&t.ast.linksTo?e(t.ast.linksTo):[]}function rQ(t){if(!t||!t.item||!(t.ast instanceof Je)||t.runtime.context.bindingLoader?.type!=="Zephyr")return[];let e=t.item instanceof Qe?t.item.parent:t.item,n=e.nodeType instanceof St?e.nodeType.zephyrBinding:void 0;if(!n)return[];let r=VF(t.ast.name,n);if(r)return[On.Location.create(ue(n.filePath),r)];let i=(t.runtime.context.bindingLoader?.getZephyrContextBinding?.()??[]).filter(s=>n.extends?.some(o=>(0,zF.basename)(s.filePath)===`${o}.yaml`));for(let s of i){let o=VF(t.ast.name,s);if(o)return[On.Location.create(ue(s.filePath),o)]}return[On.Location.create(ue(n.filePath),On.Range.create(On.Position.create(0,0),On.Position.create(0,0)))]}async function GF(t,e){return wt(t,e,n=>[...nQ(n),...rQ(n)])}function VF(t,e){let n=e.filePath,r=(0,WF.readFileSync)(n,"utf8");return iQ(r,new RegExp(`(${t}|"${t}")\\s*:`))}function iQ(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(`
|
|
329
329
|
`).length-1,o=i.lastIndexOf(`
|
|
330
330
|
`),a=o===-1?r+1:r-o,c=a+n[0].length;return On.Range.create(On.Position.create(s,a),On.Position.create(s,c))}var Tc=require("fs");var sQ=(t,e)=>{let n=(0,Tc.readFileSync)(t).toString();if(xn().needsRenew(t,n))xn().renewLexer(t,n),e(t);else return console.log("file changed event has the same text, skipping.",t)},sg=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}sQ(e,n)},(0,Tc.watchFile)(e,this.onChange)}}unwatch(){this.count===1&&(console.log("dispose watch for",this.file),(0,Tc.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 cn=L(require("path")),ck=require("fs");var mi=t=>{if(t)return Array.isArray(t)?t:[t]},oQ=t=>({...t,deviceOrgBindingsMetaSchema:mi(t.deviceOrgBindingsMetaSchema),deviceOrgTreeBindings:mi(t.deviceOrgTreeBindings),includePaths:mi(t.includePaths),lockRenameEdits:mi(t.lockRenameEdits),zephyrBindings:mi(t.zephyrBindings),overlays:mi(t.overlays)}),KF=t=>({...t,defaultDeviceOrgBindingsMetaSchema:mi(t.defaultDeviceOrgBindingsMetaSchema),defaultDeviceOrgTreeBindings:mi(t.defaultDeviceOrgTreeBindings),defaultIncludePaths:mi(t.defaultIncludePaths),defaultLockRenameEdits:mi(t.defaultLockRenameEdits),defaultZephyrBindings:mi(t.defaultZephyrBindings),contexts:t.contexts?.map(oQ)}),Vr=async(t,e=[],n)=>{let r=n?e.map(s=>Se(s.uri)).find(s=>fE(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},Ks={defaultBindingType:"Zephyr",defaultZephyrBindings:[],defaultIncludePaths:[],defaultDeviceOrgBindingsMetaSchema:[],defaultDeviceOrgTreeBindings:[],contexts:[],defaultLockRenameEdits:[],allowAdhocContexts:!0,autoChangeContext:!0,defaultShowFormattingErrorAsDiagnostics:!0,disableFileWatchers:!1},lk=async(t,e,n)=>{let r=await Vr(t.cwd??"${workspaceFolder}",n,t.dtsFile)??e.cwd,i=await Promise.all((t.includePaths??e.defaultIncludePaths).map(p=>Vr(p,n,t.dtsFile))),s=await Promise.all((t.zephyrBindings??e.defaultZephyrBindings).map(p=>Vr(p,n,t.dtsFile))),o=t.bindingType??e.defaultBindingType,a=await Promise.all((t.deviceOrgTreeBindings??e.defaultDeviceOrgTreeBindings).map(p=>Vr(p,n,t.dtsFile))),c=await Promise.all((t.deviceOrgBindingsMetaSchema??e.defaultDeviceOrgBindingsMetaSchema).map(p=>Vr(p,n,t.dtsFile))),l=await Promise.all((t.lockRenameEdits??e.defaultLockRenameEdits).map(p=>Vr(p,n,t.dtsFile)));if(r&&o==="Zephyr"&&(!s||s.length===0)&&(s=["./zephyr/dts/bindings"]),!t.dtsFile){console.log("Context is missing dtsFile, skipping...");return}let u=t.dtsFile,d=t.overlays??[],f=t.compileCommands;return r&&(s=s.map(p=>(0,cn.resolve)(r,p)).filter(p=>(0,ck.existsSync)(p)),a=a?.map(p=>(0,cn.resolve)(r,p)),c=c.map(p=>(0,cn.resolve)(r,p)),i=i.map(p=>(0,cn.resolve)(r,p)),u=(0,cn.resolve)(r,u),d=d.map(p=>(0,cn.resolve)(r,p)),l=l.map(p=>(0,cn.resolve)(r,p)),f=f?(0,cn.resolve)(r,f):void 0),{ctxName:t.ctxName??(0,cn.basename)(u),cwd:r?lt(r):void 0,includePaths:i.map(lt),zephyrBindings:s.map(lt),bindingType:o,deviceOrgTreeBindings:a.map(lt),deviceOrgBindingsMetaSchema:c.map(lt),dtsFile:lt(u),overlays:d.map(lt),lockRenameEdits:l.map(lt),compileCommands:f?lt(f):void 0,showFormattingErrorAsDiagnostics:t.showFormattingErrorAsDiagnostics??e.defaultShowFormattingErrorAsDiagnostics,disableFileWatchers:t.disableFileWatchers??e.disableFileWatchers}},Vu=async(t,e)=>{let n=t.cwd?await Vr(t.cwd,e):void 0,r=t.defaultBindingType,i=t.defaultDeviceOrgBindingsMetaSchema=await Promise.all((t.defaultDeviceOrgBindingsMetaSchema??[]).map(d=>Vr(d,e))),s=t.defaultDeviceOrgTreeBindings=await Promise.all((t.defaultDeviceOrgTreeBindings??[]).map(d=>Vr(d,e))),o=t.defaultIncludePaths=await Promise.all((t.defaultIncludePaths??[]).map(d=>Vr(d,e))),a=t.defaultZephyrBindings=await Promise.all((t.defaultZephyrBindings??[]).map(d=>Vr(d,e))),c=t.defaultLockRenameEdits=await Promise.all((t.defaultLockRenameEdits??[]).map(d=>Vr(d,e)));n&&(o=t.defaultIncludePaths=(t.defaultIncludePaths??[]).map(d=>(0,cn.resolve)(n,d)),r==="Zephyr"&&!t.defaultZephyrBindings&&(a=["./zephyr/dts/bindings"]),a=a.map(d=>(0,cn.resolve)(n,d)),i=i.map(d=>(0,cn.resolve)(n,d)),s=(t.defaultDeviceOrgTreeBindings??[]).map(d=>(0,cn.resolve)(n,d)),c=c.map(d=>(0,cn.resolve)(n,d)));let l={cwd:n,defaultDeviceOrgBindingsMetaSchema:i,defaultDeviceOrgTreeBindings:s,defaultIncludePaths:o,defaultZephyrBindings:a,defaultLockRenameEdits:c,defaultBindingType:r,autoChangeContext:t.autoChangeContext??Ks.autoChangeContext,allowAdhocContexts:t.allowAdhocContexts??Ks.allowAdhocContexts,defaultShowFormattingErrorAsDiagnostics:t.defaultShowFormattingErrorAsDiagnostics??Ks.defaultShowFormattingErrorAsDiagnostics,disableFileWatchers:t.disableFileWatchers??!1},u=(await Promise.all(t.contexts?.map(d=>lk(d,l,e))??[])).filter(d=>!!d).filter(d=>[d.dtsFile,...d.overlays].every(f=>(0,ck.existsSync)(f)&&cn.default.isAbsolute(f)));return{...l,contexts:u}};var YF=t=>`DT_PROP(${uk(t.parent)}, ${t.name.replaceAll("-","_")}))`,XF=t=>t.parent.labels.map(e=>`DT_PROP(DT_NODELABEL(${e.label.toString()}), ${t.name.replaceAll("-","_")})`);var uk=t=>`DT_PATH(${t.path.slice(1).map(e=>e.replace("@","_").replaceAll("-","_")).join(",")})`,JF=t=>t.labels.map(e=>`DT_NODELABEL(${e.label.toString()})`),QF=t=>{let e=[];return ki.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 se&&s.linksTo===t||s instanceof ut&&s.path?.pathParts.at(-1)?.linksTo===t)return!0})?.forEach(i=>e.push(`DT_ALIAS(${i.name.replaceAll("-","_")})`)),e};function aQ(t,e){if(!t||!(t.item instanceof Qe)||!(t.ast instanceof Je))return[];let n=[];return e.settings.bindingType==="Zephyr"&&(n.push({type:"dt_zephyr_macro_prop_node_path",data:YF(t.item)}),XF(t.item).forEach(r=>{n.push({type:"dt_zephyr_macro_prop_node_label",data:r})})),n}function cQ(t,e){if(!t||t.item===null)return[];let n;if(t.item instanceof X?n=t.item:t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo?n=t.ast.parentNode.linksTo:t.ast instanceof $e&&t.ast.linksTo&&(n=t.ast.linksTo),!n)return[];let r=[{type:"path",data:n.pathString}];return e.settings.bindingType==="Zephyr"&&(JF(n).forEach(i=>{r.push({type:"dt_zephyr_macro_node_label",data:i})}),r.push({type:"dt_zephyr_macro_node_path",data:uk(n)}),QF(n).forEach(i=>{r.push({type:"dt_zephyr_macro_prop_node_alias",data:i})})),r}async function ZF(t,e){return e?wt(t,e,n=>[...cQ(n,e),...aQ(n,e)]):[]}var eB=L(U());function lQ(t){return!t||!(t.item instanceof Qe)?void 0:t.item.parent.nodeType?.getSignatureHelp?.(t.item,t.ast,t.beforeAst,t.afterAst)}async function uQ(t){let e=zc(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 Si))return;let i=r.params.map(o=>({label:o instanceof yt?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:[eB.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 tB(t,e){if(e)return(await wt(t,e,async n=>[await uQ(n)||lQ(n)])).at(0)}var nB=require("timers"),rB=require("events");var dk=class extends rB.EventEmitter{constructor(e=3e3,n=1e3){super(),this.thresholdBytes=e*1024*1024,this.interval=(0,nB.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)}},dQ=new dk(3e3),iB=()=>{dQ.on("thresholdExceeded",({usedMb:t,thresholdMb:e})=>{console.warn(`[HeapMonitor] Heap usage exceeded ${e}MB: ${t}MB used`),vD(),TD()})};var sB=t=>`0x${t.map((e,n)=>e.toString(16).padStart(n?8:0,"0")).join("")}`;function fk(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=Nr(e.start,e.size),u=Nr(c.start,c.size),d=At(e.start,c.start)>=0,f=At(l,u)<=0,p=At(e.start,c.start)===0&&At(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){fk(c,e);return}for(let l of o)fk(l,e);return}let a=t.children.find(c=>c.name===s);a?(a.start=pE(a.start,e.start),a.size=hE(a.size,yT(Nr(e.start,e.size),a.start))):(a={name:s,start:e.start,size:e.size,children:[]},t.children.push(a))}function fQ(t){let e={};for(let n of t){let r={name:n.name,children:[]};for(let i of n.partitions)fk(r,i);e[n.name]=r}return e}function oB(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: ${sB(t.start)}`),"size"in t&&t.size&&o.push(`size: ${sB(t.size)}`);let a=o.length>0?` [${o.join(", ")}]`:"",c=t.name;i+=`${e}${s}${c} ${a}
|
|
331
331
|
`;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(b=>b.name))).join(", "),h={};p.forEach(b=>{b.children.forEach(v=>{let P=`${v.start}-${v.size}-${v.name}`;h[P]=v})});let y=Object.values(h),_={name:m,start:p[0].start,size:p[0].size,children:y};i+=oB(_,l,f===u.length-1)}),i}function aB(t){return fQ(t)}function cB(t){return Object.values(t).map(e=>oB(e)).join(`
|
|
332
|
-
`)}var Ie=[],le,Ys,og=new WeakMap,Wu=new Map;iB();var cg=new Map,uB=t=>{t.settings.disableFileWatchers||t.getContextFiles().forEach(e=>{Wu.has(e)||Wu.set(e,new sg(e,Tk,()=>{let n=Ju(e),r=cg.get(e);return!n||r===void 0?!1:r!==n.version})),Wu.get(e)?.watch()})},gk=async t=>{let e=Ie.indexOf(t);if(e===-1)return;Gu(t,void 0,!0),og.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let n=await Js(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}),Ie.splice(e,1),await _k(),t===le&&(le=void 0,Ie.length)){let r=Ys?Nn(Ie,{fsPath:Ys}):void 0;r??=Ie[0],console.log("Active context was deleted. Forcing active to",r.id),await vn({id:r.id},!0)}t.settings.disableFileWatchers||t.getContextFiles().map(r=>{Wu.get(r)?.unwatch()}),setTimeout(async()=>{await Oe();let r=new Set(Ie.flatMap(i=>i.getContextFiles()));t.getContextFiles().map(i=>{r.has(i)||xn().reset(i)})},2e3),t.bindingLoader?.dispose()},pQ=t=>{let e=og.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},Oe=async()=>{await Promise.all(Ie.map(pQ))},yk=async(t,e)=>(await dB(e)).indexOf(t)!==-1,dB=async t=>{let e=await fB(t);return Ie.filter(n=>!e.some(r=>r===n))},fB=async t=>{let e=await mk(t);return Ie.filter(n=>e.contexts.find(r=>Vi(r)===n.id))},hQ=async t=>{let e=await bQ(t);return Ie.filter(n=>e.contexts.find(r=>Vi(r)===n.id))},mQ=async(t,e)=>(await hQ(e)).indexOf(t)!==-1,gQ=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=>fe(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=>fe(i,t.parser.fsPath))},yQ=async t=>{if(!await yk(t))return;let e=await dB(),n=await fB(),r=await Ff(e);if(Ie.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 gQ(a.context,c)})))),s=t.getContextFiles(),o=r.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==t&&fe(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(gk))},Q=(0,He.createConnection)(He.ProposedFeatures.all),ln=new He.TextDocuments(Vt),pB=!1,ag=!1,hB=!1,mB=!1,gB=!1,pk;Q.onInitialize(async t=>{pk=t.workspaceFolders??[],Q.console.log(`[Server(${process.pid}) ${pk?.at(0)?.uri} Version 0.8.5 ] Started and initialize received`);let e=t.capabilities;pB=!!(e.workspace&&e.workspace.configuration),ag=!!(e.workspace&&e.workspace.workspaceFolders),hB=!!e.workspace?.diagnostics?.refreshSupport,mB=!!e.workspace?.semanticTokens?.refreshSupport,gB=!!e.workspace?.foldingRange?.refreshSupport;let n={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:He.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[He.CodeActionKind.QuickFix,He.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:Of,tokenModifiers:Mf},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,documentRangeFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return ag&&(n.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),await bB(t.initializationOptions),n});var hk,TQ={tabSize:8,insertSpaces:!1,trimTrailingWhitespace:!0,insertFinalNewline:!0,wordWrapColumn:100};Q.onInitialized(async()=>{if(pB&&(Q.client.register(He.DidChangeConfigurationNotification.type,{}),!hk)){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"],removeMacroMultiline:e?.["editor.removeMacroMultiline"],wrapLongLines:e?.["editor.wrapLongLines"],indentExpressions:e?.["editor.indentExpressions"],removeEmptyReferences:e?.["editor.removeEmptyReferences"],removeEmptyNodes:e?.["editor.removeEmptyNodes"],removeEmptyRoots:e?.["editor.removeEmptyRoots"],sortNodesAndProperties:e?.["editor.sortNodesAndProperties"]};(t||n)&&(hk={...t,...n})}ag&&Q.workspace.onDidChangeWorkspaceFolders(async t=>{Q.console.log("Workspace folder change event received"),await Xu()})});Q.onRequest("workspace/workspaceFolders",async()=>pk??null);var vQ=async t=>{let e=yB();return e={...Ks,...e},Vu(e,t??await Yu())},mk=async t=>{let e=SQ();return e={...Ks,...e},Vu(e,t??await Yu())},bQ=async t=>{let e=kQ();return e={...Ks,...e},Vu(e,t??await Yu())},Ku=async t=>{let e=_Q();return e={...Ks,...e},Vu(e,t??await Yu())},Yu=async()=>ag?await Q.workspace.getWorkspaceFolders()??[]:[],lB=async t=>{let e=Nn(Ie,{id:Vi(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=Vi(t);console.log(`(ID: ${n}) New context [${t.ctxName}]`),console.log(`(ID: ${n}) Settings: ${JSON.stringify(t,void 0," ")}`);let r=(0,bc.join)((0,bc.dirname)(t.dtsFile),"dts","bindings"),i=new up(t,hk??TQ,t.bindingType?jF({zephyrBindings:t.zephyrBindings?[r,...t.zephyrBindings]:[r],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ie.push(i);let s=performance.now();await i.stable(),console.log(`(ID: ${n}) New context took ${performance.now()-s}ms to start [${t.ctxName}]`),uB(i);let o=await Js(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 yQ(i),await _k(),i},Xu=async()=>{let t=await mk(),e=await Ku();e.allowAdhocContexts||(e=await mk());let n=e.contexts.map(Vi),r=Ie.filter(i=>!n.includes(i.id));await Promise.all(r.map(gk)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await lB(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await vQ()).contexts?.reduce((s,o)=>s.then(async()=>{Nn(Ie,{fsPath:o.dtsFile})||await lB(o)}),Promise.resolve()),setTimeout(async()=>{Ys?await vn({fsPath:Ys}):!le&&Ie.length&&(console.log(`No active context using first context (ID: ${Ie[0].id}) [${Ie[0].ctxNames.join(",")}]`),await vn({id:Ie[0].id}))})},Wr,Xs,zu=new Map,vc=new Map,_Q=()=>!Xs&&!Wr?void 0:{...Xs,...Wr,contexts:[...Wr?.contexts??[],...Array.from(vc.values()),...Array.from(zu.values())]},yB=()=>!Xs&&!Wr?void 0:{...Xs,...Wr,contexts:[...Array.from(zu.values())]},SQ=()=>!Xs&&!Wr?void 0:{...Xs,...Wr,contexts:[...Wr?.contexts??[],...Array.from(vc.values())]},kQ=()=>!Xs&&!Wr?void 0:{...Wr,contexts:[...Wr?.contexts??[]]};function PQ(t){let e={...t};for(let n in e)e[n]===null&&delete e[n];return e}var TB=async()=>{let t=await Ku();console.log("Resolved settings",JSON.stringify(t,void 0," ")),Q.sendNotification("devicetree/settingsChanged",t),await Xu(),Oe().then(()=>{hB&&Q.languages.diagnostics.refresh()})},NQ=async()=>{let t=le?.getContextFiles();await Promise.all(Array.from(ln.keys()).filter(Yt).map(async e=>{t?.some(n=>fe(n,Se(e)))||await Q.sendDiagnostics({uri:e,version:ln.get(e)?.version,diagnostics:[{severity:He.DiagnosticSeverity.Information,range:He.Range.create(He.Position.create(0,0),He.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},Tk=async t=>{let e=mT(Ie,t);if(e.length)e.sort((n,r)=>n===le?-1:r===le?1:0).forEach(n=>{og.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?vB(n):[],l=n.getContextFiles();if(await n.reevaluate(t),uB(n),l.forEach(p=>Wu.get(p)?.unwatch()),a&&Sk(n)?.length&&(vk(n).then(p=>{let m=p.items.map(h=>({uri:h.uri,version:h.version??void 0,diagnostics:h.items}));Gu(n,c.filter(h=>m.every(y=>y.uri!==h.uri))),m.forEach(h=>{Q.sendDiagnostics(h)}),Qu.set(n,!0)}),Ys)){let p=n.getFsPathParser(Ys);p&&setTimeout(()=>{p.latestSemanticTokensBuilt||Q.languages.semanticTokens.refresh()},50)}let[u,d]=await Promise.all([Js(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)})});og.set(n,{abort:r,promise:i})});else{if((await Ku()).allowAdhocContexts===!1)return;await Xu(),await vn({fsPath:t})}},RQ=t=>ln.keys().find(e=>fe(Se(e),t)),Ju=t=>{let e=RQ(t);if(e)return ln.get(e)},vB=t=>t.getContextFiles().map(e=>({uri:ue(e),version:Ju(e)?.version,diagnostics:[]})),Qu=new WeakMap,Gu=async(t,e=vB(t),n=!1)=>{if(!n&&t!==le)return;let r=performance.now();await Promise.all(e.filter(i=>t===le||!le?.getContextFiles().some(s=>fe(Se(i.uri),s))).map(i=>Q.sendDiagnostics({uri:i.uri,version:ln.get(i.uri)?.version,diagnostics:[]}))),Qu.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-r)},vk=async t=>{await t.stable();let e=performance.now(),n=await t.getDiagnostics(),r=await Promise.all(t.getContextFiles().map(async i=>{let s=Ju(i),o=[];return s&&t.settings.showFormattingErrorAsDiagnostics&&o.push(...(await Ps({textDocument:s,options:t.formattingOptions},s.getText(),"File Diagnostics").catch(()=>[])).map(a=>a.diagnostic())),{uri:ue(i),kind:He.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]}},bk=async t=>{let{items:e}=await vk(t);e.map(n=>({uri:n.uri,version:n.version??void 0,diagnostics:n.items})).forEach(async n=>{Q.sendDiagnostics(n)}),Qu.set(t,!0)},_k=async()=>{let t=await Promise.all(Ie.map(e=>Js(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("==============================")},Js=async(t,e)=>{let n=await yk(t,e),r=!n&&await mQ(t,e);return{ctx:t,type:n?"Ad Hoc":r?"User":"3rd Party"}},vn=async(t,e=!1)=>{if("fsPath"in t){if(!Yt(t.fsPath))return!1;Ys=t.fsPath,console.log("Active File Uri",Ys)}let n=await Ku();if(le&&!e&&!n.autoChangeContext||(await Oe(),!e&&le?.getContextFiles().find(o=>"fsPath"in t&&fe(o,t.fsPath))))return!1;let r=le,i=Nn(Ie,t),s=r!==i;return s&&(r&&Gu(r),le=i,i?(Js(i).then(async o=>{let a=await i.getFileTree();!i||i!==le&&!Ie.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})}),Sk(i)?.length&&bk(i),await _k()):Q.sendNotification("devicetree/newActiveContext",void 0)),gB&&Q.languages.foldingRange.refresh(),mB&&Q.languages.semanticTokens.refresh(),s},Yt=t=>[".dts",".dtsi",".dtso",".overlay"].some(e=>t.endsWith(e));ln.listen(Q);var Sk=t=>t?.getContextFiles()?.filter(e=>Ju(e));ln.onDidSave(t=>{cg.set(Se(t.document.uri),t.document.version)});ln.onDidClose(async t=>{let e=Se(t.document.uri);if(!Yt(e))return;cg.delete(e);let n=mT(Ie,e);if(n.length===0){zu.delete(e),Q.sendDiagnostics({uri:t.document.uri,version:ln.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(n.map(async r=>{!!Sk(r)?.filter(s=>s!==e).length?le?.getContextFiles().some(s=>fe(s,e))?le?.getContextFiles().some(s=>fe(s,e))&&(await Gu(le),await bk(le)):Q.sendDiagnostics({uri:t.document.uri,version:ln.get(t.document.uri)?.version,diagnostics:[]}):await yk(r)?(await gk(r),zu.delete(r.settings.dtsFile)):Gu(r)}))});ln.onDidOpen(async t=>{let e=Se(t.document.uri);if(!Yt(e))return;cg.set(e,t.document.version),await Oe(),NQ();let n=Nn(Ie,{fsPath:e});if(console.log("onDidOpen",n?.id,e),n)n!==le?await vn({id:n.id}):n===le&&(!Qu.get(n)||n.getContextFiles().some(r=>!fe(r,e)))&&await bk(n);else{let r={ctxName:(0,bc.basename)(e),dtsFile:e};zu.set(e,r),await Tk(e)}});ln.onDidChangeContent(async t=>{let e=Se(t.document.uri);if(!Yt(e))return;let n=t.document.getText(),r=xn();r.needsRenew(e,n)&&(console.log("Content changed",e),r.renewLexer(e,n),await Tk(e))});var bB=async t=>{t?.settings?.devicetree&&(Wr=KF(PQ(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await TB())};Q.onDidChangeConfiguration(async t=>{await bB(t)});Q.listen();Q.languages.diagnostics.onWorkspace(async()=>{await Oe();let t=le;return t?vk(t).finally(()=>{Qu.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 UA(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return[];await Oe(),vn({fsPath:e});let n=Un(e);return n?[...await RD(t,n),...await b0(t,n)]:[]});Q.onCompletionResolve(t=>t);var Un=t=>{let e=yB();return Nn(Ie,{fsPath:t},le,e?.preferredContext)};Q.onDocumentSymbol(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return[];await Oe();let n=Un(e);return n?n.getFsPathParser(e)?.getDocumentSymbols(e):[]});Q.onWorkspaceSymbol(async()=>{await Oe();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(!Yt(e))return{data:[]};try{await Oe();let n=Un(e),r=new He.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 Oe();let e=Se(t.textDocument.uri);return Yt(e)?Un(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&le?le.bindingLoader?.getDocumentLinks?.(ln.get(t.textDocument.uri))??[]:[]});Q.onPrepareRename(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return KA(t,n)});Q.onRenameRequest(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return GA(t,n)});Q.onReferences(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return HA(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 JA(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e),r=(await n?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>He.Location.create(i.target,i.range))??[];return r.length?r:XA(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 t0(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return e0(t,n)});Q.onCodeAction(async t=>{let e=Se(t.textDocument.uri);if(Yt(e))return r0(t)});var _B=async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);if(!n)return[];if((await n.getSyntaxIssues(void 0,l=>uo(l.raw,e,!1)?l:void 0)).get(e)?.length)return[];let i=ln.get(t.textDocument.uri)??xn().getDocument(e),s=i.getText(),o=await Ps({...t,options:{...n.formattingOptions,...t.options}},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[He.TextEdit.replace(He.Range.create(He.Position.create(0,0),He.Position.create(i.lineCount,c)),o)]};Q.onDocumentRangeFormatting(_B);Q.onDocumentFormatting(_B);Q.onHover(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return HO(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return;await Oe();let n=Un(e);return(await _0(t,n)).at(0)});Q.onFoldingRanges(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe();let n=Un(e),r=n?.isInContext(e);if(!n||!r)return[];let i=(await n.getAllStableParsers()).find(s=>s.getFiles().some(o=>o===e));return i?HF(e,i):[]});Q.onTypeDefinition(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return GF(t,n)});Q.onSignatureHelp(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return tB(t,n)});Q.onRequest("devicetree/getContexts",async()=>(await Oe(),Promise.all(Ie.map(async t=>{let e=await Js(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 Oe(),console.log("devicetree/setActive",t),await vn(t,!0)));Q.onRequest("devicetree/getActiveContext",async()=>{if(await Oe(),console.log("devicetree/getActiveContext"),!le)return;let t=await Js(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 Oe(),Xs=t,console.log("Integration Settings",t),await TB()});Q.onRequest("devicetree/requestContext",async t=>{await Oe();let e=await Yu(),n=await Ku(e),r=await lk(t,n,e);if(!r)throw console.log("Failed to resolve context",t),new Error("Failed to resolve context");console.log("devicetree/requestContext",r);let i=Vi(r),s=Array.from(vc).find(([,c])=>c.ctxName===t.ctxName);if(s){let c=s[0].split(":",1)[0];Nn(Ie,{name:r.ctxName.toString()})?.removeCtxName(r.ctxName),console.log(`Removing integration context with ID ${c} and name ${t.ctxName}`),vc.delete(s[0])}vc.set(`${i}:${t.ctxName}`,t),await Xu();let o=Ie.find(c=>c.id===i);if(!o)throw new Error("Failed to create context");let a=await Js(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 Oe(),vc.delete(`${t}:${e}`);let n=Nn(Ie,{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 Xu()}});Q.onRequest("devicetree/compiledDtsOutput",async t=>{if(await Oe(),!t)return;let e=Nn(Ie,{id:t});if(!e||!e.settings.dtsFile){console.log("Context or DTS file not found for ID",t);return}let n=await e.toFullString();return Ps({textDocument:{uri:ue(e.settings.dtsFile)},options:e.formattingOptions},n,"New Text").catch(()=>n)});Q.onRequest("devicetree/serializedContext",async t=>{if(await Oe(),!t)return;let e=Nn(Ie,{id:t}),n=performance.now();return e?.serialize().finally(()=>{console.info("serializedContext",performance.now()-n)})});Q.onRequest("devicetree/activePath",async t=>{if(await Oe(),!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 wt(t,le,n=>[e(n)])).at(0)});Q.onRequest("devicetree/customActions",async t=>(await Oe(),ZF(t,le)));Q.onRequest("devicetree/activeFsPath",async t=>{await Oe(),vn({fsPath:t})});Q.onRequest("devicetree/formattingText",async t=>{let e=Se(t.textDocument.uri),n=Ju(e)??xn().getDocument(e,t.text);return{text:await Ps(t,n.getText(),"New Text"),diagnostics:await Ps(t,n.getText(),"File Diagnostics")}});Q.onRequest("devicetree/formatTextEdits",async t=>{await Oe();let e=xn().getDocument(Se(t.textDocument.uri),t.text),n=e.positionAt(e.getText().length),r=He.TextEdit.replace(He.Range.create(He.Position.create(0,0),n),""),i=Jn(e,t.edits),o=await Ps({...t,ranges:void 0},i,"New Text").catch(()=>i);return r.newText=o,r});Q.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await Oe();let n=Se(t);vn({fsPath:n});let r=Un(n);if(!r)return[];let i=e?(await r.getDiagnostics()).get(n):(await r.getSyntaxIssues(void 0,s=>uo(s.raw,n,!!e)?s:void 0)).get(n);if(i?.length)return i});Q.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await Oe();let n=Nn(Ie,{id:e});return n?t.map(r=>{let i=Uc(r,n.macros),s=Me(i);return{macro:r,evaluated:typeof s=="number"?s:i}}):[]});Q.onRequest("devicetree/memoryViews",async({ctxId:t})=>{let e=Nn(Ie,{id:t});if(!e)return;await e?.stable();let n=await e.getRuntime(),r=n.rootNode.getMemoryViews(n.context.macros).sort((o,a)=>At(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=aB(Array.from(i.values()));return{trees:s,treeStr:cB(s)}});Q.onRequest("devicetree/zephyrTypeBindings",async t=>(await Oe(),t?Nn(Ie,{id:t})?.bindingLoader?.getZephyrContextBinding():void 0));Q.onRequest("devicetree/contextMacroNames",async t=>{if(await Oe(),!t)return;let e=Nn(Ie,{id:t});return Array.from(e?.macros.keys()??[])});Q.onRequest("devicetree/locationScopedInformation",async t=>{await Oe();let e=Nn(Ie,{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 wt(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])})});
|
|
332
|
+
`)}var Ie=[],le,Ys,og=new WeakMap,Wu=new Map;iB();var cg=new Map,uB=t=>{t.settings.disableFileWatchers||t.getContextFiles().forEach(e=>{Wu.has(e)||Wu.set(e,new sg(e,Tk,()=>{let n=Ju(e),r=cg.get(e);return!n||r===void 0?!1:r!==n.version})),Wu.get(e)?.watch()})},gk=async t=>{let e=Ie.indexOf(t);if(e===-1)return;Gu(t,void 0,!0),og.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let n=await Js(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}),Ie.splice(e,1),await _k(),t===le&&(le=void 0,Ie.length)){let r=Ys?Nn(Ie,{fsPath:Ys}):void 0;r??=Ie[0],console.log("Active context was deleted. Forcing active to",r.id),await vn({id:r.id},!0)}t.settings.disableFileWatchers||t.getContextFiles().map(r=>{Wu.get(r)?.unwatch()}),setTimeout(async()=>{await Oe();let r=new Set(Ie.flatMap(i=>i.getContextFiles()));t.getContextFiles().map(i=>{r.has(i)||xn().reset(i)})},2e3),t.bindingLoader?.dispose()},pQ=t=>{let e=og.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},Oe=async()=>{await Promise.all(Ie.map(pQ))},yk=async(t,e)=>(await dB(e)).indexOf(t)!==-1,dB=async t=>{let e=await fB(t);return Ie.filter(n=>!e.some(r=>r===n))},fB=async t=>{let e=await mk(t);return Ie.filter(n=>e.contexts.find(r=>Vi(r)===n.id))},hQ=async t=>{let e=await bQ(t);return Ie.filter(n=>e.contexts.find(r=>Vi(r)===n.id))},mQ=async(t,e)=>(await hQ(e)).indexOf(t)!==-1,gQ=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))},yQ=async t=>{if(!await yk(t))return;let e=await dB(),n=await fB(),r=await Ff(e);if(Ie.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 gQ(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(gk))},Q=(0,He.createConnection)(He.ProposedFeatures.all),ln=new He.TextDocuments(Vt),pB=!1,ag=!1,hB=!1,mB=!1,gB=!1,pk;Q.onInitialize(async t=>{pk=t.workspaceFolders??[],Q.console.log(`[Server(${process.pid}) ${pk?.at(0)?.uri} Version 0.8.5 ] Started and initialize received`);let e=t.capabilities;pB=!!(e.workspace&&e.workspace.configuration),ag=!!(e.workspace&&e.workspace.workspaceFolders),hB=!!e.workspace?.diagnostics?.refreshSupport,mB=!!e.workspace?.semanticTokens?.refreshSupport,gB=!!e.workspace?.foldingRange?.refreshSupport;let n={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:He.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[He.CodeActionKind.QuickFix,He.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:Of,tokenModifiers:Mf},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,documentRangeFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return ag&&(n.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),await bB(t.initializationOptions),n});var hk,TQ={tabSize:8,insertSpaces:!1,trimTrailingWhitespace:!0,insertFinalNewline:!0,wordWrapColumn:100};Q.onInitialized(async()=>{if(pB&&(Q.client.register(He.DidChangeConfigurationNotification.type,{}),!hk)){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"],removeMacroMultiline:e?.["editor.removeMacroMultiline"],wrapLongLines:e?.["editor.wrapLongLines"],indentExpressions:e?.["editor.indentExpressions"],removeEmptyReferences:e?.["editor.removeEmptyReferences"],removeEmptyNodes:e?.["editor.removeEmptyNodes"],removeEmptyRoots:e?.["editor.removeEmptyRoots"],sortNodesAndProperties:e?.["editor.sortNodesAndProperties"]};(t||n)&&(hk={...t,...n})}ag&&Q.workspace.onDidChangeWorkspaceFolders(async t=>{Q.console.log("Workspace folder change event received"),await Xu()})});Q.onRequest("workspace/workspaceFolders",async()=>pk??null);var vQ=async t=>{let e=yB();return e={...Ks,...e},Vu(e,t??await Yu())},mk=async t=>{let e=SQ();return e={...Ks,...e},Vu(e,t??await Yu())},bQ=async t=>{let e=kQ();return e={...Ks,...e},Vu(e,t??await Yu())},Ku=async t=>{let e=_Q();return e={...Ks,...e},Vu(e,t??await Yu())},Yu=async()=>ag?await Q.workspace.getWorkspaceFolders()??[]:[],lB=async t=>{let e=Nn(Ie,{id:Vi(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=Vi(t);console.log(`(ID: ${n}) New context [${t.ctxName}]`),console.log(`(ID: ${n}) Settings: ${JSON.stringify(t,void 0," ")}`);let r=(0,bc.join)((0,bc.dirname)(t.dtsFile),"dts","bindings"),i=new up(t,hk??TQ,t.bindingType?jF({zephyrBindings:t.zephyrBindings?[r,...t.zephyrBindings]:[r],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ie.push(i);let s=performance.now();await i.stable(),console.log(`(ID: ${n}) New context took ${performance.now()-s}ms to start [${t.ctxName}]`),uB(i);let o=await Js(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 yQ(i),await _k(),i},Xu=async()=>{let t=await mk(),e=await Ku();e.allowAdhocContexts||(e=await mk());let n=e.contexts.map(Vi),r=Ie.filter(i=>!n.includes(i.id));await Promise.all(r.map(gk)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await lB(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await vQ()).contexts?.reduce((s,o)=>s.then(async()=>{Nn(Ie,{fsPath:o.dtsFile})||await lB(o)}),Promise.resolve()),setTimeout(async()=>{Ys?await vn({fsPath:Ys}):!le&&Ie.length&&(console.log(`No active context using first context (ID: ${Ie[0].id}) [${Ie[0].ctxNames.join(",")}]`),await vn({id:Ie[0].id}))})},Wr,Xs,zu=new Map,vc=new Map,_Q=()=>!Xs&&!Wr?void 0:{...Xs,...Wr,contexts:[...Wr?.contexts??[],...Array.from(vc.values()),...Array.from(zu.values())]},yB=()=>!Xs&&!Wr?void 0:{...Xs,...Wr,contexts:[...Array.from(zu.values())]},SQ=()=>!Xs&&!Wr?void 0:{...Xs,...Wr,contexts:[...Wr?.contexts??[],...Array.from(vc.values())]},kQ=()=>!Xs&&!Wr?void 0:{...Wr,contexts:[...Wr?.contexts??[]]};function PQ(t){let e={...t};for(let n in e)e[n]===null&&delete e[n];return e}var TB=async()=>{let t=await Ku();console.log("Resolved settings",JSON.stringify(t,void 0," ")),Q.sendNotification("devicetree/settingsChanged",t),await Xu(),Oe().then(()=>{hB&&Q.languages.diagnostics.refresh()})},NQ=async()=>{let t=le?.getContextFiles();await Promise.all(Array.from(ln.keys()).filter(Yt).map(async e=>{t?.some(n=>pe(n,Se(e)))||await Q.sendDiagnostics({uri:e,version:ln.get(e)?.version,diagnostics:[{severity:He.DiagnosticSeverity.Information,range:He.Range.create(He.Position.create(0,0),He.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},Tk=async t=>{let e=mT(Ie,t);if(e.length)e.sort((n,r)=>n===le?-1:r===le?1:0).forEach(n=>{og.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?vB(n):[],l=n.getContextFiles();if(await n.reevaluate(t),uB(n),l.forEach(p=>Wu.get(p)?.unwatch()),a&&Sk(n)?.length&&(vk(n).then(p=>{let m=p.items.map(h=>({uri:h.uri,version:h.version??void 0,diagnostics:h.items}));Gu(n,c.filter(h=>m.every(y=>y.uri!==h.uri))),m.forEach(h=>{Q.sendDiagnostics(h)}),Qu.set(n,!0)}),Ys)){let p=n.getFsPathParser(Ys);p&&setTimeout(()=>{p.latestSemanticTokensBuilt||Q.languages.semanticTokens.refresh()},50)}let[u,d]=await Promise.all([Js(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)})});og.set(n,{abort:r,promise:i})});else{if((await Ku()).allowAdhocContexts===!1)return;await Xu(),await vn({fsPath:t})}},RQ=t=>ln.keys().find(e=>pe(Se(e),t)),Ju=t=>{let e=RQ(t);if(e)return ln.get(e)},vB=t=>t.getContextFiles().map(e=>({uri:ue(e),version:Ju(e)?.version,diagnostics:[]})),Qu=new WeakMap,Gu=async(t,e=vB(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:ln.get(i.uri)?.version,diagnostics:[]}))),Qu.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-r)},vk=async t=>{await t.stable();let e=performance.now(),n=await t.getDiagnostics(),r=await Promise.all(t.getContextFiles().map(async i=>{let s=Ju(i),o=[];return s&&t.settings.showFormattingErrorAsDiagnostics&&o.push(...(await Ps({textDocument:s,options:t.formattingOptions},s.getText(),"File Diagnostics").catch(()=>[])).map(a=>a.diagnostic())),{uri:ue(i),kind:He.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]}},bk=async t=>{let{items:e}=await vk(t);e.map(n=>({uri:n.uri,version:n.version??void 0,diagnostics:n.items})).forEach(async n=>{Q.sendDiagnostics(n)}),Qu.set(t,!0)},_k=async()=>{let t=await Promise.all(Ie.map(e=>Js(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("==============================")},Js=async(t,e)=>{let n=await yk(t,e),r=!n&&await mQ(t,e);return{ctx:t,type:n?"Ad Hoc":r?"User":"3rd Party"}},vn=async(t,e=!1)=>{if("fsPath"in t){if(!Yt(t.fsPath))return!1;Ys=t.fsPath,console.log("Active File Uri",Ys)}let n=await Ku();if(le&&!e&&!n.autoChangeContext||(await Oe(),!e&&le?.getContextFiles().find(o=>"fsPath"in t&&pe(o,t.fsPath))))return!1;let r=le,i=Nn(Ie,t),s=r!==i;return s&&(r&&Gu(r),le=i,i?(Js(i).then(async o=>{let a=await i.getFileTree();!i||i!==le&&!Ie.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})}),Sk(i)?.length&&bk(i),await _k()):Q.sendNotification("devicetree/newActiveContext",void 0)),gB&&Q.languages.foldingRange.refresh(),mB&&Q.languages.semanticTokens.refresh(),s},Yt=t=>[".dts",".dtsi",".dtso",".overlay"].some(e=>t.endsWith(e));ln.listen(Q);var Sk=t=>t?.getContextFiles()?.filter(e=>Ju(e));ln.onDidSave(t=>{cg.set(Se(t.document.uri),t.document.version)});ln.onDidClose(async t=>{let e=Se(t.document.uri);if(!Yt(e))return;cg.delete(e);let n=mT(Ie,e);if(n.length===0){zu.delete(e),Q.sendDiagnostics({uri:t.document.uri,version:ln.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(n.map(async r=>{!!Sk(r)?.filter(s=>s!==e).length?le?.getContextFiles().some(s=>pe(s,e))?le?.getContextFiles().some(s=>pe(s,e))&&(await Gu(le),await bk(le)):Q.sendDiagnostics({uri:t.document.uri,version:ln.get(t.document.uri)?.version,diagnostics:[]}):await yk(r)?(await gk(r),zu.delete(r.settings.dtsFile)):Gu(r)}))});ln.onDidOpen(async t=>{let e=Se(t.document.uri);if(!Yt(e))return;cg.set(e,t.document.version),await Oe(),NQ();let n=Nn(Ie,{fsPath:e});if(console.log("onDidOpen",n?.id,e),n)n!==le?await vn({id:n.id}):n===le&&(!Qu.get(n)||n.getContextFiles().some(r=>!pe(r,e)))&&await bk(n);else{let r={ctxName:(0,bc.basename)(e),dtsFile:e};zu.set(e,r),await Tk(e)}});ln.onDidChangeContent(async t=>{let e=Se(t.document.uri);if(!Yt(e))return;let n=t.document.getText(),r=xn();r.needsRenew(e,n)&&(console.log("Content changed",e),r.renewLexer(e,n),await Tk(e))});var bB=async t=>{t?.settings?.devicetree&&(Wr=KF(PQ(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await TB())};Q.onDidChangeConfiguration(async t=>{await bB(t)});Q.listen();Q.languages.diagnostics.onWorkspace(async()=>{await Oe();let t=le;return t?vk(t).finally(()=>{Qu.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 UA(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return[];await Oe(),vn({fsPath:e});let n=Un(e);return n?[...await RD(t,n),...await b0(t,n)]:[]});Q.onCompletionResolve(t=>t);var Un=t=>{let e=yB();return Nn(Ie,{fsPath:t},le,e?.preferredContext)};Q.onDocumentSymbol(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return[];await Oe();let n=Un(e);return n?n.getFsPathParser(e)?.getDocumentSymbols(e):[]});Q.onWorkspaceSymbol(async()=>{await Oe();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(!Yt(e))return{data:[]};try{await Oe();let n=Un(e),r=new He.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 Oe();let e=Se(t.textDocument.uri);return Yt(e)?Un(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&le?le.bindingLoader?.getDocumentLinks?.(ln.get(t.textDocument.uri))??[]:[]});Q.onPrepareRename(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return KA(t,n)});Q.onRenameRequest(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return GA(t,n)});Q.onReferences(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return HA(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 JA(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e),r=(await n?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>He.Location.create(i.target,i.range))??[];return r.length?r:XA(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 t0(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return e0(t,n)});Q.onCodeAction(async t=>{let e=Se(t.textDocument.uri);if(Yt(e))return r0(t)});var _B=async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);if(!n)return[];if((await n.getSyntaxIssues(void 0,l=>uo(l.raw,e,!1)?l:void 0)).get(e)?.length)return[];let i=ln.get(t.textDocument.uri)??xn().getDocument(e),s=i.getText(),o=await Ps({...t,options:{...n.formattingOptions,...t.options}},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[He.TextEdit.replace(He.Range.create(He.Position.create(0,0),He.Position.create(i.lineCount,c)),o)]};Q.onDocumentRangeFormatting(_B);Q.onDocumentFormatting(_B);Q.onHover(async t=>{let e=Se(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&le&&le.bindingLoader?.type==="Zephyr")return HO(t,le,ln.get(t.textDocument.uri));if(!Yt(e))return;await Oe();let n=Un(e);return(await _0(t,n)).at(0)});Q.onFoldingRanges(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe();let n=Un(e),r=n?.isInContext(e);if(!n||!r)return[];let i=(await n.getAllStableParsers()).find(s=>s.getFiles().some(o=>o===e));return i?HF(e,i):[]});Q.onTypeDefinition(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return GF(t,n)});Q.onSignatureHelp(async t=>{let e=Se(t.textDocument.uri);if(!Yt(e))return;await Oe(),vn({fsPath:e});let n=Un(e);return tB(t,n)});Q.onRequest("devicetree/getContexts",async()=>(await Oe(),Promise.all(Ie.map(async t=>{let e=await Js(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 Oe(),console.log("devicetree/setActive",t),await vn(t,!0)));Q.onRequest("devicetree/getActiveContext",async()=>{if(await Oe(),console.log("devicetree/getActiveContext"),!le)return;let t=await Js(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 Oe(),Xs=t,console.log("Integration Settings",t),await TB()});Q.onRequest("devicetree/requestContext",async t=>{await Oe();let e=await Yu(),n=await Ku(e),r=await lk(t,n,e);if(!r)throw console.log("Failed to resolve context",t),new Error("Failed to resolve context");console.log("devicetree/requestContext",r);let i=Vi(r),s=Array.from(vc).find(([,c])=>c.ctxName===t.ctxName);if(s){let c=s[0].split(":",1)[0];Nn(Ie,{name:r.ctxName.toString()})?.removeCtxName(r.ctxName),console.log(`Removing integration context with ID ${c} and name ${t.ctxName}`),vc.delete(s[0])}vc.set(`${i}:${t.ctxName}`,t),await Xu();let o=Ie.find(c=>c.id===i);if(!o)throw new Error("Failed to create context");let a=await Js(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 Oe(),vc.delete(`${t}:${e}`);let n=Nn(Ie,{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 Xu()}});Q.onRequest("devicetree/compiledDtsOutput",async t=>{if(await Oe(),!t)return;let e=Nn(Ie,{id:t});if(!e||!e.settings.dtsFile){console.log("Context or DTS file not found for ID",t);return}let n=await e.toFullString();return Ps({textDocument:{uri:ue(e.settings.dtsFile)},options:e.formattingOptions},n,"New Text").catch(()=>n)});Q.onRequest("devicetree/serializedContext",async t=>{if(await Oe(),!t)return;let e=Nn(Ie,{id:t}),n=performance.now();return e?.serialize().finally(()=>{console.info("serializedContext",performance.now()-n)})});Q.onRequest("devicetree/activePath",async t=>{if(await Oe(),!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 wt(t,le,n=>[e(n)])).at(0)});Q.onRequest("devicetree/customActions",async t=>(await Oe(),ZF(t,le)));Q.onRequest("devicetree/activeFsPath",async t=>{await Oe(),vn({fsPath:t})});Q.onRequest("devicetree/formattingText",async t=>{let e=Se(t.textDocument.uri),n=Ju(e)??xn().getDocument(e,t.text);return{text:await Ps(t,n.getText(),"New Text"),diagnostics:await Ps(t,n.getText(),"File Diagnostics")}});Q.onRequest("devicetree/formatTextEdits",async t=>{await Oe();let e=xn().getDocument(Se(t.textDocument.uri),t.text),n=e.positionAt(e.getText().length),r=He.TextEdit.replace(He.Range.create(He.Position.create(0,0),n),""),i=Jn(e,t.edits),o=await Ps({...t,ranges:void 0},i,"New Text").catch(()=>i);return r.newText=o,r});Q.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await Oe();let n=Se(t);vn({fsPath:n});let r=Un(n);if(!r)return[];let i=e?(await r.getDiagnostics()).get(n):(await r.getSyntaxIssues(void 0,s=>uo(s.raw,n,!!e)?s:void 0)).get(n);if(i?.length)return i});Q.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await Oe();let n=Nn(Ie,{id:e});return n?t.map(r=>{let i=Uc(r,n.macros),s=Me(i);return{macro:r,evaluated:typeof s=="number"?s:i}}):[]});Q.onRequest("devicetree/memoryViews",async({ctxId:t})=>{let e=Nn(Ie,{id:t});if(!e)return;await e?.stable();let n=await e.getRuntime(),r=n.rootNode.getMemoryViews(n.context.macros).sort((o,a)=>At(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=aB(Array.from(i.values()));return{trees:s,treeStr:cB(s)}});Q.onRequest("devicetree/zephyrTypeBindings",async t=>(await Oe(),t?Nn(Ie,{id:t})?.bindingLoader?.getZephyrContextBinding():void 0));Q.onRequest("devicetree/contextMacroNames",async t=>{if(await Oe(),!t)return;let e=Nn(Ie,{id:t});return Array.from(e?.macros.keys()??[])});Q.onRequest("devicetree/locationScopedInformation",async t=>{await Oe();let e=Nn(Ie,{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 wt(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])})});
|