@kitelev/exocortex-cli 17.7.4 → 17.7.6
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/index.js +7 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// @kitelev/exocortex-cli v17.7.
|
|
2
|
+
// @kitelev/exocortex-cli v17.7.6
|
|
3
3
|
// CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
|
|
4
4
|
// License: MIT
|
|
5
5
|
|
|
@@ -116,7 +116,7 @@ ${n}}`}default:throw new zf(`Unsupported operation type for SPARQL generation: $
|
|
|
116
116
|
`)}generateTriple(e){let t=this.generateElement(e.subject),n=this.generatePredicate(e.predicate),i=this.generateElement(e.object);return`${t} ${n} ${i}`}generatePredicate(e){return"pathType"in e?this.generatePropertyPath(e):this.generateElement(e)}generatePropertyPath(e){let t=e.items.map(n=>"pathType"in n?`(${this.generatePropertyPath(n)})`:`<${n.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}generateElement(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":{let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}case"blank":return`_:${e.value}`;default:throw new zf(`Unknown element type: ${e.type}`)}}generateValues(e,t){let n=" ".repeat(t);if(e.variables.length===0||e.bindings.length===0)return"";if(e.variables.length===1){let o=e.variables[0],c=e.bindings.map(l=>{let u=l[o];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ");return`${n}VALUES ?${o} { ${c} }`}let i=e.variables.map(o=>`?${o}`).join(" "),s=e.bindings.map(o=>`(${e.variables.map(l=>{let u=o[l];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ")})`);return`${n}VALUES (${i}) {
|
|
117
117
|
${s.map(o=>`${n} ${o}`).join(`
|
|
118
118
|
`)}
|
|
119
|
-
${n}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(n=>this.generateExpression(n)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),n=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${n})`:`${t} IN (${n})`}default:throw new zf(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let n of e.triples)this.collectVariablesFromTriple(n,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let n of e.variables)t.add(n);break;case"project":for(let n of e.variables)t.add(n);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let n of e.variables)t.add(n);for(let n of e.aggregates)t.add(n.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let n of e.operands)this.collectVariablesFromExpression(n,t);break;case"function":case"functionCall":for(let n of e.args)this.collectVariablesFromExpression(n,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let n of e.list)this.collectVariablesFromExpression(n,t);break}}};Hf.SPARQLGenerator=yI});var Yf=T(Pi=>{"use strict";var eZ=Pi&&Pi.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),tZ=Pi&&Pi.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),tM=Pi&&Pi.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&eZ(t,e,n[i]);return tZ(t,e),t}})();Object.defineProperty(Pi,"__esModule",{value:!0});Pi.QueryExecutor=Pi.ExoQLQueryExecutor=Pi.QueryExecutorError=void 0;var rZ=$A(),nZ=Ab(),iZ=iI(),sZ=oI(),oZ=Uk(),aZ=Vk(),cZ=zk(),lZ=hI(),uZ=Kk(),fZ=Xk(),dZ=Zk(),pZ=eM(),hZ=Le(),mZ=He(),gZ=bb(),En="http://www.w3.org/2001/XMLSchema#",yZ=new Set([`${En}integer`,`${En}decimal`,`${En}float`,`${En}double`,`${En}nonPositiveInteger`,`${En}negativeInteger`,`${En}long`,`${En}int`,`${En}short`,`${En}byte`,`${En}nonNegativeInteger`,`${En}unsignedLong`,`${En}unsignedInt`,`${En}unsignedShort`,`${En}unsignedByte`,`${En}positiveInteger`]),Kf=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};Pi.QueryExecutorError=Kf;var Db=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let n=t.resolveClassHierarchy===!1?e:new dZ.ClassHierarchyResolvingStore(e);this.tripleStore=n,this.bgpExecutor=new rZ.BGPExecutor(n),this.filterExecutor=new nZ.FilterExecutor,this.optionalExecutor=new iZ.OptionalExecutor,this.unionExecutor=new sZ.UnionExecutor,this.minusExecutor=new oZ.MinusExecutor,this.valuesExecutor=new aZ.ValuesExecutor,this.aggregateExecutor=new cZ.AggregateExecutor,this.constructExecutor=new lZ.ConstructExecutor,this.serviceExecutor=new uZ.ServiceExecutor(t.serviceConfig),this.graphExecutor=new fZ.GraphExecutor(n),this.sparqlGenerator=new pZ.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(n)}async evaluateExistsPattern(e,t){let n=this.substituteVariables(e,t);for await(let i of this.execute(n))if(t.merge(i)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let n of this.execute(e))t.push(n);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new Kf(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let n=new Set;for(let o of t)for(let c of o.variables())n.add(c);let i=this.collectOperationVariables(e.right);if([...n].some(o=>i.has(o)))for(let o of t){let c=this.substituteVariables(e.right,o);for await(let l of this.execute(c)){let u=o.merge(l);u!==null&&(yield u)}}else{let o=[];for await(let c of this.execute(e.right))o.push(c);for(let c of t)for(let l of o){let u=c.merge(l);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>tM(ha())),n=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(n.has(o)){let c=i.get(o);c!==void 0&&s.set(o,c)}yield s}}async*executeOrderBy(e){let t=[];for await(let n of this.execute(e.input))t.push(n);t.sort((n,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,n),c=this.getExpressionValue(s.expression,i),l=0;if(o===void 0&&c===void 0?l=0:o===void 0?l=1:c===void 0?l=-1:typeof o=="number"&&typeof c=="number"?l=o-c:l=String(o).localeCompare(String(c)),s.descending&&(l=-l),l!==0)return l}return 0});for(let n of t)yield n}async*executeSlice(e){let t=0,n=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=n){if(i!==void 0&&t-n>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeReduced(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let n=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of n)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of n)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let n of this.execute(e.input)){let i=n.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,n):this.evaluateExtendExpression(e.expression,n);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let n of this.execute(e.left))t.push(n);for(let n of t){let i=this.substituteVariables(e.right,n);for await(let s of this.execute(i)){let o=n.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let n=JSON.parse(JSON.stringify(e));return this.substituteInOperation(n,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let n=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(n.input&&(n.input=this.substituteInOperation(n.input,t)),n.left&&(n.left=this.substituteInOperation(n.left,t)),n.right&&(n.right=this.substituteInOperation(n.right,t)),n.pattern&&(n.pattern=this.substituteInOperation(n.pattern,t)),n.query&&(n.query=this.substituteInOperation(n.query,t)),n.where&&(n.where=this.substituteInOperation(n.where,t)),n.expression&&this.substituteInExpression(n.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.type==="variable"&&typeof e.name=="string"){let n=this.termToAlgebraNode(t.get(e.name));if(n!==null){delete e.name;for(let[i,s]of Object.entries(n))e[i]=s}}if(e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let n of e.operands)this.substituteInExpression(n,t);if(e.args)for(let n of e.args)this.substituteInExpression(n,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let n of e.list)this.substituteInExpression(n,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let n=this.termToAlgebraNode(t.get(e.value));if(n!==null)return n}return e}termToAlgebraNode(e){if(e==null)return null;let t=e;return e instanceof hZ.IRI||t.termType==="NamedNode"?{type:"iri",value:e.value}:t.termType==="Literal"||typeof t.value=="string"?{type:"literal",value:t.value,datatype:t.datatype?.value??t._datatype?.value,language:t.language??t._language}:null}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(n,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{n.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(n,i):yield*this.execute(n)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:n}=await Promise.resolve().then(()=>tM(ha()));yield new n;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let n=t.get(e.name);if(!n)return;if(n instanceof mZ.Literal){let i=n.datatype?.value;if(i===`${En}dayTimeDuration`)try{return gZ.DateTimeFunctions.parseDayTimeDuration(n.value)}catch{return n.value}if(i&&yZ.has(i)){let s=parseFloat(n.value);if(!Number.isNaN(s))return s}return n.value}return n.value??n.id??String(n)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="bgp"&&n.triples)for(let i of n.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(n.type==="values"&&n.variables)for(let i of n.variables)t.add(i);n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.type==="extend"&&n.variable&&t.add(n.variable),n.input&&this.collectVarsFromOperation(n.input,t),n.left&&this.collectVarsFromOperation(n.left,t),n.right&&this.collectVarsFromOperation(n.right,t),n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.query&&this.collectVarsFromOperation(n.query,t),n.where&&this.collectVarsFromOperation(n.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let n=e;n.type==="variable"&&t.add(n.value),n.type==="quoted"&&(this.collectVarsFromElement(n.subject,t),this.collectVarsFromElement(n.predicate,t),this.collectVarsFromElement(n.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="variable"&&n.name&&t.add(n.name),n.type==="exists"&&n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.left&&this.collectVarsFromExpressionTree(n.left,t),n.right&&this.collectVarsFromExpressionTree(n.right,t),n.operands)for(let i of n.operands)this.collectVarsFromExpressionTree(i,t);if(n.args)for(let i of n.args)this.collectVarsFromExpressionTree(i,t);if(n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.list)for(let i of n.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new Kf("executeConstruct requires a CONSTRUCT operation");let t=await this.executeAll(e.where);return this.constructExecutor.execute(e.template,t)}isAskQuery(e){return e.type==="ask"}async executeAsk(e){if(e.type!=="ask")throw new Kf("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};Pi.ExoQLQueryExecutor=Db;Pi.QueryExecutor=Db});var dM=T(ma=>{"use strict";var bZ=ma&&ma.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_Z=ma&&ma.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(ma,"__esModule",{value:!0});ma.CommandResolver=void 0;var SZ=lt(),wZ=mh(),EZ=gc(),gr=Le(),cr=He(),X=At(),rM=uc(),nM=Xp(),vZ=Bl(),iM=yc(),sM=P0(),Xf=zv(),oM=WN(),TZ=Tf(),AZ=Of(),IZ=Yf(),Jl=10,Lb="exo__Asset",RZ=Jl+1,aM="08cec529-90eb-4d43-88de-ceecccea12b0",CZ=X.Namespace.EXOCMD.term("SubstitutionToken").value,cM=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","createdInstance","targetClassSelf"]);function xZ(r,e){return`__SUBSTITUTE__${r}__${e}__`}a(xZ,"buildSubstitutionMarker");function OZ(r,e,t){let n=(0,vZ.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${r}__${e}__${n}__`}a(OZ,"buildParameterisedMarker");var lM="3f28af98-c031-4718-8ba2-44ad0b012c52",PZ=X.Namespace.EXOCMD.term("TokenInvocation").value,uM="29e2c8f8-2d27-4e58-b467-2e85d46f8122",fM="universal-default-template",bI=class{static{a(this,"CommandResolver")}warnOnce(e){this._warnedMessages.has(e)||(this._warnedMessages.add(e),this.logger.warn(e))}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null}constructor(e,t=wZ.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorDepthCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._fallbackWarnedKeys=new Set,this._ambiguousRefWarnedKeys=new Set,this._warnedMessages=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,n){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${n??""}`,o=this.multiCache.get(s);if(o)return o;let c=n?await this.expandPrototypeChain(n):void 0,l=await this.expandClassHierarchy(t),u=new Map;for(let[h,g]of l){let m=await this.resolveForAsset(e,h,c);for(let b of m){let _=this.getBindingPriority(b.binding)===2?g:0,S=u.get(b.binding.id);(!S||_<S.depth)&&u.set(b.binding.id,{rc:b,depth:_})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let g of h.binding.overrides)f.add(g);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,g)=>{let m=this.getBindingPriority(h.rc.binding),b=this.getBindingPriority(g.rc.binding);return m!==b?m-b:h.depth!==g.depth?h.depth-g.depth:(h.rc.binding.order??100)-(g.rc.binding.order??100)});let p=d.map(h=>h.rc);return this.multiCache.set(s,p),p}async expandClassHierarchy(e){let t=new Map;for(let c of e){if(c===Lb){t.set(c,new Set);continue}let l=[];try{l=await this.getClassAncestors(c)}catch{l=[]}t.set(c,new Set(l))}let n=a(c=>{for(let l of e)if(l!==c&&t.get(l)?.has(c)&&!t.get(c)?.has(l))return!0;return!1},"isAncestorOfSibling"),i=e.filter(c=>!n(c)),s=new Map,o=a((c,l)=>{let u=s.get(c);(u===void 0||l<u)&&s.set(c,l)},"setMin");for(let c of i){if(o(c,0),this.looksLikeUUID(c))try{let u=await this.resolveLabelByUID(c);u&&o(u,0)}catch{}if(c===Lb)continue;let l=[];try{l=await this.getClassAncestorsWithDepth(c)}catch{l=[]}for(let{ref:u,depth:f}of l)o(u,f)}return s.has(Lb)||s.set(Lb,RZ),s}async resolveForAsset(e,t,n){let i=typeof n=="string"?`s:${n}`:n?`c:${n.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let c=typeof n=="string"?await this.expandPrototypeChain(n):n,l=await this.findBindings(t,c,e),u=[];for(let f of l){let d=await this.loadCommand(f.commandRef,{targetClass:f.targetClass});if(!d)continue;let p=f.precondition?{...d,precondition:f.precondition}:d;u.push({command:p,binding:f})}return u.sort((f,d)=>{let p=this.getBindingPriority(f.binding),h=this.getBindingPriority(d.binding);return p!==h?p-h:(f.binding.order??100)-(d.binding.order??100)}),this.cache.set(s,u),u}async loadCommand(e,t){let n=await this.findSubjectByUID(e);if(!n||(await this.tripleStore.match(n,X.Namespace.RDF.term("type"),X.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.readAssetLabel(n)??"Unknown Command",o=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_labelTemplate")),c=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_icon")),l=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(n),g=await this.loadLinkedGrounding(n,0,t);return g?{id:e,name:s,labelTemplate:o??void 0,icon:c??void 0,precondition:h??void 0,grounding:g,confirmMessage:l??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,n){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,X.Namespace.RDF.term("type"),X.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let c of s){let l=c.subject,u=await this.loadBindingDefinition(l);u&&this.bindingMatches(u,e,i,n)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,X.Namespace.RDF.term("type"),X.Namespace.EXOCMD.term("Command")),t=[],n=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,X.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let c=await this.getLiteralValue(s,X.Namespace.EXO.term("Asset_uid"));if(!c){this.warnOnce(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let l=await this.loadCommand(c);if(!l){this.warnOnce(`[CommandResolver] paletteEnabled command ${c} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,X.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,X.Namespace.EXOCMD.term("Command_cliName")),d=u??f??c;if(n.has(d)){this.warnOnce(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${c}`);continue}n.add(d),t.push({command:l,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear(),this.clearUniversalCache()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let n=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let c=await this.evaluateSelectSnippet(o,t);n=n.replace(s,c)}return n}extractPlaceholders(e){let t=[],n=0;for(;n<e.length;)if(e[n]==="{"){let i=1,s=n+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(n,s),c=e.slice(n+1,s-1);t.push({full:o,body:c})}n=s}else n++;return t}async evaluateSelectSnippet(e,t){try{let n=e.replace(/\$target/g,`<${t}>`),s=new TZ.ExoQLParser().parse(n),c=new AZ.ExoQLAlgebraTranslator().translate(s),u=await new IZ.ExoQLQueryExecutor(this.tripleStore).executeAll(c);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let p=f.get(d[0]);return p?p instanceof cr.Literal||p instanceof gr.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.readAssetLabel(e)??"",i=await this.getLinkedUID(e,X.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,X.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,X.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),c=await this.getLinkedValue(e,X.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!c)return null;let l=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,X.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),g=await this.getLinkedUIDs(e,X.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:n,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:c??void 0,position:l??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:g.length>0?g:void 0}}async loadLinkedStyle(e,t){let n=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(n.length>0){let s=n[0].object,o=null;if(s instanceof gr.IRI)o=await this.resolveRefIriSubject(s);else if(s instanceof cr.Literal){let c=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(c)}if(o){let c=await this.loadStyleAsset(o);if(c)return c}this.warnOnce(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_variant"));if(i!==null){let s=this.coerceVariant(i,t);if(s!==void 0)return{id:`inline:${t}`,label:"",variant:s,inline:!0}}return null}async loadStyleAsset(e){let t=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.readAssetLabel(e)??"",i=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),c=this.coerceBoolean(o),l=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=l!==null?this.coerceLabelClass(l,t):void 0,f=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_source")),g=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:n,variant:s,showIcon:c,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:g,inline:!1}}coerceVariant(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Xf.COMMAND_VARIANT_VALUES.includes(n))return n;this.warnOnce(this.capWarning(`CommandBindingStyle variant "${n}" not in whitelist [${Xf.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Xf.LABEL_CLASS_VALUES.includes(n))return n;this.warnOnce(this.capWarning(`CommandBindingStyle labelClass "${n}" not in whitelist [${Xf.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Xf.STYLE_SOURCE_VALUES.includes(n))return n;this.warnOnce(this.capWarning(`CommandBindingStyle source "${n}" not in whitelist [${Xf.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,n,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&n){for(let s of n)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let n=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(n===i)return!0;let s=this.extractPathBasename(i);if(s&&s===n)return!0;let o=this.extractPathBasename(n);if(o&&o===i)return!0;let c=this.extractAlias(t);if(c&&n===c)return!0;let l=this.extractAlias(e);return!!(l&&l===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(n+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,X.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=await this.resolvePreconditionRef(n[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof gr.IRI)return this.resolveRefIriSubject(e);if(e instanceof cr.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,n){let i=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid")),s=await this.readAssetLabel(e)??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(n>=Jl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||c.length>0||l.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||c.length>0){let g=o.length>0?"all":"any",m=o.length>0?o:c,b=[];for(let _ of m)b.push(await this.loadChildPrecondition(_.object,p,n+1));return{id:i??"",label:s,composite:{op:g,children:b}}}let h=await this.loadChildPrecondition(l[0].object,p,n+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Precondition_hostFunction")),d=await this.loadPreconditionQueryRef(e);return!i||!u&&!f&&!d?null:{id:i,label:s,...u&&{sparqlAsk:u},...f&&{hostFunction:f},...d&&{query:d}}}async loadChildPrecondition(e,t,n){let i=await this.resolvePreconditionRef(e);if(!i){let c=e instanceof cr.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(c,"")}let s=await this.loadPreconditionSubject(i,t,n);if(s)return s;let o=await this.getLiteralValue(i,X.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let n=t[0].object;if(n instanceof gr.IRI)return await this.getLiteralValue(await this.resolveRefIriSubject(n),X.Namespace.EXO.term("Asset_uid"))??void 0;if(n instanceof cr.Literal)return this.normalizeWikilink(n.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,n){if(t>=Jl)return null;let i=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!n?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let c=await this.resolveGroundingRef(o.object);if(!c)continue;let l=await this.getObsidianName(c,X.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(l&&this.matchesReference(l,n.targetClass))return this.loadGroundingDefinition(c,t)}this.warnOnce(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${n.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof gr.IRI)return this.resolveRefIriSubject(e);if(e instanceof cr.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadGroundingByUid(e){let t=await this.findSubjectByUID(e);return t?this.loadGroundingDefinition(t,0):null}async loadGroundingDefinition(e,t){if(t>=Jl)return null;let n=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid"));if(!n)return null;let i=await this.readAssetLabel(e)??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let ae=await this.resolveLabelByUID(o);if(!ae)return this.warnOnce(`Grounding ${n}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=ae}if(s===rM.GroundingType.SERVICE_CALL){let ae=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_serviceId"));ae&&(o=ae)}let c=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetValueRef")),l=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let ae=await this.resolveLabelByUID(u);if(!ae)return this.warnOnce(`Grounding ${n}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=ae}else u&&(f=u);let d=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),g=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_appendExpression")),m=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_replaceFromExpression")),b=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_replaceToExpression")),_=await this.getObsidianWikilinkValue(e,X.Namespace.EXOCMD.term("Grounding_isDefinedBy")),S=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),A=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetClass"));if(A&&!this.looksLikeUUID(A)){let ae=await this.findUidByLabel(A);ae&&(A=ae)}let w=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetPrototype")),E=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_targetFolder")),R=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_linkBackProperty")),x=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_inputSchema")),P=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_incrementBy")),N=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_shiftDelta")),$;if(P!=null&&P!==""){let ae=Number.parseInt(String(P),10);Number.isFinite(ae)&&($=ae)}let k=await this.resolvePropertyDefaults(e,n),G=await this.resolveInheritanceRules(e,n),B=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_propertyDefaults"));B!==null&&B!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(n)&&(this.warnOnce(`Grounding ${n}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(n));let M;s===rM.GroundingType.COMPOSITE&&(M=await this.loadCompositeSteps(e,t+1));let ie;if(x)try{let ae=JSON.parse(x);ae?.properties&&(ie=Object.entries(ae.properties).map(([Ie,ye])=>{let Te=ye.type,Re=Te==="string"?ye.format==="asset-reference"?"assetRef":"text":Te,pe=ye.defaultValue!==void 0?ye.defaultValue:ye.default,q={name:Ie,type:Re,label:ye.title??Ie,required:Array.isArray(ae.required)&&ae.required.includes(Ie)};return pe!=null&&(q.defaultValue=String(pe)),typeof ye.targetClassUid=="string"&&(q.targetClassUid=ye.targetClassUid),q}))}catch{}let Z=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),te=Z!==null&&String(Z).trim().toLowerCase()==="true",V=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_labelTemplate")),H=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_direction")),he;if(H!=null){let ae=String(H).trim().toLowerCase();ae==="forward"||ae==="rollback"?he=ae:ae!==""&&this.warnOnce(`Grounding ${n}: exocmd__Grounding_direction value '${H}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let ze=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_bodyTemplate")),ce=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_templateRef")),ee=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),K=ee!==null&&String(ee).trim().toLowerCase()==="true",Y=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),ne=Y!==null&&String(Y).trim().toLowerCase()==="true",Ce=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_omitLabel")),U=Ce!==null&&String(Ce).trim().toLowerCase()==="true",fe={id:n,label:i,type:s,targetProperty:o??void 0,targetValueRef:c??void 0,targetValueLiteral:l??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:g??void 0,replaceFromExpression:m??void 0,replaceToExpression:b??void 0,sparqlUpdate:S??void 0,steps:M,targetClass:A??void 0,targetPrototype:w??void 0,targetFolder:E??void 0,linkBackProperty:R??void 0,incrementBy:$,shiftDelta:N??void 0,propertyDefault:k.length>0?k:void 0,inheritanceRule:G.length>0?G:void 0,isDefinedBy:_??void 0,prefillLabelWithDate:te||void 0,labelTemplate:V??void 0,direction:he,bodyTemplate:ze??void 0,templateRef:ce??void 0,cloneTargetBody:K||void 0,targetsCreatedInstance:ne||void 0,omitLabel:U||void 0};return ie&&(fe.inputSchema=ie),fe}async loadCompositeSteps(e,t){if(t>=Jl)return[];let n=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of n){let o=null;if(s.object instanceof gr.IRI)o=await this.resolveRefIriSubject(s.object);else if(s.object instanceof cr.Literal){let l=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(l)}if(!o)continue;let c=await this.loadGroundingDefinition(o,t);c&&i.push(c)}return i}async resolvePropertyDefaults(e,t){let n=await this.resolvePropertyDefaultsForSubject(e,t,X.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,oM.mergePropertyDefaults)(i.propertyDefaults,n):n}async resolvePropertyDefaultsForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[];for(let o of i){let c=await this.resolveRefTripleObject(o.object);if(!c)continue;let l=await this.getObsidianName(c,X.Namespace.EXOCMD.term("PropertyDefault_property"));if(!l){this.warnOnce(`Grounding ${t}: PropertyDefault asset <${c.value}> missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(l)?await this.resolveLabelByUID(l):l;if(!u){this.warnOnce(`Grounding ${t}: PropertyDefault property UID '${l}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(c,X.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.warnOnce(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await this.findUniversalSingleton();if(!e)return this.logger.debug("[CommandResolver] No exocmd__UniversalDefaultTemplate instance found in the store; universal property-defaults and inheritance-rules will not be applied. This verdict is cached until invalidateCache() is called \u2014 if the store was still warming up, the next invalidation re-resolves it."),this._universalCacheValue=null,null;let t=await this.resolvePropertyDefaultsForSubject(e,fM,X.Namespace.EXOCMD.term("Template_propertyDefault")),n=await this.resolveInheritanceRulesForSubject(e,fM,X.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:t,inheritanceRules:n},this._universalCacheValue}async findUniversalSingleton(){let e=X.Namespace.EXOCMD.term("UniversalDefaultTemplate"),t=e.value,i=(await this.tripleStore.match(void 0,X.Namespace.EXO.term("Instance_class"),e)).map(c=>c.subject).filter(c=>c instanceof gr.IRI);if(i.length>0)return this.pickUniversalSingleton(i);let s=await this.tripleStore.match(void 0,X.Namespace.EXO.term("Instance_class"),void 0),o=[];for(let c of s){let l=!1;if(c.object instanceof gr.IRI)l=c.object.value===t||c.object.value.includes(uM);else if(c.object instanceof cr.Literal){let u=this.unwrapWikilink(c.object.value);l=u==="exocmd__UniversalDefaultTemplate"||u===uM}l&&c.subject instanceof gr.IRI&&o.push(c.subject)}return this.pickUniversalSingleton(o)}pickUniversalSingleton(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=[...e].sort((n,i)=>n.value.localeCompare(i.value));return this.warnOnce(`Multiple UniversalDefaultTemplate singletons found (${t.length}); selecting deterministically by lexicographic UID order: ${t[0].value}`),t[0]}async resolveInheritanceRules(e,t){let n=await this.resolveInheritanceRulesForSubject(e,t,X.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,oM.mergeInheritanceRules)(i.inheritanceRules,n):n}async resolveInheritanceRulesForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[],o=t;for(let c of i){let l=await this.resolveRefTripleObject(c.object);if(!l)continue;let u=await this.resolveLabelRef(l,X.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(l,X.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(l,X.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let w=await this.getObsidianName(l,X.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!w||!w.trim()){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> has exocmd__InheritanceRule_targetClassCondition triple but ref is unresolvable \u2014 entire rule skipped (would otherwise apply unconditionally, broadening scope).`);continue}this.looksLikeUUID(w)?(h=w,p=await this.resolveLabelByUID(w)??void 0):p=w}let g=await this.tripleStore.match(l,X.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),m=[],b=[],_=!1;for(let w of g){let E=null;if(w.object instanceof gr.IRI?E=this.iriToObsidianName(w.object.value)??w.object.value:w.object instanceof cr.Literal&&(E=this.unwrapWikilink(w.object.value)),!E){_=!0;continue}if(this.looksLikeUUID(E)){b.push(E);let R=await this.resolveLabelByUID(E);R&&m.push(R)}else m.push(E)}if(_){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> has unresolvable exocmd__InheritanceRule_targetClassExclusion entry \u2014 entire rule skipped (would otherwise expand scope by silently dropping the excluded class).`);continue}let S=await this.getLiteralValue(l,X.Namespace.EXOCMD.term("InheritanceRule_priority")),A=50;if(S!==null&&S!==""){let w=Number.parseInt(String(S),10);Number.isFinite(w)&&(A=w)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:m,targetClassExclusionUids:b,priority:A})}return s}async resolveRefIriSubject(e){if((await this.tripleStore.match(e,X.Namespace.EXO.term("Asset_uid"),void 0)).length>0)return e;let n=await(0,sM.labelTermBearers)(this.tripleStore,e);return n.length>1?(this._ambiguousRefWarnedKeys.has(e.value)||(this._ambiguousRefWarnedKeys.add(e.value),this.warnOnce(this.capWarning(`Reference <${e.value}> names a label borne by ${n.length} assets (${n.map(i=>i.uid).join(", ")}) \u2014 left unresolved`))),e):n[0]?.subject??e}async resolveRefTripleObject(e){if(e instanceof gr.IRI)return this.resolveRefIriSubject(e);if(e instanceof cr.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let n=await this.getObsidianName(e,t);return n?this.looksLikeUUID(n)?this.resolveLabelByUID(n):n:null}async resolvePropertyDefaultValue(e,t,n){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let c=`${t}|${e}`;return this._fallbackWarnedKeys.has(c)||(this._fallbackWarnedKeys.add(c),this.warnOnce(this.capWarning(`Grounding ${t}: PropertyDefault '${n}' \u2192 value asset ${e} not in store; SKIPPING the property (the executor's own default applies). Previously this emitted a wikilink, i.e. a link written where a value belongs.`))),EZ.STRING_SCALAR_PROPERTIES.has(n)?null:`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,n):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,n,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${n}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,n,i,s){let o=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let c=o.trim();return cM.has(c)?s!==void 0?OZ(c,t,s):xZ(c,t):(this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${c}' \u2014 falling back to wikilink form. Known ids: ${Array.from(cM).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,n,i){let s=await this.getObsidianName(e,X.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let c=await this.findSubjectByUID(s);return c?this.dispatchSubstitutionToken(c,s,n,i,o):(this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,X.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof gr.IRI){if(i.object.value===PZ||i.object.value.includes(lM))return!0}else if(i.object instanceof cr.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===lM)return!0}return(await this.tripleStore.match(e,X.Namespace.EXOCMD.term("TokenInvocation_token"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as TokenInvocation via its exocmd__TokenInvocation_token property; exo__Instance_class was absent or unresolved.`),!0):!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,X.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof gr.IRI){if(i.object.value===CZ||i.object.value.includes(aM))return!0}else if(i.object instanceof cr.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===aM)return!0}return(await this.tripleStore.match(e,X.Namespace.EXOCMD.term("SubstitutionToken_resolver"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as SubstitutionToken via its resolver property; exo__Instance_class was absent or unresolved.`),!0):!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let n=t[0].object;if(n instanceof gr.IRI)return(0,nM.resolveGroundingTypeFromIRI)(n.value);if(n instanceof cr.Literal){let i=n.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,nM.resolveGroundingTypeFromIRI)(`obsidian://vault/${s[1].toLowerCase()}.md`):(this.warnOnce(`[exocmd-grounding-type-literal-form] legacy literal-string form '${i}' for exocmd__Grounding_type on <${e.value}>. Migrate to wikilink form per RFC 9d20c91f Phase 3.`),null)}return null}async expandPrototypeChain(e){if(!e||!this.normalizeWikilink(e))return[];let t=[e],n=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Jl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let c=null;try{let u=await this.findSubjectByUID(o);if(!u)break;c=await this.getLinkedValue(u,X.Namespace.EXO.term("Asset_prototype"))}catch(u){this.logger.debug(this.capWarning(`[expandPrototypeChain] store lookup failed at hop ${s} for '${i}': ${String(u)}`));break}if(!c)break;let l=this.normalizeWikilink(c).toLowerCase();if(n.has(l))break;n.add(l),t.push(c),i=c}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let n=this.extractPathBasename(t);return n&&this.looksLikeUUID(n)?n:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let n=await this.tripleStore.findSubjectsByUUID(e);if(n.length>0)return n[0]}let t=await this.tripleStore.match(void 0,X.Namespace.EXO.term("Asset_uid"),void 0);for(let n of t)if(n.object instanceof cr.Literal&&n.object.value===e)return n.subject;return null}async getLiteralValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof cr.Literal||i instanceof gr.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);return t?this.readAssetLabel(t):null}async readAssetLabel(e){let t=(await this.tripleStore.match(e,X.Namespace.EXO.term("Asset_label"),void 0))[0]?.object;return t instanceof gr.IRI?(0,iM.iriToObsidianName)(t.value)??t.value:t instanceof cr.Literal?t.value:null}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(n=>n.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let n=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),c=await this.getLiteralValue(s,X.Namespace.EXO.term("Asset_uid"));c&&o.add(c);let l=await this.readAssetLabel(s);l&&o.add(l);let u=a((p,h)=>{if(o.has(p))return;let g=n.get(p);(g===void 0||h<g)&&n.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:g}=p;if(g>=Jl||i.has(h.value))continue;i.add(h.value);let m=await this.tripleStore.match(h,X.Namespace.EXO.term("Class_superClass"),void 0);for(let b of m){let _=b.object;if(!(_ instanceof gr.IRI))continue;let S=g+1,A=_.value.startsWith("obsidian://vault/"),w=this.iriToObsidianName(_.value);w&&u(w,S);let E=null;if(A?E=_:w&&(E=await this.resolveClassFileIRI(w)),!E)continue;let R=await this.getLiteralValue(E,X.Namespace.EXO.term("Asset_uid"));R&&u(R,S),i.has(E.value)||f.push({fileIRI:E,depth:S})}}let d=Array.from(n.entries()).map(([p,h])=>({ref:p,depth:h}));return this._ancestorDepthCache.set(e,d),d}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){return(0,sM.findUidByAssetLabel)(this.tripleStore,e)}async getLinkedUID(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof gr.IRI){let s=await this.tripleStore.match(await this.resolveRefIriSubject(i),X.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof cr.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof cr.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let n=await this.tripleStore.match(e,t,void 0),i=[];for(let s of n){let o=s.object;if(o instanceof gr.IRI){let c=await this.tripleStore.match(await this.resolveRefIriSubject(o),X.Namespace.EXO.term("Asset_uid"),void 0);if(c.length>0&&c[0].object instanceof cr.Literal)i.push(c[0].object.value);else{let l=o.value.split("/").pop()?.replace(".md","");l&&i.push(l)}}else if(o instanceof cr.Literal){let c=this.normalizeWikilink(o.value);c&&i.push(c)}}return i}async getLinkedValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof cr.Literal?this.normalizeWikilink(i.value):i instanceof gr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof cr.Literal?this.unwrapWikilink(i.value):i instanceof gr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let n=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(n)return n[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof cr.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof gr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let n=t[1],i=await this.findSubjectByUID(n);if(!i)return e;let s=await this.readAssetLabel(i);return s?e.replace(`[[${n}]]`,`[[${n}|${s}]]`):e}iriToObsidianName(e){return(0,iM.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(0,n):t}};ma.CommandResolver=bI;ma.CommandResolver=bI=bZ([(0,SZ.injectable)(),_Z("design:paramtypes",[Object,Object])],bI)});var SI=T(_I=>{"use strict";Object.defineProperty(_I,"__esModule",{value:!0});_I.validateExoQLAllowlist=FZ;var Nb=Nh();function FZ(r){if(!r||typeof r!="object")return;let e=r;if(e.type==="update"){let t=r.updates??[];for(let n of t)if(n?.type==="load")throw new Nb.ExoQLForbiddenKeywordError("LOAD");throw new Nb.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,n=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||n)throw new Nb.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)kb(t);if(Array.isArray(e.template))for(let t of e.template)kb(t)}}a(FZ,"validateExoQLAllowlist");function kb(r){if(!r||typeof r!="object")return;if(r.type==="service")throw new Nb.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(r.patterns))for(let t of r.patterns)kb(t);let e=r.where;if(Array.isArray(e))for(let t of e)kb(t)}a(kb,"walkPatternForBannedKeywords")});var wI=T(Mb=>{"use strict";Object.defineProperty(Mb,"__esModule",{value:!0});Mb.DEFAULT_EVAL_CONFIG=void 0;Mb.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var jb=T(EI=>{"use strict";Object.defineProperty(EI,"__esModule",{value:!0});EI.evaluateWithExoEval=$Z;var DZ=Tf(),LZ=Of(),NZ=Yf(),kZ=SI(),MZ=wI(),jZ=Nh();async function $Z(r,e={}){if(typeof r!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let n=new DZ.ExoQLParser().parse(r);if((0,kZ.validateExoQLAllowlist)(n),!{...MZ.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new jZ.ExoQLEvalDisabledError;let s="queryType"in n&&typeof n.queryType=="string"?n.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let c=new LZ.ExoQLAlgebraTranslator().translate(n),l=new NZ.ExoQLQueryExecutor(e.store);return l.isAskQuery(c)?{kind:"ask",result:await l.executeAsk(c)}:l.isConstructQuery(c)?{kind:"construct",triples:await l.executeConstruct(c)}:{kind:"select",rows:await l.executeAll(c)}}a($Z,"evaluateWithExoEval")});var wo=T($b=>{"use strict";Object.defineProperty($b,"__esModule",{value:!0});$b.DateFormatter=void 0;var vI=class r{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${i}T${s}:${o}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${n}-${i}]]"`}static getTodayWikilink(){return r.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}static parseWikilink(e){let n=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return n?n[1]:null}static addDays(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),r.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[n,i,s]=t,o=new Date(n,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return r.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return r.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};$b.DateFormatter=vI});var Mh=T(Ub=>{"use strict";Object.defineProperty(Ub,"__esModule",{value:!0});Ub.liveClock=UZ;Ub.frozenClock=BZ;function UZ(){return{now:a(()=>new Date,"now")}}a(UZ,"liveClock");function BZ(r){let e=new Date(r);return{now:a(()=>new Date(e.getTime()),"now")}}a(BZ,"frozenClock")});var hM=T(ga=>{"use strict";var VZ=ga&&ga.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},GZ=ga&&ga.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},$h;Object.defineProperty(ga,"__esModule",{value:!0});ga.PreconditionEvaluator=void 0;var qZ=lt(),WZ=Tf(),zZ=Of(),pM=Yf(),HZ=jb(),jh=wo(),KZ=Mh(),Uh=$h=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,n){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=n?.clock??(0,KZ.liveClock)()}async evaluate(e,t,n){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,n,i)==="yes"}async evaluateNode(e,t,n,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let c=await Promise.all(o.map(l=>this.evaluateNode(l,t,n,i)));return s==="all"?c.includes("no")?"no":c.includes("unknown")?"unknown":"yes":c.includes("yes")?"yes":c.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,n,i);return s==="unknown"?"unknown":s==="yes"?"no":"yes"}return e.sparqlAsk?await this.evaluateSparqlAskMemoized(e.sparqlAsk,t,i)?"yes":"no":e.query?await this.evaluateQueryRef(e.query,t)?"yes":"no":e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,n)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,n){let i=n.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return n.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return!1;let i=this.substituteVariables(n,t),s=await(0,HZ.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,n){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,n):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,$h.SENTINEL_IRI),i=new WZ.ExoQLParser().parse(t),o=new zZ.ExoQLAlgebraTranslator().translate(i);return new pM.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,n){let i=this.hostFunctions.get(e);if(!i)return!0;let s=n?{...n,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let n=$h.TEMPORAL_TOKEN.test(e),i=n?jh.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||n&&s.day!==i){let l=this.compileAsk(e);if(!l)return!1;s={day:i,compiled:l},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll($h.SENTINEL_IRI,t));return await new pM.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let n=this.clock.now(),i=n.toISOString(),s=n.getFullYear(),o=n.getMonth(),c=n.getDate(),l=n.getDay(),u=jh.DateFormatter.toDateString(n),f=jh.DateFormatter.toDateString(new Date(s,o,c-1)),d=(l+6)%7,p=jh.DateFormatter.toDateString(new Date(s,o,c-d)),h=jh.DateFormatter.toDateString(new Date(s,o,c-d-7)),g=`${s}-${String(o+1).padStart(2,"0")}-01`,m=o===0?11:o-1,_=`${o===0?s-1:s}-${String(m+1).padStart(2,"0")}-01`,S=`${s}-01-01`;return e.replace(/\$target\b/g,`<${t}>`).replace(/\$now\b/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday\b/g,`"${f}"^^xsd:date`).replace(/\$thisWeekStart\b/g,`"${p}"^^xsd:date`).replace(/\$lastWeekStart\b/g,`"${h}"^^xsd:date`).replace(/\$thisMonthStart\b/g,`"${g}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${_}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${S}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};ga.PreconditionEvaluator=Uh;Uh.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Uh.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;ga.PreconditionEvaluator=Uh=$h=VZ([(0,qZ.injectable)(),GZ("design:paramtypes",[Object,Object,Object])],Uh)});var mM=T(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.hasUidFilename=ya.hasNonUidFilename=void 0;ya.registerDefaultHostFunctions=QZ;var YZ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");ya.hasNonUidFilename=YZ;var XZ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");ya.hasUidFilename=XZ;function QZ(r){r.registerHostFunction("hasNonUidFilename",ya.hasNonUidFilename),r.registerHostFunction("hasUidFilename",ya.hasUidFilename)}a(QZ,"registerDefaultHostFunctions")});var Vb=T(Bb=>{"use strict";Object.defineProperty(Bb,"__esModule",{value:!0});Bb.liveUidGenerator=JZ;Bb.seededUidGenerator=eee;var TI=sf();function JZ(){return{next:a(()=>(0,TI.v4)(),"next")}}a(JZ,"liveUidGenerator");var ZZ="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function eee(r){let e=0,t=(0,TI.v5)(r,ZZ);return{next:a(()=>{let n=`${r}#${e}`;return e+=1,(0,TI.v5)(n,t)},"next")}}a(eee,"seededUidGenerator")});var Wb=T(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.registerResolver=yr;Ac.getResolver=nee;Ac.isResolverModifierAware=iee;Ac.getRegisteredResolverIds=see;Ac.clearResolvers=oee;Ac.installDefaultResolvers=gee;var tee=wo(),gM=gc(),qb=new Map,AI=new Set,ree=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function yr(r,e,t=!1){qb.set(r,e),t&&AI.add(r)}a(yr,"registerResolver");function nee(r){return qb.get(r)}a(nee,"getResolver");function iee(r){return AI.has(r)}a(iee,"isResolverModifierAware");function see(){return Array.from(qb.keys())}a(see,"getRegisteredResolverIds");function oee(){qb.clear(),AI.clear()}a(oee,"clearResolvers");function vn(r){return r<10?`0${r}`:String(r)}a(vn,"pad2");var aee=["January","February","March","April","May","June","July","August","September","October","November","December"],cee=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],lee=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],uee=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function fee(r){let e=["th","st","nd","rd"],t=r%100;return`${r}${e[(t-20)%10]||e[t]||e[0]}`}a(fee,"ordinalDay");var dee=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function pee(r,e){let t=(r.getHours()+11)%12+1;return e.replace(dee,n=>{switch(n){case"YYYY":return String(r.getFullYear());case"YY":return vn(r.getFullYear()%100);case"MMMM":return aee[r.getMonth()];case"MMM":return cee[r.getMonth()];case"MM":return vn(r.getMonth()+1);case"M":return String(r.getMonth()+1);case"Do":return fee(r.getDate());case"DD":return vn(r.getDate());case"D":return String(r.getDate());case"dddd":return lee[r.getDay()];case"ddd":return uee[r.getDay()];case"HH":return vn(r.getHours());case"H":return String(r.getHours());case"hh":return vn(t);case"h":return String(t);case"mm":return vn(r.getMinutes());case"m":return String(r.getMinutes());case"ss":return vn(r.getSeconds());case"s":return String(r.getSeconds());case"A":return r.getHours()<12?"AM":"PM";case"a":return r.getHours()<12?"am":"pm";default:return n}})}a(pee,"formatDate");function yM(r,e,t){let n=r.getDate(),i=new Date(r.getTime());i.setDate(1),t==="M"?i.setMonth(i.getMonth()+e):i.setFullYear(i.getFullYear()+e);let s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(n,s)),i}a(yM,"addMonthsClamped");function hee(r,e){if(!e)return r;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return r;let n=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(r.getTime());switch(i){case"d":s.setDate(s.getDate()+n);break;case"w":s.setDate(s.getDate()+n*7);break;case"M":s=yM(s,n,"M");break;case"y":s=yM(s,n,"y");break}return isNaN(s.getTime())?r:s}a(hee,"applyDateOffset");function mee(r){if(!r)return{offset:null,format:null};let e=r.indexOf(":");if(e<0)return{offset:r,format:null};let t=r.slice(0,e),n=r.slice(e+1);return{offset:t||null,format:n||null}}a(mee,"parseDateModifier");function Gb(r,e){return(t,n)=>{let{offset:i,format:s}=mee(n),o=new Date;return r!==0&&o.setDate(o.getDate()+r),o=hee(o,i),pee(o,s??e)}}a(Gb,"makeDateResolver");function gee(){yr("today",()=>{let r=new Date;return`${r.getFullYear()}-${vn(r.getMonth()+1)}-${vn(r.getDate())}`}),yr("todayStart",()=>tee.DateFormatter.getTodayStartTimestamp()),yr("date",Gb(0,"YYYY-MM-DD"),!0),yr("now",Gb(0,"YYYY-MM-DDTHH:mm:ss"),!0),yr("tomorrow",Gb(1,"YYYY-MM-DD"),!0),yr("yesterday",Gb(-1,"YYYY-MM-DD"),!0),yr("target",r=>r.targetIRI?`"[[${r.targetIRI}]]"`:""),yr("targetFolder",r=>{if(!r.targetFilePath)return"";let e=r.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),yr("createdInstance",r=>{let e=r.createdInstancePath;if(!e)return null;let t=e.replace(/\.md$/i,"").replace(/^\/+/,""),n=t.split("/").pop()??t;return`"[[${ree.test(n)?n:t}]]"`}),yr("randomUUIDv4",()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();throw new Error("randomUUIDv4 resolver requires crypto.randomUUID() \u2014 runtime is missing Node crypto / Web Crypto API.")}),yr("nowTimestamp",()=>{let r=new Date;return`${r.getFullYear()}-${vn(r.getMonth()+1)}-${vn(r.getDate())}T${vn(r.getHours())}:${vn(r.getMinutes())}:${vn(r.getSeconds())}`}),yr("nowDate",()=>{let r=new Date;return`${r.getFullYear()}-${vn(r.getMonth()+1)}-${vn(r.getDate())}`}),yr("nowYear",()=>String(new Date().getFullYear())),yr("nowMonth",()=>vn(new Date().getMonth()+1)),yr("userInputLabel",r=>{let e=r.userInput?.label;return typeof e=="string"?e:""}),yr("userInput",(r,e)=>{if(!e)return null;let t=r.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),yr("targetProperty",(r,e)=>{if(!e||!r.targetFm)return null;let t=r.targetFm[e];return t==null?null:Array.isArray(t)?t.map(n=>(0,gM.decodeYamlBlockScalar)(String(n),!0)):(0,gM.decodeYamlBlockScalar)(String(t))}),yr("targetRefProperty",(r,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!n||!i)return null;let s=r.targetRefFm?.[n];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),yr("labelAsArray",r=>{let e=r.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),yr("groundingTargetClass",r=>r.groundingTargetClassUid?`"[[${r.groundingTargetClassUid}]]"`:null),yr("targetClassSelf",r=>{if(!r.targetFilePath)return null;let e=r.targetFilePath.replace(/^\/+/,""),n=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return n.length>0?`"[[${n}]]"`:null})}a(gee,"installDefaultResolvers")});var RI=T(zb=>{"use strict";Object.defineProperty(zb,"__esModule",{value:!0});zb.resolveTemplateBody=bee;zb.stripTemplateFrontmatter=_ee;var II=Wb();(0,II.installDefaultResolvers)();var yee=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function bee(r,e={}){return r.replace(yee,(t,n,i)=>{let s=(0,II.getResolver)(n);if(s===void 0)return t;let o=s(e,i.length>0?i:void 0);return typeof o!="string"||o.length===0?t:(0,II.isResolverModifierAware)(n)?o:o+i})}a(bee,"resolveTemplateBody");function _ee(r){let e=r.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?r.slice(e[0].length):r}a(_ee,"stripTemplateFrontmatter")});var Yb=T(Qf=>{"use strict";Object.defineProperty(Qf,"__esModule",{value:!0});Qf.registerOrderSpecLoader=See;Qf.clearOrderSpecLoader=wee;Qf.loadDefaultSpec=Eee;Qf.orderProperties=vee;var Hb=null,Ic,Kb=!1;function See(r){Hb=r,Ic=void 0,Kb=!1}a(See,"registerOrderSpecLoader");function wee(){Hb=null,Ic=void 0,Kb=!1}a(wee,"clearOrderSpecLoader");function Eee(){if(Ic!==void 0)return Ic;if(!Hb)return Ic=null,null;try{Ic=Hb()}catch(r){Kb||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",r),Kb=!0),Ic=null}return Ic}a(Eee,"loadDefaultSpec");function vee(r,e){if(!e||e.head.length===0&&e.tail.length===0)return r;let t=Object.keys(r),n=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),c=t.filter(u=>!n.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&c.sort((u,f)=>u.localeCompare(f));let l={};for(let u of s)l[u]=r[u];for(let u of c)l[u]=r[u];for(let u of o)l[u]=r[u];return l}a(vee,"orderProperties")});var Fi=T(Xb=>{"use strict";Object.defineProperty(Xb,"__esModule",{value:!0});Xb.DI_TOKENS=void 0;Xb.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),ClassCreationService:Symbol.for("ClassCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),RenameToUidService:Symbol.for("RenameToUidService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var xI=T(Qb=>{"use strict";Object.defineProperty(Qb,"__esModule",{value:!0});Qb.RDFVocabularyMapper=void 0;var Dr=Ai(),bM=Le(),Ae=At(),CI=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",Ae.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",Ae.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",Ae.Namespace.RDFS.term("subClassOf")],["exo__Property_range",Ae.Namespace.RDFS.term("range")],["exo__Property_domain",Ae.Namespace.RDFS.term("domain")],["exo__Property_superProperty",Ae.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Dr.Triple(Ae.Namespace.EXO.term("Asset"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.RDFS.term("Resource"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Class"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.RDFS.term("Class"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.RDF.term("Property"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Task"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Project"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Area"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Workflow"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("WorkflowState"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("WorkflowTransition"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("Command"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("Precondition"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("Grounding"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("CommandBinding"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Dr.Triple(Ae.Namespace.EXO.term("Instance_class"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDF.term("type"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Asset_isDefinedBy"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("isDefinedBy"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Class_superClass"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("subClassOf"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property_range"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("range"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property_domain"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("domain"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property_superProperty"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,n){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(n instanceof bM.IRI)s=n;else{let o=Ae.Namespace.fromPropertyKey(n);s=o?o.namespace.term(o.localName):new bM.IRI(n)}return new Dr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};Qb.RDFVocabularyMapper=CI});var Jb=T(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.OBSIDIAN_VAULT_SCHEME=void 0;ba.vaultPathToIRI=Tee;ba.iriToVaultPath=Aee;ba.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function Tee(r){let e=r.startsWith("./")?r.slice(2):r;return`${ba.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(Tee,"vaultPathToIRI");function Aee(r){if(!r.startsWith(ba.OBSIDIAN_VAULT_SCHEME))return null;let e=r.slice(ba.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(Aee,"iriToVaultPath")});var e_=T(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});Bh.derivePath=_M;Bh.deriveUrl=Iee;Bh.deriveLegacyFlatPath=Ree;var OI="assetspaces",Zb=/^[A-Za-z0-9._-]+$/;function _M(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let n=t.split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!Zb.test(i)||!Zb.test(s)?null:`${OI}/${i}/${s}`}a(_M,"derivePath");function Iee(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${OI}/`;if(!e.startsWith(t))return null;let n=e.slice(t.length).split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!Zb.test(i)||!Zb.test(s)?null:`https://github.com/${i}/${s}`}a(Iee,"deriveUrl");function Ree(r){let e=_M(r);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let n=t.startsWith("exoas-")?t.slice(6):t;return n.length===0?null:`${OI}/${n}`}a(Ree,"deriveLegacyFlatPath")});var t_=T(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.FILE_SPACE_CLASS_UID=void 0;Ts.frontmatterDeclaresFileSpace=xee;Ts.discoverFileSpaceExclusions=Pee;var Cee=e_();Ts.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var SM=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,PI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function EM(r){let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;SM.lastIndex=0;let i;for(;(i=SM.exec(n))!==null;)t.push(i[1].trim())}return t}a(EM,"wikilinkTargets");function xee(r){return r?EM(r.exo__Instance_class).some(e=>PI.test(e)&&e.toLowerCase()===Ts.FILE_SPACE_CLASS_UID):!1}a(xee,"frontmatterDeclaresFileSpace");function wM(r,e){try{return r.getFrontmatter(e)}catch{return null}}a(wM,"readFrontmatterSafe");function Oee(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(Oee,"readSource");function Pee(r){let e=[],t=[],n=[],i=new Map,s=a((c,l)=>{if(PI.test(c))return c.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;let u=r.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=wM(r,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(c=>c.some(l=>PI.test(l)&&l.toLowerCase()===Ts.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of r.getAllFiles()){let l=wM(r,c);if(!l)continue;let u=EM(l.exo__Instance_class);if(!u.some(h=>s(h,c.path)))continue;t.push(c.path),o(u)||n.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Ts.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=Oee(l);if(f===null){n.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,Cee.derivePath)(f);if(d===null){n.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;c.path.startsWith(p)&&n.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${p} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(p)}return{prefixes:e,declarationPaths:t,warnings:n}}a(Pee,"discoverFileSpaceExclusions")});var eu=T(kt=>{"use strict";var Fee=kt&&kt.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Dee=kt&&kt.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},vM=kt&&kt.__param||function(r,e){return function(t,n){e(t,n,r)}},LI;Object.defineProperty(kt,"__esModule",{value:!0});kt.NoteToRDFConverter=kt.LEGACY_YAML_KEYS=kt.LEGACY_UNPREFIXED_ASSET_FIELDS=kt.UNPREFIXED_ASSET_FIELDS=void 0;kt.canonicalYamlKey=jee;kt.isPosixBracketExpression=IM;kt.normaliseExcludedFolders=RM;kt.isPathExcluded=CM;var FI=lt(),Lr=Ai(),As=Le(),jn=He(),TM=sr(),Zt=At(),AM=Fi(),Lee=xI(),Nee=mh(),DI=Jb(),Di=OT(),kee=t_();kt.UNPREFIXED_ASSET_FIELDS=new Set(["draft","pinned","aliases"]);kt.LEGACY_UNPREFIXED_ASSET_FIELDS=new Set(["archived"]);kt.LEGACY_YAML_KEYS=new Map([...kt.LEGACY_UNPREFIXED_ASSET_FIELDS].map(r=>[`exo__Asset_${r}`,[r]]));var Mee=/^exo__Asset_(.+)$/;function jee(r){let e=Mee.exec(r);return e&&kt.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(r)?`exo__Asset_${r}`:r}a(jee,"canonicalYamlKey");function IM(r){return/^:[^\s[\]|]+:$/.test(r)}a(IM,"isPosixBracketExpression");function RM(r){return Array.isArray(r)?r.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(RM,"normaliseExcludedFolders");function CM(r,e){if(e.length===0)return!1;let t=r.replace(/\\/g,"/");for(let n of e)if(t.startsWith(n))return!0;return!1}a(CM,"isPathExcluded");function $ee(r){if(!r)return"";let e=r.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a($ee,"normaliseSubjectIriPrefix");var Zl=LI=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=Nee.NullLogger,n={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.preResolvedTargetFm=new Map,this.vocabularyMapper=new Lee.RDFVocabularyMapper,this.subjectIriPrefix=$ee(n.subjectIriPrefix),this.emitInstanceClassAsUid=n.emitInstanceClassAsUid??!1}async convertNote(e){let t=this.vault.getFrontmatterWithFallback?await this.vault.getFrontmatterWithFallback(e):this.vault.getFrontmatter(e);return this.convertNoteFromFrontmatter(e,t)}async convertNoteFromFrontmatter(e,t){if(!t)return[];await this.preResolveWikilinkTargets(t);let n=this.notePathToIRI(e.path),i=Zt.Namespace.EXO.term("Asset_filename"),s=new Lr.Triple(n,i,new jn.Literal(e.basename));if(Di.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,n){this.pendingExtraTriples=[];let i=[n],s=this.notePathToIRI(e.path),o,c,l,u=!1,f=Zt.Namespace.EXO.term("Statement").value;for(let[m,b]of Object.entries(t)){if(kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)&&Object.prototype.hasOwnProperty.call(t,`exo__Asset_${m}`))continue;let _=kt.UNPREFIXED_ASSET_FIELDS.has(m)||kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)?`exo__Asset_${m}`:m;if(!this.isExocortexProperty(_))continue;let S=this.propertyKeyToIRI(_),A=Array.isArray(b)?b:[b];for(let w of A)if(!((m==="exo__Asset_label"||kt.UNPREFIXED_ASSET_FIELDS.has(m)||kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m))&&(w==null||typeof w=="string"&&w.trim()==="")))if(m==="exo__Instance_class"){let E=this.valueToClassURI(w);i.push(new Lr.Triple(s,S,E))}else{let E=await this.valueToRDFObject(w,e,S);if(_==="exo__Statement_subject"&&o===void 0){let R=E.find(x=>x instanceof As.IRI);R&&(o=R)}else if(_==="exo__Statement_predicate"&&c===void 0){let R=E.find(x=>x instanceof As.IRI);R&&(c=R)}else _==="exo__Statement_object"&&l===void 0&&(l=E[0]);for(let R of E)if(i.push(new Lr.Triple(s,S,R)),this.vocabularyMapper.hasMappingFor(m)&&R instanceof As.IRI){let x=this.vocabularyMapper.generateMappedTriple(s,m,R);x&&i.push(x)}}if(m==="exo__Instance_class")for(let w of A){let E=this.valueToClassURI(w);if(E instanceof As.IRI){let R=Zt.Namespace.RDF.term("type");i.push(new Lr.Triple(s,R,E)),E.value===f&&(u=!0)}}if(m==="exo__Asset_label"){let w=Zt.Namespace.RDFS.term("label");for(let E of A)typeof E=="string"&&E.length>0&&i.push(new Lr.Triple(s,w,new jn.Literal(E)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let m=Zt.Namespace.RDFS.term("label"),b=Zt.Namespace.EXO.term("Asset_label"),_=new jn.Literal(e.basename);i.push(new Lr.Triple(s,m,_)),i.push(new Lr.Triple(s,b,_))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&c&&l&&i.push(new Lr.Triple(o,c,l));let g=await this.convertBodyWikilinks(e,s);return i.push(...g),i}async convertExo003Note(e,t){let n=Di.Exo003Parser.parse(t);if(!n.success||!n.metadata)return[];let i=n.metadata,s=[];switch(i.metadata){case Di.Exo003MetadataType.Namespace:break;case Di.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Di.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Di.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Di.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let n=this.notePathToIRI(e.path),i=new As.IRI(t.uri);return[new Lr.Triple(n,Zt.Namespace.OWL.term("sameAs"),i),new Lr.Triple(i,Zt.Namespace.OWL.term("sameAs"),n)]}convertExo003BlankNode(e,t){let n=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new Lr.Triple(n,Zt.Namespace.OWL.term("sameAs"),new TM.BlankNode(i))]}convertExo003Statement(e,t){let n=[];try{let i=this.createExo003ReferenceResolver(e),s=Di.Exo003Parser.toTriple(t,i);n.push(s);let o=this.notePathToIRI(e.path);n.push(new Lr.Triple(o,Zt.Namespace.RDF.term("value"),s.subject))}catch{}return n}async convertExo003Body(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new As.IRI(c.value):new TM.BlankNode(c.value),f=new As.IRI(l.value),d=Di.Exo003Parser.toLiteral(t,s.trim());n.push(new Lr.Triple(u,f,d));let p=this.notePathToIRI(e.path);n.push(new Lr.Triple(p,Zt.Namespace.RDF.term("value"),u))}catch{}return n}createExo003ReferenceResolver(e){return t=>{let n=this.extractWikilink(t),i=n||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.targetFrontmatter(s);if(o&&Di.Exo003Parser.isExo003Format(o)){let c=Di.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Di.Exo003MetadataType.Anchor||l.metadata===Di.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Di.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!n&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders,onFileTriples:e.onFileTriples})).triples}async convertVaultWithValidation(e={}){let t=e.files??this.vault.getAllFiles(),n=[],i=[],s=e.strict??!1,o=0,c=0,l=0,u=e.fileSpacePrefixes?{prefixes:e.fileSpacePrefixes,declarationPaths:[],warnings:[]}:(0,kee.discoverFileSpaceExclusions)(this.vault);for(let b of u.warnings)this.logger.warn(`FileSpace discovery: ${b}`);let f=[...RM(e.excludedFolders),...u.prefixes],d=f.length===0?t:t.filter(b=>!CM(b.path,f)),p=e.onProgress,h=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:LI.INDEX_PROGRESS_INTERVAL,g=d.length,m=0;for(let b of d){if(m++,p&&m%h===0&&m<g)try{p(m,g)}catch{}try{let _=this.vault.getFrontmatter(b);if(!_){let w=this.vault.getFrontmatterParseFailure?.(b);if(w){if(s)throw new Error(`Unparseable frontmatter in "${b.path}": ${w.reason}`);i.push({path:b.path,reason:`Unparseable frontmatter: ${w.reason}`}),l++,this.logger.info(`Skipping file with unparseable frontmatter: ${b.path}`,{reason:w.reason});continue}}let S=_?this.validateExocortexAsset(_,b.basename):null;if(S){if(s)throw new Error(`Invariant violation in "${b.path}": ${S.message}`);i.push({path:b.path,reason:`Invariant violation: ${S.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${b.path}`,{code:S.code,property:S.property,reason:S.message});continue}let A=await this.convertNote(b);if(n.push(...A),e.onFileTriples)try{e.onFileTriples(b,A)}catch{}}catch(_){let S=_ instanceof Error?_.message:String(_);if(s)throw new Error(`Invalid IRI for file "${b.path}": ${S}`);i.push({path:b.path,reason:`Invalid IRI: ${S}`}),c++,this.logger.info(`Skipping file with invalid IRI: ${b.path}`,{reason:S})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),l>0&&this.logger.warn(`Skipped ${l} file${l===1?"":"s"} with unparseable frontmatter during indexing (paths in developer console)`,{count:l}),c>0&&this.logger.warn(`Skipped ${c} file${c===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:c}),{triples:n,skippedFiles:i,summary:{total:d.length,indexed:d.length-i.length,skipped:i.length},fileSpaces:u}}static inferLabelFromBasename(e){return Zt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let n=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(n):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(n(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&n(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let p=this.removeQuotes(d),g=(this.extractWikilink(p)??p).trim(),m=g.indexOf("__");m>0&&Zt.Namespace.isValidPrefix(g.slice(0,m))&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let n of e){let i=(0,DI.vaultPathToIRI)(n.path);As.IRI.isValidIRI(i)||t.push({path:n.path,reason:`Path "${n.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new As.IRI((0,DI.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new As.IRI((0,DI.vaultPathToIRI)(e))}isExocortexProperty(e){return Zt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Zt.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let n=this.targetFrontmatter(t);if(!n)return;let i=n.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof As.IRI&&(this.pendingExtraTriples.push(new Lr.Triple(e,Zt.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new Lr.Triple(e,Zt.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,n){if(typeof e=="string"){let i=this.removeQuotes(e);if(n?.value.endsWith("#TokenInvocation_parameter"))return[new jn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new jn.Literal(u);if(n?.value.endsWith("#Grounding_targetValueRef")||n?.value.endsWith("#Grounding_targetValueSubstitution")||n?.value.endsWith("#Grounding_targetClass")||n?.value.endsWith("#Grounding_type")||n?.value.endsWith("#PropertyDefault_value"))return[l];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let g=this.targetFrontmatter(o);if(g){let A=g.exo__Asset_label;if(typeof A=="string"){let w=this.expandClassValue(A);if(w)return this.emitTypeTripleForEnumInstance(w,o),[w]}}let m=n?.value.endsWith("#Asset_prototype")||n?.value.endsWith("/Asset_prototype"),_=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(A=>A.trim()).filter(Boolean),S=_.length>0&&_.some(A=>n?.value.endsWith(`#${A}`));return m||S?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new jn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new jn.Literal(i,Zt.Namespace.XSD.term("dateTime"))]:[new jn.Literal(i)]}return typeof e=="boolean"?[new jn.Literal(e.toString())]:typeof e=="number"?[new jn.Literal(e.toString(),Number.isInteger(e)?Zt.Namespace.XSD.term("integer"):Zt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new jn.Literal(e.toISOString(),Zt.Namespace.XSD.term("dateTime"))]:[new jn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1];return n.includes("|")?n.split("|")[0]:n}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1],i=n.indexOf("|");return i>=0?n.substring(i+1).trim():null}targetFrontmatter(e){return this.vault.getFrontmatter(e)??this.preResolvedTargetFm.get(e.path)??null}async preResolveWikilinkTargets(e){let t=this.vault.getFrontmatterWithFallback?.bind(this.vault);if(t)for(let n of Object.values(e)){let i=Array.isArray(n)?n:n==null?[]:[n];for(let s of i){if(typeof s!="string")continue;let o=this.removeQuotes(s),c=this.extractWikilink(o);if(!c||!this.isUUID(c))continue;let l=this.vault.getFirstLinkpathDest(c,"");!l||this.preResolvedTargetFm.has(l.path)||this.vault.getFrontmatter(l)||this.preResolvedTargetFm.set(l.path,await t(l))}}}valueToClassURI(e){if(typeof e!="string")return new jn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):l;let u=this.targetFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):d}}return this.notePathToIRI(c.path)}}return new jn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Zt.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),n=Zt.Namespace.fromPropertyKey(t);return!n||/[\s()]/.test(n.localName)?null:n.namespace.term(n.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,n,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(n=i.exec(e))!==null;)n[1]&&!IM(n[1].trim())&&t.add(n[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=Zt.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);n.push(new Lr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?n.push(new Lr.Triple(t,c,f)):n.push(new Lr.Triple(t,c,new jn.Literal(l)))}else n.push(new Lr.Triple(t,c,new jn.Literal(l)))}}catch{}return n}};kt.NoteToRDFConverter=Zl;Zl.INDEX_PROGRESS_INTERVAL=200;Zl.SkippedFileInfo=class{constructor(r,e){this.path=r,this.reason=e}};Zl.VaultValidationResult=class{constructor(r,e,t){this.triples=r,this.skippedFiles=e,this.summary=t}};Zl.VaultValidationOptions=class{constructor(r=!1){this.strict=r}};kt.NoteToRDFConverter=Zl=LI=Fee([(0,FI.injectable)(),vM(0,(0,FI.inject)(AM.DI_TOKENS.IVaultAdapter)),vM(1,(0,FI.inject)(AM.DI_TOKENS.ILogger)),Dee("design:paramtypes",[Object,Object,Object])],Zl)});var tu=T(n_=>{"use strict";Object.defineProperty(n_,"__esModule",{value:!0});n_.FrontmatterService=void 0;var xM=Yb(),r_=gc(),Jf=eu(),Uee=At(),Zf=class r{static{a(this,"FrontmatterService")}parse(e){let t=e.match(r.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}static splitFlowSequence(e){let t=[],n="",i=null,s=0;for(let c=0;c<e.length;c++){let l=e[c];if(i!==null){if(n+=l,l==="\\"&&i==='"'){n+=e[++c]??"";continue}l===i&&(i=null);continue}if(l==='"'||l==="'"){i=l,n+=l;continue}if(l==="["||l==="{"){s++,n+=l;continue}if(l==="]"||l==="}"){if(s--,s<0)return null;n+=l;continue}if(l===","&&s===0){t.push(n.trim()),n="";continue}n+=l}if(i!==null||s!==0)return null;let o=n.trim();return o!==""&&t.push(o),t}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let n={},i=t.content.split(/\r?\n/),s=null,o=null,c=[],l=null,u=a(()=>{s!==null&&o!==null&&(n[s]=o),s=null,o=null,c=[]},"flushArray");for(let f of i){if(l!==null){if(f.trim()===""){c.push(f);continue}if(/^[ \t]/.test(f)){n[l]=[n[l],...c,f].join(`
|
|
119
|
+
${n}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(n=>this.generateExpression(n)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),n=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${n})`:`${t} IN (${n})`}default:throw new zf(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let n of e.triples)this.collectVariablesFromTriple(n,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let n of e.variables)t.add(n);break;case"project":for(let n of e.variables)t.add(n);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let n of e.variables)t.add(n);for(let n of e.aggregates)t.add(n.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let n of e.operands)this.collectVariablesFromExpression(n,t);break;case"function":case"functionCall":for(let n of e.args)this.collectVariablesFromExpression(n,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let n of e.list)this.collectVariablesFromExpression(n,t);break}}};Hf.SPARQLGenerator=yI});var Yf=T(Pi=>{"use strict";var eZ=Pi&&Pi.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),tZ=Pi&&Pi.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),tM=Pi&&Pi.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&eZ(t,e,n[i]);return tZ(t,e),t}})();Object.defineProperty(Pi,"__esModule",{value:!0});Pi.QueryExecutor=Pi.ExoQLQueryExecutor=Pi.QueryExecutorError=void 0;var rZ=$A(),nZ=Ab(),iZ=iI(),sZ=oI(),oZ=Uk(),aZ=Vk(),cZ=zk(),lZ=hI(),uZ=Kk(),fZ=Xk(),dZ=Zk(),pZ=eM(),hZ=Le(),mZ=He(),gZ=bb(),En="http://www.w3.org/2001/XMLSchema#",yZ=new Set([`${En}integer`,`${En}decimal`,`${En}float`,`${En}double`,`${En}nonPositiveInteger`,`${En}negativeInteger`,`${En}long`,`${En}int`,`${En}short`,`${En}byte`,`${En}nonNegativeInteger`,`${En}unsignedLong`,`${En}unsignedInt`,`${En}unsignedShort`,`${En}unsignedByte`,`${En}positiveInteger`]),Kf=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};Pi.QueryExecutorError=Kf;var Db=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let n=t.resolveClassHierarchy===!1?e:new dZ.ClassHierarchyResolvingStore(e);this.tripleStore=n,this.bgpExecutor=new rZ.BGPExecutor(n),this.filterExecutor=new nZ.FilterExecutor,this.optionalExecutor=new iZ.OptionalExecutor,this.unionExecutor=new sZ.UnionExecutor,this.minusExecutor=new oZ.MinusExecutor,this.valuesExecutor=new aZ.ValuesExecutor,this.aggregateExecutor=new cZ.AggregateExecutor,this.constructExecutor=new lZ.ConstructExecutor,this.serviceExecutor=new uZ.ServiceExecutor(t.serviceConfig),this.graphExecutor=new fZ.GraphExecutor(n),this.sparqlGenerator=new pZ.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(n)}async evaluateExistsPattern(e,t){let n=this.substituteVariables(e,t);for await(let i of this.execute(n))if(t.merge(i)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let n of this.execute(e))t.push(n);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new Kf(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let n=new Set;for(let o of t)for(let c of o.variables())n.add(c);let i=this.collectOperationVariables(e.right);if([...n].some(o=>i.has(o)))for(let o of t){let c=this.substituteVariables(e.right,o);for await(let l of this.execute(c)){let u=o.merge(l);u!==null&&(yield u)}}else{let o=[];for await(let c of this.execute(e.right))o.push(c);for(let c of t)for(let l of o){let u=c.merge(l);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>tM(ha())),n=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(n.has(o)){let c=i.get(o);c!==void 0&&s.set(o,c)}yield s}}async*executeOrderBy(e){let t=[];for await(let n of this.execute(e.input))t.push(n);t.sort((n,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,n),c=this.getExpressionValue(s.expression,i),l=0;if(o===void 0&&c===void 0?l=0:o===void 0?l=1:c===void 0?l=-1:typeof o=="number"&&typeof c=="number"?l=o-c:l=String(o).localeCompare(String(c)),s.descending&&(l=-l),l!==0)return l}return 0});for(let n of t)yield n}async*executeSlice(e){let t=0,n=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=n){if(i!==void 0&&t-n>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeReduced(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let n=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of n)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of n)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let n of this.execute(e.input)){let i=n.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,n):this.evaluateExtendExpression(e.expression,n);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let n of this.execute(e.left))t.push(n);for(let n of t){let i=this.substituteVariables(e.right,n);for await(let s of this.execute(i)){let o=n.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let n=JSON.parse(JSON.stringify(e));return this.substituteInOperation(n,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let n=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(n.input&&(n.input=this.substituteInOperation(n.input,t)),n.left&&(n.left=this.substituteInOperation(n.left,t)),n.right&&(n.right=this.substituteInOperation(n.right,t)),n.pattern&&(n.pattern=this.substituteInOperation(n.pattern,t)),n.query&&(n.query=this.substituteInOperation(n.query,t)),n.where&&(n.where=this.substituteInOperation(n.where,t)),n.expression&&this.substituteInExpression(n.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.type==="variable"&&typeof e.name=="string"){let n=this.termToAlgebraNode(t.get(e.name));if(n!==null){delete e.name;for(let[i,s]of Object.entries(n))e[i]=s}}if(e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let n of e.operands)this.substituteInExpression(n,t);if(e.args)for(let n of e.args)this.substituteInExpression(n,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let n of e.list)this.substituteInExpression(n,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let n=this.termToAlgebraNode(t.get(e.value));if(n!==null)return n}return e}termToAlgebraNode(e){if(e==null)return null;let t=e;return e instanceof hZ.IRI||t.termType==="NamedNode"?{type:"iri",value:e.value}:t.termType==="Literal"||typeof t.value=="string"?{type:"literal",value:t.value,datatype:t.datatype?.value??t._datatype?.value,language:t.language??t._language}:null}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(n,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{n.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(n,i):yield*this.execute(n)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:n}=await Promise.resolve().then(()=>tM(ha()));yield new n;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let n=t.get(e.name);if(!n)return;if(n instanceof mZ.Literal){let i=n.datatype?.value;if(i===`${En}dayTimeDuration`)try{return gZ.DateTimeFunctions.parseDayTimeDuration(n.value)}catch{return n.value}if(i&&yZ.has(i)){let s=parseFloat(n.value);if(!Number.isNaN(s))return s}return n.value}return n.value??n.id??String(n)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="bgp"&&n.triples)for(let i of n.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(n.type==="values"&&n.variables)for(let i of n.variables)t.add(i);n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.type==="extend"&&n.variable&&t.add(n.variable),n.input&&this.collectVarsFromOperation(n.input,t),n.left&&this.collectVarsFromOperation(n.left,t),n.right&&this.collectVarsFromOperation(n.right,t),n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.query&&this.collectVarsFromOperation(n.query,t),n.where&&this.collectVarsFromOperation(n.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let n=e;n.type==="variable"&&t.add(n.value),n.type==="quoted"&&(this.collectVarsFromElement(n.subject,t),this.collectVarsFromElement(n.predicate,t),this.collectVarsFromElement(n.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="variable"&&n.name&&t.add(n.name),n.type==="exists"&&n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.left&&this.collectVarsFromExpressionTree(n.left,t),n.right&&this.collectVarsFromExpressionTree(n.right,t),n.operands)for(let i of n.operands)this.collectVarsFromExpressionTree(i,t);if(n.args)for(let i of n.args)this.collectVarsFromExpressionTree(i,t);if(n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.list)for(let i of n.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new Kf("executeConstruct requires a CONSTRUCT operation");let t=await this.executeAll(e.where);return this.constructExecutor.execute(e.template,t)}isAskQuery(e){return e.type==="ask"}async executeAsk(e){if(e.type!=="ask")throw new Kf("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};Pi.ExoQLQueryExecutor=Db;Pi.QueryExecutor=Db});var dM=T(ma=>{"use strict";var bZ=ma&&ma.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},_Z=ma&&ma.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(ma,"__esModule",{value:!0});ma.CommandResolver=void 0;var SZ=lt(),wZ=mh(),EZ=gc(),gr=Le(),cr=He(),X=At(),rM=uc(),nM=Xp(),vZ=Bl(),iM=yc(),sM=P0(),Xf=zv(),oM=WN(),TZ=Tf(),AZ=Of(),IZ=Yf(),Jl=10,Lb="exo__Asset",RZ=Jl+1,aM="08cec529-90eb-4d43-88de-ceecccea12b0",CZ=X.Namespace.EXOCMD.term("SubstitutionToken").value,cM=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","createdInstance","targetClassSelf"]);function xZ(r,e){return`__SUBSTITUTE__${r}__${e}__`}a(xZ,"buildSubstitutionMarker");function OZ(r,e,t){let n=(0,vZ.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${r}__${e}__${n}__`}a(OZ,"buildParameterisedMarker");var lM="3f28af98-c031-4718-8ba2-44ad0b012c52",PZ=X.Namespace.EXOCMD.term("TokenInvocation").value,uM="29e2c8f8-2d27-4e58-b467-2e85d46f8122",fM="universal-default-template",bI=class{static{a(this,"CommandResolver")}warnOnce(e){this._warnedMessages.has(e)||(this._warnedMessages.add(e),this.logger.warn(e))}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null}constructor(e,t=wZ.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorDepthCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._fallbackWarnedKeys=new Set,this._ambiguousRefWarnedKeys=new Set,this._warnedMessages=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,n){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${n??""}`,o=this.multiCache.get(s);if(o)return o;let c=n?await this.expandPrototypeChain(n):void 0,l=await this.expandClassHierarchy(t),u=new Map;for(let[h,g]of l){let m=await this.resolveForAsset(e,h,c);for(let b of m){let _=this.getBindingPriority(b.binding)===2?g:0,S=u.get(b.binding.id);(!S||_<S.depth)&&u.set(b.binding.id,{rc:b,depth:_})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let g of h.binding.overrides)f.add(g);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,g)=>{let m=this.getBindingPriority(h.rc.binding),b=this.getBindingPriority(g.rc.binding);return m!==b?m-b:h.depth!==g.depth?h.depth-g.depth:(h.rc.binding.order??100)-(g.rc.binding.order??100)});let p=d.map(h=>h.rc);return this.multiCache.set(s,p),p}async expandClassHierarchy(e){let t=new Map;for(let c of e){if(c===Lb){t.set(c,new Set);continue}let l=[];try{l=await this.getClassAncestors(c)}catch{l=[]}t.set(c,new Set(l))}let n=a(c=>{for(let l of e)if(l!==c&&t.get(l)?.has(c)&&!t.get(c)?.has(l))return!0;return!1},"isAncestorOfSibling"),i=e.filter(c=>!n(c)),s=new Map,o=a((c,l)=>{let u=s.get(c);(u===void 0||l<u)&&s.set(c,l)},"setMin");for(let c of i){if(o(c,0),this.looksLikeUUID(c))try{let u=await this.resolveLabelByUID(c);u&&o(u,0)}catch{}if(c===Lb)continue;let l=[];try{l=await this.getClassAncestorsWithDepth(c)}catch{l=[]}for(let{ref:u,depth:f}of l)o(u,f)}return s.has(Lb)||s.set(Lb,RZ),s}async resolveForAsset(e,t,n){let i=typeof n=="string"?`s:${n}`:n?`c:${n.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let c=typeof n=="string"?await this.expandPrototypeChain(n):n,l=await this.findBindings(t,c,e),u=[];for(let f of l){let d=await this.loadCommand(f.commandRef,{targetClass:f.targetClass});if(!d)continue;let p=f.precondition?{...d,precondition:f.precondition}:d;u.push({command:p,binding:f})}return u.sort((f,d)=>{let p=this.getBindingPriority(f.binding),h=this.getBindingPriority(d.binding);return p!==h?p-h:(f.binding.order??100)-(d.binding.order??100)}),this.cache.set(s,u),u}async loadCommand(e,t){let n=await this.findSubjectByUID(e);if(!n||(await this.tripleStore.match(n,X.Namespace.RDF.term("type"),X.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.readAssetLabel(n)??"Unknown Command",o=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_labelTemplate")),c=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_icon")),l=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(n,X.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(n),g=await this.loadLinkedGrounding(n,0,t);return g?{id:e,name:s,labelTemplate:o??void 0,icon:c??void 0,precondition:h??void 0,grounding:g,confirmMessage:l??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,n){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,X.Namespace.RDF.term("type"),X.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let c of s){let l=c.subject,u=await this.loadBindingDefinition(l);u&&this.bindingMatches(u,e,i,n)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,X.Namespace.RDF.term("type"),X.Namespace.EXOCMD.term("Command")),t=[],n=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,X.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let c=await this.getLiteralValue(s,X.Namespace.EXO.term("Asset_uid"));if(!c){this.warnOnce(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let l=await this.loadCommand(c);if(!l){this.warnOnce(`[CommandResolver] paletteEnabled command ${c} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,X.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,X.Namespace.EXOCMD.term("Command_cliName")),d=u??f??c;if(n.has(d)){this.warnOnce(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${c}`);continue}n.add(d),t.push({command:l,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear(),this.clearUniversalCache()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let n=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let c=await this.evaluateSelectSnippet(o,t);n=n.replace(s,c)}return n}extractPlaceholders(e){let t=[],n=0;for(;n<e.length;)if(e[n]==="{"){let i=1,s=n+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(n,s),c=e.slice(n+1,s-1);t.push({full:o,body:c})}n=s}else n++;return t}async evaluateSelectSnippet(e,t){try{let n=e.replace(/\$target/g,`<${t}>`),s=new TZ.ExoQLParser().parse(n),c=new AZ.ExoQLAlgebraTranslator().translate(s),u=await new IZ.ExoQLQueryExecutor(this.tripleStore).executeAll(c);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let p=f.get(d[0]);return p?p instanceof cr.Literal||p instanceof gr.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.readAssetLabel(e)??"",i=await this.getLinkedUID(e,X.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,X.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,X.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),c=await this.getLinkedValue(e,X.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!c)return null;let l=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,X.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),g=await this.getLinkedUIDs(e,X.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:n,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:c??void 0,position:l??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:g.length>0?g:void 0}}async loadLinkedStyle(e,t){let n=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(n.length>0){let s=n[0].object,o=null;if(s instanceof gr.IRI)o=await this.resolveRefIriSubject(s);else if(s instanceof cr.Literal){let c=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(c)}if(o){let c=await this.loadStyleAsset(o);if(c)return c}this.warnOnce(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBinding_variant"));if(i!==null){let s=this.coerceVariant(i,t);if(s!==void 0)return{id:`inline:${t}`,label:"",variant:s,inline:!0}}return null}async loadStyleAsset(e){let t=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.readAssetLabel(e)??"",i=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),c=this.coerceBoolean(o),l=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=l!==null?this.coerceLabelClass(l,t):void 0,f=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("CommandBindingStyle_source")),g=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:n,variant:s,showIcon:c,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:g,inline:!1}}coerceVariant(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Xf.COMMAND_VARIANT_VALUES.includes(n))return n;this.warnOnce(this.capWarning(`CommandBindingStyle variant "${n}" not in whitelist [${Xf.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Xf.LABEL_CLASS_VALUES.includes(n))return n;this.warnOnce(this.capWarning(`CommandBindingStyle labelClass "${n}" not in whitelist [${Xf.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Xf.STYLE_SOURCE_VALUES.includes(n))return n;this.warnOnce(this.capWarning(`CommandBindingStyle source "${n}" not in whitelist [${Xf.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,n,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&n){for(let s of n)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let n=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(n===i)return!0;let s=this.extractPathBasename(i);if(s&&s===n)return!0;let o=this.extractPathBasename(n);if(o&&o===i)return!0;let c=this.extractAlias(t);if(c&&n===c)return!0;let l=this.extractAlias(e);return!!(l&&l===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(n+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,X.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=await this.resolvePreconditionRef(n[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof gr.IRI)return this.resolveRefIriSubject(e);if(e instanceof cr.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,n){let i=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid")),s=await this.readAssetLabel(e)??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(n>=Jl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||c.length>0||l.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||c.length>0){let g=o.length>0?"all":"any",m=o.length>0?o:c,b=[];for(let _ of m)b.push(await this.loadChildPrecondition(_.object,p,n+1));return{id:i??"",label:s,composite:{op:g,children:b}}}let h=await this.loadChildPrecondition(l[0].object,p,n+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Precondition_hostFunction")),d=await this.loadPreconditionQueryRef(e);return!i||!u&&!f&&!d?null:{id:i,label:s,...u&&{sparqlAsk:u},...f&&{hostFunction:f},...d&&{query:d}}}async loadChildPrecondition(e,t,n){let i=await this.resolvePreconditionRef(e);if(!i){let c=e instanceof cr.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(c,"")}let s=await this.loadPreconditionSubject(i,t,n);if(s)return s;let o=await this.getLiteralValue(i,X.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let n=t[0].object;if(n instanceof gr.IRI)return await this.getLiteralValue(await this.resolveRefIriSubject(n),X.Namespace.EXO.term("Asset_uid"))??void 0;if(n instanceof cr.Literal)return this.normalizeWikilink(n.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,n){if(t>=Jl)return null;let i=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!n?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let c=await this.resolveGroundingRef(o.object);if(!c)continue;let l=await this.getObsidianName(c,X.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(l&&this.matchesReference(l,n.targetClass))return this.loadGroundingDefinition(c,t)}this.warnOnce(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${n.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof gr.IRI)return this.resolveRefIriSubject(e);if(e instanceof cr.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadGroundingByUid(e){let t=await this.findSubjectByUID(e);return t?this.loadGroundingDefinition(t,0):null}async loadGroundingDefinition(e,t){if(t>=Jl)return null;let n=await this.getLiteralValue(e,X.Namespace.EXO.term("Asset_uid"));if(!n)return null;let i=await this.readAssetLabel(e)??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let ae=await this.resolveLabelByUID(o);if(!ae)return this.warnOnce(`Grounding ${n}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=ae}if(s===rM.GroundingType.SERVICE_CALL){let ae=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_serviceId"));ae&&(o=ae)}let c=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetValueRef")),l=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let ae=await this.resolveLabelByUID(u);if(!ae)return this.warnOnce(`Grounding ${n}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=ae}else u&&(f=u);let d=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),g=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_appendExpression")),m=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_replaceFromExpression")),b=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_replaceToExpression")),_=await this.getObsidianWikilinkValue(e,X.Namespace.EXOCMD.term("Grounding_isDefinedBy")),S=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),A=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetClass"));if(A&&!this.looksLikeUUID(A)){let ae=await this.findUidByLabel(A);ae&&(A=ae)}let w=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_targetPrototype")),E=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_targetFolder")),R=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_linkBackProperty")),x=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_inputSchema")),P=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_incrementBy")),N=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_shiftDelta")),$;if(P!=null&&P!==""){let ae=Number.parseInt(String(P),10);Number.isFinite(ae)&&($=ae)}let k=await this.resolvePropertyDefaults(e,n),G=await this.resolveInheritanceRules(e,n),B=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_propertyDefaults"));B!==null&&B!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(n)&&(this.warnOnce(`Grounding ${n}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(n));let M;s===rM.GroundingType.COMPOSITE&&(M=await this.loadCompositeSteps(e,t+1));let ie;if(x)try{let ae=JSON.parse(x);ae?.properties&&(ie=Object.entries(ae.properties).map(([Ie,ye])=>{let Te=ye.type,Re=Te==="string"?ye.format==="asset-reference"?"assetRef":"text":Te,pe=ye.defaultValue!==void 0?ye.defaultValue:ye.default,q={name:Ie,type:Re,label:ye.title??Ie,required:Array.isArray(ae.required)&&ae.required.includes(Ie)};return pe!=null&&(q.defaultValue=String(pe)),typeof ye.targetClassUid=="string"&&(q.targetClassUid=ye.targetClassUid),q}))}catch{}let Z=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),te=Z!==null&&String(Z).trim().toLowerCase()==="true",V=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_labelTemplate")),H=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_direction")),he;if(H!=null){let ae=String(H).trim().toLowerCase();ae==="forward"||ae==="rollback"?he=ae:ae!==""&&this.warnOnce(`Grounding ${n}: exocmd__Grounding_direction value '${H}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let ze=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_bodyTemplate")),ce=await this.getObsidianName(e,X.Namespace.EXOCMD.term("Grounding_templateRef")),ee=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),K=ee!==null&&String(ee).trim().toLowerCase()==="true",Y=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),ne=Y!==null&&String(Y).trim().toLowerCase()==="true",Ce=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("Grounding_omitLabel")),U=Ce!==null&&String(Ce).trim().toLowerCase()==="true",fe={id:n,label:i,type:s,targetProperty:o??void 0,targetValueRef:c??void 0,targetValueLiteral:l??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:g??void 0,replaceFromExpression:m??void 0,replaceToExpression:b??void 0,sparqlUpdate:S??void 0,steps:M,targetClass:A??void 0,targetPrototype:w??void 0,targetFolder:E??void 0,linkBackProperty:R??void 0,incrementBy:$,shiftDelta:N??void 0,propertyDefault:k.length>0?k:void 0,inheritanceRule:G.length>0?G:void 0,isDefinedBy:_??void 0,prefillLabelWithDate:te||void 0,labelTemplate:V??void 0,direction:he,bodyTemplate:ze??void 0,templateRef:ce??void 0,cloneTargetBody:K||void 0,targetsCreatedInstance:ne||void 0,omitLabel:U||void 0};return ie&&(fe.inputSchema=ie),fe}async loadCompositeSteps(e,t){if(t>=Jl)return[];let n=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of n){let o=null;if(s.object instanceof gr.IRI)o=await this.resolveRefIriSubject(s.object);else if(s.object instanceof cr.Literal){let l=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(l)}if(!o)continue;let c=await this.loadGroundingDefinition(o,t);c&&i.push(c)}return i}async resolvePropertyDefaults(e,t){let n=await this.resolvePropertyDefaultsForSubject(e,t,X.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,oM.mergePropertyDefaults)(i.propertyDefaults,n):n}async resolvePropertyDefaultsForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[];for(let o of i){let c=await this.resolveRefTripleObject(o.object);if(!c)continue;let l=await this.getObsidianName(c,X.Namespace.EXOCMD.term("PropertyDefault_property"));if(!l){this.warnOnce(`Grounding ${t}: PropertyDefault asset <${c.value}> missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(l)?await this.resolveLabelByUID(l):l;if(!u){this.warnOnce(`Grounding ${t}: PropertyDefault property UID '${l}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(c,X.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.warnOnce(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await this.findUniversalSingleton();if(!e)return this.logger.debug("[CommandResolver] No exocmd__UniversalDefaultTemplate instance found in the store; universal property-defaults and inheritance-rules will not be applied. This verdict is cached until invalidateCache() is called \u2014 if the store was still warming up, the next invalidation re-resolves it."),this._universalCacheValue=null,null;let t=await this.resolvePropertyDefaultsForSubject(e,fM,X.Namespace.EXOCMD.term("Template_propertyDefault")),n=await this.resolveInheritanceRulesForSubject(e,fM,X.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:t,inheritanceRules:n},this._universalCacheValue}async findUniversalSingleton(){let e=X.Namespace.EXOCMD.term("UniversalDefaultTemplate"),t=e.value,i=(await this.tripleStore.match(void 0,X.Namespace.EXO.term("Instance_class"),e)).map(c=>c.subject).filter(c=>c instanceof gr.IRI);if(i.length>0)return this.pickUniversalSingleton(i);let s=await this.tripleStore.match(void 0,X.Namespace.EXO.term("Instance_class"),void 0),o=[];for(let c of s){let l=!1;if(c.object instanceof gr.IRI)l=c.object.value===t||c.object.value.includes(uM);else if(c.object instanceof cr.Literal){let u=this.unwrapWikilink(c.object.value);l=u==="exocmd__UniversalDefaultTemplate"||u===uM}l&&c.subject instanceof gr.IRI&&o.push(c.subject)}return this.pickUniversalSingleton(o)}pickUniversalSingleton(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=[...e].sort((n,i)=>n.value.localeCompare(i.value));return this.warnOnce(`Multiple UniversalDefaultTemplate singletons found (${t.length}); selecting deterministically by lexicographic UID order: ${t[0].value}`),t[0]}async resolveInheritanceRules(e,t){let n=await this.resolveInheritanceRulesForSubject(e,t,X.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,oM.mergeInheritanceRules)(i.inheritanceRules,n):n}async resolveInheritanceRulesForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[],o=t;for(let c of i){let l=await this.resolveRefTripleObject(c.object);if(!l)continue;let u=await this.resolveLabelRef(l,X.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(l,X.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(l,X.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let w=await this.getObsidianName(l,X.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!w||!w.trim()){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> has exocmd__InheritanceRule_targetClassCondition triple but ref is unresolvable \u2014 entire rule skipped (would otherwise apply unconditionally, broadening scope).`);continue}this.looksLikeUUID(w)?(h=w,p=await this.resolveLabelByUID(w)??void 0):p=w}let g=await this.tripleStore.match(l,X.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),m=[],b=[],_=!1;for(let w of g){let E=null;if(w.object instanceof gr.IRI?E=this.iriToObsidianName(w.object.value)??w.object.value:w.object instanceof cr.Literal&&(E=this.unwrapWikilink(w.object.value)),!E){_=!0;continue}if(this.looksLikeUUID(E)){b.push(E);let R=await this.resolveLabelByUID(E);R&&m.push(R)}else m.push(E)}if(_){this.warnOnce(`Grounding ${o}: InheritanceRule <${l.value}> has unresolvable exocmd__InheritanceRule_targetClassExclusion entry \u2014 entire rule skipped (would otherwise expand scope by silently dropping the excluded class).`);continue}let S=await this.getLiteralValue(l,X.Namespace.EXOCMD.term("InheritanceRule_priority")),A=50;if(S!==null&&S!==""){let w=Number.parseInt(String(S),10);Number.isFinite(w)&&(A=w)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:m,targetClassExclusionUids:b,priority:A})}return s}async resolveRefIriSubject(e){if((await this.tripleStore.match(e,X.Namespace.EXO.term("Asset_uid"),void 0)).length>0)return e;let n=await(0,sM.labelTermBearers)(this.tripleStore,e);return n.length>1?(this._ambiguousRefWarnedKeys.has(e.value)||(this._ambiguousRefWarnedKeys.add(e.value),this.warnOnce(this.capWarning(`Reference <${e.value}> names a label borne by ${n.length} assets (${n.map(i=>i.uid).join(", ")}) \u2014 left unresolved`))),e):n[0]?.subject??e}async resolveRefTripleObject(e){if(e instanceof gr.IRI)return this.resolveRefIriSubject(e);if(e instanceof cr.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let n=await this.getObsidianName(e,t);return n?this.looksLikeUUID(n)?this.resolveLabelByUID(n):n:null}async resolvePropertyDefaultValue(e,t,n){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let c=`${t}|${e}`;return this._fallbackWarnedKeys.has(c)||(this._fallbackWarnedKeys.add(c),this.warnOnce(this.capWarning(`Grounding ${t}: PropertyDefault '${n}' \u2192 value asset ${e} not in store; SKIPPING the property (the executor's own default applies). Previously this emitted a wikilink, i.e. a link written where a value belongs.`))),EZ.STRING_SCALAR_PROPERTIES.has(n)?null:`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,n):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,n,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${n}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,n,i,s){let o=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let c=o.trim();return cM.has(c)?s!==void 0?OZ(c,t,s):xZ(c,t):(this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${c}' \u2014 falling back to wikilink form. Known ids: ${Array.from(cM).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,n,i){let s=await this.getObsidianName(e,X.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,X.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let c=await this.findSubjectByUID(s);return c?this.dispatchSubstitutionToken(c,s,n,i,o):(this.warnOnce(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,X.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof gr.IRI){if(i.object.value===PZ||i.object.value.includes(lM))return!0}else if(i.object instanceof cr.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===lM)return!0}return(await this.tripleStore.match(e,X.Namespace.EXOCMD.term("TokenInvocation_token"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as TokenInvocation via its exocmd__TokenInvocation_token property; exo__Instance_class was absent or unresolved.`),!0):!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,X.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof gr.IRI){if(i.object.value===CZ||i.object.value.includes(aM))return!0}else if(i.object instanceof cr.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===aM)return!0}return(await this.tripleStore.match(e,X.Namespace.EXOCMD.term("SubstitutionToken_resolver"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as SubstitutionToken via its resolver property; exo__Instance_class was absent or unresolved.`),!0):!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,X.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let n=t[0].object;if(n instanceof gr.IRI)return(0,nM.resolveGroundingTypeFromIRI)(n.value);if(n instanceof cr.Literal){let i=n.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,nM.resolveGroundingTypeFromIRI)(`obsidian://vault/${s[1].toLowerCase()}.md`):(this.warnOnce(`[exocmd-grounding-type-literal-form] legacy literal-string form '${i}' for exocmd__Grounding_type on <${e.value}>. Migrate to wikilink form per RFC 9d20c91f Phase 3.`),null)}return null}async expandPrototypeChain(e){if(!e||!this.normalizeWikilink(e))return[];let t=[e],n=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Jl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let c=null;try{let u=await this.findSubjectByUID(o);if(!u)break;c=await this.getLinkedValue(u,X.Namespace.EXO.term("Asset_prototype"))}catch(u){this.logger.debug(this.capWarning(`[expandPrototypeChain] store lookup failed at hop ${s} for '${i}': ${String(u)}`));break}if(!c)break;let l=this.normalizeWikilink(c).toLowerCase();if(n.has(l))break;n.add(l),t.push(c),i=c}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let n=this.extractPathBasename(t);return n&&this.looksLikeUUID(n)?n:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let n=await this.tripleStore.findSubjectsByUUID(e);if(n.length>0)return n[0]}let t=await this.tripleStore.match(void 0,X.Namespace.EXO.term("Asset_uid"),void 0);for(let n of t)if(n.object instanceof cr.Literal&&n.object.value===e)return n.subject;return null}async getLiteralValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof cr.Literal||i instanceof gr.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);return t?this.readAssetLabel(t):null}async readAssetLabel(e){let t=(await this.tripleStore.match(e,X.Namespace.EXO.term("Asset_label"),void 0))[0]?.object;return t instanceof gr.IRI?(0,iM.iriToObsidianName)(t.value)??t.value:t instanceof cr.Literal?t.value:null}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(n=>n.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let n=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),c=await this.getLiteralValue(s,X.Namespace.EXO.term("Asset_uid"));c&&o.add(c);let l=await this.readAssetLabel(s);l&&o.add(l);let u=a((p,h)=>{if(o.has(p))return;let g=n.get(p);(g===void 0||h<g)&&n.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:g}=p;if(g>=Jl||i.has(h.value))continue;i.add(h.value);let m=await this.tripleStore.match(h,X.Namespace.EXO.term("Class_superClass"),void 0);for(let b of m){let _=b.object;if(!(_ instanceof gr.IRI))continue;let S=g+1,A=_.value.startsWith("obsidian://vault/"),w=this.iriToObsidianName(_.value);w&&u(w,S);let E=null;if(A?E=_:w&&(E=await this.resolveClassFileIRI(w)),!E)continue;let R=await this.getLiteralValue(E,X.Namespace.EXO.term("Asset_uid"));R&&u(R,S),i.has(E.value)||f.push({fileIRI:E,depth:S})}}let d=Array.from(n.entries()).map(([p,h])=>({ref:p,depth:h}));return this._ancestorDepthCache.set(e,d),d}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){return(0,sM.findUidByAssetLabel)(this.tripleStore,e)}async getLinkedUID(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof gr.IRI){let s=await this.tripleStore.match(await this.resolveRefIriSubject(i),X.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof cr.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof cr.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let n=await this.tripleStore.match(e,t,void 0),i=[];for(let s of n){let o=s.object;if(o instanceof gr.IRI){let c=await this.tripleStore.match(await this.resolveRefIriSubject(o),X.Namespace.EXO.term("Asset_uid"),void 0);if(c.length>0&&c[0].object instanceof cr.Literal)i.push(c[0].object.value);else{let l=o.value.split("/").pop()?.replace(".md","");l&&i.push(l)}}else if(o instanceof cr.Literal){let c=this.normalizeWikilink(o.value);c&&i.push(c)}}return i}async getLinkedValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof cr.Literal?this.normalizeWikilink(i.value):i instanceof gr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof cr.Literal?this.unwrapWikilink(i.value):i instanceof gr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let n=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(n)return n[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof cr.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof gr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let n=t[1],i=await this.findSubjectByUID(n);if(!i)return e;let s=await this.readAssetLabel(i);return s?e.replace(`[[${n}]]`,`[[${n}|${s}]]`):e}iriToObsidianName(e){return(0,iM.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(0,n):t}};ma.CommandResolver=bI;ma.CommandResolver=bI=bZ([(0,SZ.injectable)(),_Z("design:paramtypes",[Object,Object])],bI)});var SI=T(_I=>{"use strict";Object.defineProperty(_I,"__esModule",{value:!0});_I.validateExoQLAllowlist=FZ;var Nb=Nh();function FZ(r){if(!r||typeof r!="object")return;let e=r;if(e.type==="update"){let t=r.updates??[];for(let n of t)if(n?.type==="load")throw new Nb.ExoQLForbiddenKeywordError("LOAD");throw new Nb.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,n=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||n)throw new Nb.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)kb(t);if(Array.isArray(e.template))for(let t of e.template)kb(t)}}a(FZ,"validateExoQLAllowlist");function kb(r){if(!r||typeof r!="object")return;if(r.type==="service")throw new Nb.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(r.patterns))for(let t of r.patterns)kb(t);let e=r.where;if(Array.isArray(e))for(let t of e)kb(t)}a(kb,"walkPatternForBannedKeywords")});var wI=T(Mb=>{"use strict";Object.defineProperty(Mb,"__esModule",{value:!0});Mb.DEFAULT_EVAL_CONFIG=void 0;Mb.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var jb=T(EI=>{"use strict";Object.defineProperty(EI,"__esModule",{value:!0});EI.evaluateWithExoEval=$Z;var DZ=Tf(),LZ=Of(),NZ=Yf(),kZ=SI(),MZ=wI(),jZ=Nh();async function $Z(r,e={}){if(typeof r!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let n=new DZ.ExoQLParser().parse(r);if((0,kZ.validateExoQLAllowlist)(n),!{...MZ.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new jZ.ExoQLEvalDisabledError;let s="queryType"in n&&typeof n.queryType=="string"?n.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let c=new LZ.ExoQLAlgebraTranslator().translate(n),l=new NZ.ExoQLQueryExecutor(e.store);return l.isAskQuery(c)?{kind:"ask",result:await l.executeAsk(c)}:l.isConstructQuery(c)?{kind:"construct",triples:await l.executeConstruct(c)}:{kind:"select",rows:await l.executeAll(c)}}a($Z,"evaluateWithExoEval")});var wo=T($b=>{"use strict";Object.defineProperty($b,"__esModule",{value:!0});$b.DateFormatter=void 0;var vI=class r{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${i}T${s}:${o}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${n}-${i}]]"`}static getTodayWikilink(){return r.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}static parseWikilink(e){let n=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return n?n[1]:null}static addDays(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),r.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[n,i,s]=t,o=new Date(n,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return r.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return r.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};$b.DateFormatter=vI});var Mh=T(Ub=>{"use strict";Object.defineProperty(Ub,"__esModule",{value:!0});Ub.liveClock=UZ;Ub.frozenClock=BZ;function UZ(){return{now:a(()=>new Date,"now")}}a(UZ,"liveClock");function BZ(r){let e=new Date(r);return{now:a(()=>new Date(e.getTime()),"now")}}a(BZ,"frozenClock")});var hM=T(ga=>{"use strict";var VZ=ga&&ga.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},GZ=ga&&ga.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},$h;Object.defineProperty(ga,"__esModule",{value:!0});ga.PreconditionEvaluator=void 0;var qZ=lt(),WZ=Tf(),zZ=Of(),pM=Yf(),HZ=jb(),jh=wo(),KZ=Mh(),Uh=$h=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,n){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=n?.clock??(0,KZ.liveClock)()}async evaluate(e,t,n){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,n,i)==="yes"}async evaluateNode(e,t,n,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let c=await Promise.all(o.map(l=>this.evaluateNode(l,t,n,i)));return s==="all"?c.includes("no")?"no":c.includes("unknown")?"unknown":"yes":c.includes("yes")?"yes":c.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,n,i);return s==="unknown"?"unknown":s==="yes"?"no":"yes"}return e.sparqlAsk?await this.evaluateSparqlAskMemoized(e.sparqlAsk,t,i)?"yes":"no":e.query?await this.evaluateQueryRef(e.query,t)?"yes":"no":e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,n)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,n){let i=n.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return n.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return!1;let i=this.substituteVariables(n,t),s=await(0,HZ.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,n){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,n):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,$h.SENTINEL_IRI),i=new WZ.ExoQLParser().parse(t),o=new zZ.ExoQLAlgebraTranslator().translate(i);return new pM.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,n){let i=this.hostFunctions.get(e);if(!i)return!0;let s=n?{...n,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let n=$h.TEMPORAL_TOKEN.test(e),i=n?jh.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||n&&s.day!==i){let l=this.compileAsk(e);if(!l)return!1;s={day:i,compiled:l},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll($h.SENTINEL_IRI,t));return await new pM.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let n=this.clock.now(),i=n.toISOString(),s=n.getFullYear(),o=n.getMonth(),c=n.getDate(),l=n.getDay(),u=jh.DateFormatter.toDateString(n),f=jh.DateFormatter.toDateString(new Date(s,o,c-1)),d=(l+6)%7,p=jh.DateFormatter.toDateString(new Date(s,o,c-d)),h=jh.DateFormatter.toDateString(new Date(s,o,c-d-7)),g=`${s}-${String(o+1).padStart(2,"0")}-01`,m=o===0?11:o-1,_=`${o===0?s-1:s}-${String(m+1).padStart(2,"0")}-01`,S=`${s}-01-01`;return e.replace(/\$target\b/g,`<${t}>`).replace(/\$now\b/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday\b/g,`"${f}"^^xsd:date`).replace(/\$thisWeekStart\b/g,`"${p}"^^xsd:date`).replace(/\$lastWeekStart\b/g,`"${h}"^^xsd:date`).replace(/\$thisMonthStart\b/g,`"${g}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${_}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${S}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};ga.PreconditionEvaluator=Uh;Uh.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Uh.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;ga.PreconditionEvaluator=Uh=$h=VZ([(0,qZ.injectable)(),GZ("design:paramtypes",[Object,Object,Object])],Uh)});var mM=T(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.hasUidFilename=ya.hasNonUidFilename=void 0;ya.registerDefaultHostFunctions=QZ;var YZ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");ya.hasNonUidFilename=YZ;var XZ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");ya.hasUidFilename=XZ;function QZ(r){r.registerHostFunction("hasNonUidFilename",ya.hasNonUidFilename),r.registerHostFunction("hasUidFilename",ya.hasUidFilename)}a(QZ,"registerDefaultHostFunctions")});var Vb=T(Bb=>{"use strict";Object.defineProperty(Bb,"__esModule",{value:!0});Bb.liveUidGenerator=JZ;Bb.seededUidGenerator=eee;var TI=sf();function JZ(){return{next:a(()=>(0,TI.v4)(),"next")}}a(JZ,"liveUidGenerator");var ZZ="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function eee(r){let e=0,t=(0,TI.v5)(r,ZZ);return{next:a(()=>{let n=`${r}#${e}`;return e+=1,(0,TI.v5)(n,t)},"next")}}a(eee,"seededUidGenerator")});var Wb=T(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.registerResolver=yr;Ac.getResolver=nee;Ac.isResolverModifierAware=iee;Ac.getRegisteredResolverIds=see;Ac.clearResolvers=oee;Ac.installDefaultResolvers=gee;var tee=wo(),gM=gc(),qb=new Map,AI=new Set,ree=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function yr(r,e,t=!1){qb.set(r,e),t&&AI.add(r)}a(yr,"registerResolver");function nee(r){return qb.get(r)}a(nee,"getResolver");function iee(r){return AI.has(r)}a(iee,"isResolverModifierAware");function see(){return Array.from(qb.keys())}a(see,"getRegisteredResolverIds");function oee(){qb.clear(),AI.clear()}a(oee,"clearResolvers");function vn(r){return r<10?`0${r}`:String(r)}a(vn,"pad2");var aee=["January","February","March","April","May","June","July","August","September","October","November","December"],cee=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],lee=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],uee=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function fee(r){let e=["th","st","nd","rd"],t=r%100;return`${r}${e[(t-20)%10]||e[t]||e[0]}`}a(fee,"ordinalDay");var dee=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function pee(r,e){let t=(r.getHours()+11)%12+1;return e.replace(dee,n=>{switch(n){case"YYYY":return String(r.getFullYear());case"YY":return vn(r.getFullYear()%100);case"MMMM":return aee[r.getMonth()];case"MMM":return cee[r.getMonth()];case"MM":return vn(r.getMonth()+1);case"M":return String(r.getMonth()+1);case"Do":return fee(r.getDate());case"DD":return vn(r.getDate());case"D":return String(r.getDate());case"dddd":return lee[r.getDay()];case"ddd":return uee[r.getDay()];case"HH":return vn(r.getHours());case"H":return String(r.getHours());case"hh":return vn(t);case"h":return String(t);case"mm":return vn(r.getMinutes());case"m":return String(r.getMinutes());case"ss":return vn(r.getSeconds());case"s":return String(r.getSeconds());case"A":return r.getHours()<12?"AM":"PM";case"a":return r.getHours()<12?"am":"pm";default:return n}})}a(pee,"formatDate");function yM(r,e,t){let n=r.getDate(),i=new Date(r.getTime());i.setDate(1),t==="M"?i.setMonth(i.getMonth()+e):i.setFullYear(i.getFullYear()+e);let s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(n,s)),i}a(yM,"addMonthsClamped");function hee(r,e){if(!e)return r;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return r;let n=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(r.getTime());switch(i){case"d":s.setDate(s.getDate()+n);break;case"w":s.setDate(s.getDate()+n*7);break;case"M":s=yM(s,n,"M");break;case"y":s=yM(s,n,"y");break}return isNaN(s.getTime())?r:s}a(hee,"applyDateOffset");function mee(r){if(!r)return{offset:null,format:null};let e=r.indexOf(":");if(e<0)return{offset:r,format:null};let t=r.slice(0,e),n=r.slice(e+1);return{offset:t||null,format:n||null}}a(mee,"parseDateModifier");function Gb(r,e){return(t,n)=>{let{offset:i,format:s}=mee(n),o=new Date;return r!==0&&o.setDate(o.getDate()+r),o=hee(o,i),pee(o,s??e)}}a(Gb,"makeDateResolver");function gee(){yr("today",()=>{let r=new Date;return`${r.getFullYear()}-${vn(r.getMonth()+1)}-${vn(r.getDate())}`}),yr("todayStart",()=>tee.DateFormatter.getTodayStartTimestamp()),yr("date",Gb(0,"YYYY-MM-DD"),!0),yr("now",Gb(0,"YYYY-MM-DDTHH:mm:ss"),!0),yr("tomorrow",Gb(1,"YYYY-MM-DD"),!0),yr("yesterday",Gb(-1,"YYYY-MM-DD"),!0),yr("target",r=>r.targetIRI?`"[[${r.targetIRI}]]"`:""),yr("targetFolder",r=>{if(!r.targetFilePath)return"";let e=r.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),yr("createdInstance",r=>{let e=r.createdInstancePath;if(!e)return null;let t=e.replace(/\.md$/i,"").replace(/^\/+/,""),n=t.split("/").pop()??t;return`"[[${ree.test(n)?n:t}]]"`}),yr("randomUUIDv4",()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();throw new Error("randomUUIDv4 resolver requires crypto.randomUUID() \u2014 runtime is missing Node crypto / Web Crypto API.")}),yr("nowTimestamp",()=>{let r=new Date;return`${r.getFullYear()}-${vn(r.getMonth()+1)}-${vn(r.getDate())}T${vn(r.getHours())}:${vn(r.getMinutes())}:${vn(r.getSeconds())}`}),yr("nowDate",()=>{let r=new Date;return`${r.getFullYear()}-${vn(r.getMonth()+1)}-${vn(r.getDate())}`}),yr("nowYear",()=>String(new Date().getFullYear())),yr("nowMonth",()=>vn(new Date().getMonth()+1)),yr("userInputLabel",r=>{let e=r.userInput?.label;return typeof e=="string"?e:""}),yr("userInput",(r,e)=>{if(!e)return null;let t=r.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),yr("targetProperty",(r,e)=>{if(!e||!r.targetFm)return null;let t=r.targetFm[e];return t==null?null:Array.isArray(t)?t.map(n=>(0,gM.decodeYamlBlockScalar)(String(n),!0)):(0,gM.decodeYamlBlockScalar)(String(t))}),yr("targetRefProperty",(r,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!n||!i)return null;let s=r.targetRefFm?.[n];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),yr("labelAsArray",r=>{let e=r.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),yr("groundingTargetClass",r=>r.groundingTargetClassUid?`"[[${r.groundingTargetClassUid}]]"`:null),yr("targetClassSelf",r=>{if(!r.targetFilePath)return null;let e=r.targetFilePath.replace(/^\/+/,""),n=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return n.length>0?`"[[${n}]]"`:null})}a(gee,"installDefaultResolvers")});var RI=T(zb=>{"use strict";Object.defineProperty(zb,"__esModule",{value:!0});zb.resolveTemplateBody=bee;zb.stripTemplateFrontmatter=_ee;var II=Wb();(0,II.installDefaultResolvers)();var yee=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function bee(r,e={}){return r.replace(yee,(t,n,i)=>{let s=(0,II.getResolver)(n);if(s===void 0)return t;let o=s(e,i.length>0?i:void 0);return typeof o!="string"||o.length===0?t:(0,II.isResolverModifierAware)(n)?o:o+i})}a(bee,"resolveTemplateBody");function _ee(r){let e=r.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?r.slice(e[0].length):r}a(_ee,"stripTemplateFrontmatter")});var Yb=T(Qf=>{"use strict";Object.defineProperty(Qf,"__esModule",{value:!0});Qf.registerOrderSpecLoader=See;Qf.clearOrderSpecLoader=wee;Qf.loadDefaultSpec=Eee;Qf.orderProperties=vee;var Hb=null,Ic,Kb=!1;function See(r){Hb=r,Ic=void 0,Kb=!1}a(See,"registerOrderSpecLoader");function wee(){Hb=null,Ic=void 0,Kb=!1}a(wee,"clearOrderSpecLoader");function Eee(){if(Ic!==void 0)return Ic;if(!Hb)return Ic=null,null;try{Ic=Hb()}catch(r){Kb||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",r),Kb=!0),Ic=null}return Ic}a(Eee,"loadDefaultSpec");function vee(r,e){if(!e||e.head.length===0&&e.tail.length===0)return r;let t=Object.keys(r),n=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),c=t.filter(u=>!n.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&c.sort((u,f)=>u.localeCompare(f));let l={};for(let u of s)l[u]=r[u];for(let u of c)l[u]=r[u];for(let u of o)l[u]=r[u];return l}a(vee,"orderProperties")});var Fi=T(Xb=>{"use strict";Object.defineProperty(Xb,"__esModule",{value:!0});Xb.DI_TOKENS=void 0;Xb.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),ClassCreationService:Symbol.for("ClassCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),RenameToUidService:Symbol.for("RenameToUidService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var xI=T(Qb=>{"use strict";Object.defineProperty(Qb,"__esModule",{value:!0});Qb.RDFVocabularyMapper=void 0;var Dr=Ai(),bM=Le(),Ae=At(),CI=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",Ae.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",Ae.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",Ae.Namespace.RDFS.term("subClassOf")],["exo__Property_range",Ae.Namespace.RDFS.term("range")],["exo__Property_domain",Ae.Namespace.RDFS.term("domain")],["exo__Property_superProperty",Ae.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Dr.Triple(Ae.Namespace.EXO.term("Asset"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.RDFS.term("Resource"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Class"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.RDFS.term("Class"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.RDF.term("Property"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Task"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Project"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Area"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("Workflow"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("WorkflowState"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EMS.term("WorkflowTransition"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("Command"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("Precondition"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("Grounding"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e.push(new Dr.Triple(Ae.Namespace.EXOCMD.term("CommandBinding"),Ae.Namespace.RDFS.term("subClassOf"),Ae.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Dr.Triple(Ae.Namespace.EXO.term("Instance_class"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDF.term("type"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Asset_isDefinedBy"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("isDefinedBy"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Class_superClass"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("subClassOf"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property_range"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("range"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property_domain"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("domain"))),e.push(new Dr.Triple(Ae.Namespace.EXO.term("Property_superProperty"),Ae.Namespace.RDFS.term("subPropertyOf"),Ae.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,n){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(n instanceof bM.IRI)s=n;else{let o=Ae.Namespace.fromPropertyKey(n);s=o?o.namespace.term(o.localName):new bM.IRI(n)}return new Dr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};Qb.RDFVocabularyMapper=CI});var Jb=T(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.OBSIDIAN_VAULT_SCHEME=void 0;ba.vaultPathToIRI=Tee;ba.iriToVaultPath=Aee;ba.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function Tee(r){let e=r.startsWith("./")?r.slice(2):r;return`${ba.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(Tee,"vaultPathToIRI");function Aee(r){if(!r.startsWith(ba.OBSIDIAN_VAULT_SCHEME))return null;let e=r.slice(ba.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(Aee,"iriToVaultPath")});var e_=T(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});Bh.derivePath=_M;Bh.deriveUrl=Iee;Bh.deriveLegacyFlatPath=Ree;var OI="assetspaces",Zb=/^[A-Za-z0-9._-]+$/;function _M(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let n=t.split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!Zb.test(i)||!Zb.test(s)?null:`${OI}/${i}/${s}`}a(_M,"derivePath");function Iee(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${OI}/`;if(!e.startsWith(t))return null;let n=e.slice(t.length).split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!Zb.test(i)||!Zb.test(s)?null:`https://github.com/${i}/${s}`}a(Iee,"deriveUrl");function Ree(r){let e=_M(r);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let n=t.startsWith("exoas-")?t.slice(6):t;return n.length===0?null:`${OI}/${n}`}a(Ree,"deriveLegacyFlatPath")});var t_=T(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.FILE_SPACE_CLASS_UID=void 0;Ts.frontmatterDeclaresFileSpace=xee;Ts.discoverFileSpaceExclusions=Pee;var Cee=e_();Ts.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var SM=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,PI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function EM(r){let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;SM.lastIndex=0;let i;for(;(i=SM.exec(n))!==null;)t.push(i[1].trim())}return t}a(EM,"wikilinkTargets");function xee(r){return r?EM(r.exo__Instance_class).some(e=>PI.test(e)&&e.toLowerCase()===Ts.FILE_SPACE_CLASS_UID):!1}a(xee,"frontmatterDeclaresFileSpace");function wM(r,e){try{return r.getFrontmatter(e)}catch{return null}}a(wM,"readFrontmatterSafe");function Oee(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(Oee,"readSource");function Pee(r){let e=[],t=[],n=[],i=new Map,s=a((c,l)=>{if(PI.test(c))return c.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;let u=r.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=wM(r,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(c=>c.some(l=>PI.test(l)&&l.toLowerCase()===Ts.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of r.getAllFiles()){let l=wM(r,c);if(!l)continue;let u=EM(l.exo__Instance_class);if(!u.some(h=>s(h,c.path)))continue;t.push(c.path),o(u)||n.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Ts.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=Oee(l);if(f===null){n.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,Cee.derivePath)(f);if(d===null){n.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;c.path.startsWith(p)&&n.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${p} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(p)}return{prefixes:e,declarationPaths:t,warnings:n}}a(Pee,"discoverFileSpaceExclusions")});var eu=T(kt=>{"use strict";var Fee=kt&&kt.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Dee=kt&&kt.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},vM=kt&&kt.__param||function(r,e){return function(t,n){e(t,n,r)}},LI;Object.defineProperty(kt,"__esModule",{value:!0});kt.NoteToRDFConverter=kt.LEGACY_YAML_KEYS=kt.LEGACY_UNPREFIXED_ASSET_FIELDS=kt.UNPREFIXED_ASSET_FIELDS=void 0;kt.canonicalYamlKey=jee;kt.isPosixBracketExpression=IM;kt.normaliseExcludedFolders=RM;kt.isPathExcluded=CM;var FI=lt(),Lr=Ai(),As=Le(),jn=He(),TM=sr(),Zt=At(),AM=Fi(),Lee=xI(),Nee=mh(),DI=Jb(),Di=OT(),kee=t_();kt.UNPREFIXED_ASSET_FIELDS=new Set(["draft","pinned","aliases"]);kt.LEGACY_UNPREFIXED_ASSET_FIELDS=new Set(["archived"]);kt.LEGACY_YAML_KEYS=new Map([...kt.LEGACY_UNPREFIXED_ASSET_FIELDS].map(r=>[`exo__Asset_${r}`,[r]]));var Mee=/^exo__Asset_(.+)$/;function jee(r){let e=Mee.exec(r);return e&&kt.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(r)?`exo__Asset_${r}`:r}a(jee,"canonicalYamlKey");function IM(r){return/^:[^\s[\]|]+:$/.test(r)}a(IM,"isPosixBracketExpression");function RM(r){return Array.isArray(r)?r.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(RM,"normaliseExcludedFolders");function CM(r,e){if(e.length===0)return!1;let t=r.replace(/\\/g,"/");for(let n of e)if(t.startsWith(n))return!0;return!1}a(CM,"isPathExcluded");function $ee(r){if(!r)return"";let e=r.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a($ee,"normaliseSubjectIriPrefix");var Zl=LI=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=Nee.NullLogger,n={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.preResolvedTargetFm=new Map,this.vocabularyMapper=new Lee.RDFVocabularyMapper,this.subjectIriPrefix=$ee(n.subjectIriPrefix),this.emitInstanceClassAsUid=n.emitInstanceClassAsUid??!1}async convertNote(e){let t=this.vault.getFrontmatterWithFallback?await this.vault.getFrontmatterWithFallback(e):this.vault.getFrontmatter(e);return this.convertNoteFromFrontmatter(e,t)}async convertNoteFromFrontmatter(e,t){if(!t)return[];await this.preResolveWikilinkTargets(t);let n=this.notePathToIRI(e.path),i=Zt.Namespace.EXO.term("Asset_filename"),s=new Lr.Triple(n,i,new jn.Literal(e.basename));if(Di.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,n){this.pendingExtraTriples=[];let i=[n],s=this.notePathToIRI(e.path),o,c,l,u=!1,f=Zt.Namespace.EXO.term("Statement").value;for(let[m,b]of Object.entries(t)){if(kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)&&Object.prototype.hasOwnProperty.call(t,`exo__Asset_${m}`))continue;let _=kt.UNPREFIXED_ASSET_FIELDS.has(m)||kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)?`exo__Asset_${m}`:m;if(!this.isExocortexProperty(_))continue;let S=this.propertyKeyToIRI(_),A=Array.isArray(b)?b:[b];for(let w of A)if(!((m==="exo__Asset_label"||kt.UNPREFIXED_ASSET_FIELDS.has(m)||kt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m))&&(w==null||typeof w=="string"&&w.trim()==="")))if(m==="exo__Instance_class"){let E=this.valueToClassURI(w);i.push(new Lr.Triple(s,S,E))}else{let E=await this.valueToRDFObject(w,e,S);if(_==="exo__Statement_subject"&&o===void 0){let R=E.find(x=>x instanceof As.IRI);R&&(o=R)}else if(_==="exo__Statement_predicate"&&c===void 0){let R=E.find(x=>x instanceof As.IRI);R&&(c=R)}else _==="exo__Statement_object"&&l===void 0&&(l=E[0]);for(let R of E)if(i.push(new Lr.Triple(s,S,R)),this.vocabularyMapper.hasMappingFor(m)&&R instanceof As.IRI){let x=this.vocabularyMapper.generateMappedTriple(s,m,R);x&&i.push(x)}}if(m==="exo__Instance_class")for(let w of A){let E=this.valueToClassURI(w);if(E instanceof As.IRI){let R=Zt.Namespace.RDF.term("type");i.push(new Lr.Triple(s,R,E)),E.value===f&&(u=!0)}}if(m==="exo__Asset_label"){let w=Zt.Namespace.RDFS.term("label");for(let E of A)typeof E=="string"&&E.length>0&&i.push(new Lr.Triple(s,w,new jn.Literal(E)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let m=Zt.Namespace.RDFS.term("label"),b=Zt.Namespace.EXO.term("Asset_label"),_=new jn.Literal(e.basename);i.push(new Lr.Triple(s,m,_)),i.push(new Lr.Triple(s,b,_))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&c&&l&&i.push(new Lr.Triple(o,c,l));let g=await this.convertBodyWikilinks(e,s);return i.push(...g),i}async convertExo003Note(e,t){let n=Di.Exo003Parser.parse(t);if(!n.success||!n.metadata)return[];let i=n.metadata,s=[];switch(i.metadata){case Di.Exo003MetadataType.Namespace:break;case Di.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Di.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Di.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Di.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let n=this.notePathToIRI(e.path),i=new As.IRI(t.uri);return[new Lr.Triple(n,Zt.Namespace.OWL.term("sameAs"),i),new Lr.Triple(i,Zt.Namespace.OWL.term("sameAs"),n)]}convertExo003BlankNode(e,t){let n=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new Lr.Triple(n,Zt.Namespace.OWL.term("sameAs"),new TM.BlankNode(i))]}convertExo003Statement(e,t){let n=[];try{let i=this.createExo003ReferenceResolver(e),s=Di.Exo003Parser.toTriple(t,i);n.push(s);let o=this.notePathToIRI(e.path);n.push(new Lr.Triple(o,Zt.Namespace.RDF.term("value"),s.subject))}catch{}return n}async convertExo003Body(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new As.IRI(c.value):new TM.BlankNode(c.value),f=new As.IRI(l.value),d=Di.Exo003Parser.toLiteral(t,s.trim());n.push(new Lr.Triple(u,f,d));let p=this.notePathToIRI(e.path);n.push(new Lr.Triple(p,Zt.Namespace.RDF.term("value"),u))}catch{}return n}createExo003ReferenceResolver(e){return t=>{let n=this.extractWikilink(t),i=n||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.targetFrontmatter(s);if(o&&Di.Exo003Parser.isExo003Format(o)){let c=Di.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Di.Exo003MetadataType.Anchor||l.metadata===Di.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Di.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!n&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders,onFileTriples:e.onFileTriples})).triples}async convertVaultWithValidation(e={}){let t=e.files??this.vault.getAllFiles(),n=[],i=[],s=e.strict??!1,o=0,c=0,l=0,u=e.fileSpacePrefixes?{prefixes:e.fileSpacePrefixes,declarationPaths:[],warnings:[]}:(0,kee.discoverFileSpaceExclusions)(this.vault);for(let b of u.warnings)this.logger.warn(`FileSpace discovery: ${b}`);let f=[...RM(e.excludedFolders),...u.prefixes],d=f.length===0?t:t.filter(b=>!CM(b.path,f)),p=e.onProgress,h=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:LI.INDEX_PROGRESS_INTERVAL,g=d.length,m=0;for(let b of d){if(m++,p&&m%h===0&&m<g)try{p(m,g)}catch{}try{let _=this.vault.getFrontmatter(b);if(!_){let w=this.vault.getFrontmatterParseFailure?.(b);if(w){if(s)throw new Error(`Unparseable frontmatter in "${b.path}": ${w.reason}`);i.push({path:b.path,reason:`Unparseable frontmatter: ${w.reason}`}),l++,this.logger.info(`Skipping file with unparseable frontmatter: ${b.path}`,{reason:w.reason});continue}}let S=_?this.validateExocortexAsset(_,b.basename):null;if(S){if(s)throw new Error(`Invariant violation in "${b.path}": ${S.message}`);i.push({path:b.path,reason:`Invariant violation: ${S.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${b.path}`,{code:S.code,property:S.property,reason:S.message});continue}let A=await this.convertNote(b);if(n.push(...A),e.onFileTriples)try{e.onFileTriples(b,A)}catch{}}catch(_){let S=_ instanceof Error?_.message:String(_);if(s)throw new Error(`Invalid IRI for file "${b.path}": ${S}`);i.push({path:b.path,reason:`Invalid IRI: ${S}`}),c++,this.logger.info(`Skipping file with invalid IRI: ${b.path}`,{reason:S})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),l>0&&this.logger.warn(`Skipped ${l} file${l===1?"":"s"} with unparseable frontmatter during indexing (paths in developer console)`,{count:l}),c>0&&this.logger.warn(`Skipped ${c} file${c===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:c}),{triples:n,skippedFiles:i,summary:{total:d.length,indexed:d.length-i.length,skipped:i.length},fileSpaces:u}}static inferLabelFromBasename(e){return Zt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let n=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(n):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(n(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&n(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let p=this.removeQuotes(d),g=(this.extractWikilink(p)??p).trim(),m=g.indexOf("__");m>0&&Zt.Namespace.isValidPrefix(g.slice(0,m))&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let n of e){let i=(0,DI.vaultPathToIRI)(n.path);As.IRI.isValidIRI(i)||t.push({path:n.path,reason:`Path "${n.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new As.IRI((0,DI.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new As.IRI((0,DI.vaultPathToIRI)(e))}isExocortexProperty(e){return Zt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Zt.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let n=this.targetFrontmatter(t);if(!n)return;let i=n.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof As.IRI&&(this.pendingExtraTriples.push(new Lr.Triple(e,Zt.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new Lr.Triple(e,Zt.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,n){if(typeof e=="string"){let i=this.removeQuotes(e);if(n?.value.endsWith("#TokenInvocation_parameter"))return[new jn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new jn.Literal(u);if(n?.value.endsWith("#Grounding_targetValueRef")||n?.value.endsWith("#Grounding_targetValueSubstitution")||n?.value.endsWith("#Grounding_targetClass")||n?.value.endsWith("#Grounding_type")||n?.value.endsWith("#PropertyDefault_value"))return[l];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let g=this.targetFrontmatter(o);if(g){let A=g.exo__Asset_label;if(typeof A=="string"){let w=this.expandClassValue(A);if(w)return this.emitTypeTripleForEnumInstance(w,o),[w]}}let m=n?.value.endsWith("#Asset_prototype")||n?.value.endsWith("/Asset_prototype"),_=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(A=>A.trim()).filter(Boolean),S=_.length>0&&_.some(A=>n?.value.endsWith(`#${A}`));return m||S?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new jn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new jn.Literal(i,Zt.Namespace.XSD.term("dateTime"))]:[new jn.Literal(i)]}return typeof e=="boolean"?[new jn.Literal(e.toString())]:typeof e=="number"?[new jn.Literal(e.toString(),Number.isInteger(e)?Zt.Namespace.XSD.term("integer"):Zt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new jn.Literal(e.toISOString(),Zt.Namespace.XSD.term("dateTime"))]:[new jn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1];return n.includes("|")?n.split("|")[0]:n}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1],i=n.indexOf("|");return i>=0?n.substring(i+1).trim():null}targetFrontmatter(e){return this.vault.getFrontmatter(e)??this.preResolvedTargetFm.get(e.path)??null}async preResolveWikilinkTargets(e){let t=this.vault.getFrontmatterWithFallback?.bind(this.vault);if(t)for(let n of Object.values(e)){let i=Array.isArray(n)?n:n==null?[]:[n];for(let s of i){if(typeof s!="string")continue;let o=this.removeQuotes(s),c=this.extractWikilink(o);if(!c||!this.isUUID(c))continue;let l=this.vault.getFirstLinkpathDest(c,"");!l||this.preResolvedTargetFm.has(l.path)||this.vault.getFrontmatter(l)||this.preResolvedTargetFm.set(l.path,await t(l))}}}valueToClassURI(e){if(typeof e!="string")return new jn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):l;let u=this.targetFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):d}}return this.notePathToIRI(c.path)}}return new jn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Zt.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),n=Zt.Namespace.fromPropertyKey(t);return!n||/[\s()]/.test(n.localName)?null:n.namespace.term(n.localName)}extractBodyContent(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return t.replace(n,"")}extractBodyWikilinks(e){let t=new Set,n,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(n=i.exec(e))!==null;)n[1]&&!IM(n[1].trim())&&t.add(n[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=Zt.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);n.push(new Lr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?n.push(new Lr.Triple(t,c,f)):n.push(new Lr.Triple(t,c,new jn.Literal(l)))}else n.push(new Lr.Triple(t,c,new jn.Literal(l)))}}catch{}return n}};kt.NoteToRDFConverter=Zl;Zl.INDEX_PROGRESS_INTERVAL=200;Zl.SkippedFileInfo=class{constructor(r,e){this.path=r,this.reason=e}};Zl.VaultValidationResult=class{constructor(r,e,t){this.triples=r,this.skippedFiles=e,this.summary=t}};Zl.VaultValidationOptions=class{constructor(r=!1){this.strict=r}};kt.NoteToRDFConverter=Zl=LI=Fee([(0,FI.injectable)(),vM(0,(0,FI.inject)(AM.DI_TOKENS.IVaultAdapter)),vM(1,(0,FI.inject)(AM.DI_TOKENS.ILogger)),Dee("design:paramtypes",[Object,Object,Object])],Zl)});var tu=T(n_=>{"use strict";Object.defineProperty(n_,"__esModule",{value:!0});n_.FrontmatterService=void 0;var xM=Yb(),r_=gc(),Jf=eu(),Uee=At(),Zf=class r{static{a(this,"FrontmatterService")}parse(e){let t=e.match(r.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}static splitFlowSequence(e){let t=[],n="",i=null,s=0;for(let c=0;c<e.length;c++){let l=e[c];if(i!==null){if(n+=l,l==="\\"&&i==='"'){n+=e[++c]??"";continue}l===i&&(i=null);continue}if(l==='"'||l==="'"){i=l,n+=l;continue}if(l==="["||l==="{"){s++,n+=l;continue}if(l==="]"||l==="}"){if(s--,s<0)return null;n+=l;continue}if(l===","&&s===0){t.push(n.trim()),n="";continue}n+=l}if(i!==null||s!==0)return null;let o=n.trim();return o!==""&&t.push(o),t}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let n={},i=t.content.split(/\r?\n/),s=null,o=null,c=[],l=null,u=a(()=>{s!==null&&o!==null&&(n[s]=o),s=null,o=null,c=[]},"flushArray");for(let f of i){if(l!==null){if(f.trim()===""){c.push(f);continue}if(/^[ \t]/.test(f)){n[l]=[n[l],...c,f].join(`
|
|
120
120
|
`),c=[];continue}l=null,c=[]}let d=r.ARRAY_ITEM_LINE.exec(f);if(d){s!==null&&o!==null&&o.push(d[1].trim()),c=[];continue}let p=o!==null&&o.length>0?o:null,h=p!==null&&r.BLOCK_SCALAR_HEADER.test(p[p.length-1].split(`
|
|
121
121
|
`,1)[0]);if(f.trim()===""){if(p!==null){c.push(f);continue}u();continue}if(o!==null&&!h&&/^[ \t]+#/.test(f)){c=[];continue}if(p!==null&&/^[ \t]/.test(f)){let _=p.length-1;p[_]=[p[_],...c,f].join(`
|
|
122
122
|
`),c=[];continue}u();let g=/^([^:\s][^:]*):\s*(.*)$/.exec(f);if(!g)continue;let m=g[1].trim(),b=g[2].trim();if(b===""){s=m,o=[];continue}if(r.BLOCK_SCALAR_HEADER.test(b)){n[m]=b,l=m;continue}if(b.startsWith("[")&&b.endsWith("]")&&!b.startsWith("[[")){let _=r.splitFlowSequence(b.slice(1,-1));if(_!==null){n[m]=_;continue}}n[m]=b}return u(),n}updateProperty(e,t,n){t=(0,Jf.canonicalYamlKey)(r.normalizeIRI(t)),typeof n=="string"&&(n=r.normalizeIRIValue(n));let i=this.parse(e),s=this.serializeValue(t,n);if(!i.exists)return`---
|
|
@@ -428,12 +428,12 @@ ${r.slice(o+1)}`:l+=r.slice(i),l.slice(1)}function Zme(r){let e="",t=0;for(let n
|
|
|
428
428
|
`:" ";n+=`---${d}${f}
|
|
429
429
|
`}else n+=Ga(t,0,o.contents,{block:!0,compact:!0})+`
|
|
430
430
|
`;i=o.explicitEnd||o.contents!==null&&ige(o.contents),i&&(n+=`...
|
|
431
|
-
`)}return n}function Jd(r,e={}){let t={...age,...e},n=Rme(r,t.schema,{noRefs:t.noRefs,skipInvalid:t.skipInvalid});return t.flowLevel>=0&&xme(n,(i,s)=>{if(!(s.depth<t.flowLevel))return i.style.flow=!0,d6}),t.transform(n),oge(n,{...rO(t,Object.keys(vO)),schema:t.schema})}var bt,Dpe,Lpe,Npe,kpe,Mpe,jpe,$pe,Upe,Bpe,Vpe,Gpe,qpe,Wpe,zpe,Hpe,Kpe,Ype,X5,Jpe,Zpe,rhe,nhe,eO,ohe,ahe,Q5,uhe,fhe,hhe,mhe,ghe,tO,_he,She,vhe,The,Ahe,Rhe,Che,xhe,Ohe,Phe,Fhe,Aw,yO,kNe,vu,tg,khe,MNe,jNe,Mhe,Kc,_r,Cn,Yc,Ki,$he,e6,t6,Hhe,Wd,Khe,_O,wt,o6,Yd,nO,a6,ww,eme,tme,c6,iO,l6,rme,nme,ime,SO,vme,yw,yu,Cme,d6,wO,Ome,Eu,p6,Pme,Fme,h6,aO,Dme,Lme,m6,Nme,cO,EO,Qm,kme,Mme,g6,jme,lO,uO,$me,fO,Ume,dO,Hn,vO,Zm,Xm,TO,AO,Hc,age,$Ne,UNe,BNe,VNe,GNe,qNe,WNe,zNe,HNe,KNe,YNe,XNe,QNe,JNe,ZNe,eke,rg=Me(()=>{bt=Symbol("NOT_RESOLVED");a(zn,"defineScalarTag");a(gO,"defineSequenceTag");a(vw,"defineMappingTag");Dpe=zn("tag:yaml.org,2002:str",{resolve:a(r=>r,"resolve"),identify:a(r=>typeof r=="string","identify")}),Lpe=["","~","null","Null","NULL"],Npe=zn("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:a(r=>Lpe.indexOf(r)!==-1?null:bt,"resolve"),identify:a(r=>r===null,"identify"),represent:a(()=>"null","represent")}),kpe=zn("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["n"],resolve:a((r,e)=>r==="null"||e&&r===""?null:bt,"resolve"),identify:a(r=>r===null,"identify"),represent:a(()=>"null","represent")}),Mpe=["","~","null","Null","NULL"],jpe=zn("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:a(r=>Mpe.indexOf(r)!==-1?null:bt,"resolve"),identify:a(r=>r===null,"identify"),represent:a(()=>"null","represent")}),$pe=["true","True","TRUE"],Upe=["false","False","FALSE"],Bpe=zn("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","T","f","F"],resolve:a(r=>$pe.indexOf(r)!==-1?!0:Upe.indexOf(r)!==-1?!1:bt,"resolve"),identify:a(r=>Object.prototype.toString.call(r)==="[object Boolean]","identify"),represent:a(r=>r?"true":"false","represent")}),Vpe=["true"],Gpe=["false"],qpe=zn("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","f"],resolve:a(r=>Vpe.indexOf(r)!==-1?!0:Gpe.indexOf(r)!==-1?!1:bt,"resolve"),identify:a(r=>Object.prototype.toString.call(r)==="[object Boolean]","identify"),represent:a(r=>r?"true":"false","represent")}),Wpe=["true","True","TRUE","y","Y","yes","Yes","YES","on","On","ON"],zpe=["false","False","FALSE","n","N","no","No","NO","off","Off","OFF"],Hpe=zn("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["y","Y","n","N","t","T","f","F","o","O"],resolve:a(r=>Wpe.indexOf(r)!==-1?!0:zpe.indexOf(r)!==-1?!1:bt,"resolve"),identify:a(r=>Object.prototype.toString.call(r)==="[object Boolean]","identify"),represent:a(r=>r?"true":"false","represent")}),Kpe=new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$"),Ype=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");a(Xpe,"parseYamlInteger$2");a(Qpe,"resolveYamlInteger$2");X5=zn("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:Qpe,identify:a(r=>Number.isInteger(r)&&!Object.is(r,-0)&&r.toString(10).indexOf("e")<0,"identify"),represent:a(r=>r.toString(10),"represent")}),Jpe=new RegExp("^-?(?:0|[1-9][0-9]*)$"),Zpe=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");a(ehe,"parseYamlInteger$1");a(the,"resolveYamlInteger$1");rhe=zn("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:the,identify:a(r=>Number.isInteger(r)&&!Object.is(r,-0)&&r.toString(10).indexOf("e")<0,"identify"),represent:a(r=>r.toString(10),"represent")}),nhe=new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");a(ihe,"parseYamlInteger");a(she,"resolveYamlInteger");eO=zn("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:she,identify:a(r=>Number.isInteger(r)&&!Object.is(r,-0)&&r.toString(10).indexOf("e")<0,"identify"),represent:a(r=>r.toString(10),"represent")}),ohe=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),ahe=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");a(che,"resolveYamlFloat$2");a(lhe,"representYamlFloat$2");Q5=zn("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:che,identify:a(r=>typeof r=="number"&&(!Number.isInteger(r)||Object.is(r,-0)||r.toString(10).indexOf("e")>=0),"identify"),represent:lhe}),uhe=new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$"),fhe=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");a(dhe,"resolveYamlFloat$1");a(phe,"representYamlFloat$1");hhe=zn("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:dhe,identify:a(r=>typeof r=="number"&&(!Number.isInteger(r)||Object.is(r,-0)||r.toString(10).indexOf("e")>=0),"identify"),represent:phe}),mhe=new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),ghe=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");a(yhe,"resolveYamlFloat");a(bhe,"representYamlFloat");tO=zn("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:yhe,identify:a(r=>typeof r=="number"&&(!Number.isInteger(r)||Object.is(r,-0)||r.toString(10).indexOf("e")>=0),"identify"),represent:bhe}),_he=zn("tag:yaml.org,2002:merge",{implicit:!0,implicitFirstChars:["<"],resolve:a((r,e)=>r==="<<"||e&&r===""?"<<":bt,"resolve"),identify:a(()=>!1,"identify")}),She=/^[A-Za-z0-9+/]*={0,2}$/;a(whe,"resolveYamlBinary");a(Ehe,"representYamlBinary");vhe=zn("tag:yaml.org,2002:binary",{resolve:whe,identify:a(r=>Object.prototype.toString.call(r)==="[object Uint8Array]","identify"),represent:Ehe}),The=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ahe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");a(F5,"makeUtcDate");a(Ihe,"resolveYamlTimestamp");Rhe=zn("tag:yaml.org,2002:timestamp",{implicit:!0,implicitFirstChars:[..."0123456789"],resolve:Ihe,identify:a(r=>r instanceof Date,"identify"),represent:a(r=>r.toISOString(),"represent")}),Che=gO("tag:yaml.org,2002:seq",{create:a(()=>[],"create"),addItem:a((r,e)=>{r.push(e)},"addItem"),identify:Array.isArray});a(Tw,"isPlainObject");a(rO,"pick");xhe=gO("tag:yaml.org,2002:omap",{create:a(()=>({list:[],seen:new Set}),"create"),addItem:a((r,e)=>{let t;if(e instanceof Map){if(e.size!==1)return"cannot resolve an ordered map item";t=e.keys().next().value}else if(Tw(e)){let n=Object.keys(e);if(n.length!==1)return"cannot resolve an ordered map item";t=n[0]}else return"cannot resolve an ordered map item";return r.seen.has(t)?"duplicate key in ordered map":(r.seen.add(t),r.list.push(e),"")},"addItem"),finalize:a(r=>r.list,"finalize"),identify:a(()=>!1,"identify")}),Ohe=gO("tag:yaml.org,2002:pairs",{create:a(()=>[],"create"),addItem:a((r,e)=>{if(e instanceof Map)return e.size!==1?"cannot resolve a pairs item":(r.push(e.entries().next().value),"");if(Object.prototype.toString.call(e)!=="[object Object]")return"cannot resolve a pairs item";let t=e,n=Object.keys(t);return n.length!==1?"cannot resolve a pairs item":(r.push([n[0],t[n[0]]]),"")},"addItem"),identify:a(()=>!1,"identify")}),Phe=vw("tag:yaml.org,2002:map",{create:a(()=>({}),"create"),identify:Tw,represent:a(r=>{let e=new Map;for(let t of Object.keys(r))e.set(t,r[t]);return e},"represent"),addPair:a((r,e,t)=>{if(e!==null&&typeof e=="object")return"object-based map does not support complex keys";let n=String(e);return n==="__proto__"?Object.defineProperty(r,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[n]=t,""},"addPair"),has:a((r,e)=>e!==null&&typeof e=="object"?!1:Object.prototype.hasOwnProperty.call(r,String(e)),"has"),keys:a(r=>Object.keys(r),"keys"),get:a((r,e)=>{let t=String(e);return Object.prototype.hasOwnProperty.call(r,t)?r[t]:null},"get")}),Fhe=vw("tag:yaml.org,2002:set",{create:a(()=>new Set,"create"),identify:a(r=>r instanceof Set,"identify"),represent:a(r=>{let e=new Map;for(let t of r)e.set(t,null);return e},"represent"),addPair:a((r,e,t)=>t!==null?"cannot resolve a set item":(r.add(e),""),"addPair"),has:a((r,e)=>r.has(e),"has"),keys:a(r=>r.keys(),"keys"),get:a(()=>null,"get")});a(Dhe,"createTagDefinitionMap");a(Lhe,"createTagDefinitionListMap");a(Nhe,"compileTags");Aw=class J5{static{a(this,"Schema")}tags;implicitScalarTags;implicitScalarByFirstChar;implicitScalarAnyFirstChar;defaultScalarTag;defaultSequenceTag;defaultMappingTag;exact;prefix;constructor(e){let t=Nhe(e),n=[],i=Dhe(),s=Lhe();for(let f of t){if(f.nodeKind==="scalar"&&f.implicit){if(f.matchByTagPrefix)throw new Error("Implicit scalar tags cannot match by tag prefix");n.push(f)}switch(f.nodeKind){case"scalar":f.matchByTagPrefix?s.scalar.push(f):i.scalar[f.tagName]=f;break;case"sequence":f.matchByTagPrefix?s.sequence.push(f):i.sequence[f.tagName]=f;break;case"mapping":f.matchByTagPrefix?s.mapping.push(f):i.mapping[f.tagName]=f;break}}let o=n.filter(f=>f.implicitFirstChars===null),c=new Set;for(let f of n)if(f.implicitFirstChars!==null)for(let d of f.implicitFirstChars)c.add(d);let l=new Map;for(let f of c)l.set(f,n.filter(d=>d.implicitFirstChars===null||d.implicitFirstChars.indexOf(f)!==-1));let u=i.scalar["tag:yaml.org,2002:str"];if(!u)throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");this.tags=t,this.implicitScalarTags=n,this.implicitScalarByFirstChar=l,this.implicitScalarAnyFirstChar=o,this.defaultScalarTag=u,this.defaultSequenceTag=i.sequence["tag:yaml.org,2002:seq"],this.defaultMappingTag=i.mapping["tag:yaml.org,2002:map"],this.exact=i,this.prefix=s}lookupScalarTag(e){let t=this.exact.scalar[e];if(t)return t;for(let n of this.prefix.scalar)if(e.startsWith(n.tagName))return n}lookupSequenceTag(e){let t=this.exact.sequence[e];if(t)return t;for(let n of this.prefix.sequence)if(e.startsWith(n.tagName))return n}lookupMappingTag(e){let t=this.exact.mapping[e];if(t)return t;for(let n of this.prefix.mapping)if(e.startsWith(n.tagName))return n}resolveImplicitScalarTag(e){let t=this.implicitScalarByFirstChar.get(e.charAt(0))??this.implicitScalarAnyFirstChar;for(let i of t){let s=i.resolve(e,!1,i.tagName);if(s!==bt)return{value:s,tag:i}}let n=this.defaultScalarTag;return{value:n.resolve(e,!1,n.tagName),tag:n}}withTags(...e){let t=[];for(let n of e)t=t.concat(n);return new J5([...this.tags,...t])}},yO=new Aw([Dpe,Che,Phe]),kNe=new Aw([...yO.tags,kpe,qpe,rhe,hhe]),vu=new Aw([...yO.tags,Npe,Bpe,X5,Q5]),tg=new Aw([...yO.tags,jpe,Hpe,eO,tO,Rhe,_he,vhe,xhe,Ohe,Fhe]),khe=tg.withTags({...eO,resolve:a((r,e,t)=>{let n=eO.resolve(r,e,t);return n===bt?X5.resolve(r,e,t):n},"resolve")},{...tO,resolve:a((r,e,t)=>{let n=tO.resolve(r,e,t);return n===bt?Q5.resolve(r,e,t):n},"resolve")}),MNe=vw("tag:yaml.org,2002:map",{create:a(()=>new Map,"create"),addPair:a((r,e,t)=>(r.set(e,t),""),"addPair"),has:a((r,e)=>r.has(e),"has"),keys:a(r=>r.keys(),"keys"),get:a((r,e)=>r.get(e),"get"),identify:a(r=>r instanceof Map||Tw(r),"identify"),represent:a(r=>{if(r instanceof Map)return r;let e=new Map,t=r;for(let n of Object.keys(t))e.set(n,t[n]);return e},"represent")});a(D5,"normalizeKey");jNe=vw("tag:yaml.org,2002:map",{create:a(()=>({}),"create"),identify:Tw,represent:a(r=>{let e=new Map;for(let t of Object.keys(r))e.set(t,r[t]);return e},"represent"),addPair:a((r,e,t)=>{let n=D5(e);return n===null?"nested arrays are not supported inside keys":(n==="__proto__"?Object.defineProperty(r,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[n]=t,"")},"addPair"),has:a((r,e)=>{let t=D5(e);return t!==null&&Object.prototype.hasOwnProperty.call(r,t)},"has"),keys:a(r=>Object.keys(r),"keys"),get:a((r,e)=>{let t=String(e);return Object.prototype.hasOwnProperty.call(r,t)?r[t]:null},"get")}),Mhe={maxLength:79,indent:1,linesBefore:3,linesAfter:2};a(Kx,"getLine");a(Yx,"padStart");a(jhe,"makeSnippet");a(L5,"formatError");Kc=class Z5 extends Error{static{a(this,"YAMLException")}reason;mark;constructor(e,t){super(),this.name="YAMLException",this.reason=e,this.mark=t,this.message=L5(this,!1),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toString(e){return`${this.name}: ${L5(this,e)}`}static throwAt(e,t,n,i=""){let s=0,o=0;for(let l=0;l<t;l++){let u=e.charCodeAt(l);u===10?(s++,o=l+1):u===13&&(s++,e.charCodeAt(l+1)===10&&l++,o=l+1)}let c={name:i,buffer:e,position:t,line:s,column:t-o};throw c.snippet=jhe(c),new Z5(n,c)}},_r={DOCUMENT:1,SEQUENCE:2,MAPPING:3,SCALAR:4,ALIAS:5,POP:6},Cn={PLAIN:1,SINGLE_QUOTED:2,DOUBLE_QUOTED:3,LITERAL_BLOCK:4,FOLDED_BLOCK:5},Yc={BLOCK:1,FLOW:2},Ki={CLIP:1,STRIP:2,KEEP:3},$he=-1;a(N5,"simpleEscapeSequence");e6=new Array(256),t6=new Array(256);for(let r=0;r<256;r++)e6[r]=N5(r)?1:0,t6[r]=N5(r);a(Uhe,"charFromCodepoint");a(Bhe,"fromHexCode$1");a(Vhe,"escapedHexLen$1");a(Sw,"skipFoldedBreaks");a(bO,"foldedBreaks");a(Ghe,"getPlainValue");a(qhe,"getSingleQuotedValue");a(Whe,"getDoubleQuotedValue");a(k5,"getBlockValue");a(zhe,"getScalarValue");Hhe=Object.assign(Object.create(null),{"!":"!","!!":"tag:yaml.org,2002:"});a(Xx,"tagPercentEncode");a(r6,"tagNameFull");a(n6,"tagNameShort");Wd=-1,Khe="tag:yaml.org,2002:merge",_O={filename:"",schema:vu,json:!1,maxTotalMergeKeys:1e4,maxAliases:-1};a(Yhe,"eventPosition$1");a(Wn,"throwError$1");a(i6,"finalizeCollection");a(Xhe,"constructScalar");a(M5,"collectionTagName");a(s6,"isMappingTag");a(j5,"mergeKeys");a(Qhe,"mergeSource");a(Jhe,"addMappingValue");a(Qx,"addValue");a(Jx,"storeAnchor");a(Zhe,"constructFromEvents");wt=-1,o6=Object.prototype.hasOwnProperty,Yd=1,nO=2,a6=3,ww=4,eme=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,tme=/[,\[\]{}]/,c6=/^(?:!|!!|![0-9A-Za-z-]+!)$/,iO=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,l6=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,rme=new RegExp(`^(?:${iO})*$`),nme=new RegExp(`^(?:${l6})+$`),ime=new RegExp(`^(?:!(?:${iO})*|${l6}(?:${iO})*)$`),SO={filename:"",maxDepth:100};a(sme,"addDocumentEvent");a(u6,"addSequenceEvent");a(sO,"addMappingEvent");a($5,"insertFlowPairMappingEvent");a(Qd,"addScalarEvent");a(ome,"addAliasEvent");a(zd,"addPopEvent");a(di,"addEmptyScalarEvent");a(U5,"emptyProperties");a(Ym,"snapshotState");a(Hd,"restoreState");a(Ue,"throwError");a(sn,"isEol");a(Su,"isWhiteSpace");a(Gs,"isWsOrEol");a(Va,"isWsOrEolOrEnd");a(wu,"isFlowIndicator");a(ame,"fromDecimalCode");a(cme,"fromHexCode");a(lme,"escapedHexLen");a(ume,"isSimpleEscape");a(Ew,"consumeLineBreak");a(pi,"skipSeparationSpace");a(bu,"testDocumentSeparator");a(B5,"skipUntilLineEnd");a(f6,"checkPrintable");a(fme,"readTagProperty");a(dme,"readAnchorProperty");a(pme,"readAlias");a(oO,"readFlowScalarBreak");a(hme,"readSingleQuotedScalar");a(mme,"readDoubleQuotedScalar");a(gme,"readBlockScalar");a(yme,"canStartPlainScalar");a(bme,"readPlainScalar");a(Hm,"skipFlowSeparationSpace");a(_me,"readFlowCollection");a(V5,"readBlockSequence");a(Zx,"readBlockMapping");a(_u,"parseNode");a(Sme,"readDirective");a(wme,"readDocument");a(Eme,"parseEvents");vme={...SO,..._O};a(Tme,"loadDocuments");a(Xc,"load");yw=class{static{a(this,"Style")}tagged=!1;flow=!1;singleQuoted=!1;doubleQuoted=!1;literal=!1;folded=!1},yu=Symbol("INVALID");a(Ame,"buildRepresentTypes");a(Ime,"matchTag");a(Km,"build");a(Rme,"jsToAst");Cme=Symbol("visit:break"),d6=Symbol("visit:skip");a(_w,"visitNode");a(xme,"visit");wO=65279,Ome=9,Eu=10,p6=13,Pme=32,Fme=33,h6=34,aO=35,Dme=37,Lme=38,m6=39,Nme=42,cO=44,EO=45,Qm=58,kme=61,Mme=62,g6=63,jme=64,lO=91,uO=93,$me=96,fO=123,Ume=124,dO=125,Hn={};Hn[0]="\\0";Hn[7]="\\a";Hn[8]="\\b";Hn[9]="\\t";Hn[10]="\\n";Hn[11]="\\v";Hn[12]="\\f";Hn[13]="\\r";Hn[27]="\\e";Hn[34]='\\"';Hn[92]="\\\\";Hn[133]="\\N";Hn[160]="\\_";Hn[8232]="\\L";Hn[8233]="\\P";vO={indent:2,seqNoIndent:!1,seqInlineFirst:!0,sortKeys:!1,lineWidth:80,flowBracketPadding:!1,flowSkipCommaSpace:!1,flowSkipColonSpace:!1,quoteFlowKeys:!1,quoteStyle:"single",forceQuotes:!1,tagBeforeAnchor:!1};a(Bme,"nodeTagShort");a(Vme,"createPresenterState");a(Gme,"encodeNonPrintable");a(G5,"indentString");a(pO,"generateNextLine");a(qme,"scalarLayout");a(Xd,"isWhitespace");a(Wme,"startsWithDocumentSeparator");a(Jm,"isPrintable");a(q5,"isNsCharOrWhitespace");a(hO,"isPlainSafe");a(zme,"isPlainSafeFirst");a(Hme,"isPlainSafeAtStart");a(Kme,"isPlainSafeLast");a(Kd,"codePointAt");a(y6,"needIndentIndicator");Zm=1,Xm=2,TO=3,AO=4,Hc=5;a(Yme,"chooseScalarStyle");a(Xme,"renderScalarStyle");a(Qme,"resolveScalarStyle");a(W5,"blockHeader");a(z5,"encodeFlowBreaks");a(H5,"dropEndingNewline");a(eg,"isMoreIndented");a(Jme,"foldBlockScalar");a(K5,"foldLine");a(Zme,"escapeString");a(ege,"writeFlowSequence");a(Y5,"writeBlockSequence");a(tge,"writeFlowMapping");a(bw,"sortKeyValue");a(b6,"sortMappingItems");a(rge,"writeBlockMapping");a(mO,"cannotBeCompact");a(Ga,"writeNode");a(nge,"rootStartsOwnLine");a(ige,"isOpenEnded");a(sge,"writeDocumentDirectives");a(oge,"present");age={...vO,schema:khe,skipInvalid:!1,noRefs:!1,flowLevel:-1,transform:a(()=>{},"transform")};a(Jd,"dump");$Ne=_r.DOCUMENT,UNe=_r.SEQUENCE,BNe=_r.MAPPING,VNe=_r.SCALAR,GNe=_r.ALIAS,qNe=_r.POP,WNe=Cn.PLAIN,zNe=Cn.SINGLE_QUOTED,HNe=Cn.DOUBLE_QUOTED,KNe=Cn.LITERAL_BLOCK,YNe=Cn.FOLDED_BLOCK,XNe=Yc.BLOCK,QNe=Yc.FLOW,JNe=Ki.CLIP,ZNe=Ki.STRIP,eke=Ki.KEEP});var IO,_6,cge,S6=Me(()=>{IO=a((r,e,t)=>{let n=r instanceof RegExp?_6(r,t):r,i=e instanceof RegExp?_6(e,t):e,s=n!==null&&i!=null&&cge(n,i,t);return s&&{start:s[0],end:s[1],pre:t.slice(0,s[0]),body:t.slice(s[0]+n.length,s[1]),post:t.slice(s[1]+i.length)}},"balanced"),_6=a((r,e)=>{let t=e.match(r);return t?t[0]:null},"maybeMatch"),cge=a((r,e,t)=>{let n,i,s,o,c,l=t.indexOf(r),u=t.indexOf(e,l+1),f=l;if(l>=0&&u>0){if(r===e)return[l,u];for(n=[],s=t.length;f>=0&&!c;){if(f===l)n.push(f),l=t.indexOf(r,f+1);else if(n.length===1){let d=n.pop();d!==void 0&&(c=[d,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=t.indexOf(e,f+1);f=l<u&&l>=0?l:u}n.length&&o!==void 0&&(c=[s,o])}return c},"range")});function RO(r){return isNaN(r)?r.charCodeAt(0):parseInt(r,10)}function wge(r){return r.replace(hge,w6).replace(mge,E6).replace(gge,xO).replace(yge,v6).replace(bge,T6)}function Ege(r){return r.replace(lge,"\\").replace(uge,"{").replace(fge,"}").replace(dge,",").replace(pge,".")}function A6(r){if(!r)return[""];let e=[],t=IO("{","}",r);if(!t)return r.split(",");let{pre:n,body:i,post:s}=t,o=n.split(",");o[o.length-1]+="{"+i+"}";let c=A6(s);return s.length&&(o[o.length-1]+=c.shift(),o.push.apply(o,c)),e.push.apply(e,o),e}function I6(r,e={}){if(!r)return[];let{max:t=_ge,maxLength:n=Sge}=e;return r.slice(0,2)==="{}"&&(r="\\{\\}"+r.slice(2)),CO(wge(r),t,n,!0).map(Ege)}function vge(r){return"{"+r+"}"}function Tge(r){return/^-?0\d/.test(r)}function Age(r,e){return r<=e}function Ige(r,e){return r>=e}function ng(r,e,t,n,i,s){let o=[],c=0;for(let l=0;l<r.length;l++)for(let u=0;u<t.length;u++){if(o.length>=n)return o;let f=r[l]+e+t[u];if(!(s&&!f)){if(c+f.length>i)return o;o.push(f),c+=f.length}}return o}function Rge(r,e,t,n){let i=r.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=RO(i[0]),c=RO(i[1]),l=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(RO(i[2])),1):1,f=Age;c<o&&(u*=-1,f=Ige);let p=i.some(Tge),h=0;for(let g=o;f(g,c)&&s.length<t;g+=u){let m;if(e)m=String.fromCharCode(g),m==="\\"&&(m="");else if(m=String(g),p){let b=l-m.length;if(b>0){let _=new Array(b+1).join("0");g<0?m="-"+_+m.slice(1):m=_+m}}if(h+m.length>n)break;s.push(m),h+=m.length}return s}function CO(r,e,t,n){let i=[""],s=!1,o=!0;for(;;){let c=IO("{","}",r);if(!c)return ng(i,r,[""],e,t,s);let l=c.pre;if(/\$$/.test(l)){if(i=ng(i,l+"{"+c.body+"}",[""],e,t,s&&!c.post.length),o=!1,!c.post.length)break;r=c.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(c.body),f=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(c.body),d=u||f,p=c.body.indexOf(",")>=0;if(!d&&!p){if(c.post.match(/,(?!,).*\}/)){r=c.pre+"{"+c.body+xO+c.post,n=!0;continue}return ng(i,l+"{"+c.body+"}"+c.post,[""],e,t,s)}o&&(s=n&&!d,o=!1);let h;if(d)h=Rge(c.body,f,e,t);else{let g=A6(c.body);if(g.length===1&&g[0]!==void 0&&(g=CO(g[0],e,t,!1).map(vge),g.length===1)){if(i=ng(i,l+g[0],[""],e,t,s&&!c.post.length),!c.post.length)break;r=c.post;continue}let m=s&&!c.post.length&&!l;for(let _=0;m&&_<i.length;_++)i[_]&&(m=!1);h=[];let b=0;e:for(let _=0;_<g.length;_++){let S=CO(g[_],e,t,!1);for(let A=0;A<S.length;A++){let w=S[A];if(!(m&&!w)){if(h.length>=e||b+w.length>t)break e;h.push(w),b+=w.length}}}}if(i=ng(i,l,h,e,t,s&&!c.post.length),!c.post.length)break;r=c.post}return i}var w6,E6,xO,v6,T6,lge,uge,fge,dge,pge,hge,mge,gge,yge,bge,_ge,Sge,R6=Me(()=>{S6();w6="\0SLASH"+Math.random()+"\0",E6="\0OPEN"+Math.random()+"\0",xO="\0CLOSE"+Math.random()+"\0",v6="\0COMMA"+Math.random()+"\0",T6="\0PERIOD"+Math.random()+"\0",lge=new RegExp(w6,"g"),uge=new RegExp(E6,"g"),fge=new RegExp(xO,"g"),dge=new RegExp(v6,"g"),pge=new RegExp(T6,"g"),hge=/\\\\/g,mge=/\\{/g,gge=/\\}/g,yge=/\\,/g,bge=/\\\./g,_ge=1e5,Sge=4e6;a(RO,"numeric");a(wge,"escapeBraces");a(Ege,"unescapeBraces");a(A6,"parseCommaParts");a(I6,"expand");a(vge,"embrace");a(Tge,"isPadded");a(Age,"lte");a(Ige,"gte");a(ng,"combine");a(Rge,"expandSequence");a(CO,"expand_")});var ig,C6=Me(()=>{ig=a(r=>{if(typeof r!="string")throw new TypeError("invalid pattern");if(r.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern")});var Cge,sg,xge,x6,O6,P6=Me(()=>{Cge={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},sg=a(r=>r.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),xge=a(r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),x6=a(r=>r.join(""),"rangesToString"),O6=a((r,e)=>{let t=e;if(r.charAt(t)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=t+1,o=!1,c=!1,l=!1,u=!1,f=t,d="";e:for(;s<r.length;){let m=r.charAt(s);if((m==="!"||m==="^")&&s===t+1){u=!0,s++;continue}if(m==="]"&&o&&!l){f=s+1;break}if(o=!0,m==="\\"&&!l){l=!0,s++;continue}if(m==="["&&!l){for(let[b,[_,S,A]]of Object.entries(Cge))if(r.startsWith(b,s)){if(d)return["$.",!1,r.length-t,!0];s+=b.length,A?i.push(_):n.push(_),c=c||S;continue e}}if(l=!1,d){m>d?n.push(sg(d)+"-"+sg(m)):m===d&&n.push(sg(m)),d="",s++;continue}if(r.startsWith("-]",s+1)){n.push(sg(m+"-")),s+=2;continue}if(r.startsWith("-",s+1)){d=m,s+=2;continue}n.push(sg(m)),s++}if(f<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,r.length-t,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let m=n[0].length===2?n[0].slice(-1):n[0];return[xge(m),!1,f-t,!1]}let p="["+(u?"^":"")+x6(n)+"]",h="["+(u?"":"^")+x6(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,c,f-t,!0]},"parseClass")});var qs,Rw=Me(()=>{qs=a((r,{windowsPathsNoEscape:e=!1,magicalBraces:t=!0}={})=>t?e?r.replace(/\[([^/\\])\]/g,"$1"):r.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?r.replace(/\[([^/\\{}])\]/g,"$1"):r.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape")});var ji,Oge,OO,F6,Pge,Fge,Dge,D6,Lge,Cw,Nge,kge,Mge,jge,PO,L6,N6,$ge,Tu,FO=Me(()=>{P6();Rw();Oge=new Set(["!","?","+","*","@"]),OO=a(r=>Oge.has(r),"isExtglobType"),F6=a(r=>OO(r.type),"isExtglobAST"),Pge=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Fge=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Dge=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),D6=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Lge="(?!(?:^|/)\\.\\.?(?:$|/))",Cw="(?!\\.)",Nge=new Set(["[","."]),kge=new Set(["..","."]),Mge=new Set("().*{}+?[]^$\\!"),jge=a(r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),PO="[^/]",L6=PO+"*?",N6=PO+"+?",$ge=0,Tu=class{static{a(this,"AST")}type;#t;#r;#n=!1;#e=[];#i;#a;#p;#u=!1;#c;#f;#l=!1;id=++$ge;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#t.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#e.length,parts:this.#e}}constructor(e,t,n={}){this.type=e,e&&(this.#r=!0),this.#i=t,this.#t=this.#i?this.#i.#t:this,this.#c=this.#t===this?n:this.#t.#c,this.#p=this.#t===this?[]:this.#t.#p,e==="!"&&!this.#t.#u&&this.#p.push(this),this.#a=this.#i?this.#i.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let e of this.#e)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#f=this.#e.map(e=>String(e)).join("")}#d(){if(this!==this.#t)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let e;for(;e=this.#p.pop();){if(e.type!=="!")continue;let t=e,n=t.#i;for(;n;){for(let i=t.#a+1;!n.type&&i<n.#e.length;i++)for(let s of e.#e){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#e[i])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof ji&&t.#i===this))throw new Error("invalid part: "+t);this.#e.push(t)}}toJSON(){let e=this.type===null?this.#e.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#e.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#u&&this.#i?.type==="!")&&e.push({}),e}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#e[t];if(!(n instanceof ji&&n.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#e.length:0;return this.#a===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new ji(this.type,e);for(let n of this.#e)t.copyIn(n);return t}static#o(e,t,n,i,s){let o=i.maxExtglobRecursion??2,c=!1,l=!1,u=-1,f=!1;if(t.type===null){let m=n,b="";for(;m<e.length;){let _=e.charAt(m++);if(c||_==="\\"){c=!c,b+=_;continue}if(l){m===u+1?(_==="^"||_==="!")&&(f=!0):_==="]"&&!(m===u+2&&f)&&(l=!1),b+=_;continue}else if(_==="["){l=!0,u=m,f=!1,b+=_;continue}if(!i.noext&&OO(_)&&e.charAt(m)==="("&&s<=o){t.push(b),b="";let A=new ji(_,t);m=ji.#o(e,A,m,i,s+1),t.push(A);continue}b+=_}return t.push(b),m}let d=n+1,p=new ji(null,t),h=[],g="";for(;d<e.length;){let m=e.charAt(d++);if(c||m==="\\"){c=!c,g+=m;continue}if(l){d===u+1?(m==="^"||m==="!")&&(f=!0):m==="]"&&!(d===u+2&&f)&&(l=!1),g+=m;continue}else if(m==="["){l=!0,u=d,f=!1,g+=m;continue}if(!i.noext&&OO(m)&&e.charAt(d)==="("&&(s<=o||t&&t.#_(m))){let _=t&&t.#_(m)?0:1;p.push(g),g="";let S=new ji(m,p);p.push(S),d=ji.#o(e,S,d,i,s+_);continue}if(m==="|"){p.push(g),g="",h.push(p),p=new ji(null,t);continue}if(m===")")return g===""&&t.#e.length===0&&(t.#l=!0),p.push(g),g="",t.push(...h,p),d;g+=m}return t.type=null,t.#r=void 0,t.#e=[e.substring(n-1)],d}#g(e){return this.#E(e,Fge)}#E(e,t=Pge){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null)return!1;let n=e.#e[0];return!n||typeof n!="object"||n.type===null?!1:this.#_(n.type,t)}#_(e,t=Dge){return!!t.get(this.type)?.includes(e)}#S(e,t){let n=e.#e[0],i=new ji(null,n,this.options);i.#e.push(""),n.push(i),this.#A(e,t)}#A(e,t){let n=e.#e[0];this.#e.splice(t,1,...n.#e);for(let i of n.#e)typeof i=="object"&&(i.#i=this);this.#f=void 0}#y(e){return!!D6.get(this.type)?.has(e)}#v(e){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null||this.#e.length!==1)return!1;let t=e.#e[0];return!t||typeof t!="object"||t.type===null?!1:this.#y(t.type)}#T(e){let t=D6.get(this.type),n=e.#e[0],i=t?.get(n.type);if(!i)return!1;this.#e=n.#e;for(let s of this.#e)typeof s=="object"&&(s.#i=this);this.type=i,this.#f=void 0,this.#l=!1}static fromGlob(e,t={}){let n=new ji(null,void 0,t);return ji.#o(e,n,0,t,0),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let e=this.toString(),[t,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let c=(this.#c.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,c),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#t===this&&(this.#m(),this.#d()),!F6(this)){let l=this.isStart()&&this.isEnd()&&!this.#e.some(h=>typeof h!="string"),u=this.#e.map(h=>{let[g,m,b,_]=typeof h=="string"?ji.#w(h,this.#r,l):h.toRegExpSource(e);return this.#r=this.#r||b,this.#n=this.#n||_,g}).join(""),f="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&kge.has(this.#e[0]))){let g=Nge,m=t&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),b=!t&&!e&&g.has(u.charAt(0));f=m?Lge:b?Cw:""}let d="";return this.isEnd()&&this.#t.#u&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,qs(u),this.#r=!!this.#r,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#b(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString(),u=this;return u.#e=[l],u.type=null,u.#r=void 0,[l,qs(this.toString()),!1,!1]}let o=!n||e||t||!Cw?"":this.#b(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let c="";if(this.type==="!"&&this.#l)c=(this.isStart()&&!t?Cw:"")+N6;else{let l=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Cw:"")+L6+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;c=i+s+l}return[c,qs(s),this.#r=!!this.#r,this.#n]}#m(){if(F6(this)){let e=0,t=!1;do{t=!0;for(let n=0;n<this.#e.length;n++){let i=this.#e[n];typeof i=="object"&&(i.#m(),this.#E(i)?(t=!1,this.#A(i,n)):this.#g(i)?(t=!1,this.#S(i,n)):this.#v(i)&&(t=!1,this.#T(i)))}}while(!t&&++e<10)}else for(let e of this.#e)typeof e=="object"&&e.#m();this.#f=void 0}#b(e){return this.#e.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=t.toRegExpSource(e);return this.#n=this.#n||o,n}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#w(e,t,n=!1){let i=!1,s="",o=!1,c=!1;for(let l=0;l<e.length;l++){let u=e.charAt(l);if(i){i=!1,s+=(Mge.has(u)?"\\":"")+u;continue}if(u==="*"){if(c)continue;c=!0,s+=n&&/^[*]+$/.test(e)?N6:L6,t=!0;continue}else c=!1;if(u==="\\"){l===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,p,h]=O6(e,l);if(p){s+=f,o=o||d,l+=p-1,t=t||h;continue}}if(u==="?"){s+=PO,t=!0;continue}s+=jge(u)}return[s,qs(e),!!t,o]}};ji=Tu});var Zd,DO=Me(()=>{Zd=a((r,{windowsPathsNoEscape:e=!1,magicalBraces:t=!1}={})=>t?e?r.replace(/[?*()[\]{}]/g,"[$&]"):r.replace(/[?*()[\]\\{}]/g,"\\$&"):e?r.replace(/[?*()[\]]/g,"[$&]"):r.replace(/[?*()[\]\\]/g,"\\$&"),"escape")});var hi,Uge,Bge,Vge,Gge,qge,Wge,zge,Hge,Kge,Yge,Xge,Qge,Jge,Zge,eye,tye,rye,nye,j6,$6,U6,k6,iye,Ir,sye,oye,aye,cye,lye,fs,uye,B6,fye,dye,M6,pye,Yi,Qc=Me(()=>{R6();C6();FO();DO();Rw();FO();DO();Rw();hi=a((r,e,t={})=>(ig(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Yi(e,t).match(r)),"minimatch"),Uge=/^\*+([^+@!?*[(]*)$/,Bge=a(r=>e=>!e.startsWith(".")&&e.endsWith(r),"starDotExtTest"),Vge=a(r=>e=>e.endsWith(r),"starDotExtTestDot"),Gge=a(r=>(r=r.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(r)),"starDotExtTestNocase"),qge=a(r=>(r=r.toLowerCase(),e=>e.toLowerCase().endsWith(r)),"starDotExtTestNocaseDot"),Wge=/^\*+\.\*+$/,zge=a(r=>!r.startsWith(".")&&r.includes("."),"starDotStarTest"),Hge=a(r=>r!=="."&&r!==".."&&r.includes("."),"starDotStarTestDot"),Kge=/^\.\*+$/,Yge=a(r=>r!=="."&&r!==".."&&r.startsWith("."),"dotStarTest"),Xge=/^\*+$/,Qge=a(r=>r.length!==0&&!r.startsWith("."),"starTest"),Jge=a(r=>r.length!==0&&r!=="."&&r!=="..","starTestDot"),Zge=/^\?+([^+@!?*[(]*)?$/,eye=a(([r,e=""])=>{let t=j6([r]);return e?(e=e.toLowerCase(),n=>t(n)&&n.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),tye=a(([r,e=""])=>{let t=$6([r]);return e?(e=e.toLowerCase(),n=>t(n)&&n.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),rye=a(([r,e=""])=>{let t=$6([r]);return e?n=>t(n)&&n.endsWith(e):t},"qmarksTestDot"),nye=a(([r,e=""])=>{let t=j6([r]);return e?n=>t(n)&&n.endsWith(e):t},"qmarksTest"),j6=a(([r])=>{let e=r.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),$6=a(([r])=>{let e=r.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),U6=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",k6={win32:{sep:"\\"},posix:{sep:"/"}},iye=U6==="win32"?k6.win32.sep:k6.posix.sep;hi.sep=iye;Ir=Symbol("globstar **");hi.GLOBSTAR=Ir;sye="[^/]",oye=sye+"*?",aye="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",cye="(?:(?!(?:\\/|^)\\.).)*?",lye=a((r,e={})=>t=>hi(t,r,e),"filter");hi.filter=lye;fs=a((r,e={})=>Object.assign({},r,e),"ext"),uye=a(r=>{if(!r||typeof r!="object"||!Object.keys(r).length)return hi;let e=hi;return Object.assign(a((n,i,s={})=>e(n,i,fs(r,s)),"m"),{Minimatch:class extends e.Minimatch{static{a(this,"Minimatch")}constructor(i,s={}){super(i,fs(r,s))}static defaults(i){return e.defaults(fs(r,i)).Minimatch}},AST:class extends e.AST{static{a(this,"AST")}constructor(i,s,o={}){super(i,s,fs(r,o))}static fromGlob(i,s={}){return e.AST.fromGlob(i,fs(r,s))}},unescape:a((n,i={})=>e.unescape(n,fs(r,i)),"unescape"),escape:a((n,i={})=>e.escape(n,fs(r,i)),"escape"),filter:a((n,i={})=>e.filter(n,fs(r,i)),"filter"),defaults:a(n=>e.defaults(fs(r,n)),"defaults"),makeRe:a((n,i={})=>e.makeRe(n,fs(r,i)),"makeRe"),braceExpand:a((n,i={})=>e.braceExpand(n,fs(r,i)),"braceExpand"),match:a((n,i,s={})=>e.match(n,i,fs(r,s)),"match"),sep:e.sep,GLOBSTAR:Ir})},"defaults");hi.defaults=uye;B6=a((r,e={})=>(ig(r),e.nobrace||!/\{(?:(?!\{).)*\}/.test(r)?[r]:I6(r,{max:e.braceExpandMax})),"braceExpand");hi.braceExpand=B6;fye=a((r,e={})=>new Yi(r,e).makeRe(),"makeRe");hi.makeRe=fye;dye=a((r,e,t={})=>{let n=new Yi(e,t);return r=r.filter(i=>n.match(i)),n.options.nonull&&!r.length&&r.push(e),r},"match");hi.match=dye;M6=/[?*]|[+@!]\(.*?\)|\[|\]/,pye=a(r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Yi=class{static{a(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){ig(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||U6,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!M6.test(s[2]))&&!M6.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(l)return[...s.slice(0,4),...s.slice(4).map(f=>this.parse(f))];if(u)return[s[0],...s.slice(1).map(f=>this.parse(f))]}return s.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n of e)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let n=-1;for(;(n=t.indexOf("**",n+1))!==-1;){let i=n;for(;t[i+1]==="**";)i++;i!==n&&t.splice(n,i-n)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let c=n[i+1],l=n[i+2],u=n[i+3];if(c!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;t=!0,n.splice(i,1);let f=n.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let c=n[o];o===1&&c===""&&n[0]===""||(c==="."||c==="")&&(t=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(t=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let l=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...l),n.length===0&&n.push(""),s-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let i=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(i){e[t]=[],e[n]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,n=!1){let i=0,s=0,o=[],c="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])o.push(c==="b"?t[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&t[s]===e[i+1])o.push(e[i]),i++;else if(n&&t[s]==="**"&&e[i]===t[s+1])o.push(t[s]),s++;else if(e[i]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(c==="b")return!1;c="a",o.push(e[i]),i++,s++}else if(t[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(c==="a")return!1;c="b",o.push(t[s]),i++,s++}else return!1;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let i=0,s=0;if(this.isWindows){let c=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),l=!c&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),u=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),f=!u&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),d=l?3:c?0:void 0,p=f?3:u?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[h,g]=[e[d],t[p]];h.toLowerCase()===g.toLowerCase()&&(t[p]=h,s=p,i=d)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Ir)?this.#t(e,t,n,i,s):this.#n(e,t,n,i,s)}#t(e,t,n,i,s){let o=t.indexOf(Ir,s),c=t.lastIndexOf(Ir),[l,u,f]=n?[t.slice(s,o),t.slice(o+1),[]]:[t.slice(s,o),t.slice(o+1,c),t.slice(c+1)];if(l.length){let S=e.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,s+=l.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let S=e.length-f.length;if(this.#n(e,f,n,S,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(S--,!this.#n(e,f,n,S,0)))return!1;d=f.length+1}}if(!u.length){let S=!!d;for(let A=i;A<e.length-d;A++){let w=String(e[A]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let p=[[[],0]],h=p[0],g=0,m=[0];for(let S of u)S===Ir?(m.push(g),h=[[],0],p.push(h)):(h[0].push(S),g++);let b=p.length-1,_=e.length-d;for(let S of p)S[1]=_-(m[b--]+S[0].length);return!!this.#r(e,p,i,0,n,0,!!d)}#r(e,t,n,i,s,o,c){let l=t[i];if(!l){for(let d=n;d<e.length;d++){c=!0;let p=e[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return c}let[u,f]=l;for(;n<=f;){if(this.#n(e.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let h=this.#r(e,t,n+u.length,i+1,s,o+1,c);if(h!==!1)return h}let p=e[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(e,t,n,i,s){let o,c,l,u;for(o=i,c=s,u=e.length,l=t.length;o<u&&c<l;o++,c++){this.debug("matchOne loop");let f=t[c],d=e[o];if(this.debug(t,f,d),f===!1||f===Ir)return!1;let p;if(typeof f=="string"?(p=d===f,this.debug("string match",f,d,p)):(p=f.test(d),this.debug("pattern match",f,d,p)),!p)return!1}if(o===u&&c===l)return!0;if(o===u)return n;if(c===l)return o===u-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return B6(this.pattern,this.options)}parse(e){ig(e);let t=this.options;if(e==="**")return Ir;if(e==="")return"";let n,i=null;(n=e.match(Xge))?i=t.dot?Jge:Qge:(n=e.match(Uge))?i=(t.nocase?t.dot?qge:Gge:t.dot?Vge:Bge)(n[1]):(n=e.match(Zge))?i=(t.nocase?t.dot?tye:eye:t.dot?rye:nye)(n):(n=e.match(Wge))?i=t.dot?Hge:zge:(n=e.match(Kge))&&(i=Yge);let s=Tu.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?oye:t.dot?aye:cye,i=new Set(t.nocase?["i"]:[]),s=e.map(l=>{let u=l.map(d=>{if(d instanceof RegExp)for(let p of d.flags.split(""))i.add(p);return typeof d=="string"?pye(d):d===Ir?Ir:d._src});u.forEach((d,p)=>{let h=u[p+1],g=u[p-1];d!==Ir||g===Ir||(g===void 0?h!==void 0&&h!==Ir?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=g+"(?:\\/|\\/"+n+")?":h!==Ir&&(u[p-1]=g+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=Ir))});let f=u.filter(d=>d!==Ir);if(this.partial&&f.length>=1){let d=[];for(let p=1;p<=f.length;p++)d.push(f.slice(0,p).join("/"));return"(?:"+d.join("|")+")"}return f.join("/")}).join("|"),[o,c]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+c+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+c+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let c=i.length-2;!o&&c>=0;c--)o=i[c];for(let c of s){let l=i;if(n.matchBase&&c.length===1&&(l=[o]),this.matchOne(l,c,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return hi.defaults(e).Minimatch}};hi.AST=Tu;hi.Minimatch=Yi;hi.escape=Zd;hi.unescape=qs});var Ow,xn,og,hye,LO,G6,V6,mye,gye,Jc,q6,xw,yye,cg,z6=Me(()=>{Ow=require("node:diagnostics_channel"),xn=(0,Ow.channel)("lru-cache:metrics"),og=(0,Ow.tracingChannel)("lru-cache"),hye=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,LO=a(()=>xn.hasSubscribers||og.hasSubscribers,"R"),G6=new Set,V6=typeof process=="object"&&process?process:{},mye=a((r,e,t,n)=>{typeof V6.emitWarning=="function"?V6.emitWarning(r,e,t,n):console.error(`[${t}] ${e}: ${r}`)},"k"),gye=a(r=>!G6.has(r),"H"),Jc=a(r=>!!r&&r===Math.floor(r)&&r>0&&isFinite(r),"T"),q6=a(r=>Jc(r)?r<=Math.pow(2,8)?Uint8Array:r<=Math.pow(2,16)?Uint16Array:r<=Math.pow(2,32)?Uint32Array:r<=Number.MAX_SAFE_INTEGER?xw:null:null,"j"),xw=class extends Array{static{a(this,"O")}constructor(r){super(r),this.fill(0)}},yye=class ag{static{a(this,"d")}heap;length;static#t=!1;static create(e){let t=q6(e);if(!t)return[];ag.#t=!0;let n=new ag(e,t);return ag.#t=!1,n}constructor(e,t){if(!ag.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},cg=class W6{static{a(this,"d")}#t;#r;#n;#e;#i;#a;#p;#u;get perf(){return this.#u}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;backgroundFetchSize;#c;#f;#l;#d;#o;#g;#E;#_;#S;#A;#y;#v;#T;#m;#b;#w;#R;#s;#x;static unsafeExposeInternals(e){return{starts:e.#T,ttls:e.#m,autopurgeTimers:e.#b,sizes:e.#v,keyMap:e.#l,keyList:e.#d,valList:e.#o,next:e.#g,prev:e.#E,get head(){return e.#_},get tail(){return e.#S},free:e.#A,isBackgroundFetch:a(t=>e.#h(t),"isBackgroundFetch"),backgroundFetch:a((t,n,i,s)=>e.#M(t,n,i,s),"backgroundFetch"),moveToTail:a(t=>e.#K(t),"moveToTail"),indexes:a(t=>e.#P(t),"indexes"),rindexes:a(t=>e.#F(t),"rindexes"),isStale:a(t=>e.#I(t),"isStale")}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#f}get size(){return this.#c}get fetchMethod(){return this.#a}get memoMethod(){return this.#p}get dispose(){return this.#n}get onInsert(){return this.#e}get disposeAfter(){return this.#i}constructor(e){let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:l,dispose:u,onInsert:f,disposeAfter:d,noDisposeOnSet:p,noUpdateTTL:h,maxSize:g=0,maxEntrySize:m=0,sizeCalculation:b,fetchMethod:_,memoMethod:S,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:R,ignoreFetchAbort:x,backgroundFetchSize:P=1,perf:N}=e;if(this.backgroundFetchSize=P,N!==void 0&&typeof N?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#u=N??hye,t!==0&&!Jc(t))throw new TypeError("max option must be a nonnegative integer");let $=t?q6(t):Array;if(!$)throw new Error("invalid max value: "+t);if(this.#t=t,this.#r=g,this.maxEntrySize=m||this.#r,this.sizeCalculation=b,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#p=S,_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#a=_,this.#R=!!_,this.#l=new Map,this.#d=Array.from({length:t}).fill(void 0),this.#o=Array.from({length:t}).fill(void 0),this.#g=new $(t),this.#E=new $(t),this.#_=0,this.#S=0,this.#A=yye.create(t),this.#c=0,this.#f=0,typeof u=="function"&&(this.#n=u),typeof f=="function"&&(this.#e=f),typeof d=="function"?(this.#i=d,this.#y=[]):(this.#i=void 0,this.#y=void 0),this.#w=!!this.#n,this.#x=!!this.#e,this.#s=!!this.#i,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!x,this.maxEntrySize!==0){if(this.#r!==0&&!Jc(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!Jc(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#q()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=Jc(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!Jc(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let k="LRU_CACHE_UNBOUNDED";gye(k)&&(G6.add(k),mye("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",k,W6))}}getRemainingTTL(e){return this.#l.has(e)?1/0:0}#O(){let e=new xw(this.#t),t=new xw(this.#t);this.#m=e,this.#T=t;let n=this.ttlAutopurge?Array.from({length:this.#t}):void 0;this.#b=n,this.#$=(l,u,f=this.#u.now())=>{t[l]=u!==0?f:0,e[l]=u,i(l,u)},this.#C=l=>{t[l]=e[l]!==0?this.#u.now():0,i(l,e[l])};let i=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let f=setTimeout(()=>{this.#I(l)?(this.#j(this.#d[l],"expire"),n[l]=void 0):i(l,c(l))},u+1);f.unref&&f.unref(),n[l]=f}}:()=>{};this.#D=(l,u)=>{if(e[u]){let f=e[u],d=t[u];if(!f||!d)return;l.ttl=f,l.start=d,l.now=s||o();let p=l.now-d;l.remainingTTL=f-p}};let s=0,o=a(()=>{let l=this.#u.now();if(this.ttlResolution>0){s=l;let u=setTimeout(()=>s=0,this.ttlResolution);u.unref&&u.unref()}return l},"o");this.getRemainingTTL=l=>{let u=this.#l.get(l);return u===void 0?0:c(u)};let c=a(l=>{let u=e[l],f=t[l];if(!u||!f)return 1/0;let d=(s||o())-f;return u-d},"l");this.#I=l=>{let u=t[l],f=e[l];return!!f&&!!u&&(s||o())-u>f}}#C=a(()=>{},"#R");#D=a(()=>{},"#v");#$=a(()=>{},"#H");#I=a(()=>!1,"#p");#q(){let e=new xw(this.#t);this.#f=0,this.#v=e,this.#N=t=>{this.#f-=e[t],e[t]=0},this.#U=(t,n,i,s)=>{if(!Jc(i)){if(this.#h(n))return this.backgroundFetchSize;if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,t),!Jc(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return i},this.#L=(t,n,i)=>{if(e[t]=n,this.#r){let s=this.#r-e[t];for(;this.#f>s;)this.#G(!0)}this.#f+=e[t],i&&(i.entrySize=n,i.totalCalculatedSize=this.#f)}}#N=a(e=>{},"#x");#L=a((e,t,n)=>{},"#j");#U=a((e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#N");*#P({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#S;this.#B(t)&&((e||!this.#I(t))&&(yield t),t!==this.#_);)t=this.#E[t]}*#F({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#_;this.#B(t)&&((e||!this.#I(t))&&(yield t),t!==this.#S);)t=this.#g[t]}#B(e){return e!==void 0&&this.#l.get(this.#d[e])===e}*entries(){for(let e of this.#P())this.#o[e]!==void 0&&this.#d[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#d[e],this.#o[e]])}*rentries(){for(let e of this.#F())this.#o[e]!==void 0&&this.#d[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#d[e],this.#o[e]])}*keys(){for(let e of this.#P()){let t=this.#d[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*rkeys(){for(let e of this.#F()){let t=this.#d[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*values(){for(let e of this.#P())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#F())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let n of this.#P()){let i=this.#o[n],s=this.#h(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#d[n],this))return this.#H(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#P()){let i=this.#o[n],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#F()){let i=this.#o[n],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#F({allowStale:!0}))this.#I(t)&&(this.#j(this.#d[t],"expire"),e=!0);return e}info(e){let t=this.#l.get(e);if(t===void 0)return;let n=this.#o[t],i=this.#h(n)?n.__staleWhileFetching:n;if(i===void 0)return;let s={value:i};if(this.#m&&this.#T){let o=this.#m[t],c=this.#T[t];if(o&&c){let l=o-(this.#u.now()-c);s.ttl=l,s.start=Date.now()}}return this.#v&&(s.size=this.#v[t]),s}dump(){let e=[];for(let t of this.#P({allowStale:!0})){let n=this.#d[t],i=this.#o[t],s=this.#h(i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;let o={value:s};if(this.#m&&this.#T){o.ttl=this.#m[t];let c=this.#u.now()-this.#T[t];o.start=Math.floor(Date.now()-c)}this.#v&&(o.size=this.#v[t]),e.unshift([n,o])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=this.#u.now()-i}this.#k(t,n.value,n)}}set(e,t,n={}){let{status:i=xn.hasSubscribers?{}:void 0}=n;n.status=i,i&&(i.op="set",i.key=e,t!==void 0&&(i.value=t),i.cache=this);let s=this.#k(e,t,n);return i&&xn.hasSubscribers&&xn.publish(i),s}#k(e,t,n,i){let{ttl:s=this.ttl,start:o,noDisposeOnSet:c=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,f=this.#h(t);if(t===void 0)return u&&(u.set="deleted"),this.delete(e),this;let{noUpdateTTL:d=this.noUpdateTTL}=n;u&&!f&&(u.value=t);let p=this.#U(e,t,n.size||0,l,u);if(this.maxEntrySize&&p>this.maxEntrySize)return this.#j(e,"set"),u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this;let h=this.#c===0?void 0:this.#l.get(e);if(h===void 0)h=this.#c===0?this.#S:this.#A.length!==0?this.#A.pop():this.#c===this.#t?this.#G(!1):this.#c,this.#d[h]=e,this.#o[h]=t,this.#l.set(e,h),this.#g[this.#S]=h,this.#E[h]=this.#S,this.#S=h,this.#c++,this.#L(h,p,u),u&&(u.set="add"),d=!1,this.#x&&!f&&this.#e?.(t,e,"add");else{this.#K(h);let g=this.#o[h];if(t!==g){if(!c)if(this.#h(g)){g!==i&&g.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=g;m!==void 0&&m!==t&&(this.#w&&this.#n?.(m,e,"set"),this.#s&&this.#y?.push([m,e,"set"]))}else this.#w&&this.#n?.(g,e,"set"),this.#s&&this.#y?.push([g,e,"set"]);if(this.#N(h),this.#L(h,p,u),this.#o[h]=t,!f){let m=g&&this.#h(g)?g.__staleWhileFetching:g,b=m===void 0?"add":t!==m?"replace":"update";u&&(u.set=b,m!==void 0&&(u.oldValue=m)),this.#x&&this.onInsert?.(t,e,b)}}else f||(u&&(u.set="update"),this.#x&&this.onInsert?.(t,e,"update"))}if(s!==0&&!this.#m&&this.#O(),this.#m&&(d||this.#$(h,s,o),u&&this.#D(u,h)),!c&&this.#s&&this.#y){let g=this.#y,m;for(;m=g?.shift();)this.#i?.(...m)}return this}pop(){try{for(;this.#c;){let e=this.#o[this.#_];if(this.#G(!0),this.#h(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#s&&this.#y){let e=this.#y,t;for(;t=e?.shift();)this.#i?.(...t)}}}#G(e){let t=this.#_,n=this.#d[t],i=this.#o[t],s=this.#h(i);s&&i.__abortController.abort(new Error("evicted"));let o=s?i.__staleWhileFetching:i;return(this.#w||this.#s)&&o!==void 0&&(this.#w&&this.#n?.(o,n,"evict"),this.#s&&this.#y?.push([o,n,"evict"])),this.#N(t),this.#b?.[t]&&(clearTimeout(this.#b[t]),this.#b[t]=void 0),e&&(this.#d[t]=void 0,this.#o[t]=void 0,this.#A.push(t)),this.#c===1?(this.#_=this.#S=0,this.#A.length=0):this.#_=this.#g[t],this.#l.delete(n),this.#c--,t}has(e,t={}){let{status:n=xn.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="has",n.key=e,n.cache=this);let i=this.#Y(e,t);return xn.hasSubscribers&&xn.publish(n),i}#Y(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,s=this.#l.get(e);if(s!==void 0){let o=this.#o[s];if(this.#h(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#I(s))i&&(i.has="stale",this.#D(i,s));else return n&&this.#C(s),i&&(i.has="hit",this.#D(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{status:n=LO()?{}:void 0}=t;n&&(n.op="peek",n.key=e,n.cache=this),t.status=n;let i=this.#W(e,t);return xn.hasSubscribers&&xn.publish(n),i}#W(e,t){let{status:n,allowStale:i=this.allowStale}=t,s=this.#l.get(e);if(s===void 0||!i&&this.#I(s)){n&&(n.peek=s===void 0?"miss":"stale");return}let o=this.#o[s],c=this.#h(o)?o.__staleWhileFetching:o;return n&&(c!==void 0?(n.peek="hit",n.value=c):n.peek="miss"),c}#M(e,t,n,i){let s=t===void 0?void 0:this.#o[t];if(this.#h(s))return s;let o=new AbortController,{signal:c}=n;c?.addEventListener("abort",()=>o.abort(c.reason),{signal:o.signal});let l={signal:o.signal,options:n,context:i},u=a((m,b=!1)=>{let{aborted:_}=o.signal,S=n.ignoreFetchAbort&&m!==void 0,A=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&m!==void 0);if(n.status&&(_&&!b?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,S&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),_&&!S&&!b)return d(o.signal.reason,A);let w=h,E=this.#o[t];return(E===h||E===void 0&&S&&b)&&(m===void 0?w.__staleWhileFetching!==void 0?this.#o[t]=w.__staleWhileFetching:this.#j(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.#k(e,m,l.options,w))),m},"r"),f=a(m=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=m),d(m,!1)),"c"),d=a((m,b)=>{let{aborted:_}=o.signal,S=_&&n.allowStaleOnFetchAbort,A=S||n.allowStaleOnFetchRejection,w=A||n.noDeleteOnFetchRejection,E=h;if(this.#o[t]===h&&(!w||!b&&E.__staleWhileFetching===void 0?this.#j(e,"fetch"):S||(this.#o[t]=E.__staleWhileFetching)),A)return n.status&&E.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),E.__staleWhileFetching;if(E.__returned===E)throw m},"m"),p=a((m,b)=>{let _=this.#a?.(e,s,l);o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(m(void 0),n.allowStaleOnFetchAbort&&(m=a(S=>u(S,!0),"f")))}),_&&_ instanceof Promise?_.then(S=>m(S===void 0?void 0:S),b):_!==void 0&&m(_)},"_");n.status&&(n.status.fetchDispatched=!0);let h=new Promise(p).then(u,f),g=Object.assign(h,{__abortController:o,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.#k(e,g,{...l.options,status:void 0}),t=this.#l.get(e)):this.#o[t]=g,g}#h(e){if(!this.#R)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController}fetch(e,t={}){let n=og.hasSubscribers,{status:i=LO()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#z(e,t);return i&&n&&(i.trace=!0,og.tracePromise(()=>s,i).catch(()=>{})),s}async#z(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:l=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:h=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:m,forceRefresh:b=!1,status:_,signal:S}=t;if(_&&(_.op="fetch",_.key=e,b&&(_.forceRefresh=!0),_.cache=this),!this.#R)return _&&(_.fetch="get"),this.#H(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:_});let A={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:o,noDisposeOnSet:c,size:l,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:g,ignoreFetchAbort:h,status:_,signal:S},w=this.#l.get(e);if(w===void 0){_&&(_.fetch="miss");let E=this.#M(e,w,A,m);return E.__returned=E}else{let E=this.#o[w];if(this.#h(E)){let N=n&&E.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",N&&(_.returnedStale=!0)),N?E.__staleWhileFetching:E.__returned=E}let R=this.#I(w);if(!b&&!R)return _&&(_.fetch="hit"),this.#K(w),i&&this.#C(w),_&&this.#D(_,w),E;let x=this.#M(e,w,A,m),P=x.__staleWhileFetching!==void 0&&n;return _&&(_.fetch=R?"stale":"refresh",P&&R&&(_.returnedStale=!0)),P?x.__staleWhileFetching:x.__returned=x}}forceFetch(e,t={}){let n=og.hasSubscribers,{status:i=LO()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#V(e,t);return i&&n&&(i.trace=!0,og.tracePromise(()=>s,i).catch(()=>{})),s}async#V(e,t={}){let n=await this.#z(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let{status:n=xn.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="memo",n.key=e,t.context&&(n.context=t.context),n.cache=this);let i=this.#J(e,t);return n&&(n.value=i),xn.hasSubscribers&&xn.publish(n),i}#J(e,t={}){let n=this.#p;if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,status:s,forceRefresh:o,...c}=t;s&&o&&(s.forceRefresh=!0);let l=this.#H(e,c),u=o||l===void 0;if(s&&(s.memo=u?"miss":"hit",u||(s.value=l)),!u)return l;let f=n(e,l,{options:c,context:i});return s&&(s.value=f),this.#k(e,f,c),f}get(e,t={}){let{status:n=xn.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="get",n.key=e,n.cache=this);let i=this.#H(e,t);return n&&(i!==void 0&&(n.value=i),xn.hasSubscribers&&xn.publish(n)),i}#H(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:o}=t,c=this.#l.get(e);if(c===void 0){o&&(o.get="miss");return}let l=this.#o[c],u=this.#h(l);return o&&this.#D(o,c),this.#I(c)?u?(o&&(o.get="stale-fetching"),n&&l.__staleWhileFetching!==void 0?(o&&(o.returnedStale=!0),l.__staleWhileFetching):void 0):(s||this.#j(e,"expire"),o&&(o.get="stale"),n?(o&&(o.returnedStale=!0),l):void 0):(o&&(o.get=u?"fetching":"hit"),this.#K(c),i&&this.#C(c),u?l.__staleWhileFetching:l)}#X(e,t){this.#E[t]=e,this.#g[e]=t}#K(e){e!==this.#S&&(e===this.#_?this.#_=this.#g[e]:this.#X(this.#E[e],this.#g[e]),this.#X(this.#S,e),this.#S=e)}delete(e){return this.#j(e,"delete")}#j(e,t){xn.hasSubscribers&&xn.publish({op:"delete",delete:t,key:e,cache:this});let n=!1;if(this.#c!==0){let i=this.#l.get(e);if(i!==void 0)if(this.#b?.[i]&&(clearTimeout(this.#b[i]),this.#b[i]=void 0),n=!0,this.#c===1)this.#Q(t);else{this.#N(i);let s=this.#o[i];if(this.#h(s)?s.__abortController.abort(new Error("deleted")):(this.#w||this.#s)&&(this.#w&&this.#n?.(s,e,t),this.#s&&this.#y?.push([s,e,t])),this.#l.delete(e),this.#d[i]=void 0,this.#o[i]=void 0,i===this.#S)this.#S=this.#E[i];else if(i===this.#_)this.#_=this.#g[i];else{let o=this.#E[i];this.#g[o]=this.#g[i];let c=this.#g[i];this.#E[c]=this.#E[i]}this.#c--,this.#A.push(i)}}if(this.#s&&this.#y?.length){let i=this.#y,s;for(;s=i?.shift();)this.#i?.(...s)}return n}clear(){return this.#Q("delete")}#Q(e){for(let t of this.#F({allowStale:!0})){let n=this.#o[t];if(this.#h(n))n.__abortController.abort(new Error("deleted"));else{let i=this.#d[t];this.#w&&this.#n?.(n,i,e),this.#s&&this.#y?.push([n,i,e])}}if(this.#l.clear(),this.#o.fill(void 0),this.#d.fill(void 0),this.#m&&this.#T){this.#m.fill(0),this.#T.fill(0);for(let t of this.#b??[])t!==void 0&&clearTimeout(t);this.#b?.fill(void 0)}if(this.#v&&this.#v.fill(0),this.#_=0,this.#S=0,this.#A.length=0,this.#f=0,this.#c=0,this.#s&&this.#y){let t=this.#y,n;for(;n=t?.shift();)this.#i?.(...n)}}}});var Mw,BO,Q6,H6,bye,_ye,Sye,qa,Wa,Zc,Pw,lg,Fw,K6,Dw,Y6,Ws,ep,on,ug,tp,an,mi,cn,NO,Lw,Kn,Rr,kO,MO,X6,jO,jo,$O,Nw,fg,Au,Xi,dg,wye,Eye,vye,Tye,kw,UO,Aye,Iye,el,VO=Me(()=>{Mw=require("node:events"),BO=Q(require("node:stream"),1),Q6=require("node:string_decoder"),H6=typeof process=="object"&&process?process:{stdout:null,stderr:null},bye=a(r=>!!r&&typeof r=="object"&&(r instanceof el||r instanceof BO.default||_ye(r)||Sye(r)),"isStream"),_ye=a(r=>!!r&&typeof r=="object"&&r instanceof Mw.EventEmitter&&typeof r.pipe=="function"&&r.pipe!==BO.default.Writable.prototype.pipe,"isReadable"),Sye=a(r=>!!r&&typeof r=="object"&&r instanceof Mw.EventEmitter&&typeof r.write=="function"&&typeof r.end=="function","isWritable"),qa=Symbol("EOF"),Wa=Symbol("maybeEmitEnd"),Zc=Symbol("emittedEnd"),Pw=Symbol("emittingEnd"),lg=Symbol("emittedError"),Fw=Symbol("closed"),K6=Symbol("read"),Dw=Symbol("flush"),Y6=Symbol("flushChunk"),Ws=Symbol("encoding"),ep=Symbol("decoder"),on=Symbol("flowing"),ug=Symbol("paused"),tp=Symbol("resume"),an=Symbol("buffer"),mi=Symbol("pipes"),cn=Symbol("bufferLength"),NO=Symbol("bufferPush"),Lw=Symbol("bufferShift"),Kn=Symbol("objectMode"),Rr=Symbol("destroyed"),kO=Symbol("error"),MO=Symbol("emitData"),X6=Symbol("emitEnd"),jO=Symbol("emitEnd2"),jo=Symbol("async"),$O=Symbol("abort"),Nw=Symbol("aborted"),fg=Symbol("signal"),Au=Symbol("dataListeners"),Xi=Symbol("discarded"),dg=a(r=>Promise.resolve().then(r),"defer"),wye=a(r=>r(),"nodefer"),Eye=a(r=>r==="end"||r==="finish"||r==="prefinish","isEndish"),vye=a(r=>r instanceof ArrayBuffer||!!r&&typeof r=="object"&&r.constructor&&r.constructor.name==="ArrayBuffer"&&r.byteLength>=0,"isArrayBufferLike"),Tye=a(r=>!Buffer.isBuffer(r)&&ArrayBuffer.isView(r),"isArrayBufferView"),kw=class{static{a(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[tp](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},UO=class extends kw{static{a(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},Aye=a(r=>!!r.objectMode,"isObjectModeOptions"),Iye=a(r=>!r.objectMode&&!!r.encoding&&r.encoding!=="buffer","isEncodingOptions"),el=class extends Mw.EventEmitter{static{a(this,"Minipass")}[on]=!1;[ug]=!1;[mi]=[];[an]=[];[Kn];[Ws];[jo];[ep];[qa]=!1;[Zc]=!1;[Pw]=!1;[Fw]=!1;[lg]=null;[cn]=0;[Rr]=!1;[fg];[Nw]=!1;[Au]=0;[Xi]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Aye(t)?(this[Kn]=!0,this[Ws]=null):Iye(t)?(this[Ws]=t.encoding,this[Kn]=!1):(this[Kn]=!1,this[Ws]=null),this[jo]=!!t.async,this[ep]=this[Ws]?new Q6.StringDecoder(this[Ws]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:a(()=>this[an],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:a(()=>this[mi],"get")});let{signal:n}=t;n&&(this[fg]=n,n.aborted?this[$O]():n.addEventListener("abort",()=>this[$O]()))}get bufferLength(){return this[cn]}get encoding(){return this[Ws]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Kn]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[jo]}set async(e){this[jo]=this[jo]||!!e}[$O](){this[Nw]=!0,this.emit("abort",this[fg]?.reason),this.destroy(this[fg]?.reason)}get aborted(){return this[Nw]}set aborted(e){}write(e,t,n){if(this[Nw])return!1;if(this[qa])throw new Error("write after end");if(this[Rr])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(n=t,t="utf8"),t||(t="utf8");let i=this[jo]?dg:wye;if(!this[Kn]&&!Buffer.isBuffer(e)){if(Tye(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(vye(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Kn]?(this[on]&&this[cn]!==0&&this[Dw](!0),this[on]?this.emit("data",e):this[NO](e),this[cn]!==0&&this.emit("readable"),n&&i(n),this[on]):e.length?(typeof e=="string"&&!(t===this[Ws]&&!this[ep]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Ws]&&(e=this[ep].write(e)),this[on]&&this[cn]!==0&&this[Dw](!0),this[on]?this.emit("data",e):this[NO](e),this[cn]!==0&&this.emit("readable"),n&&i(n),this[on]):(this[cn]!==0&&this.emit("readable"),n&&i(n),this[on])}read(e){if(this[Rr])return null;if(this[Xi]=!1,this[cn]===0||e===0||e&&e>this[cn])return this[Wa](),null;this[Kn]&&(e=null),this[an].length>1&&!this[Kn]&&(this[an]=[this[Ws]?this[an].join(""):Buffer.concat(this[an],this[cn])]);let t=this[K6](e||null,this[an][0]);return this[Wa](),t}[K6](e,t){if(this[Kn])this[Lw]();else{let n=t;e===n.length||e===null?this[Lw]():typeof n=="string"?(this[an][0]=n.slice(e),t=n.slice(0,e),this[cn]-=e):(this[an][0]=n.subarray(e),t=n.subarray(0,e),this[cn]-=e)}return this.emit("data",t),!this[an].length&&!this[qa]&&this.emit("drain"),t}end(e,t,n){return typeof e=="function"&&(n=e,e=void 0),typeof t=="function"&&(n=t,t="utf8"),e!==void 0&&this.write(e,t),n&&this.once("end",n),this[qa]=!0,this.writable=!1,(this[on]||!this[ug])&&this[Wa](),this}[tp](){this[Rr]||(!this[Au]&&!this[mi].length&&(this[Xi]=!0),this[ug]=!1,this[on]=!0,this.emit("resume"),this[an].length?this[Dw]():this[qa]?this[Wa]():this.emit("drain"))}resume(){return this[tp]()}pause(){this[on]=!1,this[ug]=!0,this[Xi]=!1}get destroyed(){return this[Rr]}get flowing(){return this[on]}get paused(){return this[ug]}[NO](e){this[Kn]?this[cn]+=1:this[cn]+=e.length,this[an].push(e)}[Lw](){return this[Kn]?this[cn]-=1:this[cn]-=this[an][0].length,this[an].shift()}[Dw](e=!1){do;while(this[Y6](this[Lw]())&&this[an].length);!e&&!this[an].length&&!this[qa]&&this.emit("drain")}[Y6](e){return this.emit("data",e),this[on]}pipe(e,t){if(this[Rr])return e;this[Xi]=!1;let n=this[Zc];return t=t||{},e===H6.stdout||e===H6.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[mi].push(t.proxyErrors?new UO(this,e,t):new kw(this,e,t)),this[jo]?dg(()=>this[tp]()):this[tp]()),e}unpipe(e){let t=this[mi].find(n=>n.dest===e);t&&(this[mi].length===1?(this[on]&&this[Au]===0&&(this[on]=!1),this[mi]=[]):this[mi].splice(this[mi].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e==="data")this[Xi]=!1,this[Au]++,!this[mi].length&&!this[on]&&this[tp]();else if(e==="readable"&&this[cn]!==0)super.emit("readable");else if(Eye(e)&&this[Zc])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[lg]){let i=t;this[jo]?dg(()=>i.call(this,this[lg])):i.call(this,this[lg])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e==="data"&&(this[Au]=this.listeners("data").length,this[Au]===0&&!this[Xi]&&!this[mi].length&&(this[on]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Au]=0,!this[Xi]&&!this[mi].length&&(this[on]=!1)),t}get emittedEnd(){return this[Zc]}[Wa](){!this[Pw]&&!this[Zc]&&!this[Rr]&&this[an].length===0&&this[qa]&&(this[Pw]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Fw]&&this.emit("close"),this[Pw]=!1)}emit(e,...t){let n=t[0];if(e!=="error"&&e!=="close"&&e!==Rr&&this[Rr])return!1;if(e==="data")return!this[Kn]&&!n?!1:this[jo]?(dg(()=>this[MO](n)),!0):this[MO](n);if(e==="end")return this[X6]();if(e==="close"){if(this[Fw]=!0,!this[Zc]&&!this[Rr])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[lg]=n,super.emit(kO,n);let s=!this[fg]||this.listeners("error").length?super.emit("error",n):!1;return this[Wa](),s}else if(e==="resume"){let s=super.emit("resume");return this[Wa](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let i=super.emit(e,...t);return this[Wa](),i}[MO](e){for(let n of this[mi])n.dest.write(e)===!1&&this.pause();let t=this[Xi]?!1:super.emit("data",e);return this[Wa](),t}[X6](){return this[Zc]?!1:(this[Zc]=!0,this.readable=!1,this[jo]?(dg(()=>this[jO]()),!0):this[jO]())}[jO](){if(this[ep]){let t=this[ep].end();if(t){for(let n of this[mi])n.dest.write(t);this[Xi]||super.emit("data",t)}}for(let t of this[mi])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Kn]||(e.dataLength=0);let t=this.promise();return this.on("data",n=>{e.push(n),this[Kn]||(e.dataLength+=n.length)}),await t,e}async concat(){if(this[Kn])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Ws]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(Rr,()=>t(new Error("stream destroyed"))),this.on("error",n=>t(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Xi]=!1;let e=!1,t=a(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:a(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[qa])return t();let s,o,c=a(d=>{this.off("data",l),this.off("end",u),this.off(Rr,f),t(),o(d)},"onerr"),l=a(d=>{this.off("error",c),this.off("end",u),this.off(Rr,f),this.pause(),s({value:d,done:!!this[qa]})},"ondata"),u=a(()=>{this.off("error",c),this.off("data",l),this.off(Rr,f),t(),s({done:!0,value:void 0})},"onend"),f=a(()=>c(new Error("stream destroyed")),"ondestroy");return new Promise((d,p)=>{o=p,s=d,this.once(Rr,f),this.once("error",c),this.once("end",u),this.once("data",l)})},"next"),throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Xi]=!1;let e=!1,t=a(()=>(this.pause(),this.off(kO,t),this.off(Rr,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),n=a(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(kO,t),this.once(Rr,t),{next:n,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[Rr])return e?this.emit("error",e):this.emit(Rr),this;this[Rr]=!0,this[Xi]=!0,this[an].length=0,this[cn]=0;let t=this;return typeof t.close=="function"&&!this[Fw]&&t.close(),e?this.emit("error",e):this.emit(Rr),this}static get isStream(){return bye}}});var rp,r8,Uo,Rye,tl,Cye,hg,n8,i8,xye,Oye,ps,s8,o8,$o,a8,c8,Iu,l8,ds,pg,GO,J6,mg,zs,jw,Uw,Z6,Pye,qO,e8,gg,t8,$w,Bw,WO,u8,Yn,Vw,Gw,qw,np,ip,yg,$ke,f8,d8=Me(()=>{z6();rp=require("node:path"),r8=require("node:url"),Uo=require("fs"),Rye=Q(require("node:fs"),1),tl=require("node:fs/promises");VO();Cye=Uo.realpathSync.native,hg={lstatSync:Uo.lstatSync,readdir:Uo.readdir,readdirSync:Uo.readdirSync,readlinkSync:Uo.readlinkSync,realpathSync:Cye,promises:{lstat:tl.lstat,readdir:tl.readdir,readlink:tl.readlink,realpath:tl.realpath}},n8=a(r=>!r||r===hg||r===Rye?hg:{...hg,...r,promises:{...hg.promises,...r.promises||{}}},"fsFromOption"),i8=/^\\\\\?\\([a-z]:)\\?$/i,xye=a(r=>r.replace(/\//g,"\\").replace(i8,"$1\\"),"uncToDrive"),Oye=/[\\\/]/,ps=0,s8=1,o8=2,$o=4,a8=6,c8=8,Iu=10,l8=12,ds=15,pg=~ds,GO=16,J6=32,mg=64,zs=128,jw=256,Uw=512,Z6=mg|zs|Uw,Pye=1023,qO=a(r=>r.isFile()?c8:r.isDirectory()?$o:r.isSymbolicLink()?Iu:r.isCharacterDevice()?o8:r.isBlockDevice()?a8:r.isSocket()?l8:r.isFIFO()?s8:ps,"entToType"),e8=new cg({max:2**12}),gg=a(r=>{let e=e8.get(r);if(e)return e;let t=r.normalize("NFKD");return e8.set(r,t),t},"normalize"),t8=new cg({max:2**12}),$w=a(r=>{let e=t8.get(r);if(e)return e;let t=gg(r.toLowerCase());return t8.set(r,t),t},"normalizeNocase"),Bw=class extends cg{static{a(this,"ResolveCache")}constructor(){super({max:256})}},WO=class extends cg{static{a(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:a(t=>t.length+1,"sizeCalculation")})}},u8=Symbol("PathScurry setAsCwd"),Yn=class{static{a(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#e;get nlink(){return this.#e}#i;get uid(){return this.#i}#a;get gid(){return this.#a}#p;get rdev(){return this.#p}#u;get blksize(){return this.#u}#c;get ino(){return this.#c}#f;get size(){return this.#f}#l;get blocks(){return this.#l}#d;get atimeMs(){return this.#d}#o;get mtimeMs(){return this.#o}#g;get ctimeMs(){return this.#g}#E;get birthtimeMs(){return this.#E}#_;get atime(){return this.#_}#S;get mtime(){return this.#S}#A;get ctime(){return this.#A}#y;get birthtime(){return this.#y}#v;#T;#m;#b;#w;#R;#s;#x;#O;#C;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=ps,n,i,s,o,c){this.name=e,this.#v=s?$w(e):gg(e),this.#s=t&Pye,this.nocase=s,this.roots=i,this.root=n||this,this.#x=o,this.#m=c.fullpath,this.#w=c.relative,this.#R=c.relativePosix,this.parent=c.parent,this.parent?this.#t=this.parent.#t:this.#t=n8(c.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#x}resolve(e){if(!e)return this;let t=this.getRootString(e),i=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#D(i):this.#D(i)}#D(e){let t=this;for(let n of e)t=t.child(n);return t}children(){let e=this.#x.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#x.set(this,t),this.#s&=~GO,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let n=this.children(),i=this.nocase?$w(e):gg(e);for(let l of n)if(l.#v===i)return l;let s=this.parent?this.sep:"",o=this.#m?this.#m+s+e:void 0,c=this.newChild(e,ps,{...t,parent:this,fullpath:o});return this.canReaddir()||(c.#s|=zs),n.push(c),c}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let e=this.name,t=this.parent;if(!t)return this.#w=this.name;let n=t.relative();return n+(!n||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#R!==void 0)return this.#R;let e=this.name,t=this.parent;if(!t)return this.#R=this.fullpathPosix();let n=t.relativePosix();return n+(!n||!t.parent?"":"/")+e}fullpath(){if(this.#m!==void 0)return this.#m;let e=this.name,t=this.parent;if(!t)return this.#m=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#m=i}fullpathPosix(){if(this.#b!==void 0)return this.#b;if(this.sep==="/")return this.#b=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#b=`//?/${i}`:this.#b=i}let e=this.parent,t=e.fullpathPosix(),n=t+(!t||!e.parent?"":"/")+this.name;return this.#b=n}isUnknown(){return(this.#s&ds)===ps}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#s&ds)===c8}isDirectory(){return(this.#s&ds)===$o}isCharacterDevice(){return(this.#s&ds)===o8}isBlockDevice(){return(this.#s&ds)===a8}isFIFO(){return(this.#s&ds)===s8}isSocket(){return(this.#s&ds)===l8}isSymbolicLink(){return(this.#s&Iu)===Iu}lstatCached(){return this.#s&J6?this:void 0}readlinkCached(){return this.#O}realpathCached(){return this.#C}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#O)return!0;if(!this.parent)return!1;let e=this.#s&ds;return!(e!==ps&&e!==Iu||this.#s&jw||this.#s&zs)}calledReaddir(){return!!(this.#s&GO)}isENOENT(){return!!(this.#s&zs)}isNamed(e){return this.nocase?this.#v===$w(e):this.#v===gg(e)}async readlink(){let e=this.#O;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#t.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(t);if(n)return this.#O=n}catch(t){this.#F(t.code);return}}readlinkSync(){let e=this.#O;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#t.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(t);if(n)return this.#O=n}catch(t){this.#F(t.code);return}}#$(e){this.#s|=GO;for(let t=e.provisional;t<e.length;t++){let n=e[t];n&&n.#I()}}#I(){this.#s&zs||(this.#s=(this.#s|zs)&pg,this.#q())}#q(){let e=this.children();e.provisional=0;for(let t of e)t.#I()}#N(){this.#s|=Uw,this.#L()}#L(){if(this.#s&mg)return;let e=this.#s;(e&ds)===$o&&(e&=pg),this.#s=e|mg,this.#q()}#U(e=""){e==="ENOTDIR"||e==="EPERM"?this.#L():e==="ENOENT"?this.#I():this.children().provisional=0}#P(e=""){e==="ENOTDIR"?this.parent.#L():e==="ENOENT"&&this.#I()}#F(e=""){let t=this.#s;t|=jw,e==="ENOENT"&&(t|=zs),(e==="EINVAL"||e==="UNKNOWN")&&(t&=pg),this.#s=t,e==="ENOTDIR"&&this.parent&&this.parent.#L()}#B(e,t){return this.#G(e,t)||this.#k(e,t)}#k(e,t){let n=qO(e),i=this.newChild(e.name,n,{parent:this}),s=i.#s&ds;return s!==$o&&s!==Iu&&s!==ps&&(i.#s|=mg),t.unshift(i),t.provisional++,i}#G(e,t){for(let n=t.provisional;n<t.length;n++){let i=t[n];if((this.nocase?$w(e.name):gg(e.name))===i.#v)return this.#Y(e,i,n,t)}}#Y(e,t,n,i){let s=t.name;return t.#s=t.#s&pg|qO(e),s!==e.name&&(t.name=e.name),n!==i.provisional&&(n===i.length-1?i.pop():i.splice(n,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#s&zs)===0)try{return this.#W(await this.#t.promises.lstat(this.fullpath())),this}catch(e){this.#P(e.code)}}lstatSync(){if((this.#s&zs)===0)try{return this.#W(this.#t.lstatSync(this.fullpath())),this}catch(e){this.#P(e.code)}}#W(e){let{atime:t,atimeMs:n,birthtime:i,birthtimeMs:s,blksize:o,blocks:c,ctime:l,ctimeMs:u,dev:f,gid:d,ino:p,mode:h,mtime:g,mtimeMs:m,nlink:b,rdev:_,size:S,uid:A}=e;this.#_=t,this.#d=n,this.#y=i,this.#E=s,this.#u=o,this.#l=c,this.#A=l,this.#g=u,this.#r=f,this.#a=d,this.#c=p,this.#n=h,this.#S=g,this.#o=m,this.#e=b,this.#p=_,this.#f=S,this.#i=A;let w=qO(e);this.#s=this.#s&pg|w|J6,w!==ps&&w!==$o&&w!==Iu&&(this.#s|=mg)}#M=[];#h=!1;#z(e){this.#h=!1;let t=this.#M.slice();this.#M.length=0,t.forEach(n=>n(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let n=this.children();if(this.calledReaddir()){let s=n.slice(0,n.provisional);t?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#M.push(e),this.#h)return;this.#h=!0;let i=this.fullpath();this.#t.readdir(i,{withFileTypes:!0},(s,o)=>{if(s)this.#U(s.code),n.provisional=0;else{for(let c of o)this.#B(c,n);this.#$(n)}this.#z(n.slice(0,n.provisional))})}#V;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#V)await this.#V;else{let n=a(()=>{},"resolve");this.#V=new Promise(i=>n=i);try{for(let i of await this.#t.promises.readdir(t,{withFileTypes:!0}))this.#B(i,e);this.#$(e)}catch(i){this.#U(i.code),e.provisional=0}this.#V=void 0,n()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let n of this.#t.readdirSync(t,{withFileTypes:!0}))this.#B(n,e);this.#$(e)}catch(n){this.#U(n.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#s&Z6)return!1;let e=ds&this.#s;return e===ps||e===$o||e===Iu}shouldWalk(e,t){return(this.#s&$o)===$o&&!(this.#s&Z6)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#C)return this.#C;if(!((Uw|jw|zs)&this.#s))try{let e=await this.#t.promises.realpath(this.fullpath());return this.#C=this.resolve(e)}catch{this.#N()}}realpathSync(){if(this.#C)return this.#C;if(!((Uw|jw|zs)&this.#s))try{let e=this.#t.realpathSync(this.fullpath());return this.#C=this.resolve(e)}catch{this.#N()}}[u8](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),n=[],i=this;for(;i&&i.parent;)t.add(i),i.#w=n.join(this.sep),i.#R=n.join("/"),i=i.parent,n.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#w=void 0,i.#R=void 0,i=i.parent}},Vw=class r extends Yn{static{a(this,"PathWin32")}sep="\\";splitSep=Oye;constructor(e,t=ps,n,i,s,o,c){super(e,t,n,i,s,o,c)}newChild(e,t=ps,n={}){return new r(e,t,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return rp.win32.parse(e).root}getRoot(e){if(e=xye(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,n]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=n;return this.roots[e]=new np(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(i8,"$1\\"),e===t}},Gw=class r extends Yn{static{a(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=ps,n,i,s,o,c){super(e,t,n,i,s,o,c)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=ps,n={}){return new r(e,t,this.root,this.roots,this.nocase,this.childrenCache(),n)}},qw=class{static{a(this,"PathScurryBase")}root;rootPath;roots;cwd;#t;#r;#n;nocase;#e;constructor(e=process.cwd(),t,n,{nocase:i,childrenCacheSize:s=16*1024,fs:o=hg}={}){this.#e=n8(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,r8.fileURLToPath)(e));let c=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(c),this.#t=new Bw,this.#r=new Bw,this.#n=new WO(s);let l=c.substring(this.rootPath.length).split(n);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#e),this.roots[this.rootPath]=this.root;let u=this.root,f=l.length-1,d=t.sep,p=this.rootPath,h=!1;for(let g of l){let m=f--;u=u.child(g,{relative:new Array(m).fill("..").join(d),relativePosix:new Array(m).fill("..").join("/"),fullpath:p+=(h?"":d)+g}),h=!0}this.cwd=u}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let t="";for(let s=e.length-1;s>=0;s--){let o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let n=this.#t.get(t);if(n!==void 0)return n;let i=this.cwd.resolve(t).fullpath();return this.#t.set(t,i),i}resolvePosix(...e){let t="";for(let s=e.length-1;s>=0;s--){let o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let n=this.#r.get(t);if(n!==void 0)return n;let i=this.cwd.resolve(t).fullpathPosix();return this.#r.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n}=t;if(e.canReaddir()){let i=await e.readdir();return n?i:i.map(s=>s.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0}=t;return e.canReaddir()?n?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=await e.readlink();return t?n:n?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=e.readlinkSync();return t?n:n?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=await e.realpath();return t?n:n?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=e.realpathSync();return t?n:n?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=[];(!s||s(e))&&c.push(n?e:e.fullpath());let l=new Set,u=a((d,p)=>{l.add(d),d.readdirCB((h,g)=>{if(h)return p(h);let m=g.length;if(!m)return p();let b=a(()=>{--m===0&&p()},"next");for(let _ of g)(!s||s(_))&&c.push(n?_:_.fullpath()),i&&_.isSymbolicLink()?_.realpath().then(S=>S?.isUnknown()?S.lstat():S).then(S=>S?.shouldWalk(l,o)?u(S,b):b()):_.shouldWalk(l,o)?u(_,b):b()},!0)},"walk"),f=e;return new Promise((d,p)=>{u(f,h=>{if(h)return p(h);d(c)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=[];(!s||s(e))&&c.push(n?e:e.fullpath());let l=new Set([e]);for(let u of l){let f=u.readdirSync();for(let d of f){(!s||s(d))&&c.push(n?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(i&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(l,o)&&l.add(p)}}return c}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t;(!s||s(e))&&(yield n?e:e.fullpath());let c=new Set([e]);for(let l of c){let u=l.readdirSync();for(let f of u){(!s||s(f))&&(yield n?f:f.fullpath());let d=f;if(f.isSymbolicLink()){if(!(i&&(d=f.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,o)&&c.add(d)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=new el({objectMode:!0});(!s||s(e))&&c.write(n?e:e.fullpath());let l=new Set,u=[e],f=0,d=a(()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&c.end();return}f++,l.add(h);let g=a((b,_,S=!1)=>{if(b)return c.emit("error",b);if(i&&!S){let A=[];for(let w of _)w.isSymbolicLink()&&A.push(w.realpath().then(E=>E?.isUnknown()?E.lstat():E));if(A.length){Promise.all(A).then(()=>g(null,_,!0));return}}for(let A of _)A&&(!s||s(A))&&(c.write(n?A:A.fullpath())||(p=!0));f--;for(let A of _){let w=A.realpathCached()||A;w.shouldWalk(l,o)&&u.push(w)}p&&!c.flowing?c.once("drain",d):m||d()},"onReaddir"),m=!0;h.readdirCB(g,!0),m=!1}},"process");return d(),c}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=new el({objectMode:!0}),l=new Set;(!s||s(e))&&c.write(n?e:e.fullpath());let u=[e],f=0,d=a(()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&c.end();return}f++,l.add(h);let g=h.readdirSync();for(let m of g)(!s||s(m))&&(c.write(n?m:m.fullpath())||(p=!0));f--;for(let m of g){let b=m;if(m.isSymbolicLink()){if(!(i&&(b=m.realpathSync())))continue;b.isUnknown()&&b.lstatSync()}b.shouldWalk(l,o)&&u.push(b)}}p&&!c.flowing&&c.once("drain",d)},"process");return d(),c}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[u8](t)}},np=class extends qw{static{a(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,rp.win32,"\\",{...t,nocase:n}),this.nocase=n;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return rp.win32.parse(e).root.toUpperCase()}newRoot(e){return new Vw(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},ip=class extends qw{static{a(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:n=!1}=t;super(e,rp.posix,"/",{...t,nocase:n}),this.nocase=n}parseRootPath(e){return"/"}newRoot(e){return new Gw(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},yg=class extends ip{static{a(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,{...t,nocase:n})}},$ke=process.platform==="win32"?Vw:Gw,f8=process.platform==="win32"?np:process.platform==="darwin"?yg:ip});var Fye,Dye,sp,zO=Me(()=>{Qc();Fye=a(r=>r.length>=1,"isPatternList"),Dye=a(r=>r.length>=1,"isGlobList"),sp=class r{static{a(this,"Pattern")}#t;#r;#n;length;#e;#i;#a;#p;#u;#c;#f=!0;constructor(e,t,n,i){if(!Fye(e))throw new TypeError("empty pattern list");if(!Dye(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#t=e,this.#r=t,this.#n=n,this.#e=i,this.#n===0){if(this.isUNC()){let[s,o,c,l,...u]=this.#t,[f,d,p,h,...g]=this.#r;u[0]===""&&(u.shift(),g.shift());let m=[s,o,c,l,""].join("/"),b=[f,d,p,h,""].join("/");this.#t=[m,...u],this.#r=[b,...g],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[s,...o]=this.#t,[c,...l]=this.#r;o[0]===""&&(o.shift(),l.shift());let u=s+"/",f=c+"/";this.#t=[u,...o],this.#r=[f,...l],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===Ir}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#a=this.#a||(this.#n===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new r(this.#t,this.#r,this.#n+1,this.#e),this.#i.#c=this.#c,this.#i.#u=this.#u,this.#i.#p=this.#p,this.#i):this.#i=null}isUNC(){let e=this.#t;return this.#u!==void 0?this.#u:this.#u=this.#e==="win32"&&this.#n===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#t;return this.#p!==void 0?this.#p:this.#p=this.#e==="win32"&&this.#n===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#t;return this.#c!==void 0?this.#c:this.#c=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#t[0];return typeof e=="string"&&this.isAbsolute()&&this.#n===0?e:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}}});var Lye,op,HO=Me(()=>{Qc();zO();Lye=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",op=class{static{a(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:n,noext:i,noglobstar:s,platform:o=Lye}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:n,noext:i,noglobstar:s,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let c of e)this.add(c)}add(e){let t=new Yi(e,this.mmopts);for(let n=0;n<t.set.length;n++){let i=t.set[n],s=t.globParts[n];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let o=new sp(i,s,0,this.platform),c=new Yi(o.globString(),this.mmopts),l=s[s.length-1]==="**",u=o.isAbsolute();u?this.absolute.push(c):this.relative.push(c),l&&(u?this.absoluteChildren.push(c):this.relativeChildren.push(c))}}ignored(e){let t=e.fullpath(),n=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(s))return!0;for(let o of this.absolute)if(o.match(t)||o.match(n))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",n=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(n))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}}});var KO,YO,XO,bg,p8=Me(()=>{Qc();KO=class r{static{a(this,"HasWalkedCache")}store;constructor(e=new Map){this.store=e}copy(){return new r(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let n=e.fullpath(),i=this.store.get(n);i?i.add(t.globString()):this.store.set(n,new Set([t.globString()]))}},YO=class{static{a(this,"MatchRecord")}store=new Map;add(e,t,n){let i=(t?2:0)|(n?1:0),s=this.store.get(e);this.store.set(e,s===void 0?i:i&s)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},XO=class{static{a(this,"SubWalks")}store=new Map;add(e,t){if(!e.canReaddir())return;let n=this.store.get(e);n?n.find(i=>i.globString()===t.globString())||n.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},bg=class r{static{a(this,"Processor")}hasWalkedCache;matches=new YO;subwalks=new XO;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new KO}processPatterns(e,t){this.patterns=t;let n=t.map(i=>[e,i]);for(let[i,s]of n){this.hasWalkedCache.storeWalked(i,s);let o=s.root(),c=s.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let d=s.rest();if(d)s=d;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let l,u,f=!1;for(;typeof(l=s.pattern())=="string"&&(u=s.rest());)i=i.resolve(l),s=u,f=!0;if(l=s.pattern(),u=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof l=="string"){let d=l===".."||l===""||l===".";this.matches.add(i.resolve(l),c,d);continue}else if(l===Ir){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let d=u?.pattern(),p=u?.rest();if(!u||(d===""||d===".")&&!p)this.matches.add(i,c,d===""||d===".");else if(d===".."){let h=i.parent||i;p?this.hasWalkedCache.hasWalked(h,p)||this.subwalks.add(h,p):this.matches.add(h,c,!0)}}else l instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new r(this.opts,this.hasWalkedCache)}filterEntries(e,t){let n=this.subwalks.get(e),i=this.child();for(let s of t)for(let o of n){let c=o.isAbsolute(),l=o.pattern(),u=o.rest();l===Ir?i.testGlobstar(s,o,u,c):l instanceof RegExp?i.testRegExp(s,l,u,c):i.testString(s,l,u,c)}return i}testGlobstar(e,t,n,i){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(n&&t.checkFollowGlobstar()?this.subwalks.add(e,n):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),n){let s=n.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,n.rest(),i);else if(s===".."){let o=e.parent||e;this.subwalks.add(o,n)}else s instanceof RegExp&&this.testRegExp(e,s,n.rest(),i)}}testRegExp(e,t,n,i){t.test(e.name)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}testString(e,t,n,i){e.isNamed(t)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}}});var Nye,Ww,_g,Sg,h8=Me(()=>{VO();HO();p8();Nye=a((r,e)=>typeof r=="string"?new op([r],e):Array.isArray(r)?new op(r,e):r,"makeIgnore"),Ww=class{static{a(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#n;signal;maxDepth;includeChildMatches;constructor(e,t,n){if(this.patterns=e,this.path=t,this.opts=n,this.#n=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#r=Nye(n.ignore??[],n),!this.includeChildMatches&&typeof this.#r.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#e(e){return this.seen.has(e)||!!this.#r?.ignored?.(e)}#i(e){return!!this.#r?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#t.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#t.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||await e.realpath(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let o=await s.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(s,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#e(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||e.realpathSync(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let o=s.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(s,t)}matchFinish(e,t){if(this.#e(e))return;if(!this.includeChildMatches&&this.#r?.add){let s=`${e.relativePosix()}/**`;this.#r.add(s)}let n=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(n){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!s.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(s?o+s+i:"."+i)}}async match(e,t,n){let i=await this.matchCheck(e,n);i&&this.matchFinish(i,t)}matchSync(e,t,n){let i=this.matchCheckSync(e,n);i&&this.matchFinish(i,t)}walkCB(e,t,n){this.signal?.aborted&&n(),this.walkCB2(e,t,new bg(this.opts),n)}walkCB2(e,t,n,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,n,i));return}n.processPatterns(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||(s++,this.match(c,l,u).then(()=>o()));for(let c of n.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirCached();c.calledReaddir()?this.walkCB3(c,l,n,o):c.readdirCB((u,f)=>this.walkCB3(c,f,n,o),!0)}o()}walkCB3(e,t,n,i){n=n.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||(s++,this.match(c,l,u).then(()=>o()));for(let[c,l]of n.subwalks.entries())s++,this.walkCB2(c,l,n.child(),o);o()}walkCBSync(e,t,n){this.signal?.aborted&&n(),this.walkCB2Sync(e,t,new bg(this.opts),n)}walkCB2Sync(e,t,n,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,n,i));return}n.processPatterns(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||this.matchSync(c,l,u);for(let c of n.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirSync();this.walkCB3Sync(c,l,n,o)}o()}walkCB3Sync(e,t,n,i){n=n.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||this.matchSync(c,l,u);for(let[c,l]of n.subwalks.entries())s++,this.walkCB2Sync(c,l,n.child(),o);o()}},_g=class extends Ww{static{a(this,"GlobWalker")}matches=new Set;constructor(e,t,n){super(e,t,n)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Sg=class extends Ww{static{a(this,"GlobStream")}results;constructor(e,t,n){super(e,t,n),this.results=new el({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}});var m8,kye,Hs,QO=Me(()=>{Qc();m8=require("node:url");d8();zO();h8();kye=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Hs=class{static{a(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,m8.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(l=>l.includes("/")?l:`./**/${l}`)}if(this.pattern=e,this.platform=t.platform||kye,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let l=t.platform==="win32"?np:t.platform==="darwin"?yg:t.platform?ip:f8;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},s=this.pattern.map(l=>new Yi(l,i)),[o,c]=s.reduce((l,u)=>(l[0].push(...u.set),l[1].push(...u.globParts),l),[[],[]]);this.patterns=o.map((l,u)=>{let f=c[u];if(!f)throw new Error("invalid pattern object");return new sp(l,f,0,this.platform)})}async walk(){return[...await new _g(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new _g(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Sg(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Sg(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}});var JO,ZO=Me(()=>{Qc();JO=a((r,e={})=>{Array.isArray(r)||(r=[r]);for(let t of r)if(new Yi(t,e).hasMagic())return!0;return!1},"hasMagic")});function zw(r,e={}){return new Hs(r,e).streamSync()}function y8(r,e={}){return new Hs(r,e).stream()}function b8(r,e={}){return new Hs(r,e).walkSync()}async function g8(r,e={}){return new Hs(r,e).walk()}function Hw(r,e={}){return new Hs(r,e).iterateSync()}function _8(r,e={}){return new Hs(r,e).iterate()}var Mye,jye,$ye,Uye,Bye,ap,eP=Me(()=>{Qc();QO();ZO();Qc();QO();ZO();HO();a(zw,"globStreamSync");a(y8,"globStream");a(b8,"globSync");a(g8,"glob_");a(Hw,"globIterateSync");a(_8,"globIterate");Mye=zw,jye=Object.assign(y8,{sync:zw}),$ye=Hw,Uye=Object.assign(_8,{sync:Hw}),Bye=Object.assign(b8,{stream:zw,iterate:Hw}),ap=Object.assign(g8,{glob:g8,globSync:b8,sync:Bye,globStream:y8,stream:jye,globStreamSync:zw,streamSync:Mye,globIterate:_8,iterate:Uye,globIterateSync:Hw,iterateSync:$ye,Glob:Hs,hasMagic:JO,escape:Zd,unescape:qs});ap.glob=ap});async function w8(r,e,t,n={}){let{excludeRelPath:i}=n,s=Ru.default.join(r,"**/*.md"),o=await ap(s,{nodir:!0,ignore:[Ru.default.join(r,".obsidian/**"),Ru.default.join(r,".trash/**"),Ru.default.join(r,"**/.obsidian/**"),Ru.default.join(r,"**/.trash/**")]}),c={filesScanned:0,filesModified:0,replacements:0,modifiedFiles:[]};for(let l of o){let u=Ru.default.relative(r,l);if(i&&u===i)continue;c.filesScanned+=1;let f;try{f=await tP.default.readFile(l,"utf-8")}catch{continue}let{updated:d,replacements:p}=Vye(f,e,t);p>0&&(c.filesModified+=1,c.replacements+=p,c.modifiedFiles.push(u),await tP.default.writeFile(l,d,"utf-8"))}return c}function Vye(r,e,t){let n=r.split(/(^```[\s\S]*?^```)/m),i=0;for(let s=0;s<n.length;s++){if(s%2===1)continue;let o=n[s],c=Gye(o,e,t);i+=c.replacements,n[s]=c.updated}return{updated:n.join(""),replacements:i}}function Gye(r,e,t){let n=r.split(/(`[^`\n]*`)/),i=0;for(let s=0;s<n.length;s++){if(s%2===1)continue;let o=qye(n[s],e,t);i+=o.replacements,n[s]=o.updated}return{updated:n.join(""),replacements:i}}function qye(r,e,t){let n=/(?<!!)\[\[([^\[\]\n|#^]+)((?:[#^][^\[\]\n|]*)?)(?:\|[^\[\]\n]*)?\]\]/g,i=0;return{updated:r.replace(n,(o,c,l)=>c.trim()!==e?o:(i+=1,`[[${t}${l}]]`)),replacements:i}}var tP,Ru,E8=Me(()=>{"use strict";tP=Q(Mo()),Ru=Q(require("path"));eP();a(w8,"rewriteInboundWikilinks");a(Vye,"rewriteContent");a(Gye,"rewriteProseSegment");a(qye,"replaceWikilinks")});var Cr,fr,Kw,Wye,Ht,Ks=Me(()=>{"use strict";Cr=Q(Mo()),fr=Q(require("path"));rg();Kw=Q(Pe());E8();Wye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ht=class r{constructor(e){this.rootPath=e;this.uuidIndex=null;this.basenameIndex=null;this.aliasIndex=null}static{a(this,"FileSystemVaultAdapter")}async read(e){let t=this.resolvePath(e.path);if(!await Cr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);return Cr.default.readFile(t,"utf-8")}async create(e,t){let n=this.resolvePath(e);if(await Cr.default.pathExists(n))throw new Error(`File already exists: ${e}`);return await Cr.default.ensureDir(fr.default.dirname(n)),await Cr.default.writeFile(n,t,"utf-8"),this.createFileObject(e)}async modify(e,t){let n=this.resolvePath(e.path);if(!await Cr.default.pathExists(n))throw new Error(`File not found: ${e.path}`);await Cr.default.writeFile(n,t,"utf-8")}async delete(e){let t=this.resolvePath(e.path);if(!await Cr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);await Cr.default.remove(t)}async exists(e){let t=this.resolvePath(e);return Cr.default.pathExists(t)}getAbstractFileByPath(e){let t=this.resolvePath(e);try{let n=Cr.default.statSync(t);if(n.isFile())return this.createFileObject(e);if(n.isDirectory())return this.createFolderObject(e)}catch{return null}return null}getAllFiles(){let e=[];return this.walkDirectory(this.rootPath,t=>{if(t.endsWith(".md")){let n=fr.default.relative(this.rootPath,t);e.push(this.createFileObject(n))}}),e}getFrontmatter(e){try{let t=Cr.default.readFileSync(this.resolvePath(e.path),"utf-8");return this.extractFrontmatter(t)}catch{return null}}getFrontmatterParseFailure(e){let t;try{t=Cr.default.readFileSync(this.resolvePath(e.path),"utf-8")}catch{return null}let n=r.FRONTMATTER_BLOCK.exec(t)?.[1];if(n===void 0)return null;let i=/^[ \t]*(#.*)?\r?$/;if(!n.split(`
|
|
431
|
+
`)}return n}function Jd(r,e={}){let t={...age,...e},n=Rme(r,t.schema,{noRefs:t.noRefs,skipInvalid:t.skipInvalid});return t.flowLevel>=0&&xme(n,(i,s)=>{if(!(s.depth<t.flowLevel))return i.style.flow=!0,d6}),t.transform(n),oge(n,{...rO(t,Object.keys(vO)),schema:t.schema})}var bt,Dpe,Lpe,Npe,kpe,Mpe,jpe,$pe,Upe,Bpe,Vpe,Gpe,qpe,Wpe,zpe,Hpe,Kpe,Ype,X5,Jpe,Zpe,rhe,nhe,eO,ohe,ahe,Q5,uhe,fhe,hhe,mhe,ghe,tO,_he,She,vhe,The,Ahe,Rhe,Che,xhe,Ohe,Phe,Fhe,Aw,yO,kNe,vu,tg,khe,MNe,jNe,Mhe,Kc,_r,Cn,Yc,Ki,$he,e6,t6,Hhe,Wd,Khe,_O,wt,o6,Yd,nO,a6,ww,eme,tme,c6,iO,l6,rme,nme,ime,SO,vme,yw,yu,Cme,d6,wO,Ome,Eu,p6,Pme,Fme,h6,aO,Dme,Lme,m6,Nme,cO,EO,Qm,kme,Mme,g6,jme,lO,uO,$me,fO,Ume,dO,Hn,vO,Zm,Xm,TO,AO,Hc,age,$Ne,UNe,BNe,VNe,GNe,qNe,WNe,zNe,HNe,KNe,YNe,XNe,QNe,JNe,ZNe,eke,rg=Me(()=>{bt=Symbol("NOT_RESOLVED");a(zn,"defineScalarTag");a(gO,"defineSequenceTag");a(vw,"defineMappingTag");Dpe=zn("tag:yaml.org,2002:str",{resolve:a(r=>r,"resolve"),identify:a(r=>typeof r=="string","identify")}),Lpe=["","~","null","Null","NULL"],Npe=zn("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:a(r=>Lpe.indexOf(r)!==-1?null:bt,"resolve"),identify:a(r=>r===null,"identify"),represent:a(()=>"null","represent")}),kpe=zn("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["n"],resolve:a((r,e)=>r==="null"||e&&r===""?null:bt,"resolve"),identify:a(r=>r===null,"identify"),represent:a(()=>"null","represent")}),Mpe=["","~","null","Null","NULL"],jpe=zn("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:a(r=>Mpe.indexOf(r)!==-1?null:bt,"resolve"),identify:a(r=>r===null,"identify"),represent:a(()=>"null","represent")}),$pe=["true","True","TRUE"],Upe=["false","False","FALSE"],Bpe=zn("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","T","f","F"],resolve:a(r=>$pe.indexOf(r)!==-1?!0:Upe.indexOf(r)!==-1?!1:bt,"resolve"),identify:a(r=>Object.prototype.toString.call(r)==="[object Boolean]","identify"),represent:a(r=>r?"true":"false","represent")}),Vpe=["true"],Gpe=["false"],qpe=zn("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","f"],resolve:a(r=>Vpe.indexOf(r)!==-1?!0:Gpe.indexOf(r)!==-1?!1:bt,"resolve"),identify:a(r=>Object.prototype.toString.call(r)==="[object Boolean]","identify"),represent:a(r=>r?"true":"false","represent")}),Wpe=["true","True","TRUE","y","Y","yes","Yes","YES","on","On","ON"],zpe=["false","False","FALSE","n","N","no","No","NO","off","Off","OFF"],Hpe=zn("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["y","Y","n","N","t","T","f","F","o","O"],resolve:a(r=>Wpe.indexOf(r)!==-1?!0:zpe.indexOf(r)!==-1?!1:bt,"resolve"),identify:a(r=>Object.prototype.toString.call(r)==="[object Boolean]","identify"),represent:a(r=>r?"true":"false","represent")}),Kpe=new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$"),Ype=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");a(Xpe,"parseYamlInteger$2");a(Qpe,"resolveYamlInteger$2");X5=zn("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:Qpe,identify:a(r=>Number.isInteger(r)&&!Object.is(r,-0)&&r.toString(10).indexOf("e")<0,"identify"),represent:a(r=>r.toString(10),"represent")}),Jpe=new RegExp("^-?(?:0|[1-9][0-9]*)$"),Zpe=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");a(ehe,"parseYamlInteger$1");a(the,"resolveYamlInteger$1");rhe=zn("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:the,identify:a(r=>Number.isInteger(r)&&!Object.is(r,-0)&&r.toString(10).indexOf("e")<0,"identify"),represent:a(r=>r.toString(10),"represent")}),nhe=new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");a(ihe,"parseYamlInteger");a(she,"resolveYamlInteger");eO=zn("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:she,identify:a(r=>Number.isInteger(r)&&!Object.is(r,-0)&&r.toString(10).indexOf("e")<0,"identify"),represent:a(r=>r.toString(10),"represent")}),ohe=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),ahe=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");a(che,"resolveYamlFloat$2");a(lhe,"representYamlFloat$2");Q5=zn("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:che,identify:a(r=>typeof r=="number"&&(!Number.isInteger(r)||Object.is(r,-0)||r.toString(10).indexOf("e")>=0),"identify"),represent:lhe}),uhe=new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$"),fhe=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");a(dhe,"resolveYamlFloat$1");a(phe,"representYamlFloat$1");hhe=zn("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:dhe,identify:a(r=>typeof r=="number"&&(!Number.isInteger(r)||Object.is(r,-0)||r.toString(10).indexOf("e")>=0),"identify"),represent:phe}),mhe=new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),ghe=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");a(yhe,"resolveYamlFloat");a(bhe,"representYamlFloat");tO=zn("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:yhe,identify:a(r=>typeof r=="number"&&(!Number.isInteger(r)||Object.is(r,-0)||r.toString(10).indexOf("e")>=0),"identify"),represent:bhe}),_he=zn("tag:yaml.org,2002:merge",{implicit:!0,implicitFirstChars:["<"],resolve:a((r,e)=>r==="<<"||e&&r===""?"<<":bt,"resolve"),identify:a(()=>!1,"identify")}),She=/^[A-Za-z0-9+/]*={0,2}$/;a(whe,"resolveYamlBinary");a(Ehe,"representYamlBinary");vhe=zn("tag:yaml.org,2002:binary",{resolve:whe,identify:a(r=>Object.prototype.toString.call(r)==="[object Uint8Array]","identify"),represent:Ehe}),The=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ahe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");a(F5,"makeUtcDate");a(Ihe,"resolveYamlTimestamp");Rhe=zn("tag:yaml.org,2002:timestamp",{implicit:!0,implicitFirstChars:[..."0123456789"],resolve:Ihe,identify:a(r=>r instanceof Date,"identify"),represent:a(r=>r.toISOString(),"represent")}),Che=gO("tag:yaml.org,2002:seq",{create:a(()=>[],"create"),addItem:a((r,e)=>{r.push(e)},"addItem"),identify:Array.isArray});a(Tw,"isPlainObject");a(rO,"pick");xhe=gO("tag:yaml.org,2002:omap",{create:a(()=>({list:[],seen:new Set}),"create"),addItem:a((r,e)=>{let t;if(e instanceof Map){if(e.size!==1)return"cannot resolve an ordered map item";t=e.keys().next().value}else if(Tw(e)){let n=Object.keys(e);if(n.length!==1)return"cannot resolve an ordered map item";t=n[0]}else return"cannot resolve an ordered map item";return r.seen.has(t)?"duplicate key in ordered map":(r.seen.add(t),r.list.push(e),"")},"addItem"),finalize:a(r=>r.list,"finalize"),identify:a(()=>!1,"identify")}),Ohe=gO("tag:yaml.org,2002:pairs",{create:a(()=>[],"create"),addItem:a((r,e)=>{if(e instanceof Map)return e.size!==1?"cannot resolve a pairs item":(r.push(e.entries().next().value),"");if(Object.prototype.toString.call(e)!=="[object Object]")return"cannot resolve a pairs item";let t=e,n=Object.keys(t);return n.length!==1?"cannot resolve a pairs item":(r.push([n[0],t[n[0]]]),"")},"addItem"),identify:a(()=>!1,"identify")}),Phe=vw("tag:yaml.org,2002:map",{create:a(()=>({}),"create"),identify:Tw,represent:a(r=>{let e=new Map;for(let t of Object.keys(r))e.set(t,r[t]);return e},"represent"),addPair:a((r,e,t)=>{if(e!==null&&typeof e=="object")return"object-based map does not support complex keys";let n=String(e);return n==="__proto__"?Object.defineProperty(r,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[n]=t,""},"addPair"),has:a((r,e)=>e!==null&&typeof e=="object"?!1:Object.prototype.hasOwnProperty.call(r,String(e)),"has"),keys:a(r=>Object.keys(r),"keys"),get:a((r,e)=>{let t=String(e);return Object.prototype.hasOwnProperty.call(r,t)?r[t]:null},"get")}),Fhe=vw("tag:yaml.org,2002:set",{create:a(()=>new Set,"create"),identify:a(r=>r instanceof Set,"identify"),represent:a(r=>{let e=new Map;for(let t of r)e.set(t,null);return e},"represent"),addPair:a((r,e,t)=>t!==null?"cannot resolve a set item":(r.add(e),""),"addPair"),has:a((r,e)=>r.has(e),"has"),keys:a(r=>r.keys(),"keys"),get:a(()=>null,"get")});a(Dhe,"createTagDefinitionMap");a(Lhe,"createTagDefinitionListMap");a(Nhe,"compileTags");Aw=class J5{static{a(this,"Schema")}tags;implicitScalarTags;implicitScalarByFirstChar;implicitScalarAnyFirstChar;defaultScalarTag;defaultSequenceTag;defaultMappingTag;exact;prefix;constructor(e){let t=Nhe(e),n=[],i=Dhe(),s=Lhe();for(let f of t){if(f.nodeKind==="scalar"&&f.implicit){if(f.matchByTagPrefix)throw new Error("Implicit scalar tags cannot match by tag prefix");n.push(f)}switch(f.nodeKind){case"scalar":f.matchByTagPrefix?s.scalar.push(f):i.scalar[f.tagName]=f;break;case"sequence":f.matchByTagPrefix?s.sequence.push(f):i.sequence[f.tagName]=f;break;case"mapping":f.matchByTagPrefix?s.mapping.push(f):i.mapping[f.tagName]=f;break}}let o=n.filter(f=>f.implicitFirstChars===null),c=new Set;for(let f of n)if(f.implicitFirstChars!==null)for(let d of f.implicitFirstChars)c.add(d);let l=new Map;for(let f of c)l.set(f,n.filter(d=>d.implicitFirstChars===null||d.implicitFirstChars.indexOf(f)!==-1));let u=i.scalar["tag:yaml.org,2002:str"];if(!u)throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");this.tags=t,this.implicitScalarTags=n,this.implicitScalarByFirstChar=l,this.implicitScalarAnyFirstChar=o,this.defaultScalarTag=u,this.defaultSequenceTag=i.sequence["tag:yaml.org,2002:seq"],this.defaultMappingTag=i.mapping["tag:yaml.org,2002:map"],this.exact=i,this.prefix=s}lookupScalarTag(e){let t=this.exact.scalar[e];if(t)return t;for(let n of this.prefix.scalar)if(e.startsWith(n.tagName))return n}lookupSequenceTag(e){let t=this.exact.sequence[e];if(t)return t;for(let n of this.prefix.sequence)if(e.startsWith(n.tagName))return n}lookupMappingTag(e){let t=this.exact.mapping[e];if(t)return t;for(let n of this.prefix.mapping)if(e.startsWith(n.tagName))return n}resolveImplicitScalarTag(e){let t=this.implicitScalarByFirstChar.get(e.charAt(0))??this.implicitScalarAnyFirstChar;for(let i of t){let s=i.resolve(e,!1,i.tagName);if(s!==bt)return{value:s,tag:i}}let n=this.defaultScalarTag;return{value:n.resolve(e,!1,n.tagName),tag:n}}withTags(...e){let t=[];for(let n of e)t=t.concat(n);return new J5([...this.tags,...t])}},yO=new Aw([Dpe,Che,Phe]),kNe=new Aw([...yO.tags,kpe,qpe,rhe,hhe]),vu=new Aw([...yO.tags,Npe,Bpe,X5,Q5]),tg=new Aw([...yO.tags,jpe,Hpe,eO,tO,Rhe,_he,vhe,xhe,Ohe,Fhe]),khe=tg.withTags({...eO,resolve:a((r,e,t)=>{let n=eO.resolve(r,e,t);return n===bt?X5.resolve(r,e,t):n},"resolve")},{...tO,resolve:a((r,e,t)=>{let n=tO.resolve(r,e,t);return n===bt?Q5.resolve(r,e,t):n},"resolve")}),MNe=vw("tag:yaml.org,2002:map",{create:a(()=>new Map,"create"),addPair:a((r,e,t)=>(r.set(e,t),""),"addPair"),has:a((r,e)=>r.has(e),"has"),keys:a(r=>r.keys(),"keys"),get:a((r,e)=>r.get(e),"get"),identify:a(r=>r instanceof Map||Tw(r),"identify"),represent:a(r=>{if(r instanceof Map)return r;let e=new Map,t=r;for(let n of Object.keys(t))e.set(n,t[n]);return e},"represent")});a(D5,"normalizeKey");jNe=vw("tag:yaml.org,2002:map",{create:a(()=>({}),"create"),identify:Tw,represent:a(r=>{let e=new Map;for(let t of Object.keys(r))e.set(t,r[t]);return e},"represent"),addPair:a((r,e,t)=>{let n=D5(e);return n===null?"nested arrays are not supported inside keys":(n==="__proto__"?Object.defineProperty(r,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[n]=t,"")},"addPair"),has:a((r,e)=>{let t=D5(e);return t!==null&&Object.prototype.hasOwnProperty.call(r,t)},"has"),keys:a(r=>Object.keys(r),"keys"),get:a((r,e)=>{let t=String(e);return Object.prototype.hasOwnProperty.call(r,t)?r[t]:null},"get")}),Mhe={maxLength:79,indent:1,linesBefore:3,linesAfter:2};a(Kx,"getLine");a(Yx,"padStart");a(jhe,"makeSnippet");a(L5,"formatError");Kc=class Z5 extends Error{static{a(this,"YAMLException")}reason;mark;constructor(e,t){super(),this.name="YAMLException",this.reason=e,this.mark=t,this.message=L5(this,!1),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toString(e){return`${this.name}: ${L5(this,e)}`}static throwAt(e,t,n,i=""){let s=0,o=0;for(let l=0;l<t;l++){let u=e.charCodeAt(l);u===10?(s++,o=l+1):u===13&&(s++,e.charCodeAt(l+1)===10&&l++,o=l+1)}let c={name:i,buffer:e,position:t,line:s,column:t-o};throw c.snippet=jhe(c),new Z5(n,c)}},_r={DOCUMENT:1,SEQUENCE:2,MAPPING:3,SCALAR:4,ALIAS:5,POP:6},Cn={PLAIN:1,SINGLE_QUOTED:2,DOUBLE_QUOTED:3,LITERAL_BLOCK:4,FOLDED_BLOCK:5},Yc={BLOCK:1,FLOW:2},Ki={CLIP:1,STRIP:2,KEEP:3},$he=-1;a(N5,"simpleEscapeSequence");e6=new Array(256),t6=new Array(256);for(let r=0;r<256;r++)e6[r]=N5(r)?1:0,t6[r]=N5(r);a(Uhe,"charFromCodepoint");a(Bhe,"fromHexCode$1");a(Vhe,"escapedHexLen$1");a(Sw,"skipFoldedBreaks");a(bO,"foldedBreaks");a(Ghe,"getPlainValue");a(qhe,"getSingleQuotedValue");a(Whe,"getDoubleQuotedValue");a(k5,"getBlockValue");a(zhe,"getScalarValue");Hhe=Object.assign(Object.create(null),{"!":"!","!!":"tag:yaml.org,2002:"});a(Xx,"tagPercentEncode");a(r6,"tagNameFull");a(n6,"tagNameShort");Wd=-1,Khe="tag:yaml.org,2002:merge",_O={filename:"",schema:vu,json:!1,maxTotalMergeKeys:1e4,maxAliases:-1};a(Yhe,"eventPosition$1");a(Wn,"throwError$1");a(i6,"finalizeCollection");a(Xhe,"constructScalar");a(M5,"collectionTagName");a(s6,"isMappingTag");a(j5,"mergeKeys");a(Qhe,"mergeSource");a(Jhe,"addMappingValue");a(Qx,"addValue");a(Jx,"storeAnchor");a(Zhe,"constructFromEvents");wt=-1,o6=Object.prototype.hasOwnProperty,Yd=1,nO=2,a6=3,ww=4,eme=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,tme=/[,\[\]{}]/,c6=/^(?:!|!!|![0-9A-Za-z-]+!)$/,iO=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,l6=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,rme=new RegExp(`^(?:${iO})*$`),nme=new RegExp(`^(?:${l6})+$`),ime=new RegExp(`^(?:!(?:${iO})*|${l6}(?:${iO})*)$`),SO={filename:"",maxDepth:100};a(sme,"addDocumentEvent");a(u6,"addSequenceEvent");a(sO,"addMappingEvent");a($5,"insertFlowPairMappingEvent");a(Qd,"addScalarEvent");a(ome,"addAliasEvent");a(zd,"addPopEvent");a(di,"addEmptyScalarEvent");a(U5,"emptyProperties");a(Ym,"snapshotState");a(Hd,"restoreState");a(Ue,"throwError");a(sn,"isEol");a(Su,"isWhiteSpace");a(Gs,"isWsOrEol");a(Va,"isWsOrEolOrEnd");a(wu,"isFlowIndicator");a(ame,"fromDecimalCode");a(cme,"fromHexCode");a(lme,"escapedHexLen");a(ume,"isSimpleEscape");a(Ew,"consumeLineBreak");a(pi,"skipSeparationSpace");a(bu,"testDocumentSeparator");a(B5,"skipUntilLineEnd");a(f6,"checkPrintable");a(fme,"readTagProperty");a(dme,"readAnchorProperty");a(pme,"readAlias");a(oO,"readFlowScalarBreak");a(hme,"readSingleQuotedScalar");a(mme,"readDoubleQuotedScalar");a(gme,"readBlockScalar");a(yme,"canStartPlainScalar");a(bme,"readPlainScalar");a(Hm,"skipFlowSeparationSpace");a(_me,"readFlowCollection");a(V5,"readBlockSequence");a(Zx,"readBlockMapping");a(_u,"parseNode");a(Sme,"readDirective");a(wme,"readDocument");a(Eme,"parseEvents");vme={...SO,..._O};a(Tme,"loadDocuments");a(Xc,"load");yw=class{static{a(this,"Style")}tagged=!1;flow=!1;singleQuoted=!1;doubleQuoted=!1;literal=!1;folded=!1},yu=Symbol("INVALID");a(Ame,"buildRepresentTypes");a(Ime,"matchTag");a(Km,"build");a(Rme,"jsToAst");Cme=Symbol("visit:break"),d6=Symbol("visit:skip");a(_w,"visitNode");a(xme,"visit");wO=65279,Ome=9,Eu=10,p6=13,Pme=32,Fme=33,h6=34,aO=35,Dme=37,Lme=38,m6=39,Nme=42,cO=44,EO=45,Qm=58,kme=61,Mme=62,g6=63,jme=64,lO=91,uO=93,$me=96,fO=123,Ume=124,dO=125,Hn={};Hn[0]="\\0";Hn[7]="\\a";Hn[8]="\\b";Hn[9]="\\t";Hn[10]="\\n";Hn[11]="\\v";Hn[12]="\\f";Hn[13]="\\r";Hn[27]="\\e";Hn[34]='\\"';Hn[92]="\\\\";Hn[133]="\\N";Hn[160]="\\_";Hn[8232]="\\L";Hn[8233]="\\P";vO={indent:2,seqNoIndent:!1,seqInlineFirst:!0,sortKeys:!1,lineWidth:80,flowBracketPadding:!1,flowSkipCommaSpace:!1,flowSkipColonSpace:!1,quoteFlowKeys:!1,quoteStyle:"single",forceQuotes:!1,tagBeforeAnchor:!1};a(Bme,"nodeTagShort");a(Vme,"createPresenterState");a(Gme,"encodeNonPrintable");a(G5,"indentString");a(pO,"generateNextLine");a(qme,"scalarLayout");a(Xd,"isWhitespace");a(Wme,"startsWithDocumentSeparator");a(Jm,"isPrintable");a(q5,"isNsCharOrWhitespace");a(hO,"isPlainSafe");a(zme,"isPlainSafeFirst");a(Hme,"isPlainSafeAtStart");a(Kme,"isPlainSafeLast");a(Kd,"codePointAt");a(y6,"needIndentIndicator");Zm=1,Xm=2,TO=3,AO=4,Hc=5;a(Yme,"chooseScalarStyle");a(Xme,"renderScalarStyle");a(Qme,"resolveScalarStyle");a(W5,"blockHeader");a(z5,"encodeFlowBreaks");a(H5,"dropEndingNewline");a(eg,"isMoreIndented");a(Jme,"foldBlockScalar");a(K5,"foldLine");a(Zme,"escapeString");a(ege,"writeFlowSequence");a(Y5,"writeBlockSequence");a(tge,"writeFlowMapping");a(bw,"sortKeyValue");a(b6,"sortMappingItems");a(rge,"writeBlockMapping");a(mO,"cannotBeCompact");a(Ga,"writeNode");a(nge,"rootStartsOwnLine");a(ige,"isOpenEnded");a(sge,"writeDocumentDirectives");a(oge,"present");age={...vO,schema:khe,skipInvalid:!1,noRefs:!1,flowLevel:-1,transform:a(()=>{},"transform")};a(Jd,"dump");$Ne=_r.DOCUMENT,UNe=_r.SEQUENCE,BNe=_r.MAPPING,VNe=_r.SCALAR,GNe=_r.ALIAS,qNe=_r.POP,WNe=Cn.PLAIN,zNe=Cn.SINGLE_QUOTED,HNe=Cn.DOUBLE_QUOTED,KNe=Cn.LITERAL_BLOCK,YNe=Cn.FOLDED_BLOCK,XNe=Yc.BLOCK,QNe=Yc.FLOW,JNe=Ki.CLIP,ZNe=Ki.STRIP,eke=Ki.KEEP});var IO,_6,cge,S6=Me(()=>{IO=a((r,e,t)=>{let n=r instanceof RegExp?_6(r,t):r,i=e instanceof RegExp?_6(e,t):e,s=n!==null&&i!=null&&cge(n,i,t);return s&&{start:s[0],end:s[1],pre:t.slice(0,s[0]),body:t.slice(s[0]+n.length,s[1]),post:t.slice(s[1]+i.length)}},"balanced"),_6=a((r,e)=>{let t=e.match(r);return t?t[0]:null},"maybeMatch"),cge=a((r,e,t)=>{let n,i,s,o,c,l=t.indexOf(r),u=t.indexOf(e,l+1),f=l;if(l>=0&&u>0){if(r===e)return[l,u];for(n=[],s=t.length;f>=0&&!c;){if(f===l)n.push(f),l=t.indexOf(r,f+1);else if(n.length===1){let d=n.pop();d!==void 0&&(c=[d,u])}else i=n.pop(),i!==void 0&&i<s&&(s=i,o=u),u=t.indexOf(e,f+1);f=l<u&&l>=0?l:u}n.length&&o!==void 0&&(c=[s,o])}return c},"range")});function RO(r){return isNaN(r)?r.charCodeAt(0):parseInt(r,10)}function wge(r){return r.replace(hge,w6).replace(mge,E6).replace(gge,xO).replace(yge,v6).replace(bge,T6)}function Ege(r){return r.replace(lge,"\\").replace(uge,"{").replace(fge,"}").replace(dge,",").replace(pge,".")}function A6(r){if(!r)return[""];let e=[],t=IO("{","}",r);if(!t)return r.split(",");let{pre:n,body:i,post:s}=t,o=n.split(",");o[o.length-1]+="{"+i+"}";let c=A6(s);return s.length&&(o[o.length-1]+=c.shift(),o.push.apply(o,c)),e.push.apply(e,o),e}function I6(r,e={}){if(!r)return[];let{max:t=_ge,maxLength:n=Sge}=e;return r.slice(0,2)==="{}"&&(r="\\{\\}"+r.slice(2)),CO(wge(r),t,n,!0).map(Ege)}function vge(r){return"{"+r+"}"}function Tge(r){return/^-?0\d/.test(r)}function Age(r,e){return r<=e}function Ige(r,e){return r>=e}function ng(r,e,t,n,i,s){let o=[],c=0;for(let l=0;l<r.length;l++)for(let u=0;u<t.length;u++){if(o.length>=n)return o;let f=r[l]+e+t[u];if(!(s&&!f)){if(c+f.length>i)return o;o.push(f),c+=f.length}}return o}function Rge(r,e,t,n){let i=r.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let o=RO(i[0]),c=RO(i[1]),l=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(RO(i[2])),1):1,f=Age;c<o&&(u*=-1,f=Ige);let p=i.some(Tge),h=0;for(let g=o;f(g,c)&&s.length<t;g+=u){let m;if(e)m=String.fromCharCode(g),m==="\\"&&(m="");else if(m=String(g),p){let b=l-m.length;if(b>0){let _=new Array(b+1).join("0");g<0?m="-"+_+m.slice(1):m=_+m}}if(h+m.length>n)break;s.push(m),h+=m.length}return s}function CO(r,e,t,n){let i=[""],s=!1,o=!0;for(;;){let c=IO("{","}",r);if(!c)return ng(i,r,[""],e,t,s);let l=c.pre;if(/\$$/.test(l)){if(i=ng(i,l+"{"+c.body+"}",[""],e,t,s&&!c.post.length),o=!1,!c.post.length)break;r=c.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(c.body),f=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(c.body),d=u||f,p=c.body.indexOf(",")>=0;if(!d&&!p){if(c.post.match(/,(?!,).*\}/)){r=c.pre+"{"+c.body+xO+c.post,n=!0;continue}return ng(i,l+"{"+c.body+"}"+c.post,[""],e,t,s)}o&&(s=n&&!d,o=!1);let h;if(d)h=Rge(c.body,f,e,t);else{let g=A6(c.body);if(g.length===1&&g[0]!==void 0&&(g=CO(g[0],e,t,!1).map(vge),g.length===1)){if(i=ng(i,l+g[0],[""],e,t,s&&!c.post.length),!c.post.length)break;r=c.post;continue}let m=s&&!c.post.length&&!l;for(let _=0;m&&_<i.length;_++)i[_]&&(m=!1);h=[];let b=0;e:for(let _=0;_<g.length;_++){let S=CO(g[_],e,t,!1);for(let A=0;A<S.length;A++){let w=S[A];if(!(m&&!w)){if(h.length>=e||b+w.length>t)break e;h.push(w),b+=w.length}}}}if(i=ng(i,l,h,e,t,s&&!c.post.length),!c.post.length)break;r=c.post}return i}var w6,E6,xO,v6,T6,lge,uge,fge,dge,pge,hge,mge,gge,yge,bge,_ge,Sge,R6=Me(()=>{S6();w6="\0SLASH"+Math.random()+"\0",E6="\0OPEN"+Math.random()+"\0",xO="\0CLOSE"+Math.random()+"\0",v6="\0COMMA"+Math.random()+"\0",T6="\0PERIOD"+Math.random()+"\0",lge=new RegExp(w6,"g"),uge=new RegExp(E6,"g"),fge=new RegExp(xO,"g"),dge=new RegExp(v6,"g"),pge=new RegExp(T6,"g"),hge=/\\\\/g,mge=/\\{/g,gge=/\\}/g,yge=/\\,/g,bge=/\\\./g,_ge=1e5,Sge=4e6;a(RO,"numeric");a(wge,"escapeBraces");a(Ege,"unescapeBraces");a(A6,"parseCommaParts");a(I6,"expand");a(vge,"embrace");a(Tge,"isPadded");a(Age,"lte");a(Ige,"gte");a(ng,"combine");a(Rge,"expandSequence");a(CO,"expand_")});var ig,C6=Me(()=>{ig=a(r=>{if(typeof r!="string")throw new TypeError("invalid pattern");if(r.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern")});var Cge,sg,xge,x6,O6,P6=Me(()=>{Cge={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},sg=a(r=>r.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),xge=a(r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),x6=a(r=>r.join(""),"rangesToString"),O6=a((r,e)=>{let t=e;if(r.charAt(t)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=t+1,o=!1,c=!1,l=!1,u=!1,f=t,d="";e:for(;s<r.length;){let m=r.charAt(s);if((m==="!"||m==="^")&&s===t+1){u=!0,s++;continue}if(m==="]"&&o&&!l){f=s+1;break}if(o=!0,m==="\\"&&!l){l=!0,s++;continue}if(m==="["&&!l){for(let[b,[_,S,A]]of Object.entries(Cge))if(r.startsWith(b,s)){if(d)return["$.",!1,r.length-t,!0];s+=b.length,A?i.push(_):n.push(_),c=c||S;continue e}}if(l=!1,d){m>d?n.push(sg(d)+"-"+sg(m)):m===d&&n.push(sg(m)),d="",s++;continue}if(r.startsWith("-]",s+1)){n.push(sg(m+"-")),s+=2;continue}if(r.startsWith("-",s+1)){d=m,s+=2;continue}n.push(sg(m)),s++}if(f<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,r.length-t,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let m=n[0].length===2?n[0].slice(-1):n[0];return[xge(m),!1,f-t,!1]}let p="["+(u?"^":"")+x6(n)+"]",h="["+(u?"":"^")+x6(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,c,f-t,!0]},"parseClass")});var qs,Rw=Me(()=>{qs=a((r,{windowsPathsNoEscape:e=!1,magicalBraces:t=!0}={})=>t?e?r.replace(/\[([^/\\])\]/g,"$1"):r.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?r.replace(/\[([^/\\{}])\]/g,"$1"):r.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),"unescape")});var ji,Oge,OO,F6,Pge,Fge,Dge,D6,Lge,Cw,Nge,kge,Mge,jge,PO,L6,N6,$ge,Tu,FO=Me(()=>{P6();Rw();Oge=new Set(["!","?","+","*","@"]),OO=a(r=>Oge.has(r),"isExtglobType"),F6=a(r=>OO(r.type),"isExtglobAST"),Pge=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Fge=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Dge=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),D6=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Lge="(?!(?:^|/)\\.\\.?(?:$|/))",Cw="(?!\\.)",Nge=new Set(["[","."]),kge=new Set(["..","."]),Mge=new Set("().*{}+?[]^$\\!"),jge=a(r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),PO="[^/]",L6=PO+"*?",N6=PO+"+?",$ge=0,Tu=class{static{a(this,"AST")}type;#t;#r;#n=!1;#e=[];#i;#a;#p;#u=!1;#c;#f;#l=!1;id=++$ge;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#t.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#e.length,parts:this.#e}}constructor(e,t,n={}){this.type=e,e&&(this.#r=!0),this.#i=t,this.#t=this.#i?this.#i.#t:this,this.#c=this.#t===this?n:this.#t.#c,this.#p=this.#t===this?[]:this.#t.#p,e==="!"&&!this.#t.#u&&this.#p.push(this),this.#a=this.#i?this.#i.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let e of this.#e)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#f=this.#e.map(e=>String(e)).join("")}#d(){if(this!==this.#t)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let e;for(;e=this.#p.pop();){if(e.type!=="!")continue;let t=e,n=t.#i;for(;n;){for(let i=t.#a+1;!n.type&&i<n.#e.length;i++)for(let s of e.#e){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#e[i])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof ji&&t.#i===this))throw new Error("invalid part: "+t);this.#e.push(t)}}toJSON(){let e=this.type===null?this.#e.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#e.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#u&&this.#i?.type==="!")&&e.push({}),e}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#e[t];if(!(n instanceof ji&&n.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#e.length:0;return this.#a===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new ji(this.type,e);for(let n of this.#e)t.copyIn(n);return t}static#o(e,t,n,i,s){let o=i.maxExtglobRecursion??2,c=!1,l=!1,u=-1,f=!1;if(t.type===null){let m=n,b="";for(;m<e.length;){let _=e.charAt(m++);if(c||_==="\\"){c=!c,b+=_;continue}if(l){m===u+1?(_==="^"||_==="!")&&(f=!0):_==="]"&&!(m===u+2&&f)&&(l=!1),b+=_;continue}else if(_==="["){l=!0,u=m,f=!1,b+=_;continue}if(!i.noext&&OO(_)&&e.charAt(m)==="("&&s<=o){t.push(b),b="";let A=new ji(_,t);m=ji.#o(e,A,m,i,s+1),t.push(A);continue}b+=_}return t.push(b),m}let d=n+1,p=new ji(null,t),h=[],g="";for(;d<e.length;){let m=e.charAt(d++);if(c||m==="\\"){c=!c,g+=m;continue}if(l){d===u+1?(m==="^"||m==="!")&&(f=!0):m==="]"&&!(d===u+2&&f)&&(l=!1),g+=m;continue}else if(m==="["){l=!0,u=d,f=!1,g+=m;continue}if(!i.noext&&OO(m)&&e.charAt(d)==="("&&(s<=o||t&&t.#_(m))){let _=t&&t.#_(m)?0:1;p.push(g),g="";let S=new ji(m,p);p.push(S),d=ji.#o(e,S,d,i,s+_);continue}if(m==="|"){p.push(g),g="",h.push(p),p=new ji(null,t);continue}if(m===")")return g===""&&t.#e.length===0&&(t.#l=!0),p.push(g),g="",t.push(...h,p),d;g+=m}return t.type=null,t.#r=void 0,t.#e=[e.substring(n-1)],d}#g(e){return this.#E(e,Fge)}#E(e,t=Pge){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null)return!1;let n=e.#e[0];return!n||typeof n!="object"||n.type===null?!1:this.#_(n.type,t)}#_(e,t=Dge){return!!t.get(this.type)?.includes(e)}#S(e,t){let n=e.#e[0],i=new ji(null,n,this.options);i.#e.push(""),n.push(i),this.#A(e,t)}#A(e,t){let n=e.#e[0];this.#e.splice(t,1,...n.#e);for(let i of n.#e)typeof i=="object"&&(i.#i=this);this.#f=void 0}#y(e){return!!D6.get(this.type)?.has(e)}#v(e){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null||this.#e.length!==1)return!1;let t=e.#e[0];return!t||typeof t!="object"||t.type===null?!1:this.#y(t.type)}#T(e){let t=D6.get(this.type),n=e.#e[0],i=t?.get(n.type);if(!i)return!1;this.#e=n.#e;for(let s of this.#e)typeof s=="object"&&(s.#i=this);this.type=i,this.#f=void 0,this.#l=!1}static fromGlob(e,t={}){let n=new ji(null,void 0,t);return ji.#o(e,n,0,t,0),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let e=this.toString(),[t,n,i,s]=this.toRegExpSource();if(!(i||this.#r||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let c=(this.#c.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,c),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#t===this&&(this.#m(),this.#d()),!F6(this)){let l=this.isStart()&&this.isEnd()&&!this.#e.some(h=>typeof h!="string"),u=this.#e.map(h=>{let[g,m,b,_]=typeof h=="string"?ji.#w(h,this.#r,l):h.toRegExpSource(e);return this.#r=this.#r||b,this.#n=this.#n||_,g}).join(""),f="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&kge.has(this.#e[0]))){let g=Nge,m=t&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),b=!t&&!e&&g.has(u.charAt(0));f=m?Lge:b?Cw:""}let d="";return this.isEnd()&&this.#t.#u&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,qs(u),this.#r=!!this.#r,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#b(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString(),u=this;return u.#e=[l],u.type=null,u.#r=void 0,[l,qs(this.toString()),!1,!1]}let o=!n||e||t||!Cw?"":this.#b(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let c="";if(this.type==="!"&&this.#l)c=(this.isStart()&&!t?Cw:"")+N6;else{let l=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Cw:"")+L6+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;c=i+s+l}return[c,qs(s),this.#r=!!this.#r,this.#n]}#m(){if(F6(this)){let e=0,t=!1;do{t=!0;for(let n=0;n<this.#e.length;n++){let i=this.#e[n];typeof i=="object"&&(i.#m(),this.#E(i)?(t=!1,this.#A(i,n)):this.#g(i)?(t=!1,this.#S(i,n)):this.#v(i)&&(t=!1,this.#T(i)))}}while(!t&&++e<10)}else for(let e of this.#e)typeof e=="object"&&e.#m();this.#f=void 0}#b(e){return this.#e.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=t.toRegExpSource(e);return this.#n=this.#n||o,n}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#w(e,t,n=!1){let i=!1,s="",o=!1,c=!1;for(let l=0;l<e.length;l++){let u=e.charAt(l);if(i){i=!1,s+=(Mge.has(u)?"\\":"")+u;continue}if(u==="*"){if(c)continue;c=!0,s+=n&&/^[*]+$/.test(e)?N6:L6,t=!0;continue}else c=!1;if(u==="\\"){l===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,p,h]=O6(e,l);if(p){s+=f,o=o||d,l+=p-1,t=t||h;continue}}if(u==="?"){s+=PO,t=!0;continue}s+=jge(u)}return[s,qs(e),!!t,o]}};ji=Tu});var Zd,DO=Me(()=>{Zd=a((r,{windowsPathsNoEscape:e=!1,magicalBraces:t=!1}={})=>t?e?r.replace(/[?*()[\]{}]/g,"[$&]"):r.replace(/[?*()[\]\\{}]/g,"\\$&"):e?r.replace(/[?*()[\]]/g,"[$&]"):r.replace(/[?*()[\]\\]/g,"\\$&"),"escape")});var hi,Uge,Bge,Vge,Gge,qge,Wge,zge,Hge,Kge,Yge,Xge,Qge,Jge,Zge,eye,tye,rye,nye,j6,$6,U6,k6,iye,Ir,sye,oye,aye,cye,lye,fs,uye,B6,fye,dye,M6,pye,Yi,Qc=Me(()=>{R6();C6();FO();DO();Rw();FO();DO();Rw();hi=a((r,e,t={})=>(ig(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Yi(e,t).match(r)),"minimatch"),Uge=/^\*+([^+@!?*[(]*)$/,Bge=a(r=>e=>!e.startsWith(".")&&e.endsWith(r),"starDotExtTest"),Vge=a(r=>e=>e.endsWith(r),"starDotExtTestDot"),Gge=a(r=>(r=r.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(r)),"starDotExtTestNocase"),qge=a(r=>(r=r.toLowerCase(),e=>e.toLowerCase().endsWith(r)),"starDotExtTestNocaseDot"),Wge=/^\*+\.\*+$/,zge=a(r=>!r.startsWith(".")&&r.includes("."),"starDotStarTest"),Hge=a(r=>r!=="."&&r!==".."&&r.includes("."),"starDotStarTestDot"),Kge=/^\.\*+$/,Yge=a(r=>r!=="."&&r!==".."&&r.startsWith("."),"dotStarTest"),Xge=/^\*+$/,Qge=a(r=>r.length!==0&&!r.startsWith("."),"starTest"),Jge=a(r=>r.length!==0&&r!=="."&&r!=="..","starTestDot"),Zge=/^\?+([^+@!?*[(]*)?$/,eye=a(([r,e=""])=>{let t=j6([r]);return e?(e=e.toLowerCase(),n=>t(n)&&n.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),tye=a(([r,e=""])=>{let t=$6([r]);return e?(e=e.toLowerCase(),n=>t(n)&&n.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),rye=a(([r,e=""])=>{let t=$6([r]);return e?n=>t(n)&&n.endsWith(e):t},"qmarksTestDot"),nye=a(([r,e=""])=>{let t=j6([r]);return e?n=>t(n)&&n.endsWith(e):t},"qmarksTest"),j6=a(([r])=>{let e=r.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),$6=a(([r])=>{let e=r.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),U6=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",k6={win32:{sep:"\\"},posix:{sep:"/"}},iye=U6==="win32"?k6.win32.sep:k6.posix.sep;hi.sep=iye;Ir=Symbol("globstar **");hi.GLOBSTAR=Ir;sye="[^/]",oye=sye+"*?",aye="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",cye="(?:(?!(?:\\/|^)\\.).)*?",lye=a((r,e={})=>t=>hi(t,r,e),"filter");hi.filter=lye;fs=a((r,e={})=>Object.assign({},r,e),"ext"),uye=a(r=>{if(!r||typeof r!="object"||!Object.keys(r).length)return hi;let e=hi;return Object.assign(a((n,i,s={})=>e(n,i,fs(r,s)),"m"),{Minimatch:class extends e.Minimatch{static{a(this,"Minimatch")}constructor(i,s={}){super(i,fs(r,s))}static defaults(i){return e.defaults(fs(r,i)).Minimatch}},AST:class extends e.AST{static{a(this,"AST")}constructor(i,s,o={}){super(i,s,fs(r,o))}static fromGlob(i,s={}){return e.AST.fromGlob(i,fs(r,s))}},unescape:a((n,i={})=>e.unescape(n,fs(r,i)),"unescape"),escape:a((n,i={})=>e.escape(n,fs(r,i)),"escape"),filter:a((n,i={})=>e.filter(n,fs(r,i)),"filter"),defaults:a(n=>e.defaults(fs(r,n)),"defaults"),makeRe:a((n,i={})=>e.makeRe(n,fs(r,i)),"makeRe"),braceExpand:a((n,i={})=>e.braceExpand(n,fs(r,i)),"braceExpand"),match:a((n,i,s={})=>e.match(n,i,fs(r,s)),"match"),sep:e.sep,GLOBSTAR:Ir})},"defaults");hi.defaults=uye;B6=a((r,e={})=>(ig(r),e.nobrace||!/\{(?:(?!\{).)*\}/.test(r)?[r]:I6(r,{max:e.braceExpandMax})),"braceExpand");hi.braceExpand=B6;fye=a((r,e={})=>new Yi(r,e).makeRe(),"makeRe");hi.makeRe=fye;dye=a((r,e,t={})=>{let n=new Yi(e,t);return r=r.filter(i=>n.match(i)),n.options.nonull&&!r.length&&r.push(e),r},"match");hi.match=dye;M6=/[?*]|[+@!]\(.*?\)|\[|\]/,pye=a(r=>r.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Yi=class{static{a(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){ig(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||U6,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!M6.test(s[2]))&&!M6.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(l)return[...s.slice(0,4),...s.slice(4).map(f=>this.parse(f))];if(u)return[s[0],...s.slice(1).map(f=>this.parse(f))]}return s.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n of e)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):t>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let n=-1;for(;(n=t.indexOf("**",n+1))!==-1;){let i=n;for(;t[i+1]==="**";)i++;i!==n&&t.splice(n,i-n)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(t=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let c=n[i+1],l=n[i+2],u=n[i+3];if(c!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;t=!0,n.splice(i,1);let f=n.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let c=n[o];o===1&&c===""&&n[0]===""||(c==="."||c==="")&&(t=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(t=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let l=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...l),n.length===0&&n.push(""),s-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let i=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(i){e[t]=[],e[n]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,n=!1){let i=0,s=0,o=[],c="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])o.push(c==="b"?t[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&t[s]===e[i+1])o.push(e[i]),i++;else if(n&&t[s]==="**"&&e[i]===t[s+1])o.push(t[s]),s++;else if(e[i]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(c==="b")return!1;c="a",o.push(e[i]),i++,s++}else if(t[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(c==="a")return!1;c="b",o.push(t[s]),i++,s++}else return!1;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let i=0,s=0;if(this.isWindows){let c=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),l=!c&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),u=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),f=!u&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),d=l?3:c?0:void 0,p=f?3:u?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[h,g]=[e[d],t[p]];h.toLowerCase()===g.toLowerCase()&&(t[p]=h,s=p,i=d)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Ir)?this.#t(e,t,n,i,s):this.#n(e,t,n,i,s)}#t(e,t,n,i,s){let o=t.indexOf(Ir,s),c=t.lastIndexOf(Ir),[l,u,f]=n?[t.slice(s,o),t.slice(o+1),[]]:[t.slice(s,o),t.slice(o+1,c),t.slice(c+1)];if(l.length){let S=e.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,s+=l.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let S=e.length-f.length;if(this.#n(e,f,n,S,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(S--,!this.#n(e,f,n,S,0)))return!1;d=f.length+1}}if(!u.length){let S=!!d;for(let A=i;A<e.length-d;A++){let w=String(e[A]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let p=[[[],0]],h=p[0],g=0,m=[0];for(let S of u)S===Ir?(m.push(g),h=[[],0],p.push(h)):(h[0].push(S),g++);let b=p.length-1,_=e.length-d;for(let S of p)S[1]=_-(m[b--]+S[0].length);return!!this.#r(e,p,i,0,n,0,!!d)}#r(e,t,n,i,s,o,c){let l=t[i];if(!l){for(let d=n;d<e.length;d++){c=!0;let p=e[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return c}let[u,f]=l;for(;n<=f;){if(this.#n(e.slice(0,n+u.length),u,s,n,0)&&o<this.maxGlobstarRecursion){let h=this.#r(e,t,n+u.length,i+1,s,o+1,c);if(h!==!1)return h}let p=e[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return s||null}#n(e,t,n,i,s){let o,c,l,u;for(o=i,c=s,u=e.length,l=t.length;o<u&&c<l;o++,c++){this.debug("matchOne loop");let f=t[c],d=e[o];if(this.debug(t,f,d),f===!1||f===Ir)return!1;let p;if(typeof f=="string"?(p=d===f,this.debug("string match",f,d,p)):(p=f.test(d),this.debug("pattern match",f,d,p)),!p)return!1}if(o===u&&c===l)return!0;if(o===u)return n;if(c===l)return o===u-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return B6(this.pattern,this.options)}parse(e){ig(e);let t=this.options;if(e==="**")return Ir;if(e==="")return"";let n,i=null;(n=e.match(Xge))?i=t.dot?Jge:Qge:(n=e.match(Uge))?i=(t.nocase?t.dot?qge:Gge:t.dot?Vge:Bge)(n[1]):(n=e.match(Zge))?i=(t.nocase?t.dot?tye:eye:t.dot?rye:nye)(n):(n=e.match(Wge))?i=t.dot?Hge:zge:(n=e.match(Kge))&&(i=Yge);let s=Tu.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?oye:t.dot?aye:cye,i=new Set(t.nocase?["i"]:[]),s=e.map(l=>{let u=l.map(d=>{if(d instanceof RegExp)for(let p of d.flags.split(""))i.add(p);return typeof d=="string"?pye(d):d===Ir?Ir:d._src});u.forEach((d,p)=>{let h=u[p+1],g=u[p-1];d!==Ir||g===Ir||(g===void 0?h!==void 0&&h!==Ir?u[p+1]="(?:\\/|"+n+"\\/)?"+h:u[p]=n:h===void 0?u[p-1]=g+"(?:\\/|\\/"+n+")?":h!==Ir&&(u[p-1]=g+"(?:\\/|\\/"+n+"\\/)"+h,u[p+1]=Ir))});let f=u.filter(d=>d!==Ir);if(this.partial&&f.length>=1){let d=[];for(let p=1;p<=f.length;p++)d.push(f.slice(0,p).join("/"));return"(?:"+d.join("|")+")"}return f.join("/")}).join("|"),[o,c]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+c+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+c+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let c=i.length-2;!o&&c>=0;c--)o=i[c];for(let c of s){let l=i;if(n.matchBase&&c.length===1&&(l=[o]),this.matchOne(l,c,t))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return hi.defaults(e).Minimatch}};hi.AST=Tu;hi.Minimatch=Yi;hi.escape=Zd;hi.unescape=qs});var Ow,xn,og,hye,LO,G6,V6,mye,gye,Jc,q6,xw,yye,cg,z6=Me(()=>{Ow=require("node:diagnostics_channel"),xn=(0,Ow.channel)("lru-cache:metrics"),og=(0,Ow.tracingChannel)("lru-cache"),hye=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,LO=a(()=>xn.hasSubscribers||og.hasSubscribers,"R"),G6=new Set,V6=typeof process=="object"&&process?process:{},mye=a((r,e,t,n)=>{typeof V6.emitWarning=="function"?V6.emitWarning(r,e,t,n):console.error(`[${t}] ${e}: ${r}`)},"k"),gye=a(r=>!G6.has(r),"H"),Jc=a(r=>!!r&&r===Math.floor(r)&&r>0&&isFinite(r),"T"),q6=a(r=>Jc(r)?r<=Math.pow(2,8)?Uint8Array:r<=Math.pow(2,16)?Uint16Array:r<=Math.pow(2,32)?Uint32Array:r<=Number.MAX_SAFE_INTEGER?xw:null:null,"j"),xw=class extends Array{static{a(this,"O")}constructor(r){super(r),this.fill(0)}},yye=class ag{static{a(this,"d")}heap;length;static#t=!1;static create(e){let t=q6(e);if(!t)return[];ag.#t=!0;let n=new ag(e,t);return ag.#t=!1,n}constructor(e,t){if(!ag.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},cg=class W6{static{a(this,"d")}#t;#r;#n;#e;#i;#a;#p;#u;get perf(){return this.#u}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;backgroundFetchSize;#c;#f;#l;#d;#o;#g;#E;#_;#S;#A;#y;#v;#T;#m;#b;#w;#R;#s;#x;static unsafeExposeInternals(e){return{starts:e.#T,ttls:e.#m,autopurgeTimers:e.#b,sizes:e.#v,keyMap:e.#l,keyList:e.#d,valList:e.#o,next:e.#g,prev:e.#E,get head(){return e.#_},get tail(){return e.#S},free:e.#A,isBackgroundFetch:a(t=>e.#h(t),"isBackgroundFetch"),backgroundFetch:a((t,n,i,s)=>e.#M(t,n,i,s),"backgroundFetch"),moveToTail:a(t=>e.#K(t),"moveToTail"),indexes:a(t=>e.#P(t),"indexes"),rindexes:a(t=>e.#F(t),"rindexes"),isStale:a(t=>e.#I(t),"isStale")}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#f}get size(){return this.#c}get fetchMethod(){return this.#a}get memoMethod(){return this.#p}get dispose(){return this.#n}get onInsert(){return this.#e}get disposeAfter(){return this.#i}constructor(e){let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:l,dispose:u,onInsert:f,disposeAfter:d,noDisposeOnSet:p,noUpdateTTL:h,maxSize:g=0,maxEntrySize:m=0,sizeCalculation:b,fetchMethod:_,memoMethod:S,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:R,ignoreFetchAbort:x,backgroundFetchSize:P=1,perf:N}=e;if(this.backgroundFetchSize=P,N!==void 0&&typeof N?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#u=N??hye,t!==0&&!Jc(t))throw new TypeError("max option must be a nonnegative integer");let $=t?q6(t):Array;if(!$)throw new Error("invalid max value: "+t);if(this.#t=t,this.#r=g,this.maxEntrySize=m||this.#r,this.sizeCalculation=b,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#p=S,_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#a=_,this.#R=!!_,this.#l=new Map,this.#d=Array.from({length:t}).fill(void 0),this.#o=Array.from({length:t}).fill(void 0),this.#g=new $(t),this.#E=new $(t),this.#_=0,this.#S=0,this.#A=yye.create(t),this.#c=0,this.#f=0,typeof u=="function"&&(this.#n=u),typeof f=="function"&&(this.#e=f),typeof d=="function"?(this.#i=d,this.#y=[]):(this.#i=void 0,this.#y=void 0),this.#w=!!this.#n,this.#x=!!this.#e,this.#s=!!this.#i,this.noDisposeOnSet=!!p,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!x,this.maxEntrySize!==0){if(this.#r!==0&&!Jc(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!Jc(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#q()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=Jc(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!Jc(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#O()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let k="LRU_CACHE_UNBOUNDED";gye(k)&&(G6.add(k),mye("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",k,W6))}}getRemainingTTL(e){return this.#l.has(e)?1/0:0}#O(){let e=new xw(this.#t),t=new xw(this.#t);this.#m=e,this.#T=t;let n=this.ttlAutopurge?Array.from({length:this.#t}):void 0;this.#b=n,this.#$=(l,u,f=this.#u.now())=>{t[l]=u!==0?f:0,e[l]=u,i(l,u)},this.#C=l=>{t[l]=e[l]!==0?this.#u.now():0,i(l,e[l])};let i=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let f=setTimeout(()=>{this.#I(l)?(this.#j(this.#d[l],"expire"),n[l]=void 0):i(l,c(l))},u+1);f.unref&&f.unref(),n[l]=f}}:()=>{};this.#D=(l,u)=>{if(e[u]){let f=e[u],d=t[u];if(!f||!d)return;l.ttl=f,l.start=d,l.now=s||o();let p=l.now-d;l.remainingTTL=f-p}};let s=0,o=a(()=>{let l=this.#u.now();if(this.ttlResolution>0){s=l;let u=setTimeout(()=>s=0,this.ttlResolution);u.unref&&u.unref()}return l},"o");this.getRemainingTTL=l=>{let u=this.#l.get(l);return u===void 0?0:c(u)};let c=a(l=>{let u=e[l],f=t[l];if(!u||!f)return 1/0;let d=(s||o())-f;return u-d},"l");this.#I=l=>{let u=t[l],f=e[l];return!!f&&!!u&&(s||o())-u>f}}#C=a(()=>{},"#R");#D=a(()=>{},"#v");#$=a(()=>{},"#H");#I=a(()=>!1,"#p");#q(){let e=new xw(this.#t);this.#f=0,this.#v=e,this.#N=t=>{this.#f-=e[t],e[t]=0},this.#U=(t,n,i,s)=>{if(!Jc(i)){if(this.#h(n))return this.backgroundFetchSize;if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,t),!Jc(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.")}return i},this.#L=(t,n,i)=>{if(e[t]=n,this.#r){let s=this.#r-e[t];for(;this.#f>s;)this.#G(!0)}this.#f+=e[t],i&&(i.entrySize=n,i.totalCalculatedSize=this.#f)}}#N=a(e=>{},"#x");#L=a((e,t,n)=>{},"#j");#U=a((e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#N");*#P({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#S;this.#B(t)&&((e||!this.#I(t))&&(yield t),t!==this.#_);)t=this.#E[t]}*#F({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#_;this.#B(t)&&((e||!this.#I(t))&&(yield t),t!==this.#S);)t=this.#g[t]}#B(e){return e!==void 0&&this.#l.get(this.#d[e])===e}*entries(){for(let e of this.#P())this.#o[e]!==void 0&&this.#d[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#d[e],this.#o[e]])}*rentries(){for(let e of this.#F())this.#o[e]!==void 0&&this.#d[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#d[e],this.#o[e]])}*keys(){for(let e of this.#P()){let t=this.#d[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*rkeys(){for(let e of this.#F()){let t=this.#d[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*values(){for(let e of this.#P())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#F())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let n of this.#P()){let i=this.#o[n],s=this.#h(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#d[n],this))return this.#H(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#P()){let i=this.#o[n],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#F()){let i=this.#o[n],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#F({allowStale:!0}))this.#I(t)&&(this.#j(this.#d[t],"expire"),e=!0);return e}info(e){let t=this.#l.get(e);if(t===void 0)return;let n=this.#o[t],i=this.#h(n)?n.__staleWhileFetching:n;if(i===void 0)return;let s={value:i};if(this.#m&&this.#T){let o=this.#m[t],c=this.#T[t];if(o&&c){let l=o-(this.#u.now()-c);s.ttl=l,s.start=Date.now()}}return this.#v&&(s.size=this.#v[t]),s}dump(){let e=[];for(let t of this.#P({allowStale:!0})){let n=this.#d[t],i=this.#o[t],s=this.#h(i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;let o={value:s};if(this.#m&&this.#T){o.ttl=this.#m[t];let c=this.#u.now()-this.#T[t];o.start=Math.floor(Date.now()-c)}this.#v&&(o.size=this.#v[t]),e.unshift([n,o])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=this.#u.now()-i}this.#k(t,n.value,n)}}set(e,t,n={}){let{status:i=xn.hasSubscribers?{}:void 0}=n;n.status=i,i&&(i.op="set",i.key=e,t!==void 0&&(i.value=t),i.cache=this);let s=this.#k(e,t,n);return i&&xn.hasSubscribers&&xn.publish(i),s}#k(e,t,n,i){let{ttl:s=this.ttl,start:o,noDisposeOnSet:c=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,f=this.#h(t);if(t===void 0)return u&&(u.set="deleted"),this.delete(e),this;let{noUpdateTTL:d=this.noUpdateTTL}=n;u&&!f&&(u.value=t);let p=this.#U(e,t,n.size||0,l,u);if(this.maxEntrySize&&p>this.maxEntrySize)return this.#j(e,"set"),u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this;let h=this.#c===0?void 0:this.#l.get(e);if(h===void 0)h=this.#c===0?this.#S:this.#A.length!==0?this.#A.pop():this.#c===this.#t?this.#G(!1):this.#c,this.#d[h]=e,this.#o[h]=t,this.#l.set(e,h),this.#g[this.#S]=h,this.#E[h]=this.#S,this.#S=h,this.#c++,this.#L(h,p,u),u&&(u.set="add"),d=!1,this.#x&&!f&&this.#e?.(t,e,"add");else{this.#K(h);let g=this.#o[h];if(t!==g){if(!c)if(this.#h(g)){g!==i&&g.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=g;m!==void 0&&m!==t&&(this.#w&&this.#n?.(m,e,"set"),this.#s&&this.#y?.push([m,e,"set"]))}else this.#w&&this.#n?.(g,e,"set"),this.#s&&this.#y?.push([g,e,"set"]);if(this.#N(h),this.#L(h,p,u),this.#o[h]=t,!f){let m=g&&this.#h(g)?g.__staleWhileFetching:g,b=m===void 0?"add":t!==m?"replace":"update";u&&(u.set=b,m!==void 0&&(u.oldValue=m)),this.#x&&this.onInsert?.(t,e,b)}}else f||(u&&(u.set="update"),this.#x&&this.onInsert?.(t,e,"update"))}if(s!==0&&!this.#m&&this.#O(),this.#m&&(d||this.#$(h,s,o),u&&this.#D(u,h)),!c&&this.#s&&this.#y){let g=this.#y,m;for(;m=g?.shift();)this.#i?.(...m)}return this}pop(){try{for(;this.#c;){let e=this.#o[this.#_];if(this.#G(!0),this.#h(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#s&&this.#y){let e=this.#y,t;for(;t=e?.shift();)this.#i?.(...t)}}}#G(e){let t=this.#_,n=this.#d[t],i=this.#o[t],s=this.#h(i);s&&i.__abortController.abort(new Error("evicted"));let o=s?i.__staleWhileFetching:i;return(this.#w||this.#s)&&o!==void 0&&(this.#w&&this.#n?.(o,n,"evict"),this.#s&&this.#y?.push([o,n,"evict"])),this.#N(t),this.#b?.[t]&&(clearTimeout(this.#b[t]),this.#b[t]=void 0),e&&(this.#d[t]=void 0,this.#o[t]=void 0,this.#A.push(t)),this.#c===1?(this.#_=this.#S=0,this.#A.length=0):this.#_=this.#g[t],this.#l.delete(n),this.#c--,t}has(e,t={}){let{status:n=xn.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="has",n.key=e,n.cache=this);let i=this.#Y(e,t);return xn.hasSubscribers&&xn.publish(n),i}#Y(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,s=this.#l.get(e);if(s!==void 0){let o=this.#o[s];if(this.#h(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#I(s))i&&(i.has="stale",this.#D(i,s));else return n&&this.#C(s),i&&(i.has="hit",this.#D(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{status:n=LO()?{}:void 0}=t;n&&(n.op="peek",n.key=e,n.cache=this),t.status=n;let i=this.#W(e,t);return xn.hasSubscribers&&xn.publish(n),i}#W(e,t){let{status:n,allowStale:i=this.allowStale}=t,s=this.#l.get(e);if(s===void 0||!i&&this.#I(s)){n&&(n.peek=s===void 0?"miss":"stale");return}let o=this.#o[s],c=this.#h(o)?o.__staleWhileFetching:o;return n&&(c!==void 0?(n.peek="hit",n.value=c):n.peek="miss"),c}#M(e,t,n,i){let s=t===void 0?void 0:this.#o[t];if(this.#h(s))return s;let o=new AbortController,{signal:c}=n;c?.addEventListener("abort",()=>o.abort(c.reason),{signal:o.signal});let l={signal:o.signal,options:n,context:i},u=a((m,b=!1)=>{let{aborted:_}=o.signal,S=n.ignoreFetchAbort&&m!==void 0,A=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&m!==void 0);if(n.status&&(_&&!b?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,S&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),_&&!S&&!b)return d(o.signal.reason,A);let w=h,E=this.#o[t];return(E===h||E===void 0&&S&&b)&&(m===void 0?w.__staleWhileFetching!==void 0?this.#o[t]=w.__staleWhileFetching:this.#j(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.#k(e,m,l.options,w))),m},"r"),f=a(m=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=m),d(m,!1)),"c"),d=a((m,b)=>{let{aborted:_}=o.signal,S=_&&n.allowStaleOnFetchAbort,A=S||n.allowStaleOnFetchRejection,w=A||n.noDeleteOnFetchRejection,E=h;if(this.#o[t]===h&&(!w||!b&&E.__staleWhileFetching===void 0?this.#j(e,"fetch"):S||(this.#o[t]=E.__staleWhileFetching)),A)return n.status&&E.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),E.__staleWhileFetching;if(E.__returned===E)throw m},"m"),p=a((m,b)=>{let _=this.#a?.(e,s,l);o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(m(void 0),n.allowStaleOnFetchAbort&&(m=a(S=>u(S,!0),"f")))}),_&&_ instanceof Promise?_.then(S=>m(S===void 0?void 0:S),b):_!==void 0&&m(_)},"_");n.status&&(n.status.fetchDispatched=!0);let h=new Promise(p).then(u,f),g=Object.assign(h,{__abortController:o,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.#k(e,g,{...l.options,status:void 0}),t=this.#l.get(e)):this.#o[t]=g,g}#h(e){if(!this.#R)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController}fetch(e,t={}){let n=og.hasSubscribers,{status:i=LO()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#z(e,t);return i&&n&&(i.trace=!0,og.tracePromise(()=>s,i).catch(()=>{})),s}async#z(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:l=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:h=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:m,forceRefresh:b=!1,status:_,signal:S}=t;if(_&&(_.op="fetch",_.key=e,b&&(_.forceRefresh=!0),_.cache=this),!this.#R)return _&&(_.fetch="get"),this.#H(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:_});let A={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:o,noDisposeOnSet:c,size:l,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:g,ignoreFetchAbort:h,status:_,signal:S},w=this.#l.get(e);if(w===void 0){_&&(_.fetch="miss");let E=this.#M(e,w,A,m);return E.__returned=E}else{let E=this.#o[w];if(this.#h(E)){let N=n&&E.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",N&&(_.returnedStale=!0)),N?E.__staleWhileFetching:E.__returned=E}let R=this.#I(w);if(!b&&!R)return _&&(_.fetch="hit"),this.#K(w),i&&this.#C(w),_&&this.#D(_,w),E;let x=this.#M(e,w,A,m),P=x.__staleWhileFetching!==void 0&&n;return _&&(_.fetch=R?"stale":"refresh",P&&R&&(_.returnedStale=!0)),P?x.__staleWhileFetching:x.__returned=x}}forceFetch(e,t={}){let n=og.hasSubscribers,{status:i=LO()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let s=this.#V(e,t);return i&&n&&(i.trace=!0,og.tracePromise(()=>s,i).catch(()=>{})),s}async#V(e,t={}){let n=await this.#z(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let{status:n=xn.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="memo",n.key=e,t.context&&(n.context=t.context),n.cache=this);let i=this.#J(e,t);return n&&(n.value=i),xn.hasSubscribers&&xn.publish(n),i}#J(e,t={}){let n=this.#p;if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,status:s,forceRefresh:o,...c}=t;s&&o&&(s.forceRefresh=!0);let l=this.#H(e,c),u=o||l===void 0;if(s&&(s.memo=u?"miss":"hit",u||(s.value=l)),!u)return l;let f=n(e,l,{options:c,context:i});return s&&(s.value=f),this.#k(e,f,c),f}get(e,t={}){let{status:n=xn.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op="get",n.key=e,n.cache=this);let i=this.#H(e,t);return n&&(i!==void 0&&(n.value=i),xn.hasSubscribers&&xn.publish(n)),i}#H(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:o}=t,c=this.#l.get(e);if(c===void 0){o&&(o.get="miss");return}let l=this.#o[c],u=this.#h(l);return o&&this.#D(o,c),this.#I(c)?u?(o&&(o.get="stale-fetching"),n&&l.__staleWhileFetching!==void 0?(o&&(o.returnedStale=!0),l.__staleWhileFetching):void 0):(s||this.#j(e,"expire"),o&&(o.get="stale"),n?(o&&(o.returnedStale=!0),l):void 0):(o&&(o.get=u?"fetching":"hit"),this.#K(c),i&&this.#C(c),u?l.__staleWhileFetching:l)}#X(e,t){this.#E[t]=e,this.#g[e]=t}#K(e){e!==this.#S&&(e===this.#_?this.#_=this.#g[e]:this.#X(this.#E[e],this.#g[e]),this.#X(this.#S,e),this.#S=e)}delete(e){return this.#j(e,"delete")}#j(e,t){xn.hasSubscribers&&xn.publish({op:"delete",delete:t,key:e,cache:this});let n=!1;if(this.#c!==0){let i=this.#l.get(e);if(i!==void 0)if(this.#b?.[i]&&(clearTimeout(this.#b[i]),this.#b[i]=void 0),n=!0,this.#c===1)this.#Q(t);else{this.#N(i);let s=this.#o[i];if(this.#h(s)?s.__abortController.abort(new Error("deleted")):(this.#w||this.#s)&&(this.#w&&this.#n?.(s,e,t),this.#s&&this.#y?.push([s,e,t])),this.#l.delete(e),this.#d[i]=void 0,this.#o[i]=void 0,i===this.#S)this.#S=this.#E[i];else if(i===this.#_)this.#_=this.#g[i];else{let o=this.#E[i];this.#g[o]=this.#g[i];let c=this.#g[i];this.#E[c]=this.#E[i]}this.#c--,this.#A.push(i)}}if(this.#s&&this.#y?.length){let i=this.#y,s;for(;s=i?.shift();)this.#i?.(...s)}return n}clear(){return this.#Q("delete")}#Q(e){for(let t of this.#F({allowStale:!0})){let n=this.#o[t];if(this.#h(n))n.__abortController.abort(new Error("deleted"));else{let i=this.#d[t];this.#w&&this.#n?.(n,i,e),this.#s&&this.#y?.push([n,i,e])}}if(this.#l.clear(),this.#o.fill(void 0),this.#d.fill(void 0),this.#m&&this.#T){this.#m.fill(0),this.#T.fill(0);for(let t of this.#b??[])t!==void 0&&clearTimeout(t);this.#b?.fill(void 0)}if(this.#v&&this.#v.fill(0),this.#_=0,this.#S=0,this.#A.length=0,this.#f=0,this.#c=0,this.#s&&this.#y){let t=this.#y,n;for(;n=t?.shift();)this.#i?.(...n)}}}});var Mw,BO,Q6,H6,bye,_ye,Sye,qa,Wa,Zc,Pw,lg,Fw,K6,Dw,Y6,Ws,ep,on,ug,tp,an,mi,cn,NO,Lw,Kn,Rr,kO,MO,X6,jO,jo,$O,Nw,fg,Au,Xi,dg,wye,Eye,vye,Tye,kw,UO,Aye,Iye,el,VO=Me(()=>{Mw=require("node:events"),BO=Q(require("node:stream"),1),Q6=require("node:string_decoder"),H6=typeof process=="object"&&process?process:{stdout:null,stderr:null},bye=a(r=>!!r&&typeof r=="object"&&(r instanceof el||r instanceof BO.default||_ye(r)||Sye(r)),"isStream"),_ye=a(r=>!!r&&typeof r=="object"&&r instanceof Mw.EventEmitter&&typeof r.pipe=="function"&&r.pipe!==BO.default.Writable.prototype.pipe,"isReadable"),Sye=a(r=>!!r&&typeof r=="object"&&r instanceof Mw.EventEmitter&&typeof r.write=="function"&&typeof r.end=="function","isWritable"),qa=Symbol("EOF"),Wa=Symbol("maybeEmitEnd"),Zc=Symbol("emittedEnd"),Pw=Symbol("emittingEnd"),lg=Symbol("emittedError"),Fw=Symbol("closed"),K6=Symbol("read"),Dw=Symbol("flush"),Y6=Symbol("flushChunk"),Ws=Symbol("encoding"),ep=Symbol("decoder"),on=Symbol("flowing"),ug=Symbol("paused"),tp=Symbol("resume"),an=Symbol("buffer"),mi=Symbol("pipes"),cn=Symbol("bufferLength"),NO=Symbol("bufferPush"),Lw=Symbol("bufferShift"),Kn=Symbol("objectMode"),Rr=Symbol("destroyed"),kO=Symbol("error"),MO=Symbol("emitData"),X6=Symbol("emitEnd"),jO=Symbol("emitEnd2"),jo=Symbol("async"),$O=Symbol("abort"),Nw=Symbol("aborted"),fg=Symbol("signal"),Au=Symbol("dataListeners"),Xi=Symbol("discarded"),dg=a(r=>Promise.resolve().then(r),"defer"),wye=a(r=>r(),"nodefer"),Eye=a(r=>r==="end"||r==="finish"||r==="prefinish","isEndish"),vye=a(r=>r instanceof ArrayBuffer||!!r&&typeof r=="object"&&r.constructor&&r.constructor.name==="ArrayBuffer"&&r.byteLength>=0,"isArrayBufferLike"),Tye=a(r=>!Buffer.isBuffer(r)&&ArrayBuffer.isView(r),"isArrayBufferView"),kw=class{static{a(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[tp](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},UO=class extends kw{static{a(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},Aye=a(r=>!!r.objectMode,"isObjectModeOptions"),Iye=a(r=>!r.objectMode&&!!r.encoding&&r.encoding!=="buffer","isEncodingOptions"),el=class extends Mw.EventEmitter{static{a(this,"Minipass")}[on]=!1;[ug]=!1;[mi]=[];[an]=[];[Kn];[Ws];[jo];[ep];[qa]=!1;[Zc]=!1;[Pw]=!1;[Fw]=!1;[lg]=null;[cn]=0;[Rr]=!1;[fg];[Nw]=!1;[Au]=0;[Xi]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Aye(t)?(this[Kn]=!0,this[Ws]=null):Iye(t)?(this[Ws]=t.encoding,this[Kn]=!1):(this[Kn]=!1,this[Ws]=null),this[jo]=!!t.async,this[ep]=this[Ws]?new Q6.StringDecoder(this[Ws]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:a(()=>this[an],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:a(()=>this[mi],"get")});let{signal:n}=t;n&&(this[fg]=n,n.aborted?this[$O]():n.addEventListener("abort",()=>this[$O]()))}get bufferLength(){return this[cn]}get encoding(){return this[Ws]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Kn]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[jo]}set async(e){this[jo]=this[jo]||!!e}[$O](){this[Nw]=!0,this.emit("abort",this[fg]?.reason),this.destroy(this[fg]?.reason)}get aborted(){return this[Nw]}set aborted(e){}write(e,t,n){if(this[Nw])return!1;if(this[qa])throw new Error("write after end");if(this[Rr])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(n=t,t="utf8"),t||(t="utf8");let i=this[jo]?dg:wye;if(!this[Kn]&&!Buffer.isBuffer(e)){if(Tye(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(vye(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Kn]?(this[on]&&this[cn]!==0&&this[Dw](!0),this[on]?this.emit("data",e):this[NO](e),this[cn]!==0&&this.emit("readable"),n&&i(n),this[on]):e.length?(typeof e=="string"&&!(t===this[Ws]&&!this[ep]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Ws]&&(e=this[ep].write(e)),this[on]&&this[cn]!==0&&this[Dw](!0),this[on]?this.emit("data",e):this[NO](e),this[cn]!==0&&this.emit("readable"),n&&i(n),this[on]):(this[cn]!==0&&this.emit("readable"),n&&i(n),this[on])}read(e){if(this[Rr])return null;if(this[Xi]=!1,this[cn]===0||e===0||e&&e>this[cn])return this[Wa](),null;this[Kn]&&(e=null),this[an].length>1&&!this[Kn]&&(this[an]=[this[Ws]?this[an].join(""):Buffer.concat(this[an],this[cn])]);let t=this[K6](e||null,this[an][0]);return this[Wa](),t}[K6](e,t){if(this[Kn])this[Lw]();else{let n=t;e===n.length||e===null?this[Lw]():typeof n=="string"?(this[an][0]=n.slice(e),t=n.slice(0,e),this[cn]-=e):(this[an][0]=n.subarray(e),t=n.subarray(0,e),this[cn]-=e)}return this.emit("data",t),!this[an].length&&!this[qa]&&this.emit("drain"),t}end(e,t,n){return typeof e=="function"&&(n=e,e=void 0),typeof t=="function"&&(n=t,t="utf8"),e!==void 0&&this.write(e,t),n&&this.once("end",n),this[qa]=!0,this.writable=!1,(this[on]||!this[ug])&&this[Wa](),this}[tp](){this[Rr]||(!this[Au]&&!this[mi].length&&(this[Xi]=!0),this[ug]=!1,this[on]=!0,this.emit("resume"),this[an].length?this[Dw]():this[qa]?this[Wa]():this.emit("drain"))}resume(){return this[tp]()}pause(){this[on]=!1,this[ug]=!0,this[Xi]=!1}get destroyed(){return this[Rr]}get flowing(){return this[on]}get paused(){return this[ug]}[NO](e){this[Kn]?this[cn]+=1:this[cn]+=e.length,this[an].push(e)}[Lw](){return this[Kn]?this[cn]-=1:this[cn]-=this[an][0].length,this[an].shift()}[Dw](e=!1){do;while(this[Y6](this[Lw]())&&this[an].length);!e&&!this[an].length&&!this[qa]&&this.emit("drain")}[Y6](e){return this.emit("data",e),this[on]}pipe(e,t){if(this[Rr])return e;this[Xi]=!1;let n=this[Zc];return t=t||{},e===H6.stdout||e===H6.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[mi].push(t.proxyErrors?new UO(this,e,t):new kw(this,e,t)),this[jo]?dg(()=>this[tp]()):this[tp]()),e}unpipe(e){let t=this[mi].find(n=>n.dest===e);t&&(this[mi].length===1?(this[on]&&this[Au]===0&&(this[on]=!1),this[mi]=[]):this[mi].splice(this[mi].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e==="data")this[Xi]=!1,this[Au]++,!this[mi].length&&!this[on]&&this[tp]();else if(e==="readable"&&this[cn]!==0)super.emit("readable");else if(Eye(e)&&this[Zc])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[lg]){let i=t;this[jo]?dg(()=>i.call(this,this[lg])):i.call(this,this[lg])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e==="data"&&(this[Au]=this.listeners("data").length,this[Au]===0&&!this[Xi]&&!this[mi].length&&(this[on]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Au]=0,!this[Xi]&&!this[mi].length&&(this[on]=!1)),t}get emittedEnd(){return this[Zc]}[Wa](){!this[Pw]&&!this[Zc]&&!this[Rr]&&this[an].length===0&&this[qa]&&(this[Pw]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Fw]&&this.emit("close"),this[Pw]=!1)}emit(e,...t){let n=t[0];if(e!=="error"&&e!=="close"&&e!==Rr&&this[Rr])return!1;if(e==="data")return!this[Kn]&&!n?!1:this[jo]?(dg(()=>this[MO](n)),!0):this[MO](n);if(e==="end")return this[X6]();if(e==="close"){if(this[Fw]=!0,!this[Zc]&&!this[Rr])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[lg]=n,super.emit(kO,n);let s=!this[fg]||this.listeners("error").length?super.emit("error",n):!1;return this[Wa](),s}else if(e==="resume"){let s=super.emit("resume");return this[Wa](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let i=super.emit(e,...t);return this[Wa](),i}[MO](e){for(let n of this[mi])n.dest.write(e)===!1&&this.pause();let t=this[Xi]?!1:super.emit("data",e);return this[Wa](),t}[X6](){return this[Zc]?!1:(this[Zc]=!0,this.readable=!1,this[jo]?(dg(()=>this[jO]()),!0):this[jO]())}[jO](){if(this[ep]){let t=this[ep].end();if(t){for(let n of this[mi])n.dest.write(t);this[Xi]||super.emit("data",t)}}for(let t of this[mi])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Kn]||(e.dataLength=0);let t=this.promise();return this.on("data",n=>{e.push(n),this[Kn]||(e.dataLength+=n.length)}),await t,e}async concat(){if(this[Kn])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Ws]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(Rr,()=>t(new Error("stream destroyed"))),this.on("error",n=>t(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Xi]=!1;let e=!1,t=a(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:a(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[qa])return t();let s,o,c=a(d=>{this.off("data",l),this.off("end",u),this.off(Rr,f),t(),o(d)},"onerr"),l=a(d=>{this.off("error",c),this.off("end",u),this.off(Rr,f),this.pause(),s({value:d,done:!!this[qa]})},"ondata"),u=a(()=>{this.off("error",c),this.off("data",l),this.off(Rr,f),t(),s({done:!0,value:void 0})},"onend"),f=a(()=>c(new Error("stream destroyed")),"ondestroy");return new Promise((d,p)=>{o=p,s=d,this.once(Rr,f),this.once("error",c),this.once("end",u),this.once("data",l)})},"next"),throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Xi]=!1;let e=!1,t=a(()=>(this.pause(),this.off(kO,t),this.off(Rr,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),n=a(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(kO,t),this.once(Rr,t),{next:n,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[Rr])return e?this.emit("error",e):this.emit(Rr),this;this[Rr]=!0,this[Xi]=!0,this[an].length=0,this[cn]=0;let t=this;return typeof t.close=="function"&&!this[Fw]&&t.close(),e?this.emit("error",e):this.emit(Rr),this}static get isStream(){return bye}}});var rp,r8,Uo,Rye,tl,Cye,hg,n8,i8,xye,Oye,ps,s8,o8,$o,a8,c8,Iu,l8,ds,pg,GO,J6,mg,zs,jw,Uw,Z6,Pye,qO,e8,gg,t8,$w,Bw,WO,u8,Yn,Vw,Gw,qw,np,ip,yg,$ke,f8,d8=Me(()=>{z6();rp=require("node:path"),r8=require("node:url"),Uo=require("fs"),Rye=Q(require("node:fs"),1),tl=require("node:fs/promises");VO();Cye=Uo.realpathSync.native,hg={lstatSync:Uo.lstatSync,readdir:Uo.readdir,readdirSync:Uo.readdirSync,readlinkSync:Uo.readlinkSync,realpathSync:Cye,promises:{lstat:tl.lstat,readdir:tl.readdir,readlink:tl.readlink,realpath:tl.realpath}},n8=a(r=>!r||r===hg||r===Rye?hg:{...hg,...r,promises:{...hg.promises,...r.promises||{}}},"fsFromOption"),i8=/^\\\\\?\\([a-z]:)\\?$/i,xye=a(r=>r.replace(/\//g,"\\").replace(i8,"$1\\"),"uncToDrive"),Oye=/[\\\/]/,ps=0,s8=1,o8=2,$o=4,a8=6,c8=8,Iu=10,l8=12,ds=15,pg=~ds,GO=16,J6=32,mg=64,zs=128,jw=256,Uw=512,Z6=mg|zs|Uw,Pye=1023,qO=a(r=>r.isFile()?c8:r.isDirectory()?$o:r.isSymbolicLink()?Iu:r.isCharacterDevice()?o8:r.isBlockDevice()?a8:r.isSocket()?l8:r.isFIFO()?s8:ps,"entToType"),e8=new cg({max:2**12}),gg=a(r=>{let e=e8.get(r);if(e)return e;let t=r.normalize("NFKD");return e8.set(r,t),t},"normalize"),t8=new cg({max:2**12}),$w=a(r=>{let e=t8.get(r);if(e)return e;let t=gg(r.toLowerCase());return t8.set(r,t),t},"normalizeNocase"),Bw=class extends cg{static{a(this,"ResolveCache")}constructor(){super({max:256})}},WO=class extends cg{static{a(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:a(t=>t.length+1,"sizeCalculation")})}},u8=Symbol("PathScurry setAsCwd"),Yn=class{static{a(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#n;get mode(){return this.#n}#e;get nlink(){return this.#e}#i;get uid(){return this.#i}#a;get gid(){return this.#a}#p;get rdev(){return this.#p}#u;get blksize(){return this.#u}#c;get ino(){return this.#c}#f;get size(){return this.#f}#l;get blocks(){return this.#l}#d;get atimeMs(){return this.#d}#o;get mtimeMs(){return this.#o}#g;get ctimeMs(){return this.#g}#E;get birthtimeMs(){return this.#E}#_;get atime(){return this.#_}#S;get mtime(){return this.#S}#A;get ctime(){return this.#A}#y;get birthtime(){return this.#y}#v;#T;#m;#b;#w;#R;#s;#x;#O;#C;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=ps,n,i,s,o,c){this.name=e,this.#v=s?$w(e):gg(e),this.#s=t&Pye,this.nocase=s,this.roots=i,this.root=n||this,this.#x=o,this.#m=c.fullpath,this.#w=c.relative,this.#R=c.relativePosix,this.parent=c.parent,this.parent?this.#t=this.parent.#t:this.#t=n8(c.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#x}resolve(e){if(!e)return this;let t=this.getRootString(e),i=e.substring(t.length).split(this.splitSep);return t?this.getRoot(t).#D(i):this.#D(i)}#D(e){let t=this;for(let n of e)t=t.child(n);return t}children(){let e=this.#x.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#x.set(this,t),this.#s&=~GO,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let n=this.children(),i=this.nocase?$w(e):gg(e);for(let l of n)if(l.#v===i)return l;let s=this.parent?this.sep:"",o=this.#m?this.#m+s+e:void 0,c=this.newChild(e,ps,{...t,parent:this,fullpath:o});return this.canReaddir()||(c.#s|=zs),n.push(c),c}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let e=this.name,t=this.parent;if(!t)return this.#w=this.name;let n=t.relative();return n+(!n||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#R!==void 0)return this.#R;let e=this.name,t=this.parent;if(!t)return this.#R=this.fullpathPosix();let n=t.relativePosix();return n+(!n||!t.parent?"":"/")+e}fullpath(){if(this.#m!==void 0)return this.#m;let e=this.name,t=this.parent;if(!t)return this.#m=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#m=i}fullpathPosix(){if(this.#b!==void 0)return this.#b;if(this.sep==="/")return this.#b=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#b=`//?/${i}`:this.#b=i}let e=this.parent,t=e.fullpathPosix(),n=t+(!t||!e.parent?"":"/")+this.name;return this.#b=n}isUnknown(){return(this.#s&ds)===ps}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#s&ds)===c8}isDirectory(){return(this.#s&ds)===$o}isCharacterDevice(){return(this.#s&ds)===o8}isBlockDevice(){return(this.#s&ds)===a8}isFIFO(){return(this.#s&ds)===s8}isSocket(){return(this.#s&ds)===l8}isSymbolicLink(){return(this.#s&Iu)===Iu}lstatCached(){return this.#s&J6?this:void 0}readlinkCached(){return this.#O}realpathCached(){return this.#C}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#O)return!0;if(!this.parent)return!1;let e=this.#s&ds;return!(e!==ps&&e!==Iu||this.#s&jw||this.#s&zs)}calledReaddir(){return!!(this.#s&GO)}isENOENT(){return!!(this.#s&zs)}isNamed(e){return this.nocase?this.#v===$w(e):this.#v===gg(e)}async readlink(){let e=this.#O;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#t.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(t);if(n)return this.#O=n}catch(t){this.#F(t.code);return}}readlinkSync(){let e=this.#O;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#t.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(t);if(n)return this.#O=n}catch(t){this.#F(t.code);return}}#$(e){this.#s|=GO;for(let t=e.provisional;t<e.length;t++){let n=e[t];n&&n.#I()}}#I(){this.#s&zs||(this.#s=(this.#s|zs)&pg,this.#q())}#q(){let e=this.children();e.provisional=0;for(let t of e)t.#I()}#N(){this.#s|=Uw,this.#L()}#L(){if(this.#s&mg)return;let e=this.#s;(e&ds)===$o&&(e&=pg),this.#s=e|mg,this.#q()}#U(e=""){e==="ENOTDIR"||e==="EPERM"?this.#L():e==="ENOENT"?this.#I():this.children().provisional=0}#P(e=""){e==="ENOTDIR"?this.parent.#L():e==="ENOENT"&&this.#I()}#F(e=""){let t=this.#s;t|=jw,e==="ENOENT"&&(t|=zs),(e==="EINVAL"||e==="UNKNOWN")&&(t&=pg),this.#s=t,e==="ENOTDIR"&&this.parent&&this.parent.#L()}#B(e,t){return this.#G(e,t)||this.#k(e,t)}#k(e,t){let n=qO(e),i=this.newChild(e.name,n,{parent:this}),s=i.#s&ds;return s!==$o&&s!==Iu&&s!==ps&&(i.#s|=mg),t.unshift(i),t.provisional++,i}#G(e,t){for(let n=t.provisional;n<t.length;n++){let i=t[n];if((this.nocase?$w(e.name):gg(e.name))===i.#v)return this.#Y(e,i,n,t)}}#Y(e,t,n,i){let s=t.name;return t.#s=t.#s&pg|qO(e),s!==e.name&&(t.name=e.name),n!==i.provisional&&(n===i.length-1?i.pop():i.splice(n,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#s&zs)===0)try{return this.#W(await this.#t.promises.lstat(this.fullpath())),this}catch(e){this.#P(e.code)}}lstatSync(){if((this.#s&zs)===0)try{return this.#W(this.#t.lstatSync(this.fullpath())),this}catch(e){this.#P(e.code)}}#W(e){let{atime:t,atimeMs:n,birthtime:i,birthtimeMs:s,blksize:o,blocks:c,ctime:l,ctimeMs:u,dev:f,gid:d,ino:p,mode:h,mtime:g,mtimeMs:m,nlink:b,rdev:_,size:S,uid:A}=e;this.#_=t,this.#d=n,this.#y=i,this.#E=s,this.#u=o,this.#l=c,this.#A=l,this.#g=u,this.#r=f,this.#a=d,this.#c=p,this.#n=h,this.#S=g,this.#o=m,this.#e=b,this.#p=_,this.#f=S,this.#i=A;let w=qO(e);this.#s=this.#s&pg|w|J6,w!==ps&&w!==$o&&w!==Iu&&(this.#s|=mg)}#M=[];#h=!1;#z(e){this.#h=!1;let t=this.#M.slice();this.#M.length=0,t.forEach(n=>n(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let n=this.children();if(this.calledReaddir()){let s=n.slice(0,n.provisional);t?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#M.push(e),this.#h)return;this.#h=!0;let i=this.fullpath();this.#t.readdir(i,{withFileTypes:!0},(s,o)=>{if(s)this.#U(s.code),n.provisional=0;else{for(let c of o)this.#B(c,n);this.#$(n)}this.#z(n.slice(0,n.provisional))})}#V;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();if(this.#V)await this.#V;else{let n=a(()=>{},"resolve");this.#V=new Promise(i=>n=i);try{for(let i of await this.#t.promises.readdir(t,{withFileTypes:!0}))this.#B(i,e);this.#$(e)}catch(i){this.#U(i.code),e.provisional=0}this.#V=void 0,n()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let t=this.fullpath();try{for(let n of this.#t.readdirSync(t,{withFileTypes:!0}))this.#B(n,e);this.#$(e)}catch(n){this.#U(n.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#s&Z6)return!1;let e=ds&this.#s;return e===ps||e===$o||e===Iu}shouldWalk(e,t){return(this.#s&$o)===$o&&!(this.#s&Z6)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#C)return this.#C;if(!((Uw|jw|zs)&this.#s))try{let e=await this.#t.promises.realpath(this.fullpath());return this.#C=this.resolve(e)}catch{this.#N()}}realpathSync(){if(this.#C)return this.#C;if(!((Uw|jw|zs)&this.#s))try{let e=this.#t.realpathSync(this.fullpath());return this.#C=this.resolve(e)}catch{this.#N()}}[u8](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),n=[],i=this;for(;i&&i.parent;)t.add(i),i.#w=n.join(this.sep),i.#R=n.join("/"),i=i.parent,n.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#w=void 0,i.#R=void 0,i=i.parent}},Vw=class r extends Yn{static{a(this,"PathWin32")}sep="\\";splitSep=Oye;constructor(e,t=ps,n,i,s,o,c){super(e,t,n,i,s,o,c)}newChild(e,t=ps,n={}){return new r(e,t,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return rp.win32.parse(e).root}getRoot(e){if(e=xye(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,n]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=n;return this.roots[e]=new np(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(i8,"$1\\"),e===t}},Gw=class r extends Yn{static{a(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=ps,n,i,s,o,c){super(e,t,n,i,s,o,c)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=ps,n={}){return new r(e,t,this.root,this.roots,this.nocase,this.childrenCache(),n)}},qw=class{static{a(this,"PathScurryBase")}root;rootPath;roots;cwd;#t;#r;#n;nocase;#e;constructor(e=process.cwd(),t,n,{nocase:i,childrenCacheSize:s=16*1024,fs:o=hg}={}){this.#e=n8(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,r8.fileURLToPath)(e));let c=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(c),this.#t=new Bw,this.#r=new Bw,this.#n=new WO(s);let l=c.substring(this.rootPath.length).split(n);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#e),this.roots[this.rootPath]=this.root;let u=this.root,f=l.length-1,d=t.sep,p=this.rootPath,h=!1;for(let g of l){let m=f--;u=u.child(g,{relative:new Array(m).fill("..").join(d),relativePosix:new Array(m).fill("..").join("/"),fullpath:p+=(h?"":d)+g}),h=!0}this.cwd=u}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#n}resolve(...e){let t="";for(let s=e.length-1;s>=0;s--){let o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let n=this.#t.get(t);if(n!==void 0)return n;let i=this.cwd.resolve(t).fullpath();return this.#t.set(t,i),i}resolvePosix(...e){let t="";for(let s=e.length-1;s>=0;s--){let o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))break}let n=this.#r.get(t);if(n!==void 0)return n;let i=this.cwd.resolve(t).fullpathPosix();return this.#r.set(t,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n}=t;if(e.canReaddir()){let i=await e.readdir();return n?i:i.map(s=>s.name)}else return[]}readdirSync(e=this.cwd,t={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0}=t;return e.canReaddir()?n?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=await e.readlink();return t?n:n?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=e.readlinkSync();return t?n:n?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=await e.realpath();return t?n:n?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e.withFileTypes,e=this.cwd);let n=e.realpathSync();return t?n:n?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=[];(!s||s(e))&&c.push(n?e:e.fullpath());let l=new Set,u=a((d,p)=>{l.add(d),d.readdirCB((h,g)=>{if(h)return p(h);let m=g.length;if(!m)return p();let b=a(()=>{--m===0&&p()},"next");for(let _ of g)(!s||s(_))&&c.push(n?_:_.fullpath()),i&&_.isSymbolicLink()?_.realpath().then(S=>S?.isUnknown()?S.lstat():S).then(S=>S?.shouldWalk(l,o)?u(S,b):b()):_.shouldWalk(l,o)?u(_,b):b()},!0)},"walk"),f=e;return new Promise((d,p)=>{u(f,h=>{if(h)return p(h);d(c)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=[];(!s||s(e))&&c.push(n?e:e.fullpath());let l=new Set([e]);for(let u of l){let f=u.readdirSync();for(let d of f){(!s||s(d))&&c.push(n?d:d.fullpath());let p=d;if(d.isSymbolicLink()){if(!(i&&(p=d.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(l,o)&&l.add(p)}}return c}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd),this.stream(e,t)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t;(!s||s(e))&&(yield n?e:e.fullpath());let c=new Set([e]);for(let l of c){let u=l.readdirSync();for(let f of u){(!s||s(f))&&(yield n?f:f.fullpath());let d=f;if(f.isSymbolicLink()){if(!(i&&(d=f.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,o)&&c.add(d)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=new el({objectMode:!0});(!s||s(e))&&c.write(n?e:e.fullpath());let l=new Set,u=[e],f=0,d=a(()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&c.end();return}f++,l.add(h);let g=a((b,_,S=!1)=>{if(b)return c.emit("error",b);if(i&&!S){let A=[];for(let w of _)w.isSymbolicLink()&&A.push(w.realpath().then(E=>E?.isUnknown()?E.lstat():E));if(A.length){Promise.all(A).then(()=>g(null,_,!0));return}}for(let A of _)A&&(!s||s(A))&&(c.write(n?A:A.fullpath())||(p=!0));f--;for(let A of _){let w=A.realpathCached()||A;w.shouldWalk(l,o)&&u.push(w)}p&&!c.flowing?c.once("drain",d):m||d()},"onReaddir"),m=!0;h.readdirCB(g,!0),m=!1}},"process");return d(),c}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Yn||(t=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=t,c=new el({objectMode:!0}),l=new Set;(!s||s(e))&&c.write(n?e:e.fullpath());let u=[e],f=0,d=a(()=>{let p=!1;for(;!p;){let h=u.shift();if(!h){f===0&&c.end();return}f++,l.add(h);let g=h.readdirSync();for(let m of g)(!s||s(m))&&(c.write(n?m:m.fullpath())||(p=!0));f--;for(let m of g){let b=m;if(m.isSymbolicLink()){if(!(i&&(b=m.realpathSync())))continue;b.isUnknown()&&b.lstatSync()}b.shouldWalk(l,o)&&u.push(b)}}p&&!c.flowing&&c.once("drain",d)},"process");return d(),c}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[u8](t)}},np=class extends qw{static{a(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,rp.win32,"\\",{...t,nocase:n}),this.nocase=n;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return rp.win32.parse(e).root.toUpperCase()}newRoot(e){return new Vw(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},ip=class extends qw{static{a(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:n=!1}=t;super(e,rp.posix,"/",{...t,nocase:n}),this.nocase=n}parseRootPath(e){return"/"}newRoot(e){return new Gw(this.rootPath,$o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},yg=class extends ip{static{a(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:n=!0}=t;super(e,{...t,nocase:n})}},$ke=process.platform==="win32"?Vw:Gw,f8=process.platform==="win32"?np:process.platform==="darwin"?yg:ip});var Fye,Dye,sp,zO=Me(()=>{Qc();Fye=a(r=>r.length>=1,"isPatternList"),Dye=a(r=>r.length>=1,"isGlobList"),sp=class r{static{a(this,"Pattern")}#t;#r;#n;length;#e;#i;#a;#p;#u;#c;#f=!0;constructor(e,t,n,i){if(!Fye(e))throw new TypeError("empty pattern list");if(!Dye(t))throw new TypeError("empty glob list");if(t.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#t=e,this.#r=t,this.#n=n,this.#e=i,this.#n===0){if(this.isUNC()){let[s,o,c,l,...u]=this.#t,[f,d,p,h,...g]=this.#r;u[0]===""&&(u.shift(),g.shift());let m=[s,o,c,l,""].join("/"),b=[f,d,p,h,""].join("/");this.#t=[m,...u],this.#r=[b,...g],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[s,...o]=this.#t,[c,...l]=this.#r;o[0]===""&&(o.shift(),l.shift());let u=s+"/",f=c+"/";this.#t=[u,...o],this.#r=[f,...l],this.length=this.#t.length}}}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===Ir}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#a=this.#a||(this.#n===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new r(this.#t,this.#r,this.#n+1,this.#e),this.#i.#c=this.#c,this.#i.#u=this.#u,this.#i.#p=this.#p,this.#i):this.#i=null}isUNC(){let e=this.#t;return this.#u!==void 0?this.#u:this.#u=this.#e==="win32"&&this.#n===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#t;return this.#p!==void 0?this.#p:this.#p=this.#e==="win32"&&this.#n===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#t;return this.#c!==void 0?this.#c:this.#c=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#t[0];return typeof e=="string"&&this.isAbsolute()&&this.#n===0?e:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}}});var Lye,op,HO=Me(()=>{Qc();zO();Lye=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",op=class{static{a(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:n,noext:i,noglobstar:s,platform:o=Lye}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:n,noext:i,noglobstar:s,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let c of e)this.add(c)}add(e){let t=new Yi(e,this.mmopts);for(let n=0;n<t.set.length;n++){let i=t.set[n],s=t.globParts[n];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let o=new sp(i,s,0,this.platform),c=new Yi(o.globString(),this.mmopts),l=s[s.length-1]==="**",u=o.isAbsolute();u?this.absolute.push(c):this.relative.push(c),l&&(u?this.absoluteChildren.push(c):this.relativeChildren.push(c))}}ignored(e){let t=e.fullpath(),n=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(s))return!0;for(let o of this.absolute)if(o.match(t)||o.match(n))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",n=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(n))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}}});var KO,YO,XO,bg,p8=Me(()=>{Qc();KO=class r{static{a(this,"HasWalkedCache")}store;constructor(e=new Map){this.store=e}copy(){return new r(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let n=e.fullpath(),i=this.store.get(n);i?i.add(t.globString()):this.store.set(n,new Set([t.globString()]))}},YO=class{static{a(this,"MatchRecord")}store=new Map;add(e,t,n){let i=(t?2:0)|(n?1:0),s=this.store.get(e);this.store.set(e,s===void 0?i:i&s)}entries(){return[...this.store.entries()].map(([e,t])=>[e,!!(t&2),!!(t&1)])}},XO=class{static{a(this,"SubWalks")}store=new Map;add(e,t){if(!e.canReaddir())return;let n=this.store.get(e);n?n.find(i=>i.globString()===t.globString())||n.push(t):this.store.set(e,[t])}get(e){let t=this.store.get(e);if(!t)throw new Error("attempting to walk unknown path");return t}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},bg=class r{static{a(this,"Processor")}hasWalkedCache;matches=new YO;subwalks=new XO;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new KO}processPatterns(e,t){this.patterns=t;let n=t.map(i=>[e,i]);for(let[i,s]of n){this.hasWalkedCache.storeWalked(i,s);let o=s.root(),c=s.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let d=s.rest();if(d)s=d;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let l,u,f=!1;for(;typeof(l=s.pattern())=="string"&&(u=s.rest());)i=i.resolve(l),s=u,f=!0;if(l=s.pattern(),u=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof l=="string"){let d=l===".."||l===""||l===".";this.matches.add(i.resolve(l),c,d);continue}else if(l===Ir){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let d=u?.pattern(),p=u?.rest();if(!u||(d===""||d===".")&&!p)this.matches.add(i,c,d===""||d===".");else if(d===".."){let h=i.parent||i;p?this.hasWalkedCache.hasWalked(h,p)||this.subwalks.add(h,p):this.matches.add(h,c,!0)}}else l instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new r(this.opts,this.hasWalkedCache)}filterEntries(e,t){let n=this.subwalks.get(e),i=this.child();for(let s of t)for(let o of n){let c=o.isAbsolute(),l=o.pattern(),u=o.rest();l===Ir?i.testGlobstar(s,o,u,c):l instanceof RegExp?i.testRegExp(s,l,u,c):i.testString(s,l,u,c)}return i}testGlobstar(e,t,n,i){if((this.dot||!e.name.startsWith("."))&&(t.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,t):e.isSymbolicLink()&&(n&&t.checkFollowGlobstar()?this.subwalks.add(e,n):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),n){let s=n.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,n.rest(),i);else if(s===".."){let o=e.parent||e;this.subwalks.add(o,n)}else s instanceof RegExp&&this.testRegExp(e,s,n.rest(),i)}}testRegExp(e,t,n,i){t.test(e.name)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}testString(e,t,n,i){e.isNamed(t)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}}});var Nye,Ww,_g,Sg,h8=Me(()=>{VO();HO();p8();Nye=a((r,e)=>typeof r=="string"?new op([r],e):Array.isArray(r)?new op(r,e):r,"makeIgnore"),Ww=class{static{a(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#n;signal;maxDepth;includeChildMatches;constructor(e,t,n){if(this.patterns=e,this.path=t,this.opts=n,this.#n=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#r=Nye(n.ignore??[],n),!this.includeChildMatches&&typeof this.#r.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#e(e){return this.seen.has(e)||!!this.#r?.ignored?.(e)}#i(e){return!!this.#r?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#t.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#t.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||await e.realpath(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let o=await s.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(s,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#e(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||e.realpathSync(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let o=s.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(s,t)}matchFinish(e,t){if(this.#e(e))return;if(!this.includeChildMatches&&this.#r?.add){let s=`${e.relativePosix()}/**`;this.#r.add(s)}let n=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(n){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!s.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(s?o+s+i:"."+i)}}async match(e,t,n){let i=await this.matchCheck(e,n);i&&this.matchFinish(i,t)}matchSync(e,t,n){let i=this.matchCheckSync(e,n);i&&this.matchFinish(i,t)}walkCB(e,t,n){this.signal?.aborted&&n(),this.walkCB2(e,t,new bg(this.opts),n)}walkCB2(e,t,n,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,n,i));return}n.processPatterns(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||(s++,this.match(c,l,u).then(()=>o()));for(let c of n.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirCached();c.calledReaddir()?this.walkCB3(c,l,n,o):c.readdirCB((u,f)=>this.walkCB3(c,f,n,o),!0)}o()}walkCB3(e,t,n,i){n=n.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||(s++,this.match(c,l,u).then(()=>o()));for(let[c,l]of n.subwalks.entries())s++,this.walkCB2(c,l,n.child(),o);o()}walkCBSync(e,t,n){this.signal?.aborted&&n(),this.walkCB2Sync(e,t,new bg(this.opts),n)}walkCB2Sync(e,t,n,i){if(this.#i(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,n,i));return}n.processPatterns(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||this.matchSync(c,l,u);for(let c of n.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirSync();this.walkCB3Sync(c,l,n,o)}o()}walkCB3Sync(e,t,n,i){n=n.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[c,l,u]of n.matches.entries())this.#e(c)||this.matchSync(c,l,u);for(let[c,l]of n.subwalks.entries())s++,this.walkCB2Sync(c,l,n.child(),o);o()}},_g=class extends Ww{static{a(this,"GlobWalker")}matches=new Set;constructor(e,t,n){super(e,t,n)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,t)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?t(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Sg=class extends Ww{static{a(this,"GlobStream")}results;constructor(e,t,n){super(e,t,n),this.results=new el({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}});var m8,kye,Hs,QO=Me(()=>{Qc();m8=require("node:url");d8();zO();h8();kye=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Hs=class{static{a(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,m8.fileURLToPath)(t.cwd)):this.cwd="",this.cwd=t.cwd||"",this.root=t.root,this.magicalBraces=!!t.magicalBraces,this.nobrace=!!t.nobrace,this.noext=!!t.noext,this.realpath=!!t.realpath,this.absolute=t.absolute,this.includeChildMatches=t.includeChildMatches!==!1,this.noglobstar=!!t.noglobstar,this.matchBase=!!t.matchBase,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:1/0,this.stat=!!t.stat,this.ignore=t.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(l=>l.includes("/")?l:`./**/${l}`)}if(this.pattern=e,this.platform=t.platform||kye,this.opts={...t,platform:this.platform},t.scurry){if(this.scurry=t.scurry,t.nocase!==void 0&&t.nocase!==t.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let l=t.platform==="win32"?np:t.platform==="darwin"?yg:t.platform?ip:f8;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},s=this.pattern.map(l=>new Yi(l,i)),[o,c]=s.reduce((l,u)=>(l[0].push(...u.set),l[1].push(...u.globParts),l),[[],[]]);this.patterns=o.map((l,u)=>{let f=c[u];if(!f)throw new Error("invalid pattern object");return new sp(l,f,0,this.platform)})}async walk(){return[...await new _g(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new _g(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Sg(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Sg(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}});var JO,ZO=Me(()=>{Qc();JO=a((r,e={})=>{Array.isArray(r)||(r=[r]);for(let t of r)if(new Yi(t,e).hasMagic())return!0;return!1},"hasMagic")});function zw(r,e={}){return new Hs(r,e).streamSync()}function y8(r,e={}){return new Hs(r,e).stream()}function b8(r,e={}){return new Hs(r,e).walkSync()}async function g8(r,e={}){return new Hs(r,e).walk()}function Hw(r,e={}){return new Hs(r,e).iterateSync()}function _8(r,e={}){return new Hs(r,e).iterate()}var Mye,jye,$ye,Uye,Bye,ap,eP=Me(()=>{Qc();QO();ZO();Qc();QO();ZO();HO();a(zw,"globStreamSync");a(y8,"globStream");a(b8,"globSync");a(g8,"glob_");a(Hw,"globIterateSync");a(_8,"globIterate");Mye=zw,jye=Object.assign(y8,{sync:zw}),$ye=Hw,Uye=Object.assign(_8,{sync:Hw}),Bye=Object.assign(b8,{stream:zw,iterate:Hw}),ap=Object.assign(g8,{glob:g8,globSync:b8,sync:Bye,globStream:y8,stream:jye,globStreamSync:zw,streamSync:Mye,globIterate:_8,iterate:Uye,globIterateSync:Hw,iterateSync:$ye,Glob:Hs,hasMagic:JO,escape:Zd,unescape:qs});ap.glob=ap});async function w8(r,e,t,n={}){let{excludeRelPath:i}=n,s=Ru.default.join(r,"**/*.md"),o=await ap(s,{nodir:!0,ignore:[Ru.default.join(r,".obsidian/**"),Ru.default.join(r,".trash/**"),Ru.default.join(r,"**/.obsidian/**"),Ru.default.join(r,"**/.trash/**")]}),c={filesScanned:0,filesModified:0,replacements:0,modifiedFiles:[]};for(let l of o){let u=Ru.default.relative(r,l);if(i&&u===i)continue;c.filesScanned+=1;let f;try{f=await tP.default.readFile(l,"utf-8")}catch{continue}let{updated:d,replacements:p}=Vye(f,e,t);p>0&&(c.filesModified+=1,c.replacements+=p,c.modifiedFiles.push(u),await tP.default.writeFile(l,d,"utf-8"))}return c}function Vye(r,e,t){let n=r.split(/(^```[\s\S]*?^```)/m),i=0;for(let s=0;s<n.length;s++){if(s%2===1)continue;let o=n[s],c=Gye(o,e,t);i+=c.replacements,n[s]=c.updated}return{updated:n.join(""),replacements:i}}function Gye(r,e,t){let n=r.split(/(`[^`\n]*`)/),i=0;for(let s=0;s<n.length;s++){if(s%2===1)continue;let o=qye(n[s],e,t);i+=o.replacements,n[s]=o.updated}return{updated:n.join(""),replacements:i}}function qye(r,e,t){let n=/(?<!!)\[\[([^\[\]\n|#^]+)((?:[#^][^\[\]\n|]*)?)(?:\|[^\[\]\n]*)?\]\]/g,i=0;return{updated:r.replace(n,(o,c,l)=>c.trim()!==e?o:(i+=1,`[[${t}${l}]]`)),replacements:i}}var tP,Ru,E8=Me(()=>{"use strict";tP=Q(Mo()),Ru=Q(require("path"));eP();a(w8,"rewriteInboundWikilinks");a(Vye,"rewriteContent");a(Gye,"rewriteProseSegment");a(qye,"replaceWikilinks")});var Cr,fr,Kw,Wye,Ht,Ks=Me(()=>{"use strict";Cr=Q(Mo()),fr=Q(require("path"));rg();Kw=Q(Pe());E8();Wye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ht=class r{constructor(e){this.rootPath=e;this.uuidIndex=null;this.basenameIndex=null;this.aliasIndex=null}static{a(this,"FileSystemVaultAdapter")}async read(e){let t=this.resolvePath(e.path);if(!await Cr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);return Cr.default.readFile(t,"utf-8")}async create(e,t){let n=this.resolvePath(e);if(await Cr.default.pathExists(n))throw new Error(`File already exists: ${e}`);return await Cr.default.ensureDir(fr.default.dirname(n)),await Cr.default.writeFile(n,t,"utf-8"),this.createFileObject(e)}async modify(e,t){let n=this.resolvePath(e.path);if(!await Cr.default.pathExists(n))throw new Error(`File not found: ${e.path}`);await Cr.default.writeFile(n,t,"utf-8")}async delete(e){let t=this.resolvePath(e.path);if(!await Cr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);await Cr.default.remove(t)}async exists(e){let t=this.resolvePath(e);return Cr.default.pathExists(t)}getAbstractFileByPath(e){let t=this.resolvePath(e);try{let n=Cr.default.statSync(t);if(n.isFile())return this.createFileObject(e);if(n.isDirectory())return this.createFolderObject(e)}catch{return null}return null}getAllFiles(){let e=[];return this.walkDirectory(this.rootPath,t=>{if(t.endsWith(".md")){let n=fr.default.relative(this.rootPath,t);e.push(this.createFileObject(n))}}),e}getFrontmatter(e){try{let t=Cr.default.readFileSync(this.resolvePath(e.path),"utf-8");return this.extractFrontmatter(t)}catch{return null}}getFrontmatterParseFailure(e){let t;try{t=Cr.default.readFileSync(this.resolvePath(e.path),"utf-8")}catch{return null}let n=r.matchFrontmatterBlock(t)?.body;if(n===void 0)return null;let i=/^[ \t]*(#.*)?\r?$/;if(!n.split(`
|
|
432
432
|
`).some(o=>!i.test(o))||this.extractFrontmatter(t)!==null)return null;try{return Xc(n,{schema:tg}),{reason:"frontmatter is not a mapping with string keys"}}catch(o){return{reason:o instanceof Error?o.message.split(`
|
|
433
|
-
`)[0]:String(o)}}}async updateFrontmatter(e,t){let n=await this.read(e),i=this.extractFrontmatter(n),s=r.
|
|
433
|
+
`)[0]:String(o)}}}async updateFrontmatter(e,t){let n=await this.read(e),i=this.extractFrontmatter(n),s=r.matchFrontmatterBlock(n)?.body;if(i===null&&s!==void 0&&s.trim()!=="")throw new Error(`updateFrontmatter: frontmatter of ${e.path} is not parseable \u2014 refusing to patch (re-serialising would overwrite the unreadable block)`);let o=i??{},c=t({...o});Kw.FrontmatterService.applyPatch(o,c);let l=this.replaceFrontmatter(n,o);await this.modify(e,l)}async rename(e,t){let n=this.resolvePath(e.path),i=this.resolvePath(t);if(!await Cr.default.pathExists(n))throw new Error(`File not found: ${e.path}`);await Cr.default.ensureDir(fr.default.dirname(i)),await Cr.default.move(n,i)}async createFolder(e){let t=this.resolvePath(e);await Cr.default.ensureDir(t)}getFirstLinkpathDest(e,t,n){let i=e.split("|")[0].trim();if(!i)return null;if(Wye.test(i)){this.uuidIndex===null&&this.buildUuidIndex();let u=i.toLowerCase(),f=this.uuidIndex.get(u);return f?this.createFileObject(f):null}let s=fr.default.dirname(this.resolvePath(t)),o;if(fr.default.isAbsolute(i)?o=this.resolvePath(i):o=fr.default.resolve(s,i),i.endsWith(".md")||(o+=".md"),Cr.default.existsSync(o)){let u=fr.default.relative(this.rootPath,o);return this.createFileObject(u)}(this.basenameIndex===null||this.aliasIndex===null)&&this.buildLinkpathIndex();let c=i.toLowerCase(),l=this.basenameIndex.get(c);if(l)return this.createFileObject(l);if(n?.allowAliasFallback!==!1){let u=this.aliasIndex.get(c);if(u)return this.createFileObject(u)}return null}buildLinkpathIndex(){this.basenameIndex=new Map,this.aliasIndex=new Map,this.walkDirectory(this.rootPath,e=>{if(!e.endsWith(".md"))return;let t=fr.default.relative(this.rootPath,e),n=fr.default.basename(e,".md").toLowerCase();this.basenameIndex.has(n)||this.basenameIndex.set(n,t);let i;try{i=Cr.default.readFileSync(e,"utf-8")}catch{return}let s=this.extractFrontmatter(i);if(!s)return;let o=s.aliases,c=Array.isArray(o)?o:typeof o=="string"?[o]:[];for(let l of c){if(typeof l!="string")continue;let u=l.trim().toLowerCase();u&&(this.aliasIndex.has(u)||this.aliasIndex.set(u,t))}})}buildUuidIndex(){this.uuidIndex=new Map,this.walkDirectory(this.rootPath,e=>{if(e.endsWith(".md")){let n=fr.default.basename(e,".md").match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);if(n){let i=n[1].toLowerCase(),s=fr.default.relative(this.rootPath,e);this.uuidIndex.set(i,s)}}})}async process(e,t){let n=await this.read(e),i=t(n);return await this.modify(e,i),i}getDefaultNewFileParent(){return{path:"",name:""}}async updateLinks(e,t,n){let i=fr.default.basename(t,".md");await w8(this.rootPath,n,i,{excludeRelPath:e})}resolvePath(e){if(fr.default.isAbsolute(e))return e;let t=this.rootPath.replace(/[/\\]+$/,""),n=fr.default.sep+e;return n===t||n.startsWith(t+fr.default.sep)?n:fr.default.join(this.rootPath,e)}createFileObject(e){let t=fr.default.basename(e),n=fr.default.basename(e,fr.default.extname(e)),i=fr.default.dirname(e);return{path:e,basename:n,name:t,parent:i!=="."?this.createFolderObject(i):null}}createFolderObject(e){return{path:e,name:fr.default.basename(e)}}static{this.FRONTMATTER_BLOCK=/^---\r?\n([\s\S]*?)\r?\n---/}static bomLength(e){return e.charCodeAt(0)===65279?1:0}static matchFrontmatterBlock(e){let t=r.bomLength(e),n=r.FRONTMATTER_BLOCK.exec(t===0?e:e.slice(t));return n?{body:n[1],blockStart:t,blockEnd:t+n[0].length}:null}extractFrontmatter(e){let t=r.matchFrontmatterBlock(e);return t?(0,Kw.parseYamlFrontmatterTolerant)(t.body):null}replaceFrontmatter(e,t){let i=`---
|
|
434
434
|
${Jd(t,{lineWidth:-1,noRefs:!0,quoteStyle:"double"}).trim()}
|
|
435
|
-
---`,s=r.
|
|
436
|
-
${e}`}shouldSkipDirectory(e){return e.startsWith(".")}walkDirectory(e,t){let n;try{n=Cr.default.readdirSync(e,{withFileTypes:!0})}catch(i){let s=i;if(s.code==="EPERM"||s.code==="EACCES")return;throw i}n.sort((i,s)=>i.name<s.name?-1:i.name>s.name?1:0);for(let i of n){let s=fr.default.join(e,i.name);if(i.isDirectory()){if(this.shouldSkipDirectory(i.name))continue;this.walkDirectory(s,t)}else i.isFile()&&t(s)}}}});function za(r){if(r instanceof Qi.IRI)return{type:"IRI",value:r.value};if(r instanceof Qi.Literal){let e={type:"Literal",value:r.value};return r.datatype&&(e.datatype=r.datatype.value),r.language&&(e.language=r.language),e}return r instanceof Qi.BlankNode?{type:"BlankNode",value:r.id}:{type:"IRI",value:String(r)}}function wg(r){switch(r.type){case"IRI":return new Qi.IRI(r.value);case"Literal":return r.datatype?new Qi.Literal(r.value,new Qi.IRI(r.datatype)):r.language?new Qi.Literal(r.value,void 0,r.language):new Qi.Literal(r.value);case"BlankNode":return new Qi.BlankNode(r.value);default:return new Qi.IRI(r.value)}}var Qi,rP=Me(()=>{"use strict";Qi=Q(Pe());a(za,"serializeNode");a(wg,"deserializeNode")});function v8(r){let e=za(r.subject),t=za(r.predicate),n=za(r.object);return`${e.type}:${e.value}|${t.type}:${t.value}|${n.type}:${n.value}|${n.datatype??""}|${n.language??""}`}async function Eg(r){let e=new Bo.InMemoryTripleStore;await e.addAll(r);let n=await new Bo.RDFSInferenceEngine().materialize(e),i=new Bo.NonInheritablePropertyRegistry;await i.initialize(e);let s=new Bo.PropertyCardinalityRegistry;await s.initialize(e);let o=new Bo.PrototypeChainMaterializer(i,s);if(n+=await o.materialize(e),n<=0)return{inferred:[],inferredCount:0};let c=new Set;for(let f of r)c.add(v8(f));let l=await e.match(),u=[];for(let f of l)c.has(v8(f))||u.push(f);return{inferred:u,inferredCount:n}}var Bo,nP=Me(()=>{"use strict";Bo=Q(Pe());rP();a(v8,"tripleKey");a(Eg,"materializeInferredTriples")});var Ys,Yw,Cu=Me(()=>{"use strict";Ys="[a-z][a-zA-Z0-9]*(?:-[a-zA-Z0-9]+)*",Yw=new RegExp(`^${Ys}$`)});var k8={};Zu(k8,{CACHE_FORMAT_VERSION:()=>cP,CacheManager:()=>xu,DELTA_REBUILD_RATIO:()=>lP,STALE_TMP_MAX_AGE_MS:()=>O8,deserializeNode:()=>wg,diffManifest:()=>Xw,inferenceInputsChanged:()=>N8,isSafeRelativePath:()=>L8,serializeNode:()=>za});function iP(r){return r.added.length===0&&r.modified.length===0&&r.removed.length===0}function Xw(r,e){let t=[],n=[],i=[],s=new Map;for(let o of r)s.set(o.path,{mtimeMs:o.mtimeMs,size:o.size});for(let[o,c]of e){let l=s.get(o);l===void 0?t.push(o):(l.mtimeMs!==c.mtimeMs||l.size!==c.size)&&n.push(o)}for(let o of s.keys())e.has(o)||i.push(o);return{added:t,modified:n,removed:i}}function sP(r){return typeof r.basename=="string"}function T8(r){return cp.test(gi.default.basename(r,gi.default.extname(r)))}function oP(r){if(r.tboxLabel)return!0;let e=(0,ln.vaultPathToIRI)(r.path);for(let t of r.triples)if(t.subject.type==="IRI"&&t.subject.value===e&&t.predicate.type==="IRI"&&t.predicate.value.endsWith(P8)&&(t.object.type==="IRI"||t.object.type==="Literal"&&cp.test(t.object.value)))return!0;return!1}function Hye(r,e,t){for(let n of r.triples)if(n.object.type==="IRI"){if(e.has(n.object.value))return!0}else if(n.object.type==="Literal"&&t.size>0&&t.has(Kye(n.object.value)))return!0;return!1}function Kye(r){let e=r.trim();e.startsWith("[[")&&e.endsWith("]]")&&(e=e.slice(2,-2));let t=e.indexOf("|");return t>=0&&(e=e.slice(0,t)),e=e.trim().toLowerCase(),e.endsWith(".md")?e.slice(0,-3):e}function A8(r){let e=(0,ln.vaultPathToIRI)(r.path),t=new Set;for(let n of r.triples)n.subject.type==="IRI"&&n.subject.value===e&&n.predicate.type==="IRI"&&n.predicate.value.endsWith(fP)&&n.object.type==="Literal"&&t.add(n.object.value.trim().toLowerCase());return t}function Yye(r){let e=new Set;for(let t of D8(r))e.add(t.toLowerCase());return e}function D8(r){let e=r?.aliases,t=Array.isArray(e)?e:e==null?[]:[e],n=[];for(let i of t)typeof i=="string"&&i.trim()!==""&&n.push(i.trim());return n}function Xye(r){return D8(r).some(e=>cp.test(e))}function Qye(r){let e=(0,ln.vaultPathToIRI)(r.path);for(let t of r.triples)if(t.subject.type==="IRI"&&t.subject.value===e&&t.predicate.type==="IRI"&&t.predicate.value.endsWith(fP)&&(t.object.type==="IRI"||t.object.type==="Literal"&&cp.test(t.object.value.trim())))return!0;return!1}function Jye(r,e){if(r.size!==e.size)return!1;for(let t of r)if(!e.has(t))return!1;return!0}function aP(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function uP(r,e){return r.newLabel?`TBox-form asset changed: ${e}`:r.hadLabel?`asset lost its TBox-form label: ${e}`:`TBox-form alias: ${e}`}function I8(r,e){let t=(0,ln.vaultPathToIRI)(r),n=[],i=[],s=[];for(let o of e){if(o.subject.type!=="IRI"||o.subject.value!==t||o.predicate.type!=="IRI")continue;let c=o.predicate.value;c.endsWith(P8)?o.object.type==="IRI"&&n.push(o.object.value):c.endsWith(fP)?o.object.type==="IRI"&&i.push(o.object.value):c.endsWith(F8)&&s.push(`${o.object.type}:${o.object.value}|${o.object.datatype??""}|${o.object.language??""}`)}return i.sort(),{label:n,tboxAliases:i,instanceClass:s}}function Zye(r,e,t,n){let i=I8(r,e),s=I8(r,t);return aP(i.label,s.label)?aP(i.tboxAliases,s.tboxAliases)?aP(i.instanceClass,s.instanceClass)?null:`TBox-form asset class changed: ${r}`:`TBox-form alias: ${r}`:uP(n,r)}function e0e(r){if((0,ln.frontmatterDeclaresFileSpace)(r))return!0;let e=r.exo__Instance_class;return(Array.isArray(e)?e:[e]).some(n=>typeof n=="string"&&/\bexo__FileSpace\b/.test(n))}function L8(r){return r.length===0||gi.default.isAbsolute(r)||/^[a-zA-Z]:/.test(r)||/^[\\/]/.test(r)?!1:!r.split(/[\\/]/).some(e=>e==="..")}function R8(r){return r.predicate.type==="IRI"&&zye.some(e=>r.predicate.value.endsWith(e))}function C8(r){return!!r&&r.triples.some(e=>e.predicate.type==="IRI"&&e.predicate.value.endsWith(dP))}function N8(r,e,t){let n=new Map;for(let s of r.files)n.set(s.path,s);let i=new Set;for(let s of r.files)for(let o of s.triples)o.object.type==="IRI"&&o.predicate.type==="IRI"&&o.predicate.value.endsWith(dP)&&i.add(o.object.value);for(let s of t){let o=n.get(s),c=e.get(s);if(C8(o)||C8(c)||i.has((0,ln.vaultPathToIRI)(s)))return!0;let l=a(d=>`${d.subject.type}:${d.subject.value}|${d.predicate.value}|${d.object.type}:${d.object.value}`,"key"),u=(o?.triples??[]).filter(R8).map(l).sort(),f=(c?.triples??[]).filter(R8).map(l).sort();if(u.length!==f.length)return!0;for(let d=0;d<u.length;d++)if(u[d]!==f[d])return!0}return!1}var gi,x8,zr,ln,cP,lP,O8,cp,P8,fP,dP,F8,zye,xu,Qw=Me(()=>{"use strict";gi=Q(require("path")),x8=Q(require("crypto")),zr=Q(Mo()),ln=Q(Pe());Ks();rP();nP();Cu();cP=4,lP=.5,O8=600*1e3,cp=new RegExp(`^${Ys}__\\S+$`),P8="#Asset_label",fP="#Asset_aliases",dP="#Asset_prototype",F8="#Instance_class",zye=[F8,"#Class_superClass","#type",dP],xu=class r{constructor(e){this.cliVersion="1.0.0";this.loaded=null;this.loadedStamp=null;this.vaultPath=gi.default.resolve(e),this.cachePath=gi.default.join(this.vaultPath,".exocortex","cache","triples.json")}static{a(this,"CacheManager")}getCachePath(){return this.cachePath}async isCacheValid(){let e=await this.computeManifestDiff();return e!==null&&iP(e)}async computeManifestDiff(){let e=await this.readCacheData();if(!e)return null;let t=this.computeFileManifest();return t?Xw(e.files,t):null}async loadOrBuild(){let e=Date.now(),t=await this.readCacheData();if(!t)return this.rebuild(e,"cache absent, corrupt or legacy format",null);let n=this.computeFileManifest();if(!n)return this.rebuild(e,"vault could not be walked",t);let i=Xw(t.files,n);if(iP(i))return{triples:this.materializeTriples(t),explicitCount:r.explicitCountOf(t),zeroTriplePaths:r.zeroTriplePathsOf(t),cacheHit:!0,durationMs:Date.now()-e,mode:"hit",reparsedFiles:0};let s=new Ht(this.vaultPath),o=await this.planDelta(t,n,i,s);if(o.rebuildReason)return this.rebuild(e,o.rebuildReason,t);let c=await this.applyDelta(t,n,i,o.reparse,s);return{triples:c.triples,explicitCount:r.explicitCountOf(c.data),zeroTriplePaths:r.zeroTriplePathsOf(c.data),cacheHit:!0,durationMs:Date.now()-e,mode:"delta",reparsedFiles:o.reparse.length,inferredRecomputed:c.inferredRecomputed}}static explicitCountOf(e){let t=0;for(let n of e.files)t+=n.triples.length;return t}static zeroTriplePathsOf(e){let t=[];for(let n of e.files)n.triples.length===0&&t.push(n.path);return t}async refreshAfterWrite(){let e=await this.loadedIsCurrent()?this.loaded:await this.readCacheData();if(!e)return{mode:"skipped",reparsedFiles:0,reason:"no cache to refresh"};let t=new Ht(this.vaultPath),n=this.computeFileManifest(t);if(!n)return{mode:"skipped",reparsedFiles:0,reason:"vault could not be walked"};let i=Xw(e.files,n);if(iP(i))return{mode:"noop",reparsedFiles:0};let s=await this.planDelta(e,n,i,t);return s.rebuildReason?{mode:"skipped",reparsedFiles:0,reason:`rebuild needed (${s.rebuildReason}) \u2014 left to the next reader`}:(await this.applyDelta(e,n,i,s.reparse,t,{needTriples:!1}),{mode:"delta",reparsedFiles:s.reparse.length})}async rebuild(e,t,n){let i=await this.buildInternal({strict:!1,materializeInference:n?.metadata.inferenceEnabled===!0});return{triples:i.triples.concat(i.inferred),explicitCount:i.triples.length,zeroTriplePaths:r.zeroTriplePathsOf(i.data),cacheHit:!1,durationMs:Date.now()-e,mode:"rebuild",reparsedFiles:i.data.files.length,rebuildReason:t}}materializeTriples(e){let t=[];for(let n of e.files)for(let i of n.triples)t.push(this.deserializeTriple(i));for(let n of e.inferred)t.push(this.deserializeTriple(n));return t}async readCacheData(){try{if(!await zr.default.pathExists(this.cachePath))return null;let e=await this.statCache(),t=await zr.default.readJson(this.cachePath);if(!t.metadata||t.metadata.formatVersion!==cP||typeof t.metadata.tripleCount!="number"||!Array.isArray(t.files)||!Array.isArray(t.inferred))return null;for(let i of t.files)if(typeof i?.path!="string"||!L8(i.path)||typeof i.mtimeMs!="number"||typeof i.size!="number"||!Array.isArray(i.triples))return null;let n={metadata:{...t.metadata,fileSpacePrefixes:Array.isArray(t.metadata.fileSpacePrefixes)?t.metadata.fileSpacePrefixes:[],fileSpaceDeclarations:Array.isArray(t.metadata.fileSpaceDeclarations)?t.metadata.fileSpaceDeclarations:[],inferenceEnabled:typeof t.metadata.inferenceEnabled=="boolean"?t.metadata.inferenceEnabled:t.inferred.length>0},files:t.files,inferred:t.inferred};return this.loaded=n,this.loadedStamp=e,n}catch{return null}}async statCache(){try{let e=await zr.default.stat(this.cachePath);return{mtimeMs:e.mtimeMs,size:e.size}}catch{return null}}async loadedIsCurrent(){if(!this.loaded||!this.loadedStamp)return!1;let e=await this.statCache();return e!==null&&e.mtimeMs===this.loadedStamp.mtimeMs&&e.size===this.loadedStamp.size}computeFileManifest(e){try{let t=e??new Ht(this.vaultPath),n=new Map;for(let i of t.getAllFiles())try{let s=zr.default.statSync(gi.default.join(this.vaultPath,i.path));n.set(i.path,{mtimeMs:s.mtimeMs,size:s.size})}catch{}return n}catch{return null}}async planDelta(e,t,n,i){let s=n.added.length+n.modified.length+n.removed.length,o=Math.max(e.files.length,t.size,1);if(s>o*lP)return{reparse:[],rebuildReason:`${s} of ${o} files changed (> ${lP*100}%)`};let c=new Map;for(let m of e.files)c.set(m.path,m);let l=new Set(e.metadata.fileSpaceDeclarations),u=new Set,f=new Set;for(let m of n.removed){if(l.has(m))return{reparse:[],rebuildReason:`FileSpace declaration removed: ${m}`};if(T8(m))return{reparse:[],rebuildReason:`TBox-form file removed: ${m}`};let b=c.get(m);if(b&&oP(b))return{reparse:[],rebuildReason:`TBox-form asset removed: ${m}`};u.add((0,ln.vaultPathToIRI)(m))}let d=new Map;for(let m of[...n.added,...n.modified]){if(l.has(m))return{reparse:[],rebuildReason:`FileSpace declaration changed: ${m}`};if(T8(m))return{reparse:[],rebuildReason:`TBox-form file changed: ${m}`};let b=i.getAbstractFileByPath(m),_=b&&sP(b)?b:null,S=_?i.getFrontmatter(_):null;if(S&&e0e(S))return{reparse:[],rebuildReason:`FileSpace declaration changed: ${m}`};d.set(m,{file:_,frontmatter:S})}let p=null;for(let[m,{file:b,frontmatter:_}]of d){let S=c.get(m),A=_?.exo__Asset_label,w={newLabel:typeof A=="string"&&cp.test(A),hadLabel:S!==void 0&&oP(S),newAlias:Xye(_),hadAlias:S!==void 0&&Qye(S)},E;if(w.newLabel||w.hadLabel||w.newAlias||w.hadAlias){if(!S||S.triples.length===0||!b)return{reparse:[],rebuildReason:uP(w,m)};p??=new ln.NoteToRDFConverter(i);let x;try{x=(await p.convertNote(b)).map(this.serializeTriple)}catch{return{reparse:[],rebuildReason:uP(w,m)}}let P=Zye(m,S.triples,x,w);if(P)return{reparse:[],rebuildReason:P};E=A8({path:m,mtimeMs:0,size:0,triples:x})}else E=Yye(_);let R=S?A8(S):new Set;if(S&&!Jye(R,E)){let x=!1;for(let P of R)E.has(P)||(f.add(P),x=!0);for(let P of E)R.has(P)||f.add(P);x&&u.add((0,ln.vaultPathToIRI)(m))}if(!S)for(let x of E)f.add(x)}for(let m of n.added){let b=gi.default.basename(m);u.add((0,ln.vaultPathToIRI)(b)),f.add(gi.default.basename(m,gi.default.extname(m)).toLowerCase())}let h=new Set([...n.added,...n.modified]),g=new Set(n.removed);if(u.size>0||f.size>0)for(let m of e.files)h.has(m.path)||g.has(m.path)||Hye(m,u,f)&&h.add(m.path);return{reparse:[...h]}}async applyDelta(e,t,n,i,s,o={needTriples:!0}){let c=[];for(let R of i){let x=s.getAbstractFileByPath(R);x&&sP(x)&&c.push(x)}let l=new Map;await new ln.NoteToRDFConverter(s).convertVaultWithValidation({strict:!1,files:c,fileSpacePrefixes:e.metadata.fileSpacePrefixes,onFileTriples:a((R,x)=>{l.set(R.path,x)},"onFileTriples")});let f=new Set(i),d=new Set(n.removed),p=a(R=>this.makeEntry(R,t,l.get(R)??[],s),"makeEntry"),h=[];for(let R of e.files)d.has(R.path)||h.push(f.has(R.path)?p(R.path):R);let g=new Set(h.map(R=>R.path));for(let R of t.keys())g.has(R)||h.push(p(R));let m=null,b=a(()=>{if(m===null){m=[];for(let R of h)for(let x of R.triples)m.push(this.deserializeTriple(x))}return m},"explicitTriples"),_=[],S=[],A=!1;if(e.metadata.inferenceEnabled){let R=new Map;for(let x of h)R.set(x.path,x);N8(e,R,[...f,...d])?(S=(await Eg(b())).inferred,_=S.map(this.serializeTriple),A=!0):(_=e.inferred,o.needTriples&&(S=e.inferred.map(this.deserializeTriple)))}let w=this.assembleCacheData(h,_,{fileSpacePrefixes:e.metadata.fileSpacePrefixes,fileSpaceDeclarations:e.metadata.fileSpaceDeclarations,inferenceEnabled:e.metadata.inferenceEnabled});await this.writeCacheData(w);let E=o.needTriples?b().concat(S):[];return{data:w,triples:E,inferredRecomputed:A}}makeEntry(e,t,n,i){let s=t.get(e),o={path:e,mtimeMs:s?.mtimeMs??0,size:s?.size??0,triples:n.map(this.serializeTriple)},c=oP(o);if(!c&&n.length===0){let l=i.getAbstractFileByPath(e),f=(l&&sP(l)?i.getFrontmatter(l):null)?.exo__Asset_label;c=typeof f=="string"&&cp.test(f)}return c&&(o.tboxLabel=!0),o}async buildCache(){let e=await this.buildCacheWithValidation({strict:!1});return{tripleCount:e.tripleCount,durationMs:e.durationMs}}async buildCacheWithValidation(e={}){return(await this.buildInternal(e)).result}async buildInternal(e){let t=Date.now(),n=new Ht(this.vaultPath),i=n.getAllFiles(),s=new Map;for(let h of i)try{let g=zr.default.statSync(gi.default.join(this.vaultPath,h.path));s.set(h.path,{mtimeMs:g.mtimeMs,size:g.size})}catch{}let o=new Map,l=await new ln.NoteToRDFConverter(n).convertVaultWithValidation({strict:e.strict??!1,files:i,onFileTriples:a((h,g)=>{o.set(h.path,g)},"onFileTriples")}),u=[];for(let h of i)s.has(h.path)&&u.push(this.makeEntry(h.path,s,o.get(h.path)??[],n));let f=[];for(let h of i){if(!s.has(h.path))continue;let g=o.get(h.path);g&&f.push(...g)}let d=[];e.materializeInference&&(d=(await Eg(f)).inferred);let p=this.assembleCacheData(u,d.map(this.serializeTriple),{fileSpacePrefixes:l.fileSpaces?.prefixes??[],fileSpaceDeclarations:l.fileSpaces?.declarationPaths??[],inferenceEnabled:e.materializeInference===!0});return await this.writeCacheData(p),{result:{tripleCount:l.triples.length,durationMs:Date.now()-t,skippedFiles:l.skippedFiles,summary:l.summary},data:p,triples:f,inferred:d}}async validateVault(){let e=new Ht(this.vaultPath);return new ln.NoteToRDFConverter(e).validateVault()}async invalidate(){await zr.default.pathExists(this.cachePath)&&await zr.default.remove(this.cachePath),await this.removeStaleTempFiles()}async removeStaleTempFiles(){let e=gi.default.dirname(this.cachePath),t=`${gi.default.basename(this.cachePath)}.`,n;try{n=await zr.default.readdir(e)}catch{return}let i=Date.now()-O8;for(let s of n){if(!s.startsWith(t)||!s.endsWith(".tmp"))continue;let o=gi.default.join(e,s);try{(await zr.default.stat(o)).mtimeMs<i&&await zr.default.remove(o)}catch{}}}async getCacheStats(){try{if(!await zr.default.pathExists(this.cachePath))return null;let e=await this.readCacheData();if(!e){let i=await zr.default.stat(this.cachePath);return{tripleCount:0,createdAt:new Date(i.mtimeMs),isValid:!1,sizeBytes:i.size}}let t=await zr.default.stat(this.cachePath),n=await this.isCacheValid();return{tripleCount:e.metadata.tripleCount,createdAt:new Date(e.metadata.timestamp),isValid:n,sizeBytes:t.size}}catch{return null}}async saveInferredTriples(e){let t=await this.readCacheData();if(!t)throw new Error(`Cannot save inferred triples: no valid cache at ${this.cachePath} (build the cache first)`);let n=this.assembleCacheData(t.files,e.map(this.serializeTriple),{fileSpacePrefixes:t.metadata.fileSpacePrefixes,fileSpaceDeclarations:t.metadata.fileSpaceDeclarations,inferenceEnabled:!0});await this.writeCacheData(n)}assembleCacheData(e,t,n){let i=0;for(let s of e)i+=s.triples.length;return{metadata:{version:this.cliVersion,timestamp:Date.now(),vaultPath:this.vaultPath,tripleCount:i+t.length,formatVersion:cP,fileCount:e.length,inferredCount:t.length,fileSpacePrefixes:n.fileSpacePrefixes,fileSpaceDeclarations:n.fileSpaceDeclarations,inferenceEnabled:n.inferenceEnabled},files:e,inferred:t}}async writeCacheData(e){await zr.default.ensureDir(gi.default.dirname(this.cachePath)),await this.removeStaleTempFiles();let t=`${this.cachePath}.${process.pid}.${x8.default.randomBytes(6).toString("hex")}.tmp`;try{await zr.default.writeJson(t,e,{spaces:0});let n=await zr.default.stat(t);await zr.default.rename(t,this.cachePath),this.loaded=e,this.loadedStamp={mtimeMs:n.mtimeMs,size:n.size}}catch(n){throw await zr.default.remove(t).catch(()=>{}),n}}serializeTriple(e){return{subject:za(e.subject),predicate:za(e.predicate),object:za(e.object)}}deserializeTriple(e){return new ln.Triple(wg(e.subject),wg(e.predicate),wg(e.object))}};a(iP,"isEmptyDiff");a(Xw,"diffManifest");a(sP,"isFile");a(T8,"isTBoxBasename");a(oP,"entryHasTBoxLabel");a(Hye,"entryRefersTo");a(Kye,"linkpathOf");a(A8,"entryAliases");a(Yye,"frontmatterAliases");a(D8,"rawFrontmatterAliases");a(Xye,"frontmatterHasTBoxFormAlias");a(Qye,"entryHasTBoxFormAlias");a(Jye,"sameSet");a(aP,"sameList");a(uP,"tboxRebuildReason");a(I8,"tboxProjection");a(Zye,"tboxProjectionChanged");a(e0e,"frontmatterDeclaresFileSpaceAnyForm");a(L8,"isSafeRelativePath");a(R8,"isInferenceRelevant");a(C8,"hasPrototype");a(N8,"inferenceInputsChanged")});var j8={};Zu(j8,{SKIPPED_FILES_NOTICE_LIMIT:()=>hP,cacheLoadNotice:()=>Ou,loadVaultTriples:()=>yi,skippedFilesNotice:()=>Pu,targetSkippedNotice:()=>vg,writeThroughCache:()=>mP,writeThroughNotice:()=>gP});async function yi(r,e){if(e.useCache){let u=e.cacheManager??new xu(r),f=pP.default.join(pP.default.resolve(r),".exocortex","cache","triples.json");if(u.getCachePath()!==f)throw new Error(`loadVaultTriples: the given CacheManager belongs to ${u.getCachePath()}, not to vault ${r}`);let d=await u.loadOrBuild();return{triples:d.triples,cacheHit:d.cacheHit,mode:d.mode,reparsedFiles:d.reparsedFiles,cacheManager:u,explicitCount:d.explicitCount,zeroTriplePaths:d.zeroTriplePaths}}let t=e.vaultAdapter??new Ht(r),n=new M8.NoteToRDFConverter(t),i=t.getAllFiles(),s=new Map,o=await n.convertVaultWithValidation({strict:!1,onFileTriples:a((u,f)=>{s.set(u.path,f.length)},"onFileTriples")}),c=o.triples,l=i.filter(u=>(s.get(u.path)??0)===0).map(u=>u.path);return{triples:c,cacheHit:!1,mode:"full-parse",explicitCount:c.length,zeroTriplePaths:l,skippedFiles:o.skippedFiles}}function Ou(r){switch(r.mode){case"hit":return"\u26A1 triple cache: hit";case"delta":return`\u267B\uFE0F triple cache: delta (${r.reparsedFiles??0} file(s) re-parsed)`;case"rebuild":{let e=r.triples.length-r.explicitCount,t=e>0?` + inferred layer (${e})`:"";return`\u{1F528} triple cache: rebuild (${r.reparsedFiles??0} file(s) parsed, cache written${t})`}default:return"triple cache: not used (full parse)"}}function Pu(r){let e=r.skippedFiles;if(e!==void 0){if(e.length===0)return null;let t=[`\u26A0\uFE0F ${e.length} file(s) skipped by the vault loader \u2014 they contributed no triples:`];for(let i of e.slice(0,hP))t.push(` - ${i.path}`),t.push(` ${i.reason}`);let n=e.length-hP;return n>0&&t.push(` \u2026 and ${n} more \u2014 run 'index' to see them all`),t.join(`
|
|
435
|
+
---`,s=r.matchFrontmatterBlock(e);if(s)return e.slice(0,s.blockStart)+i+e.slice(s.blockEnd);let o=r.bomLength(e);return e.slice(0,o)+`${i}
|
|
436
|
+
`+e.slice(o)}shouldSkipDirectory(e){return e.startsWith(".")}walkDirectory(e,t){let n;try{n=Cr.default.readdirSync(e,{withFileTypes:!0})}catch(i){let s=i;if(s.code==="EPERM"||s.code==="EACCES")return;throw i}n.sort((i,s)=>i.name<s.name?-1:i.name>s.name?1:0);for(let i of n){let s=fr.default.join(e,i.name);if(i.isDirectory()){if(this.shouldSkipDirectory(i.name))continue;this.walkDirectory(s,t)}else i.isFile()&&t(s)}}}});function za(r){if(r instanceof Qi.IRI)return{type:"IRI",value:r.value};if(r instanceof Qi.Literal){let e={type:"Literal",value:r.value};return r.datatype&&(e.datatype=r.datatype.value),r.language&&(e.language=r.language),e}return r instanceof Qi.BlankNode?{type:"BlankNode",value:r.id}:{type:"IRI",value:String(r)}}function wg(r){switch(r.type){case"IRI":return new Qi.IRI(r.value);case"Literal":return r.datatype?new Qi.Literal(r.value,new Qi.IRI(r.datatype)):r.language?new Qi.Literal(r.value,void 0,r.language):new Qi.Literal(r.value);case"BlankNode":return new Qi.BlankNode(r.value);default:return new Qi.IRI(r.value)}}var Qi,rP=Me(()=>{"use strict";Qi=Q(Pe());a(za,"serializeNode");a(wg,"deserializeNode")});function v8(r){let e=za(r.subject),t=za(r.predicate),n=za(r.object);return`${e.type}:${e.value}|${t.type}:${t.value}|${n.type}:${n.value}|${n.datatype??""}|${n.language??""}`}async function Eg(r){let e=new Bo.InMemoryTripleStore;await e.addAll(r);let n=await new Bo.RDFSInferenceEngine().materialize(e),i=new Bo.NonInheritablePropertyRegistry;await i.initialize(e);let s=new Bo.PropertyCardinalityRegistry;await s.initialize(e);let o=new Bo.PrototypeChainMaterializer(i,s);if(n+=await o.materialize(e),n<=0)return{inferred:[],inferredCount:0};let c=new Set;for(let f of r)c.add(v8(f));let l=await e.match(),u=[];for(let f of l)c.has(v8(f))||u.push(f);return{inferred:u,inferredCount:n}}var Bo,nP=Me(()=>{"use strict";Bo=Q(Pe());rP();a(v8,"tripleKey");a(Eg,"materializeInferredTriples")});var Ys,Yw,Cu=Me(()=>{"use strict";Ys="[a-z][a-zA-Z0-9]*(?:-[a-zA-Z0-9]+)*",Yw=new RegExp(`^${Ys}$`)});var k8={};Zu(k8,{CACHE_FORMAT_VERSION:()=>cP,CacheManager:()=>xu,DELTA_REBUILD_RATIO:()=>lP,STALE_TMP_MAX_AGE_MS:()=>O8,deserializeNode:()=>wg,diffManifest:()=>Xw,inferenceInputsChanged:()=>N8,isSafeRelativePath:()=>L8,serializeNode:()=>za});function iP(r){return r.added.length===0&&r.modified.length===0&&r.removed.length===0}function Xw(r,e){let t=[],n=[],i=[],s=new Map;for(let o of r)s.set(o.path,{mtimeMs:o.mtimeMs,size:o.size});for(let[o,c]of e){let l=s.get(o);l===void 0?t.push(o):(l.mtimeMs!==c.mtimeMs||l.size!==c.size)&&n.push(o)}for(let o of s.keys())e.has(o)||i.push(o);return{added:t,modified:n,removed:i}}function sP(r){return typeof r.basename=="string"}function T8(r){return cp.test(gi.default.basename(r,gi.default.extname(r)))}function oP(r){if(r.tboxLabel)return!0;let e=(0,ln.vaultPathToIRI)(r.path);for(let t of r.triples)if(t.subject.type==="IRI"&&t.subject.value===e&&t.predicate.type==="IRI"&&t.predicate.value.endsWith(P8)&&(t.object.type==="IRI"||t.object.type==="Literal"&&cp.test(t.object.value)))return!0;return!1}function Hye(r,e,t){for(let n of r.triples)if(n.object.type==="IRI"){if(e.has(n.object.value))return!0}else if(n.object.type==="Literal"&&t.size>0&&t.has(Kye(n.object.value)))return!0;return!1}function Kye(r){let e=r.trim();e.startsWith("[[")&&e.endsWith("]]")&&(e=e.slice(2,-2));let t=e.indexOf("|");return t>=0&&(e=e.slice(0,t)),e=e.trim().toLowerCase(),e.endsWith(".md")?e.slice(0,-3):e}function A8(r){let e=(0,ln.vaultPathToIRI)(r.path),t=new Set;for(let n of r.triples)n.subject.type==="IRI"&&n.subject.value===e&&n.predicate.type==="IRI"&&n.predicate.value.endsWith(fP)&&n.object.type==="Literal"&&t.add(n.object.value.trim().toLowerCase());return t}function Yye(r){let e=new Set;for(let t of D8(r))e.add(t.toLowerCase());return e}function D8(r){let e=r?.aliases,t=Array.isArray(e)?e:e==null?[]:[e],n=[];for(let i of t)typeof i=="string"&&i.trim()!==""&&n.push(i.trim());return n}function Xye(r){return D8(r).some(e=>cp.test(e))}function Qye(r){let e=(0,ln.vaultPathToIRI)(r.path);for(let t of r.triples)if(t.subject.type==="IRI"&&t.subject.value===e&&t.predicate.type==="IRI"&&t.predicate.value.endsWith(fP)&&(t.object.type==="IRI"||t.object.type==="Literal"&&cp.test(t.object.value.trim())))return!0;return!1}function Jye(r,e){if(r.size!==e.size)return!1;for(let t of r)if(!e.has(t))return!1;return!0}function aP(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function uP(r,e){return r.newLabel?`TBox-form asset changed: ${e}`:r.hadLabel?`asset lost its TBox-form label: ${e}`:`TBox-form alias: ${e}`}function I8(r,e){let t=(0,ln.vaultPathToIRI)(r),n=[],i=[],s=[];for(let o of e){if(o.subject.type!=="IRI"||o.subject.value!==t||o.predicate.type!=="IRI")continue;let c=o.predicate.value;c.endsWith(P8)?o.object.type==="IRI"&&n.push(o.object.value):c.endsWith(fP)?o.object.type==="IRI"&&i.push(o.object.value):c.endsWith(F8)&&s.push(`${o.object.type}:${o.object.value}|${o.object.datatype??""}|${o.object.language??""}`)}return i.sort(),{label:n,tboxAliases:i,instanceClass:s}}function Zye(r,e,t,n){let i=I8(r,e),s=I8(r,t);return aP(i.label,s.label)?aP(i.tboxAliases,s.tboxAliases)?aP(i.instanceClass,s.instanceClass)?null:`TBox-form asset class changed: ${r}`:`TBox-form alias: ${r}`:uP(n,r)}function e0e(r){if((0,ln.frontmatterDeclaresFileSpace)(r))return!0;let e=r.exo__Instance_class;return(Array.isArray(e)?e:[e]).some(n=>typeof n=="string"&&/\bexo__FileSpace\b/.test(n))}function L8(r){return r.length===0||gi.default.isAbsolute(r)||/^[a-zA-Z]:/.test(r)||/^[\\/]/.test(r)?!1:!r.split(/[\\/]/).some(e=>e==="..")}function R8(r){return r.predicate.type==="IRI"&&zye.some(e=>r.predicate.value.endsWith(e))}function C8(r){return!!r&&r.triples.some(e=>e.predicate.type==="IRI"&&e.predicate.value.endsWith(dP))}function N8(r,e,t){let n=new Map;for(let s of r.files)n.set(s.path,s);let i=new Set;for(let s of r.files)for(let o of s.triples)o.object.type==="IRI"&&o.predicate.type==="IRI"&&o.predicate.value.endsWith(dP)&&i.add(o.object.value);for(let s of t){let o=n.get(s),c=e.get(s);if(C8(o)||C8(c)||i.has((0,ln.vaultPathToIRI)(s)))return!0;let l=a(d=>`${d.subject.type}:${d.subject.value}|${d.predicate.value}|${d.object.type}:${d.object.value}`,"key"),u=(o?.triples??[]).filter(R8).map(l).sort(),f=(c?.triples??[]).filter(R8).map(l).sort();if(u.length!==f.length)return!0;for(let d=0;d<u.length;d++)if(u[d]!==f[d])return!0}return!1}var gi,x8,zr,ln,cP,lP,O8,cp,P8,fP,dP,F8,zye,xu,Qw=Me(()=>{"use strict";gi=Q(require("path")),x8=Q(require("crypto")),zr=Q(Mo()),ln=Q(Pe());Ks();rP();nP();Cu();cP=4,lP=.5,O8=600*1e3,cp=new RegExp(`^${Ys}__\\S+$`),P8="#Asset_label",fP="#Asset_aliases",dP="#Asset_prototype",F8="#Instance_class",zye=[F8,"#Class_superClass","#type",dP],xu=class r{constructor(e){this.cliVersion="1.0.0";this.loaded=null;this.loadedStamp=null;this.vaultPath=gi.default.resolve(e),this.cachePath=gi.default.join(this.vaultPath,".exocortex","cache","triples.json")}static{a(this,"CacheManager")}getCachePath(){return this.cachePath}async isCacheValid(){let e=await this.computeManifestDiff();return e!==null&&iP(e)}async computeManifestDiff(){let e=await this.readCacheData();if(!e)return null;let t=this.computeFileManifest();return t?Xw(e.files,t):null}async loadOrBuild(){let e=Date.now(),t=await this.readCacheData();if(!t)return this.rebuild(e,"cache absent, corrupt or legacy format",null);let n=this.computeFileManifest();if(!n)return this.rebuild(e,"vault could not be walked",t);let i=Xw(t.files,n);if(iP(i))return{triples:this.materializeTriples(t),explicitCount:r.explicitCountOf(t),zeroTriplePaths:r.zeroTriplePathsOf(t),cacheHit:!0,durationMs:Date.now()-e,mode:"hit",reparsedFiles:0};let s=new Ht(this.vaultPath),o=await this.planDelta(t,n,i,s);if(o.rebuildReason)return this.rebuild(e,o.rebuildReason,t);let c=await this.applyDelta(t,n,i,o.reparse,s);return{triples:c.triples,explicitCount:r.explicitCountOf(c.data),zeroTriplePaths:r.zeroTriplePathsOf(c.data),cacheHit:!0,durationMs:Date.now()-e,mode:"delta",reparsedFiles:o.reparse.length,inferredRecomputed:c.inferredRecomputed}}static explicitCountOf(e){let t=0;for(let n of e.files)t+=n.triples.length;return t}static zeroTriplePathsOf(e){let t=[];for(let n of e.files)n.triples.length===0&&t.push(n.path);return t}async refreshAfterWrite(){let e=await this.loadedIsCurrent()?this.loaded:await this.readCacheData();if(!e)return{mode:"skipped",reparsedFiles:0,reason:"no cache to refresh"};let t=new Ht(this.vaultPath),n=this.computeFileManifest(t);if(!n)return{mode:"skipped",reparsedFiles:0,reason:"vault could not be walked"};let i=Xw(e.files,n);if(iP(i))return{mode:"noop",reparsedFiles:0};let s=await this.planDelta(e,n,i,t);return s.rebuildReason?{mode:"skipped",reparsedFiles:0,reason:`rebuild needed (${s.rebuildReason}) \u2014 left to the next reader`}:(await this.applyDelta(e,n,i,s.reparse,t,{needTriples:!1}),{mode:"delta",reparsedFiles:s.reparse.length})}async rebuild(e,t,n){let i=await this.buildInternal({strict:!1,materializeInference:n?.metadata.inferenceEnabled===!0});return{triples:i.triples.concat(i.inferred),explicitCount:i.triples.length,zeroTriplePaths:r.zeroTriplePathsOf(i.data),cacheHit:!1,durationMs:Date.now()-e,mode:"rebuild",reparsedFiles:i.data.files.length,rebuildReason:t}}materializeTriples(e){let t=[];for(let n of e.files)for(let i of n.triples)t.push(this.deserializeTriple(i));for(let n of e.inferred)t.push(this.deserializeTriple(n));return t}async readCacheData(){try{if(!await zr.default.pathExists(this.cachePath))return null;let e=await this.statCache(),t=await zr.default.readJson(this.cachePath);if(!t.metadata||t.metadata.formatVersion!==cP||typeof t.metadata.tripleCount!="number"||!Array.isArray(t.files)||!Array.isArray(t.inferred))return null;for(let i of t.files)if(typeof i?.path!="string"||!L8(i.path)||typeof i.mtimeMs!="number"||typeof i.size!="number"||!Array.isArray(i.triples))return null;let n={metadata:{...t.metadata,fileSpacePrefixes:Array.isArray(t.metadata.fileSpacePrefixes)?t.metadata.fileSpacePrefixes:[],fileSpaceDeclarations:Array.isArray(t.metadata.fileSpaceDeclarations)?t.metadata.fileSpaceDeclarations:[],inferenceEnabled:typeof t.metadata.inferenceEnabled=="boolean"?t.metadata.inferenceEnabled:t.inferred.length>0},files:t.files,inferred:t.inferred};return this.loaded=n,this.loadedStamp=e,n}catch{return null}}async statCache(){try{let e=await zr.default.stat(this.cachePath);return{mtimeMs:e.mtimeMs,size:e.size}}catch{return null}}async loadedIsCurrent(){if(!this.loaded||!this.loadedStamp)return!1;let e=await this.statCache();return e!==null&&e.mtimeMs===this.loadedStamp.mtimeMs&&e.size===this.loadedStamp.size}computeFileManifest(e){try{let t=e??new Ht(this.vaultPath),n=new Map;for(let i of t.getAllFiles())try{let s=zr.default.statSync(gi.default.join(this.vaultPath,i.path));n.set(i.path,{mtimeMs:s.mtimeMs,size:s.size})}catch{}return n}catch{return null}}async planDelta(e,t,n,i){let s=n.added.length+n.modified.length+n.removed.length,o=Math.max(e.files.length,t.size,1);if(s>o*lP)return{reparse:[],rebuildReason:`${s} of ${o} files changed (> ${lP*100}%)`};let c=new Map;for(let m of e.files)c.set(m.path,m);let l=new Set(e.metadata.fileSpaceDeclarations),u=new Set,f=new Set;for(let m of n.removed){if(l.has(m))return{reparse:[],rebuildReason:`FileSpace declaration removed: ${m}`};if(T8(m))return{reparse:[],rebuildReason:`TBox-form file removed: ${m}`};let b=c.get(m);if(b&&oP(b))return{reparse:[],rebuildReason:`TBox-form asset removed: ${m}`};u.add((0,ln.vaultPathToIRI)(m))}let d=new Map;for(let m of[...n.added,...n.modified]){if(l.has(m))return{reparse:[],rebuildReason:`FileSpace declaration changed: ${m}`};if(T8(m))return{reparse:[],rebuildReason:`TBox-form file changed: ${m}`};let b=i.getAbstractFileByPath(m),_=b&&sP(b)?b:null,S=_?i.getFrontmatter(_):null;if(S&&e0e(S))return{reparse:[],rebuildReason:`FileSpace declaration changed: ${m}`};d.set(m,{file:_,frontmatter:S})}let p=null;for(let[m,{file:b,frontmatter:_}]of d){let S=c.get(m),A=_?.exo__Asset_label,w={newLabel:typeof A=="string"&&cp.test(A),hadLabel:S!==void 0&&oP(S),newAlias:Xye(_),hadAlias:S!==void 0&&Qye(S)},E;if(w.newLabel||w.hadLabel||w.newAlias||w.hadAlias){if(!S||S.triples.length===0||!b)return{reparse:[],rebuildReason:uP(w,m)};p??=new ln.NoteToRDFConverter(i);let x;try{x=(await p.convertNote(b)).map(this.serializeTriple)}catch{return{reparse:[],rebuildReason:uP(w,m)}}let P=Zye(m,S.triples,x,w);if(P)return{reparse:[],rebuildReason:P};E=A8({path:m,mtimeMs:0,size:0,triples:x})}else E=Yye(_);let R=S?A8(S):new Set;if(S&&!Jye(R,E)){let x=!1;for(let P of R)E.has(P)||(f.add(P),x=!0);for(let P of E)R.has(P)||f.add(P);x&&u.add((0,ln.vaultPathToIRI)(m))}if(!S)for(let x of E)f.add(x)}for(let m of n.added){let b=gi.default.basename(m);u.add((0,ln.vaultPathToIRI)(b)),f.add(gi.default.basename(m,gi.default.extname(m)).toLowerCase())}let h=new Set([...n.added,...n.modified]),g=new Set(n.removed);if(u.size>0||f.size>0)for(let m of e.files)h.has(m.path)||g.has(m.path)||Hye(m,u,f)&&h.add(m.path);return{reparse:[...h]}}async applyDelta(e,t,n,i,s,o={needTriples:!0}){let c=[];for(let R of i){let x=s.getAbstractFileByPath(R);x&&sP(x)&&c.push(x)}let l=new Map;await new ln.NoteToRDFConverter(s).convertVaultWithValidation({strict:!1,files:c,fileSpacePrefixes:e.metadata.fileSpacePrefixes,onFileTriples:a((R,x)=>{l.set(R.path,x)},"onFileTriples")});let f=new Set(i),d=new Set(n.removed),p=a(R=>this.makeEntry(R,t,l.get(R)??[],s),"makeEntry"),h=[];for(let R of e.files)d.has(R.path)||h.push(f.has(R.path)?p(R.path):R);let g=new Set(h.map(R=>R.path));for(let R of t.keys())g.has(R)||h.push(p(R));let m=null,b=a(()=>{if(m===null){m=[];for(let R of h)for(let x of R.triples)m.push(this.deserializeTriple(x))}return m},"explicitTriples"),_=[],S=[],A=!1;if(e.metadata.inferenceEnabled){let R=new Map;for(let x of h)R.set(x.path,x);N8(e,R,[...f,...d])?(S=(await Eg(b())).inferred,_=S.map(this.serializeTriple),A=!0):(_=e.inferred,o.needTriples&&(S=e.inferred.map(this.deserializeTriple)))}let w=this.assembleCacheData(h,_,{fileSpacePrefixes:e.metadata.fileSpacePrefixes,fileSpaceDeclarations:e.metadata.fileSpaceDeclarations,inferenceEnabled:e.metadata.inferenceEnabled});await this.writeCacheData(w);let E=o.needTriples?b().concat(S):[];return{data:w,triples:E,inferredRecomputed:A}}makeEntry(e,t,n,i){let s=t.get(e),o={path:e,mtimeMs:s?.mtimeMs??0,size:s?.size??0,triples:n.map(this.serializeTriple)},c=oP(o);if(!c&&n.length===0){let l=i.getAbstractFileByPath(e),f=(l&&sP(l)?i.getFrontmatter(l):null)?.exo__Asset_label;c=typeof f=="string"&&cp.test(f)}return c&&(o.tboxLabel=!0),o}async buildCache(){let e=await this.buildCacheWithValidation({strict:!1});return{tripleCount:e.tripleCount,durationMs:e.durationMs}}async buildCacheWithValidation(e={}){return(await this.buildInternal(e)).result}async buildInternal(e){let t=Date.now(),n=new Ht(this.vaultPath),i=n.getAllFiles(),s=new Map;for(let h of i)try{let g=zr.default.statSync(gi.default.join(this.vaultPath,h.path));s.set(h.path,{mtimeMs:g.mtimeMs,size:g.size})}catch{}let o=new Map,l=await new ln.NoteToRDFConverter(n).convertVaultWithValidation({strict:e.strict??!1,files:i,onFileTriples:a((h,g)=>{o.set(h.path,g)},"onFileTriples")}),u=[];for(let h of i)s.has(h.path)&&u.push(this.makeEntry(h.path,s,o.get(h.path)??[],n));let f=[];for(let h of i){if(!s.has(h.path))continue;let g=o.get(h.path);g&&f.push(...g)}let d=[];e.materializeInference&&(d=(await Eg(f)).inferred);let p=this.assembleCacheData(u,d.map(this.serializeTriple),{fileSpacePrefixes:l.fileSpaces?.prefixes??[],fileSpaceDeclarations:l.fileSpaces?.declarationPaths??[],inferenceEnabled:e.materializeInference===!0});return await this.writeCacheData(p),{result:{tripleCount:l.triples.length,durationMs:Date.now()-t,skippedFiles:l.skippedFiles,summary:l.summary},data:p,triples:f,inferred:d}}async validateVault(){let e=new Ht(this.vaultPath);return new ln.NoteToRDFConverter(e).validateVault()}async invalidate(){await zr.default.pathExists(this.cachePath)&&await zr.default.remove(this.cachePath),await this.removeStaleTempFiles()}async removeStaleTempFiles(){let e=gi.default.dirname(this.cachePath),t=`${gi.default.basename(this.cachePath)}.`,n;try{n=await zr.default.readdir(e)}catch{return}let i=Date.now()-O8;for(let s of n){if(!s.startsWith(t)||!s.endsWith(".tmp"))continue;let o=gi.default.join(e,s);try{(await zr.default.stat(o)).mtimeMs<i&&await zr.default.remove(o)}catch{}}}async getCacheStats(){try{if(!await zr.default.pathExists(this.cachePath))return null;let e=await this.readCacheData();if(!e){let i=await zr.default.stat(this.cachePath);return{tripleCount:0,createdAt:new Date(i.mtimeMs),isValid:!1,sizeBytes:i.size}}let t=await zr.default.stat(this.cachePath),n=await this.isCacheValid();return{tripleCount:e.metadata.tripleCount,createdAt:new Date(e.metadata.timestamp),isValid:n,sizeBytes:t.size}}catch{return null}}async saveInferredTriples(e){let t=await this.readCacheData();if(!t)throw new Error(`Cannot save inferred triples: no valid cache at ${this.cachePath} (build the cache first)`);let n=this.assembleCacheData(t.files,e.map(this.serializeTriple),{fileSpacePrefixes:t.metadata.fileSpacePrefixes,fileSpaceDeclarations:t.metadata.fileSpaceDeclarations,inferenceEnabled:!0});await this.writeCacheData(n)}assembleCacheData(e,t,n){let i=0;for(let s of e)i+=s.triples.length;return{metadata:{version:this.cliVersion,timestamp:Date.now(),vaultPath:this.vaultPath,tripleCount:i+t.length,formatVersion:cP,fileCount:e.length,inferredCount:t.length,fileSpacePrefixes:n.fileSpacePrefixes,fileSpaceDeclarations:n.fileSpaceDeclarations,inferenceEnabled:n.inferenceEnabled},files:e,inferred:t}}async writeCacheData(e){await zr.default.ensureDir(gi.default.dirname(this.cachePath)),await this.removeStaleTempFiles();let t=`${this.cachePath}.${process.pid}.${x8.default.randomBytes(6).toString("hex")}.tmp`;try{await zr.default.writeJson(t,e,{spaces:0});let n=await zr.default.stat(t);await zr.default.rename(t,this.cachePath),this.loaded=e,this.loadedStamp={mtimeMs:n.mtimeMs,size:n.size}}catch(n){throw await zr.default.remove(t).catch(()=>{}),n}}serializeTriple(e){return{subject:za(e.subject),predicate:za(e.predicate),object:za(e.object)}}deserializeTriple(e){return new ln.Triple(wg(e.subject),wg(e.predicate),wg(e.object))}};a(iP,"isEmptyDiff");a(Xw,"diffManifest");a(sP,"isFile");a(T8,"isTBoxBasename");a(oP,"entryHasTBoxLabel");a(Hye,"entryRefersTo");a(Kye,"linkpathOf");a(A8,"entryAliases");a(Yye,"frontmatterAliases");a(D8,"rawFrontmatterAliases");a(Xye,"frontmatterHasTBoxFormAlias");a(Qye,"entryHasTBoxFormAlias");a(Jye,"sameSet");a(aP,"sameList");a(uP,"tboxRebuildReason");a(I8,"tboxProjection");a(Zye,"tboxProjectionChanged");a(e0e,"frontmatterDeclaresFileSpaceAnyForm");a(L8,"isSafeRelativePath");a(R8,"isInferenceRelevant");a(C8,"hasPrototype");a(N8,"inferenceInputsChanged")});var j8={};Zu(j8,{SKIPPED_FILES_NOTICE_LIMIT:()=>hP,cacheLoadNotice:()=>Ou,loadVaultTriples:()=>yi,skippedFilesNotice:()=>Pu,targetSkippedNotice:()=>vg,writeThroughCache:()=>mP,writeThroughNotice:()=>gP});async function yi(r,e){if(e.useCache){let u=e.cacheManager??new xu(r),f=pP.default.join(pP.default.resolve(r),".exocortex","cache","triples.json");if(u.getCachePath()!==f)throw new Error(`loadVaultTriples: the given CacheManager belongs to ${u.getCachePath()}, not to vault ${r}`);let d=await u.loadOrBuild();return{triples:d.triples,cacheHit:d.cacheHit,mode:d.mode,reparsedFiles:d.reparsedFiles,cacheManager:u,explicitCount:d.explicitCount,zeroTriplePaths:d.zeroTriplePaths}}let t=e.vaultAdapter??new Ht(r),n=new M8.NoteToRDFConverter(t),i=t.getAllFiles(),s=new Map,o=await n.convertVaultWithValidation({strict:!1,onFileTriples:a((u,f)=>{s.set(u.path,f.length)},"onFileTriples")}),c=o.triples,l=i.filter(u=>(s.get(u.path)??0)===0).map(u=>u.path);return{triples:c,cacheHit:!1,mode:"full-parse",explicitCount:c.length,zeroTriplePaths:l,skippedFiles:o.skippedFiles}}function Ou(r){switch(r.mode){case"hit":return"\u26A1 triple cache: hit";case"delta":return`\u267B\uFE0F triple cache: delta (${r.reparsedFiles??0} file(s) re-parsed)`;case"rebuild":{let e=r.triples.length-r.explicitCount,t=e>0?` + inferred layer (${e})`:"";return`\u{1F528} triple cache: rebuild (${r.reparsedFiles??0} file(s) parsed, cache written${t})`}default:return"triple cache: not used (full parse)"}}function Pu(r){let e=r.skippedFiles;if(e!==void 0){if(e.length===0)return null;let t=[`\u26A0\uFE0F ${e.length} file(s) skipped by the vault loader \u2014 they contributed no triples:`];for(let i of e.slice(0,hP))t.push(` - ${i.path}`),t.push(` ${i.reason}`);let n=e.length-hP;return n>0&&t.push(` \u2026 and ${n} more \u2014 run 'index' to see them all`),t.join(`
|
|
437
437
|
`)}return r.zeroTriplePaths.length===0?null:`\u2139\uFE0F ${r.zeroTriplePaths.length} file(s) contributed no triples; the triple cache does not record WHY \u2014 re-run without --use-cache, or run 'index', to see the per-file reasons`}function vg(r,e){let t=r.skippedFiles;if(t!==void 0){let n=t.find(i=>i.path===e);return n===void 0?null:`\u26A0\uFE0F "${e}" itself was skipped by the vault loader, so it has no triples \u2014 preconditions and $target reads see nothing: ${n.reason}`}return r.zeroTriplePaths.includes(e)?`\u2139\uFE0F "${e}" contributed no triples, so preconditions and $target reads see nothing; the triple cache does not record WHY \u2014 re-run without --use-cache to see the reason`:null}async function mP(r){try{return await r.refreshAfterWrite()}catch(e){return{mode:"failed",reparsedFiles:0,reason:e instanceof Error?e.message:String(e)}}}function gP(r){switch(r.mode){case"delta":return`\u{1F4BE} triple cache: write-through persisted (${r.reparsedFiles} file(s) re-parsed)`;case"noop":return"\u{1F4BE} triple cache: write-through \u2014 nothing changed";case"skipped":return`\u{1F4BE} triple cache: write-through skipped (${r.reason??"unknown"})`;default:return`\u26A0 triple cache: write-through failed (${r.reason}) \u2014 command result unaffected; the next --use-cache run refreshes the cache itself`}}var pP,M8,hP,Ha=Me(()=>{"use strict";pP=Q(require("path")),M8=Q(Pe());Ks();Qw();a(yi,"loadVaultTriples");a(Ou,"cacheLoadNotice");hP=10;a(Pu,"skippedFilesNotice");a(vg,"targetSkippedNotice");a(mP,"writeThroughCache");a(gP,"writeThroughNotice")});function pp(r){let e=new Set,t=/PREFIX\s+([\w-]+)\s*:/gi,n;for(;(n=t.exec(r))!==null;)e.add(n[1].toLowerCase());let i=m7.SPARQL_PREFIXES.split(`
|
|
438
438
|
`).filter(f=>f.trim().length>0),s=[];for(let f of i){let d=/PREFIX\s+(\w+)\s*:/i.exec(f);d&&!e.has(d[1].toLowerCase())&&s.push(f)}let o=new RegExp(`(?<![:\\w?$])(${Ys}):[a-zA-Z_]`,"g"),c=new Set,l;for(;(l=o.exec(r))!==null;)c.add(l[1]);let u=new Set(e);for(let f of s){let d=/PREFIX\s+(\w+)\s*:/i.exec(f);d&&u.add(d[1].toLowerCase())}for(let f of c)u.has(f.toLowerCase())||nbe.test(f)&&(s.push(`PREFIX ${f}: <${rbe}${f}#>`),u.add(f.toLowerCase()));return s.length===0?r:s.join(`
|
|
439
439
|
`)+`
|
|
@@ -716,7 +716,7 @@ Next steps:
|
|
|
716
716
|
`).map(n=>n.trim()).filter(n=>n.length>0),t=e[e.length-1];if(t!==void 0)try{return JSON.parse(t)}catch{return}}a(OEe,"parseLastJsonLine");function dq(r,e){return e.filter(t=>{let n=r[t];return typeof n!="string"||n.trim().length===0})}a(dq,"missingStringFields");var gv=class{constructor(e){this.deps=e}static{a(this,"McpServer")}async handle(e){if(typeof e!="object"||e===null||Array.isArray(e))return{jsonrpc:"2.0",id:null,error:{code:fq,message:"Invalid request: expected a JSON-RPC object"}};let t=e.id,n=t===void 0;if(typeof e.method!="string")return n?null:{jsonrpc:"2.0",id:t??null,error:{code:fq,message:"Invalid request: missing method"}};if(n)return null;let i=t??null;switch(e.method){case"initialize":return{jsonrpc:"2.0",id:i,result:{protocolVersion:CEe,capabilities:{tools:{}},serverInfo:{name:"exocortex",version:this.deps.version}}};case"ping":return{jsonrpc:"2.0",id:i,result:{}};case"tools/list":return{jsonrpc:"2.0",id:i,result:{tools:uq}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:xEe,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,n=e.arguments??{},i;if(t==="create_asset"){let c=dq(n,["vault","class","label"]);if(c.length>0)return Lp(`create_asset: missing required argument(s): ${c.join(", ")}`,!0);let l=aq(n);if(l!==null)return Lp(`create_asset: ${l}`,!0);i=cq(n)}else if(t==="create_effort"){let c=dq(n,["vault","command","target"]);if(c.length>0)return Lp(`create_effort: missing required argument(s): ${c.join(", ")}`,!0);i=lq(n)}else return Lp(`Unknown tool: ${String(t)}`,!0);let s=await this.deps.runCli(i);if(s.exitCode!==0){let c=s.stderr.trim()||s.stdout.trim()||"(no diagnostic output)";return Lp(`exocortex-cli exited ${s.exitCode}
|
|
717
717
|
${c}`,!0)}let o=OEe(s.stdout);return Lp(o===void 0?s.stdout.trim():JSON.stringify(o))}};var mq=require("child_process");var PEe=32*1024*1024;function gq(r){return e=>new Promise(t=>{(0,mq.execFile)(process.execPath,[r,...e],{maxBuffer:PEe},(n,i,s)=>{let o=0;if(n){let c=n.code;o=typeof c=="number"?c:1}t({stdout:i,stderr:s,exitCode:o})})})}a(gq,"createSelfCliRunner");async function FEe(r,e,t){let n=(0,yq.createInterface)({input:e,crlfDelay:1/0});for await(let i of n){let s=i.trim();if(s.length===0)continue;let o;try{o=JSON.parse(s)}catch{t(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:pq,message:"Parse error: invalid JSON"}})+`
|
|
718
718
|
`);continue}let c;try{c=await r.handle(o)}catch(l){c={jsonrpc:"2.0",id:typeof o?.id=="string"||typeof o?.id=="number"?o.id:null,error:{code:hq,message:`Internal error: ${l instanceof Error?l.message:String(l)}`}}}c!==null&&t(JSON.stringify(c)+`
|
|
719
|
-
`)}}a(FEe,"runStdioServer");function bq(r){return new de("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new gv({runCli:gq(t),version:r??"unknown"});await FEe(n,process.stdin,i=>process.stdout.write(i))})}a(bq,"mcpCommand");function yv(r){let e=new de;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"17.7.
|
|
719
|
+
`)}}a(FEe,"runStdioServer");function bq(r){return new de("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new gv({runCli:gq(t),version:r??"unknown"});await FEe(n,process.stdin,i=>process.stdout.write(i))})}a(bq,"mcpCommand");function yv(r){let e=new de;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"17.7.6"),e.addCommand(BV()),e.addCommand(QV()),e.addCommand(_7()),e.addCommand(v7()),e.addCommand(q7()),e.addCommand(T7()),e.addCommand(x7()),e.addCommand(O7()),e.addCommand(J7()),e.addCommand(nV()),e.addCommand(vV()),e.addCommand(CV()),e.addCommand(FV()),e.addCommand(DV()),e.addCommand(NV()),e.addCommand(MV()),e.addCommand(jV()),e.addCommand(SG()),e.addCommand(vG()),e.addCommand(YG()),e.addCommand(QG()),e.addCommand(eq()),e.addCommand(tq()),e.addCommand(iq()),e.addCommand(jG()),e.addCommand(zG()),e.addCommand(sq()),e.addCommand(bq(r??"17.7.6")),e}a(yv,"createProgram");yv().parse();0&&(module.exports={createProgram});
|
|
720
720
|
/*! Bundled license information:
|
|
721
721
|
|
|
722
722
|
reflect-metadata/Reflect.js:
|