@kitelev/exocortex-cli 16.15.0 → 16.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +4 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v16.15.0
2
+ // @kitelev/exocortex-cli v16.16.0
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
@@ -368,7 +368,7 @@ LIMIT ${this.config.defaultLimit}`,s="\u041D\u0435 \u0443\u0434\u0430\u043B\u043
368
368
  `,i=this.composePrefixes(t),s=this.serializePrefixes(i,r),a=this.nTriplesSerializer.serialize(e,{newline:r}).trimEnd();return s?a?`${s}${r}${r}${a}${r}`:`${s}${r}`:a?`${a}${r}`:""}serializePrefixes(e,t){let r=Object.entries(e);return r.length===0?"":r.map(([i,s])=>`@prefix ${i}: <${s}> .`).join(t)}composePrefixes(e){return e.includeDefaultPrefixes??!0?{...J7,...e.prefixes??{}}:{...e.prefixes??{}}}serializeTriplesOnly(e,t){return this.nTriplesSerializer.serializeChunk(e,t).trimEnd()}};Np.TurtleSerializer=Yb});var ex=b(Lp=>{"use strict";Object.defineProperty(Lp,"__esModule",{value:!0});Lp.JSONLDSerializer=void 0;var JA=Ee(),ZA=Mt(),Z7=je(),Zc=ir(),e8={rdf:Zc.Namespace.RDF.iri.value,rdfs:Zc.Namespace.RDFS.iri.value,owl:Zc.Namespace.OWL.iri.value,xsd:Zc.Namespace.XSD.iri.value,exo:Zc.Namespace.EXO.iri.value,ems:Zc.Namespace.EMS.iri.value},Xb=class{static{o(this,"JSONLDSerializer")}toDocument(e,t={}){let r={...e8,...t.context??{}},i=new Map;for(let s of e){let a=this.subjectToId(s.subject),c=this.compactIri(s.predicate.value,r),l=this.objectToJSONLD(s.object,r),u=i.get(a)??{"@id":a},f=u[c];f===void 0?u[c]=l:Array.isArray(f)?f.push(l):u[c]=[f,l],i.set(a,u)}return{"@context":r,"@graph":Array.from(i.values())}}serialize(e,t={}){let r=this.toDocument(e,t),i=t.pretty?t.indent??2:void 0;return JSON.stringify(r,null,i)}subjectToId(e){return e instanceof JA.IRI?e.value:e instanceof ZA.BlankNode?`_:${e.id}`:String(e)}compactIri(e,t){for(let[r,i]of Object.entries(t))if(e.startsWith(i)){let s=e.slice(i.length);if(s.length>0)return`${r}:${s}`}return e}objectToJSONLD(e,t){if(e instanceof JA.IRI)return{"@id":e.value};if(e instanceof ZA.BlankNode)return{"@id":`_:${e.id}`};if(e instanceof Z7.Literal){let r={"@value":e.value};return e.datatype?r["@type"]=this.compactIri(e.datatype.value,t):e.language&&(r["@language"]=e.language,e.hasDirection()&&e.direction&&(r["@direction"]=e.direction)),r}return e}};Lp.JSONLDSerializer=Xb});var eS=b(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});kp.NTriplesParser=void 0;var t8=Kn(),tx=Ee(),Jb=je(),r8=Mt(),el=ir(),n8={rdf:el.Namespace.RDF.iri.value,rdfs:el.Namespace.RDFS.iri.value,owl:el.Namespace.OWL.iri.value,xsd:el.Namespace.XSD.iri.value,exo:el.Namespace.EXO.iri.value,ems:el.Namespace.EMS.iri.value},Zb=class{static{o(this,"NTriplesParser")}parse(e,t={}){let r={prefixes:{...n8,...t.prefixes??{}},strict:t.strict??!1},i=[];return e.split(/\r?\n/).forEach((a,c)=>{let l=a.trim();!l||l.startsWith("#")||i.push(this.parseLine(l,c+1,r))}),i}parseLine(e,t,r){if(!e.endsWith("."))throw new Error(`Invalid RDF statement at line ${t}: missing '.' terminator`);let s=e.slice(0,-1).trim(),a=this.parseSubject(s,t,r);s=a.rest.trim();let c=this.parsePredicate(s,t,r);s=c.rest.trim();let l=this.parseObject(s,t,r);if(s=l.rest.trim(),s.length>0)throw new Error(`Unexpected tokens after object at line ${t}`);return new t8.Triple(a.node,c.node,l.node)}parseSubject(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):e.startsWith("_:")?this.consumeBlankNode(e,t):this.consumePrefixedName(e,t,r)}parsePredicate(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):this.consumePrefixedName(e,t,r)}parseObject(e,t,r){return e.startsWith("<")?this.consumeIRI(e,t,r):e.startsWith("_:")?this.consumeBlankNode(e,t):e.startsWith('"')?this.consumeLiteral(e,t,r):this.consumePrefixedName(e,t,r)}consumePrefixedName(e,t,r){let i=e.match(/^([a-zA-Z_][\w-]*):([^\s]+)(?:\s+(.*))?$/);if(!i)throw new Error(`Invalid token at line ${t}: ${e}`);let[,s,a,c]=i,l=r.prefixes[s];if(!l)throw new Error(`Unknown prefix "${s}" at line ${t}`);return{node:new tx.IRI(`${l}${a}`),rest:(c??"").trimStart()}}consumeIRI(e,t,r){let i=this.findClosingBracket(e,"<",">");if(i===-1)throw new Error(`Invalid IRI at line ${t}`);let s=e.slice(1,i),a=new tx.IRI(s),c=e.slice(i+1).trimStart();return{node:a,rest:c}}consumeBlankNode(e,t){let r=e.match(/^_:(\w+)(?:\s+(.*))?$/);if(!r)throw new Error(`Invalid blank node identifier at line ${t}`);let[,i,s]=r;return{node:new r8.BlankNode(i),rest:(s??"").trimStart()}}consumeLiteral(e,t,r){let{value:i,rest:s}=this.consumeQuotedString(e,t),a=s.trimStart();if(a.startsWith("^^")){a=a.slice(2).trimStart();let c=a.startsWith("<")?this.consumeIRI(a,t,r):this.consumePrefixedName(a,t,r);return{node:new Jb.Literal(i,c.node),rest:c.rest}}if(a.startsWith("@")){let c=a.match(/^@([a-zA-Z-]+)(?:\s+(.*))?$/);if(!c)throw new Error(`Invalid language tag at line ${t}`);let[,l,u]=c;return{node:new Jb.Literal(i,void 0,l),rest:(u??"").trimStart()}}return{node:new Jb.Literal(i),rest:a}}consumeQuotedString(e,t){if(!e.startsWith('"'))throw new Error(`Expected quoted string at line ${t}`);let r="";for(let i=1;i<e.length;i++){let s=e[i];if(s==="\\"){if(i+1>=e.length)throw new Error(`Invalid escape sequence at line ${t}`);let a=e[i+1];switch(a){case"t":r+=" ",i+=1;break;case"b":r+="\b",i+=1;break;case"n":r+=`
369
369
  `,i+=1;break;case"r":r+="\r",i+=1;break;case"f":r+="\f",i+=1;break;case'"':r+='"',i+=1;break;case"\\":r+="\\",i+=1;break;case"u":{let c=e.slice(i+2,i+6);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw new Error(`Invalid \\u escape at line ${t}`);r+=String.fromCharCode(parseInt(c,16)),i+=5;break}case"U":{let c=e.slice(i+2,i+10);if(c.length!==8||!/^[0-9a-fA-F]{8}$/.test(c))throw new Error(`Invalid \\U escape at line ${t}`);r+=String.fromCodePoint(parseInt(c,16)),i+=9;break}default:throw new Error(`Unknown escape sequence \\${a} at line ${t}`)}continue}if(s==='"'){let a=e.slice(i+1);return{value:r,rest:a}}r+=s}throw new Error(`Unterminated string literal at line ${t}`)}findClosingBracket(e,t,r){let i=0;for(let s=0;s<e.length;s++){let a=e[s];if(a===t){i++;continue}if(a===r&&(i--,i===0))return s}return-1}};kp.NTriplesParser=Zb});var rx=b(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});jp.TurtleParser=void 0;var tl=ir(),i8=eS(),s8={rdf:tl.Namespace.RDF.iri.value,rdfs:tl.Namespace.RDFS.iri.value,owl:tl.Namespace.OWL.iri.value,xsd:tl.Namespace.XSD.iri.value,exo:tl.Namespace.EXO.iri.value,ems:tl.Namespace.EMS.iri.value},a8=/^@prefix\s+([a-zA-Z_][\w-]*):\s*<([^>]+)>\s*\.$/,tS=class{static{o(this,"TurtleParser")}constructor(){this.nTriplesParser=new i8.NTriplesParser}parse(e,t={}){let r={...s8,...t.prefixes??{}},i=this.collectStatements(e),s=[];return i.forEach(({statement:a,lineNumber:c})=>{if(this.isPrefixStatement(a)){let u=a.match(a8);if(!u)throw new Error(`Invalid prefix declaration at line ${c}`);let[,f,d]=u;r[f]=d;return}if(a.includes(";")||a.includes(","))throw new Error(`Complex Turtle statements with ';' or ',' are not supported (line ${c})`);let l=this.normalizeShortcuts(a);s.push(this.nTriplesParser.parseLine(l,c,{prefixes:r,strict:!1}))}),s}collectStatements(e){let t=e.split(/\r?\n/),r=[],i="",s=0;if(t.forEach((a,c)=>{let l=a.trim();!l||l.startsWith("#")||(i||(s=c+1),i=i?`${i} ${l}`:l,l.endsWith(".")&&(r.push({statement:i,lineNumber:s}),i=""))}),i)throw new Error(`Unterminated Turtle statement near line ${s}`);return r}isPrefixStatement(e){return e.startsWith("@prefix")}normalizeShortcuts(e){return e.includes(" a ")?e.replace(/\sa\s/g," rdf:type "):e}};jp.TurtleParser=tS});var nx=b(Mp=>{"use strict";Object.defineProperty(Mp,"__esModule",{value:!0});Mp.RDFSerializer=void 0;var rl=Kn(),Lo=Ee(),ko=je(),rS=Mt(),ds=ir(),o8=XA(),c8=Kb(),l8=ex(),u8=rx(),f8=eS(),d8=1024,h8=`
370
370
  `,p8={rdf:ds.Namespace.RDF.iri.value,rdfs:ds.Namespace.RDFS.iri.value,owl:ds.Namespace.OWL.iri.value,xsd:ds.Namespace.XSD.iri.value,exo:ds.Namespace.EXO.iri.value,ems:ds.Namespace.EMS.iri.value},nS=class{static{o(this,"RDFSerializer")}constructor(e){this.store=e,this.turtleSerializer=new o8.TurtleSerializer,this.nTriplesSerializer=new c8.NTriplesSerializer,this.jsonldSerializer=new l8.JSONLDSerializer,this.turtleParser=new u8.TurtleParser,this.nTriplesParser=new f8.NTriplesParser}async serialize(e,t={}){let r=await this.store.match();return this.serializeTriples(r,e,t)}serializeTriples(e,t,r={}){switch(t){case"turtle":return this.turtleSerializer.serialize(e,{prefixes:r.prefixes,includeDefaultPrefixes:r.includeDefaultPrefixes,newline:r.newline});case"n-triples":return this.nTriplesSerializer.serialize(e,{newline:r.newline});case"json-ld":return this.jsonldSerializer.serialize(e,{context:r.prefixes,pretty:r.pretty,indent:r.indent});default:throw new Error(`Unsupported serialization format: ${t}`)}}stream(e,t={}){let r=t.newline??h8,i=t.batchSize??d8,s=t.includeDefaultPrefixes,a=t.prefixes,c=this,l=!1,u=[],f=[],d=0,h=o(async()=>{if(!l){if(f=await c.store.match(),e==="json-ld"){let y=c.jsonldSerializer.toDocument(f,{context:a,pretty:!1});u.push(...c.buildJsonLdChunks(y))}else if(e==="turtle"){let y=c.turtleSerializer.serializePrefixes(c.composePrefixes(a,s),r);y&&u.push(`${y}${r}${r}`)}l=!0}},"ensureInitialized");return{async next(){if(await h(),u.length>0)return{value:u.shift(),done:!1};if(e==="json-ld")return{value:void 0,done:!0};if(d>=f.length)return{value:void 0,done:!0};let y=f.slice(d,d+i);d+=y.length;let S="";if(e==="turtle"){let v=c.turtleSerializer.serializeTriplesOnly(y,r);v&&(S=`${v}${r}`)}else e==="n-triples"&&(S=c.nTriplesSerializer.serializeChunk(y,r));return S?{value:S,done:!1}:this.next()},async return(){return u=[],f=[],d=0,{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}async load(e,t,r={}){let i=this.parse(e,t,r);return r.mode!=="append"&&await this.store.clear(),await this.store.addAll(i),i.length}parse(e,t,r={}){switch(t){case"turtle":return this.turtleParser.parse(e,this.buildTurtleParseOptions(r));case"n-triples":return this.nTriplesParser.parse(e,this.buildNTriplesParseOptions(r));case"json-ld":return this.parseJsonLd(e,r);default:throw new Error(`Unsupported serialization format: ${t}`)}}buildTurtleParseOptions(e){return{prefixes:this.composePrefixes(e.prefixes,!0),strict:e.strict}}buildNTriplesParseOptions(e){return{prefixes:this.composePrefixes(e.prefixes,!0),strict:e.strict}}composePrefixes(e,t){return t??!0?{...p8,...e??{}}:{...e??{}}}parseJsonLd(e,t){let r;try{r=JSON.parse(e)}catch(u){throw new Error(`Invalid JSON-LD document: ${u.message}`)}let i=this.composePrefixes(t.prefixes,!0),s=this.extractContext(r),a={...i,...s},c=this.extractGraph(r),l=[];return c.forEach((u,f)=>{if(!u||typeof u!="object"||Array.isArray(u))throw new Error(`Invalid JSON-LD node at index ${f}`);let d=this.parseSubjectFromNode(u,a,f),h=Object.entries(u);for(let[p,y]of h){if(p==="@id"||p==="@context")continue;if(p==="@type"){this.collectTypeTriples(d,y,l,a);continue}let S=this.expandTerm(p,a),v=new Lo.IRI(S);this.collectTriplesForValue(d,v,y,l,a)}}),l}extractContext(e){if(!e||typeof e!="object"||Array.isArray(e))return{};let t=e["@context"];if(!t||typeof t!="object"||Array.isArray(t))return{};let r={};return Object.entries(t).forEach(([i,s])=>{typeof s=="string"&&(r[i]=s)}),r}extractGraph(e){if(Array.isArray(e))return e;if(!e||typeof e!="object")return[];let t=e["@graph"];return Array.isArray(t)?t:[e]}parseSubjectFromNode(e,t,r){let i=e["@id"];if(typeof i=="string"){if(i.startsWith("_:"))return new rS.BlankNode(i.slice(2));if(this.isAbsoluteIri(i))return new Lo.IRI(i);let s=this.expandTerm(i,t);return new Lo.IRI(s)}return new rS.BlankNode(`jsonld_${r}`)}collectTypeTriples(e,t,r,i){let s=ds.Namespace.RDF.term("type");(Array.isArray(t)?t:[t]).forEach(c=>{if(typeof c!="string")throw new Error("Invalid @type value in JSON-LD node");let l=this.expandTerm(c,i);r.push(new rl.Triple(e,s,new Lo.IRI(l)))})}collectTriplesForValue(e,t,r,i,s){if(r!=null){if(Array.isArray(r)){r.forEach(a=>this.collectTriplesForValue(e,t,a,i,s));return}if(typeof r=="object"){let a=r;if(typeof a["@id"]=="string"){let c=this.parseIdNode(a["@id"],s);i.push(new rl.Triple(e,t,c));return}if(a["@value"]!==void 0){let c=this.parseLiteralObject(a,s);i.push(new rl.Triple(e,t,c));return}}if(typeof r=="string"){i.push(new rl.Triple(e,t,new ko.Literal(r)));return}if(typeof r=="number"){let a=Number.isInteger(r)?ds.Namespace.XSD.term("integer"):ds.Namespace.XSD.term("decimal");i.push(new rl.Triple(e,t,new ko.Literal(r.toString(),a)));return}if(typeof r=="boolean"){let a=ds.Namespace.XSD.term("boolean");i.push(new rl.Triple(e,t,new ko.Literal(r.toString(),a)));return}throw new Error("Unsupported JSON-LD value encountered")}}parseIdNode(e,t){if(e.startsWith("_:"))return new rS.BlankNode(e.slice(2));if(this.isAbsoluteIri(e))return new Lo.IRI(e);let r=this.expandTerm(e,t);return new Lo.IRI(r)}parseLiteralObject(e,t){let r=e["@value"];if(typeof r!="string")throw new Error("JSON-LD literal values must be strings");if(typeof e["@language"]=="string"){let i=e["@direction"];return i==="ltr"||i==="rtl"?new ko.Literal(r,void 0,e["@language"],i):new ko.Literal(r,void 0,e["@language"])}if(typeof e["@type"]=="string"){let i=this.expandTerm(e["@type"],t);return new ko.Literal(r,new Lo.IRI(i))}return new ko.Literal(r)}expandTerm(e,t){if(this.isAbsoluteIri(e))return e;let r=e.indexOf(":");if(r>0){let s=e.slice(0,r),a=e.slice(r+1),c=t[s];if(!c)throw new Error(`Unknown prefix "${s}" in JSON-LD document`);return`${c}${a}`}let i=t["@vocab"];if(i)return`${i}${e}`;throw new Error(`Unable to expand JSON-LD term "${e}"`)}isAbsoluteIri(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)}buildJsonLdChunks(e){let t=[],r=JSON.stringify(e["@context"]);return t.push(`{"@context":${r},"@graph":[`),e["@graph"].forEach((i,s)=>{let a=JSON.stringify(i);s>0?t.push(`,${a}`):t.push(a)}),t.push(`]}
371
- `),t}};Mp.RDFSerializer=nS});var iS=b(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});nl.OBSIDIAN_VAULT_SCHEME=void 0;nl.vaultPathToIRI=m8;nl.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function m8(n){let e=n.startsWith("./")?n.slice(2):n;return`${nl.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}o(m8,"vaultPathToIRI")});var aS=b($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});$p.RDFVocabularyMapper=void 0;var Xt=Kn(),ix=Ee(),X=ir(),sS=class{static{o(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",X.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",X.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",X.Namespace.RDFS.term("subClassOf")],["exo__Property_range",X.Namespace.RDFS.term("range")],["exo__Property_domain",X.Namespace.RDFS.term("domain")],["exo__Property_superProperty",X.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Xt.Triple(X.Namespace.EXO.term("Asset"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.RDFS.term("Resource"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Class"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.RDFS.term("Class"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.RDF.term("Property"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Task"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Project"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Area"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Workflow"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("WorkflowState"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("WorkflowTransition"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("Command"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("Precondition"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("Grounding"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("CommandBinding"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Xt.Triple(X.Namespace.EXO.term("Instance_class"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDF.term("type"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Asset_isDefinedBy"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("isDefinedBy"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Class_superClass"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("subClassOf"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property_range"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("range"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property_domain"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("domain"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property_superProperty"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof ix.IRI)s=r;else{let a=r.match(/^(ems|exo|exocmd)__(.+)$/);if(a){let[,c,l]=a;s=(c==="ems"?X.Namespace.EMS:c==="exocmd"?X.Namespace.EXOCMD:X.Namespace.EXO).term(l)}else s=new ix.IRI(r)}return new Xt.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};$p.RDFVocabularyMapper=sS});var sx=b(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});Bp.RDFSInferenceEngine=void 0;var g8=Kn(),Vp=Ee(),oS=class{static{o(this,"RDFSInferenceEngine")}async materialize(e){let t=await e.predicates(),r=t.find(d=>d.value.includes("Class_superClass")),i=t.find(d=>d.value.includes("Instance_class"));if(!r||!i)return 0;let s=await this.buildDirectParentMap(e,r);if(s.size===0)return 0;let a=this.computeAllAncestors(s),c=await e.count(),l=await e.match(void 0,i),u=[];for(let d of l)if(d.object instanceof Vp.IRI){let h=a.get(d.object.value);if(h)for(let p of h)u.push(new g8.Triple(d.subject,i,new Vp.IRI(p)))}return u.length>0&&await e.addAll(u),await e.count()-c}async buildDirectParentMap(e,t){let r=await e.match(void 0,t),i=new Map;for(let s of r)if(s.subject instanceof Vp.IRI&&s.object instanceof Vp.IRI){let a=s.subject.value,c=s.object.value;i.has(a)||i.set(a,new Set),i.get(a).add(c)}return i}computeAllAncestors(e){let t=new Map;for(let r of e.keys())t.has(r)||t.set(r,this.computeAncestorsBFS(r,e));return t}computeAncestorsBFS(e,t){let r=new Set,i=new Set,s=[],a=t.get(e);if(a)for(let c of a)s.push(c);for(;s.length>0;){let c=s.shift();if(i.has(c))continue;i.add(c),r.add(c);let l=t.get(c);if(l)for(let u of l)i.has(u)||s.push(u)}return r}};Bp.RDFSInferenceEngine=oS});var uS=b(jo=>{"use strict";var y8=jo&&jo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(jo,"__esModule",{value:!0});jo.NonInheritablePropertyRegistry=void 0;var _8=Ce(),ax=Ee(),ox=je(),cS=ir(),lS=class{static{o(this,"NonInheritablePropertyRegistry")}constructor(){this.nonInheritableIRIs=new Set,this.initialized=!1}async initialize(e){this.nonInheritableIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Instance_class"));if(!r){this.initialized=!0;return}let i=await this.findNonInheritableClassIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let a=t.find(c=>c.value.includes("Asset_label"));if(!a){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,a,void 0);for(let u of l)if(u.object instanceof ox.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.nonInheritableIRIs.add(d)}}}catch{}this.initialized=!0}isNonInheritable(e){return this.nonInheritableIRIs.has(e)}get size(){return this.nonInheritableIRIs.size}get isInitialized(){return this.initialized}async findNonInheritableClassIRI(e,t){let r=t.find(a=>a.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new ox.Literal("exo__NonInheritableProperty"));if(i.length>0&&i[0].subject instanceof ax.IRI)return i[0].subject;let s=t.find(a=>a.value.includes("Instance_class"));if(s){let a=await e.match(void 0,s,void 0);for(let c of a)if(c.object instanceof ax.IRI&&c.object.value.includes("NonInheritableProperty"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?cS.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?cS.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?cS.Namespace.EXOCMD.term(e.substring(8)).value:null}};jo.NonInheritablePropertyRegistry=lS;jo.NonInheritablePropertyRegistry=lS=y8([(0,_8.injectable)()],lS)});var hS=b(Mo=>{"use strict";var b8=Mo&&Mo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Mo,"__esModule",{value:!0});Mo.PropertyCardinalityRegistry=void 0;var S8=Ce(),cx=Ee(),lx=je(),fS=ir(),dS=class{static{o(this,"PropertyCardinalityRegistry")}constructor(){this.multiValuedIRIs=new Set,this.initialized=!1}async initialize(e){this.multiValuedIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Property_cardinality"));if(!r){this.initialized=!0;return}let i=await this.findMultipleCardinalityIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let a=t.find(c=>c.value.includes("Asset_label"));if(!a){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,a,void 0);for(let u of l)if(u.object instanceof lx.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.multiValuedIRIs.add(d)}}}catch{}this.initialized=!0}isMultiValued(e){return this.multiValuedIRIs.has(e)}get size(){return this.multiValuedIRIs.size}get isInitialized(){return this.initialized}async findMultipleCardinalityIRI(e,t){let r=t.find(a=>a.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new lx.Literal("exo__PropertyCardinalityMultiple"));if(i.length>0&&i[0].subject instanceof cx.IRI)return i[0].subject;let s=t.find(a=>a.value.includes("Instance_class"));if(s){let a=await e.match(void 0,s,void 0);for(let c of a)if(c.object instanceof cx.IRI&&c.object.value.includes("PropertyCardinalityMultiple"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?fS.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?fS.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?fS.Namespace.EXOCMD.term(e.substring(8)).value:null}};Mo.PropertyCardinalityRegistry=dS;Mo.PropertyCardinalityRegistry=dS=b8([(0,S8.injectable)()],dS)});var gS=b(_r=>{"use strict";var w8=_r&&_r.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},v8=_r&&_r.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(_r,"__esModule",{value:!0});_r.PrototypeChainMaterializer=_r.MAX_PROTOTYPE_DEPTH=_r.INFERRED_GRAPH=void 0;_r.inferredGraphForDepth=pS;var E8=Ce(),ux=Kn(),La=Ee(),T8=uS(),A8=hS();_r.INFERRED_GRAPH=new La.IRI("https://exocortex.my/ontology/exo#inferred");var x8="https://exocortex.my/ontology/exo#inferred/";function pS(n){return new La.IRI(`${x8}${n}`)}o(pS,"inferredGraphForDepth");_r.MAX_PROTOTYPE_DEPTH=10;var mS=class{static{o(this,"PrototypeChainMaterializer")}constructor(e,t){this.registry=e,this.cardinalityRegistry=t??null}async materialize(e){let r=(await e.predicates()).find(c=>c.value.includes("Asset_prototype"));if(!r)return 0;let i=await e.match(void 0,r,void 0);if(i.length===0)return 0;let s=new Map;for(let c of i)if(c.subject instanceof La.IRI&&c.object instanceof La.IRI){let l=c.subject.value,u=c.object.value;l!==u&&s.set(l,c.object)}if(s.size===0)return 0;let a=0;for(let[c]of s){let l=new La.IRI(c),u=this.resolveChain(c,s);if(u.length===0)continue;let f=await e.match(l,void 0,void 0),d=new Set,h=new Map;for(let p of f)if(d.add(p.predicate.value),this.isMultiValued(p.predicate.value)){let y=p.object instanceof La.IRI?p.object.value:String(p.object),S=h.get(p.predicate.value);S||(S=new Set,h.set(p.predicate.value,S)),S.add(y)}for(let p=0;p<u.length;p++){let y=u[p],S=p+1,v=new La.IRI(y),w=await e.match(v,void 0,void 0),T=new Set;if(e.matchInGraph){let C=await e.matchInGraph(v,void 0,void 0,_r.INFERRED_GRAPH);for(let M of C)T.add(M.predicate.value)}for(let C of w){let M=C.predicate.value;if(this.registry.isNonInheritable(M)||T.has(M))continue;if(d.has(M)&&this.isMultiValued(M)){let ee=C.object instanceof La.IRI?C.object.value:String(C.object);if(h.get(M)?.has(ee))continue;let W=h.get(M);W||(W=new Set,h.set(M,W)),W.add(ee);let P=new ux.Triple(l,C.predicate,C.object);await e.add(P),e.addToGraph&&(await e.addToGraph(P,_r.INFERRED_GRAPH),await e.addToGraph(P,pS(S))),a++;continue}if(d.has(M))continue;let V=new ux.Triple(l,C.predicate,C.object);await e.add(V),e.addToGraph&&(await e.addToGraph(V,_r.INFERRED_GRAPH),await e.addToGraph(V,pS(S))),d.add(M),a++}}}return a}isMultiValued(e){return this.cardinalityRegistry?this.cardinalityRegistry.isMultiValued(e):!1}resolveChain(e,t){let r=[],i=new Set;i.add(e);let s=[],a=t.get(e);for(a&&s.push(a.value);s.length>0&&r.length<_r.MAX_PROTOTYPE_DEPTH;){let c=s.shift();if(c===void 0)break;if(i.has(c))continue;i.add(c),r.push(c);let l=t.get(c);l&&!i.has(l.value)&&s.push(l.value)}return r}};_r.PrototypeChainMaterializer=mS;_r.PrototypeChainMaterializer=mS=w8([(0,E8.injectable)(),v8("design:paramtypes",[T8.NonInheritablePropertyRegistry,A8.PropertyCardinalityRegistry])],mS)});var _S=b(lr=>{"use strict";var I8=lr&&lr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},C8=lr&&lr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(lr,"__esModule",{value:!0});lr.SourceAnnotator=lr.DEPTH_VARIABLE=lr.SOURCE_VARIABLE=void 0;var R8=Ce(),il=je(),O8=Ee(),Up=gS();lr.SOURCE_VARIABLE="_source";lr.DEPTH_VARIABLE="_depth";var yS=class{static{o(this,"SourceAnnotator")}constructor(e){this.tripleStore=e}async annotate(e,t,r,i){if(!this.tripleStore.matchInGraph)return e.map(a=>{let c=a.clone();return c.set(lr.SOURCE_VARIABLE,new il.Literal("own")),c});let s=[];for(let a of e){let c=a.get(t),l=a.get(r),u=a.get(i),f=a.clone();if(!c||!l||!u)f.set(lr.SOURCE_VARIABLE,new il.Literal("own"));else{let d=await this.determineSource(c,l,u);f.set(lr.SOURCE_VARIABLE,new il.Literal(d))}s.push(f)}return s}async annotateSingle(e,t,r,i){return(await this.annotate([e],t,r,i))[0]}async determineSource(e,t,r){return this.tripleStore.matchInGraph&&(await this.tripleStore.matchInGraph(e,t,r,Up.INFERRED_GRAPH)).length>0?"inherited":"own"}async getInheritanceDepth(e,t,r){if(!this.tripleStore.matchInGraph)return 0;for(let i=1;i<=Up.MAX_PROTOTYPE_DEPTH;i++){let s=(0,Up.inferredGraphForDepth)(i);if((await this.tripleStore.matchInGraph(e,t,r,s)).length>0)return i}return 0}async annotateBySubject(e,t){if(!this.tripleStore.matchInGraph)return e.map(s=>{let a=s.clone();return a.set(lr.SOURCE_VARIABLE,new il.Literal("own")),a});let r=[],i=new Map;for(let s of e){let a=s.get(t),c=s.clone();if(!a||!(a instanceof O8.IRI))c.set(lr.SOURCE_VARIABLE,new il.Literal("own"));else{let l=a.value;if(!i.has(l)){let f=await this.tripleStore.matchInGraph(a,void 0,void 0,Up.INFERRED_GRAPH);i.set(l,f.length>0?"inherited":"own")}let u=i.get(l)??"own";c.set(lr.SOURCE_VARIABLE,new il.Literal(u))}r.push(c)}return r}};lr.SourceAnnotator=yS;lr.SourceAnnotator=yS=I8([(0,R8.injectable)(),C8("design:paramtypes",[Object])],yS)});var SS=b(ki=>{"use strict";var P8=ki&&ki.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},F8=ki&&ki.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},fx=ki&&ki.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ki,"__esModule",{value:!0});ki.NoteToRDFConverter=void 0;var bS=Ce(),ur=Kn(),ka=Ee(),hn=je(),dx=Mt(),Wt=ir(),hx=Ct(),D8=aS(),N8=pc(),px=iS(),Rn=m0(),L8=new Set(["archived","draft","pinned"]),sl=class{static{o(this,"NoteToRDFConverter")}constructor(e,t=N8.NullLogger){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new D8.RDFVocabularyMapper}async convertNote(e){let t=this.vault.getFrontmatter(e);return t?Rn.Exo003Parser.isExo003Format(t)?this.convertExo003Note(e,t):this.convertLegacyNote(e,t):[]}async convertLegacyNote(e,t){this.pendingExtraTriples=[];let r=[],i=this.notePathToIRI(e.path),s=Wt.Namespace.EXO.term("Asset_fileName");r.push(new ur.Triple(i,s,new hn.Literal(e.basename)));for(let[f,d]of Object.entries(t)){let h=L8.has(f)?`exo__Asset_${f}`:f;if(!this.isExocortexProperty(h))continue;let p=this.propertyKeyToIRI(h),y=Array.isArray(d)?d:[d];for(let S of y)if(!(f==="exo__Asset_label"&&typeof S=="string"&&S.trim()===""))if(f==="exo__Instance_class"){let v=this.valueToClassURI(S);r.push(new ur.Triple(i,p,v))}else{let v=await this.valueToRDFObject(S,e,p);for(let w of v)if(r.push(new ur.Triple(i,p,w)),this.vocabularyMapper.hasMappingFor(f)&&w instanceof ka.IRI){let T=this.vocabularyMapper.generateMappedTriple(i,f,w);T&&r.push(T)}}if(f==="exo__Instance_class")for(let S of y){let v=this.valueToClassURI(S);if(v instanceof ka.IRI){let w=Wt.Namespace.RDF.term("type");r.push(new ur.Triple(i,w,v))}}if(f==="exo__Asset_label"){let S=Wt.Namespace.RDFS.term("label");for(let v of y)typeof v=="string"&&v.length>0&&r.push(new ur.Triple(i,S,new hn.Literal(v)))}}let a="exo__Instance_class"in t||"exo__Asset_uid"in t,c=t.exo__Asset_label,l="exo__Asset_label"in t&&c!==null&&c!==void 0&&!(typeof c=="string"&&c.trim()==="")&&!(Array.isArray(c)&&c.length===0);if(a&&!l){let f=Wt.Namespace.RDFS.term("label"),d=Wt.Namespace.EXO.term("Asset_label"),h=new hn.Literal(e.basename);r.push(new ur.Triple(i,f,h)),r.push(new ur.Triple(i,d,h))}r.push(...this.pendingExtraTriples),this.pendingExtraTriples=[];let u=await this.convertBodyWikilinks(e,i);return r.push(...u),r}async convertExo003Note(e,t){let r=Rn.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Rn.Exo003MetadataType.Namespace:break;case Rn.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Rn.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Rn.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Rn.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new ka.IRI(t.uri);return[new ur.Triple(r,Wt.Namespace.OWL.term("sameAs"),i),new ur.Triple(i,Wt.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new ur.Triple(r,Wt.Namespace.OWL.term("sameAs"),new dx.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Rn.Exo003Parser.toTriple(t,i);r.push(s);let a=this.notePathToIRI(e.path);r.push(new ur.Triple(a,Wt.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.createExo003ReferenceResolver(e),c=a(t.subject),l=a(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 ka.IRI(c.value):new dx.BlankNode(c.value),f=new ka.IRI(l.value),d=Rn.Exo003Parser.toLiteral(t,s.trim());r.push(new ur.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new ur.Triple(h,Wt.Namespace.RDF.term("value"),u))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let a=this.vault.getFrontmatter(s);if(a&&Rn.Exo003Parser.isExo003Format(a)){let c=Rn.Exo003Parser.parse(a);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Rn.Exo003MetadataType.Anchor||l.metadata===Rn.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Rn.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!r&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(){return(await this.convertVaultWithValidation({strict:!1})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1;for(let a of t)try{let c=this.vault.getFrontmatter(a),l=c?this.validateExocortexAsset(c,a.basename):null;if(l){if(s)throw new Error(`Invariant violation in "${a.path}": ${l.message}`);i.push({path:a.path,reason:`Invariant violation: ${l.message}`}),this.logger.warn(`Skipping file with invariant violation: ${a.path}`,{code:l.code,property:l.property,reason:l.message});continue}let u=await this.convertNote(a);r.push(...u)}catch(c){let l=c instanceof Error?c.message:String(c);if(s)throw new Error(`Invalid IRI for file "${a.path}": ${l}`);i.push({path:a.path,reason:`Invalid IRI: ${l}`}),this.logger.warn(`Skipping file with invalid IRI: ${a.path}`,{reason:l})}return{triples:r,skippedFiles:i,summary:{total:t.length,indexed:t.length-i.length,skipped:i.length}}}static inferLabelFromBasename(e){return Wt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=o(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(r):!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(r(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let a=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of a)if(d in e&&r(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 h=this.removeQuotes(d),y=(this.extractWikilink(h)??h).trim();/^[a-z][a-zA-Z0-9]*__/.test(y)&&/[\s()]/.test(y)?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 r of e){let i=(0,px.vaultPathToIRI)(r.path);ka.IRI.isValidIRI(i)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new ka.IRI((0,px.vaultPathToIRI)(e))}isExocortexProperty(e){return Wt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Wt.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let r=this.vault.getFrontmatter(t);if(!r)return;let i=r.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let a=this.valueToClassURI(s);a instanceof ka.IRI&&(this.pendingExtraTriples.push(new ur.Triple(e,Wt.Namespace.RDF.term("type"),a)),this.pendingExtraTriples.push(new ur.Triple(e,Wt.Namespace.EXO.term("Instance_class"),a)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e),s=this.extractWikilink(i);if(s){let a=this.vault.getFirstLinkpathDest(s,t.path);if(a){let l=this.notePathToIRI(a.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new hn.Literal(u);if(r?.value.endsWith("#Grounding_targetValueRef")||r?.value.endsWith("#Grounding_targetValueSubstitution")||r?.value.endsWith("#Grounding_targetClass"))return[l];let p=this.expandClassValue(a.basename);if(p)return this.emitTypeTripleForEnumInstance(p,a),[p];let y=this.vault.getFrontmatter(a);if(y){let v=y.exo__Asset_label;if(typeof v=="string"){let w=this.expandClassValue(v);if(w)return this.emitTypeTripleForEnumInstance(w,a),[w]}}return r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype")?[l,d]:[l]}let f=this.expandClassValue(a.basename);return f?(this.emitTypeTripleForEnumInstance(f,a),[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.notePathToIRI(`${c}.md`)]:[new hn.Literal(i)]}if(this.isClassReference(i)){let a=this.expandClassValue(i);if(a)return[a]}return this.isISO8601DateTime(i)?[new hn.Literal(i,Wt.Namespace.XSD.term("dateTime"))]:[new hn.Literal(i)]}return typeof e=="boolean"?[new hn.Literal(e.toString())]:typeof e=="number"?[new hn.Literal(e.toString(),Wt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new hn.Literal(e.toISOString(),Wt.Namespace.XSD.term("dateTime"))]:[new hn.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 r=t[1];return r.includes("|")?r.split("|")[0]:r}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1],i=r.indexOf("|");return i>=0?r.substring(i+1).trim():null}valueToClassURI(e){if(typeof e!="string")return new hn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let a=this.extractWikilinkAlias(t);if(a){let c=this.expandClassValue(a);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 l;let u=this.vault.getFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return d}}}}return new hn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Wt.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),r=Wt.Namespace.fromPropertyKey(t);return!r||/[\s()]/.test(r.localName)?null:r.namespace.term(r.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.extractBodyWikilinks(s),c=Wt.Namespace.EXO.term("Asset_bodyLink");for(let l of a){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new ur.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?r.push(new ur.Triple(t,c,f)):r.push(new ur.Triple(t,c,new hn.Literal(l)))}else r.push(new ur.Triple(t,c,new hn.Literal(l)))}}catch{}return r}};ki.NoteToRDFConverter=sl;sl.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};sl.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};sl.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};ki.NoteToRDFConverter=sl=P8([(0,bS.injectable)(),fx(0,(0,bS.inject)(hx.DI_TOKENS.IVaultAdapter)),fx(1,(0,bS.inject)(hx.DI_TOKENS.ILogger)),F8("design:paramtypes",[Object,Object])],sl)});var vS=b(qp=>{"use strict";Object.defineProperty(qp,"__esModule",{value:!0});qp.FilterContainsOptimizer=void 0;var k8=Ee(),j8=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,wS=class{static{o(this,"FilterContainsOptimizer")}constructor(){this.tripleStore=null,this.lastOptimizationHints=[]}setTripleStore(e){this.tripleStore=e}getLastOptimizationHints(){return this.lastOptimizationHints}clearHints(){this.lastOptimizationHints=[]}async optimize(e){return this.clearHints(),this.optimizeRecursive(e)}optimizeSync(e,t){return this.clearHints(),this.optimizeSyncRecursive(e,t)}async optimizeRecursive(e){return e.type==="filter"?this.optimizeFilter(e):e.type==="join"?{type:"join",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="leftjoin"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="union"?{type:"union",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="minus"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="project"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="orderby"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="slice"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="distinct"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="reduced"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="group"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="extend"?{...e,input:await this.optimizeRecursive(e.input)}:e}optimizeSyncRecursive(e,t){return e.type==="filter"?this.optimizeFilterSync(e,t):e.type==="join"?{type:"join",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="leftjoin"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="union"?{type:"union",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="minus"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="project"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="orderby"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="slice"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="distinct"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="reduced"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="group"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="extend"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e}async optimizeFilter(e){let t=this.detectContainsUUIDPattern(e.expression);if(!t)return{type:"filter",expression:e.expression,input:await this.optimizeRecursive(e.input)};let r=[];return this.tripleStore&&(r=await this.findSubjectsContainingUUID(t.uuid)),this.rewriteFilter(e,t,r)}optimizeFilterSync(e,t){let r=this.detectContainsUUIDPattern(e.expression);if(!r)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input,t)};let i=t?t.filter(s=>s.includes(r.uuid)):[];return this.rewriteFilter(e,r,i)}rewriteFilter(e,t,r){if(this.lastOptimizationHints.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${t.variable}), "${t.uuid}"))`,suggestedRewrite:r.length===1?`VALUES ?${t.variable} { <${r[0]}> }`:r.length>1?`VALUES ?${t.variable} { ${r.map(i=>`<${i}>`).join(" ")} }`:"No matching URIs found for UUID",estimatedSpeedup:r.length>0?"O(n) \u2192 O(1)":"N/A",matchedUri:r.length===1?r[0]:void 0}),r.length===0)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input)};if(r.length===1){let i=this.injectSubjectConstraint(e.input,t.variable,r[0]);if(i!==e.input)return i}return this.createValuesJoin(e,t,r)}detectContainsUUIDPattern(e){if(e.type==="function"||e.type==="functionCall"){let t=e;if((typeof t.function=="string"?t.function.toLowerCase():t.function?.value?.toLowerCase()??"")==="contains"&&t.args.length===2)return this.analyzeContainsArgs(t.args[0],t.args[1],e)}if(e.type==="logical"&&e.operator==="&&")for(let t of e.operands){let r=this.detectContainsUUIDPattern(t);if(r)return r}return null}analyzeContainsArgs(e,t,r){let i=null;if(e.type==="function"||e.type==="functionCall"){let s=e;if((typeof s.function=="string"?s.function.toLowerCase():s.function?.value?.toLowerCase()??"")==="str"&&s.args.length===1){let c=s.args[0];c.type==="variable"&&(i=c.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let c=String(t.value).match(j8);if(c)return{variable:i,uuid:c[0].toLowerCase(),originalExpression:r}}return null}async findSubjectsContainingUUID(e){if(!this.tripleStore)return[];if(this.tripleStore.findSubjectsByUUID)return(await this.tripleStore.findSubjectsByUUID(e)).map(s=>s.value);let t=await this.tripleStore.subjects(),r=[];for(let i of t)i instanceof k8.IRI&&i.value.toLowerCase().includes(e.toLowerCase())&&r.push(i.value);return r}injectSubjectConstraint(e,t,r){if(e.type==="bgp"){let i=e.triples.map(a=>a.subject.type==="variable"&&a.subject.value===t?{...a,subject:{type:"iri",value:r}}:a);if(i.some((a,c)=>a.subject!==e.triples[c].subject))return{type:"bgp",triples:i}}if(e.type==="join"){let i=this.injectSubjectConstraint(e.left,t,r),s=this.injectSubjectConstraint(e.right,t,r);if(i!==e.left||s!==e.right)return{type:"join",left:i,right:s}}if(e.type==="filter"){let i=this.injectSubjectConstraint(e.input,t,r);if(i!==e.input)return{...e,input:i}}return e}createValuesJoin(e,t,r){return{type:"join",left:{type:"values",variables:[t.variable],bindings:r.map(a=>({[t.variable]:{type:"iri",value:a}}))},right:this.optimizeSyncRecursive(e.input)}}analyzeQuery(e){let t=[];return this.analyzeRecursive(e,t),t}analyzeRecursive(e,t){if(e.type==="filter"){let r=this.detectContainsUUIDPattern(e.expression);r&&t.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${r.variable}), "${r.uuid}"))`,suggestedRewrite:`Use --optimize flag or rewrite as VALUES ?${r.variable} { <uri-containing-uuid> }`,estimatedSpeedup:"O(n) \u2192 O(1) with UUID index lookup"}),this.analyzeRecursive(e.input,t);return}e.type==="join"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="leftjoin"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="union"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="minus"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="project"?this.analyzeRecursive(e.input,t):e.type==="orderby"?this.analyzeRecursive(e.input,t):e.type==="slice"?this.analyzeRecursive(e.input,t):e.type==="distinct"?this.analyzeRecursive(e.input,t):e.type==="reduced"?this.analyzeRecursive(e.input,t):e.type==="group"?this.analyzeRecursive(e.input,t):e.type==="extend"&&this.analyzeRecursive(e.input,t)}};qp.FilterContainsOptimizer=wS});var mx=b(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});Wp.AlgebraOptimizer=void 0;var M8=vS(),ES=class{static{o(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new M8.FilterContainsOptimizer}setTripleStore(e){this.tripleStore=e,this.filterContainsOptimizer.setTripleStore(e)}getOptimizationHints(){return this.filterContainsOptimizer.getLastOptimizationHints()}analyzeQuery(e){return this.filterContainsOptimizer.analyzeQuery(e)}optimize(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),t=this.filterPushDown(t),t=this.joinReordering(t),t}async optimizeAsync(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),this.tripleStore&&(t=await this.filterContainsOptimizer.optimize(t)),t=this.filterPushDown(t),t=this.joinReordering(t),t}optimizeWithSubjects(e,t){let r=e;return r=this.eliminateEmptyBGPInFilterJoin(r),r=this.filterContainsOptimizer.optimizeSync(r,t),r=this.filterPushDown(r),r=this.joinReordering(r),r}eliminateEmptyBGPInFilterJoin(e){if(e.type==="join"){if(e.left.type==="filter"){let t=e.left;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.right)}}if(e.right.type==="filter"){let t=e.right;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.left)}}return{type:"join",left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}}return e.type==="filter"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="leftjoin"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="union"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="minus"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="project"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="orderby"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="slice"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="distinct"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e}filterPushDown(e){return e.type==="filter"?this.pushDownFilter(e):e.type==="join"?{type:"join",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="leftjoin"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="union"?{type:"union",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="minus"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="project"?{...e,input:this.filterPushDown(e.input)}:e.type==="orderby"?{...e,input:this.filterPushDown(e.input)}:e.type==="slice"?{...e,input:this.filterPushDown(e.input)}:e.type==="distinct"?{...e,input:this.filterPushDown(e.input)}:e}pushDownFilter(e){let t=e.input;if(t.type==="join"){let r=this.getFilterVariables(e.expression),i=this.getOperationVariables(t.left),s=this.getOperationVariables(t.right),a=r.every(l=>i.has(l)),c=r.every(l=>s.has(l));return a&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!a?{type:"join",left:this.filterPushDown(t.left),right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:{type:"join",left:this.filterPushDown(t.left),right:this.filterPushDown(t.right)}}}return t.type==="union"?{type:"union",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:this.filterPushDown(t)}}getFilterVariables(e){let t=[];if(e.type==="variable")t.push(e.name);else if(e.type==="comparison")t.push(...this.getFilterVariables(e.left)),t.push(...this.getFilterVariables(e.right));else if(e.type==="logical")for(let r of e.operands)t.push(...this.getFilterVariables(r));else if(e.type==="function")for(let r of e.args)t.push(...this.getFilterVariables(r));return Array.from(new Set(t))}getOperationVariables(e){let t=new Set;if(e.type==="bgp")for(let r of e.triples)r.subject.type==="variable"&&t.add(r.subject.value),r.predicate.type==="variable"&&t.add(r.predicate.value),r.object.type==="variable"&&t.add(r.object.value);else if(e.type==="join"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="filter")return this.getOperationVariables(e.input);if(e.type==="leftjoin"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else if(e.type==="union"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="minus")return this.getOperationVariables(e.left);if(e.type==="project")return new Set(e.variables)}}return t}joinReordering(e){return e.type==="join"?this.reorderJoin(e):e.type==="filter"?{...e,input:this.joinReordering(e.input)}:e.type==="leftjoin"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="union"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="minus"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="project"?{...e,input:this.joinReordering(e.input)}:e.type==="orderby"?{...e,input:this.joinReordering(e.input)}:e.type==="slice"?{...e,input:this.joinReordering(e.input)}:e.type==="distinct"?{...e,input:this.joinReordering(e.input)}:e}reorderJoin(e){let t=this.isConstrained(e.left),r=this.isConstrained(e.right);if(r&&!t)return{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)};if(t&&!r)return{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)};let i=this.estimateCost(e.left);return this.estimateCost(e.right)<i?{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)}:{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)}}isConstrained(e){return e.type==="values"?!0:e.type==="bgp"?e.triples.some(t=>t.object.type!=="variable"||t.subject.type!=="variable"):e.type==="filter"?this.isConstrained(e.input):e.type==="join"?this.isConstrained(e.left)||this.isConstrained(e.right):e.type==="union"?this.isConstrained(e.left)&&this.isConstrained(e.right):!1}estimateCost(e){if(e.type==="bgp"){let t=0;for(let r of e.triples){let i=10;r.subject.type==="variable"&&(i*=10),r.predicate.type==="variable"&&(i*=20),r.object.type==="variable"&&(i*=5),t+=i}return t}if(e.type==="filter")return this.estimateCost(e.input)*.3;if(e.type==="join"){let t=this.estimateCost(e.left),r=this.estimateCost(e.right);return e.left.type==="values"||e.right.type==="values"?Math.min(t,r)*2:t*r}if(e.type==="leftjoin")return this.estimateCost(e.left)+this.estimateCost(e.right)*.5;if(e.type==="union")return this.estimateCost(e.left)+this.estimateCost(e.right);if(e.type==="values"){let t=e.bindings;return Array.isArray(t)?t.length*5:10}return e.type==="minus"?this.estimateCost(e.left)+this.estimateCost(e.right)*.3:100}setStatistics(e,t){this.stats.set(e,t)}getStatistics(e){return this.stats.get(e)}};Wp.AlgebraOptimizer=ES});var gx=b(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});Gp.AlgebraSerializer=void 0;var TS=class{static{o(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
371
+ `),t}};Mp.RDFSerializer=nS});var iS=b(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});nl.OBSIDIAN_VAULT_SCHEME=void 0;nl.vaultPathToIRI=m8;nl.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function m8(n){let e=n.startsWith("./")?n.slice(2):n;return`${nl.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}o(m8,"vaultPathToIRI")});var aS=b($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});$p.RDFVocabularyMapper=void 0;var Xt=Kn(),ix=Ee(),X=ir(),sS=class{static{o(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",X.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",X.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",X.Namespace.RDFS.term("subClassOf")],["exo__Property_range",X.Namespace.RDFS.term("range")],["exo__Property_domain",X.Namespace.RDFS.term("domain")],["exo__Property_superProperty",X.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Xt.Triple(X.Namespace.EXO.term("Asset"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.RDFS.term("Resource"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Class"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.RDFS.term("Class"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.RDF.term("Property"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Task"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Project"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Area"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("Workflow"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("WorkflowState"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EMS.term("WorkflowTransition"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("Command"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("Precondition"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("Grounding"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e.push(new Xt.Triple(X.Namespace.EXOCMD.term("CommandBinding"),X.Namespace.RDFS.term("subClassOf"),X.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Xt.Triple(X.Namespace.EXO.term("Instance_class"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDF.term("type"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Asset_isDefinedBy"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("isDefinedBy"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Class_superClass"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("subClassOf"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property_range"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("range"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property_domain"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("domain"))),e.push(new Xt.Triple(X.Namespace.EXO.term("Property_superProperty"),X.Namespace.RDFS.term("subPropertyOf"),X.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof ix.IRI)s=r;else{let a=r.match(/^(ems|exo|exocmd)__(.+)$/);if(a){let[,c,l]=a;s=(c==="ems"?X.Namespace.EMS:c==="exocmd"?X.Namespace.EXOCMD:X.Namespace.EXO).term(l)}else s=new ix.IRI(r)}return new Xt.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};$p.RDFVocabularyMapper=sS});var sx=b(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});Bp.RDFSInferenceEngine=void 0;var g8=Kn(),Vp=Ee(),oS=class{static{o(this,"RDFSInferenceEngine")}async materialize(e){let t=await e.predicates(),r=t.find(d=>d.value.includes("Class_superClass")),i=t.find(d=>d.value.includes("Instance_class"));if(!r||!i)return 0;let s=await this.buildDirectParentMap(e,r);if(s.size===0)return 0;let a=this.computeAllAncestors(s),c=await e.count(),l=await e.match(void 0,i),u=[];for(let d of l)if(d.object instanceof Vp.IRI){let h=a.get(d.object.value);if(h)for(let p of h)u.push(new g8.Triple(d.subject,i,new Vp.IRI(p)))}return u.length>0&&await e.addAll(u),await e.count()-c}async buildDirectParentMap(e,t){let r=await e.match(void 0,t),i=new Map;for(let s of r)if(s.subject instanceof Vp.IRI&&s.object instanceof Vp.IRI){let a=s.subject.value,c=s.object.value;i.has(a)||i.set(a,new Set),i.get(a).add(c)}return i}computeAllAncestors(e){let t=new Map;for(let r of e.keys())t.has(r)||t.set(r,this.computeAncestorsBFS(r,e));return t}computeAncestorsBFS(e,t){let r=new Set,i=new Set,s=[],a=t.get(e);if(a)for(let c of a)s.push(c);for(;s.length>0;){let c=s.shift();if(i.has(c))continue;i.add(c),r.add(c);let l=t.get(c);if(l)for(let u of l)i.has(u)||s.push(u)}return r}};Bp.RDFSInferenceEngine=oS});var uS=b(jo=>{"use strict";var y8=jo&&jo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(jo,"__esModule",{value:!0});jo.NonInheritablePropertyRegistry=void 0;var _8=Ce(),ax=Ee(),ox=je(),cS=ir(),lS=class{static{o(this,"NonInheritablePropertyRegistry")}constructor(){this.nonInheritableIRIs=new Set,this.initialized=!1}async initialize(e){this.nonInheritableIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Instance_class"));if(!r){this.initialized=!0;return}let i=await this.findNonInheritableClassIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let a=t.find(c=>c.value.includes("Asset_label"));if(!a){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,a,void 0);for(let u of l)if(u.object instanceof ox.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.nonInheritableIRIs.add(d)}}}catch{}this.initialized=!0}isNonInheritable(e){return this.nonInheritableIRIs.has(e)}get size(){return this.nonInheritableIRIs.size}get isInitialized(){return this.initialized}async findNonInheritableClassIRI(e,t){let r=t.find(a=>a.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new ox.Literal("exo__NonInheritableProperty"));if(i.length>0&&i[0].subject instanceof ax.IRI)return i[0].subject;let s=t.find(a=>a.value.includes("Instance_class"));if(s){let a=await e.match(void 0,s,void 0);for(let c of a)if(c.object instanceof ax.IRI&&c.object.value.includes("NonInheritableProperty"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?cS.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?cS.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?cS.Namespace.EXOCMD.term(e.substring(8)).value:null}};jo.NonInheritablePropertyRegistry=lS;jo.NonInheritablePropertyRegistry=lS=y8([(0,_8.injectable)()],lS)});var hS=b(Mo=>{"use strict";var b8=Mo&&Mo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Mo,"__esModule",{value:!0});Mo.PropertyCardinalityRegistry=void 0;var S8=Ce(),cx=Ee(),lx=je(),fS=ir(),dS=class{static{o(this,"PropertyCardinalityRegistry")}constructor(){this.multiValuedIRIs=new Set,this.initialized=!1}async initialize(e){this.multiValuedIRIs.clear();try{let t=await e.predicates(),r=t.find(c=>c.value.includes("Property_cardinality"));if(!r){this.initialized=!0;return}let i=await this.findMultipleCardinalityIRI(e,t);if(!i){this.initialized=!0;return}let s=await e.match(void 0,r,i);if(s.length===0){this.initialized=!0;return}let a=t.find(c=>c.value.includes("Asset_label"));if(!a){this.initialized=!0;return}for(let c of s){let l=await e.match(c.subject,a,void 0);for(let u of l)if(u.object instanceof lx.Literal){let f=u.object.value,d=this.propertyKeyToIRI(f);d&&this.multiValuedIRIs.add(d)}}}catch{}this.initialized=!0}isMultiValued(e){return this.multiValuedIRIs.has(e)}get size(){return this.multiValuedIRIs.size}get isInitialized(){return this.initialized}async findMultipleCardinalityIRI(e,t){let r=t.find(a=>a.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new lx.Literal("exo__PropertyCardinalityMultiple"));if(i.length>0&&i[0].subject instanceof cx.IRI)return i[0].subject;let s=t.find(a=>a.value.includes("Instance_class"));if(s){let a=await e.match(void 0,s,void 0);for(let c of a)if(c.object instanceof cx.IRI&&c.object.value.includes("PropertyCardinalityMultiple"))return c.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?fS.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?fS.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?fS.Namespace.EXOCMD.term(e.substring(8)).value:null}};Mo.PropertyCardinalityRegistry=dS;Mo.PropertyCardinalityRegistry=dS=b8([(0,S8.injectable)()],dS)});var gS=b(_r=>{"use strict";var w8=_r&&_r.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},v8=_r&&_r.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(_r,"__esModule",{value:!0});_r.PrototypeChainMaterializer=_r.MAX_PROTOTYPE_DEPTH=_r.INFERRED_GRAPH=void 0;_r.inferredGraphForDepth=pS;var E8=Ce(),ux=Kn(),La=Ee(),T8=uS(),A8=hS();_r.INFERRED_GRAPH=new La.IRI("https://exocortex.my/ontology/exo#inferred");var x8="https://exocortex.my/ontology/exo#inferred/";function pS(n){return new La.IRI(`${x8}${n}`)}o(pS,"inferredGraphForDepth");_r.MAX_PROTOTYPE_DEPTH=10;var mS=class{static{o(this,"PrototypeChainMaterializer")}constructor(e,t){this.registry=e,this.cardinalityRegistry=t??null}async materialize(e){let r=(await e.predicates()).find(c=>c.value.includes("Asset_prototype"));if(!r)return 0;let i=await e.match(void 0,r,void 0);if(i.length===0)return 0;let s=new Map;for(let c of i)if(c.subject instanceof La.IRI&&c.object instanceof La.IRI){let l=c.subject.value,u=c.object.value;l!==u&&s.set(l,c.object)}if(s.size===0)return 0;let a=0;for(let[c]of s){let l=new La.IRI(c),u=this.resolveChain(c,s);if(u.length===0)continue;let f=await e.match(l,void 0,void 0),d=new Set,h=new Map;for(let p of f)if(d.add(p.predicate.value),this.isMultiValued(p.predicate.value)){let y=p.object instanceof La.IRI?p.object.value:String(p.object),S=h.get(p.predicate.value);S||(S=new Set,h.set(p.predicate.value,S)),S.add(y)}for(let p=0;p<u.length;p++){let y=u[p],S=p+1,v=new La.IRI(y),w=await e.match(v,void 0,void 0),T=new Set;if(e.matchInGraph){let C=await e.matchInGraph(v,void 0,void 0,_r.INFERRED_GRAPH);for(let M of C)T.add(M.predicate.value)}for(let C of w){let M=C.predicate.value;if(this.registry.isNonInheritable(M)||T.has(M))continue;if(d.has(M)&&this.isMultiValued(M)){let ee=C.object instanceof La.IRI?C.object.value:String(C.object);if(h.get(M)?.has(ee))continue;let W=h.get(M);W||(W=new Set,h.set(M,W)),W.add(ee);let P=new ux.Triple(l,C.predicate,C.object);await e.add(P),e.addToGraph&&(await e.addToGraph(P,_r.INFERRED_GRAPH),await e.addToGraph(P,pS(S))),a++;continue}if(d.has(M))continue;let V=new ux.Triple(l,C.predicate,C.object);await e.add(V),e.addToGraph&&(await e.addToGraph(V,_r.INFERRED_GRAPH),await e.addToGraph(V,pS(S))),d.add(M),a++}}}return a}isMultiValued(e){return this.cardinalityRegistry?this.cardinalityRegistry.isMultiValued(e):!1}resolveChain(e,t){let r=[],i=new Set;i.add(e);let s=[],a=t.get(e);for(a&&s.push(a.value);s.length>0&&r.length<_r.MAX_PROTOTYPE_DEPTH;){let c=s.shift();if(c===void 0)break;if(i.has(c))continue;i.add(c),r.push(c);let l=t.get(c);l&&!i.has(l.value)&&s.push(l.value)}return r}};_r.PrototypeChainMaterializer=mS;_r.PrototypeChainMaterializer=mS=w8([(0,E8.injectable)(),v8("design:paramtypes",[T8.NonInheritablePropertyRegistry,A8.PropertyCardinalityRegistry])],mS)});var _S=b(lr=>{"use strict";var I8=lr&&lr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},C8=lr&&lr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(lr,"__esModule",{value:!0});lr.SourceAnnotator=lr.DEPTH_VARIABLE=lr.SOURCE_VARIABLE=void 0;var R8=Ce(),il=je(),O8=Ee(),Up=gS();lr.SOURCE_VARIABLE="_source";lr.DEPTH_VARIABLE="_depth";var yS=class{static{o(this,"SourceAnnotator")}constructor(e){this.tripleStore=e}async annotate(e,t,r,i){if(!this.tripleStore.matchInGraph)return e.map(a=>{let c=a.clone();return c.set(lr.SOURCE_VARIABLE,new il.Literal("own")),c});let s=[];for(let a of e){let c=a.get(t),l=a.get(r),u=a.get(i),f=a.clone();if(!c||!l||!u)f.set(lr.SOURCE_VARIABLE,new il.Literal("own"));else{let d=await this.determineSource(c,l,u);f.set(lr.SOURCE_VARIABLE,new il.Literal(d))}s.push(f)}return s}async annotateSingle(e,t,r,i){return(await this.annotate([e],t,r,i))[0]}async determineSource(e,t,r){return this.tripleStore.matchInGraph&&(await this.tripleStore.matchInGraph(e,t,r,Up.INFERRED_GRAPH)).length>0?"inherited":"own"}async getInheritanceDepth(e,t,r){if(!this.tripleStore.matchInGraph)return 0;for(let i=1;i<=Up.MAX_PROTOTYPE_DEPTH;i++){let s=(0,Up.inferredGraphForDepth)(i);if((await this.tripleStore.matchInGraph(e,t,r,s)).length>0)return i}return 0}async annotateBySubject(e,t){if(!this.tripleStore.matchInGraph)return e.map(s=>{let a=s.clone();return a.set(lr.SOURCE_VARIABLE,new il.Literal("own")),a});let r=[],i=new Map;for(let s of e){let a=s.get(t),c=s.clone();if(!a||!(a instanceof O8.IRI))c.set(lr.SOURCE_VARIABLE,new il.Literal("own"));else{let l=a.value;if(!i.has(l)){let f=await this.tripleStore.matchInGraph(a,void 0,void 0,Up.INFERRED_GRAPH);i.set(l,f.length>0?"inherited":"own")}let u=i.get(l)??"own";c.set(lr.SOURCE_VARIABLE,new il.Literal(u))}r.push(c)}return r}};lr.SourceAnnotator=yS;lr.SourceAnnotator=yS=I8([(0,R8.injectable)(),C8("design:paramtypes",[Object])],yS)});var SS=b(ki=>{"use strict";var P8=ki&&ki.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var c=n.length-1;c>=0;c--)(a=n[c])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},F8=ki&&ki.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},fx=ki&&ki.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ki,"__esModule",{value:!0});ki.NoteToRDFConverter=void 0;var bS=Ce(),ur=Kn(),ka=Ee(),hn=je(),dx=Mt(),Wt=ir(),hx=Ct(),D8=aS(),N8=pc(),px=iS(),Rn=m0(),L8=new Set(["archived","draft","pinned"]),sl=class{static{o(this,"NoteToRDFConverter")}constructor(e,t=N8.NullLogger){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new D8.RDFVocabularyMapper}async convertNote(e){let t=this.vault.getFrontmatter(e);if(!t)return[];let r=this.notePathToIRI(e.path),i=Wt.Namespace.EXO.term("Asset_filename"),s=new ur.Triple(r,i,new hn.Literal(e.basename));if(Rn.Exo003Parser.isExo003Format(t)){let a=await this.convertExo003Note(e,t);return[s,...a]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,r){this.pendingExtraTriples=[];let i=[r],s=this.notePathToIRI(e.path);for(let[f,d]of Object.entries(t)){let h=L8.has(f)?`exo__Asset_${f}`:f;if(!this.isExocortexProperty(h))continue;let p=this.propertyKeyToIRI(h),y=Array.isArray(d)?d:[d];for(let S of y)if(!(f==="exo__Asset_label"&&typeof S=="string"&&S.trim()===""))if(f==="exo__Instance_class"){let v=this.valueToClassURI(S);i.push(new ur.Triple(s,p,v))}else{let v=await this.valueToRDFObject(S,e,p);for(let w of v)if(i.push(new ur.Triple(s,p,w)),this.vocabularyMapper.hasMappingFor(f)&&w instanceof ka.IRI){let T=this.vocabularyMapper.generateMappedTriple(s,f,w);T&&i.push(T)}}if(f==="exo__Instance_class")for(let S of y){let v=this.valueToClassURI(S);if(v instanceof ka.IRI){let w=Wt.Namespace.RDF.term("type");i.push(new ur.Triple(s,w,v))}}if(f==="exo__Asset_label"){let S=Wt.Namespace.RDFS.term("label");for(let v of y)typeof v=="string"&&v.length>0&&i.push(new ur.Triple(s,S,new hn.Literal(v)))}}let a="exo__Instance_class"in t||"exo__Asset_uid"in t,c=t.exo__Asset_label,l="exo__Asset_label"in t&&c!==null&&c!==void 0&&!(typeof c=="string"&&c.trim()==="")&&!(Array.isArray(c)&&c.length===0);if(a&&!l){let f=Wt.Namespace.RDFS.term("label"),d=Wt.Namespace.EXO.term("Asset_label"),h=new hn.Literal(e.basename);i.push(new ur.Triple(s,f,h)),i.push(new ur.Triple(s,d,h))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[];let u=await this.convertBodyWikilinks(e,s);return i.push(...u),i}async convertExo003Note(e,t){let r=Rn.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Rn.Exo003MetadataType.Namespace:break;case Rn.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Rn.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Rn.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Rn.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new ka.IRI(t.uri);return[new ur.Triple(r,Wt.Namespace.OWL.term("sameAs"),i),new ur.Triple(i,Wt.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new ur.Triple(r,Wt.Namespace.OWL.term("sameAs"),new dx.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Rn.Exo003Parser.toTriple(t,i);r.push(s);let a=this.notePathToIRI(e.path);r.push(new ur.Triple(a,Wt.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.createExo003ReferenceResolver(e),c=a(t.subject),l=a(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 ka.IRI(c.value):new dx.BlankNode(c.value),f=new ka.IRI(l.value),d=Rn.Exo003Parser.toLiteral(t,s.trim());r.push(new ur.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new ur.Triple(h,Wt.Namespace.RDF.term("value"),u))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let a=this.vault.getFrontmatter(s);if(a&&Rn.Exo003Parser.isExo003Format(a)){let c=Rn.Exo003Parser.parse(a);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Rn.Exo003MetadataType.Anchor||l.metadata===Rn.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Rn.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!r&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(){return(await this.convertVaultWithValidation({strict:!1})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1;for(let a of t)try{let c=this.vault.getFrontmatter(a),l=c?this.validateExocortexAsset(c,a.basename):null;if(l){if(s)throw new Error(`Invariant violation in "${a.path}": ${l.message}`);i.push({path:a.path,reason:`Invariant violation: ${l.message}`}),this.logger.warn(`Skipping file with invariant violation: ${a.path}`,{code:l.code,property:l.property,reason:l.message});continue}let u=await this.convertNote(a);r.push(...u)}catch(c){let l=c instanceof Error?c.message:String(c);if(s)throw new Error(`Invalid IRI for file "${a.path}": ${l}`);i.push({path:a.path,reason:`Invalid IRI: ${l}`}),this.logger.warn(`Skipping file with invalid IRI: ${a.path}`,{reason:l})}return{triples:r,skippedFiles:i,summary:{total:t.length,indexed:t.length-i.length,skipped:i.length}}}static inferLabelFromBasename(e){return Wt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=o(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(r):!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(r(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let a=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of a)if(d in e&&r(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 h=this.removeQuotes(d),y=(this.extractWikilink(h)??h).trim();/^[a-z][a-zA-Z0-9]*__/.test(y)&&/[\s()]/.test(y)?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 r of e){let i=(0,px.vaultPathToIRI)(r.path);ka.IRI.isValidIRI(i)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new ka.IRI((0,px.vaultPathToIRI)(e))}isExocortexProperty(e){return Wt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Wt.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let r=this.vault.getFrontmatter(t);if(!r)return;let i=r.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let a=this.valueToClassURI(s);a instanceof ka.IRI&&(this.pendingExtraTriples.push(new ur.Triple(e,Wt.Namespace.RDF.term("type"),a)),this.pendingExtraTriples.push(new ur.Triple(e,Wt.Namespace.EXO.term("Instance_class"),a)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e),s=this.extractWikilink(i);if(s){let a=this.vault.getFirstLinkpathDest(s,t.path);if(a){let l=this.notePathToIRI(a.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new hn.Literal(u);if(r?.value.endsWith("#Grounding_targetValueRef")||r?.value.endsWith("#Grounding_targetValueSubstitution")||r?.value.endsWith("#Grounding_targetClass"))return[l];let p=this.expandClassValue(a.basename);if(p)return this.emitTypeTripleForEnumInstance(p,a),[p];let y=this.vault.getFrontmatter(a);if(y){let v=y.exo__Asset_label;if(typeof v=="string"){let w=this.expandClassValue(v);if(w)return this.emitTypeTripleForEnumInstance(w,a),[w]}}return r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype")?[l,d]:[l]}let f=this.expandClassValue(a.basename);return f?(this.emitTypeTripleForEnumInstance(f,a),[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.notePathToIRI(`${c}.md`)]:[new hn.Literal(i)]}if(this.isClassReference(i)){let a=this.expandClassValue(i);if(a)return[a]}return this.isISO8601DateTime(i)?[new hn.Literal(i,Wt.Namespace.XSD.term("dateTime"))]:[new hn.Literal(i)]}return typeof e=="boolean"?[new hn.Literal(e.toString())]:typeof e=="number"?[new hn.Literal(e.toString(),Wt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new hn.Literal(e.toISOString(),Wt.Namespace.XSD.term("dateTime"))]:[new hn.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 r=t[1];return r.includes("|")?r.split("|")[0]:r}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1],i=r.indexOf("|");return i>=0?r.substring(i+1).trim():null}valueToClassURI(e){if(typeof e!="string")return new hn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let a=this.extractWikilinkAlias(t);if(a){let c=this.expandClassValue(a);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 l;let u=this.vault.getFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return d}}}}return new hn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Wt.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),r=Wt.Namespace.fromPropertyKey(t);return!r||/[\s()]/.test(r.localName)?null:r.namespace.term(r.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),a=this.extractBodyWikilinks(s),c=Wt.Namespace.EXO.term("Asset_bodyLink");for(let l of a){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new ur.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?r.push(new ur.Triple(t,c,f)):r.push(new ur.Triple(t,c,new hn.Literal(l)))}else r.push(new ur.Triple(t,c,new hn.Literal(l)))}}catch{}return r}};ki.NoteToRDFConverter=sl;sl.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};sl.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};sl.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};ki.NoteToRDFConverter=sl=P8([(0,bS.injectable)(),fx(0,(0,bS.inject)(hx.DI_TOKENS.IVaultAdapter)),fx(1,(0,bS.inject)(hx.DI_TOKENS.ILogger)),F8("design:paramtypes",[Object,Object])],sl)});var vS=b(qp=>{"use strict";Object.defineProperty(qp,"__esModule",{value:!0});qp.FilterContainsOptimizer=void 0;var k8=Ee(),j8=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,wS=class{static{o(this,"FilterContainsOptimizer")}constructor(){this.tripleStore=null,this.lastOptimizationHints=[]}setTripleStore(e){this.tripleStore=e}getLastOptimizationHints(){return this.lastOptimizationHints}clearHints(){this.lastOptimizationHints=[]}async optimize(e){return this.clearHints(),this.optimizeRecursive(e)}optimizeSync(e,t){return this.clearHints(),this.optimizeSyncRecursive(e,t)}async optimizeRecursive(e){return e.type==="filter"?this.optimizeFilter(e):e.type==="join"?{type:"join",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="leftjoin"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="union"?{type:"union",left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="minus"?{...e,left:await this.optimizeRecursive(e.left),right:await this.optimizeRecursive(e.right)}:e.type==="project"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="orderby"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="slice"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="distinct"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="reduced"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="group"?{...e,input:await this.optimizeRecursive(e.input)}:e.type==="extend"?{...e,input:await this.optimizeRecursive(e.input)}:e}optimizeSyncRecursive(e,t){return e.type==="filter"?this.optimizeFilterSync(e,t):e.type==="join"?{type:"join",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="leftjoin"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="union"?{type:"union",left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="minus"?{...e,left:this.optimizeSyncRecursive(e.left,t),right:this.optimizeSyncRecursive(e.right,t)}:e.type==="project"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="orderby"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="slice"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="distinct"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="reduced"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="group"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e.type==="extend"?{...e,input:this.optimizeSyncRecursive(e.input,t)}:e}async optimizeFilter(e){let t=this.detectContainsUUIDPattern(e.expression);if(!t)return{type:"filter",expression:e.expression,input:await this.optimizeRecursive(e.input)};let r=[];return this.tripleStore&&(r=await this.findSubjectsContainingUUID(t.uuid)),this.rewriteFilter(e,t,r)}optimizeFilterSync(e,t){let r=this.detectContainsUUIDPattern(e.expression);if(!r)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input,t)};let i=t?t.filter(s=>s.includes(r.uuid)):[];return this.rewriteFilter(e,r,i)}rewriteFilter(e,t,r){if(this.lastOptimizationHints.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${t.variable}), "${t.uuid}"))`,suggestedRewrite:r.length===1?`VALUES ?${t.variable} { <${r[0]}> }`:r.length>1?`VALUES ?${t.variable} { ${r.map(i=>`<${i}>`).join(" ")} }`:"No matching URIs found for UUID",estimatedSpeedup:r.length>0?"O(n) \u2192 O(1)":"N/A",matchedUri:r.length===1?r[0]:void 0}),r.length===0)return{type:"filter",expression:e.expression,input:this.optimizeSyncRecursive(e.input)};if(r.length===1){let i=this.injectSubjectConstraint(e.input,t.variable,r[0]);if(i!==e.input)return i}return this.createValuesJoin(e,t,r)}detectContainsUUIDPattern(e){if(e.type==="function"||e.type==="functionCall"){let t=e;if((typeof t.function=="string"?t.function.toLowerCase():t.function?.value?.toLowerCase()??"")==="contains"&&t.args.length===2)return this.analyzeContainsArgs(t.args[0],t.args[1],e)}if(e.type==="logical"&&e.operator==="&&")for(let t of e.operands){let r=this.detectContainsUUIDPattern(t);if(r)return r}return null}analyzeContainsArgs(e,t,r){let i=null;if(e.type==="function"||e.type==="functionCall"){let s=e;if((typeof s.function=="string"?s.function.toLowerCase():s.function?.value?.toLowerCase()??"")==="str"&&s.args.length===1){let c=s.args[0];c.type==="variable"&&(i=c.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let c=String(t.value).match(j8);if(c)return{variable:i,uuid:c[0].toLowerCase(),originalExpression:r}}return null}async findSubjectsContainingUUID(e){if(!this.tripleStore)return[];if(this.tripleStore.findSubjectsByUUID)return(await this.tripleStore.findSubjectsByUUID(e)).map(s=>s.value);let t=await this.tripleStore.subjects(),r=[];for(let i of t)i instanceof k8.IRI&&i.value.toLowerCase().includes(e.toLowerCase())&&r.push(i.value);return r}injectSubjectConstraint(e,t,r){if(e.type==="bgp"){let i=e.triples.map(a=>a.subject.type==="variable"&&a.subject.value===t?{...a,subject:{type:"iri",value:r}}:a);if(i.some((a,c)=>a.subject!==e.triples[c].subject))return{type:"bgp",triples:i}}if(e.type==="join"){let i=this.injectSubjectConstraint(e.left,t,r),s=this.injectSubjectConstraint(e.right,t,r);if(i!==e.left||s!==e.right)return{type:"join",left:i,right:s}}if(e.type==="filter"){let i=this.injectSubjectConstraint(e.input,t,r);if(i!==e.input)return{...e,input:i}}return e}createValuesJoin(e,t,r){return{type:"join",left:{type:"values",variables:[t.variable],bindings:r.map(a=>({[t.variable]:{type:"iri",value:a}}))},right:this.optimizeSyncRecursive(e.input)}}analyzeQuery(e){let t=[];return this.analyzeRecursive(e,t),t}analyzeRecursive(e,t){if(e.type==="filter"){let r=this.detectContainsUUIDPattern(e.expression);r&&t.push({type:"uuid-index-lookup",originalPattern:`FILTER(CONTAINS(STR(?${r.variable}), "${r.uuid}"))`,suggestedRewrite:`Use --optimize flag or rewrite as VALUES ?${r.variable} { <uri-containing-uuid> }`,estimatedSpeedup:"O(n) \u2192 O(1) with UUID index lookup"}),this.analyzeRecursive(e.input,t);return}e.type==="join"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="leftjoin"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="union"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="minus"?(this.analyzeRecursive(e.left,t),this.analyzeRecursive(e.right,t)):e.type==="project"?this.analyzeRecursive(e.input,t):e.type==="orderby"?this.analyzeRecursive(e.input,t):e.type==="slice"?this.analyzeRecursive(e.input,t):e.type==="distinct"?this.analyzeRecursive(e.input,t):e.type==="reduced"?this.analyzeRecursive(e.input,t):e.type==="group"?this.analyzeRecursive(e.input,t):e.type==="extend"&&this.analyzeRecursive(e.input,t)}};qp.FilterContainsOptimizer=wS});var mx=b(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});Wp.AlgebraOptimizer=void 0;var M8=vS(),ES=class{static{o(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new M8.FilterContainsOptimizer}setTripleStore(e){this.tripleStore=e,this.filterContainsOptimizer.setTripleStore(e)}getOptimizationHints(){return this.filterContainsOptimizer.getLastOptimizationHints()}analyzeQuery(e){return this.filterContainsOptimizer.analyzeQuery(e)}optimize(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),t=this.filterPushDown(t),t=this.joinReordering(t),t}async optimizeAsync(e){let t=e;return t=this.eliminateEmptyBGPInFilterJoin(t),this.tripleStore&&(t=await this.filterContainsOptimizer.optimize(t)),t=this.filterPushDown(t),t=this.joinReordering(t),t}optimizeWithSubjects(e,t){let r=e;return r=this.eliminateEmptyBGPInFilterJoin(r),r=this.filterContainsOptimizer.optimizeSync(r,t),r=this.filterPushDown(r),r=this.joinReordering(r),r}eliminateEmptyBGPInFilterJoin(e){if(e.type==="join"){if(e.left.type==="filter"){let t=e.left;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.right)}}if(e.right.type==="filter"){let t=e.right;if(t.input.type==="bgp"&&t.input.triples.length===0)return{type:"filter",expression:t.expression,input:this.eliminateEmptyBGPInFilterJoin(e.left)}}return{type:"join",left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}}return e.type==="filter"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="leftjoin"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="union"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="minus"?{...e,left:this.eliminateEmptyBGPInFilterJoin(e.left),right:this.eliminateEmptyBGPInFilterJoin(e.right)}:e.type==="project"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="orderby"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="slice"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e.type==="distinct"?{...e,input:this.eliminateEmptyBGPInFilterJoin(e.input)}:e}filterPushDown(e){return e.type==="filter"?this.pushDownFilter(e):e.type==="join"?{type:"join",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="leftjoin"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="union"?{type:"union",left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="minus"?{...e,left:this.filterPushDown(e.left),right:this.filterPushDown(e.right)}:e.type==="project"?{...e,input:this.filterPushDown(e.input)}:e.type==="orderby"?{...e,input:this.filterPushDown(e.input)}:e.type==="slice"?{...e,input:this.filterPushDown(e.input)}:e.type==="distinct"?{...e,input:this.filterPushDown(e.input)}:e}pushDownFilter(e){let t=e.input;if(t.type==="join"){let r=this.getFilterVariables(e.expression),i=this.getOperationVariables(t.left),s=this.getOperationVariables(t.right),a=r.every(l=>i.has(l)),c=r.every(l=>s.has(l));return a&&!c?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:c&&!a?{type:"join",left:this.filterPushDown(t.left),right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:{type:"join",left:this.filterPushDown(t.left),right:this.filterPushDown(t.right)}}}return t.type==="union"?{type:"union",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:{type:"filter",expression:e.expression,input:this.filterPushDown(t.right)}}:{type:"filter",expression:e.expression,input:this.filterPushDown(t)}}getFilterVariables(e){let t=[];if(e.type==="variable")t.push(e.name);else if(e.type==="comparison")t.push(...this.getFilterVariables(e.left)),t.push(...this.getFilterVariables(e.right));else if(e.type==="logical")for(let r of e.operands)t.push(...this.getFilterVariables(r));else if(e.type==="function")for(let r of e.args)t.push(...this.getFilterVariables(r));return Array.from(new Set(t))}getOperationVariables(e){let t=new Set;if(e.type==="bgp")for(let r of e.triples)r.subject.type==="variable"&&t.add(r.subject.value),r.predicate.type==="variable"&&t.add(r.predicate.value),r.object.type==="variable"&&t.add(r.object.value);else if(e.type==="join"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="filter")return this.getOperationVariables(e.input);if(e.type==="leftjoin"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else if(e.type==="union"){let r=this.getOperationVariables(e.left),i=this.getOperationVariables(e.right);return new Set([...r,...i])}else{if(e.type==="minus")return this.getOperationVariables(e.left);if(e.type==="project")return new Set(e.variables)}}return t}joinReordering(e){return e.type==="join"?this.reorderJoin(e):e.type==="filter"?{...e,input:this.joinReordering(e.input)}:e.type==="leftjoin"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="union"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="minus"?{...e,left:this.joinReordering(e.left),right:this.joinReordering(e.right)}:e.type==="project"?{...e,input:this.joinReordering(e.input)}:e.type==="orderby"?{...e,input:this.joinReordering(e.input)}:e.type==="slice"?{...e,input:this.joinReordering(e.input)}:e.type==="distinct"?{...e,input:this.joinReordering(e.input)}:e}reorderJoin(e){let t=this.isConstrained(e.left),r=this.isConstrained(e.right);if(r&&!t)return{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)};if(t&&!r)return{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)};let i=this.estimateCost(e.left);return this.estimateCost(e.right)<i?{type:"join",left:this.joinReordering(e.right),right:this.joinReordering(e.left)}:{type:"join",left:this.joinReordering(e.left),right:this.joinReordering(e.right)}}isConstrained(e){return e.type==="values"?!0:e.type==="bgp"?e.triples.some(t=>t.object.type!=="variable"||t.subject.type!=="variable"):e.type==="filter"?this.isConstrained(e.input):e.type==="join"?this.isConstrained(e.left)||this.isConstrained(e.right):e.type==="union"?this.isConstrained(e.left)&&this.isConstrained(e.right):!1}estimateCost(e){if(e.type==="bgp"){let t=0;for(let r of e.triples){let i=10;r.subject.type==="variable"&&(i*=10),r.predicate.type==="variable"&&(i*=20),r.object.type==="variable"&&(i*=5),t+=i}return t}if(e.type==="filter")return this.estimateCost(e.input)*.3;if(e.type==="join"){let t=this.estimateCost(e.left),r=this.estimateCost(e.right);return e.left.type==="values"||e.right.type==="values"?Math.min(t,r)*2:t*r}if(e.type==="leftjoin")return this.estimateCost(e.left)+this.estimateCost(e.right)*.5;if(e.type==="union")return this.estimateCost(e.left)+this.estimateCost(e.right);if(e.type==="values"){let t=e.bindings;return Array.isArray(t)?t.length*5:10}return e.type==="minus"?this.estimateCost(e.left)+this.estimateCost(e.right)*.3:100}setStatistics(e,t){this.stats.set(e,t)}getStatistics(e){return this.stats.get(e)}};Wp.AlgebraOptimizer=ES});var gx=b(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});Gp.AlgebraSerializer=void 0;var TS=class{static{o(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
372
372
  ${e.triples.map(u=>`${r} ${this.tripleToString(u)}`).join(`
373
373
  `)}
374
374
  ${r}]`;case"filter":return`${r}Filter(
@@ -485,7 +485,7 @@ GFS4: `),console.error(n)},"debug"));Nt[kr]||(NI=global[kr]||[],kI(Nt,NI),Nt.clo
485
485
  `+n.slice(i,s),i=s+1),a=c;return l+=`
486
486
  `,n.length-i>e&&a>i?l+=n.slice(i,a)+`
487
487
  `+n.slice(a+1):l+=n.slice(i),l.slice(1)}o(NR,"foldLine");function bz(n){for(var e="",t=0,r,i=0;i<n.length;t>=65536?i+=2:i++)t=mf(n,i),r=Kr[t],!r&&bf(t)?(e+=n[i],t>=65536&&(e+=n[i+1])):e+=r||uz(t);return e}o(bz,"escapeString");function Sz(n,e,t){var r="",i=n.tag,s,a,c;for(s=0,a=t.length;s<a;s+=1)c=t[s],n.replacer&&(c=n.replacer.call(t,String(s),c)),(ca(n,e,c,!1,!1)||typeof c>"u"&&ca(n,e,null,!1,!1))&&(r!==""&&(r+=","+(n.condenseFlow?"":" ")),r+=n.dump);n.tag=i,n.dump="["+r+"]"}o(Sz,"writeFlowSequence");function LR(n,e,t,r){var i="",s=n.tag,a,c,l;for(a=0,c=t.length;a<c;a+=1)l=t[a],n.replacer&&(l=n.replacer.call(t,String(a),l)),(ca(n,e+1,l,!0,!0,!1,!0)||typeof l>"u"&&ca(n,e+1,null,!0,!0,!1,!0))&&((!r||i!=="")&&(i+=Vw(n,e)),n.dump&&yf===n.dump.charCodeAt(0)?i+="-":i+="- ",i+=n.dump);n.tag=s,n.dump=i||"[]"}o(LR,"writeBlockSequence");function wz(n,e,t){var r="",i=n.tag,s=Object.keys(t),a,c,l,u,f;for(a=0,c=s.length;a<c;a+=1)f="",r!==""&&(f+=", "),n.condenseFlow&&(f+='"'),l=s[a],u=t[l],n.replacer&&(u=n.replacer.call(t,l,u)),ca(n,e,l,!1,!1)&&(n.dump.length>1024&&(f+="? "),f+=n.dump+(n.condenseFlow?'"':"")+":"+(n.condenseFlow?"":" "),ca(n,e,u,!1,!1)&&(f+=n.dump,r+=f));n.tag=i,n.dump="{"+r+"}"}o(wz,"writeFlowMapping");function vz(n,e,t,r){var i="",s=n.tag,a=Object.keys(t),c,l,u,f,d,h;if(n.sortKeys===!0)a.sort();else if(typeof n.sortKeys=="function")a.sort(n.sortKeys);else if(n.sortKeys)throw new _n("sortKeys must be a boolean or a function");for(c=0,l=a.length;c<l;c+=1)h="",(!r||i!=="")&&(h+=Vw(n,e)),u=a[c],f=t[u],n.replacer&&(f=n.replacer.call(t,u,f)),ca(n,e+1,u,!0,!0,!0)&&(d=n.tag!==null&&n.tag!=="?"||n.dump&&n.dump.length>1024,d&&(n.dump&&yf===n.dump.charCodeAt(0)?h+="?":h+="? "),h+=n.dump,d&&(h+=Vw(n,e)),ca(n,e+1,f,!0,d)&&(n.dump&&yf===n.dump.charCodeAt(0)?h+=":":h+=": ",h+=n.dump,i+=h));n.tag=s,n.dump=i||"{}"}o(vz,"writeBlockMapping");function kR(n,e,t){var r,i,s,a,c,l;for(i=t?n.explicitTypes:n.implicitTypes,s=0,a=i.length;s<a;s+=1)if(c=i[s],(c.instanceOf||c.predicate)&&(!c.instanceOf||typeof e=="object"&&e instanceof c.instanceOf)&&(!c.predicate||c.predicate(e))){if(t?c.multi&&c.representName?n.tag=c.representName(e):n.tag=c.tag:n.tag="?",c.represent){if(l=n.styleMap[c.tag]||c.defaultStyle,pO.call(c.represent)==="[object Function]")r=c.represent(e,l);else if(mO.call(c.represent,l))r=c.represent[l](e,l);else throw new _n("!<"+c.tag+'> tag resolver accepts not "'+l+'" style');n.dump=r}return!0}return!1}o(kR,"detectType");function ca(n,e,t,r,i,s,a){n.tag=null,n.dump=t,kR(n,t,!1)||kR(n,t,!0);var c=pO.call(n.dump),l=r,u;r&&(r=n.flowLevel<0||n.flowLevel>e);var f=c==="[object Object]"||c==="[object Array]",d,h;if(f&&(d=n.duplicates.indexOf(t),h=d!==-1),(n.tag!==null&&n.tag!=="?"||h||n.indent!==2&&e>0)&&(i=!1),h&&n.usedDuplicates[d])n.dump="*ref_"+d;else{if(f&&h&&!n.usedDuplicates[d]&&(n.usedDuplicates[d]=!0),c==="[object Object]")r&&Object.keys(n.dump).length!==0?(vz(n,e,n.dump,i),h&&(n.dump="&ref_"+d+n.dump)):(wz(n,e,n.dump),h&&(n.dump="&ref_"+d+" "+n.dump));else if(c==="[object Array]")r&&n.dump.length!==0?(n.noArrayIndent&&!a&&e>0?LR(n,e-1,n.dump,i):LR(n,e,n.dump,i),h&&(n.dump="&ref_"+d+n.dump)):(Sz(n,e,n.dump),h&&(n.dump="&ref_"+d+" "+n.dump));else if(c==="[object String]")n.tag!=="?"&&yz(n,n.dump,e,s,l);else{if(c==="[object Undefined]")return!1;if(n.skipInvalid)return!1;throw new _n("unacceptable kind of an object to dump "+c)}n.tag!==null&&n.tag!=="?"&&(u=encodeURI(n.tag[0]==="!"?n.tag.slice(1):n.tag).replace(/!/g,"%21"),n.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",n.dump=u+" "+n.dump)}return!0}o(ca,"writeNode");function Ez(n,e){var t=[],r=[],i,s;for(Uw(n,t,r),i=0,s=r.length;i<s;i+=1)e.duplicates.push(t[r[i]]);e.usedDuplicates=new Array(s)}o(Ez,"getDuplicateReferences");function Uw(n,e,t){var r,i,s;if(n!==null&&typeof n=="object")if(i=e.indexOf(n),i!==-1)t.indexOf(i)===-1&&t.push(i);else if(e.push(n),Array.isArray(n))for(i=0,s=n.length;i<s;i+=1)Uw(n[i],e,t);else for(r=Object.keys(n),i=0,s=r.length;i<s;i+=1)Uw(n[r[i]],e,t)}o(Uw,"inspectNode");function Tz(n,e){e=e||{};var t=new dz(e);t.noRefs||Ez(n,t);var r=n;return t.replacer&&(r=t.replacer.call({"":r},"",r)),ca(t,0,r,!0,!0)?t.dump+`
488
- `:""}o(Tz,"dump$1");var Az=Tz,xz={dump:Az};function Qw(n,e){return function(){throw new Error("Function yaml."+n+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}o(Qw,"renamed");var Iz=jr,Cz=$R,Rz=qR,Oz=QR,Pz=KR,Fz=Ww,Dz=hO.load,Nz=hO.loadAll,Lz=xz.dump,kz=_n,jz={binary:eO,float:HR,map:UR,null:WR,pairs:rO,set:nO,timestamp:JR,bool:GR,int:zR,merge:ZR,omap:tO,seq:BR,str:VR},Mz=Qw("safeLoad","load"),$z=Qw("safeLoadAll","loadAll"),Vz=Qw("safeDump","dump"),rr={Type:Iz,Schema:Cz,FAILSAFE_SCHEMA:Rz,JSON_SCHEMA:Oz,CORE_SCHEMA:Pz,DEFAULT_SCHEMA:Fz,load:Dz,loadAll:Nz,dump:Lz,YAMLException:kz,types:jz,safeLoad:Mz,safeLoadAll:$z,safeDump:Vz};var mv=le(Sl()),Ho=le(require("path"));var zO=le(jO(),1);var wf=o(n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Qz={"[: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]},vf=o(n=>n.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Kz=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),MO=o(n=>n.join(""),"rangesToString"),$O=o((n,e)=>{let t=e;if(n.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=t+1,a=!1,c=!1,l=!1,u=!1,f=t,d="";e:for(;s<n.length;){let S=n.charAt(s);if((S==="!"||S==="^")&&s===t+1){u=!0,s++;continue}if(S==="]"&&a&&!l){f=s+1;break}if(a=!0,S==="\\"&&!l){l=!0,s++;continue}if(S==="["&&!l){for(let[v,[w,T,C]]of Object.entries(Qz))if(n.startsWith(v,s)){if(d)return["$.",!1,n.length-t,!0];s+=v.length,C?i.push(w):r.push(w),c=c||T;continue e}}if(l=!1,d){S>d?r.push(vf(d)+"-"+vf(S)):S===d&&r.push(vf(S)),d="",s++;continue}if(n.startsWith("-]",s+1)){r.push(vf(S+"-")),s+=2;continue}if(n.startsWith("-",s+1)){d=S,s+=2;continue}r.push(vf(S)),s++}if(f<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,n.length-t,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!u){let S=r[0].length===2?r[0].slice(-1):r[0];return[Kz(S),!1,f-t,!1]}let h="["+(u?"^":"")+MO(r)+"]",p="["+(u?"":"^")+MO(i)+"]";return[r.length&&i.length?"("+h+"|"+p+")":r.length?h:p,c,f-t,!0]},"parseClass");var $i=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),"unescape");var Fn,Yz=new Set(["!","?","+","*","@"]),Xw=o(n=>Yz.has(n),"isExtglobType"),VO=o(n=>Xw(n.type),"isExtglobAST"),Xz=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Jz=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Zz=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),BO=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),eH="(?!(?:^|/)\\.\\.?(?:$|/))",Um="(?!\\.)",tH=new Set(["[","."]),rH=new Set(["..","."]),nH=new Set("().*{}+?[]^$\\!"),iH=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Jw="[^/]",UO=Jw+"*?",qO=Jw+"+?",Wo=class{static{o(this,"AST")}type;#e;#n;#r=!1;#t=[];#c;#_;#i;#u=!1;#s;#l;#a=!1;constructor(e,t,r={}){this.type=e,e&&(this.#n=!0),this.#c=t,this.#e=this.#c?this.#c.#e:this,this.#s=this.#e===this?r:this.#e.#s,this.#i=this.#e===this?[]:this.#e.#i,e==="!"&&!this.#e.#u&&this.#i.push(this),this.#_=this.#c?this.#c.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let e of this.#t)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#l!==void 0?this.#l:this.type?this.#l=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#l=this.#t.map(e=>String(e)).join("")}#p(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let e;for(;e=this.#i.pop();){if(e.type!=="!")continue;let t=e,r=t.#c;for(;r;){for(let i=t.#_+1;!r.type&&i<r.#t.length;i++)for(let s of e.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#t[i])}t=r,r=t.#c}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof Fn&&t.#c===this))throw new Error("invalid part: "+t);this.#t.push(t)}}toJSON(){let e=this.type===null?this.#t.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#t.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#c?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#c?.isStart())return!1;if(this.#_===0)return!0;let e=this.#c;for(let t=0;t<this.#_;t++){let r=e.#t[t];if(!(r instanceof Fn&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#c?.type==="!")return!0;if(!this.#c?.isEnd())return!1;if(!this.type)return this.#c?.isEnd();let e=this.#c?this.#c.#t.length:0;return this.#_===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new Fn(this.type,e);for(let r of this.#t)t.copyIn(r);return t}static#g(e,t,r,i,s){let a=i.maxExtglobRecursion??2,c=!1,l=!1,u=-1,f=!1;if(t.type===null){let S=r,v="";for(;S<e.length;){let w=e.charAt(S++);if(c||w==="\\"){c=!c,v+=w;continue}if(l){S===u+1?(w==="^"||w==="!")&&(f=!0):w==="]"&&!(S===u+2&&f)&&(l=!1),v+=w;continue}else if(w==="["){l=!0,u=S,f=!1,v+=w;continue}if(!i.noext&&Xw(w)&&e.charAt(S)==="("&&s<=a){t.push(v),v="";let C=new Fn(w,t);S=Fn.#g(e,C,S,i,s+1),t.push(C);continue}v+=w}return t.push(v),S}let d=r+1,h=new Fn(null,t),p=[],y="";for(;d<e.length;){let S=e.charAt(d++);if(c||S==="\\"){c=!c,y+=S;continue}if(l){d===u+1?(S==="^"||S==="!")&&(f=!0):S==="]"&&!(d===u+2&&f)&&(l=!1),y+=S;continue}else if(S==="["){l=!0,u=d,f=!1,y+=S;continue}if(Xw(S)&&e.charAt(d)==="("&&(s<=a||t&&t.#y(S))){let w=t&&t.#y(S)?0:1;h.push(y),y="";let T=new Fn(S,h);h.push(T),d=Fn.#g(e,T,d,i,s+w);continue}if(S==="|"){h.push(y),y="",p.push(h),h=new Fn(null,t);continue}if(S===")")return y===""&&t.#t.length===0&&(t.#a=!0),h.push(y),y="",t.push(...p,h),d;y+=S}return t.type=null,t.#n=void 0,t.#t=[e.substring(r-1)],d}#d(e){return this.#m(e,Jz)}#m(e,t=Xz){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null)return!1;let r=e.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type,t)}#y(e,t=Zz){return!!t.get(this.type)?.includes(e)}#f(e,t){let r=e.#t[0],i=new Fn(null,r,this.options);i.#t.push(""),r.push(i),this.#E(e,t)}#E(e,t){let r=e.#t[0];this.#t.splice(t,1,...r.#t);for(let i of r.#t)typeof i=="object"&&(i.#c=this);this.#l=void 0}#T(e){return!!BO.get(this.type)?.has(e)}#b(e){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let t=e.#t[0];return!t||typeof t!="object"||t.type===null?!1:this.#T(t.type)}#v(e){let t=BO.get(this.type),r=e.#t[0],i=t?.get(r.type);if(!i)return!1;this.#t=r.#t;for(let s of this.#t)typeof s=="object"&&(s.#c=this);this.type=i,this.#l=void 0,this.#a=!1}#S(){if(VO(this)){let e=0,t=!1;do{t=!0;for(let r=0;r<this.#t.length;r++){let i=this.#t[r];typeof i=="object"&&(i.#S(),this.#m(i)?(t=!1,this.#E(i,r)):this.#d(i)?(t=!1,this.#f(i,r)):this.#b(i)&&(t=!1,this.#v(i)))}}while(!t&&++e<10)}else for(let e of this.#t)typeof e=="object"&&e.#S();this.#l=void 0}static fromGlob(e,t={}){let r=new Fn(null,void 0,t);return Fn.#g(e,r,0,t,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,r,i,s]=this.toRegExpSource();if(!(i||this.#n||this.#s.nocase&&!this.#s.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return r;let c=(this.#s.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,c),{_src:t,_glob:e})}get options(){return this.#s}toRegExpSource(e){let t=e??!!this.#s.dot;if(this.#e===this&&(this.#S(),this.#p()),!VO(this)){let l=this.isStart()&&this.isEnd(),u=this.#t.map(p=>{let[y,S,v,w]=typeof p=="string"?Fn.#x(p,this.#n,l):p.toRegExpSource(e);return this.#n=this.#n||v,this.#r=this.#r||w,y}).join(""),f="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&rH.has(this.#t[0]))){let y=tH,S=t&&y.has(u.charAt(0))||u.startsWith("\\.")&&y.has(u.charAt(2))||u.startsWith("\\.\\.")&&y.has(u.charAt(4)),v=!t&&!e&&y.has(u.charAt(0));f=S?eH:v?Um:""}let d="";return this.isEnd()&&this.#e.#u&&this.#c?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,$i(u),this.#n=!!this.#n,this.#r]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#w(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString(),u=this;return u.#t=[l],u.type=null,u.#n=void 0,[l,$i(this.toString()),!1,!1]}let a=!r||e||t||!Um?"":this.#w(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let c="";if(this.type==="!"&&this.#a)c=(this.isStart()&&!t?Um:"")+qO;else{let l=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Um:"")+UO+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;c=i+s+l}return[c,$i(s),this.#n=!!this.#n,this.#r]}#w(e){return this.#t.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[r,i,s,a]=t.toRegExpSource(e);return this.#r=this.#r||a,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#x(e,t,r=!1){let i=!1,s="",a=!1,c=!1;for(let l=0;l<e.length;l++){let u=e.charAt(l);if(i){i=!1,s+=(nH.has(u)?"\\":"")+u,c=!1;continue}if(u==="\\"){l===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,h,p]=$O(e,l);if(h){s+=f,a=a||d,l+=h-1,t=t||p,c=!1;continue}}if(u==="*"){if(c)continue;c=!0,s+=r&&/^[*]+$/.test(e)?qO:UO,t=!0;continue}else c=!1;if(u==="?"){s+=Jw,t=!0;continue}s+=iH(u)}return[s,$i(e),!!t,a]}};Fn=Wo;var Al=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Mr=o((n,e,t={})=>(wf(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Bn(e,t).match(n)),"minimatch"),sH=/^\*+([^+@!?\*\[\(]*)$/,aH=o(n=>e=>!e.startsWith(".")&&e.endsWith(n),"starDotExtTest"),oH=o(n=>e=>e.endsWith(n),"starDotExtTestDot"),cH=o(n=>(n=n.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(n)),"starDotExtTestNocase"),lH=o(n=>(n=n.toLowerCase(),e=>e.toLowerCase().endsWith(n)),"starDotExtTestNocaseDot"),uH=/^\*+\.\*+$/,fH=o(n=>!n.startsWith(".")&&n.includes("."),"starDotStarTest"),dH=o(n=>n!=="."&&n!==".."&&n.includes("."),"starDotStarTestDot"),hH=/^\.\*+$/,pH=o(n=>n!=="."&&n!==".."&&n.startsWith("."),"dotStarTest"),mH=/^\*+$/,gH=o(n=>n.length!==0&&!n.startsWith("."),"starTest"),yH=o(n=>n.length!==0&&n!=="."&&n!=="..","starTestDot"),_H=/^\?+([^+@!?\*\[\(]*)?$/,bH=o(([n,e=""])=>{let t=HO([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),SH=o(([n,e=""])=>{let t=QO([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),wH=o(([n,e=""])=>{let t=QO([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTestDot"),vH=o(([n,e=""])=>{let t=HO([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTest"),HO=o(([n])=>{let e=n.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),QO=o(([n])=>{let e=n.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),KO=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",WO={win32:{sep:"\\"},posix:{sep:"/"}},EH=KO==="win32"?WO.win32.sep:WO.posix.sep;Mr.sep=EH;var Gt=Symbol("globstar **");Mr.GLOBSTAR=Gt;var TH="[^/]",AH=TH+"*?",xH="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",IH="(?:(?!(?:\\/|^)\\.).)*?",CH=o((n,e={})=>t=>Mr(t,n,e),"filter");Mr.filter=CH;var ni=o((n,e={})=>Object.assign({},n,e),"ext"),RH=o(n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return Mr;let e=Mr;return Object.assign(o((r,i,s={})=>e(r,i,ni(n,s)),"m"),{Minimatch:class extends e.Minimatch{static{o(this,"Minimatch")}constructor(i,s={}){super(i,ni(n,s))}static defaults(i){return e.defaults(ni(n,i)).Minimatch}},AST:class extends e.AST{static{o(this,"AST")}constructor(i,s,a={}){super(i,s,ni(n,a))}static fromGlob(i,s={}){return e.AST.fromGlob(i,ni(n,s))}},unescape:o((r,i={})=>e.unescape(r,ni(n,i)),"unescape"),escape:o((r,i={})=>e.escape(r,ni(n,i)),"escape"),filter:o((r,i={})=>e.filter(r,ni(n,i)),"filter"),defaults:o(r=>e.defaults(ni(n,r)),"defaults"),makeRe:o((r,i={})=>e.makeRe(r,ni(n,i)),"makeRe"),braceExpand:o((r,i={})=>e.braceExpand(r,ni(n,i)),"braceExpand"),match:o((r,i,s={})=>e.match(r,i,ni(n,s)),"match"),sep:e.sep,GLOBSTAR:Gt})},"defaults");Mr.defaults=RH;var YO=o((n,e={})=>(wf(n),e.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,zO.default)(n)),"braceExpand");Mr.braceExpand=YO;var OH=o((n,e={})=>new Bn(n,e).makeRe(),"makeRe");Mr.makeRe=OH;var PH=o((n,e,t={})=>{let r=new Bn(e,t);return n=n.filter(i=>r.match(i)),r.options.nonull&&!n.length&&n.push(e),n},"match");Mr.match=PH;var GO=/[?*]|[+@!]\(.*?\)|\[|\]/,FH=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Bn=class{static{o(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){wf(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||KO,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!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 r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!GO.test(s[2]))&&!GO.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 a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let r=0;r<e.length;r++)for(let i=0;i<e[r].length;i++)e[r][i]==="**"&&(e[r][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 r=-1;for(;(r=t.indexOf("**",r+1))!==-1;){let i=r;for(;t[i+1]==="**";)i++;i!==r&&t.splice(r,i-r)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),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 r=0;for(;(r=e.indexOf("..",r+1))!==-1;){let i=e[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=!0,e.splice(r-1,2),r-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let r of e){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let a=i;for(;r[a+1]==="**";)a++;a>i&&r.splice(i+1,a-i);let c=r[i+1],l=r[i+2],u=r[i+3];if(c!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;t=!0,r.splice(i,1);let f=r.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<r.length-1;a++){let c=r[a];a===1&&c===""&&r[0]===""||(c==="."||c==="")&&(t=!0,r.splice(a,1),a--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let a=r[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){t=!0;let l=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...l),r.length===0&&r.push(""),s-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let r=t+1;r<e.length;r++){let i=this.partsMatch(e[t],e[r],!this.preserveMultipleSlashes);if(i){e[t]=[],e[r]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,r=!1){let i=0,s=0,a=[],c="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])a.push(c==="b"?t[s]:e[i]),i++,s++;else if(r&&e[i]==="**"&&t[s]===e[i+1])a.push(e[i]),i++;else if(r&&t[s]==="**"&&e[i]===t[s+1])a.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",a.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",a.push(t[s]),i++,s++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,r=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,r++;r&&(this.pattern=e.slice(r)),this.negate=t}matchOne(e,t,r=!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,h=f?3:u?0:void 0;if(typeof d=="number"&&typeof h=="number"){let[p,y]=[e[d],t[h]];p.toLowerCase()===y.toLowerCase()&&(t[h]=p,s=h,i=d)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Gt)?this.#e(e,t,r,i,s):this.#r(e,t,r,i,s)}#e(e,t,r,i,s){let a=t.indexOf(Gt,s),c=t.lastIndexOf(Gt),[l,u,f]=r?[t.slice(s,a),t.slice(a+1),[]]:[t.slice(s,a),t.slice(a+1,c),t.slice(c+1)];if(l.length){let T=e.slice(i,i+l.length);if(!this.#r(T,l,r,0,0))return!1;i+=l.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let T=e.length-f.length;if(this.#r(e,f,r,T,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(T--,!this.#r(e,f,r,T,0)))return!1;d=f.length+1}}if(!u.length){let T=!!d;for(let C=i;C<e.length-d;C++){let M=String(e[C]);if(T=!0,M==="."||M===".."||!this.options.dot&&M.startsWith("."))return!1}return r||T}let h=[[[],0]],p=h[0],y=0,S=[0];for(let T of u)T===Gt?(S.push(y),p=[[],0],h.push(p)):(p[0].push(T),y++);let v=h.length-1,w=e.length-d;for(let T of h)T[1]=w-(S[v--]+T[0].length);return!!this.#n(e,h,i,0,r,0,!!d)}#n(e,t,r,i,s,a,c){let l=t[i];if(!l){for(let d=r;d<e.length;d++){c=!0;let h=e[d];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1}return c}let[u,f]=l;for(;r<=f;){if(this.#r(e.slice(0,r+u.length),u,s,r,0)&&a<this.maxGlobstarRecursion){let p=this.#n(e,t,r+u.length,i+1,s,a+1,c);if(p!==!1)return p}let h=e[r];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1;r++}return s||null}#r(e,t,r,i,s){let a,c,l,u;for(a=i,c=s,u=e.length,l=t.length;a<u&&c<l;a++,c++){this.debug("matchOne loop");let f=t[c],d=e[a];if(this.debug(t,f,d),f===!1||f===Gt)return!1;let h;if(typeof f=="string"?(h=d===f,this.debug("string match",f,d,h)):(h=f.test(d),this.debug("pattern match",f,d,h)),!h)return!1}if(a===u&&c===l)return!0;if(a===u)return r;if(c===l)return a===u-1&&e[a]==="";throw new Error("wtf?")}braceExpand(){return YO(this.pattern,this.options)}parse(e){wf(e);let t=this.options;if(e==="**")return Gt;if(e==="")return"";let r,i=null;(r=e.match(mH))?i=t.dot?yH:gH:(r=e.match(sH))?i=(t.nocase?t.dot?lH:cH:t.dot?oH:aH)(r[1]):(r=e.match(_H))?i=(t.nocase?t.dot?SH:bH:t.dot?wH:vH)(r):(r=e.match(uH))?i=t.dot?dH:fH:(r=e.match(hH))&&(i=pH);let s=Wo.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,r=t.noglobstar?AH:t.dot?xH:IH,i=new Set(t.nocase?["i"]:[]),s=e.map(l=>{let u=l.map(f=>{if(f instanceof RegExp)for(let d of f.flags.split(""))i.add(d);return typeof f=="string"?FH(f):f===Gt?Gt:f._src});return u.forEach((f,d)=>{let h=u[d+1],p=u[d-1];f!==Gt||p===Gt||(p===void 0?h!==void 0&&h!==Gt?u[d+1]="(?:\\/|"+r+"\\/)?"+h:u[d]=r:h===void 0?u[d-1]=p+"(?:\\/|"+r+")?":h!==Gt&&(u[d-1]=p+"(?:\\/|\\/"+r+"\\/)"+h,u[d+1]=Gt))}),u.filter(f=>f!==Gt).join("/")}).join("|"),[a,c]=e.length>1?["(?:",")"]:["",""];s="^"+a+s+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 r=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 a=i[i.length-1];if(!a)for(let c=i.length-2;!a&&c>=0;c--)a=i[c];for(let c=0;c<s.length;c++){let l=s[c],u=i;if(r.matchBase&&l.length===1&&(u=[a]),this.matchOne(u,l,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Mr.defaults(e).Minimatch}};Mr.AST=Wo;Mr.Minimatch=Bn;Mr.escape=Al;Mr.unescape=$i;var SP=require("node:url");var xl=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,JO=new Set,Zw=typeof process=="object"&&process?process:{},ZO=o((n,e,t,r)=>{typeof Zw.emitWarning=="function"?Zw.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)},"emitWarning"),qm=globalThis.AbortController,XO=globalThis.AbortSignal;if(typeof qm>"u"){XO=class{static{o(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},qm=class{static{o(this,"AbortController")}constructor(){e()}signal=new XO;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let i of this.signal._onabort)i(r);this.signal.onabort?.(r)}}};let n=Zw.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=o(()=>{n&&(n=!1,ZO("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))},"warnACPolyfill")}var DH=o(n=>!JO.has(n),"shouldWarn");var za=o(n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),"isPosInt"),eP=o(n=>za(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Il:null:null,"getUintArray"),Il=class extends Array{static{o(this,"ZeroArray")}constructor(e){super(e),this.fill(0)}},ev=class n{static{o(this,"Stack")}heap;length;static#e=!1;static create(e){let t=eP(e);if(!t)return[];n.#e=!0;let r=new n(e,t);return n.#e=!1,r}constructor(e,t){if(!n.#e)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]}},Ef=class n{static{o(this,"LRUCache")}#e;#n;#r;#t;#c;#_;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#u;#s;#l;#a;#p;#g;#d;#m;#y;#f;#E;#T;#b;#v;#S;#w;static unsafeExposeInternals(e){return{starts:e.#T,ttls:e.#b,sizes:e.#E,keyMap:e.#s,keyList:e.#l,valList:e.#a,next:e.#p,prev:e.#g,get head(){return e.#d},get tail(){return e.#m},free:e.#y,isBackgroundFetch:o(t=>e.#h(t),"isBackgroundFetch"),backgroundFetch:o((t,r,i,s)=>e.#M(t,r,i,s),"backgroundFetch"),moveToTail:o(t=>e.#V(t),"moveToTail"),indexes:o(t=>e.#C(t),"indexes"),rindexes:o(t=>e.#R(t),"rindexes"),isStale:o(t=>e.#A(t),"isStale")}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#u}get size(){return this.#i}get fetchMethod(){return this.#c}get memoMethod(){return this.#_}get dispose(){return this.#r}get disposeAfter(){return this.#t}constructor(e){let{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:c,allowStale:l,dispose:u,disposeAfter:f,noDisposeOnSet:d,noUpdateTTL:h,maxSize:p=0,maxEntrySize:y=0,sizeCalculation:S,fetchMethod:v,memoMethod:w,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:V,ignoreFetchAbort:ee}=e;if(t!==0&&!za(t))throw new TypeError("max option must be a nonnegative integer");let U=t?eP(t):Array;if(!U)throw new Error("invalid max value: "+t);if(this.#e=t,this.#n=p,this.maxEntrySize=y||this.#n,this.sizeCalculation=S,this.sizeCalculation){if(!this.#n&&!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(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#_=w,v!==void 0&&typeof v!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#c=v,this.#S=!!v,this.#s=new Map,this.#l=new Array(t).fill(void 0),this.#a=new Array(t).fill(void 0),this.#p=new U(t),this.#g=new U(t),this.#d=0,this.#m=0,this.#y=ev.create(t),this.#i=0,this.#u=0,typeof u=="function"&&(this.#r=u),typeof f=="function"?(this.#t=f,this.#f=[]):(this.#t=void 0,this.#f=void 0),this.#v=!!this.#r,this.#w=!!this.#t,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!V,this.ignoreFetchAbort=!!ee,this.maxEntrySize!==0){if(this.#n!==0&&!za(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!za(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#O()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!c,this.ttlResolution=za(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!za(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#x()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let W="LRU_CACHE_UNBOUNDED";DH(W)&&(JO.add(W),ZO("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",W,n))}}getRemainingTTL(e){return this.#s.has(e)?1/0:0}#x(){let e=new Il(this.#e),t=new Il(this.#e);this.#b=e,this.#T=t,this.#F=(s,a,c=xl.now())=>{if(t[s]=a!==0?c:0,e[s]=a,a!==0&&this.ttlAutopurge){let l=setTimeout(()=>{this.#A(s)&&this.#P(this.#l[s],"expire")},a+1);l.unref&&l.unref()}},this.#I=s=>{t[s]=e[s]!==0?xl.now():0},this.#o=(s,a)=>{if(e[a]){let c=e[a],l=t[a];if(!c||!l)return;s.ttl=c,s.start=l,s.now=r||i();let u=s.now-l;s.remainingTTL=c-u}};let r=0,i=o(()=>{let s=xl.now();if(this.ttlResolution>0){r=s;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return s},"getNow");this.getRemainingTTL=s=>{let a=this.#s.get(s);if(a===void 0)return 0;let c=e[a],l=t[a];if(!c||!l)return 1/0;let u=(r||i())-l;return c-u},this.#A=s=>{let a=t[s],c=e[s];return!!c&&!!a&&(r||i())-a>c}}#I=o(()=>{},"#updateItemAge");#o=o(()=>{},"#statusTTL");#F=o(()=>{},"#setItemTTL");#A=o(()=>!1,"#isStale");#O(){let e=new Il(this.#e);this.#u=0,this.#E=e,this.#D=t=>{this.#u-=e[t],e[t]=0},this.#L=(t,r,i,s)=>{if(this.#h(r))return 0;if(!za(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!za(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.#N=(t,r,i)=>{if(e[t]=r,this.#n){let s=this.#n-e[t];for(;this.#u>s;)this.#j(!0)}this.#u+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#u)}}#D=o(e=>{},"#removeItemSize");#N=o((e,t,r)=>{},"#addItemSize");#L=o((e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#C({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#m;!(!this.#k(t)||((e||!this.#A(t))&&(yield t),t===this.#d));)t=this.#g[t]}*#R({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#d;!(!this.#k(t)||((e||!this.#A(t))&&(yield t),t===this.#m));)t=this.#p[t]}#k(e){return e!==void 0&&this.#s.get(this.#l[e])===e}*entries(){for(let e of this.#C())this.#a[e]!==void 0&&this.#l[e]!==void 0&&!this.#h(this.#a[e])&&(yield[this.#l[e],this.#a[e]])}*rentries(){for(let e of this.#R())this.#a[e]!==void 0&&this.#l[e]!==void 0&&!this.#h(this.#a[e])&&(yield[this.#l[e],this.#a[e]])}*keys(){for(let e of this.#C()){let t=this.#l[e];t!==void 0&&!this.#h(this.#a[e])&&(yield t)}}*rkeys(){for(let e of this.#R()){let t=this.#l[e];t!==void 0&&!this.#h(this.#a[e])&&(yield t)}}*values(){for(let e of this.#C())this.#a[e]!==void 0&&!this.#h(this.#a[e])&&(yield this.#a[e])}*rvalues(){for(let e of this.#R())this.#a[e]!==void 0&&!this.#h(this.#a[e])&&(yield this.#a[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#C()){let i=this.#a[r],s=this.#h(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#l[r],this))return this.get(this.#l[r],t)}}forEach(e,t=this){for(let r of this.#C()){let i=this.#a[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#l[r],this)}}rforEach(e,t=this){for(let r of this.#R()){let i=this.#a[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#l[r],this)}}purgeStale(){let e=!1;for(let t of this.#R({allowStale:!0}))this.#A(t)&&(this.#P(this.#l[t],"expire"),e=!0);return e}info(e){let t=this.#s.get(e);if(t===void 0)return;let r=this.#a[t],i=this.#h(r)?r.__staleWhileFetching:r;if(i===void 0)return;let s={value:i};if(this.#b&&this.#T){let a=this.#b[t],c=this.#T[t];if(a&&c){let l=a-(xl.now()-c);s.ttl=l,s.start=Date.now()}}return this.#E&&(s.size=this.#E[t]),s}dump(){let e=[];for(let t of this.#C({allowStale:!0})){let r=this.#l[t],i=this.#a[t],s=this.#h(i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;let a={value:s};if(this.#b&&this.#T){a.ttl=this.#b[t];let c=xl.now()-this.#T[t];a.start=Math.floor(Date.now()-c)}this.#E&&(a.size=this.#E[t]),e.unshift([r,a])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=xl.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:l}=r,{noUpdateTTL:u=this.noUpdateTTL}=r,f=this.#L(e,t,r.size||0,c);if(this.maxEntrySize&&f>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#P(e,"set"),this;let d=this.#i===0?void 0:this.#s.get(e);if(d===void 0)d=this.#i===0?this.#m:this.#y.length!==0?this.#y.pop():this.#i===this.#e?this.#j(!1):this.#i,this.#l[d]=e,this.#a[d]=t,this.#s.set(e,d),this.#p[this.#m]=d,this.#g[d]=this.#m,this.#m=d,this.#i++,this.#N(d,f,l),l&&(l.set="add"),u=!1;else{this.#V(d);let h=this.#a[d];if(t!==h){if(this.#S&&this.#h(h)){h.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=h;p!==void 0&&!a&&(this.#v&&this.#r?.(p,e,"set"),this.#w&&this.#f?.push([p,e,"set"]))}else a||(this.#v&&this.#r?.(h,e,"set"),this.#w&&this.#f?.push([h,e,"set"]));if(this.#D(d),this.#N(d,f,l),this.#a[d]=t,l){l.set="replace";let p=h&&this.#h(h)?h.__staleWhileFetching:h;p!==void 0&&(l.oldValue=p)}}else l&&(l.set="update")}if(i!==0&&!this.#b&&this.#x(),this.#b&&(u||this.#F(d,i,s),l&&this.#o(l,d)),!a&&this.#w&&this.#f){let h=this.#f,p;for(;p=h?.shift();)this.#t?.(...p)}return this}pop(){try{for(;this.#i;){let e=this.#a[this.#d];if(this.#j(!0),this.#h(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#w&&this.#f){let e=this.#f,t;for(;t=e?.shift();)this.#t?.(...t)}}}#j(e){let t=this.#d,r=this.#l[t],i=this.#a[t];return this.#S&&this.#h(i)?i.__abortController.abort(new Error("evicted")):(this.#v||this.#w)&&(this.#v&&this.#r?.(i,r,"evict"),this.#w&&this.#f?.push([i,r,"evict"])),this.#D(t),e&&(this.#l[t]=void 0,this.#a[t]=void 0,this.#y.push(t)),this.#i===1?(this.#d=this.#m=0,this.#y.length=0):this.#d=this.#p[t],this.#s.delete(r),this.#i--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,s=this.#s.get(e);if(s!==void 0){let a=this.#a[s];if(this.#h(a)&&a.__staleWhileFetching===void 0)return!1;if(this.#A(s))i&&(i.has="stale",this.#o(i,s));else return r&&this.#I(s),i&&(i.has="hit",this.#o(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,i=this.#s.get(e);if(i===void 0||!r&&this.#A(i))return;let s=this.#a[i];return this.#h(s)?s.__staleWhileFetching:s}#M(e,t,r,i){let s=t===void 0?void 0:this.#a[t];if(this.#h(s))return s;let a=new qm,{signal:c}=r;c?.addEventListener("abort",()=>a.abort(c.reason),{signal:a.signal});let l={signal:a.signal,options:r,context:i},u=o((S,v=!1)=>{let{aborted:w}=a.signal,T=r.ignoreFetchAbort&&S!==void 0;if(r.status&&(w&&!v?(r.status.fetchAborted=!0,r.status.fetchError=a.signal.reason,T&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),w&&!T&&!v)return d(a.signal.reason);let C=p;return this.#a[t]===p&&(S===void 0?C.__staleWhileFetching?this.#a[t]=C.__staleWhileFetching:this.#P(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,S,l.options))),S},"cb"),f=o(S=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=S),d(S)),"eb"),d=o(S=>{let{aborted:v}=a.signal,w=v&&r.allowStaleOnFetchAbort,T=w||r.allowStaleOnFetchRejection,C=T||r.noDeleteOnFetchRejection,M=p;if(this.#a[t]===p&&(!C||M.__staleWhileFetching===void 0?this.#P(e,"fetch"):w||(this.#a[t]=M.__staleWhileFetching)),T)return r.status&&M.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),M.__staleWhileFetching;if(M.__returned===M)throw S},"fetchFail"),h=o((S,v)=>{let w=this.#c?.(e,s,l);w&&w instanceof Promise&&w.then(T=>S(T===void 0?void 0:T),v),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(S(void 0),r.allowStaleOnFetchAbort&&(S=o(T=>u(T,!0),"res")))})},"pcall");r.status&&(r.status.fetchDispatched=!0);let p=new Promise(h).then(u,f),y=Object.assign(p,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,y,{...l.options,status:void 0}),t=this.#s.get(e)):this.#a[t]=y,y}#h(e){if(!this.#S)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof qm}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:l=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:y=this.allowStaleOnFetchAbort,context:S,forceRefresh:v=!1,status:w,signal:T}=t;if(!this.#S)return w&&(w.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:w});let C={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:c,size:l,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:y,ignoreFetchAbort:p,status:w,signal:T},M=this.#s.get(e);if(M===void 0){w&&(w.fetch="miss");let V=this.#M(e,M,C,S);return V.__returned=V}else{let V=this.#a[M];if(this.#h(V)){let N=r&&V.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",N&&(w.returnedStale=!0)),N?V.__staleWhileFetching:V.__returned=V}let ee=this.#A(M);if(!v&&!ee)return w&&(w.fetch="hit"),this.#V(M),i&&this.#I(M),w&&this.#o(w,M),V;let U=this.#M(e,M,C,S),P=U.__staleWhileFetching!==void 0&&r;return w&&(w.fetch=ee?"stale":"refresh",P&&ee&&(w.returnedStale=!0)),P?U.__staleWhileFetching:U.__returned=U}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#_;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...a}=t,c=this.get(e,a);if(!s&&c!==void 0)return c;let l=r(e,c,{options:a,context:i});return this.set(e,l,a),l}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,c=this.#s.get(e);if(c!==void 0){let l=this.#a[c],u=this.#h(l);return a&&this.#o(a,c),this.#A(c)?(a&&(a.get="stale"),u?(a&&r&&l.__staleWhileFetching!==void 0&&(a.returnedStale=!0),r?l.__staleWhileFetching:void 0):(s||this.#P(e,"expire"),a&&r&&(a.returnedStale=!0),r?l:void 0)):(a&&(a.get="hit"),u?l.__staleWhileFetching:(this.#V(c),i&&this.#I(c),l))}else a&&(a.get="miss")}#$(e,t){this.#g[t]=e,this.#p[e]=t}#V(e){e!==this.#m&&(e===this.#d?this.#d=this.#p[e]:this.#$(this.#g[e],this.#p[e]),this.#$(this.#m,e),this.#m=e)}delete(e){return this.#P(e,"delete")}#P(e,t){let r=!1;if(this.#i!==0){let i=this.#s.get(e);if(i!==void 0)if(r=!0,this.#i===1)this.#B(t);else{this.#D(i);let s=this.#a[i];if(this.#h(s)?s.__abortController.abort(new Error("deleted")):(this.#v||this.#w)&&(this.#v&&this.#r?.(s,e,t),this.#w&&this.#f?.push([s,e,t])),this.#s.delete(e),this.#l[i]=void 0,this.#a[i]=void 0,i===this.#m)this.#m=this.#g[i];else if(i===this.#d)this.#d=this.#p[i];else{let a=this.#g[i];this.#p[a]=this.#p[i];let c=this.#p[i];this.#g[c]=this.#g[i]}this.#i--,this.#y.push(i)}}if(this.#w&&this.#f?.length){let i=this.#f,s;for(;s=i?.shift();)this.#t?.(...s)}return r}clear(){return this.#B("delete")}#B(e){for(let t of this.#R({allowStale:!0})){let r=this.#a[t];if(this.#h(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#l[t];this.#v&&this.#r?.(r,i,e),this.#w&&this.#f?.push([r,i,e])}}if(this.#s.clear(),this.#a.fill(void 0),this.#l.fill(void 0),this.#b&&this.#T&&(this.#b.fill(0),this.#T.fill(0)),this.#E&&this.#E.fill(0),this.#d=0,this.#m=0,this.#y.length=0,this.#u=0,this.#i=0,this.#w&&this.#f){let t=this.#f,r;for(;r=t?.shift();)this.#t?.(...r)}}};var Ol=require("node:path"),uP=require("node:url"),vs=require("fs"),qH=le(require("node:fs"),1),Ka=require("node:fs/promises");var Ym=require("node:events"),ov=le(require("node:stream"),1),sP=require("node:string_decoder");var tP=typeof process=="object"&&process?process:{stdout:null,stderr:null},NH=o(n=>!!n&&typeof n=="object"&&(n instanceof Qa||n instanceof ov.default||LH(n)||kH(n)),"isStream"),LH=o(n=>!!n&&typeof n=="object"&&n instanceof Ym.EventEmitter&&typeof n.pipe=="function"&&n.pipe!==ov.default.Writable.prototype.pipe,"isReadable"),kH=o(n=>!!n&&typeof n=="object"&&n instanceof Ym.EventEmitter&&typeof n.write=="function"&&typeof n.end=="function","isWritable"),la=Symbol("EOF"),ua=Symbol("maybeEmitEnd"),Ha=Symbol("emittedEnd"),Wm=Symbol("emittingEnd"),Tf=Symbol("emittedError"),Gm=Symbol("closed"),rP=Symbol("read"),zm=Symbol("flush"),nP=Symbol("flushChunk"),Vi=Symbol("encoding"),Cl=Symbol("decoder"),Er=Symbol("flowing"),Af=Symbol("paused"),Rl=Symbol("resume"),Tr=Symbol("buffer"),bn=Symbol("pipes"),Ar=Symbol("bufferLength"),tv=Symbol("bufferPush"),Hm=Symbol("bufferShift"),Yr=Symbol("objectMode"),zt=Symbol("destroyed"),rv=Symbol("error"),nv=Symbol("emitData"),iP=Symbol("emitEnd"),iv=Symbol("emitEnd2"),Ss=Symbol("async"),sv=Symbol("abort"),Qm=Symbol("aborted"),xf=Symbol("signal"),Go=Symbol("dataListeners"),Un=Symbol("discarded"),If=o(n=>Promise.resolve().then(n),"defer"),jH=o(n=>n(),"nodefer"),MH=o(n=>n==="end"||n==="finish"||n==="prefinish","isEndish"),$H=o(n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,"isArrayBufferLike"),VH=o(n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),"isArrayBufferView"),Km=class{static{o(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[Rl](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},av=class extends Km{static{o(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,r){super(e,t,r),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},BH=o(n=>!!n.objectMode,"isObjectModeOptions"),UH=o(n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer","isEncodingOptions"),Qa=class extends Ym.EventEmitter{static{o(this,"Minipass")}[Er]=!1;[Af]=!1;[bn]=[];[Tr]=[];[Yr];[Vi];[Ss];[Cl];[la]=!1;[Ha]=!1;[Wm]=!1;[Gm]=!1;[Tf]=null;[Ar]=0;[zt]=!1;[xf];[Qm]=!1;[Go]=0;[Un]=!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");BH(t)?(this[Yr]=!0,this[Vi]=null):UH(t)?(this[Vi]=t.encoding,this[Yr]=!1):(this[Yr]=!1,this[Vi]=null),this[Ss]=!!t.async,this[Cl]=this[Vi]?new sP.StringDecoder(this[Vi]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:o(()=>this[Tr],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:o(()=>this[bn],"get")});let{signal:r}=t;r&&(this[xf]=r,r.aborted?this[sv]():r.addEventListener("abort",()=>this[sv]()))}get bufferLength(){return this[Ar]}get encoding(){return this[Vi]}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[Yr]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Ss]}set async(e){this[Ss]=this[Ss]||!!e}[sv](){this[Qm]=!0,this.emit("abort",this[xf]?.reason),this.destroy(this[xf]?.reason)}get aborted(){return this[Qm]}set aborted(e){}write(e,t,r){if(this[Qm])return!1;if(this[la])throw new Error("write after end");if(this[zt])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(r=t,t="utf8"),t||(t="utf8");let i=this[Ss]?If:jH;if(!this[Yr]&&!Buffer.isBuffer(e)){if(VH(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if($H(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Yr]?(this[Er]&&this[Ar]!==0&&this[zm](!0),this[Er]?this.emit("data",e):this[tv](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Er]):e.length?(typeof e=="string"&&!(t===this[Vi]&&!this[Cl]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Vi]&&(e=this[Cl].write(e)),this[Er]&&this[Ar]!==0&&this[zm](!0),this[Er]?this.emit("data",e):this[tv](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Er]):(this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Er])}read(e){if(this[zt])return null;if(this[Un]=!1,this[Ar]===0||e===0||e&&e>this[Ar])return this[ua](),null;this[Yr]&&(e=null),this[Tr].length>1&&!this[Yr]&&(this[Tr]=[this[Vi]?this[Tr].join(""):Buffer.concat(this[Tr],this[Ar])]);let t=this[rP](e||null,this[Tr][0]);return this[ua](),t}[rP](e,t){if(this[Yr])this[Hm]();else{let r=t;e===r.length||e===null?this[Hm]():typeof r=="string"?(this[Tr][0]=r.slice(e),t=r.slice(0,e),this[Ar]-=e):(this[Tr][0]=r.subarray(e),t=r.subarray(0,e),this[Ar]-=e)}return this.emit("data",t),!this[Tr].length&&!this[la]&&this.emit("drain"),t}end(e,t,r){return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t="utf8"),e!==void 0&&this.write(e,t),r&&this.once("end",r),this[la]=!0,this.writable=!1,(this[Er]||!this[Af])&&this[ua](),this}[Rl](){this[zt]||(!this[Go]&&!this[bn].length&&(this[Un]=!0),this[Af]=!1,this[Er]=!0,this.emit("resume"),this[Tr].length?this[zm]():this[la]?this[ua]():this.emit("drain"))}resume(){return this[Rl]()}pause(){this[Er]=!1,this[Af]=!0,this[Un]=!1}get destroyed(){return this[zt]}get flowing(){return this[Er]}get paused(){return this[Af]}[tv](e){this[Yr]?this[Ar]+=1:this[Ar]+=e.length,this[Tr].push(e)}[Hm](){return this[Yr]?this[Ar]-=1:this[Ar]-=this[Tr][0].length,this[Tr].shift()}[zm](e=!1){do;while(this[nP](this[Hm]())&&this[Tr].length);!e&&!this[Tr].length&&!this[la]&&this.emit("drain")}[nP](e){return this.emit("data",e),this[Er]}pipe(e,t){if(this[zt])return e;this[Un]=!1;let r=this[Ha];return t=t||{},e===tP.stdout||e===tP.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[bn].push(t.proxyErrors?new av(this,e,t):new Km(this,e,t)),this[Ss]?If(()=>this[Rl]()):this[Rl]()),e}unpipe(e){let t=this[bn].find(r=>r.dest===e);t&&(this[bn].length===1?(this[Er]&&this[Go]===0&&(this[Er]=!1),this[bn]=[]):this[bn].splice(this[bn].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let r=super.on(e,t);if(e==="data")this[Un]=!1,this[Go]++,!this[bn].length&&!this[Er]&&this[Rl]();else if(e==="readable"&&this[Ar]!==0)super.emit("readable");else if(MH(e)&&this[Ha])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Tf]){let i=t;this[Ss]?If(()=>i.call(this,this[Tf])):i.call(this,this[Tf])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[Go]=this.listeners("data").length,this[Go]===0&&!this[Un]&&!this[bn].length&&(this[Er]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Go]=0,!this[Un]&&!this[bn].length&&(this[Er]=!1)),t}get emittedEnd(){return this[Ha]}[ua](){!this[Wm]&&!this[Ha]&&!this[zt]&&this[Tr].length===0&&this[la]&&(this[Wm]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Gm]&&this.emit("close"),this[Wm]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==zt&&this[zt])return!1;if(e==="data")return!this[Yr]&&!r?!1:this[Ss]?(If(()=>this[nv](r)),!0):this[nv](r);if(e==="end")return this[iP]();if(e==="close"){if(this[Gm]=!0,!this[Ha]&&!this[zt])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[Tf]=r,super.emit(rv,r);let s=!this[xf]||this.listeners("error").length?super.emit("error",r):!1;return this[ua](),s}else if(e==="resume"){let s=super.emit("resume");return this[ua](),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[ua](),i}[nv](e){for(let r of this[bn])r.dest.write(e)===!1&&this.pause();let t=this[Un]?!1:super.emit("data",e);return this[ua](),t}[iP](){return this[Ha]?!1:(this[Ha]=!0,this.readable=!1,this[Ss]?(If(()=>this[iv]()),!0):this[iv]())}[iv](){if(this[Cl]){let t=this[Cl].end();if(t){for(let r of this[bn])r.dest.write(t);this[Un]||super.emit("data",t)}}for(let t of this[bn])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Yr]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[Yr]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[Yr])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Vi]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(zt,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Un]=!1;let e=!1,t=o(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:o(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[la])return t();let s,a,c=o(d=>{this.off("data",l),this.off("end",u),this.off(zt,f),t(),a(d)},"onerr"),l=o(d=>{this.off("error",c),this.off("end",u),this.off(zt,f),this.pause(),s({value:d,done:!!this[la]})},"ondata"),u=o(()=>{this.off("error",c),this.off("data",l),this.off(zt,f),t(),s({done:!0,value:void 0})},"onend"),f=o(()=>c(new Error("stream destroyed")),"ondestroy");return new Promise((d,h)=>{a=h,s=d,this.once(zt,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[Un]=!1;let e=!1,t=o(()=>(this.pause(),this.off(rv,t),this.off(zt,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),r=o(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(rv,t),this.once(zt,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[zt])return e?this.emit("error",e):this.emit(zt),this;this[zt]=!0,this[Un]=!0,this[Tr].length=0,this[Ar]=0;let t=this;return typeof t.close=="function"&&!this[Gm]&&t.close(),e?this.emit("error",e):this.emit(zt),this}static get isStream(){return NH}};var WH=vs.realpathSync.native,Rf={lstatSync:vs.lstatSync,readdir:vs.readdir,readdirSync:vs.readdirSync,readlinkSync:vs.readlinkSync,realpathSync:WH,promises:{lstat:Ka.lstat,readdir:Ka.readdir,readlink:Ka.readlink,realpath:Ka.realpath}},fP=o(n=>!n||n===Rf||n===qH?Rf:{...Rf,...n,promises:{...Rf.promises,...n.promises||{}}},"fsFromOption"),dP=/^\\\\\?\\([a-z]:)\\?$/i,GH=o(n=>n.replace(/\//g,"\\").replace(dP,"$1\\"),"uncToDrive"),zH=/[\\\/]/,si=0,hP=1,pP=2,ws=4,mP=6,gP=8,zo=10,yP=12,ii=15,Cf=~ii,cv=16,aP=32,Of=64,Bi=128,Xm=256,Zm=512,oP=Of|Bi|Zm,HH=1023,lv=o(n=>n.isFile()?gP:n.isDirectory()?ws:n.isSymbolicLink()?zo:n.isCharacterDevice()?pP:n.isBlockDevice()?mP:n.isSocket()?yP:n.isFIFO()?hP:si,"entToType"),cP=new Map,Pf=o(n=>{let e=cP.get(n);if(e)return e;let t=n.normalize("NFKD");return cP.set(n,t),t},"normalize"),lP=new Map,Jm=o(n=>{let e=lP.get(n);if(e)return e;let t=Pf(n.toLowerCase());return lP.set(n,t),t},"normalizeNocase"),eg=class extends Ef{static{o(this,"ResolveCache")}constructor(){super({max:256})}},uv=class extends Ef{static{o(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:o(t=>t.length+1,"sizeCalculation")})}},_P=Symbol("PathScurry setAsCwd"),Xr=class{static{o(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#e;#n;get dev(){return this.#n}#r;get mode(){return this.#r}#t;get nlink(){return this.#t}#c;get uid(){return this.#c}#_;get gid(){return this.#_}#i;get rdev(){return this.#i}#u;get blksize(){return this.#u}#s;get ino(){return this.#s}#l;get size(){return this.#l}#a;get blocks(){return this.#a}#p;get atimeMs(){return this.#p}#g;get mtimeMs(){return this.#g}#d;get ctimeMs(){return this.#d}#m;get birthtimeMs(){return this.#m}#y;get atime(){return this.#y}#f;get mtime(){return this.#f}#E;get ctime(){return this.#E}#T;get birthtime(){return this.#T}#b;#v;#S;#w;#x;#I;#o;#F;#A;#O;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=si,r,i,s,a,c){this.name=e,this.#b=s?Jm(e):Pf(e),this.#o=t&HH,this.nocase=s,this.roots=i,this.root=r||this,this.#F=a,this.#S=c.fullpath,this.#x=c.relative,this.#I=c.relativePosix,this.parent=c.parent,this.parent?this.#e=this.parent.#e:this.#e=fP(c.fs)}depth(){return this.#v!==void 0?this.#v:this.parent?this.#v=this.parent.depth()+1:this.#v=0}childrenCache(){return this.#F}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 r of e)t=t.child(r);return t}children(){let e=this.#F.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#F.set(this,t),this.#o&=~cv,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?Jm(e):Pf(e);for(let l of r)if(l.#b===i)return l;let s=this.parent?this.sep:"",a=this.#S?this.#S+s+e:void 0,c=this.newChild(e,si,{...t,parent:this,fullpath:a});return this.canReaddir()||(c.#o|=Bi),r.push(c),c}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.name;let r=t.relative();return r+(!r||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let e=this.name,t=this.parent;if(!t)return this.#I=this.fullpathPosix();let r=t.relativePosix();return r+(!r||!t.parent?"":"/")+e}fullpath(){if(this.#S!==void 0)return this.#S;let e=this.name,t=this.parent;if(!t)return this.#S=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#S=i}fullpathPosix(){if(this.#w!==void 0)return this.#w;if(this.sep==="/")return this.#w=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#w=`//?/${i}`:this.#w=i}let e=this.parent,t=e.fullpathPosix(),r=t+(!t||!e.parent?"":"/")+this.name;return this.#w=r}isUnknown(){return(this.#o&ii)===si}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.#o&ii)===gP}isDirectory(){return(this.#o&ii)===ws}isCharacterDevice(){return(this.#o&ii)===pP}isBlockDevice(){return(this.#o&ii)===mP}isFIFO(){return(this.#o&ii)===hP}isSocket(){return(this.#o&ii)===yP}isSymbolicLink(){return(this.#o&zo)===zo}lstatCached(){return this.#o&aP?this:void 0}readlinkCached(){return this.#A}realpathCached(){return this.#O}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#A)return!0;if(!this.parent)return!1;let e=this.#o&ii;return!(e!==si&&e!==zo||this.#o&Xm||this.#o&Bi)}calledReaddir(){return!!(this.#o&cv)}isENOENT(){return!!(this.#o&Bi)}isNamed(e){return this.nocase?this.#b===Jm(e):this.#b===Pf(e)}async readlink(){let e=this.#A;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),r=(await this.parent.realpath())?.resolve(t);if(r)return this.#A=r}catch(t){this.#h(t.code);return}}readlinkSync(){let e=this.#A;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),r=this.parent.realpathSync()?.resolve(t);if(r)return this.#A=r}catch(t){this.#h(t.code);return}}#N(e){this.#o|=cv;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#L()}}#L(){this.#o&Bi||(this.#o=(this.#o|Bi)&Cf,this.#C())}#C(){let e=this.children();e.provisional=0;for(let t of e)t.#L()}#R(){this.#o|=Zm,this.#k()}#k(){if(this.#o&Of)return;let e=this.#o;(e&ii)===ws&&(e&=Cf),this.#o=e|Of,this.#C()}#j(e=""){e==="ENOTDIR"||e==="EPERM"?this.#k():e==="ENOENT"?this.#L():this.children().provisional=0}#M(e=""){e==="ENOTDIR"?this.parent.#k():e==="ENOENT"&&this.#L()}#h(e=""){let t=this.#o;t|=Xm,e==="ENOENT"&&(t|=Bi),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Cf),this.#o=t,e==="ENOTDIR"&&this.parent&&this.parent.#k()}#$(e,t){return this.#P(e,t)||this.#V(e,t)}#V(e,t){let r=lv(e),i=this.newChild(e.name,r,{parent:this}),s=i.#o&ii;return s!==ws&&s!==zo&&s!==si&&(i.#o|=Of),t.unshift(i),t.provisional++,i}#P(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?Jm(e.name):Pf(e.name))===i.#b)return this.#B(e,i,r,t)}}#B(e,t,r,i){let s=t.name;return t.#o=t.#o&Cf|lv(e),s!==e.name&&(t.name=e.name),r!==i.provisional&&(r===i.length-1?i.pop():i.splice(r,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#o&Bi)===0)try{return this.#G(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#M(e.code)}}lstatSync(){if((this.#o&Bi)===0)try{return this.#G(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#M(e.code)}}#G(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:s,blksize:a,blocks:c,ctime:l,ctimeMs:u,dev:f,gid:d,ino:h,mode:p,mtime:y,mtimeMs:S,nlink:v,rdev:w,size:T,uid:C}=e;this.#y=t,this.#p=r,this.#T=i,this.#m=s,this.#u=a,this.#a=c,this.#E=l,this.#d=u,this.#n=f,this.#_=d,this.#s=h,this.#r=p,this.#f=y,this.#g=S,this.#t=v,this.#i=w,this.#l=T,this.#c=C;let M=lv(e);this.#o=this.#o&Cf|M|aP,M!==si&&M!==ws&&M!==zo&&(this.#o|=Of)}#q=[];#W=!1;#z(e){this.#W=!1;let t=this.#q.slice();this.#q.length=0,t.forEach(r=>r(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let r=this.children();if(this.calledReaddir()){let s=r.slice(0,r.provisional);t?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#q.push(e),this.#W)return;this.#W=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,a)=>{if(s)this.#j(s.code),r.provisional=0;else{for(let c of a)this.#$(c,r);this.#N(r)}this.#z(r.slice(0,r.provisional))})}#U;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.#U)await this.#U;else{let r=o(()=>{},"resolve");this.#U=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#$(i,e);this.#N(e)}catch(i){this.#j(i.code),e.provisional=0}this.#U=void 0,r()}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 r of this.#e.readdirSync(t,{withFileTypes:!0}))this.#$(r,e);this.#N(e)}catch(r){this.#j(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#o&oP)return!1;let e=ii&this.#o;return e===si||e===ws||e===zo}shouldWalk(e,t){return(this.#o&ws)===ws&&!(this.#o&oP)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#O)return this.#O;if(!((Zm|Xm|Bi)&this.#o))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#O=this.resolve(e)}catch{this.#R()}}realpathSync(){if(this.#O)return this.#O;if(!((Zm|Xm|Bi)&this.#o))try{let e=this.#e.realpathSync(this.fullpath());return this.#O=this.resolve(e)}catch{this.#R()}}[_P](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),r=[],i=this;for(;i&&i.parent;)t.add(i),i.#x=r.join(this.sep),i.#I=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#x=void 0,i.#I=void 0,i=i.parent}},tg=class n extends Xr{static{o(this,"PathWin32")}sep="\\";splitSep=zH;constructor(e,t=si,r,i,s,a,c){super(e,t,r,i,s,a,c)}newChild(e,t=si,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return Ol.win32.parse(e).root}getRoot(e){if(e=GH(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,r]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=r;return this.roots[e]=new Pl(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(dP,"$1\\"),e===t}},rg=class n extends Xr{static{o(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=si,r,i,s,a,c){super(e,t,r,i,s,a,c)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=si,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},ng=class{static{o(this,"PathScurryBase")}root;rootPath;roots;cwd;#e;#n;#r;nocase;#t;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:s=16*1024,fs:a=Rf}={}){this.#t=fP(a),(e instanceof URL||e.startsWith("file://"))&&(e=(0,uP.fileURLToPath)(e));let c=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(c),this.#e=new eg,this.#n=new eg,this.#r=new uv(s);let l=c.substring(this.rootPath.length).split(r);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.#t),this.roots[this.rootPath]=this.root;let u=this.root,f=l.length-1,d=t.sep,h=this.rootPath,p=!1;for(let y of l){let S=f--;u=u.child(y,{relative:new Array(S).fill("..").join(d),relativePosix:new Array(S).fill("..").join("/"),fullpath:h+=(p?"":d)+y}),p=!0}this.cwd=u}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#r}resolve(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#e.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpath();return this.#e.set(t,i),i}resolvePosix(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#n.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpathPosix();return this.#n.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 Xr||(t=e,e=this.cwd);let{withFileTypes:r}=t;if(e.canReaddir()){let i=await e.readdir();return r?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 Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0}=t;return e.canReaddir()?r?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 Xr||(t=e.withFileTypes,e=this.cwd);let r=await e.readlink();return t?r:r?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e.withFileTypes,e=this.cwd);let r=e.readlinkSync();return t?r:r?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e.withFileTypes,e=this.cwd);let r=await e.realpath();return t?r:r?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e.withFileTypes,e=this.cwd);let r=e.realpathSync();return t?r:r?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?e:e.fullpath());let l=new Set,u=o((d,h)=>{l.add(d),d.readdirCB((p,y)=>{if(p)return h(p);let S=y.length;if(!S)return h();let v=o(()=>{--S===0&&h()},"next");for(let w of y)(!s||s(w))&&c.push(r?w:w.fullpath()),i&&w.isSymbolicLink()?w.realpath().then(T=>T?.isUnknown()?T.lstat():T).then(T=>T?.shouldWalk(l,a)?u(T,v):v()):w.shouldWalk(l,a)?u(w,v):v()},!0)},"walk"),f=e;return new Promise((d,h)=>{u(f,p=>{if(p)return h(p);d(c)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?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(r?d:d.fullpath());let h=d;if(d.isSymbolicLink()){if(!(i&&(h=d.realpathSync())))continue;h.isUnknown()&&h.lstatSync()}h.shouldWalk(l,a)&&l.add(h)}}return c}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(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 Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t;(!s||s(e))&&(yield r?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 r?f:f.fullpath());let d=f;if(f.isSymbolicLink()){if(!(i&&(d=f.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,a)&&c.add(d)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new Qa({objectMode:!0});(!s||s(e))&&c.write(r?e:e.fullpath());let l=new Set,u=[e],f=0,d=o(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&c.end();return}f++,l.add(p);let y=o((v,w,T=!1)=>{if(v)return c.emit("error",v);if(i&&!T){let C=[];for(let M of w)M.isSymbolicLink()&&C.push(M.realpath().then(V=>V?.isUnknown()?V.lstat():V));if(C.length){Promise.all(C).then(()=>y(null,w,!0));return}}for(let C of w)C&&(!s||s(C))&&(c.write(r?C:C.fullpath())||(h=!0));f--;for(let C of w){let M=C.realpathCached()||C;M.shouldWalk(l,a)&&u.push(M)}h&&!c.flowing?c.once("drain",d):S||d()},"onReaddir"),S=!0;p.readdirCB(y,!0),S=!1}},"process");return d(),c}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new Qa({objectMode:!0}),l=new Set;(!s||s(e))&&c.write(r?e:e.fullpath());let u=[e],f=0,d=o(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&c.end();return}f++,l.add(p);let y=p.readdirSync();for(let S of y)(!s||s(S))&&(c.write(r?S:S.fullpath())||(h=!0));f--;for(let S of y){let v=S;if(S.isSymbolicLink()){if(!(i&&(v=S.realpathSync())))continue;v.isUnknown()&&v.lstatSync()}v.shouldWalk(l,a)&&u.push(v)}}h&&!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[_P](t)}},Pl=class extends ng{static{o(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,Ol.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return Ol.win32.parse(e).root.toUpperCase()}newRoot(e){return new tg(this.rootPath,ws,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Fl=class extends ng{static{o(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,Ol.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new rg(this.rootPath,ws,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},Ff=class extends Fl{static{o(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},eue=process.platform==="win32"?tg:rg,bP=process.platform==="win32"?Pl:process.platform==="darwin"?Ff:Fl;var QH=o(n=>n.length>=1,"isPatternList"),KH=o(n=>n.length>=1,"isGlobList"),Dl=class n{static{o(this,"Pattern")}#e;#n;#r;length;#t;#c;#_;#i;#u;#s;#l=!0;constructor(e,t,r,i){if(!QH(e))throw new TypeError("empty pattern list");if(!KH(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,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#n=t,this.#r=r,this.#t=i,this.#r===0){if(this.isUNC()){let[s,a,c,l,...u]=this.#e,[f,d,h,p,...y]=this.#n;u[0]===""&&(u.shift(),y.shift());let S=[s,a,c,l,""].join("/"),v=[f,d,h,p,""].join("/");this.#e=[S,...u],this.#n=[v,...y],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...a]=this.#e,[c,...l]=this.#n;a[0]===""&&(a.shift(),l.shift());let u=s+"/",f=c+"/";this.#e=[u,...a],this.#n=[f,...l],this.length=this.#e.length}}}pattern(){return this.#e[this.#r]}isString(){return typeof this.#e[this.#r]=="string"}isGlobstar(){return this.#e[this.#r]===Gt}isRegExp(){return this.#e[this.#r]instanceof RegExp}globString(){return this.#_=this.#_||(this.#r===0?this.isAbsolute()?this.#n[0]+this.#n.slice(1).join("/"):this.#n.join("/"):this.#n.slice(this.#r).join("/"))}hasMore(){return this.length>this.#r+1}rest(){return this.#c!==void 0?this.#c:this.hasMore()?(this.#c=new n(this.#e,this.#n,this.#r+1,this.#t),this.#c.#s=this.#s,this.#c.#u=this.#u,this.#c.#i=this.#i,this.#c):this.#c=null}isUNC(){let e=this.#e;return this.#u!==void 0?this.#u:this.#u=this.#t==="win32"&&this.#r===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#i!==void 0?this.#i:this.#i=this.#t==="win32"&&this.#r===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#s!==void 0?this.#s:this.#s=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#r===0?e:""}checkFollowGlobstar(){return!(this.#r===0||!this.isGlobstar()||!this.#l)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#l?!1:(this.#l=!1,!0)}};var YH=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Nl=class{static{o(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:s,platform:a=YH}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:s,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let c of e)this.add(c)}add(e){let t=new Bn(e,this.mmopts);for(let r=0;r<t.set.length;r++){let i=t.set[r],s=t.globParts[r];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let a=new Dl(i,s,0,this.platform),c=new Bn(a.globString(),this.mmopts),l=s[s.length-1]==="**",u=a.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(),r=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let a of this.relative)if(a.match(i)||a.match(s))return!0;for(let a of this.absolute)if(a.match(t)||a.match(r))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",r=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(r))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}};var fv=class n{static{o(this,"HasWalkedCache")}store;constructor(e=new Map){this.store=e}copy(){return new n(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let r=e.fullpath(),i=this.store.get(r);i?i.add(t.globString()):this.store.set(r,new Set([t.globString()]))}},dv=class{static{o(this,"MatchRecord")}store=new Map;add(e,t,r){let i=(t?2:0)|(r?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)])}},hv=class{static{o(this,"SubWalks")}store=new Map;add(e,t){if(!e.canReaddir())return;let r=this.store.get(e);r?r.find(i=>i.globString()===t.globString())||r.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())}},Df=class n{static{o(this,"Processor")}hasWalkedCache;matches=new dv;subwalks=new hv;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new fv}processPatterns(e,t){this.patterns=t;let r=t.map(i=>[e,i]);for(let[i,s]of r){this.hasWalkedCache.storeWalked(i,s);let a=s.root(),c=s.isAbsolute()&&this.opts.absolute!==!1;if(a){i=i.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);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===Gt){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let d=u?.pattern(),h=u?.rest();if(!u||(d===""||d===".")&&!h)this.matches.add(i,c,d===""||d===".");else if(d===".."){let p=i.parent||i;h?this.hasWalkedCache.hasWalked(p,h)||this.subwalks.add(p,h):this.matches.add(p,c,!0)}}else l instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new n(this.opts,this.hasWalkedCache)}filterEntries(e,t){let r=this.subwalks.get(e),i=this.child();for(let s of t)for(let a of r){let c=a.isAbsolute(),l=a.pattern(),u=a.rest();l===Gt?i.testGlobstar(s,a,u,c):l instanceof RegExp?i.testRegExp(s,l,u,c):i.testString(s,l,u,c)}return i}testGlobstar(e,t,r,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()&&(r&&t.checkFollowGlobstar()?this.subwalks.add(e,r):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),r){let s=r.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,r.rest(),i);else if(s===".."){let a=e.parent||e;this.subwalks.add(a,r)}else s instanceof RegExp&&this.testRegExp(e,s,r.rest(),i)}}testRegExp(e,t,r,i){t.test(e.name)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}testString(e,t,r,i){e.isNamed(t)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}};var XH=o((n,e)=>typeof n=="string"?new Nl([n],e):Array.isArray(n)?new Nl(n,e):n,"makeIgnore"),ig=class{static{o(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#n;#r;signal;maxDepth;includeChildMatches;constructor(e,t,r){if(this.patterns=e,this.path=t,this.opts=r,this.#r=!r.posix&&r.platform==="win32"?"\\":"/",this.includeChildMatches=r.includeChildMatches!==!1,(r.ignore||!this.includeChildMatches)&&(this.#n=XH(r.ignore??[],r),!this.includeChildMatches&&typeof this.#n.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=r.maxDepth||1/0,r.signal&&(this.signal=r.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#t(e){return this.seen.has(e)||!!this.#n?.ignored?.(e)}#c(e){return!!this.#n?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||await e.realpath(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=await s.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.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.#t(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||e.realpathSync(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=s.realpathSync();a&&(a?.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(s,t)}matchFinish(e,t){if(this.#t(e))return;if(!this.includeChildMatches&&this.#n?.add){let s=`${e.relativePosix()}/**`;this.#n.add(s)}let r=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#r:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(r){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),a=this.opts.dotRelative&&!s.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(s?a+s+i:"."+i)}}async match(e,t,r){let i=await this.matchCheck(e,r);i&&this.matchFinish(i,t)}matchSync(e,t,r){let i=this.matchCheckSync(e,r);i&&this.matchFinish(i,t)}walkCB(e,t,r){this.signal?.aborted&&r(),this.walkCB2(e,t,new Df(this.opts),r)}walkCB2(e,t,r,i){if(this.#c(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||(s++,this.match(c,l,u).then(()=>a()));for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirCached();c.calledReaddir()?this.walkCB3(c,l,r,a):c.readdirCB((u,f)=>this.walkCB3(c,f,r,a),!0)}a()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||(s++,this.match(c,l,u).then(()=>a()));for(let[c,l]of r.subwalks.entries())s++,this.walkCB2(c,l,r.child(),a);a()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new Df(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#c(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||this.matchSync(c,l,u);for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirSync();this.walkCB3Sync(c,l,r,a)}a()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||this.matchSync(c,l,u);for(let[c,l]of r.subwalks.entries())s++,this.walkCB2Sync(c,l,r.child(),a);a()}},Nf=class extends ig{static{o(this,"GlobWalker")}matches=new Set;constructor(e,t,r){super(e,t,r)}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}},Lf=class extends ig{static{o(this,"GlobStream")}results;constructor(e,t,r){super(e,t,r),this.results=new Qa({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 JH=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ui=class{static{o(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,SP.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||JH,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"?Pl:t.platform==="darwin"?Ff:t.platform?Fl:bP;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let r=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:r,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 Bn(l,i)),[a,c]=s.reduce((l,u)=>(l[0].push(...u.set),l[1].push(...u.globParts),l),[[],[]]);this.patterns=a.map((l,u)=>{let f=c[u];if(!f)throw new Error("invalid pattern object");return new Dl(l,f,0,this.platform)})}async walk(){return[...await new Nf(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 Nf(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 Lf(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 Lf(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 pv=o((n,e={})=>{Array.isArray(n)||(n=[n]);for(let t of n)if(new Bn(t,e).hasMagic())return!0;return!1},"hasMagic");function sg(n,e={}){return new Ui(n,e).streamSync()}o(sg,"globStreamSync");function vP(n,e={}){return new Ui(n,e).stream()}o(vP,"globStream");function EP(n,e={}){return new Ui(n,e).walkSync()}o(EP,"globSync");async function wP(n,e={}){return new Ui(n,e).walk()}o(wP,"glob_");function ag(n,e={}){return new Ui(n,e).iterateSync()}o(ag,"globIterateSync");function TP(n,e={}){return new Ui(n,e).iterate()}o(TP,"globIterate");var ZH=sg,eQ=Object.assign(vP,{sync:sg}),tQ=ag,rQ=Object.assign(TP,{sync:ag}),nQ=Object.assign(EP,{stream:sg,iterate:ag}),Ll=Object.assign(wP,{glob:wP,globSync:EP,sync:nQ,globStream:vP,stream:eQ,globStreamSync:sg,streamSync:ZH,globIterate:TP,iterate:rQ,globIterateSync:ag,iterateSync:tQ,Glob:Ui,hasMagic:pv,escape:Al,unescape:$i});Ll.glob=Ll;async function xP(n,e,t,r={}){let{dryRun:i=!1,excludeRelPath:s}=r,a=Ho.default.join(n,"**/*.md"),c=await Ll(a,{nodir:!0,ignore:[Ho.default.join(n,".obsidian/**"),Ho.default.join(n,".trash/**"),Ho.default.join(n,"**/.obsidian/**"),Ho.default.join(n,"**/.trash/**")]}),l={filesScanned:0,filesModified:0,replacements:0,modifiedFiles:[]};for(let u of c){let f=Ho.default.relative(n,u);if(s&&f===s)continue;l.filesScanned+=1;let d;try{d=await mv.default.readFile(u,"utf-8")}catch{continue}let{updated:h,replacements:p}=iQ(d,e,t);p>0&&(l.filesModified+=1,l.replacements+=p,l.modifiedFiles.push(f),i||await mv.default.writeFile(u,h,"utf-8"))}return l}o(xP,"rewriteInboundWikilinks");function iQ(n,e,t){let r=n.split(/(^```[\s\S]*?^```)/m),i=0;for(let s=0;s<r.length;s++){if(s%2===1)continue;let a=r[s],c=sQ(a,e,t);i+=c.replacements,r[s]=c.updated}return{updated:r.join(""),replacements:i}}o(iQ,"rewriteContent");function sQ(n,e,t){let r=n.split(/(`[^`\n]*`)/),i=0;for(let s=0;s<r.length;s++){if(s%2===1)continue;let a=aQ(r[s],e,t);i+=a.replacements,r[s]=a.updated}return{updated:r.join(""),replacements:i}}o(sQ,"rewriteProseSegment");function aQ(n,e,t){let r=/(?<!!)\[\[([^\[\]\n|#^]+)(?:[#^][^\[\]\n|]*)?(?:\|[^\[\]\n]*)?\]\]/g,i=0;return{updated:n.replace(r,(a,c)=>c.trim()!==e?a:(i+=1,`[[${t}]]`)),replacements:i}}o(aQ,"replaceWikilinks");var oQ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Lt=class{constructor(e){this.rootPath=e;this.uuidIndex=null;this.basenameIndex=null;this.aliasIndex=null}static{o(this,"FileSystemVaultAdapter")}async read(e){let t=this.resolvePath(e.path);if(!await nr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);return nr.default.readFile(t,"utf-8")}async create(e,t){let r=this.resolvePath(e);if(await nr.default.pathExists(r))throw new Error(`File already exists: ${e}`);return await nr.default.ensureDir(Ht.default.dirname(r)),await nr.default.writeFile(r,t,"utf-8"),this.createFileObject(e)}async modify(e,t){let r=this.resolvePath(e.path);if(!await nr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await nr.default.writeFile(r,t,"utf-8")}async delete(e){let t=this.resolvePath(e.path);if(!await nr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);await nr.default.remove(t)}async exists(e){let t=this.resolvePath(e);return nr.default.pathExists(t)}getAbstractFileByPath(e){let t=this.resolvePath(e);try{let r=nr.default.statSync(t);if(r.isFile())return this.createFileObject(e);if(r.isDirectory())return this.createFolderObject(e)}catch{return null}return null}getAllFiles(){let e=[];return this.walkDirectory(this.rootPath,t=>{if(t.endsWith(".md")){let r=Ht.default.relative(this.rootPath,t);e.push(this.createFileObject(r))}}),e}getFrontmatter(e){try{let t=nr.default.readFileSync(this.resolvePath(e.path),"utf-8");return this.extractFrontmatter(t)}catch{return null}}async updateFrontmatter(e,t){let r=await this.read(e),i=this.extractFrontmatter(r)||{},s=t(i),a=this.replaceFrontmatter(r,s);await this.modify(e,a)}async rename(e,t){let r=this.resolvePath(e.path),i=this.resolvePath(t);if(!await nr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await nr.default.ensureDir(Ht.default.dirname(i)),await nr.default.move(r,i)}async createFolder(e){let t=this.resolvePath(e);await nr.default.ensureDir(t)}getFirstLinkpathDest(e,t){let r=e.split("|")[0].trim();if(!r)return null;if(oQ.test(r)){this.uuidIndex===null&&this.buildUuidIndex();let u=r.toLowerCase(),f=this.uuidIndex.get(u);return f?this.createFileObject(f):null}let i=Ht.default.dirname(this.resolvePath(t)),s;if(Ht.default.isAbsolute(r)?s=this.resolvePath(r):s=Ht.default.resolve(i,r),r.endsWith(".md")||(s+=".md"),nr.default.existsSync(s)){let u=Ht.default.relative(this.rootPath,s);return this.createFileObject(u)}(this.basenameIndex===null||this.aliasIndex===null)&&this.buildLinkpathIndex();let a=r.toLowerCase(),c=this.basenameIndex.get(a);if(c)return this.createFileObject(c);let l=this.aliasIndex.get(a);return l?this.createFileObject(l):null}buildLinkpathIndex(){this.basenameIndex=new Map,this.aliasIndex=new Map,this.walkDirectory(this.rootPath,e=>{if(!e.endsWith(".md"))return;let t=Ht.default.relative(this.rootPath,e),r=Ht.default.basename(e,".md").toLowerCase();this.basenameIndex.has(r)||this.basenameIndex.set(r,t);let i;try{i=nr.default.readFileSync(e,"utf-8")}catch{return}let s=this.extractFrontmatter(i);if(!s)return;let a=s.aliases,c=Array.isArray(a)?a:typeof a=="string"?[a]:[];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 r=Ht.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(r){let i=r[1].toLowerCase(),s=Ht.default.relative(this.rootPath,e);this.uuidIndex.set(i,s)}}})}async process(e,t){let r=await this.read(e),i=t(r);return await this.modify(e,i),i}getDefaultNewFileParent(){return{path:"",name:""}}async updateLinks(e,t,r){let i=Ht.default.basename(t,".md");await xP(this.rootPath,r,i,{excludeRelPath:e})}resolvePath(e){return Ht.default.isAbsolute(e)?e:Ht.default.join(this.rootPath,e)}createFileObject(e){let t=Ht.default.basename(e),r=Ht.default.basename(e,Ht.default.extname(e)),i=Ht.default.dirname(e);return{path:e,basename:r,name:t,parent:i!=="."?this.createFolderObject(i):null}}createFolderObject(e){return{path:e,name:Ht.default.basename(e)}}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return null;try{let i=rr.load(r[1]);return typeof i=="object"&&i!==null?i:null}catch{return null}}replaceFrontmatter(e,t){let r=rr.dump(t,{lineWidth:-1,noRefs:!0,quotingType:'"'}),i=/^---\n([\s\S]*?)\n---/;return e.match(i)?e.replace(i,`---
488
+ `:""}o(Tz,"dump$1");var Az=Tz,xz={dump:Az};function Qw(n,e){return function(){throw new Error("Function yaml."+n+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}o(Qw,"renamed");var Iz=jr,Cz=$R,Rz=qR,Oz=QR,Pz=KR,Fz=Ww,Dz=hO.load,Nz=hO.loadAll,Lz=xz.dump,kz=_n,jz={binary:eO,float:HR,map:UR,null:WR,pairs:rO,set:nO,timestamp:JR,bool:GR,int:zR,merge:ZR,omap:tO,seq:BR,str:VR},Mz=Qw("safeLoad","load"),$z=Qw("safeLoadAll","loadAll"),Vz=Qw("safeDump","dump"),rr={Type:Iz,Schema:Cz,FAILSAFE_SCHEMA:Rz,JSON_SCHEMA:Oz,CORE_SCHEMA:Pz,DEFAULT_SCHEMA:Fz,load:Dz,loadAll:Nz,dump:Lz,YAMLException:kz,types:jz,safeLoad:Mz,safeLoadAll:$z,safeDump:Vz};var mv=le(Sl()),Ho=le(require("path"));var zO=le(jO(),1);var wf=o(n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var Qz={"[: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]},vf=o(n=>n.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),Kz=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),MO=o(n=>n.join(""),"rangesToString"),$O=o((n,e)=>{let t=e;if(n.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=t+1,a=!1,c=!1,l=!1,u=!1,f=t,d="";e:for(;s<n.length;){let S=n.charAt(s);if((S==="!"||S==="^")&&s===t+1){u=!0,s++;continue}if(S==="]"&&a&&!l){f=s+1;break}if(a=!0,S==="\\"&&!l){l=!0,s++;continue}if(S==="["&&!l){for(let[v,[w,T,C]]of Object.entries(Qz))if(n.startsWith(v,s)){if(d)return["$.",!1,n.length-t,!0];s+=v.length,C?i.push(w):r.push(w),c=c||T;continue e}}if(l=!1,d){S>d?r.push(vf(d)+"-"+vf(S)):S===d&&r.push(vf(S)),d="",s++;continue}if(n.startsWith("-]",s+1)){r.push(vf(S+"-")),s+=2;continue}if(n.startsWith("-",s+1)){d=S,s+=2;continue}r.push(vf(S)),s++}if(f<s)return["",!1,0,!1];if(!r.length&&!i.length)return["$.",!1,n.length-t,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!u){let S=r[0].length===2?r[0].slice(-1):r[0];return[Kz(S),!1,f-t,!1]}let h="["+(u?"^":"")+MO(r)+"]",p="["+(u?"":"^")+MO(i)+"]";return[r.length&&i.length?"("+h+"|"+p+")":r.length?h:p,c,f-t,!0]},"parseClass");var $i=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),"unescape");var Fn,Yz=new Set(["!","?","+","*","@"]),Xw=o(n=>Yz.has(n),"isExtglobType"),VO=o(n=>Xw(n.type),"isExtglobAST"),Xz=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Jz=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Zz=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),BO=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),eH="(?!(?:^|/)\\.\\.?(?:$|/))",Um="(?!\\.)",tH=new Set(["[","."]),rH=new Set(["..","."]),nH=new Set("().*{}+?[]^$\\!"),iH=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Jw="[^/]",UO=Jw+"*?",qO=Jw+"+?",Wo=class{static{o(this,"AST")}type;#e;#n;#r=!1;#t=[];#c;#_;#i;#u=!1;#s;#l;#a=!1;constructor(e,t,r={}){this.type=e,e&&(this.#n=!0),this.#c=t,this.#e=this.#c?this.#c.#e:this,this.#s=this.#e===this?r:this.#e.#s,this.#i=this.#e===this?[]:this.#e.#i,e==="!"&&!this.#e.#u&&this.#i.push(this),this.#_=this.#c?this.#c.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let e of this.#t)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#l!==void 0?this.#l:this.type?this.#l=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#l=this.#t.map(e=>String(e)).join("")}#p(){if(this!==this.#e)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let e;for(;e=this.#i.pop();){if(e.type!=="!")continue;let t=e,r=t.#c;for(;r;){for(let i=t.#_+1;!r.type&&i<r.#t.length;i++)for(let s of e.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(r.#t[i])}t=r,r=t.#c}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof Fn&&t.#c===this))throw new Error("invalid part: "+t);this.#t.push(t)}}toJSON(){let e=this.type===null?this.#t.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#t.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#u&&this.#c?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#c?.isStart())return!1;if(this.#_===0)return!0;let e=this.#c;for(let t=0;t<this.#_;t++){let r=e.#t[t];if(!(r instanceof Fn&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#c?.type==="!")return!0;if(!this.#c?.isEnd())return!1;if(!this.type)return this.#c?.isEnd();let e=this.#c?this.#c.#t.length:0;return this.#_===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let t=new Fn(this.type,e);for(let r of this.#t)t.copyIn(r);return t}static#g(e,t,r,i,s){let a=i.maxExtglobRecursion??2,c=!1,l=!1,u=-1,f=!1;if(t.type===null){let S=r,v="";for(;S<e.length;){let w=e.charAt(S++);if(c||w==="\\"){c=!c,v+=w;continue}if(l){S===u+1?(w==="^"||w==="!")&&(f=!0):w==="]"&&!(S===u+2&&f)&&(l=!1),v+=w;continue}else if(w==="["){l=!0,u=S,f=!1,v+=w;continue}if(!i.noext&&Xw(w)&&e.charAt(S)==="("&&s<=a){t.push(v),v="";let C=new Fn(w,t);S=Fn.#g(e,C,S,i,s+1),t.push(C);continue}v+=w}return t.push(v),S}let d=r+1,h=new Fn(null,t),p=[],y="";for(;d<e.length;){let S=e.charAt(d++);if(c||S==="\\"){c=!c,y+=S;continue}if(l){d===u+1?(S==="^"||S==="!")&&(f=!0):S==="]"&&!(d===u+2&&f)&&(l=!1),y+=S;continue}else if(S==="["){l=!0,u=d,f=!1,y+=S;continue}if(Xw(S)&&e.charAt(d)==="("&&(s<=a||t&&t.#y(S))){let w=t&&t.#y(S)?0:1;h.push(y),y="";let T=new Fn(S,h);h.push(T),d=Fn.#g(e,T,d,i,s+w);continue}if(S==="|"){h.push(y),y="",p.push(h),h=new Fn(null,t);continue}if(S===")")return y===""&&t.#t.length===0&&(t.#a=!0),h.push(y),y="",t.push(...p,h),d;y+=S}return t.type=null,t.#n=void 0,t.#t=[e.substring(r-1)],d}#d(e){return this.#m(e,Jz)}#m(e,t=Xz){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null)return!1;let r=e.#t[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type,t)}#y(e,t=Zz){return!!t.get(this.type)?.includes(e)}#f(e,t){let r=e.#t[0],i=new Fn(null,r,this.options);i.#t.push(""),r.push(i),this.#E(e,t)}#E(e,t){let r=e.#t[0];this.#t.splice(t,1,...r.#t);for(let i of r.#t)typeof i=="object"&&(i.#c=this);this.#l=void 0}#T(e){return!!BO.get(this.type)?.has(e)}#b(e){if(!e||typeof e!="object"||e.type!==null||e.#t.length!==1||this.type===null||this.#t.length!==1)return!1;let t=e.#t[0];return!t||typeof t!="object"||t.type===null?!1:this.#T(t.type)}#v(e){let t=BO.get(this.type),r=e.#t[0],i=t?.get(r.type);if(!i)return!1;this.#t=r.#t;for(let s of this.#t)typeof s=="object"&&(s.#c=this);this.type=i,this.#l=void 0,this.#a=!1}#S(){if(VO(this)){let e=0,t=!1;do{t=!0;for(let r=0;r<this.#t.length;r++){let i=this.#t[r];typeof i=="object"&&(i.#S(),this.#m(i)?(t=!1,this.#E(i,r)):this.#d(i)?(t=!1,this.#f(i,r)):this.#b(i)&&(t=!1,this.#v(i)))}}while(!t&&++e<10)}else for(let e of this.#t)typeof e=="object"&&e.#S();this.#l=void 0}static fromGlob(e,t={}){let r=new Fn(null,void 0,t);return Fn.#g(e,r,0,t,0),r}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,r,i,s]=this.toRegExpSource();if(!(i||this.#n||this.#s.nocase&&!this.#s.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return r;let c=(this.#s.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,c),{_src:t,_glob:e})}get options(){return this.#s}toRegExpSource(e){let t=e??!!this.#s.dot;if(this.#e===this&&(this.#S(),this.#p()),!VO(this)){let l=this.isStart()&&this.isEnd(),u=this.#t.map(p=>{let[y,S,v,w]=typeof p=="string"?Fn.#x(p,this.#n,l):p.toRegExpSource(e);return this.#n=this.#n||v,this.#r=this.#r||w,y}).join(""),f="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&rH.has(this.#t[0]))){let y=tH,S=t&&y.has(u.charAt(0))||u.startsWith("\\.")&&y.has(u.charAt(2))||u.startsWith("\\.\\.")&&y.has(u.charAt(4)),v=!t&&!e&&y.has(u.charAt(0));f=S?eH:v?Um:""}let d="";return this.isEnd()&&this.#e.#u&&this.#c?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,$i(u),this.#n=!!this.#n,this.#r]}let r=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#w(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let l=this.toString(),u=this;return u.#t=[l],u.type=null,u.#n=void 0,[l,$i(this.toString()),!1,!1]}let a=!r||e||t||!Um?"":this.#w(!0);a===s&&(a=""),a&&(s=`(?:${s})(?:${a})*?`);let c="";if(this.type==="!"&&this.#a)c=(this.isStart()&&!t?Um:"")+qO;else{let l=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Um:"")+UO+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;c=i+s+l}return[c,$i(s),this.#n=!!this.#n,this.#r]}#w(e){return this.#t.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[r,i,s,a]=t.toRegExpSource(e);return this.#r=this.#r||a,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#x(e,t,r=!1){let i=!1,s="",a=!1,c=!1;for(let l=0;l<e.length;l++){let u=e.charAt(l);if(i){i=!1,s+=(nH.has(u)?"\\":"")+u,c=!1;continue}if(u==="\\"){l===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,h,p]=$O(e,l);if(h){s+=f,a=a||d,l+=h-1,t=t||p,c=!1;continue}}if(u==="*"){if(c)continue;c=!0,s+=r&&/^[*]+$/.test(e)?qO:UO,t=!0;continue}else c=!1;if(u==="?"){s+=Jw,t=!0;continue}s+=iH(u)}return[s,$i(e),!!t,a]}};Fn=Wo;var Al=o((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Mr=o((n,e,t={})=>(wf(e),!t.nocomment&&e.charAt(0)==="#"?!1:new Bn(e,t).match(n)),"minimatch"),sH=/^\*+([^+@!?\*\[\(]*)$/,aH=o(n=>e=>!e.startsWith(".")&&e.endsWith(n),"starDotExtTest"),oH=o(n=>e=>e.endsWith(n),"starDotExtTestDot"),cH=o(n=>(n=n.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(n)),"starDotExtTestNocase"),lH=o(n=>(n=n.toLowerCase(),e=>e.toLowerCase().endsWith(n)),"starDotExtTestNocaseDot"),uH=/^\*+\.\*+$/,fH=o(n=>!n.startsWith(".")&&n.includes("."),"starDotStarTest"),dH=o(n=>n!=="."&&n!==".."&&n.includes("."),"starDotStarTestDot"),hH=/^\.\*+$/,pH=o(n=>n!=="."&&n!==".."&&n.startsWith("."),"dotStarTest"),mH=/^\*+$/,gH=o(n=>n.length!==0&&!n.startsWith("."),"starTest"),yH=o(n=>n.length!==0&&n!=="."&&n!=="..","starTestDot"),_H=/^\?+([^+@!?\*\[\(]*)?$/,bH=o(([n,e=""])=>{let t=HO([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),SH=o(([n,e=""])=>{let t=QO([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),wH=o(([n,e=""])=>{let t=QO([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTestDot"),vH=o(([n,e=""])=>{let t=HO([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTest"),HO=o(([n])=>{let e=n.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),QO=o(([n])=>{let e=n.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),KO=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",WO={win32:{sep:"\\"},posix:{sep:"/"}},EH=KO==="win32"?WO.win32.sep:WO.posix.sep;Mr.sep=EH;var Gt=Symbol("globstar **");Mr.GLOBSTAR=Gt;var TH="[^/]",AH=TH+"*?",xH="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",IH="(?:(?!(?:\\/|^)\\.).)*?",CH=o((n,e={})=>t=>Mr(t,n,e),"filter");Mr.filter=CH;var ni=o((n,e={})=>Object.assign({},n,e),"ext"),RH=o(n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return Mr;let e=Mr;return Object.assign(o((r,i,s={})=>e(r,i,ni(n,s)),"m"),{Minimatch:class extends e.Minimatch{static{o(this,"Minimatch")}constructor(i,s={}){super(i,ni(n,s))}static defaults(i){return e.defaults(ni(n,i)).Minimatch}},AST:class extends e.AST{static{o(this,"AST")}constructor(i,s,a={}){super(i,s,ni(n,a))}static fromGlob(i,s={}){return e.AST.fromGlob(i,ni(n,s))}},unescape:o((r,i={})=>e.unescape(r,ni(n,i)),"unescape"),escape:o((r,i={})=>e.escape(r,ni(n,i)),"escape"),filter:o((r,i={})=>e.filter(r,ni(n,i)),"filter"),defaults:o(r=>e.defaults(ni(n,r)),"defaults"),makeRe:o((r,i={})=>e.makeRe(r,ni(n,i)),"makeRe"),braceExpand:o((r,i={})=>e.braceExpand(r,ni(n,i)),"braceExpand"),match:o((r,i,s={})=>e.match(r,i,ni(n,s)),"match"),sep:e.sep,GLOBSTAR:Gt})},"defaults");Mr.defaults=RH;var YO=o((n,e={})=>(wf(n),e.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,zO.default)(n)),"braceExpand");Mr.braceExpand=YO;var OH=o((n,e={})=>new Bn(n,e).makeRe(),"makeRe");Mr.makeRe=OH;var PH=o((n,e,t={})=>{let r=new Bn(e,t);return n=n.filter(i=>r.match(i)),r.options.nonull&&!n.length&&n.push(e),n},"match");Mr.match=PH;var GO=/[?*]|[+@!]\(.*?\)|\[|\]/,FH=o(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),Bn=class{static{o(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){wf(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||KO,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!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 r=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,a,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=s[0]===""&&s[1]===""&&(s[2]==="?"||!GO.test(s[2]))&&!GO.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 a=this.set[s];a[0]===""&&a[1]===""&&this.globParts[s][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let r=0;r<e.length;r++)for(let i=0;i<e[r].length;i++)e[r][i]==="**"&&(e[r][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 r=-1;for(;(r=t.indexOf("**",r+1))!==-1;){let i=r;for(;t[i+1]==="**";)i++;i!==r&&t.splice(r,i-r)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((r,i)=>{let s=r[r.length-1];return i==="**"&&s==="**"?r:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(r.pop(),r):(r.push(i),r)},[]),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 r=0;for(;(r=e.indexOf("..",r+1))!==-1;){let i=e[r-1];i&&i!=="."&&i!==".."&&i!=="**"&&(t=!0,e.splice(r-1,2),r-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let r of e){let i=-1;for(;(i=r.indexOf("**",i+1))!==-1;){let a=i;for(;r[a+1]==="**";)a++;a>i&&r.splice(i+1,a-i);let c=r[i+1],l=r[i+2],u=r[i+3];if(c!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;t=!0,r.splice(i,1);let f=r.slice(0);f[i]="**",e.push(f),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<r.length-1;a++){let c=r[a];a===1&&c===""&&r[0]===""||(c==="."||c==="")&&(t=!0,r.splice(a,1),a--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let a=r[s-1];if(a&&a!=="."&&a!==".."&&a!=="**"){t=!0;let l=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...l),r.length===0&&r.push(""),s-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let r=t+1;r<e.length;r++){let i=this.partsMatch(e[t],e[r],!this.preserveMultipleSlashes);if(i){e[t]=[],e[r]=i;break}}return e.filter(t=>t.length)}partsMatch(e,t,r=!1){let i=0,s=0,a=[],c="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])a.push(c==="b"?t[s]:e[i]),i++,s++;else if(r&&e[i]==="**"&&t[s]===e[i+1])a.push(e[i]),i++;else if(r&&t[s]==="**"&&e[i]===t[s+1])a.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",a.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",a.push(t[s]),i++,s++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,r=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)t=!t,r++;r&&(this.pattern=e.slice(r)),this.negate=t}matchOne(e,t,r=!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,h=f?3:u?0:void 0;if(typeof d=="number"&&typeof h=="number"){let[p,y]=[e[d],t[h]];p.toLowerCase()===y.toLowerCase()&&(t[h]=p,s=h,i=d)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Gt)?this.#e(e,t,r,i,s):this.#r(e,t,r,i,s)}#e(e,t,r,i,s){let a=t.indexOf(Gt,s),c=t.lastIndexOf(Gt),[l,u,f]=r?[t.slice(s,a),t.slice(a+1),[]]:[t.slice(s,a),t.slice(a+1,c),t.slice(c+1)];if(l.length){let T=e.slice(i,i+l.length);if(!this.#r(T,l,r,0,0))return!1;i+=l.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let T=e.length-f.length;if(this.#r(e,f,r,T,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(T--,!this.#r(e,f,r,T,0)))return!1;d=f.length+1}}if(!u.length){let T=!!d;for(let C=i;C<e.length-d;C++){let M=String(e[C]);if(T=!0,M==="."||M===".."||!this.options.dot&&M.startsWith("."))return!1}return r||T}let h=[[[],0]],p=h[0],y=0,S=[0];for(let T of u)T===Gt?(S.push(y),p=[[],0],h.push(p)):(p[0].push(T),y++);let v=h.length-1,w=e.length-d;for(let T of h)T[1]=w-(S[v--]+T[0].length);return!!this.#n(e,h,i,0,r,0,!!d)}#n(e,t,r,i,s,a,c){let l=t[i];if(!l){for(let d=r;d<e.length;d++){c=!0;let h=e[d];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1}return c}let[u,f]=l;for(;r<=f;){if(this.#r(e.slice(0,r+u.length),u,s,r,0)&&a<this.maxGlobstarRecursion){let p=this.#n(e,t,r+u.length,i+1,s,a+1,c);if(p!==!1)return p}let h=e[r];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1;r++}return s||null}#r(e,t,r,i,s){let a,c,l,u;for(a=i,c=s,u=e.length,l=t.length;a<u&&c<l;a++,c++){this.debug("matchOne loop");let f=t[c],d=e[a];if(this.debug(t,f,d),f===!1||f===Gt)return!1;let h;if(typeof f=="string"?(h=d===f,this.debug("string match",f,d,h)):(h=f.test(d),this.debug("pattern match",f,d,h)),!h)return!1}if(a===u&&c===l)return!0;if(a===u)return r;if(c===l)return a===u-1&&e[a]==="";throw new Error("wtf?")}braceExpand(){return YO(this.pattern,this.options)}parse(e){wf(e);let t=this.options;if(e==="**")return Gt;if(e==="")return"";let r,i=null;(r=e.match(mH))?i=t.dot?yH:gH:(r=e.match(sH))?i=(t.nocase?t.dot?lH:cH:t.dot?oH:aH)(r[1]):(r=e.match(_H))?i=(t.nocase?t.dot?SH:bH:t.dot?wH:vH)(r):(r=e.match(uH))?i=t.dot?dH:fH:(r=e.match(hH))&&(i=pH);let s=Wo.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,r=t.noglobstar?AH:t.dot?xH:IH,i=new Set(t.nocase?["i"]:[]),s=e.map(l=>{let u=l.map(f=>{if(f instanceof RegExp)for(let d of f.flags.split(""))i.add(d);return typeof f=="string"?FH(f):f===Gt?Gt:f._src});return u.forEach((f,d)=>{let h=u[d+1],p=u[d-1];f!==Gt||p===Gt||(p===void 0?h!==void 0&&h!==Gt?u[d+1]="(?:\\/|"+r+"\\/)?"+h:u[d]=r:h===void 0?u[d-1]=p+"(?:\\/|"+r+")?":h!==Gt&&(u[d-1]=p+"(?:\\/|\\/"+r+"\\/)"+h,u[d+1]=Gt))}),u.filter(f=>f!==Gt).join("/")}).join("|"),[a,c]=e.length>1?["(?:",")"]:["",""];s="^"+a+s+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 r=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 a=i[i.length-1];if(!a)for(let c=i.length-2;!a&&c>=0;c--)a=i[c];for(let c=0;c<s.length;c++){let l=s[c],u=i;if(r.matchBase&&l.length===1&&(u=[a]),this.matchOne(u,l,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Mr.defaults(e).Minimatch}};Mr.AST=Wo;Mr.Minimatch=Bn;Mr.escape=Al;Mr.unescape=$i;var SP=require("node:url");var xl=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,JO=new Set,Zw=typeof process=="object"&&process?process:{},ZO=o((n,e,t,r)=>{typeof Zw.emitWarning=="function"?Zw.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)},"emitWarning"),qm=globalThis.AbortController,XO=globalThis.AbortSignal;if(typeof qm>"u"){XO=class{static{o(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},qm=class{static{o(this,"AbortController")}constructor(){e()}signal=new XO;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let i of this.signal._onabort)i(r);this.signal.onabort?.(r)}}};let n=Zw.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=o(()=>{n&&(n=!1,ZO("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))},"warnACPolyfill")}var DH=o(n=>!JO.has(n),"shouldWarn");var za=o(n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),"isPosInt"),eP=o(n=>za(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Il:null:null,"getUintArray"),Il=class extends Array{static{o(this,"ZeroArray")}constructor(e){super(e),this.fill(0)}},ev=class n{static{o(this,"Stack")}heap;length;static#e=!1;static create(e){let t=eP(e);if(!t)return[];n.#e=!0;let r=new n(e,t);return n.#e=!1,r}constructor(e,t){if(!n.#e)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]}},Ef=class n{static{o(this,"LRUCache")}#e;#n;#r;#t;#c;#_;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#u;#s;#l;#a;#p;#g;#d;#m;#y;#f;#E;#T;#b;#v;#S;#w;static unsafeExposeInternals(e){return{starts:e.#T,ttls:e.#b,sizes:e.#E,keyMap:e.#s,keyList:e.#l,valList:e.#a,next:e.#p,prev:e.#g,get head(){return e.#d},get tail(){return e.#m},free:e.#y,isBackgroundFetch:o(t=>e.#h(t),"isBackgroundFetch"),backgroundFetch:o((t,r,i,s)=>e.#M(t,r,i,s),"backgroundFetch"),moveToTail:o(t=>e.#V(t),"moveToTail"),indexes:o(t=>e.#C(t),"indexes"),rindexes:o(t=>e.#R(t),"rindexes"),isStale:o(t=>e.#A(t),"isStale")}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#u}get size(){return this.#i}get fetchMethod(){return this.#c}get memoMethod(){return this.#_}get dispose(){return this.#r}get disposeAfter(){return this.#t}constructor(e){let{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:c,allowStale:l,dispose:u,disposeAfter:f,noDisposeOnSet:d,noUpdateTTL:h,maxSize:p=0,maxEntrySize:y=0,sizeCalculation:S,fetchMethod:v,memoMethod:w,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:V,ignoreFetchAbort:ee}=e;if(t!==0&&!za(t))throw new TypeError("max option must be a nonnegative integer");let U=t?eP(t):Array;if(!U)throw new Error("invalid max value: "+t);if(this.#e=t,this.#n=p,this.maxEntrySize=y||this.#n,this.sizeCalculation=S,this.sizeCalculation){if(!this.#n&&!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(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#_=w,v!==void 0&&typeof v!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#c=v,this.#S=!!v,this.#s=new Map,this.#l=new Array(t).fill(void 0),this.#a=new Array(t).fill(void 0),this.#p=new U(t),this.#g=new U(t),this.#d=0,this.#m=0,this.#y=ev.create(t),this.#i=0,this.#u=0,typeof u=="function"&&(this.#r=u),typeof f=="function"?(this.#t=f,this.#f=[]):(this.#t=void 0,this.#f=void 0),this.#v=!!this.#r,this.#w=!!this.#t,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!V,this.ignoreFetchAbort=!!ee,this.maxEntrySize!==0){if(this.#n!==0&&!za(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!za(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#O()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!c,this.ttlResolution=za(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!za(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#x()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let W="LRU_CACHE_UNBOUNDED";DH(W)&&(JO.add(W),ZO("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",W,n))}}getRemainingTTL(e){return this.#s.has(e)?1/0:0}#x(){let e=new Il(this.#e),t=new Il(this.#e);this.#b=e,this.#T=t,this.#F=(s,a,c=xl.now())=>{if(t[s]=a!==0?c:0,e[s]=a,a!==0&&this.ttlAutopurge){let l=setTimeout(()=>{this.#A(s)&&this.#P(this.#l[s],"expire")},a+1);l.unref&&l.unref()}},this.#I=s=>{t[s]=e[s]!==0?xl.now():0},this.#o=(s,a)=>{if(e[a]){let c=e[a],l=t[a];if(!c||!l)return;s.ttl=c,s.start=l,s.now=r||i();let u=s.now-l;s.remainingTTL=c-u}};let r=0,i=o(()=>{let s=xl.now();if(this.ttlResolution>0){r=s;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return s},"getNow");this.getRemainingTTL=s=>{let a=this.#s.get(s);if(a===void 0)return 0;let c=e[a],l=t[a];if(!c||!l)return 1/0;let u=(r||i())-l;return c-u},this.#A=s=>{let a=t[s],c=e[s];return!!c&&!!a&&(r||i())-a>c}}#I=o(()=>{},"#updateItemAge");#o=o(()=>{},"#statusTTL");#F=o(()=>{},"#setItemTTL");#A=o(()=>!1,"#isStale");#O(){let e=new Il(this.#e);this.#u=0,this.#E=e,this.#D=t=>{this.#u-=e[t],e[t]=0},this.#L=(t,r,i,s)=>{if(this.#h(r))return 0;if(!za(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!za(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.#N=(t,r,i)=>{if(e[t]=r,this.#n){let s=this.#n-e[t];for(;this.#u>s;)this.#j(!0)}this.#u+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#u)}}#D=o(e=>{},"#removeItemSize");#N=o((e,t,r)=>{},"#addItemSize");#L=o((e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#C({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#m;!(!this.#k(t)||((e||!this.#A(t))&&(yield t),t===this.#d));)t=this.#g[t]}*#R({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#d;!(!this.#k(t)||((e||!this.#A(t))&&(yield t),t===this.#m));)t=this.#p[t]}#k(e){return e!==void 0&&this.#s.get(this.#l[e])===e}*entries(){for(let e of this.#C())this.#a[e]!==void 0&&this.#l[e]!==void 0&&!this.#h(this.#a[e])&&(yield[this.#l[e],this.#a[e]])}*rentries(){for(let e of this.#R())this.#a[e]!==void 0&&this.#l[e]!==void 0&&!this.#h(this.#a[e])&&(yield[this.#l[e],this.#a[e]])}*keys(){for(let e of this.#C()){let t=this.#l[e];t!==void 0&&!this.#h(this.#a[e])&&(yield t)}}*rkeys(){for(let e of this.#R()){let t=this.#l[e];t!==void 0&&!this.#h(this.#a[e])&&(yield t)}}*values(){for(let e of this.#C())this.#a[e]!==void 0&&!this.#h(this.#a[e])&&(yield this.#a[e])}*rvalues(){for(let e of this.#R())this.#a[e]!==void 0&&!this.#h(this.#a[e])&&(yield this.#a[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#C()){let i=this.#a[r],s=this.#h(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#l[r],this))return this.get(this.#l[r],t)}}forEach(e,t=this){for(let r of this.#C()){let i=this.#a[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#l[r],this)}}rforEach(e,t=this){for(let r of this.#R()){let i=this.#a[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#l[r],this)}}purgeStale(){let e=!1;for(let t of this.#R({allowStale:!0}))this.#A(t)&&(this.#P(this.#l[t],"expire"),e=!0);return e}info(e){let t=this.#s.get(e);if(t===void 0)return;let r=this.#a[t],i=this.#h(r)?r.__staleWhileFetching:r;if(i===void 0)return;let s={value:i};if(this.#b&&this.#T){let a=this.#b[t],c=this.#T[t];if(a&&c){let l=a-(xl.now()-c);s.ttl=l,s.start=Date.now()}}return this.#E&&(s.size=this.#E[t]),s}dump(){let e=[];for(let t of this.#C({allowStale:!0})){let r=this.#l[t],i=this.#a[t],s=this.#h(i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;let a={value:s};if(this.#b&&this.#T){a.ttl=this.#b[t];let c=xl.now()-this.#T[t];a.start=Math.floor(Date.now()-c)}this.#E&&(a.size=this.#E[t]),e.unshift([r,a])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=xl.now()-i}this.set(t,r.value,r)}}set(e,t,r={}){if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:l}=r,{noUpdateTTL:u=this.noUpdateTTL}=r,f=this.#L(e,t,r.size||0,c);if(this.maxEntrySize&&f>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#P(e,"set"),this;let d=this.#i===0?void 0:this.#s.get(e);if(d===void 0)d=this.#i===0?this.#m:this.#y.length!==0?this.#y.pop():this.#i===this.#e?this.#j(!1):this.#i,this.#l[d]=e,this.#a[d]=t,this.#s.set(e,d),this.#p[this.#m]=d,this.#g[d]=this.#m,this.#m=d,this.#i++,this.#N(d,f,l),l&&(l.set="add"),u=!1;else{this.#V(d);let h=this.#a[d];if(t!==h){if(this.#S&&this.#h(h)){h.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=h;p!==void 0&&!a&&(this.#v&&this.#r?.(p,e,"set"),this.#w&&this.#f?.push([p,e,"set"]))}else a||(this.#v&&this.#r?.(h,e,"set"),this.#w&&this.#f?.push([h,e,"set"]));if(this.#D(d),this.#N(d,f,l),this.#a[d]=t,l){l.set="replace";let p=h&&this.#h(h)?h.__staleWhileFetching:h;p!==void 0&&(l.oldValue=p)}}else l&&(l.set="update")}if(i!==0&&!this.#b&&this.#x(),this.#b&&(u||this.#F(d,i,s),l&&this.#o(l,d)),!a&&this.#w&&this.#f){let h=this.#f,p;for(;p=h?.shift();)this.#t?.(...p)}return this}pop(){try{for(;this.#i;){let e=this.#a[this.#d];if(this.#j(!0),this.#h(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#w&&this.#f){let e=this.#f,t;for(;t=e?.shift();)this.#t?.(...t)}}}#j(e){let t=this.#d,r=this.#l[t],i=this.#a[t];return this.#S&&this.#h(i)?i.__abortController.abort(new Error("evicted")):(this.#v||this.#w)&&(this.#v&&this.#r?.(i,r,"evict"),this.#w&&this.#f?.push([i,r,"evict"])),this.#D(t),e&&(this.#l[t]=void 0,this.#a[t]=void 0,this.#y.push(t)),this.#i===1?(this.#d=this.#m=0,this.#y.length=0):this.#d=this.#p[t],this.#s.delete(r),this.#i--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,s=this.#s.get(e);if(s!==void 0){let a=this.#a[s];if(this.#h(a)&&a.__staleWhileFetching===void 0)return!1;if(this.#A(s))i&&(i.has="stale",this.#o(i,s));else return r&&this.#I(s),i&&(i.has="hit",this.#o(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,i=this.#s.get(e);if(i===void 0||!r&&this.#A(i))return;let s=this.#a[i];return this.#h(s)?s.__staleWhileFetching:s}#M(e,t,r,i){let s=t===void 0?void 0:this.#a[t];if(this.#h(s))return s;let a=new qm,{signal:c}=r;c?.addEventListener("abort",()=>a.abort(c.reason),{signal:a.signal});let l={signal:a.signal,options:r,context:i},u=o((S,v=!1)=>{let{aborted:w}=a.signal,T=r.ignoreFetchAbort&&S!==void 0;if(r.status&&(w&&!v?(r.status.fetchAborted=!0,r.status.fetchError=a.signal.reason,T&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),w&&!T&&!v)return d(a.signal.reason);let C=p;return this.#a[t]===p&&(S===void 0?C.__staleWhileFetching?this.#a[t]=C.__staleWhileFetching:this.#P(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,S,l.options))),S},"cb"),f=o(S=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=S),d(S)),"eb"),d=o(S=>{let{aborted:v}=a.signal,w=v&&r.allowStaleOnFetchAbort,T=w||r.allowStaleOnFetchRejection,C=T||r.noDeleteOnFetchRejection,M=p;if(this.#a[t]===p&&(!C||M.__staleWhileFetching===void 0?this.#P(e,"fetch"):w||(this.#a[t]=M.__staleWhileFetching)),T)return r.status&&M.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),M.__staleWhileFetching;if(M.__returned===M)throw S},"fetchFail"),h=o((S,v)=>{let w=this.#c?.(e,s,l);w&&w instanceof Promise&&w.then(T=>S(T===void 0?void 0:T),v),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(S(void 0),r.allowStaleOnFetchAbort&&(S=o(T=>u(T,!0),"res")))})},"pcall");r.status&&(r.status.fetchDispatched=!0);let p=new Promise(h).then(u,f),y=Object.assign(p,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,y,{...l.options,status:void 0}),t=this.#s.get(e)):this.#a[t]=y,y}#h(e){if(!this.#S)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof qm}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:l=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:y=this.allowStaleOnFetchAbort,context:S,forceRefresh:v=!1,status:w,signal:T}=t;if(!this.#S)return w&&(w.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:w});let C={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:c,size:l,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:y,ignoreFetchAbort:p,status:w,signal:T},M=this.#s.get(e);if(M===void 0){w&&(w.fetch="miss");let V=this.#M(e,M,C,S);return V.__returned=V}else{let V=this.#a[M];if(this.#h(V)){let N=r&&V.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",N&&(w.returnedStale=!0)),N?V.__staleWhileFetching:V.__returned=V}let ee=this.#A(M);if(!v&&!ee)return w&&(w.fetch="hit"),this.#V(M),i&&this.#I(M),w&&this.#o(w,M),V;let U=this.#M(e,M,C,S),P=U.__staleWhileFetching!==void 0&&r;return w&&(w.fetch=ee?"stale":"refresh",P&&ee&&(w.returnedStale=!0)),P?U.__staleWhileFetching:U.__returned=U}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=this.#_;if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...a}=t,c=this.get(e,a);if(!s&&c!==void 0)return c;let l=r(e,c,{options:a,context:i});return this.set(e,l,a),l}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,c=this.#s.get(e);if(c!==void 0){let l=this.#a[c],u=this.#h(l);return a&&this.#o(a,c),this.#A(c)?(a&&(a.get="stale"),u?(a&&r&&l.__staleWhileFetching!==void 0&&(a.returnedStale=!0),r?l.__staleWhileFetching:void 0):(s||this.#P(e,"expire"),a&&r&&(a.returnedStale=!0),r?l:void 0)):(a&&(a.get="hit"),u?l.__staleWhileFetching:(this.#V(c),i&&this.#I(c),l))}else a&&(a.get="miss")}#$(e,t){this.#g[t]=e,this.#p[e]=t}#V(e){e!==this.#m&&(e===this.#d?this.#d=this.#p[e]:this.#$(this.#g[e],this.#p[e]),this.#$(this.#m,e),this.#m=e)}delete(e){return this.#P(e,"delete")}#P(e,t){let r=!1;if(this.#i!==0){let i=this.#s.get(e);if(i!==void 0)if(r=!0,this.#i===1)this.#B(t);else{this.#D(i);let s=this.#a[i];if(this.#h(s)?s.__abortController.abort(new Error("deleted")):(this.#v||this.#w)&&(this.#v&&this.#r?.(s,e,t),this.#w&&this.#f?.push([s,e,t])),this.#s.delete(e),this.#l[i]=void 0,this.#a[i]=void 0,i===this.#m)this.#m=this.#g[i];else if(i===this.#d)this.#d=this.#p[i];else{let a=this.#g[i];this.#p[a]=this.#p[i];let c=this.#p[i];this.#g[c]=this.#g[i]}this.#i--,this.#y.push(i)}}if(this.#w&&this.#f?.length){let i=this.#f,s;for(;s=i?.shift();)this.#t?.(...s)}return r}clear(){return this.#B("delete")}#B(e){for(let t of this.#R({allowStale:!0})){let r=this.#a[t];if(this.#h(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#l[t];this.#v&&this.#r?.(r,i,e),this.#w&&this.#f?.push([r,i,e])}}if(this.#s.clear(),this.#a.fill(void 0),this.#l.fill(void 0),this.#b&&this.#T&&(this.#b.fill(0),this.#T.fill(0)),this.#E&&this.#E.fill(0),this.#d=0,this.#m=0,this.#y.length=0,this.#u=0,this.#i=0,this.#w&&this.#f){let t=this.#f,r;for(;r=t?.shift();)this.#t?.(...r)}}};var Ol=require("node:path"),uP=require("node:url"),vs=require("fs"),qH=le(require("node:fs"),1),Ka=require("node:fs/promises");var Ym=require("node:events"),ov=le(require("node:stream"),1),sP=require("node:string_decoder");var tP=typeof process=="object"&&process?process:{stdout:null,stderr:null},NH=o(n=>!!n&&typeof n=="object"&&(n instanceof Qa||n instanceof ov.default||LH(n)||kH(n)),"isStream"),LH=o(n=>!!n&&typeof n=="object"&&n instanceof Ym.EventEmitter&&typeof n.pipe=="function"&&n.pipe!==ov.default.Writable.prototype.pipe,"isReadable"),kH=o(n=>!!n&&typeof n=="object"&&n instanceof Ym.EventEmitter&&typeof n.write=="function"&&typeof n.end=="function","isWritable"),la=Symbol("EOF"),ua=Symbol("maybeEmitEnd"),Ha=Symbol("emittedEnd"),Wm=Symbol("emittingEnd"),Tf=Symbol("emittedError"),Gm=Symbol("closed"),rP=Symbol("read"),zm=Symbol("flush"),nP=Symbol("flushChunk"),Vi=Symbol("encoding"),Cl=Symbol("decoder"),Er=Symbol("flowing"),Af=Symbol("paused"),Rl=Symbol("resume"),Tr=Symbol("buffer"),bn=Symbol("pipes"),Ar=Symbol("bufferLength"),tv=Symbol("bufferPush"),Hm=Symbol("bufferShift"),Yr=Symbol("objectMode"),zt=Symbol("destroyed"),rv=Symbol("error"),nv=Symbol("emitData"),iP=Symbol("emitEnd"),iv=Symbol("emitEnd2"),Ss=Symbol("async"),sv=Symbol("abort"),Qm=Symbol("aborted"),xf=Symbol("signal"),Go=Symbol("dataListeners"),Un=Symbol("discarded"),If=o(n=>Promise.resolve().then(n),"defer"),jH=o(n=>n(),"nodefer"),MH=o(n=>n==="end"||n==="finish"||n==="prefinish","isEndish"),$H=o(n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,"isArrayBufferLike"),VH=o(n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),"isArrayBufferView"),Km=class{static{o(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[Rl](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},av=class extends Km{static{o(this,"PipeProxyErrors")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,r){super(e,t,r),this.proxyErrors=i=>t.emit("error",i),e.on("error",this.proxyErrors)}},BH=o(n=>!!n.objectMode,"isObjectModeOptions"),UH=o(n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer","isEncodingOptions"),Qa=class extends Ym.EventEmitter{static{o(this,"Minipass")}[Er]=!1;[Af]=!1;[bn]=[];[Tr]=[];[Yr];[Vi];[Ss];[Cl];[la]=!1;[Ha]=!1;[Wm]=!1;[Gm]=!1;[Tf]=null;[Ar]=0;[zt]=!1;[xf];[Qm]=!1;[Go]=0;[Un]=!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");BH(t)?(this[Yr]=!0,this[Vi]=null):UH(t)?(this[Vi]=t.encoding,this[Yr]=!1):(this[Yr]=!1,this[Vi]=null),this[Ss]=!!t.async,this[Cl]=this[Vi]?new sP.StringDecoder(this[Vi]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:o(()=>this[Tr],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:o(()=>this[bn],"get")});let{signal:r}=t;r&&(this[xf]=r,r.aborted?this[sv]():r.addEventListener("abort",()=>this[sv]()))}get bufferLength(){return this[Ar]}get encoding(){return this[Vi]}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[Yr]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Ss]}set async(e){this[Ss]=this[Ss]||!!e}[sv](){this[Qm]=!0,this.emit("abort",this[xf]?.reason),this.destroy(this[xf]?.reason)}get aborted(){return this[Qm]}set aborted(e){}write(e,t,r){if(this[Qm])return!1;if(this[la])throw new Error("write after end");if(this[zt])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(r=t,t="utf8"),t||(t="utf8");let i=this[Ss]?If:jH;if(!this[Yr]&&!Buffer.isBuffer(e)){if(VH(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if($H(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Yr]?(this[Er]&&this[Ar]!==0&&this[zm](!0),this[Er]?this.emit("data",e):this[tv](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Er]):e.length?(typeof e=="string"&&!(t===this[Vi]&&!this[Cl]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Vi]&&(e=this[Cl].write(e)),this[Er]&&this[Ar]!==0&&this[zm](!0),this[Er]?this.emit("data",e):this[tv](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Er]):(this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Er])}read(e){if(this[zt])return null;if(this[Un]=!1,this[Ar]===0||e===0||e&&e>this[Ar])return this[ua](),null;this[Yr]&&(e=null),this[Tr].length>1&&!this[Yr]&&(this[Tr]=[this[Vi]?this[Tr].join(""):Buffer.concat(this[Tr],this[Ar])]);let t=this[rP](e||null,this[Tr][0]);return this[ua](),t}[rP](e,t){if(this[Yr])this[Hm]();else{let r=t;e===r.length||e===null?this[Hm]():typeof r=="string"?(this[Tr][0]=r.slice(e),t=r.slice(0,e),this[Ar]-=e):(this[Tr][0]=r.subarray(e),t=r.subarray(0,e),this[Ar]-=e)}return this.emit("data",t),!this[Tr].length&&!this[la]&&this.emit("drain"),t}end(e,t,r){return typeof e=="function"&&(r=e,e=void 0),typeof t=="function"&&(r=t,t="utf8"),e!==void 0&&this.write(e,t),r&&this.once("end",r),this[la]=!0,this.writable=!1,(this[Er]||!this[Af])&&this[ua](),this}[Rl](){this[zt]||(!this[Go]&&!this[bn].length&&(this[Un]=!0),this[Af]=!1,this[Er]=!0,this.emit("resume"),this[Tr].length?this[zm]():this[la]?this[ua]():this.emit("drain"))}resume(){return this[Rl]()}pause(){this[Er]=!1,this[Af]=!0,this[Un]=!1}get destroyed(){return this[zt]}get flowing(){return this[Er]}get paused(){return this[Af]}[tv](e){this[Yr]?this[Ar]+=1:this[Ar]+=e.length,this[Tr].push(e)}[Hm](){return this[Yr]?this[Ar]-=1:this[Ar]-=this[Tr][0].length,this[Tr].shift()}[zm](e=!1){do;while(this[nP](this[Hm]())&&this[Tr].length);!e&&!this[Tr].length&&!this[la]&&this.emit("drain")}[nP](e){return this.emit("data",e),this[Er]}pipe(e,t){if(this[zt])return e;this[Un]=!1;let r=this[Ha];return t=t||{},e===tP.stdout||e===tP.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[bn].push(t.proxyErrors?new av(this,e,t):new Km(this,e,t)),this[Ss]?If(()=>this[Rl]()):this[Rl]()),e}unpipe(e){let t=this[bn].find(r=>r.dest===e);t&&(this[bn].length===1?(this[Er]&&this[Go]===0&&(this[Er]=!1),this[bn]=[]):this[bn].splice(this[bn].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let r=super.on(e,t);if(e==="data")this[Un]=!1,this[Go]++,!this[bn].length&&!this[Er]&&this[Rl]();else if(e==="readable"&&this[Ar]!==0)super.emit("readable");else if(MH(e)&&this[Ha])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Tf]){let i=t;this[Ss]?If(()=>i.call(this,this[Tf])):i.call(this,this[Tf])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[Go]=this.listeners("data").length,this[Go]===0&&!this[Un]&&!this[bn].length&&(this[Er]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Go]=0,!this[Un]&&!this[bn].length&&(this[Er]=!1)),t}get emittedEnd(){return this[Ha]}[ua](){!this[Wm]&&!this[Ha]&&!this[zt]&&this[Tr].length===0&&this[la]&&(this[Wm]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Gm]&&this.emit("close"),this[Wm]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==zt&&this[zt])return!1;if(e==="data")return!this[Yr]&&!r?!1:this[Ss]?(If(()=>this[nv](r)),!0):this[nv](r);if(e==="end")return this[iP]();if(e==="close"){if(this[Gm]=!0,!this[Ha]&&!this[zt])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[Tf]=r,super.emit(rv,r);let s=!this[xf]||this.listeners("error").length?super.emit("error",r):!1;return this[ua](),s}else if(e==="resume"){let s=super.emit("resume");return this[ua](),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[ua](),i}[nv](e){for(let r of this[bn])r.dest.write(e)===!1&&this.pause();let t=this[Un]?!1:super.emit("data",e);return this[ua](),t}[iP](){return this[Ha]?!1:(this[Ha]=!0,this.readable=!1,this[Ss]?(If(()=>this[iv]()),!0):this[iv]())}[iv](){if(this[Cl]){let t=this[Cl].end();if(t){for(let r of this[bn])r.dest.write(t);this[Un]||super.emit("data",t)}}for(let t of this[bn])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[Yr]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[Yr]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[Yr])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Vi]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(zt,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Un]=!1;let e=!1,t=o(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:o(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[la])return t();let s,a,c=o(d=>{this.off("data",l),this.off("end",u),this.off(zt,f),t(),a(d)},"onerr"),l=o(d=>{this.off("error",c),this.off("end",u),this.off(zt,f),this.pause(),s({value:d,done:!!this[la]})},"ondata"),u=o(()=>{this.off("error",c),this.off("data",l),this.off(zt,f),t(),s({done:!0,value:void 0})},"onend"),f=o(()=>c(new Error("stream destroyed")),"ondestroy");return new Promise((d,h)=>{a=h,s=d,this.once(zt,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[Un]=!1;let e=!1,t=o(()=>(this.pause(),this.off(rv,t),this.off(zt,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),r=o(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(rv,t),this.once(zt,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[zt])return e?this.emit("error",e):this.emit(zt),this;this[zt]=!0,this[Un]=!0,this[Tr].length=0,this[Ar]=0;let t=this;return typeof t.close=="function"&&!this[Gm]&&t.close(),e?this.emit("error",e):this.emit(zt),this}static get isStream(){return NH}};var WH=vs.realpathSync.native,Rf={lstatSync:vs.lstatSync,readdir:vs.readdir,readdirSync:vs.readdirSync,readlinkSync:vs.readlinkSync,realpathSync:WH,promises:{lstat:Ka.lstat,readdir:Ka.readdir,readlink:Ka.readlink,realpath:Ka.realpath}},fP=o(n=>!n||n===Rf||n===qH?Rf:{...Rf,...n,promises:{...Rf.promises,...n.promises||{}}},"fsFromOption"),dP=/^\\\\\?\\([a-z]:)\\?$/i,GH=o(n=>n.replace(/\//g,"\\").replace(dP,"$1\\"),"uncToDrive"),zH=/[\\\/]/,si=0,hP=1,pP=2,ws=4,mP=6,gP=8,zo=10,yP=12,ii=15,Cf=~ii,cv=16,aP=32,Of=64,Bi=128,Xm=256,Zm=512,oP=Of|Bi|Zm,HH=1023,lv=o(n=>n.isFile()?gP:n.isDirectory()?ws:n.isSymbolicLink()?zo:n.isCharacterDevice()?pP:n.isBlockDevice()?mP:n.isSocket()?yP:n.isFIFO()?hP:si,"entToType"),cP=new Map,Pf=o(n=>{let e=cP.get(n);if(e)return e;let t=n.normalize("NFKD");return cP.set(n,t),t},"normalize"),lP=new Map,Jm=o(n=>{let e=lP.get(n);if(e)return e;let t=Pf(n.toLowerCase());return lP.set(n,t),t},"normalizeNocase"),eg=class extends Ef{static{o(this,"ResolveCache")}constructor(){super({max:256})}},uv=class extends Ef{static{o(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:o(t=>t.length+1,"sizeCalculation")})}},_P=Symbol("PathScurry setAsCwd"),Xr=class{static{o(this,"PathBase")}name;root;roots;parent;nocase;isCWD=!1;#e;#n;get dev(){return this.#n}#r;get mode(){return this.#r}#t;get nlink(){return this.#t}#c;get uid(){return this.#c}#_;get gid(){return this.#_}#i;get rdev(){return this.#i}#u;get blksize(){return this.#u}#s;get ino(){return this.#s}#l;get size(){return this.#l}#a;get blocks(){return this.#a}#p;get atimeMs(){return this.#p}#g;get mtimeMs(){return this.#g}#d;get ctimeMs(){return this.#d}#m;get birthtimeMs(){return this.#m}#y;get atime(){return this.#y}#f;get mtime(){return this.#f}#E;get ctime(){return this.#E}#T;get birthtime(){return this.#T}#b;#v;#S;#w;#x;#I;#o;#F;#A;#O;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=si,r,i,s,a,c){this.name=e,this.#b=s?Jm(e):Pf(e),this.#o=t&HH,this.nocase=s,this.roots=i,this.root=r||this,this.#F=a,this.#S=c.fullpath,this.#x=c.relative,this.#I=c.relativePosix,this.parent=c.parent,this.parent?this.#e=this.parent.#e:this.#e=fP(c.fs)}depth(){return this.#v!==void 0?this.#v:this.parent?this.#v=this.parent.depth()+1:this.#v=0}childrenCache(){return this.#F}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 r of e)t=t.child(r);return t}children(){let e=this.#F.get(this);if(e)return e;let t=Object.assign([],{provisional:0});return this.#F.set(this,t),this.#o&=~cv,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?Jm(e):Pf(e);for(let l of r)if(l.#b===i)return l;let s=this.parent?this.sep:"",a=this.#S?this.#S+s+e:void 0,c=this.newChild(e,si,{...t,parent:this,fullpath:a});return this.canReaddir()||(c.#o|=Bi),r.push(c),c}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let e=this.name,t=this.parent;if(!t)return this.#x=this.name;let r=t.relative();return r+(!r||!t.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let e=this.name,t=this.parent;if(!t)return this.#I=this.fullpathPosix();let r=t.relativePosix();return r+(!r||!t.parent?"":"/")+e}fullpath(){if(this.#S!==void 0)return this.#S;let e=this.name,t=this.parent;if(!t)return this.#S=this.name;let i=t.fullpath()+(t.parent?this.sep:"")+e;return this.#S=i}fullpathPosix(){if(this.#w!==void 0)return this.#w;if(this.sep==="/")return this.#w=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#w=`//?/${i}`:this.#w=i}let e=this.parent,t=e.fullpathPosix(),r=t+(!t||!e.parent?"":"/")+this.name;return this.#w=r}isUnknown(){return(this.#o&ii)===si}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.#o&ii)===gP}isDirectory(){return(this.#o&ii)===ws}isCharacterDevice(){return(this.#o&ii)===pP}isBlockDevice(){return(this.#o&ii)===mP}isFIFO(){return(this.#o&ii)===hP}isSocket(){return(this.#o&ii)===yP}isSymbolicLink(){return(this.#o&zo)===zo}lstatCached(){return this.#o&aP?this:void 0}readlinkCached(){return this.#A}realpathCached(){return this.#O}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#A)return!0;if(!this.parent)return!1;let e=this.#o&ii;return!(e!==si&&e!==zo||this.#o&Xm||this.#o&Bi)}calledReaddir(){return!!(this.#o&cv)}isENOENT(){return!!(this.#o&Bi)}isNamed(e){return this.nocase?this.#b===Jm(e):this.#b===Pf(e)}async readlink(){let e=this.#A;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=await this.#e.promises.readlink(this.fullpath()),r=(await this.parent.realpath())?.resolve(t);if(r)return this.#A=r}catch(t){this.#h(t.code);return}}readlinkSync(){let e=this.#A;if(e)return e;if(this.canReadlink()&&this.parent)try{let t=this.#e.readlinkSync(this.fullpath()),r=this.parent.realpathSync()?.resolve(t);if(r)return this.#A=r}catch(t){this.#h(t.code);return}}#N(e){this.#o|=cv;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#L()}}#L(){this.#o&Bi||(this.#o=(this.#o|Bi)&Cf,this.#C())}#C(){let e=this.children();e.provisional=0;for(let t of e)t.#L()}#R(){this.#o|=Zm,this.#k()}#k(){if(this.#o&Of)return;let e=this.#o;(e&ii)===ws&&(e&=Cf),this.#o=e|Of,this.#C()}#j(e=""){e==="ENOTDIR"||e==="EPERM"?this.#k():e==="ENOENT"?this.#L():this.children().provisional=0}#M(e=""){e==="ENOTDIR"?this.parent.#k():e==="ENOENT"&&this.#L()}#h(e=""){let t=this.#o;t|=Xm,e==="ENOENT"&&(t|=Bi),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Cf),this.#o=t,e==="ENOTDIR"&&this.parent&&this.parent.#k()}#$(e,t){return this.#P(e,t)||this.#V(e,t)}#V(e,t){let r=lv(e),i=this.newChild(e.name,r,{parent:this}),s=i.#o&ii;return s!==ws&&s!==zo&&s!==si&&(i.#o|=Of),t.unshift(i),t.provisional++,i}#P(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?Jm(e.name):Pf(e.name))===i.#b)return this.#B(e,i,r,t)}}#B(e,t,r,i){let s=t.name;return t.#o=t.#o&Cf|lv(e),s!==e.name&&(t.name=e.name),r!==i.provisional&&(r===i.length-1?i.pop():i.splice(r,1),i.unshift(t)),i.provisional++,t}async lstat(){if((this.#o&Bi)===0)try{return this.#G(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#M(e.code)}}lstatSync(){if((this.#o&Bi)===0)try{return this.#G(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#M(e.code)}}#G(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:s,blksize:a,blocks:c,ctime:l,ctimeMs:u,dev:f,gid:d,ino:h,mode:p,mtime:y,mtimeMs:S,nlink:v,rdev:w,size:T,uid:C}=e;this.#y=t,this.#p=r,this.#T=i,this.#m=s,this.#u=a,this.#a=c,this.#E=l,this.#d=u,this.#n=f,this.#_=d,this.#s=h,this.#r=p,this.#f=y,this.#g=S,this.#t=v,this.#i=w,this.#l=T,this.#c=C;let M=lv(e);this.#o=this.#o&Cf|M|aP,M!==si&&M!==ws&&M!==zo&&(this.#o|=Of)}#q=[];#W=!1;#z(e){this.#W=!1;let t=this.#q.slice();this.#q.length=0,t.forEach(r=>r(null,e))}readdirCB(e,t=!1){if(!this.canReaddir()){t?e(null,[]):queueMicrotask(()=>e(null,[]));return}let r=this.children();if(this.calledReaddir()){let s=r.slice(0,r.provisional);t?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#q.push(e),this.#W)return;this.#W=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,a)=>{if(s)this.#j(s.code),r.provisional=0;else{for(let c of a)this.#$(c,r);this.#N(r)}this.#z(r.slice(0,r.provisional))})}#U;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.#U)await this.#U;else{let r=o(()=>{},"resolve");this.#U=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#$(i,e);this.#N(e)}catch(i){this.#j(i.code),e.provisional=0}this.#U=void 0,r()}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 r of this.#e.readdirSync(t,{withFileTypes:!0}))this.#$(r,e);this.#N(e)}catch(r){this.#j(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#o&oP)return!1;let e=ii&this.#o;return e===si||e===ws||e===zo}shouldWalk(e,t){return(this.#o&ws)===ws&&!(this.#o&oP)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#O)return this.#O;if(!((Zm|Xm|Bi)&this.#o))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#O=this.resolve(e)}catch{this.#R()}}realpathSync(){if(this.#O)return this.#O;if(!((Zm|Xm|Bi)&this.#o))try{let e=this.#e.realpathSync(this.fullpath());return this.#O=this.resolve(e)}catch{this.#R()}}[_P](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let t=new Set([]),r=[],i=this;for(;i&&i.parent;)t.add(i),i.#x=r.join(this.sep),i.#I=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#x=void 0,i.#I=void 0,i=i.parent}},tg=class n extends Xr{static{o(this,"PathWin32")}sep="\\";splitSep=zH;constructor(e,t=si,r,i,s,a,c){super(e,t,r,i,s,a,c)}newChild(e,t=si,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return Ol.win32.parse(e).root}getRoot(e){if(e=GH(e.toUpperCase()),e===this.root.name)return this.root;for(let[t,r]of Object.entries(this.roots))if(this.sameRoot(e,t))return this.roots[e]=r;return this.roots[e]=new Pl(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(dP,"$1\\"),e===t}},rg=class n extends Xr{static{o(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=si,r,i,s,a,c){super(e,t,r,i,s,a,c)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=si,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},ng=class{static{o(this,"PathScurryBase")}root;rootPath;roots;cwd;#e;#n;#r;nocase;#t;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:s=16*1024,fs:a=Rf}={}){this.#t=fP(a),(e instanceof URL||e.startsWith("file://"))&&(e=(0,uP.fileURLToPath)(e));let c=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(c),this.#e=new eg,this.#n=new eg,this.#r=new uv(s);let l=c.substring(this.rootPath.length).split(r);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.#t),this.roots[this.rootPath]=this.root;let u=this.root,f=l.length-1,d=t.sep,h=this.rootPath,p=!1;for(let y of l){let S=f--;u=u.child(y,{relative:new Array(S).fill("..").join(d),relativePosix:new Array(S).fill("..").join("/"),fullpath:h+=(p?"":d)+y}),p=!0}this.cwd=u}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#r}resolve(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#e.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpath();return this.#e.set(t,i),i}resolvePosix(...e){let t="";for(let s=e.length-1;s>=0;s--){let a=e[s];if(!(!a||a===".")&&(t=t?`${a}/${t}`:a,this.isAbsolute(a)))break}let r=this.#n.get(t);if(r!==void 0)return r;let i=this.cwd.resolve(t).fullpathPosix();return this.#n.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 Xr||(t=e,e=this.cwd);let{withFileTypes:r}=t;if(e.canReaddir()){let i=await e.readdir();return r?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 Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0}=t;return e.canReaddir()?r?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 Xr||(t=e.withFileTypes,e=this.cwd);let r=await e.readlink();return t?r:r?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e.withFileTypes,e=this.cwd);let r=e.readlinkSync();return t?r:r?.fullpath()}async realpath(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e.withFileTypes,e=this.cwd);let r=await e.realpath();return t?r:r?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:t}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e.withFileTypes,e=this.cwd);let r=e.realpathSync();return t?r:r?.fullpath()}async walk(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?e:e.fullpath());let l=new Set,u=o((d,h)=>{l.add(d),d.readdirCB((p,y)=>{if(p)return h(p);let S=y.length;if(!S)return h();let v=o(()=>{--S===0&&h()},"next");for(let w of y)(!s||s(w))&&c.push(r?w:w.fullpath()),i&&w.isSymbolicLink()?w.realpath().then(T=>T?.isUnknown()?T.lstat():T).then(T=>T?.shouldWalk(l,a)?u(T,v):v()):w.shouldWalk(l,a)?u(w,v):v()},!0)},"walk"),f=e;return new Promise((d,h)=>{u(f,p=>{if(p)return h(p);d(c)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=[];(!s||s(e))&&c.push(r?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(r?d:d.fullpath());let h=d;if(d.isSymbolicLink()){if(!(i&&(h=d.realpathSync())))continue;h.isUnknown()&&h.lstatSync()}h.shouldWalk(l,a)&&l.add(h)}}return c}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(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 Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t;(!s||s(e))&&(yield r?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 r?f:f.fullpath());let d=f;if(f.isSymbolicLink()){if(!(i&&(d=f.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,a)&&c.add(d)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new Qa({objectMode:!0});(!s||s(e))&&c.write(r?e:e.fullpath());let l=new Set,u=[e],f=0,d=o(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&c.end();return}f++,l.add(p);let y=o((v,w,T=!1)=>{if(v)return c.emit("error",v);if(i&&!T){let C=[];for(let M of w)M.isSymbolicLink()&&C.push(M.realpath().then(V=>V?.isUnknown()?V.lstat():V));if(C.length){Promise.all(C).then(()=>y(null,w,!0));return}}for(let C of w)C&&(!s||s(C))&&(c.write(r?C:C.fullpath())||(h=!0));f--;for(let C of w){let M=C.realpathCached()||C;M.shouldWalk(l,a)&&u.push(M)}h&&!c.flowing?c.once("drain",d):S||d()},"onReaddir"),S=!0;p.readdirCB(y,!0),S=!1}},"process");return d(),c}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof Xr||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:a}=t,c=new Qa({objectMode:!0}),l=new Set;(!s||s(e))&&c.write(r?e:e.fullpath());let u=[e],f=0,d=o(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&c.end();return}f++,l.add(p);let y=p.readdirSync();for(let S of y)(!s||s(S))&&(c.write(r?S:S.fullpath())||(h=!0));f--;for(let S of y){let v=S;if(S.isSymbolicLink()){if(!(i&&(v=S.realpathSync())))continue;v.isUnknown()&&v.lstatSync()}v.shouldWalk(l,a)&&u.push(v)}}h&&!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[_P](t)}},Pl=class extends ng{static{o(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,Ol.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return Ol.win32.parse(e).root.toUpperCase()}newRoot(e){return new tg(this.rootPath,ws,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Fl=class extends ng{static{o(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,Ol.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new rg(this.rootPath,ws,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},Ff=class extends Fl{static{o(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},eue=process.platform==="win32"?tg:rg,bP=process.platform==="win32"?Pl:process.platform==="darwin"?Ff:Fl;var QH=o(n=>n.length>=1,"isPatternList"),KH=o(n=>n.length>=1,"isGlobList"),Dl=class n{static{o(this,"Pattern")}#e;#n;#r;length;#t;#c;#_;#i;#u;#s;#l=!0;constructor(e,t,r,i){if(!QH(e))throw new TypeError("empty pattern list");if(!KH(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,r<0||r>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#n=t,this.#r=r,this.#t=i,this.#r===0){if(this.isUNC()){let[s,a,c,l,...u]=this.#e,[f,d,h,p,...y]=this.#n;u[0]===""&&(u.shift(),y.shift());let S=[s,a,c,l,""].join("/"),v=[f,d,h,p,""].join("/");this.#e=[S,...u],this.#n=[v,...y],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...a]=this.#e,[c,...l]=this.#n;a[0]===""&&(a.shift(),l.shift());let u=s+"/",f=c+"/";this.#e=[u,...a],this.#n=[f,...l],this.length=this.#e.length}}}pattern(){return this.#e[this.#r]}isString(){return typeof this.#e[this.#r]=="string"}isGlobstar(){return this.#e[this.#r]===Gt}isRegExp(){return this.#e[this.#r]instanceof RegExp}globString(){return this.#_=this.#_||(this.#r===0?this.isAbsolute()?this.#n[0]+this.#n.slice(1).join("/"):this.#n.join("/"):this.#n.slice(this.#r).join("/"))}hasMore(){return this.length>this.#r+1}rest(){return this.#c!==void 0?this.#c:this.hasMore()?(this.#c=new n(this.#e,this.#n,this.#r+1,this.#t),this.#c.#s=this.#s,this.#c.#u=this.#u,this.#c.#i=this.#i,this.#c):this.#c=null}isUNC(){let e=this.#e;return this.#u!==void 0?this.#u:this.#u=this.#t==="win32"&&this.#r===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#i!==void 0?this.#i:this.#i=this.#t==="win32"&&this.#r===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#s!==void 0?this.#s:this.#s=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#r===0?e:""}checkFollowGlobstar(){return!(this.#r===0||!this.isGlobstar()||!this.#l)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#l?!1:(this.#l=!1,!0)}};var YH=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Nl=class{static{o(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:s,platform:a=YH}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:s,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let c of e)this.add(c)}add(e){let t=new Bn(e,this.mmopts);for(let r=0;r<t.set.length;r++){let i=t.set[r],s=t.globParts[r];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let a=new Dl(i,s,0,this.platform),c=new Bn(a.globString(),this.mmopts),l=s[s.length-1]==="**",u=a.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(),r=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let a of this.relative)if(a.match(i)||a.match(s))return!0;for(let a of this.absolute)if(a.match(t)||a.match(r))return!0;return!1}childrenIgnored(e){let t=e.fullpath()+"/",r=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(r))return!0;for(let i of this.absoluteChildren)if(i.match(t))return!0;return!1}};var fv=class n{static{o(this,"HasWalkedCache")}store;constructor(e=new Map){this.store=e}copy(){return new n(new Map(this.store))}hasWalked(e,t){return this.store.get(e.fullpath())?.has(t.globString())}storeWalked(e,t){let r=e.fullpath(),i=this.store.get(r);i?i.add(t.globString()):this.store.set(r,new Set([t.globString()]))}},dv=class{static{o(this,"MatchRecord")}store=new Map;add(e,t,r){let i=(t?2:0)|(r?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)])}},hv=class{static{o(this,"SubWalks")}store=new Map;add(e,t){if(!e.canReaddir())return;let r=this.store.get(e);r?r.find(i=>i.globString()===t.globString())||r.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())}},Df=class n{static{o(this,"Processor")}hasWalkedCache;matches=new dv;subwalks=new hv;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new fv}processPatterns(e,t){this.patterns=t;let r=t.map(i=>[e,i]);for(let[i,s]of r){this.hasWalkedCache.storeWalked(i,s);let a=s.root(),c=s.isAbsolute()&&this.opts.absolute!==!1;if(a){i=i.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);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===Gt){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let d=u?.pattern(),h=u?.rest();if(!u||(d===""||d===".")&&!h)this.matches.add(i,c,d===""||d===".");else if(d===".."){let p=i.parent||i;h?this.hasWalkedCache.hasWalked(p,h)||this.subwalks.add(p,h):this.matches.add(p,c,!0)}}else l instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new n(this.opts,this.hasWalkedCache)}filterEntries(e,t){let r=this.subwalks.get(e),i=this.child();for(let s of t)for(let a of r){let c=a.isAbsolute(),l=a.pattern(),u=a.rest();l===Gt?i.testGlobstar(s,a,u,c):l instanceof RegExp?i.testRegExp(s,l,u,c):i.testString(s,l,u,c)}return i}testGlobstar(e,t,r,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()&&(r&&t.checkFollowGlobstar()?this.subwalks.add(e,r):t.markFollowGlobstar()&&this.subwalks.add(e,t)))),r){let s=r.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,r.rest(),i);else if(s===".."){let a=e.parent||e;this.subwalks.add(a,r)}else s instanceof RegExp&&this.testRegExp(e,s,r.rest(),i)}}testRegExp(e,t,r,i){t.test(e.name)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}testString(e,t,r,i){e.isNamed(t)&&(r?this.subwalks.add(e,r):this.matches.add(e,i,!1))}};var XH=o((n,e)=>typeof n=="string"?new Nl([n],e):Array.isArray(n)?new Nl(n,e):n,"makeIgnore"),ig=class{static{o(this,"GlobUtil")}path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#n;#r;signal;maxDepth;includeChildMatches;constructor(e,t,r){if(this.patterns=e,this.path=t,this.opts=r,this.#r=!r.posix&&r.platform==="win32"?"\\":"/",this.includeChildMatches=r.includeChildMatches!==!1,(r.ignore||!this.includeChildMatches)&&(this.#n=XH(r.ignore??[],r),!this.includeChildMatches&&typeof this.#n.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=r.maxDepth||1/0,r.signal&&(this.signal=r.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#t(e){return this.seen.has(e)||!!this.#n?.ignored?.(e)}#c(e){return!!this.#n?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||await e.realpath(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=await s.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.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.#t(e)?e:void 0}matchCheckSync(e,t){if(t&&this.opts.nodir)return;let r;if(this.opts.realpath){if(r=e.realpathCached()||e.realpathSync(),!r)return;e=r}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let a=s.realpathSync();a&&(a?.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(s,t)}matchFinish(e,t){if(this.#t(e))return;if(!this.includeChildMatches&&this.#n?.add){let s=`${e.relativePosix()}/**`;this.#n.add(s)}let r=this.opts.absolute===void 0?t:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#r:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(r){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),a=this.opts.dotRelative&&!s.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(s?a+s+i:"."+i)}}async match(e,t,r){let i=await this.matchCheck(e,r);i&&this.matchFinish(i,t)}matchSync(e,t,r){let i=this.matchCheckSync(e,r);i&&this.matchFinish(i,t)}walkCB(e,t,r){this.signal?.aborted&&r(),this.walkCB2(e,t,new Df(this.opts),r)}walkCB2(e,t,r,i){if(this.#c(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||(s++,this.match(c,l,u).then(()=>a()));for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirCached();c.calledReaddir()?this.walkCB3(c,l,r,a):c.readdirCB((u,f)=>this.walkCB3(c,f,r,a),!0)}a()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||(s++,this.match(c,l,u).then(()=>a()));for(let[c,l]of r.subwalks.entries())s++,this.walkCB2(c,l,r.child(),a);a()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new Df(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#c(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,t,r,i));return}r.processPatterns(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||this.matchSync(c,l,u);for(let c of r.subwalkTargets()){if(this.maxDepth!==1/0&&c.depth()>=this.maxDepth)continue;s++;let l=c.readdirSync();this.walkCB3Sync(c,l,r,a)}a()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let s=1,a=o(()=>{--s===0&&i()},"next");for(let[c,l,u]of r.matches.entries())this.#t(c)||this.matchSync(c,l,u);for(let[c,l]of r.subwalks.entries())s++,this.walkCB2Sync(c,l,r.child(),a);a()}},Nf=class extends ig{static{o(this,"GlobWalker")}matches=new Set;constructor(e,t,r){super(e,t,r)}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}},Lf=class extends ig{static{o(this,"GlobStream")}results;constructor(e,t,r){super(e,t,r),this.results=new Qa({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 JH=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ui=class{static{o(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,SP.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||JH,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"?Pl:t.platform==="darwin"?Ff:t.platform?Fl:bP;this.scurry=new l(this.cwd,{nocase:t.nocase,fs:t.fs})}this.nocase=this.scurry.nocase;let r=this.platform==="darwin"||this.platform==="win32",i={...t,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:r,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 Bn(l,i)),[a,c]=s.reduce((l,u)=>(l[0].push(...u.set),l[1].push(...u.globParts),l),[[],[]]);this.patterns=a.map((l,u)=>{let f=c[u];if(!f)throw new Error("invalid pattern object");return new Dl(l,f,0,this.platform)})}async walk(){return[...await new Nf(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 Nf(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 Lf(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 Lf(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 pv=o((n,e={})=>{Array.isArray(n)||(n=[n]);for(let t of n)if(new Bn(t,e).hasMagic())return!0;return!1},"hasMagic");function sg(n,e={}){return new Ui(n,e).streamSync()}o(sg,"globStreamSync");function vP(n,e={}){return new Ui(n,e).stream()}o(vP,"globStream");function EP(n,e={}){return new Ui(n,e).walkSync()}o(EP,"globSync");async function wP(n,e={}){return new Ui(n,e).walk()}o(wP,"glob_");function ag(n,e={}){return new Ui(n,e).iterateSync()}o(ag,"globIterateSync");function TP(n,e={}){return new Ui(n,e).iterate()}o(TP,"globIterate");var ZH=sg,eQ=Object.assign(vP,{sync:sg}),tQ=ag,rQ=Object.assign(TP,{sync:ag}),nQ=Object.assign(EP,{stream:sg,iterate:ag}),Ll=Object.assign(wP,{glob:wP,globSync:EP,sync:nQ,globStream:vP,stream:eQ,globStreamSync:sg,streamSync:ZH,globIterate:TP,iterate:rQ,globIterateSync:ag,iterateSync:tQ,Glob:Ui,hasMagic:pv,escape:Al,unescape:$i});Ll.glob=Ll;async function xP(n,e,t,r={}){let{dryRun:i=!1,excludeRelPath:s}=r,a=Ho.default.join(n,"**/*.md"),c=await Ll(a,{nodir:!0,ignore:[Ho.default.join(n,".obsidian/**"),Ho.default.join(n,".trash/**"),Ho.default.join(n,"**/.obsidian/**"),Ho.default.join(n,"**/.trash/**")]}),l={filesScanned:0,filesModified:0,replacements:0,modifiedFiles:[]};for(let u of c){let f=Ho.default.relative(n,u);if(s&&f===s)continue;l.filesScanned+=1;let d;try{d=await mv.default.readFile(u,"utf-8")}catch{continue}let{updated:h,replacements:p}=iQ(d,e,t);p>0&&(l.filesModified+=1,l.replacements+=p,l.modifiedFiles.push(f),i||await mv.default.writeFile(u,h,"utf-8"))}return l}o(xP,"rewriteInboundWikilinks");function iQ(n,e,t){let r=n.split(/(^```[\s\S]*?^```)/m),i=0;for(let s=0;s<r.length;s++){if(s%2===1)continue;let a=r[s],c=sQ(a,e,t);i+=c.replacements,r[s]=c.updated}return{updated:r.join(""),replacements:i}}o(iQ,"rewriteContent");function sQ(n,e,t){let r=n.split(/(`[^`\n]*`)/),i=0;for(let s=0;s<r.length;s++){if(s%2===1)continue;let a=aQ(r[s],e,t);i+=a.replacements,r[s]=a.updated}return{updated:r.join(""),replacements:i}}o(sQ,"rewriteProseSegment");function aQ(n,e,t){let r=/(?<!!)\[\[([^\[\]\n|#^]+)((?:[#^][^\[\]\n|]*)?)(?:\|[^\[\]\n]*)?\]\]/g,i=0;return{updated:n.replace(r,(a,c,l)=>c.trim()!==e?a:(i+=1,`[[${t}${l}]]`)),replacements:i}}o(aQ,"replaceWikilinks");var oQ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Lt=class{constructor(e){this.rootPath=e;this.uuidIndex=null;this.basenameIndex=null;this.aliasIndex=null}static{o(this,"FileSystemVaultAdapter")}async read(e){let t=this.resolvePath(e.path);if(!await nr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);return nr.default.readFile(t,"utf-8")}async create(e,t){let r=this.resolvePath(e);if(await nr.default.pathExists(r))throw new Error(`File already exists: ${e}`);return await nr.default.ensureDir(Ht.default.dirname(r)),await nr.default.writeFile(r,t,"utf-8"),this.createFileObject(e)}async modify(e,t){let r=this.resolvePath(e.path);if(!await nr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await nr.default.writeFile(r,t,"utf-8")}async delete(e){let t=this.resolvePath(e.path);if(!await nr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);await nr.default.remove(t)}async exists(e){let t=this.resolvePath(e);return nr.default.pathExists(t)}getAbstractFileByPath(e){let t=this.resolvePath(e);try{let r=nr.default.statSync(t);if(r.isFile())return this.createFileObject(e);if(r.isDirectory())return this.createFolderObject(e)}catch{return null}return null}getAllFiles(){let e=[];return this.walkDirectory(this.rootPath,t=>{if(t.endsWith(".md")){let r=Ht.default.relative(this.rootPath,t);e.push(this.createFileObject(r))}}),e}getFrontmatter(e){try{let t=nr.default.readFileSync(this.resolvePath(e.path),"utf-8");return this.extractFrontmatter(t)}catch{return null}}async updateFrontmatter(e,t){let r=await this.read(e),i=this.extractFrontmatter(r)||{},s=t(i),a=this.replaceFrontmatter(r,s);await this.modify(e,a)}async rename(e,t){let r=this.resolvePath(e.path),i=this.resolvePath(t);if(!await nr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await nr.default.ensureDir(Ht.default.dirname(i)),await nr.default.move(r,i)}async createFolder(e){let t=this.resolvePath(e);await nr.default.ensureDir(t)}getFirstLinkpathDest(e,t){let r=e.split("|")[0].trim();if(!r)return null;if(oQ.test(r)){this.uuidIndex===null&&this.buildUuidIndex();let u=r.toLowerCase(),f=this.uuidIndex.get(u);return f?this.createFileObject(f):null}let i=Ht.default.dirname(this.resolvePath(t)),s;if(Ht.default.isAbsolute(r)?s=this.resolvePath(r):s=Ht.default.resolve(i,r),r.endsWith(".md")||(s+=".md"),nr.default.existsSync(s)){let u=Ht.default.relative(this.rootPath,s);return this.createFileObject(u)}(this.basenameIndex===null||this.aliasIndex===null)&&this.buildLinkpathIndex();let a=r.toLowerCase(),c=this.basenameIndex.get(a);if(c)return this.createFileObject(c);let l=this.aliasIndex.get(a);return l?this.createFileObject(l):null}buildLinkpathIndex(){this.basenameIndex=new Map,this.aliasIndex=new Map,this.walkDirectory(this.rootPath,e=>{if(!e.endsWith(".md"))return;let t=Ht.default.relative(this.rootPath,e),r=Ht.default.basename(e,".md").toLowerCase();this.basenameIndex.has(r)||this.basenameIndex.set(r,t);let i;try{i=nr.default.readFileSync(e,"utf-8")}catch{return}let s=this.extractFrontmatter(i);if(!s)return;let a=s.aliases,c=Array.isArray(a)?a:typeof a=="string"?[a]:[];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 r=Ht.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(r){let i=r[1].toLowerCase(),s=Ht.default.relative(this.rootPath,e);this.uuidIndex.set(i,s)}}})}async process(e,t){let r=await this.read(e),i=t(r);return await this.modify(e,i),i}getDefaultNewFileParent(){return{path:"",name:""}}async updateLinks(e,t,r){let i=Ht.default.basename(t,".md");await xP(this.rootPath,r,i,{excludeRelPath:e})}resolvePath(e){return Ht.default.isAbsolute(e)?e:Ht.default.join(this.rootPath,e)}createFileObject(e){let t=Ht.default.basename(e),r=Ht.default.basename(e,Ht.default.extname(e)),i=Ht.default.dirname(e);return{path:e,basename:r,name:t,parent:i!=="."?this.createFolderObject(i):null}}createFolderObject(e){return{path:e,name:Ht.default.basename(e)}}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return null;try{let i=rr.load(r[1]);return typeof i=="object"&&i!==null?i:null}catch{return null}}replaceFrontmatter(e,t){let r=rr.dump(t,{lineWidth:-1,noRefs:!0,quotingType:'"'}),i=/^---\n([\s\S]*?)\n---/;return e.match(i)?e.replace(i,`---
489
489
  ${r.trim()}
490
490
  ---`):`---
491
491
  ${r.trim()}
@@ -760,7 +760,7 @@ ${r}`}o($Y,"serializeFile");function bD(n,e,t={}){let r=Mg.default.dirname(n),i=
760
760
  `).map(s=>s.trim()).filter(Boolean)){let s=VY.exec(i);if(s){r.push({sessionName:i,uuid:s[1],type:"full"});continue}let a=BY.exec(i);a&&r.push({sessionName:i,uuid:a[1],type:"short"})}return r}o(qY,"listClaudeChildSessions");function WY(n,e,t){let r=null,i=e.toLowerCase();function s(a){if(r)return;let c;try{c=(0,Vg.readdirSync)(a,{withFileTypes:!0})}catch{return}for(let l of c){if(r)return;if(l.name.startsWith(".")||l.name==="node_modules")continue;let u=(0,SD.join)(a,l.name);if(l.isDirectory())s(u);else if(l.name.endsWith(".md")){let f=l.name.slice(0,-3).toLowerCase();(t==="full"&&f===i||t==="short"&&f.startsWith(i))&&(r=u)}}}return o(s,"walk"),s(n),r}o(WY,"findVaultFile");function GY(n,e){try{let i=(e??(s=>(0,Vg.readFileSync)(s,"utf8")))(n).match(/ems__Effort_status\s*:.*\[\[([^\]]+)\]\]/);return i?i[1].includes(UY):!1}catch{return!1}}o(GY,"isTaskDoing");async function vD(n,e=$g.exec,t){let r=await qY(e),i=[];for(let s of r){let a=WY(n,s.uuid,s.type);if(!a){i.push({sessionName:s.sessionName,taskUuid:s.uuid,taskFilePath:null,reason:"vault task not found"});continue}GY(a,t)||i.push({sessionName:s.sessionName,taskUuid:s.uuid,taskFilePath:a,reason:"vault task status != Doing"})}return i}o(vD,"detectOrphans");async function ED(n,e,t=$g.exec,r=bD){let i=wD(t);if(e)return{ok:!0};let s=new Date().toISOString();if(n.taskFilePath)try{r(n.taskFilePath,{ems__Effort_status:"[[ems__EffortStatusFailed]]",aiTask__Task_lastError:`orphan recovery: ${n.reason}`,exo__Asset_updatedAt:s})}catch(a){return{ok:!1,error:`vault update failed: ${a.message}`}}try{await i(`tmux kill-session -t ${JSON.stringify(n.sessionName)}`)}catch{}return{ok:!0}}o(ED,"recoverOrphan");function zY(){return process.env.EXOCORTEX_VAULT??(0,Bg.join)((0,AD.homedir)(),"vault-2025")}o(zY,"defaultVault");function xD(){return new Ie("recover").description("Detect and recover orphaned claude-child tmux sessions. A session is orphaned when the corresponding vault task is not in Doing status. Default mode: dry-run (no changes). Use --apply to perform recovery.").option("--vault <path>","Path to Obsidian vault",zY()).option("--dry-run","List orphans without applying changes (default)",!1).option("--apply","Apply orphan recovery: set Failed + kill tmux session",!1).action(async n=>{let e=(0,Bg.resolve)(n.vault);if(!(0,TD.existsSync)(e)){console.error(`[recover] vault not found: ${e}`),process.exitCode=1;return}let t=!n.apply;console.log(`[recover] vault=${e} mode=${t?"dry-run":"apply"}`);let r=await vD(e);if(r.length===0){console.log("[recover] No orphaned claude-child sessions found.");return}console.log(`[recover] Found ${r.length} orphan(s):`);for(let a of r){let c=a.taskFilePath??"(not found in vault)";console.log(` session=${a.sessionName} uuid=${a.taskUuid} reason=${a.reason}`),console.log(` file=${c}`)}if(t){console.log("[recover] Dry-run mode: no changes applied. Use --apply to recover.");return}let i=0,s=0;for(let a of r){let c=await ED(a,!1);c.ok?(i++,console.log(`[recover] RECOVERED: ${a.sessionName}`)):(s++,console.error(`[recover] ERROR recovering ${a.sessionName}: ${c.error}`))}console.log(`[recover] Done: recovered=${i} errors=${s}`),s>0&&(process.exitCode=1)})}o(xD,"recoverCommand");var d2=require("fs"),Ug=require("path"),Gn=le(Sr());function HY(n,e){return e.concat([n])}o(HY,"collectAlso");var QY="https://exocortex.my/ontology/find#Alias_sparql",KY="https://exocortex.my/ontology/exo#Asset_label";function Yl(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}o(Yl,"nodeValue");async function YY(n,e){let t=await n.match(void 0,void 0,void 0),r=[];for(let s of t)Yl(s.predicate)!==KY||Yl(s.object)!==e||r.push(Yl(s.subject));if(r.length===0)return null;let i=[];for(let s of r)for(let a of t)Yl(a.predicate)===QY&&Yl(a.subject)===s&&i.push(Yl(a.object));if(i.length===0)return null;if(i.length>1)throw new Vt(`Ambiguous find__Alias "${e}" \u2014 ${i.length} instances define a sparql fragment`,`Ensure exactly one find__Alias asset has exo:Asset_label "${e}"`);return i[0]}o(YY,"resolveAliasFragment");var XY=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,JY="https://exocortex.my/ontology/";function ZY(n,e){let t=XY.exec(e);if(t){let i=`<${JY}${t[1]}#${t[2]}>`;return n.replace(/\?value\b/g,i)}let r=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return n.replace(/\?value\b/g,`"${r}"`)}o(ZY,"bindValueLiteral");function ID(){return new Ie("find").description("Find vault assets via SPARQL \u2014 outputs file paths one per line (RFC 8e83442b T1.1)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to include (repeatable)",HY,[]).option("--sparql <query>","SPARQL SELECT query (must bind ?path)").option("--class <value>","Filter by class label via find__Alias 'class' (e.g. ems__Task)").action(async n=>{pe.setFormat("text");try{if(n.sparql&&n.class)throw new Vt("--sparql and --class are mutually exclusive","Pass either a raw --sparql query or a find__Alias-backed flag like --class");if(!n.sparql&&!n.class)throw new Vt("one of --sparql <query> or --class <value> is required",'exocortex find --class ems__Task OR exocortex find --sparql "SELECT ?path WHERE { ... }"');let e=(0,Ug.resolve)(n.vault);if(!(0,d2.existsSync)(e))throw new Pe(e);let t=new Lt(e),i=await new Gn.NoteToRDFConverter(t).convertVault(),s=n.also||[];for(let w of s){let T=(0,Ug.resolve)(w);if(!(0,d2.existsSync)(T))throw new Pe(T);let C=new Lt(T),V=await new Gn.NoteToRDFConverter(C).convertVault();i=i.concat(V)}let a=new Gn.InMemoryTripleStore;await a.addAll(i);let c;if(n.class){let w=await YY(a,"class");if(w===null)throw new Vt('No find__Alias with exo:Asset_label "class" was found in the vault',"Seed a find__Alias asset (label=class) or fall back to exocortex find --sparql");c=`SELECT ?path WHERE { ${ZY(w,n.class)} }`}else c=n.sparql;let l=ql(c);l=Xa(l);let u=new Gn.ExoQLParser,f=Ja(Ya(e));for(let w of s){let T=Ja(Ya((0,Ug.resolve)(w)));for(let[C,M]of T)f.has(C)||f.set(C,M)}f.size>0&&u.setVaultPrefixes(f);let d=u.parse(l),p=new Gn.ExoQLAlgebraTranslator().translate(d);p.type!=="construct"&&(p=new Gn.AlgebraOptimizer().optimize(p));let S=await new Gn.ExoQLQueryExecutor(a).executeAll(p),v="obsidian://vault/";for(let w of S){let C=w.toJSON().path;if(typeof C!="string"||!C.startsWith(v))continue;let M=C.slice(v.length),V;try{V=decodeURIComponent(M)}catch{V=M}process.stdout.write(V+`
761
761
  `)}}catch(e){pe.handle(e),process.exit(5)}})}o(ID,"findCommand");var p2=require("fs"),m2=require("path"),et=le(Sr());var FD=le(Sr()),Ut=le(RD());var OD="obsidian://vault/";function fX(n){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return{async resolveTargetPath(t){if(!t)throw new Error("Cannot resolve empty targetIRI to a vault path");let r=t;if(r.startsWith(OD))r=decodeURI(r.slice(OD.length));else if(e.test(r)){let i=await n.findFileByUID(r);if(!i)throw new Error(`No vault file found for UID: ${r}`);r=i}if(r.endsWith(".md")||(r=`${r}.md`),!await n.fileExists(r))throw new Error(`Cannot resolve target file for IRI "${t}" (tried "${r}")`);return r}}}o(fX,"createCliPathResolver");var dX=["createAsset","openFile","sparqlSelect","getActiveFileIRI","getActiveFilePath","trashFile","duplicateFile"],h2=class extends Error{constructor(t){super(`Service "${t}" is not implemented in the CLI (no-op stub). dyncommand exec on this service_call grounding cannot change vault state. See CLI parity issues #2865-#2868 for port status.`);this.serviceId=t;this.name="CliServiceNotImplementedError"}static{o(this,"CliServiceNotImplementedError")}};function PD(n){return{async execute(){throw new h2(n)}}}o(PD,"notImplementedService");function DD(n,e){for(let t of dX)n.register(t,PD(t));for(let t of["updateProperty","removeProperty","setStatus"])n.register(t,PD(t));if(e){if(e.fsAdapter){let t=new FD.FrontmatterService,r=fX(e.fsAdapter);n.register("updateProperty",(0,Ut.createUpdatePropertyService)(e.fsAdapter,t,r)),n.register("removeProperty",(0,Ut.createRemovePropertyService)(e.fsAdapter,t,r)),n.register("setStatus",(0,Ut.createSetStatusService)(e.fsAdapter,t,r))}n.register("createRelatedTask",(0,Ut.createCreateRelatedTaskService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("createRelatedProject",(0,Ut.createCreateRelatedProjectService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("archiveAsset",(0,Ut.createArchiveAssetService)(e.vaultAdapter,e.archiveAssetService)),n.register("planForEvening",(0,Ut.createPlanForEveningService)(e.vaultAdapter,e.taskStatusService)),n.register("cleanProperties",(0,Ut.createCleanPropertiesService)(e.vaultAdapter,e.propertyCleanupService)),n.register("renameToUid",(0,Ut.createRenameToUidService)(e.vaultAdapter,e.renameToUidService)),n.register("repairFolder",(0,Ut.createRepairFolderService)(e.vaultAdapter,e.folderRepairService)),n.register("fixMissingLabel",(0,Ut.createFixMissingLabelService)(e.vaultAdapter,e.fixMissingLabelService))}}o(DD,"populateCliServiceRegistry");var hX=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function pX(){if(process.stdin.isTTY)return[];let n=[];for await(let t of process.stdin)n.push(t);return Buffer.concat(n).toString("utf-8").split(`
762
762
  `).map(t=>t.trim()).filter(t=>t.length>0)}o(pX,"readStdinLines");function qg(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}o(qg,"nodeValue");async function mX(n,e){let t=new et.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),r=await n.match(void 0,t,void 0),i=[];for(let s of r)if(qg(s.object)===e){let l=qg(s.subject).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i);l&&i.push(l[1])}if(i.length===0)return null;if(i.length>1)throw new Vt(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}o(mX,"resolveSlugToUuid");async function gX(n,e){let t=new et.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),r=await n.match(void 0,t,void 0);for(let i of r)if(qg(i.subject).includes(e)){let a=qg(i.object);if(a==="true"||a==="True")return!0}return!1}o(gX,"isDestructive");async function yX(n,e,t,r,i){let s=(0,m2.resolve)(n,r);if(!(0,p2.existsSync)(s))return console.error(`\u274C Target file not found: ${r}`),!1;let c=await new et.CommandResolver(e).loadCommand(t);if(!c)return console.error(`\u274C Command with UID "${t}" not found.`),!1;if(await gX(e,t)&&!i.dryRun&&!i.yes)return console.error(`\u274C Command "${c.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),!1;let u=(0,et.vaultPathToIRI)(r);if(!await new et.PreconditionEvaluator(e).evaluate(c.precondition,u))return console.error(`\u274C Precondition not satisfied for "${c.name}" on "${r}".`),!1;if(i.dryRun)return console.log(`\u{1F50D} Dry-run: would apply "${c.name}" to "${r}" (precondition passed).`),!0;let h=new et.ServiceRegistry,p=new Lt(n),y=new et.GenericAssetCreationService(p),S=new et.ArchiveAssetService(p),v=new et.PropertyCleanupService(p),w=new et.FixMissingLabelService(p),T=new et.RenameToUidService(p),C=new et.FolderRepairService(p),M=new et.TaskStatusService(p,new et.EffortStatusWorkflow,new et.StatusTimestampService(p)),V=new hr(n);DD(h,{vaultAdapter:p,fsAdapter:V,genericAssetCreationService:y,archiveAssetService:S,taskStatusService:M,propertyCleanupService:v,fixMissingLabelService:w,renameToUidService:T,folderRepairService:C});let ee=new et.GroundingExecutor(V,V,h),U;if(i.input)try{let P=JSON.parse(i.input);if(typeof P!="object"||P===null||Array.isArray(P))throw new Error("must be a JSON object");U=P}catch(P){let N=P instanceof Error?P.message:String(P);return console.error(`\u274C --input: invalid JSON object (${N})`),!1}let W=await ee.execute(c.grounding,u,r,U);if(W.success){let P=c.successMessage??`Applied "${c.name}" to "${r}".`;return console.log(`\u2705 ${P}`),!0}else return console.error(`\u274C "${c.name}" failed on "${r}": ${W.error}`),!1}o(yX,"executeOnTarget");function ND(){return new Ie("apply").description("Apply an exocmd__Command to one or more vault assets (RFC 8e83442b T1.2). Pass a path arg or pipe paths via stdin.").argument("<cmd>","Command UUID or cliName slug").argument("[path]","Vault-relative path to target asset (omit to read paths from stdin)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--dry-run","Preview without writing").option("--yes","Skip destructive-command confirmation").option("--input <json>","JSON userInput for service_call groundings").action(async(n,e,t)=>{pe.setFormat("text");try{let r=(0,m2.resolve)(t.vault);if(!(0,p2.existsSync)(r))throw new Pe(r);let i=new Lt(r),a=await new et.NoteToRDFConverter(i).convertVault(),c=new et.InMemoryTripleStore;await c.addAll(a);let l;if(hX.test(n))l=n;else{let h=await mX(c,n);h||(console.error(`\u274C No command found with UUID or cliName "${n}".`),process.exit(3)),l=h}let u;if(e)u=[e];else if(u=await pX(),u.length===0)throw new Vt("No target path provided and stdin is empty.","exocortex apply <uuid> <path> OR exocortex find ... | exocortex apply <uuid>");let f=0,d=0;for(let h of u)await yX(r,c,l,h,t)?f++:d++;u.length>1&&console.log(`
763
- \u{1F4CA} Applied to ${f}/${u.length} target(s) (${d} failed).`),d>0&&process.exit(5)}catch(r){pe.handle(r),process.exit(5)}})}o(ND,"applyCommand");function LD(n){let e=new Ie;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.15.0"),e.addCommand(ID()),e.addCommand(ND()),e.addCommand(sF()),e.addCommand(lF()),e.addCommand(NF()),e.addCommand(dF()),e.addCommand(hF()),e.addCommand(_F()),e.addCommand(jF()),e.addCommand(GF()),e.addCommand(QF()),e.addCommand(KF()),e.addCommand(XF()),e.addCommand(cD()),e.addCommand(lD()),e.addCommand(gD()),e.addCommand(xD()),e}o(LD,"createProgram");LD().parse();0&&(module.exports={createProgram});
763
+ \u{1F4CA} Applied to ${f}/${u.length} target(s) (${d} failed).`),d>0&&process.exit(5)}catch(r){pe.handle(r),process.exit(5)}})}o(ND,"applyCommand");function LD(n){let e=new Ie;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.16.0"),e.addCommand(ID()),e.addCommand(ND()),e.addCommand(sF()),e.addCommand(lF()),e.addCommand(NF()),e.addCommand(dF()),e.addCommand(hF()),e.addCommand(_F()),e.addCommand(jF()),e.addCommand(GF()),e.addCommand(QF()),e.addCommand(KF()),e.addCommand(XF()),e.addCommand(cD()),e.addCommand(lD()),e.addCommand(gD()),e.addCommand(xD()),e}o(LD,"createProgram");LD().parse();0&&(module.exports={createProgram});
764
764
  /*! Bundled license information:
765
765
 
766
766
  reflect-metadata/Reflect.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitelev/exocortex-cli",
3
- "version": "16.15.0",
3
+ "version": "16.16.0",
4
4
  "description": "CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more",
5
5
  "main": "dist/index.js",
6
6
  "bin": {