@kitelev/exocortex-cli 16.60.13 → 16.61.1

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 +70 -70
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v16.60.13
2
+ // @kitelev/exocortex-cli v16.61.1
3
3
  // CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more
4
4
  // License: MIT
5
5
 
6
- "use strict";var HN=Object.create;var Au=Object.defineProperty;var QN=Object.getOwnPropertyDescriptor;var YN=Object.getOwnPropertyNames;var XN=Object.getPrototypeOf,KN=Object.prototype.hasOwnProperty;var a=(n,e)=>Au(n,"name",{value:e,configurable:!0});var JN=(n,e)=>()=>(n&&(e=n(n=0)),e);var S=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),s0=(n,e)=>{for(var t in e)Au(n,t,{get:e[t],enumerable:!0})},dT=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of YN(e))!KN.call(n,i)&&i!==t&&Au(n,i,{get:()=>e[i],enumerable:!(r=QN(e,i))||r.enumerable});return n};var Z=(n,e,t)=>(t=n!=null?HN(XN(n)):{},dT(e||!n||!n.__esModule?Au(t,"default",{value:n,enumerable:!0}):t,n)),Gd=n=>dT(Au({},"__esModule",{value:!0}),n);var o0=S(()=>{var hT;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:l(),r=i(n);typeof t.Reflect<"u"&&(r=i(t.Reflect,r)),e(r,t),typeof t.Reflect>"u"&&(t.Reflect=n);function i(c,u){return function(f,d){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}a(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}a(s,"functionThis");function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}a(o,"indirectEvalThis");function l(){return s()||o()}a(l,"sloppyModeThis")})(function(e,t){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",l=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!l&&!c,f={create:l?function(){return ze(Object.create(null))}:c?function(){return ze({__proto__:null})}:function(){return ze({})},has:u?function(T,x){return r.call(T,x)}:function(T,x){return x in T},get:u?function(T,x){return r.call(T,x)?T[x]:void 0}:function(T,x){return T[x]}},d=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:xe(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:st(),g=typeof WeakMap=="function"?WeakMap:et(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=Ee(),w=Te(v);function E(T,x,R,F){if(H(R)){if(!Qe(T))throw new TypeError;if(!Ye(x))throw new TypeError;return V(T,x)}else{if(!Qe(T))throw new TypeError;if(!ae(x))throw new TypeError;if(!ae(F)&&!H(F)&&!De(F))throw new TypeError;return De(F)&&(F=void 0),R=Le(R),Y(T,x,R,F)}}a(E,"decorate"),e("decorate",E);function I(T,x){function R(F,te){if(!ae(F))throw new TypeError;if(!H(te)&&!Ze(te))throw new TypeError;U(T,x,F,te)}return a(R,"decorator"),R}a(I,"metadata"),e("metadata",I);function A(T,x,R,F){if(!ae(R))throw new TypeError;return H(F)||(F=Le(F)),U(T,x,R,F)}a(A,"defineMetadata"),e("defineMetadata",A);function D(T,x,R){if(!ae(x))throw new TypeError;return H(R)||(R=Le(R)),re(T,x,R)}a(D,"hasMetadata"),e("hasMetadata",D);function K(T,x,R){if(!ae(x))throw new TypeError;return H(R)||(R=Le(R)),G(T,x,R)}a(K,"hasOwnMetadata"),e("hasOwnMetadata",K);function oe(T,x,R){if(!ae(x))throw new TypeError;return H(R)||(R=Le(R)),ne(T,x,R)}a(oe,"getMetadata"),e("getMetadata",oe);function me(T,x,R){if(!ae(x))throw new TypeError;return H(R)||(R=Le(R)),q(T,x,R)}a(me,"getOwnMetadata"),e("getOwnMetadata",me);function N(T,x){if(!ae(T))throw new TypeError;return H(x)||(x=Le(x)),B(T,x)}a(N,"getMetadataKeys"),e("getMetadataKeys",N);function Q(T,x){if(!ae(T))throw new TypeError;return H(x)||(x=Le(x)),tt(T,x)}a(Q,"getOwnMetadataKeys"),e("getOwnMetadataKeys",Q);function ie(T,x,R){if(!ae(x))throw new TypeError;if(H(R)||(R=Le(R)),!ae(x))throw new TypeError;H(R)||(R=Le(R));var F=fe(x,R,!1);return H(F)?!1:F.OrdinaryDeleteMetadata(T,x,R)}a(ie,"deleteMetadata"),e("deleteMetadata",ie);function V(T,x){for(var R=T.length-1;R>=0;--R){var F=T[R],te=F(x);if(!H(te)&&!De(te)){if(!Ye(te))throw new TypeError;x=te}}return x}a(V,"DecorateConstructor");function Y(T,x,R,F){for(var te=T.length-1;te>=0;--te){var wt=T[te],Ct=wt(x,R,F);if(!H(Ct)&&!De(Ct)){if(!ae(Ct))throw new TypeError;F=Ct}}return F}a(Y,"DecorateProperty");function re(T,x,R){var F=G(T,x,R);if(F)return!0;var te=pe(x);return De(te)?!1:re(T,te,R)}a(re,"OrdinaryHasMetadata");function G(T,x,R){var F=fe(x,R,!1);return H(F)?!1:He(F.OrdinaryHasOwnMetadata(T,x,R))}a(G,"OrdinaryHasOwnMetadata");function ne(T,x,R){var F=G(T,x,R);if(F)return q(T,x,R);var te=pe(x);if(!De(te))return ne(T,te,R)}a(ne,"OrdinaryGetMetadata");function q(T,x,R){var F=fe(x,R,!1);if(!H(F))return F.OrdinaryGetOwnMetadata(T,x,R)}a(q,"OrdinaryGetOwnMetadata");function U(T,x,R,F){var te=fe(R,F,!0);te.OrdinaryDefineOwnMetadata(T,x,R,F)}a(U,"OrdinaryDefineOwnMetadata");function B(T,x){var R=tt(T,x),F=pe(T);if(F===null)return R;var te=B(F,x);if(te.length<=0)return R;if(R.length<=0)return te;for(var wt=new p,Ct=[],Ue=0,W=R;Ue<W.length;Ue++){var z=W[Ue],X=wt.has(z);X||(wt.add(z),Ct.push(z))}for(var J=0,ke=te;J<ke.length;J++){var z=ke[J],X=wt.has(z);X||(wt.add(z),Ct.push(z))}return Ct}a(B,"OrdinaryMetadataKeys");function tt(T,x){var R=fe(T,x,!1);return R?R.OrdinaryOwnMetadataKeys(T,x):[]}a(tt,"OrdinaryOwnMetadataKeys");function at(T){if(T===null)return 1;switch(typeof T){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return T===null?1:6;default:return 6}}a(at,"Type");function H(T){return T===void 0}a(H,"IsUndefined");function De(T){return T===null}a(De,"IsNull");function Be(T){return typeof T=="symbol"}a(Be,"IsSymbol");function ae(T){return typeof T=="object"?T!==null:typeof T=="function"}a(ae,"IsObject");function Xe(T,x){switch(at(T)){case 0:return T;case 1:return T;case 2:return T;case 3:return T;case 4:return T;case 5:return T}var R=x===3?"string":x===5?"number":"default",F=Se(T,s);if(F!==void 0){var te=F.call(T,R);if(ae(te))throw new TypeError;return te}return Ke(T,R==="default"?"number":R)}a(Xe,"ToPrimitive");function Ke(T,x){if(x==="string"){var R=T.toString;if(Me(R)){var F=R.call(T);if(!ae(F))return F}var te=T.valueOf;if(Me(te)){var F=te.call(T);if(!ae(F))return F}}else{var te=T.valueOf;if(Me(te)){var F=te.call(T);if(!ae(F))return F}var wt=T.toString;if(Me(wt)){var F=wt.call(T);if(!ae(F))return F}}throw new TypeError}a(Ke,"OrdinaryToPrimitive");function He(T){return!!T}a(He,"ToBoolean");function Je(T){return""+T}a(Je,"ToString");function Le(T){var x=Xe(T,3);return Be(x)?x:Je(x)}a(Le,"ToPropertyKey");function Qe(T){return Array.isArray?Array.isArray(T):T instanceof Object?T instanceof Array:Object.prototype.toString.call(T)==="[object Array]"}a(Qe,"IsArray");function Me(T){return typeof T=="function"}a(Me,"IsCallable");function Ye(T){return typeof T=="function"}a(Ye,"IsConstructor");function Ze(T){switch(at(T)){case 3:return!0;case 4:return!0;default:return!1}}a(Ze,"IsPropertyKey");function ge(T,x){return T===x||T!==T&&x!==x}a(ge,"SameValueZero");function Se(T,x){var R=T[x];if(R!=null){if(!Me(R))throw new TypeError;return R}}a(Se,"GetMethod");function we(T){var x=Se(T,o);if(!Me(x))throw new TypeError;var R=x.call(T);if(!ae(R))throw new TypeError;return R}a(we,"GetIterator");function ye(T){return T.value}a(ye,"IteratorValue");function _e(T){var x=T.next();return x.done?!1:x}a(_e,"IteratorStep");function be(T){var x=T.return;x&&x.call(T)}a(be,"IteratorClose");function pe(T){var x=Object.getPrototypeOf(T);if(typeof T!="function"||T===d||x!==d)return x;var R=T.prototype,F=R&&Object.getPrototypeOf(R);if(F==null||F===Object.prototype)return x;var te=F.constructor;return typeof te!="function"||te===T?x:te}a(pe,"OrdinaryGetPrototypeOf");function ve(){var T;!H(_)&&typeof t.Reflect<"u"&&!(_ in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(T=Ie(t.Reflect));var x,R,F,te=new g,wt={registerProvider:Ct,getProvider:W,setProvider:X};return wt;function Ct(J){if(!Object.isExtensible(wt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case T===J:break;case H(x):x=J;break;case x===J:break;case H(R):R=J;break;case R===J:break;default:F===void 0&&(F=new p),F.add(J);break}}function Ue(J,ke){if(!H(x)){if(x.isProviderFor(J,ke))return x;if(!H(R)){if(R.isProviderFor(J,ke))return x;if(!H(F))for(var lt=we(F);;){var ct=_e(lt);if(!ct)return;var Pr=ye(ct);if(Pr.isProviderFor(J,ke))return be(lt),Pr}}}if(!H(T)&&T.isProviderFor(J,ke))return T}function W(J,ke){var lt=te.get(J),ct;return H(lt)||(ct=lt.get(ke)),H(ct)&&(ct=Ue(J,ke),H(ct)||(H(lt)&&(lt=new h,te.set(J,lt)),lt.set(ke,ct))),ct}function z(J){if(H(J))throw new TypeError;return x===J||R===J||!H(F)&&F.has(J)}function X(J,ke,lt){if(!z(lt))throw new Error("Metadata provider not registered.");var ct=W(J,ke);if(ct!==lt){if(!H(ct))return!1;var Pr=te.get(J);H(Pr)&&(Pr=new h,te.set(J,Pr)),Pr.set(ke,lt)}return!0}}a(ve,"CreateMetadataRegistry");function Ee(){var T;return!H(_)&&ae(t.Reflect)&&Object.isExtensible(t.Reflect)&&(T=t.Reflect[_]),H(T)&&(T=ve()),!H(_)&&ae(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:T}),T}a(Ee,"GetOrCreateMetadataRegistry");function Te(T){var x=new g,R={isProviderFor:a(function(z,X){var J=x.get(z);return H(J)?!1:J.has(X)},"isProviderFor"),OrdinaryDefineOwnMetadata:Ct,OrdinaryHasOwnMetadata:te,OrdinaryGetOwnMetadata:wt,OrdinaryOwnMetadataKeys:Ue,OrdinaryDeleteMetadata:W};return v.registerProvider(R),R;function F(z,X,J){var ke=x.get(z),lt=!1;if(H(ke)){if(!J)return;ke=new h,x.set(z,ke),lt=!0}var ct=ke.get(X);if(H(ct)){if(!J)return;if(ct=new h,ke.set(X,ct),!T.setProvider(z,X,R))throw ke.delete(X),lt&&x.delete(z),new Error("Wrong provider for target.")}return ct}a(F,"GetOrCreateMetadataMap");function te(z,X,J){var ke=F(X,J,!1);return H(ke)?!1:He(ke.has(z))}a(te,"OrdinaryHasOwnMetadata");function wt(z,X,J){var ke=F(X,J,!1);if(!H(ke))return ke.get(z)}a(wt,"OrdinaryGetOwnMetadata");function Ct(z,X,J,ke){var lt=F(J,ke,!0);lt.set(z,X)}a(Ct,"OrdinaryDefineOwnMetadata");function Ue(z,X){var J=[],ke=F(z,X,!1);if(H(ke))return J;for(var lt=ke.keys(),ct=we(lt),Pr=0;;){var Tn=_e(ct);if(!Tn)return J.length=Pr,J;var Vn=ye(Tn);try{J[Pr]=Vn}catch(sn){try{be(ct)}finally{throw sn}}Pr++}}a(Ue,"OrdinaryOwnMetadataKeys");function W(z,X,J){var ke=F(X,J,!1);if(H(ke)||!ke.delete(z))return!1;if(ke.size===0){var lt=x.get(X);H(lt)||(lt.delete(J),lt.size===0&&x.delete(lt))}return!0}a(W,"OrdinaryDeleteMetadata")}a(Te,"CreateMetadataProvider");function Ie(T){var x=T.defineMetadata,R=T.hasOwnMetadata,F=T.getOwnMetadata,te=T.getOwnMetadataKeys,wt=T.deleteMetadata,Ct=new g,Ue={isProviderFor:a(function(W,z){var X=Ct.get(W);return!H(X)&&X.has(z)?!0:te(W,z).length?(H(X)&&(X=new p,Ct.set(W,X)),X.add(z),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:x,OrdinaryHasOwnMetadata:R,OrdinaryGetOwnMetadata:F,OrdinaryOwnMetadataKeys:te,OrdinaryDeleteMetadata:wt};return Ue}a(Ie,"CreateFallbackProvider");function fe(T,x,R){var F=v.getProvider(T,x);if(!H(F))return F;if(R){if(v.setProvider(T,x,w))return w;throw new Error("Illegal state.")}}a(fe,"GetMetadataProvider");function xe(){var T={},x=[],R=(function(){function Ue(W,z,X){this._index=0,this._keys=W,this._values=z,this._selector=X}return a(Ue,"MapIterator"),Ue.prototype["@@iterator"]=function(){return this},Ue.prototype[o]=function(){return this},Ue.prototype.next=function(){var W=this._index;if(W>=0&&W<this._keys.length){var z=this._selector(this._keys[W],this._values[W]);return W+1>=this._keys.length?(this._index=-1,this._keys=x,this._values=x):this._index++,{value:z,done:!1}}return{value:void 0,done:!0}},Ue.prototype.throw=function(W){throw this._index>=0&&(this._index=-1,this._keys=x,this._values=x),W},Ue.prototype.return=function(W){return this._index>=0&&(this._index=-1,this._keys=x,this._values=x),{value:W,done:!0}},Ue})(),F=(function(){function Ue(){this._keys=[],this._values=[],this._cacheKey=T,this._cacheIndex=-2}return a(Ue,"Map"),Object.defineProperty(Ue.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),Ue.prototype.has=function(W){return this._find(W,!1)>=0},Ue.prototype.get=function(W){var z=this._find(W,!1);return z>=0?this._values[z]:void 0},Ue.prototype.set=function(W,z){var X=this._find(W,!0);return this._values[X]=z,this},Ue.prototype.delete=function(W){var z=this._find(W,!1);if(z>=0){for(var X=this._keys.length,J=z+1;J<X;J++)this._keys[J-1]=this._keys[J],this._values[J-1]=this._values[J];return this._keys.length--,this._values.length--,ge(W,this._cacheKey)&&(this._cacheKey=T,this._cacheIndex=-2),!0}return!1},Ue.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=T,this._cacheIndex=-2},Ue.prototype.keys=function(){return new R(this._keys,this._values,te)},Ue.prototype.values=function(){return new R(this._keys,this._values,wt)},Ue.prototype.entries=function(){return new R(this._keys,this._values,Ct)},Ue.prototype["@@iterator"]=function(){return this.entries()},Ue.prototype[o]=function(){return this.entries()},Ue.prototype._find=function(W,z){if(!ge(this._cacheKey,W)){this._cacheIndex=-1;for(var X=0;X<this._keys.length;X++)if(ge(this._keys[X],W)){this._cacheIndex=X;break}}return this._cacheIndex<0&&z&&(this._cacheIndex=this._keys.length,this._keys.push(W),this._values.push(void 0)),this._cacheIndex},Ue})();return F;function te(Ue,W){return Ue}function wt(Ue,W){return W}function Ct(Ue,W){return[Ue,W]}}a(xe,"CreateMapPolyfill");function st(){var T=(function(){function x(){this._map=new h}return a(x,"Set"),Object.defineProperty(x.prototype,"size",{get:a(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),x.prototype.has=function(R){return this._map.has(R)},x.prototype.add=function(R){return this._map.set(R,R),this},x.prototype.delete=function(R){return this._map.delete(R)},x.prototype.clear=function(){this._map.clear()},x.prototype.keys=function(){return this._map.keys()},x.prototype.values=function(){return this._map.keys()},x.prototype.entries=function(){return this._map.entries()},x.prototype["@@iterator"]=function(){return this.keys()},x.prototype[o]=function(){return this.keys()},x})();return T}a(st,"CreateSetPolyfill");function et(){var T=16,x=f.create(),R=F();return(function(){function W(){this._key=F()}return a(W,"WeakMap"),W.prototype.has=function(z){var X=te(z,!1);return X!==void 0?f.has(X,this._key):!1},W.prototype.get=function(z){var X=te(z,!1);return X!==void 0?f.get(X,this._key):void 0},W.prototype.set=function(z,X){var J=te(z,!0);return J[this._key]=X,this},W.prototype.delete=function(z){var X=te(z,!1);return X!==void 0?delete X[this._key]:!1},W.prototype.clear=function(){this._key=F()},W})();function F(){var W;do W="@@WeakMap@@"+Ue();while(f.has(x,W));return x[W]=!0,W}function te(W,z){if(!r.call(W,R)){if(!z)return;Object.defineProperty(W,R,{value:f.create()})}return W[R]}function wt(W,z){for(var X=0;X<z;++X)W[X]=Math.random()*255|0;return W}function Ct(W){if(typeof Uint8Array=="function"){var z=new Uint8Array(W);return typeof crypto<"u"?crypto.getRandomValues(z):typeof msCrypto<"u"?msCrypto.getRandomValues(z):wt(z,W),z}return wt(new Array(W),W)}function Ue(){var W=Ct(T);W[6]=W[6]&79|64,W[8]=W[8]&191|128;for(var z="",X=0;X<T;++X){var J=W[X];(X===4||X===6||X===8)&&(z+="-"),J<16&&(z+="0"),z+=J.toString(16).toLowerCase()}return z}}a(et,"CreateWeakMapPolyfill");function ze(T){return T.__=void 0,delete T.__,T}a(ze,"MakeDictionary")})})(hT||(hT={}))});var Ru=S(l0=>{var qd=class extends Error{static{a(this,"CommanderError")}constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},a0=class extends qd{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};l0.CommanderError=qd;l0.InvalidArgumentError=a0});var Wd=S(u0=>{var{InvalidArgumentError:ZN}=Ru(),c0=class{static{a(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new ZN(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function ek(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}a(ek,"humanReadableArgName");u0.Argument=c0;u0.humanReadableArgName=ek});var h0=S(d0=>{var{humanReadableArgName:tk}=Wd(),f0=class{static{a(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>tk(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatItemList(e,t,r){return t.length===0?[]:[r.styleTitle(e),...t,""]}groupItems(e,t,r){let i=new Map;return e.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth??80;function s(d,h){return t.formatItem(d,r,h,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],l=t.commandDescription(e);l.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(l),i),""]));let c=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",c,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,h)=>{let p=d.map(g=>s(t.styleOptionTerm(t.optionTerm(g)),t.styleOptionDescription(t.optionDescription(g))));o=o.concat(this.formatItemList(h,p,t))}),t.showGlobalOptions){let d=t.visibleGlobalOptions(e).map(h=>s(t.styleOptionTerm(t.optionTerm(h)),t.styleOptionDescription(t.optionDescription(h))));o=o.concat(this.formatItemList("Global Options:",d,t))}return this.groupItems(e.commands,t.visibleCommands(e),d=>d.helpGroup()||"Commands:").forEach((d,h)=>{let p=d.map(g=>s(t.styleSubcommandTerm(t.subcommandTerm(g)),t.styleSubcommandDescription(t.subcommandDescription(g))));o=o.concat(this.formatItemList(h,p,t))}),o.join(`
6
+ "use strict";var HN=Object.create;var Au=Object.defineProperty;var QN=Object.getOwnPropertyDescriptor;var YN=Object.getOwnPropertyNames;var XN=Object.getPrototypeOf,KN=Object.prototype.hasOwnProperty;var a=(n,e)=>Au(n,"name",{value:e,configurable:!0});var JN=(n,e)=>()=>(n&&(e=n(n=0)),e);var S=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),s0=(n,e)=>{for(var t in e)Au(n,t,{get:e[t],enumerable:!0})},dT=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of YN(e))!KN.call(n,i)&&i!==t&&Au(n,i,{get:()=>e[i],enumerable:!(r=QN(e,i))||r.enumerable});return n};var Z=(n,e,t)=>(t=n!=null?HN(XN(n)):{},dT(e||!n||!n.__esModule?Au(t,"default",{value:n,enumerable:!0}):t,n)),Gd=n=>dT(Au({},"__esModule",{value:!0}),n);var o0=S(()=>{var hT;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:l(),r=i(n);typeof t.Reflect<"u"&&(r=i(t.Reflect,r)),e(r,t),typeof t.Reflect>"u"&&(t.Reflect=n);function i(c,u){return function(f,d){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}a(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}a(s,"functionThis");function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}a(o,"indirectEvalThis");function l(){return s()||o()}a(l,"sloppyModeThis")})(function(e,t){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",l=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!l&&!c,f={create:l?function(){return ze(Object.create(null))}:c?function(){return ze({__proto__:null})}:function(){return ze({})},has:u?function(T,x){return r.call(T,x)}:function(T,x){return x in T},get:u?function(T,x){return r.call(T,x)?T[x]:void 0}:function(T,x){return T[x]}},d=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:xe(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:st(),g=typeof WeakMap=="function"?WeakMap:et(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=Ee(),w=Te(v);function E(T,x,A,D){if(Q(A)){if(!Qe(T))throw new TypeError;if(!Ye(x))throw new TypeError;return V(T,x)}else{if(!Qe(T))throw new TypeError;if(!ae(x))throw new TypeError;if(!ae(D)&&!Q(D)&&!De(D))throw new TypeError;return De(D)&&(D=void 0),A=Le(A),X(T,x,A,D)}}a(E,"decorate"),e("decorate",E);function I(T,x){function A(D,te){if(!ae(D))throw new TypeError;if(!Q(te)&&!Ze(te))throw new TypeError;U(T,x,D,te)}return a(A,"decorator"),A}a(I,"metadata"),e("metadata",I);function O(T,x,A,D){if(!ae(A))throw new TypeError;return Q(D)||(D=Le(D)),U(T,x,A,D)}a(O,"defineMetadata"),e("defineMetadata",O);function C(T,x,A){if(!ae(x))throw new TypeError;return Q(A)||(A=Le(A)),re(T,x,A)}a(C,"hasMetadata"),e("hasMetadata",C);function H(T,x,A){if(!ae(x))throw new TypeError;return Q(A)||(A=Le(A)),G(T,x,A)}a(H,"hasOwnMetadata"),e("hasOwnMetadata",H);function ne(T,x,A){if(!ae(x))throw new TypeError;return Q(A)||(A=Le(A)),ie(T,x,A)}a(ne,"getMetadata"),e("getMetadata",ne);function de(T,x,A){if(!ae(x))throw new TypeError;return Q(A)||(A=Le(A)),q(T,x,A)}a(de,"getOwnMetadata"),e("getOwnMetadata",de);function N(T,x){if(!ae(T))throw new TypeError;return Q(x)||(x=Le(x)),B(T,x)}a(N,"getMetadataKeys"),e("getMetadataKeys",N);function Y(T,x){if(!ae(T))throw new TypeError;return Q(x)||(x=Le(x)),tt(T,x)}a(Y,"getOwnMetadataKeys"),e("getOwnMetadataKeys",Y);function se(T,x,A){if(!ae(x))throw new TypeError;if(Q(A)||(A=Le(A)),!ae(x))throw new TypeError;Q(A)||(A=Le(A));var D=fe(x,A,!1);return Q(D)?!1:D.OrdinaryDeleteMetadata(T,x,A)}a(se,"deleteMetadata"),e("deleteMetadata",se);function V(T,x){for(var A=T.length-1;A>=0;--A){var D=T[A],te=D(x);if(!Q(te)&&!De(te)){if(!Ye(te))throw new TypeError;x=te}}return x}a(V,"DecorateConstructor");function X(T,x,A,D){for(var te=T.length-1;te>=0;--te){var wt=T[te],Ct=wt(x,A,D);if(!Q(Ct)&&!De(Ct)){if(!ae(Ct))throw new TypeError;D=Ct}}return D}a(X,"DecorateProperty");function re(T,x,A){var D=G(T,x,A);if(D)return!0;var te=me(x);return De(te)?!1:re(T,te,A)}a(re,"OrdinaryHasMetadata");function G(T,x,A){var D=fe(x,A,!1);return Q(D)?!1:He(D.OrdinaryHasOwnMetadata(T,x,A))}a(G,"OrdinaryHasOwnMetadata");function ie(T,x,A){var D=G(T,x,A);if(D)return q(T,x,A);var te=me(x);if(!De(te))return ie(T,te,A)}a(ie,"OrdinaryGetMetadata");function q(T,x,A){var D=fe(x,A,!1);if(!Q(D))return D.OrdinaryGetOwnMetadata(T,x,A)}a(q,"OrdinaryGetOwnMetadata");function U(T,x,A,D){var te=fe(A,D,!0);te.OrdinaryDefineOwnMetadata(T,x,A,D)}a(U,"OrdinaryDefineOwnMetadata");function B(T,x){var A=tt(T,x),D=me(T);if(D===null)return A;var te=B(D,x);if(te.length<=0)return A;if(A.length<=0)return te;for(var wt=new p,Ct=[],Ue=0,W=A;Ue<W.length;Ue++){var z=W[Ue],K=wt.has(z);K||(wt.add(z),Ct.push(z))}for(var J=0,ke=te;J<ke.length;J++){var z=ke[J],K=wt.has(z);K||(wt.add(z),Ct.push(z))}return Ct}a(B,"OrdinaryMetadataKeys");function tt(T,x){var A=fe(T,x,!1);return A?A.OrdinaryOwnMetadataKeys(T,x):[]}a(tt,"OrdinaryOwnMetadataKeys");function at(T){if(T===null)return 1;switch(typeof T){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return T===null?1:6;default:return 6}}a(at,"Type");function Q(T){return T===void 0}a(Q,"IsUndefined");function De(T){return T===null}a(De,"IsNull");function Be(T){return typeof T=="symbol"}a(Be,"IsSymbol");function ae(T){return typeof T=="object"?T!==null:typeof T=="function"}a(ae,"IsObject");function Xe(T,x){switch(at(T)){case 0:return T;case 1:return T;case 2:return T;case 3:return T;case 4:return T;case 5:return T}var A=x===3?"string":x===5?"number":"default",D=Se(T,s);if(D!==void 0){var te=D.call(T,A);if(ae(te))throw new TypeError;return te}return Ke(T,A==="default"?"number":A)}a(Xe,"ToPrimitive");function Ke(T,x){if(x==="string"){var A=T.toString;if(Me(A)){var D=A.call(T);if(!ae(D))return D}var te=T.valueOf;if(Me(te)){var D=te.call(T);if(!ae(D))return D}}else{var te=T.valueOf;if(Me(te)){var D=te.call(T);if(!ae(D))return D}var wt=T.toString;if(Me(wt)){var D=wt.call(T);if(!ae(D))return D}}throw new TypeError}a(Ke,"OrdinaryToPrimitive");function He(T){return!!T}a(He,"ToBoolean");function Je(T){return""+T}a(Je,"ToString");function Le(T){var x=Xe(T,3);return Be(x)?x:Je(x)}a(Le,"ToPropertyKey");function Qe(T){return Array.isArray?Array.isArray(T):T instanceof Object?T instanceof Array:Object.prototype.toString.call(T)==="[object Array]"}a(Qe,"IsArray");function Me(T){return typeof T=="function"}a(Me,"IsCallable");function Ye(T){return typeof T=="function"}a(Ye,"IsConstructor");function Ze(T){switch(at(T)){case 3:return!0;case 4:return!0;default:return!1}}a(Ze,"IsPropertyKey");function ge(T,x){return T===x||T!==T&&x!==x}a(ge,"SameValueZero");function Se(T,x){var A=T[x];if(A!=null){if(!Me(A))throw new TypeError;return A}}a(Se,"GetMethod");function we(T){var x=Se(T,o);if(!Me(x))throw new TypeError;var A=x.call(T);if(!ae(A))throw new TypeError;return A}a(we,"GetIterator");function ye(T){return T.value}a(ye,"IteratorValue");function _e(T){var x=T.next();return x.done?!1:x}a(_e,"IteratorStep");function be(T){var x=T.return;x&&x.call(T)}a(be,"IteratorClose");function me(T){var x=Object.getPrototypeOf(T);if(typeof T!="function"||T===d||x!==d)return x;var A=T.prototype,D=A&&Object.getPrototypeOf(A);if(D==null||D===Object.prototype)return x;var te=D.constructor;return typeof te!="function"||te===T?x:te}a(me,"OrdinaryGetPrototypeOf");function ve(){var T;!Q(_)&&typeof t.Reflect<"u"&&!(_ in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(T=Ie(t.Reflect));var x,A,D,te=new g,wt={registerProvider:Ct,getProvider:W,setProvider:K};return wt;function Ct(J){if(!Object.isExtensible(wt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case T===J:break;case Q(x):x=J;break;case x===J:break;case Q(A):A=J;break;case A===J:break;default:D===void 0&&(D=new p),D.add(J);break}}function Ue(J,ke){if(!Q(x)){if(x.isProviderFor(J,ke))return x;if(!Q(A)){if(A.isProviderFor(J,ke))return x;if(!Q(D))for(var lt=we(D);;){var ct=_e(lt);if(!ct)return;var Pr=ye(ct);if(Pr.isProviderFor(J,ke))return be(lt),Pr}}}if(!Q(T)&&T.isProviderFor(J,ke))return T}function W(J,ke){var lt=te.get(J),ct;return Q(lt)||(ct=lt.get(ke)),Q(ct)&&(ct=Ue(J,ke),Q(ct)||(Q(lt)&&(lt=new h,te.set(J,lt)),lt.set(ke,ct))),ct}function z(J){if(Q(J))throw new TypeError;return x===J||A===J||!Q(D)&&D.has(J)}function K(J,ke,lt){if(!z(lt))throw new Error("Metadata provider not registered.");var ct=W(J,ke);if(ct!==lt){if(!Q(ct))return!1;var Pr=te.get(J);Q(Pr)&&(Pr=new h,te.set(J,Pr)),Pr.set(ke,lt)}return!0}}a(ve,"CreateMetadataRegistry");function Ee(){var T;return!Q(_)&&ae(t.Reflect)&&Object.isExtensible(t.Reflect)&&(T=t.Reflect[_]),Q(T)&&(T=ve()),!Q(_)&&ae(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:T}),T}a(Ee,"GetOrCreateMetadataRegistry");function Te(T){var x=new g,A={isProviderFor:a(function(z,K){var J=x.get(z);return Q(J)?!1:J.has(K)},"isProviderFor"),OrdinaryDefineOwnMetadata:Ct,OrdinaryHasOwnMetadata:te,OrdinaryGetOwnMetadata:wt,OrdinaryOwnMetadataKeys:Ue,OrdinaryDeleteMetadata:W};return v.registerProvider(A),A;function D(z,K,J){var ke=x.get(z),lt=!1;if(Q(ke)){if(!J)return;ke=new h,x.set(z,ke),lt=!0}var ct=ke.get(K);if(Q(ct)){if(!J)return;if(ct=new h,ke.set(K,ct),!T.setProvider(z,K,A))throw ke.delete(K),lt&&x.delete(z),new Error("Wrong provider for target.")}return ct}a(D,"GetOrCreateMetadataMap");function te(z,K,J){var ke=D(K,J,!1);return Q(ke)?!1:He(ke.has(z))}a(te,"OrdinaryHasOwnMetadata");function wt(z,K,J){var ke=D(K,J,!1);if(!Q(ke))return ke.get(z)}a(wt,"OrdinaryGetOwnMetadata");function Ct(z,K,J,ke){var lt=D(J,ke,!0);lt.set(z,K)}a(Ct,"OrdinaryDefineOwnMetadata");function Ue(z,K){var J=[],ke=D(z,K,!1);if(Q(ke))return J;for(var lt=ke.keys(),ct=we(lt),Pr=0;;){var Tn=_e(ct);if(!Tn)return J.length=Pr,J;var Vn=ye(Tn);try{J[Pr]=Vn}catch(sn){try{be(ct)}finally{throw sn}}Pr++}}a(Ue,"OrdinaryOwnMetadataKeys");function W(z,K,J){var ke=D(K,J,!1);if(Q(ke)||!ke.delete(z))return!1;if(ke.size===0){var lt=x.get(K);Q(lt)||(lt.delete(J),lt.size===0&&x.delete(lt))}return!0}a(W,"OrdinaryDeleteMetadata")}a(Te,"CreateMetadataProvider");function Ie(T){var x=T.defineMetadata,A=T.hasOwnMetadata,D=T.getOwnMetadata,te=T.getOwnMetadataKeys,wt=T.deleteMetadata,Ct=new g,Ue={isProviderFor:a(function(W,z){var K=Ct.get(W);return!Q(K)&&K.has(z)?!0:te(W,z).length?(Q(K)&&(K=new p,Ct.set(W,K)),K.add(z),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:x,OrdinaryHasOwnMetadata:A,OrdinaryGetOwnMetadata:D,OrdinaryOwnMetadataKeys:te,OrdinaryDeleteMetadata:wt};return Ue}a(Ie,"CreateFallbackProvider");function fe(T,x,A){var D=v.getProvider(T,x);if(!Q(D))return D;if(A){if(v.setProvider(T,x,w))return w;throw new Error("Illegal state.")}}a(fe,"GetMetadataProvider");function xe(){var T={},x=[],A=(function(){function Ue(W,z,K){this._index=0,this._keys=W,this._values=z,this._selector=K}return a(Ue,"MapIterator"),Ue.prototype["@@iterator"]=function(){return this},Ue.prototype[o]=function(){return this},Ue.prototype.next=function(){var W=this._index;if(W>=0&&W<this._keys.length){var z=this._selector(this._keys[W],this._values[W]);return W+1>=this._keys.length?(this._index=-1,this._keys=x,this._values=x):this._index++,{value:z,done:!1}}return{value:void 0,done:!0}},Ue.prototype.throw=function(W){throw this._index>=0&&(this._index=-1,this._keys=x,this._values=x),W},Ue.prototype.return=function(W){return this._index>=0&&(this._index=-1,this._keys=x,this._values=x),{value:W,done:!0}},Ue})(),D=(function(){function Ue(){this._keys=[],this._values=[],this._cacheKey=T,this._cacheIndex=-2}return a(Ue,"Map"),Object.defineProperty(Ue.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),Ue.prototype.has=function(W){return this._find(W,!1)>=0},Ue.prototype.get=function(W){var z=this._find(W,!1);return z>=0?this._values[z]:void 0},Ue.prototype.set=function(W,z){var K=this._find(W,!0);return this._values[K]=z,this},Ue.prototype.delete=function(W){var z=this._find(W,!1);if(z>=0){for(var K=this._keys.length,J=z+1;J<K;J++)this._keys[J-1]=this._keys[J],this._values[J-1]=this._values[J];return this._keys.length--,this._values.length--,ge(W,this._cacheKey)&&(this._cacheKey=T,this._cacheIndex=-2),!0}return!1},Ue.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=T,this._cacheIndex=-2},Ue.prototype.keys=function(){return new A(this._keys,this._values,te)},Ue.prototype.values=function(){return new A(this._keys,this._values,wt)},Ue.prototype.entries=function(){return new A(this._keys,this._values,Ct)},Ue.prototype["@@iterator"]=function(){return this.entries()},Ue.prototype[o]=function(){return this.entries()},Ue.prototype._find=function(W,z){if(!ge(this._cacheKey,W)){this._cacheIndex=-1;for(var K=0;K<this._keys.length;K++)if(ge(this._keys[K],W)){this._cacheIndex=K;break}}return this._cacheIndex<0&&z&&(this._cacheIndex=this._keys.length,this._keys.push(W),this._values.push(void 0)),this._cacheIndex},Ue})();return D;function te(Ue,W){return Ue}function wt(Ue,W){return W}function Ct(Ue,W){return[Ue,W]}}a(xe,"CreateMapPolyfill");function st(){var T=(function(){function x(){this._map=new h}return a(x,"Set"),Object.defineProperty(x.prototype,"size",{get:a(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),x.prototype.has=function(A){return this._map.has(A)},x.prototype.add=function(A){return this._map.set(A,A),this},x.prototype.delete=function(A){return this._map.delete(A)},x.prototype.clear=function(){this._map.clear()},x.prototype.keys=function(){return this._map.keys()},x.prototype.values=function(){return this._map.keys()},x.prototype.entries=function(){return this._map.entries()},x.prototype["@@iterator"]=function(){return this.keys()},x.prototype[o]=function(){return this.keys()},x})();return T}a(st,"CreateSetPolyfill");function et(){var T=16,x=f.create(),A=D();return(function(){function W(){this._key=D()}return a(W,"WeakMap"),W.prototype.has=function(z){var K=te(z,!1);return K!==void 0?f.has(K,this._key):!1},W.prototype.get=function(z){var K=te(z,!1);return K!==void 0?f.get(K,this._key):void 0},W.prototype.set=function(z,K){var J=te(z,!0);return J[this._key]=K,this},W.prototype.delete=function(z){var K=te(z,!1);return K!==void 0?delete K[this._key]:!1},W.prototype.clear=function(){this._key=D()},W})();function D(){var W;do W="@@WeakMap@@"+Ue();while(f.has(x,W));return x[W]=!0,W}function te(W,z){if(!r.call(W,A)){if(!z)return;Object.defineProperty(W,A,{value:f.create()})}return W[A]}function wt(W,z){for(var K=0;K<z;++K)W[K]=Math.random()*255|0;return W}function Ct(W){if(typeof Uint8Array=="function"){var z=new Uint8Array(W);return typeof crypto<"u"?crypto.getRandomValues(z):typeof msCrypto<"u"?msCrypto.getRandomValues(z):wt(z,W),z}return wt(new Array(W),W)}function Ue(){var W=Ct(T);W[6]=W[6]&79|64,W[8]=W[8]&191|128;for(var z="",K=0;K<T;++K){var J=W[K];(K===4||K===6||K===8)&&(z+="-"),J<16&&(z+="0"),z+=J.toString(16).toLowerCase()}return z}}a(et,"CreateWeakMapPolyfill");function ze(T){return T.__=void 0,delete T.__,T}a(ze,"MakeDictionary")})})(hT||(hT={}))});var Ru=S(l0=>{var qd=class extends Error{static{a(this,"CommanderError")}constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},a0=class extends qd{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};l0.CommanderError=qd;l0.InvalidArgumentError=a0});var Wd=S(u0=>{var{InvalidArgumentError:ZN}=Ru(),c0=class{static{a(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new ZN(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function ek(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}a(ek,"humanReadableArgName");u0.Argument=c0;u0.humanReadableArgName=ek});var h0=S(d0=>{var{humanReadableArgName:tk}=Wd(),f0=class{static{a(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>tk(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatItemList(e,t,r){return t.length===0?[]:[r.styleTitle(e),...t,""]}groupItems(e,t,r){let i=new Map;return e.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth??80;function s(d,h){return t.formatItem(d,r,h,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],l=t.commandDescription(e);l.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(l),i),""]));let c=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",c,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,h)=>{let p=d.map(g=>s(t.styleOptionTerm(t.optionTerm(g)),t.styleOptionDescription(t.optionDescription(g))));o=o.concat(this.formatItemList(h,p,t))}),t.showGlobalOptions){let d=t.visibleGlobalOptions(e).map(h=>s(t.styleOptionTerm(t.optionTerm(h)),t.styleOptionDescription(t.optionDescription(h))));o=o.concat(this.formatItemList("Global Options:",d,t))}return this.groupItems(e.commands,t.visibleCommands(e),d=>d.helpGroup()||"Commands:").forEach((d,h)=>{let p=d.map(g=>s(t.styleSubcommandTerm(t.subcommandTerm(g)),t.styleSubcommandDescription(t.subcommandDescription(g))));o=o.concat(this.formatItemList(h,p,t))}),o.join(`
7
7
  `)}displayWidth(e){return pT(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,i){let o=" ".repeat(2);if(!r)return o+e;let l=e.padEnd(t+e.length-i.displayWidth(e)),c=2,f=(this.helpWidth??80)-t-c-2,d;return f<this.minWidthToWrap||i.preformatted(r)?d=r:d=i.boxWrap(r,f).replace(/\n/g,`
8
8
  `+" ".repeat(t+c)),o+l+" ".repeat(c)+d.replace(/\n/g,`
9
9
  ${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return r.forEach(o=>{let l=o.match(i);if(l===null){s.push("");return}let c=[l.shift()],u=this.displayWidth(c[0]);l.forEach(f=>{let d=this.displayWidth(f);if(u+d<=t){c.push(f),u+=d;return}s.push(c.join(""));let h=f.trimStart();c=[h],u=this.displayWidth(h)}),s.push(c.join(""))}),s.join(`
@@ -30,13 +30,13 @@ Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
30
30
  Expecting one of '${r.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let o;typeof t=="function"?o=t({error:s.error,command:s.command}):o=t,o&&s.write(`${o}
31
31
  `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ST(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],i=s[4]),t&&i!=="0"?`${t}=${r}:${parseInt(i)+1}`:e})}a(ST,"incrementNodeInspectorPort");function w0(){if(ft.env.NO_COLOR||ft.env.FORCE_COLOR==="0"||ft.env.FORCE_COLOR==="false")return!1;if(ft.env.FORCE_COLOR||ft.env.CLICOLOR_FORCE!==void 0)return!0}a(w0,"useColor");v0.Command=S0;v0.useColor=w0});var IT=S(Zn=>{var{Argument:vT}=Wd(),{Command:E0}=wT(),{CommanderError:dk,InvalidArgumentError:ET}=Ru(),{Help:hk}=h0(),{Option:TT}=y0();Zn.program=new E0;Zn.createCommand=n=>new E0(n);Zn.createOption=(n,e)=>new TT(n,e);Zn.createArgument=(n,e)=>new vT(n,e);Zn.Command=E0;Zn.Option=TT;Zn.Argument=vT;Zn.Help=hk;Zn.CommanderError=dk;Zn.InvalidArgumentError=ET;Zn.InvalidOptionArgumentError=ET});var Il=S(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});Hd.AssetClass=void 0;var AT;(function(n){n.AREA="ems__Area",n.TASK="ems__Task",n.PROJECT="ems__Project",n.MEETING="ems__Meeting",n.INITIATIVE="ems__Initiative",n.TASK_PROTOTYPE="ems__TaskPrototype",n.MEETING_PROTOTYPE="ems__MeetingPrototype",n.EVENT_PROTOTYPE="exo__EventPrototype",n.PROJECT_PROTOTYPE="ems__ProjectPrototype",n.EVENT="exo__Event",n.DAILY_NOTE="pn__DailyNote",n.CONCEPT="ims__Concept",n.SESSION_START_EVENT="ems__SessionStartEvent",n.SESSION_END_EVENT="ems__SessionEndEvent",n.PROTOTYPE="exo__Prototype",n.CLASS="exo__Class",n.FLEETING_NOTE="ztlk__FleetingNote",n.WORKFLOW="ems__Workflow",n.WORKFLOW_STATE="ems__WorkflowState",n.WORKFLOW_TRANSITION="ems__WorkflowTransition",n.COMMAND="exocmd__Command",n.PRECONDITION="exocmd__Precondition",n.GROUNDING="exocmd__Grounding",n.COMMAND_BINDING="exocmd__CommandBinding"})(AT||(Hd.AssetClass=AT={}))});var xl=S(Qd=>{"use strict";Object.defineProperty(Qd,"__esModule",{value:!0});Qd.EffortStatus=void 0;var RT;(function(n){n.DRAFT="ems__EffortStatusDraft",n.BACKLOG="ems__EffortStatusBacklog",n.ANALYSIS="ems__EffortStatusAnalysis",n.TODO="ems__EffortStatusToDo",n.DOING="ems__EffortStatusDoing",n.DONE="ems__EffortStatusDone",n.TRASHED="ems__EffortStatusTrashed"})(RT||(Qd.EffortStatus=RT={}))});var T0=S(Yd=>{"use strict";Object.defineProperty(Yd,"__esModule",{value:!0});Yd.EFFORT_STATUS_OPTIONS=void 0;Yd.EFFORT_STATUS_OPTIONS=[{value:"[[ems__EffortStatusDraft]]",label:"Draft"},{value:"[[ems__EffortStatusBacklog]]",label:"Backlog"},{value:"[[ems__EffortStatusAnalysis]]",label:"Analysis"},{value:"[[ems__EffortStatusToDo]]",label:"To Do"},{value:"[[ems__EffortStatusDoing]]",label:"Doing"},{value:"[[ems__EffortStatusDone]]",label:"Done"},{value:"[[ems__EffortStatusTrashed]]",label:"Trashed"}]});var Io=S(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});Xd.GroundingType=void 0;var CT;(function(n){n.SPARQL_UPDATE="sparql_update",n.PROPERTY_DELETE="property_delete",n.PROPERTY_SET="property_set",n.COMPOSITE="composite",n.SERVICE_CALL="service_call",n.CREATE_INSTANCE="create_instance",n.PROPERTY_APPEND="property_append",n.PROPERTY_INCREMENT="property_increment",n.PROPERTY_SHIFT="property_shift",n.WORKFLOW_TRANSITION="workflow_transition"})(CT||(Xd.GroundingType=CT={}))});var Cu=S(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.GROUNDING_TYPE_IRI_TO_ENUM=xn.GROUNDING_TYPE_UID_TO_ENUM=xn.GROUNDING_TYPE_UIDS=void 0;xn.resolveGroundingTypeFromIRI=mk;xn.resolveGroundingTypeFromWikilinkLiteral=gk;var Zt=Io();xn.GROUNDING_TYPE_UIDS={[Zt.GroundingType.PROPERTY_SET]:"cf3bb923-f1f1-40be-b728-782844402426",[Zt.GroundingType.PROPERTY_DELETE]:"4bdf1d0b-e9da-4d96-bafe-c5aaef8c2bd5",[Zt.GroundingType.COMPOSITE]:"8f9a57db-3865-4886-92fb-c5ab7f3c3fa3",[Zt.GroundingType.SERVICE_CALL]:"9bf9fc99-ac37-4e51-b9f5-bd920099947c",[Zt.GroundingType.CREATE_INSTANCE]:"4367e2d6-6c92-450a-becb-abce1fb07682",[Zt.GroundingType.PROPERTY_APPEND]:"572f7e69-a8a1-42f6-8113-5aa65cc4b552",[Zt.GroundingType.PROPERTY_INCREMENT]:"afc29f90-45eb-4f94-9fe2-2ce738759161",[Zt.GroundingType.PROPERTY_SHIFT]:"f4e5266f-f3cc-49fd-a5a5-ce1e8b7847a4",[Zt.GroundingType.SPARQL_UPDATE]:"79c3e709-8d1d-4694-bcc6-b9ff07d59b86",[Zt.GroundingType.WORKFLOW_TRANSITION]:"5c1a2552-d576-496d-8823-563573dd1e2f"};xn.GROUNDING_TYPE_UID_TO_ENUM=Object.freeze(Object.fromEntries(Object.entries(xn.GROUNDING_TYPE_UIDS).map(([n,e])=>[e,n])));var rs="https://exocortex.my/ontology/exocmd#";xn.GROUNDING_TYPE_IRI_TO_ENUM=Object.freeze({[`${rs}GroundingTypePropertySet`]:Zt.GroundingType.PROPERTY_SET,[`${rs}GroundingTypePropertyDelete`]:Zt.GroundingType.PROPERTY_DELETE,[`${rs}GroundingTypeComposite`]:Zt.GroundingType.COMPOSITE,[`${rs}GroundingTypeServiceCall`]:Zt.GroundingType.SERVICE_CALL,[`${rs}GroundingTypeCreateInstance`]:Zt.GroundingType.CREATE_INSTANCE,[`${rs}GroundingTypePropertyAppend`]:Zt.GroundingType.PROPERTY_APPEND,[`${rs}GroundingTypePropertyIncrement`]:Zt.GroundingType.PROPERTY_INCREMENT,[`${rs}GroundingTypePropertyShift`]:Zt.GroundingType.PROPERTY_SHIFT,[`${rs}GroundingTypeSparqlUpdate`]:Zt.GroundingType.SPARQL_UPDATE,[`${rs}GroundingTypeWorkflowTransition`]:Zt.GroundingType.WORKFLOW_TRANSITION});var pk=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;function mk(n){let e=xn.GROUNDING_TYPE_IRI_TO_ENUM[n];if(e!==void 0)return e;let t=n.match(pk);return t?xn.GROUNDING_TYPE_UID_TO_ENUM[t[1].toLowerCase()]??null:null}a(mk,"resolveGroundingTypeFromIRI");function gk(n){let e=n.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return e?xn.GROUNDING_TYPE_UID_TO_ENUM[e[1].toLowerCase()]??null:null}a(gk,"resolveGroundingTypeFromWikilinkLiteral")});var I0=S(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.CommandBindingStyleProperty=ei.CommandBindingProperty=ei.GroundingProperty=ei.PreconditionProperty=ei.CommandProperty=void 0;ei.CommandProperty={ICON:"exocmd__Command_icon",PRECONDITION:"exocmd__Command_precondition",GROUNDING:"exocmd__Command_grounding",CONFIRM_MESSAGE:"exocmd__Command_confirmMessage",SUCCESS_MESSAGE:"exocmd__Command_successMessage",CATEGORY:"exocmd__Command_category",OPEN_IN_SAME_TAB:"exocmd__Command_openInSameTab"};ei.PreconditionProperty={SPARQL_ASK:"exocmd__Precondition_sparqlAsk",QUERY:"exocmd__Precondition_query"};ei.GroundingProperty={TYPE:"exocmd__Grounding_type",SPARQL_UPDATE:"exocmd__Grounding_sparqlUpdate",TARGET_PROPERTY:"exocmd__Grounding_targetProperty",STEPS:"exocmd__Grounding_steps",IS_DEFINED_BY:"exocmd__Grounding_isDefinedBy",LABEL_TEMPLATE:"exocmd__Grounding_labelTemplate"};ei.CommandBindingProperty={COMMAND:"exocmd__CommandBinding_command",TARGET_CLASS:"exocmd__CommandBinding_targetClass",TARGET_PROTOTYPE:"exocmd__CommandBinding_targetPrototype",TARGET_ASSET:"exocmd__CommandBinding_targetAsset",POSITION:"exocmd__CommandBinding_position",ORDER:"exocmd__CommandBinding_order",PRECONDITION:"exocmd__CommandBinding_precondition",STYLE:"exocmd__CommandBinding_style",VARIANT:"exocmd__CommandBinding_variant"};ei.CommandBindingStyleProperty={VARIANT:"exocmd__CommandBindingStyle_variant",SHOW_ICON:"exocmd__CommandBindingStyle_showIcon",LABEL_CLASS:"exocmd__CommandBindingStyle_labelClass",ARIA_LABEL:"exocmd__CommandBindingStyle_ariaLabel",TOOLTIP:"exocmd__CommandBindingStyle_tooltip",KEYBOARD_SHORTCUT:"exocmd__CommandBindingStyle_keyboardShortcut",SOURCE:"exocmd__CommandBindingStyle_source"}});var x0=S(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.STYLE_SOURCE_VALUES=An.LABEL_CLASS_VALUES=An.COMMAND_VARIANT_VALUES=void 0;An.isCommandVariant=yk;An.isLabelClass=_k;An.isStyleSource=bk;An.COMMAND_VARIANT_VALUES=Object.freeze(["primary","secondary","success","warning","danger","muted"]);An.LABEL_CLASS_VALUES=Object.freeze(["muted","bold","uppercase","compact"]);An.STYLE_SOURCE_VALUES=Object.freeze(["vendor","user"]);function yk(n){return typeof n=="string"&&An.COMMAND_VARIANT_VALUES.includes(n)}a(yk,"isCommandVariant");function _k(n){return typeof n=="string"&&An.LABEL_CLASS_VALUES.includes(n)}a(_k,"isLabelClass");function bk(n){return typeof n=="string"&&An.STYLE_SOURCE_VALUES.includes(n)}a(bk,"isStyleSource")});var PT=S(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});Al.isCommandFrontmatter=Sk;Al.isPreconditionFrontmatter=wk;Al.isGroundingFrontmatter=vk;Al.isCommandBindingFrontmatter=Ek;function Sk(n){return Kd(n,"exocmd__Command")}a(Sk,"isCommandFrontmatter");function wk(n){return Kd(n,"exocmd__Precondition")}a(wk,"isPreconditionFrontmatter");function vk(n){return Kd(n,"exocmd__Grounding")}a(vk,"isGroundingFrontmatter");function Ek(n){return Kd(n,"exocmd__CommandBinding")}a(Ek,"isCommandBindingFrontmatter");function Kd(n,e){let t=n.exo__Instance_class;if(t==null)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}a(Kd,"hasInstanceClass")});var FT=S(A0=>{"use strict";Object.defineProperty(A0,"__esModule",{value:!0});A0.parseGroundingDefinitionFromFrontmatter=Ik;var Tk=Cu();function OT(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.slice(0,t).trim():e}a(OT,"normalizeGroundingRef");function Ik(n,e,t){let r=e.exocmd__Grounding_type,i=(()=>{if(typeof r!="string")return r;let d=(0,Tk.resolveGroundingTypeFromWikilinkLiteral)(r);if(d!==null)return d;throw new Error(`[exocmd-grounding-type-literal-form] legacy literal-string '${r}' for exocmd__Grounding_type in fixture ${n}. Migrate to wikilink form per RFC 9d20c91f Phase 3.`)})(),s=i==="service_call"?e.exocmd__Grounding_serviceId??e.exocmd__Grounding_targetProperty:e.exocmd__Grounding_targetProperty,o;if(i==="composite"){let d=e.exocmd__Grounding_steps;Array.isArray(d)&&(o=d.map(h=>t(OT(h))))}let l=e.exocmd__Grounding_incrementBy,c;if(l!=null&&l!==""){let d=Number.parseInt(String(l),10);Number.isFinite(d)&&(c=d)}let u=e.exocmd__Grounding_targetValueRef,f=u?OT(u):void 0;return{id:n,label:e.exo__Asset_label??"",type:i,targetProperty:s,targetValueRef:f,targetValueLiteral:e.exocmd__Grounding_targetValueLiteral,targetValueSubstitution:e.exocmd__Grounding_targetValueSubstitution,serviceCallPayload:e.exocmd__Grounding_serviceCallPayload,appendExpression:e.exocmd__Grounding_appendExpression,targetClass:e.exocmd__Grounding_targetClass,targetPrototype:e.exocmd__Grounding_targetPrototype,targetFolder:e.exocmd__Grounding_targetFolder,shiftDelta:e.exocmd__Grounding_shiftDelta,incrementBy:c,linkBackProperty:e.exocmd__Grounding_linkBackProperty,steps:o}}a(Ik,"parseGroundingDefinitionFromFrontmatter")});var DT=S(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});Jd.hasPosition=xk;Jd.isFixed=Ak;function xk(n){return typeof n.x=="number"&&typeof n.y=="number"}a(xk,"hasPosition");function Ak(n){return n.fx!==null&&n.fx!==void 0&&n.fy!==null&&n.fy!==void 0}a(Ak,"isFixed")});var LT=S(Zd=>{"use strict";Object.defineProperty(Zd,"__esModule",{value:!0});Zd.createEmptyGraphData=Rk;Zd.mergeGraphData=Ck;function Rk(){return{nodes:[],edges:[],lastUpdated:Date.now(),version:0}}a(Rk,"createEmptyGraphData");function Ck(n,e){let t=new Map,r=new Set,i=[];for(let s of n.nodes)t.set(s.id,s);for(let s of e.nodes)t.set(s.id,s);for(let s of n.edges){let o=`${s.source}->${s.target}:${s.type}`;r.has(o)||(r.add(o),i.push(s))}for(let s of e.edges){let o=`${s.source}->${s.target}:${s.type}`;r.has(o)||(r.add(o),i.push(s))}return{nodes:Array.from(t.values()),edges:i,lastUpdated:Date.now(),version:Math.max(n.version??0,e.version??0)+1}}a(Ck,"mergeGraphData")});var R0=S(eh=>{"use strict";Object.defineProperty(eh,"__esModule",{value:!0});eh.createEdgeId=Pk;eh.edgesEqual=Ok;function Pk(n,e,t,r){let i=r?`|${r}`:"";return`${n}->${e}:${t}${i}`}a(Pk,"createEdgeId");function Ok(n,e){return n.source===e.source&&n.target===e.target&&n.type===e.type&&n.predicate===e.predicate}a(Ok,"edgesEqual")});var C0=S(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.BUILT_IN_EDGE_STYLES=Gt.BUILT_IN_NODE_STYLES=Gt.DEFAULT_EDGE_STYLE=Gt.DEFAULT_NODE_STYLE=Gt.RDF_TYPE_PREDICATES=void 0;Gt.mergeNodeStyles=Fk;Gt.mergeEdgeStyles=Dk;Gt.extractLocalName=Lk;Gt.isClassType=Nk;Gt.isTypePredicate=kk;Gt.isSubClassPredicate=Mk;Gt.RDF_TYPE_PREDICATES={RDF_TYPE:"http://www.w3.org/1999/02/22-rdf-syntax-ns#type",RDFS_CLASS:"http://www.w3.org/2000/01/rdf-schema#Class",OWL_CLASS:"http://www.w3.org/2002/07/owl#Class",RDFS_SUBCLASS_OF:"http://www.w3.org/2000/01/rdf-schema#subClassOf",OWL_EQUIVALENT_CLASS:"http://www.w3.org/2002/07/owl#equivalentClass",RDFS_LABEL:"http://www.w3.org/2000/01/rdf-schema#label",RDFS_COMMENT:"http://www.w3.org/2000/01/rdf-schema#comment"};Gt.DEFAULT_NODE_STYLE={color:"#6366f1",borderColor:"#4f46e5",borderWidth:2,size:30,shape:"circle",icon:"",opacity:1,shadow:!1,animation:"none"};Gt.DEFAULT_EDGE_STYLE={color:"#9ca3af",width:1,lineStyle:"solid",arrow:"standard",curvature:0,opacity:.6,showLabel:!1,labelPosition:.5};Gt.BUILT_IN_NODE_STYLES={"http://www.w3.org/2000/01/rdf-schema#Class":{color:"#f59e0b",shape:"diamond",size:40},"http://www.w3.org/2002/07/owl#Class":{color:"#f59e0b",shape:"diamond",size:40},ems__Task:{color:"#22c55e",shape:"circle"},ems__Project:{color:"#3b82f6",shape:"square"},ems__Area:{color:"#8b5cf6",shape:"hexagon",size:40},ems__Meeting:{color:"#ec4899",shape:"circle"},exo__Class:{color:"#f59e0b",shape:"diamond"},ims__Person:{color:"#06b6d4",shape:"circle"}};Gt.BUILT_IN_EDGE_STYLES={"http://www.w3.org/1999/02/22-rdf-syntax-ns#type":{color:"#f59e0b",lineStyle:"dashed",arrow:"standard"},"http://www.w3.org/2000/01/rdf-schema#subClassOf":{color:"#8b5cf6",width:2,arrow:"triangle"},"https://exocortex.my/ontology/ems#Effort_parent":{color:"#6366f1",width:2,arrow:"standard"},"https://exocortex.my/ontology/exo#Asset_prototype":{color:"#f59e0b",lineStyle:"dashed",arrow:"circle"},"https://exocortex.my/ontology/exo#references":{color:"#22c55e",opacity:.4,arrow:"standard"}};function Fk(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(Fk,"mergeNodeStyles");function Dk(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(Dk,"mergeEdgeStyles");function Lk(n){let e=n.lastIndexOf("#"),t=n.lastIndexOf("/"),r=Math.max(e,t);return r>=0?n.substring(r+1):n}a(Lk,"extractLocalName");function Nk(n){return n===Gt.RDF_TYPE_PREDICATES.RDFS_CLASS||n===Gt.RDF_TYPE_PREDICATES.OWL_CLASS}a(Nk,"isClassType");function kk(n){return n===Gt.RDF_TYPE_PREDICATES.RDF_TYPE}a(kk,"isTypePredicate");function Mk(n){return n===Gt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF}a(Mk,"isSubClassPredicate")});var kT=S(NT=>{"use strict";Object.defineProperty(NT,"__esModule",{value:!0})});var Ae=S(th=>{"use strict";Object.defineProperty(th,"__esModule",{value:!0});th.IRI=void 0;var P0=class n{static{a(this,"IRI")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("IRI cannot be empty");if(!n.isValidIRI(t))throw new Error("Invalid IRI format");this._value=t}get value(){return this._value}equals(e){return this._value===e._value}toString(){return this._value}static isValidIRI(e){if(!e||e.trim().length===0||/\s/.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=["http","https","ftp","ftps","file","mailto","tel","data","ws","wss","urn","obsidian"],i=e.match(/^([a-z][a-z0-9+.-]*?):/i);if(i){let s=i[1].toLowerCase();if(!r.includes(s))return!1}try{return new URL(e),!0}catch{return/^urn:[a-z0-9][a-z0-9-]{0,31}:[^\s]+$/i.test(e)}}};th.IRI=P0});var $e=S(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.Literal=void 0;Ea.parseLanguageTag=MT;Ea.createDirectionalLiteral=$k;Ea.createLiteralFromLanguageTag=Uk;var jk="http://www.w3.org/2001/XMLSchema#string",Pu=class{static{a(this,"Literal")}constructor(e,t,r,i){if(e.length===0)throw new Error("Literal value cannot be empty");if(t&&r)throw new Error("Literal cannot have both datatype and language tag");if(i&&!r)throw new Error("Literal cannot have direction without language tag");if(i&&i!=="ltr"&&i!=="rtl")throw new Error('Direction must be "ltr" or "rtl"');this._value=e,this._datatype=t,this._language=r?r.toLowerCase():void 0,this._direction=i}get value(){return this._value}get datatype(){return this._datatype}get language(){return this._language}get direction(){return this._direction}hasDirection(){return this._direction!==void 0}equals(e){if(this._value!==e._value||this._language!==e._language||this._direction!==e._direction)return!1;let t=this.normalizedDatatype(),r=e.normalizedDatatype();return t===r}normalizedDatatype(){return!this._datatype||this._datatype.value===jk?null:this._datatype.value}toString(){let e=`"${this._value}"`;return this._datatype?e+=`^^<${this._datatype.value}>`:this._language&&(e+=`@${this._language}`,this._direction&&(e+=`--${this._direction}`)),e}};Ea.Literal=Pu;function MT(n){let t=n.lastIndexOf("--");if(t===-1)return{language:n.toLowerCase()};let r=n.substring(t+2),i=n.substring(0,t);return r==="ltr"||r==="rtl"?{language:i.toLowerCase(),direction:r}:{language:n.toLowerCase()}}a(MT,"parseLanguageTag");function $k(n,e,t){return new Pu(n,void 0,e,t)}a($k,"createDirectionalLiteral");function Uk(n,e){let{language:t,direction:r}=MT(e);return new Pu(n,void 0,t,r)}a(Uk,"createLiteralFromLanguageTag")});var $t=S(nh=>{"use strict";Object.defineProperty(nh,"__esModule",{value:!0});nh.BlankNode=void 0;var rh=class n{static{a(this,"BlankNode")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("BlankNode id cannot be empty");this._id=t}get id(){return this._id}equals(e){return this._id===e._id}toString(){return`_:${this._id}`}static generateId(){return`b${++n.counter}`}static create(){return new n(n.generateId())}};nh.BlankNode=rh;rh.counter=0});var er=S(ih=>{"use strict";Object.defineProperty(ih,"__esModule",{value:!0});ih.Namespace=void 0;var jT=Ae(),qe=class n{static{a(this,"Namespace")}constructor(e,t){if(e.trim().length===0)throw new Error("Namespace prefix cannot be empty");this._prefix=e,this._iri=new jT.IRI(t)}get prefix(){return this._prefix}get iri(){return this._iri}term(e){return new jT.IRI(`${this._iri.value}${e}`)}expand(e){let t=e.split(":");if(t.length!==2)return null;let[r,i]=t;return r!==this._prefix?null:this.term(i)}static forPrefix(e){if(!/^[a-z][a-zA-Z0-9]*$/.test(e))return null;let t=n.KNOWN_NAMESPACES.find(r=>r.prefix===e);return t||new n(e,`${n.EXOCORTEX_ONTOLOGY_BASE}${e}#`)}static fromPropertyKey(e){let t=/^([a-z][a-zA-Z0-9]*)__(.+)$/.exec(e);if(!t)return null;let r=n.forPrefix(t[1]);return r?{namespace:r,localName:t[2]}:null}};ih.Namespace=qe;qe.RDF=new qe("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");qe.RDFS=new qe("rdfs","http://www.w3.org/2000/01/rdf-schema#");qe.OWL=new qe("owl","http://www.w3.org/2002/07/owl#");qe.XSD=new qe("xsd","http://www.w3.org/2001/XMLSchema#");qe.EXO=new qe("exo","https://exocortex.my/ontology/exo#");qe.EMS=new qe("ems","https://exocortex.my/ontology/ems#");qe.EXOCMD=new qe("exocmd","https://exocortex.my/ontology/exocmd#");qe.IMS=new qe("ims","https://exocortex.my/ontology/ims#");qe.ZTLK=new qe("ztlk","https://exocortex.my/ontology/ztlk#");qe.PTMS=new qe("ptms","https://exocortex.my/ontology/ptms#");qe.LIT=new qe("lit","https://exocortex.my/ontology/lit#");qe.INBOX=new qe("inbox","https://exocortex.my/ontology/inbox#");qe.PMBOK=new qe("pmbok","https://exocortex.my/ontology/pmbok#");qe.EXOCORTEX_ONTOLOGY_BASE="https://exocortex.my/ontology/";qe.KNOWN_NAMESPACES=[qe.EXO,qe.EMS,qe.EXOCMD,qe.IMS,qe.ZTLK,qe.PTMS,qe.LIT,qe.INBOX,qe.PMBOK]});var Bn=S(sh=>{"use strict";Object.defineProperty(sh,"__esModule",{value:!0});sh.Triple=void 0;var O0=Ae(),F0=$e(),D0=$t(),L0=class{static{a(this,"Triple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof O0.IRI&&t instanceof O0.IRI||e instanceof D0.BlankNode&&t instanceof D0.BlankNode||e instanceof F0.Literal&&t instanceof F0.Literal||this.isQuotedTriple(e)&&this.isQuotedTriple(t)?e.equals(t):!1}isQuotedTriple(e){return typeof e=="object"&&e!==null&&"termType"in e&&e.termType==="QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`${e} ${t} ${r} .`}nodeToString(e){return e instanceof O0.IRI?`<${e.value}>`:e instanceof D0.BlankNode||e instanceof F0.Literal||this.isQuotedTriple(e)?e.toString():""}};sh.Triple=L0});var Ou=S(oh=>{"use strict";Object.defineProperty(oh,"__esModule",{value:!0});oh.QuotedTriple=void 0;var N0=Ae(),k0=$e(),M0=$t(),j0=class n{static{a(this,"QuotedTriple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof N0.IRI&&t instanceof N0.IRI||e instanceof M0.BlankNode&&t instanceof M0.BlankNode||e instanceof k0.Literal&&t instanceof k0.Literal||e instanceof n&&t instanceof n?e.equals(t):!1}get termType(){return"QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`<< ${e} ${t} ${r} >>`}nodeToString(e){return e instanceof N0.IRI?`<${e.value}>`:e instanceof M0.BlankNode||e instanceof k0.Literal||e instanceof n?e.toString():""}};oh.QuotedTriple=j0});var $T=S(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.QuotedTriple=tr.Triple=tr.Namespace=tr.BlankNode=tr.createLiteralFromLanguageTag=tr.createDirectionalLiteral=tr.parseLanguageTag=tr.Literal=tr.IRI=void 0;var Vk=Ae();Object.defineProperty(tr,"IRI",{enumerable:!0,get:a(function(){return Vk.IRI},"get")});var ah=$e();Object.defineProperty(tr,"Literal",{enumerable:!0,get:a(function(){return ah.Literal},"get")});Object.defineProperty(tr,"parseLanguageTag",{enumerable:!0,get:a(function(){return ah.parseLanguageTag},"get")});Object.defineProperty(tr,"createDirectionalLiteral",{enumerable:!0,get:a(function(){return ah.createDirectionalLiteral},"get")});Object.defineProperty(tr,"createLiteralFromLanguageTag",{enumerable:!0,get:a(function(){return ah.createLiteralFromLanguageTag},"get")});var Bk=$t();Object.defineProperty(tr,"BlankNode",{enumerable:!0,get:a(function(){return Bk.BlankNode},"get")});var Gk=er();Object.defineProperty(tr,"Namespace",{enumerable:!0,get:a(function(){return Gk.Namespace},"get")});var qk=Bn();Object.defineProperty(tr,"Triple",{enumerable:!0,get:a(function(){return qk.Triple},"get")});var Wk=Ou();Object.defineProperty(tr,"QuotedTriple",{enumerable:!0,get:a(function(){return Wk.QuotedTriple},"get")})});var lh=S(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.UUID_URL_NAMESPACE=ri.DEFAULT_LANGUAGE_TAG=ri.REQUIRED_PROPERTIES=ri.ALLOWED_PROPERTIES=ri.Exo003MetadataType=void 0;var ti;(function(n){n.Namespace="namespace",n.Anchor="anchor",n.BlankNode="blank_node",n.Statement="statement",n.Body="body"})(ti||(ri.Exo003MetadataType=ti={}));ri.ALLOWED_PROPERTIES={[ti.Namespace]:["metadata","uri","aliases"],[ti.Anchor]:["metadata","uri","aliases"],[ti.BlankNode]:["metadata","uri","aliases"],[ti.Statement]:["metadata","subject","predicate","object","aliases"],[ti.Body]:["metadata","subject","predicate","aliases"]};ri.REQUIRED_PROPERTIES={[ti.Namespace]:["metadata","uri"],[ti.Anchor]:["metadata","uri"],[ti.BlankNode]:["metadata","uri"],[ti.Statement]:["metadata","subject","predicate","object"],[ti.Body]:["metadata","subject","predicate"]};ri.DEFAULT_LANGUAGE_TAG="ru";ri.UUID_URL_NAMESPACE="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});var UT=S($0=>{"use strict";Object.defineProperty($0,"__esModule",{value:!0});$0.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var VT=S(U0=>{"use strict";Object.defineProperty(U0,"__esModule",{value:!0});U0.default="00000000-0000-0000-0000-000000000000"});var BT=S(V0=>{"use strict";Object.defineProperty(V0,"__esModule",{value:!0});V0.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i});var Fu=S(B0=>{"use strict";Object.defineProperty(B0,"__esModule",{value:!0});var zk=BT();function Hk(n){return typeof n=="string"&&zk.default.test(n)}a(Hk,"validate");B0.default=Hk});var Du=S(G0=>{"use strict";Object.defineProperty(G0,"__esModule",{value:!0});var Qk=Fu();function Yk(n){if(!(0,Qk.default)(n))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(n.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(n.slice(9,13),16))>>>8,e&255,(e=parseInt(n.slice(14,18),16))>>>8,e&255,(e=parseInt(n.slice(19,23),16))>>>8,e&255,(e=parseInt(n.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}a(Yk,"parse");G0.default=Yk});var js=S(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.unsafeStringify=void 0;var Xk=Fu(),Dr=[];for(let n=0;n<256;++n)Dr.push((n+256).toString(16).slice(1));function GT(n,e=0){return(Dr[n[e+0]]+Dr[n[e+1]]+Dr[n[e+2]]+Dr[n[e+3]]+"-"+Dr[n[e+4]]+Dr[n[e+5]]+"-"+Dr[n[e+6]]+Dr[n[e+7]]+"-"+Dr[n[e+8]]+Dr[n[e+9]]+"-"+Dr[n[e+10]]+Dr[n[e+11]]+Dr[n[e+12]]+Dr[n[e+13]]+Dr[n[e+14]]+Dr[n[e+15]]).toLowerCase()}a(GT,"unsafeStringify");Lu.unsafeStringify=GT;function Kk(n,e=0){let t=GT(n,e);if(!(0,Xk.default)(t))throw TypeError("Stringified UUID is invalid");return t}a(Kk,"stringify");Lu.default=Kk});var fh=S(q0=>{"use strict";Object.defineProperty(q0,"__esModule",{value:!0});var Jk=require("crypto"),uh=new Uint8Array(256),ch=uh.length;function Zk(){return ch>uh.length-16&&((0,Jk.randomFillSync)(uh),ch=0),uh.slice(ch,ch+=16)}a(Zk,"rng");q0.default=Zk});var W0=S(ku=>{"use strict";Object.defineProperty(ku,"__esModule",{value:!0});ku.updateV1State=void 0;var qT=fh(),e4=js(),Nu={};function t4(n,e,t){let r,i=n?._v6??!1;if(n){let s=Object.keys(n);s.length===1&&s[0]==="_v6"&&(n=void 0)}if(n)r=WT(n.random??n.rng?.()??(0,qT.default)(),n.msecs,n.nsecs,n.clockseq,n.node,e,t);else{let s=Date.now(),o=(0,qT.default)();zT(Nu,s,o),r=WT(o,Nu.msecs,Nu.nsecs,i?void 0:Nu.clockseq,i?void 0:Nu.node,e,t)}return e??(0,e4.unsafeStringify)(r)}a(t4,"v1");function zT(n,e,t){return n.msecs??=-1/0,n.nsecs??=0,e===n.msecs?(n.nsecs++,n.nsecs>=1e4&&(n.node=void 0,n.nsecs=0)):e>n.msecs?n.nsecs=0:e<n.msecs&&(n.node=void 0),n.node||(n.node=t.slice(10,16),n.node[0]|=1,n.clockseq=(t[8]<<8|t[9])&16383),n.msecs=e,n}a(zT,"updateV1State");ku.updateV1State=zT;function WT(n,e,t,r,i,s,o=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!s)s=new Uint8Array(16),o=0;else if(o<0||o+16>s.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);e??=Date.now(),t??=0,r??=(n[8]<<8|n[9])&16383,i??=n.slice(10,16),e+=122192928e5;let l=((e&268435455)*1e4+t)%4294967296;s[o++]=l>>>24&255,s[o++]=l>>>16&255,s[o++]=l>>>8&255,s[o++]=l&255;let c=e/4294967296*1e4&268435455;s[o++]=c>>>8&255,s[o++]=c&255,s[o++]=c>>>24&15|16,s[o++]=c>>>16&255,s[o++]=r>>>8|128,s[o++]=r&255;for(let u=0;u<6;++u)s[o++]=i[u];return s}a(WT,"v1Bytes");ku.default=t4});var H0=S(z0=>{"use strict";Object.defineProperty(z0,"__esModule",{value:!0});var r4=Du(),n4=js();function i4(n){let e=typeof n=="string"?(0,r4.default)(n):n,t=s4(e);return typeof n=="string"?(0,n4.unsafeStringify)(t):t}a(i4,"v1ToV6");z0.default=i4;function s4(n){return Uint8Array.of((n[6]&15)<<4|n[7]>>4&15,(n[7]&15)<<4|(n[4]&240)>>4,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,(n[1]&15)<<4|(n[2]&240)>>4,96|n[2]&15,n[3],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}a(s4,"_v1ToV6")});var HT=S(Q0=>{"use strict";Object.defineProperty(Q0,"__esModule",{value:!0});var o4=require("crypto");function a4(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,o4.createHash)("md5").update(n).digest()}a(a4,"md5");Q0.default=a4});var Mu=S($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});$s.URL=$s.DNS=$s.stringToBytes=void 0;var QT=Du(),l4=js();function YT(n){n=unescape(encodeURIComponent(n));let e=new Uint8Array(n.length);for(let t=0;t<n.length;++t)e[t]=n.charCodeAt(t);return e}a(YT,"stringToBytes");$s.stringToBytes=YT;$s.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";$s.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function c4(n,e,t,r,i,s){let o=typeof t=="string"?YT(t):t,l=typeof r=="string"?(0,QT.default)(r):r;if(typeof r=="string"&&(r=(0,QT.default)(r)),r?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(l),c.set(o,l.length),c=e(c),c[6]=c[6]&15|n,c[8]=c[8]&63|128,i){s=s||0;for(let u=0;u<16;++u)i[s+u]=c[u];return i}return(0,l4.unsafeStringify)(c)}a(c4,"v35");$s.default=c4});var KT=S(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.URL=Ta.DNS=void 0;var u4=HT(),Y0=Mu(),XT=Mu();Object.defineProperty(Ta,"DNS",{enumerable:!0,get:a(function(){return XT.DNS},"get")});Object.defineProperty(Ta,"URL",{enumerable:!0,get:a(function(){return XT.URL},"get")});function X0(n,e,t,r){return(0,Y0.default)(48,u4.default,n,e,t,r)}a(X0,"v3");X0.DNS=Y0.DNS;X0.URL=Y0.URL;Ta.default=X0});var JT=S(K0=>{"use strict";Object.defineProperty(K0,"__esModule",{value:!0});var f4=require("crypto");K0.default={randomUUID:f4.randomUUID}});var eI=S(J0=>{"use strict";Object.defineProperty(J0,"__esModule",{value:!0});var ZT=JT(),d4=fh(),h4=js();function p4(n,e,t){if(ZT.default.randomUUID&&!e&&!n)return ZT.default.randomUUID();n=n||{};let r=n.random??n.rng?.()??(0,d4.default)();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=r[i];return e}return(0,h4.unsafeStringify)(r)}a(p4,"v4");J0.default=p4});var tI=S(Z0=>{"use strict";Object.defineProperty(Z0,"__esModule",{value:!0});var m4=require("crypto");function g4(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,m4.createHash)("sha1").update(n).digest()}a(g4,"sha1");Z0.default=g4});var nI=S(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.URL=Ia.DNS=void 0;var y4=tI(),e_=Mu(),rI=Mu();Object.defineProperty(Ia,"DNS",{enumerable:!0,get:a(function(){return rI.DNS},"get")});Object.defineProperty(Ia,"URL",{enumerable:!0,get:a(function(){return rI.URL},"get")});function t_(n,e,t,r){return(0,e_.default)(80,y4.default,n,e,t,r)}a(t_,"v5");t_.DNS=e_.DNS;t_.URL=e_.URL;Ia.default=t_});var iI=S(r_=>{"use strict";Object.defineProperty(r_,"__esModule",{value:!0});var _4=js(),b4=W0(),S4=H0();function w4(n,e,t){n??={},t??=0;let r=(0,b4.default)({...n,_v6:!0},new Uint8Array(16));if(r=(0,S4.default)(r),e){for(let i=0;i<16;i++)e[t+i]=r[i];return e}return(0,_4.unsafeStringify)(r)}a(w4,"v6");r_.default=w4});var sI=S(n_=>{"use strict";Object.defineProperty(n_,"__esModule",{value:!0});var v4=Du(),E4=js();function T4(n){let e=typeof n=="string"?(0,v4.default)(n):n,t=I4(e);return typeof n=="string"?(0,E4.unsafeStringify)(t):t}a(T4,"v6ToV1");n_.default=T4;function I4(n){return Uint8Array.of((n[3]&15)<<4|n[4]>>4&15,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|n[6]&15,n[7],(n[1]&15)<<4|(n[2]&240)>>4,(n[2]&15)<<4|(n[3]&240)>>4,16|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}a(I4,"_v6ToV1")});var cI=S(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});ju.updateV7State=void 0;var oI=fh(),x4=js(),i_={};function A4(n,e,t){let r;if(n)r=aI(n.random??n.rng?.()??(0,oI.default)(),n.msecs,n.seq,e,t);else{let i=Date.now(),s=(0,oI.default)();lI(i_,i,s),r=aI(s,i_.msecs,i_.seq,e,t)}return e??(0,x4.unsafeStringify)(r)}a(A4,"v7");function lI(n,e,t){return n.msecs??=-1/0,n.seq??=0,e>n.msecs?(n.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],n.msecs=e):(n.seq=n.seq+1|0,n.seq===0&&n.msecs++),n}a(lI,"updateV7State");ju.updateV7State=lI;function aI(n,e,t,r,i=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return e??=Date.now(),t??=n[6]*127<<24|n[7]<<16|n[8]<<8|n[9],r[i++]=e/1099511627776&255,r[i++]=e/4294967296&255,r[i++]=e/16777216&255,r[i++]=e/65536&255,r[i++]=e/256&255,r[i++]=e&255,r[i++]=112|t>>>28&15,r[i++]=t>>>20&255,r[i++]=128|t>>>14&63,r[i++]=t>>>6&255,r[i++]=t<<2&255|n[10]&3,r[i++]=n[11],r[i++]=n[12],r[i++]=n[13],r[i++]=n[14],r[i++]=n[15],r}a(aI,"v7Bytes");ju.default=A4});var uI=S(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});var R4=Fu();function C4(n){if(!(0,R4.default)(n))throw TypeError("Invalid UUID");return parseInt(n.slice(14,15),16)}a(C4,"version");s_.default=C4});var mi=S(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.version=dt.validate=dt.v7=dt.v6ToV1=dt.v6=dt.v5=dt.v4=dt.v3=dt.v1ToV6=dt.v1=dt.stringify=dt.parse=dt.NIL=dt.MAX=void 0;var P4=UT();Object.defineProperty(dt,"MAX",{enumerable:!0,get:a(function(){return P4.default},"get")});var O4=VT();Object.defineProperty(dt,"NIL",{enumerable:!0,get:a(function(){return O4.default},"get")});var F4=Du();Object.defineProperty(dt,"parse",{enumerable:!0,get:a(function(){return F4.default},"get")});var D4=js();Object.defineProperty(dt,"stringify",{enumerable:!0,get:a(function(){return D4.default},"get")});var L4=W0();Object.defineProperty(dt,"v1",{enumerable:!0,get:a(function(){return L4.default},"get")});var N4=H0();Object.defineProperty(dt,"v1ToV6",{enumerable:!0,get:a(function(){return N4.default},"get")});var k4=KT();Object.defineProperty(dt,"v3",{enumerable:!0,get:a(function(){return k4.default},"get")});var M4=eI();Object.defineProperty(dt,"v4",{enumerable:!0,get:a(function(){return M4.default},"get")});var j4=nI();Object.defineProperty(dt,"v5",{enumerable:!0,get:a(function(){return j4.default},"get")});var $4=iI();Object.defineProperty(dt,"v6",{enumerable:!0,get:a(function(){return $4.default},"get")});var U4=sI();Object.defineProperty(dt,"v6ToV1",{enumerable:!0,get:a(function(){return U4.default},"get")});var V4=cI();Object.defineProperty(dt,"v7",{enumerable:!0,get:a(function(){return V4.default},"get")});var B4=Fu();Object.defineProperty(dt,"validate",{enumerable:!0,get:a(function(){return B4.default},"get")});var G4=uI();Object.defineProperty(dt,"version",{enumerable:!0,get:a(function(){return G4.default},"get")})});var l_=S(dh=>{"use strict";Object.defineProperty(dh,"__esModule",{value:!0});dh.Exo003UUIDGenerator=void 0;var o_=mi(),fI=lh(),a_=class{static{a(this,"Exo003UUIDGenerator")}static generateNamespaceUUID(e){if(!e||e.trim().length===0)throw new Error("Namespace URI cannot be empty");return(0,o_.v5)(e,fI.UUID_URL_NAMESPACE)}static generateAssetUUID(e,t){if(!t||t.trim().length===0)throw new Error("Local identifier cannot be empty");let r=this.generateNamespaceUUID(e);return(0,o_.v5)(t,r)}static generateFromIRI(e){if(!e||e.trim().length===0)throw new Error("IRI cannot be empty");let{namespace:t,localName:r}=this.splitIRI(e);return r?this.generateAssetUUID(t,r):(0,o_.v5)(e,fI.UUID_URL_NAMESPACE)}static generateBlankNodeUUID(e,t){if(!e||e.trim().length===0)throw new Error("Blank node ID cannot be empty");let r="urn:exocortex:blank-node:",i=t?`${t}#${e}`:e;return this.generateAssetUUID(r,i)}static generateStatementUUID(e,t,r){if(!e||!t||!r)throw new Error("Subject, predicate, and object cannot be empty");let i="urn:exocortex:statement:",s=`${e} ${t} ${r}`;return this.generateAssetUUID(i,s)}static generateBodyUUID(e,t){let r="urn:exocortex:body:",i=e;return t?.datatype?i+=`^^${t.datatype}`:t?.language&&(i+=`@${t.language}`,t.direction&&(i+=`--${t.direction}`)),this.generateAssetUUID(r,i)}static splitIRI(e){let t=e.lastIndexOf("#");if(t!==-1&&t<e.length-1)return{namespace:e.substring(0,t+1),localName:e.substring(t+1)};let r=e.lastIndexOf("/"),i=e.indexOf("://");return r!==-1&&r>i+2&&r<e.length-1?{namespace:e.substring(0,r+1),localName:e.substring(r+1)}:{namespace:e,localName:""}}static isValidUUID(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)}};dh.Exo003UUIDGenerator=a_});var hI=S(ph=>{"use strict";Object.defineProperty(ph,"__esModule",{value:!0});ph.Exo003Parser=void 0;var gt=lh(),$u=l_(),xo=Ae(),hh=$e(),dI=$t(),q4=Bn(),c_=class{static{a(this,"Exo003Parser")}static parse(e,t){let r=this.validate(e);if(!r.valid)return{success:!1,errors:r.errors};let i=e.metadata;try{return{success:!0,metadata:this.parseByType(e,i),bodyContent:i===gt.Exo003MetadataType.Body?t:void 0}}catch(s){return{success:!1,errors:[s instanceof Error?s.message:String(s)]}}}static validate(e){let t=[],r=[];if(!e.metadata)return t.push("Missing required property: metadata"),{valid:!1,errors:t,warnings:r};let i=e.metadata;if(!Object.values(gt.Exo003MetadataType).includes(i))return t.push(`Invalid metadata: ${i}. Valid types: ${Object.values(gt.Exo003MetadataType).join(", ")}`),{valid:!1,errors:t,warnings:r};let s=i,o=gt.ALLOWED_PROPERTIES[s],l=gt.REQUIRED_PROPERTIES[s];for(let c of l)(e[c]===void 0||e[c]===null)&&t.push(`Missing required property: ${c}`);for(let c of Object.keys(e))o.includes(c)||t.push(`Forbidden property for ${s}: ${c}`);switch(s){case gt.Exo003MetadataType.Namespace:this.validateNamespaceMetadata(e,t);break;case gt.Exo003MetadataType.Anchor:this.validateAnchorMetadata(e,t);break;case gt.Exo003MetadataType.BlankNode:this.validateBlankNodeMetadata(e,t);break;case gt.Exo003MetadataType.Statement:this.validateStatementMetadata(e,t);break;case gt.Exo003MetadataType.Body:this.validateBodyMetadata(e,t,r);break}return{valid:t.length===0,errors:t,warnings:r}}static parseByType(e,t){let r={metadata:t,aliases:e.aliases};switch(t){case gt.Exo003MetadataType.Namespace:return{...r,metadata:gt.Exo003MetadataType.Namespace,uri:e.uri};case gt.Exo003MetadataType.Anchor:return{...r,metadata:gt.Exo003MetadataType.Anchor,uri:e.uri};case gt.Exo003MetadataType.BlankNode:return{...r,metadata:gt.Exo003MetadataType.BlankNode,uri:e.uri};case gt.Exo003MetadataType.Statement:return{...r,metadata:gt.Exo003MetadataType.Statement,subject:e.subject,predicate:e.predicate,object:e.object};case gt.Exo003MetadataType.Body:return{...r,metadata:gt.Exo003MetadataType.Body,subject:e.subject,predicate:e.predicate}}}static validateNamespaceMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new xo.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateAnchorMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new xo.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateBlankNodeMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r){let i=r;if(!i.startsWith("_:"))try{new xo.IRI(i)}catch{t.push(`uri is not a valid IRI or blank node identifier: ${String(r)}`)}}}static validateStatementMetadata(e,t){let r=e.subject,i=e.predicate,s=e.object,o=[["subject",r],["predicate",i],["object",s]];for(let[l,c]of o)c&&typeof c!="string"&&t.push(`${l} must be a string`)}static validateBodyMetadata(e,t,r){let i=e.subject,s=e.predicate;i&&typeof i!="string"&&t.push("subject must be a string"),s&&typeof s!="string"&&t.push("predicate must be a string")}static toTriple(e,t,r){let i=t(e.subject),s;if(i.type==="iri")s=new xo.IRI(i.value);else if(i.type==="blank")s=new dI.BlankNode(i.value);else throw new Error("Statement subject cannot be a literal");let o=t(e.predicate);if(o.type!=="iri")throw new Error("Statement predicate must be an IRI");let l=new xo.IRI(o.value),c=t(e.object),u;if(c.type==="iri")u=new xo.IRI(c.value);else if(c.type==="blank")u=new dI.BlankNode(c.value);else{let f=r||c.value;if(c.datatype)u=new hh.Literal(f,new xo.IRI(c.datatype));else{let d=c.language||gt.DEFAULT_LANGUAGE_TAG;u=(0,hh.createDirectionalLiteral)(f,d,c.direction)}}return new q4.Triple(s,l,u)}static toLiteral(e,t,r){if(r?.datatype)return new hh.Literal(t,new xo.IRI(r.datatype));let i=r?.language||gt.DEFAULT_LANGUAGE_TAG;return(0,hh.createDirectionalLiteral)(t,i,r?.direction)}static isExo003Format(e){let t=e.metadata;return typeof t=="string"&&Object.values(gt.Exo003MetadataType).includes(t)}static generateUUID(e,t){switch(e.metadata){case gt.Exo003MetadataType.Namespace:return $u.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case gt.Exo003MetadataType.Anchor:return $u.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case gt.Exo003MetadataType.BlankNode:return $u.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case gt.Exo003MetadataType.Statement:{let r=e;return $u.Exo003UUIDGenerator.generateStatementUUID(r.subject,r.predicate,r.object)}case gt.Exo003MetadataType.Body:{let r=e;return $u.Exo003UUIDGenerator.generateBodyUUID(r.subject+"|"+r.predicate)}}}};ph.Exo003Parser=c_});var u_=S(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});qr.Exo003Parser=qr.Exo003UUIDGenerator=qr.UUID_URL_NAMESPACE=qr.DEFAULT_LANGUAGE_TAG=qr.REQUIRED_PROPERTIES=qr.ALLOWED_PROPERTIES=qr.Exo003MetadataType=void 0;var Uu=lh();Object.defineProperty(qr,"Exo003MetadataType",{enumerable:!0,get:a(function(){return Uu.Exo003MetadataType},"get")});Object.defineProperty(qr,"ALLOWED_PROPERTIES",{enumerable:!0,get:a(function(){return Uu.ALLOWED_PROPERTIES},"get")});Object.defineProperty(qr,"REQUIRED_PROPERTIES",{enumerable:!0,get:a(function(){return Uu.REQUIRED_PROPERTIES},"get")});Object.defineProperty(qr,"DEFAULT_LANGUAGE_TAG",{enumerable:!0,get:a(function(){return Uu.DEFAULT_LANGUAGE_TAG},"get")});Object.defineProperty(qr,"UUID_URL_NAMESPACE",{enumerable:!0,get:a(function(){return Uu.UUID_URL_NAMESPACE},"get")});var W4=l_();Object.defineProperty(qr,"Exo003UUIDGenerator",{enumerable:!0,get:a(function(){return W4.Exo003UUIDGenerator},"get")});var z4=hI();Object.defineProperty(qr,"Exo003Parser",{enumerable:!0,get:a(function(){return z4.Exo003Parser},"get")})});var Us=S(mh=>{"use strict";Object.defineProperty(mh,"__esModule",{value:!0});mh.WikiLinkHelpers=void 0;var Vu=class{static{a(this,"WikiLinkHelpers")}static normalize(e){if(!e)return"";let t=e.replace(this.WIKI_LINK_PATTERN,"").trim();if(!t)return"";let r=t.indexOf("|");if(r===-1)return t;let i=t.substring(0,r).trim(),s=t.substring(r+1).trim();return this.UUID_PATTERN.test(i)&&s||i}static normalizeArray(e){return e?(Array.isArray(e)?e:[e]).map(r=>this.normalize(r)).filter(r=>r.length>0):[]}static equals(e,t){return this.normalize(e)===this.normalize(t)}static includes(e,t){let r=this.normalizeArray(e),i=this.normalize(t);return r.includes(i)}static resolveSymbolic(e,t){let r=this.normalize(e);if(!r)return"";if(this.UUID_PATTERN.test(r)){let i=t(r);return i&&i.length>0?i:r}return r}static resolveSymbolicArray(e,t){return e?(Array.isArray(e)?e:[e]).map(i=>this.resolveSymbolic(i,t)).filter(i=>i.length>0):[]}};mh.WikiLinkHelpers=Vu;Vu.WIKI_LINK_PATTERN=/\[\[|\]\]/g;Vu.UUID_PATTERN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});var Ao=S(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.CommandBindingProperty=yt.GroundingProperty=yt.PreconditionProperty=yt.CommandProperty=yt.resolveGroundingTypeFromWikilinkLiteral=yt.resolveGroundingTypeFromIRI=yt.GROUNDING_TYPE_IRI_TO_ENUM=yt.GROUNDING_TYPE_UID_TO_ENUM=yt.GROUNDING_TYPE_UIDS=yt.GroundingType=yt.EFFORT_STATUS_OPTIONS=yt.EffortStatus=yt.AssetClass=void 0;var H4=Il();Object.defineProperty(yt,"AssetClass",{enumerable:!0,get:a(function(){return H4.AssetClass},"get")});var Q4=xl();Object.defineProperty(yt,"EffortStatus",{enumerable:!0,get:a(function(){return Q4.EffortStatus},"get")});var Y4=T0();Object.defineProperty(yt,"EFFORT_STATUS_OPTIONS",{enumerable:!0,get:a(function(){return Y4.EFFORT_STATUS_OPTIONS},"get")});var X4=Io();Object.defineProperty(yt,"GroundingType",{enumerable:!0,get:a(function(){return X4.GroundingType},"get")});var Bu=Cu();Object.defineProperty(yt,"GROUNDING_TYPE_UIDS",{enumerable:!0,get:a(function(){return Bu.GROUNDING_TYPE_UIDS},"get")});Object.defineProperty(yt,"GROUNDING_TYPE_UID_TO_ENUM",{enumerable:!0,get:a(function(){return Bu.GROUNDING_TYPE_UID_TO_ENUM},"get")});Object.defineProperty(yt,"GROUNDING_TYPE_IRI_TO_ENUM",{enumerable:!0,get:a(function(){return Bu.GROUNDING_TYPE_IRI_TO_ENUM},"get")});Object.defineProperty(yt,"resolveGroundingTypeFromIRI",{enumerable:!0,get:a(function(){return Bu.resolveGroundingTypeFromIRI},"get")});Object.defineProperty(yt,"resolveGroundingTypeFromWikilinkLiteral",{enumerable:!0,get:a(function(){return Bu.resolveGroundingTypeFromWikilinkLiteral},"get")});var gh=I0();Object.defineProperty(yt,"CommandProperty",{enumerable:!0,get:a(function(){return gh.CommandProperty},"get")});Object.defineProperty(yt,"PreconditionProperty",{enumerable:!0,get:a(function(){return gh.PreconditionProperty},"get")});Object.defineProperty(yt,"GroundingProperty",{enumerable:!0,get:a(function(){return gh.GroundingProperty},"get")});Object.defineProperty(yt,"CommandBindingProperty",{enumerable:!0,get:a(function(){return gh.CommandBindingProperty},"get")})});var yI=S(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.hasClass=Aa;Wr.isAreaOrProject=K4;Wr.isEffort=J4;Wr.hasStatus=Z4;Wr.isAssetArchived=eM;Wr.hasEmptyProperties=tM;Wr.needsFolderRepair=rM;Wr.getTodayDateString=f_;Wr.isPlannedForToday=nM;Wr.hasPlannedStartTimestamp=iM;Wr.extractDailyNoteDate=sM;Wr.isCurrentDateGteDay=oM;Wr.inheritsFromPrototype=gI;Wr.isPrototypeClass=lM;var mI=Us(),xa=Ao();function Aa(n,e){return n?(Array.isArray(n)?n:[n]).some(r=>mI.WikiLinkHelpers.normalize(r)===e):!1}a(Aa,"hasClass");function K4(n){return Aa(n,xa.AssetClass.AREA)||Aa(n,xa.AssetClass.PROJECT)}a(K4,"isAreaOrProject");function J4(n){return Aa(n,xa.AssetClass.TASK)||Aa(n,xa.AssetClass.PROJECT)||Aa(n,xa.AssetClass.MEETING)}a(J4,"isEffort");function Z4(n,e){if(!n)return!1;let t=Array.isArray(n)?n[0]:n;return t?mI.WikiLinkHelpers.normalize(t)===e:!1}a(Z4,"hasStatus");function eM(n){if(n===!0||n===1)return!0;if(typeof n=="string"){let e=n.toLowerCase();return e==="true"||e==="yes"}return!1}a(eM,"isAssetArchived");function tM(n){return!n||Object.keys(n).length===0?!1:Object.values(n).some(e=>!!(e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0))}a(tM,"hasEmptyProperties");function rM(n,e){if(!e)return!1;let t=n.replace(/\/$/,""),r=e.replace(/\/$/,"");return t!==r}a(rM,"needsFolderRepair");function f_(){let n=new Date,e=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0");return`${e}-${t}-${r}`}a(f_,"getTodayDateString");function nM(n){let e=n.ems__Effort_plannedStartTimestamp;if(!e)return!1;let t=f_();return typeof e=="string"?e.split("T")[0]===t:Array.isArray(e)&&e.length>0?String(e[0]).split("T")[0]===t:!1}a(nM,"isPlannedForToday");function iM(n){let e=n.ems__Effort_plannedStartTimestamp;return e?typeof e=="string"?e.trim().length>0:Array.isArray(e)&&e.length>0?String(e[0]).trim().length>0:!1:!1}a(iM,"hasPlannedStartTimestamp");function sM(n){let e=n.pn__DailyNote_day;if(!e)return null;if(typeof e=="string"){let t=e.match(/\[\[([^\[\]]+)\]\]/);return t?t[1]:e}if(Array.isArray(e)&&e.length>0){let t=String(e[0]),r=t.match(/\[\[([^\[\]]+)\]\]/);return r?r[1]:t}return null}a(sM,"extractDailyNoteDate");function oM(n){return f_()>=n}a(oM,"isCurrentDateGteDay");function pI(n){return n?n.replace(/^["']|["']$/g,"").replace(/\[\[|\]\]/g,"").trim():""}a(pI,"normalizeWithQuotes");var aM=10;function gI(n,e=aM){let t=n.exo__Class_superClass;if(!t)return!1;let r=new Set,i=[],s=Array.isArray(t)?t:[t];for(let o of s){let l=pI(o);l&&i.push({className:l,depth:0})}for(;i.length>0;){let o=i.shift();if(!o)continue;let{className:l,depth:c}=o;if(c>e)continue;if(l===xa.AssetClass.PROTOTYPE)return!0;if(r.has(l))continue;r.add(l);let u=`${l}__exo__Class_superClass`,f=n[u];if(f){let d=Array.isArray(f)?f:[f];for(let h of d){let p=pI(h);p&&!r.has(p)&&i.push({className:p,depth:c+1})}}}return!1}a(gI,"inheritsFromPrototype");function lM(n,e){return Aa(n,xa.AssetClass.CLASS)?gI(e):!1}a(lM,"isPrototypeClass")});var _I=S(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.isPrototypeClass=ht.inheritsFromPrototype=ht.isCurrentDateGteDay=ht.extractDailyNoteDate=ht.hasPlannedStartTimestamp=ht.isPlannedForToday=ht.getTodayDateString=ht.needsFolderRepair=ht.hasEmptyProperties=ht.isAssetArchived=ht.hasStatus=ht.isEffort=ht.isAreaOrProject=ht.hasClass=void 0;var Rn=yI();Object.defineProperty(ht,"hasClass",{enumerable:!0,get:a(function(){return Rn.hasClass},"get")});Object.defineProperty(ht,"isAreaOrProject",{enumerable:!0,get:a(function(){return Rn.isAreaOrProject},"get")});Object.defineProperty(ht,"isEffort",{enumerable:!0,get:a(function(){return Rn.isEffort},"get")});Object.defineProperty(ht,"hasStatus",{enumerable:!0,get:a(function(){return Rn.hasStatus},"get")});Object.defineProperty(ht,"isAssetArchived",{enumerable:!0,get:a(function(){return Rn.isAssetArchived},"get")});Object.defineProperty(ht,"hasEmptyProperties",{enumerable:!0,get:a(function(){return Rn.hasEmptyProperties},"get")});Object.defineProperty(ht,"needsFolderRepair",{enumerable:!0,get:a(function(){return Rn.needsFolderRepair},"get")});Object.defineProperty(ht,"getTodayDateString",{enumerable:!0,get:a(function(){return Rn.getTodayDateString},"get")});Object.defineProperty(ht,"isPlannedForToday",{enumerable:!0,get:a(function(){return Rn.isPlannedForToday},"get")});Object.defineProperty(ht,"hasPlannedStartTimestamp",{enumerable:!0,get:a(function(){return Rn.hasPlannedStartTimestamp},"get")});Object.defineProperty(ht,"extractDailyNoteDate",{enumerable:!0,get:a(function(){return Rn.extractDailyNoteDate},"get")});Object.defineProperty(ht,"isCurrentDateGteDay",{enumerable:!0,get:a(function(){return Rn.isCurrentDateGteDay},"get")});Object.defineProperty(ht,"inheritsFromPrototype",{enumerable:!0,get:a(function(){return Rn.inheritsFromPrototype},"get")});Object.defineProperty(ht,"isPrototypeClass",{enumerable:!0,get:a(function(){return Rn.isPrototypeClass},"get")})});var yh=S(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});Gu.PropertyFieldType=void 0;Gu.rangeToFieldType=fM;var Lr;(function(n){n.Text="text",n.Number="number",n.Date="date",n.DateTime="datetime",n.Boolean="boolean",n.Reference="reference",n.Enum="enum",n.StatusSelect="status-select",n.SizeSelect="size-select",n.Wikilink="wikilink",n.Timestamp="timestamp",n.Unknown="unknown"})(Lr||(Gu.PropertyFieldType=Lr={}));var bI="http://www.w3.org/2001/XMLSchema#",cM="https://exocortex.my/ontology/exo#",uM="https://exocortex.my/ontology/ems#";function fM(n){if(!n)return Lr.Unknown;let e=n.trim();if(!e)return Lr.Unknown;if(e.startsWith(bI)){let t=e.substring(bI.length);return d_(t)}if(e.startsWith("xsd:")){let t=e.substring(4);return d_(t)}if(e.includes("XMLSchema#")){let t=e.indexOf("XMLSchema#"),r=e.substring(t+10);return d_(r)}return e.startsWith(uM)||e.startsWith("ems:")?dM(e):e.startsWith(cM)||e.startsWith("exo:")||hM(e)?Lr.Reference:Lr.Text}a(fM,"rangeToFieldType");function d_(n){switch(n.toLowerCase()){case"string":case"normalizedstring":case"token":case"language":case"nmtoken":case"name":case"ncname":case"anyuri":return Lr.Text;case"integer":case"int":case"long":case"short":case"byte":case"nonnegativeinteger":case"positiveinteger":case"nonpositiveinteger":case"negativeinteger":case"unsignedlong":case"unsignedint":case"unsignedshort":case"unsignedbyte":case"decimal":case"float":case"double":return Lr.Number;case"date":return Lr.Date;case"datetime":case"datetimestamp":return Lr.DateTime;case"boolean":return Lr.Boolean;case"time":return Lr.Timestamp;default:return Lr.Text}}a(d_,"xsdTypeToFieldType");function dM(n){let e=n.toLowerCase();return e.includes("effortstatus")?Lr.StatusSelect:e.includes("tasksize")?Lr.SizeSelect:Lr.Reference}a(dM,"emsTypeToFieldType");function hM(n){let e=n.toLowerCase();return e.includes("exocortex.my/ontology")?!0:["asset","task","project","area","effort","class","property","concept"].some(r=>e.includes(r))}a(hM,"isClassReference")});var h_=S(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});qu.propertyNameToUri=pM;qu.uriToPropertyName=SI;qu.extractPropertyLabel=mM;function pM(n){return n.replace(/^([a-z]+)__/,"$1:")}a(pM,"propertyNameToUri");function SI(n){if(n.startsWith("http://")||n.startsWith("https://")){let e=n.match(/\/([a-z]+)#([A-Za-z0-9_]+)$/);if(e)return`${e[1]}__${e[2]}`;let t=n.lastIndexOf("#"),r=n.lastIndexOf("/"),i=Math.max(t,r);return i>=0?n.substring(i+1):n}return n.replace(/^([a-z]+):/,"$1__")}a(SI,"uriToPropertyName");function mM(n){let r=(n.includes(":")?SI(n):n).replace(/^[a-z]+__/,"").split("_");return(r.length>1?r.slice(1).join(" "):r[0]).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,s=>s.toUpperCase())}a(mM,"extractPropertyLabel")});var _h={};s0(_h,{__assign:()=>m_,__asyncDelegator:()=>RM,__asyncGenerator:()=>AM,__asyncValues:()=>CM,__await:()=>Wu,__awaiter:()=>wM,__classPrivateFieldGet:()=>DM,__classPrivateFieldSet:()=>LM,__createBinding:()=>EM,__decorate:()=>_M,__exportStar:()=>TM,__extends:()=>gM,__generator:()=>vM,__importDefault:()=>FM,__importStar:()=>OM,__makeTemplateObject:()=>PM,__metadata:()=>SM,__param:()=>bM,__read:()=>wI,__rest:()=>yM,__spread:()=>IM,__spreadArrays:()=>xM,__values:()=>g_});function gM(n,e){p_(n,e);function t(){this.constructor=n}a(t,"__"),n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function yM(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function _M(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function bM(n,e){return function(t,r){e(t,r,n)}}function SM(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function wM(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return a(i,"adopt"),new(t||(t=Promise))(function(s,o){function l(f){try{u(r.next(f))}catch(d){o(d)}}a(l,"fulfilled");function c(f){try{u(r.throw(f))}catch(d){o(d)}}a(c,"rejected");function u(f){f.done?s(f.value):i(f.value).then(l,c)}a(u,"step"),u((r=r.apply(n,e||[])).next())})}function vM(n,e){var t={label:0,sent:a(function(){if(s[0]&1)throw s[1];return s[1]},"sent"),trys:[],ops:[]},r,i,s,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(u){return function(f){return c([u,f])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;t;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){t.label=u[1];break}if(u[0]===6&&t.label<s[1]){t.label=s[1],s=u;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(u);break}s[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(n,t)}catch(f){u=[6,f],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function EM(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}function TM(n,e){for(var t in n)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=n[t])}function g_(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:a(function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}},"next")};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function wI(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return s}function IM(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(wI(arguments[e]));return n}function xM(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),i=0,e=0;e<t;e++)for(var s=arguments[e],o=0,l=s.length;o<l;o++,i++)r[i]=s[o];return r}function Wu(n){return this instanceof Wu?(this.v=n,this):new Wu(n)}function AM(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(h){r[h]&&(i[h]=function(p){return new Promise(function(g,_){s.push([h,p,g,_])>1||l(h,p)})})}function l(h,p){try{c(r[h](p))}catch(g){d(s[0][3],g)}}function c(h){h.value instanceof Wu?Promise.resolve(h.value.v).then(u,f):d(s[0][2],h)}function u(h){l("next",h)}function f(h){l("throw",h)}function d(h,p){h(p),s.shift(),s.length&&l(s[0][0],s[0][1])}}function RM(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:Wu(n[i](o)),done:i==="return"}:s?s(o):o}:s}}function CM(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof g_=="function"?g_(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(l,c){o=n[s](o),i(l,c,o.done,o.value)})}}function i(s,o,l,c){Promise.resolve(c).then(function(u){s({value:u,done:l})},o)}}function PM(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function OM(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)Object.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function FM(n){return n&&n.__esModule?n:{default:n}}function DM(n,e){if(!e.has(n))throw new TypeError("attempted to get private field on non-instance");return e.get(n)}function LM(n,e,t){if(!e.has(n))throw new TypeError("attempted to set private field on non-instance");return e.set(n,t),t}var p_,m_,bh=JN(()=>{p_=a(function(n,e){return p_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])},p_(n,e)},"extendStatics");a(gM,"__extends");m_=a(function(){return m_=Object.assign||a(function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},"__assign"),m_.apply(this,arguments)},"__assign");a(yM,"__rest");a(_M,"__decorate");a(bM,"__param");a(SM,"__metadata");a(wM,"__awaiter");a(vM,"__generator");a(EM,"__createBinding");a(TM,"__exportStar");a(g_,"__values");a(wI,"__read");a(IM,"__spread");a(xM,"__spreadArrays");a(Wu,"__await");a(AM,"__asyncGenerator");a(RM,"__asyncDelegator");a(CM,"__asyncValues");a(PM,"__makeTemplateObject");a(OM,"__importStar");a(FM,"__importDefault");a(DM,"__classPrivateFieldGet");a(LM,"__classPrivateFieldSet")});var b_=S(__=>{"use strict";Object.defineProperty(__,"__esModule",{value:!0});var y_;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(y_||(y_={}));__.default=y_});var vI=S(S_=>{"use strict";Object.defineProperty(S_,"__esModule",{value:!0});var NM=b_();Object.defineProperty(S_,"Lifecycle",{enumerable:!0,get:a(function(){return NM.default},"get")})});var Ra=S(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.defineInjectionTokenMetadata=gi.getParamInfo=gi.INJECTION_TOKEN_METADATA_KEY=void 0;gi.INJECTION_TOKEN_METADATA_KEY="injectionTokens";function kM(n){let e=Reflect.getMetadata("design:paramtypes",n)||[],t=Reflect.getOwnMetadata(gi.INJECTION_TOKEN_METADATA_KEY,n)||{};return Object.keys(t).forEach(r=>{e[+r]=t[r]}),e}a(kM,"getParamInfo");gi.getParamInfo=kM;function MM(n,e){return function(t,r,i){let s=Reflect.getOwnMetadata(gi.INJECTION_TOKEN_METADATA_KEY,t)||{};s[i]=e?{token:n,transform:e.transformToken,transformArgs:e.args||[]}:n,Reflect.defineMetadata(gi.INJECTION_TOKEN_METADATA_KEY,s,t)}}a(MM,"defineInjectionTokenMetadata");gi.defineInjectionTokenMetadata=MM});var w_=S(Sh=>{"use strict";Object.defineProperty(Sh,"__esModule",{value:!0});Sh.isClassProvider=void 0;function jM(n){return!!n.useClass}a(jM,"isClassProvider");Sh.isClassProvider=jM});var v_=S(wh=>{"use strict";Object.defineProperty(wh,"__esModule",{value:!0});wh.isFactoryProvider=void 0;function $M(n){return!!n.useFactory}a($M,"isFactoryProvider");wh.isFactoryProvider=$M});var Eh=S(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.delay=Rl.DelayedConstructor=void 0;var vh=class{static{a(this,"DelayedConstructor")}constructor(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}createProxy(e){let t={},r=!1,i,s=a(()=>(r||(i=e(this.wrap()),r=!0),i),"delayedObject");return new Proxy(t,this.createHandler(s))}createHandler(e){let t={},r=a(i=>{t[i]=(...s)=>{s[0]=e();let o=Reflect[i];return o(...s)}},"install");return this.reflectMethods.forEach(r),t}};Rl.DelayedConstructor=vh;function UM(n){if(typeof n>"u")throw new Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new vh(n)}a(UM,"delay");Rl.delay=UM});var Th=S(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});ns.isConstructorToken=ns.isTransformDescriptor=ns.isTokenDescriptor=ns.isNormalToken=void 0;var VM=Eh();function BM(n){return typeof n=="string"||typeof n=="symbol"}a(BM,"isNormalToken");ns.isNormalToken=BM;function GM(n){return typeof n=="object"&&"token"in n&&"multiple"in n}a(GM,"isTokenDescriptor");ns.isTokenDescriptor=GM;function qM(n){return typeof n=="object"&&"token"in n&&"transform"in n}a(qM,"isTransformDescriptor");ns.isTransformDescriptor=qM;function WM(n){return typeof n=="function"||n instanceof VM.DelayedConstructor}a(WM,"isConstructorToken");ns.isConstructorToken=WM});var E_=S(Ih=>{"use strict";Object.defineProperty(Ih,"__esModule",{value:!0});Ih.isTokenProvider=void 0;function zM(n){return!!n.useToken}a(zM,"isTokenProvider");Ih.isTokenProvider=zM});var T_=S(xh=>{"use strict";Object.defineProperty(xh,"__esModule",{value:!0});xh.isValueProvider=void 0;function HM(n){return n.useValue!=null}a(HM,"isValueProvider");xh.isValueProvider=HM});var I_=S(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});var QM=w_();Object.defineProperty(Ca,"isClassProvider",{enumerable:!0,get:a(function(){return QM.isClassProvider},"get")});var YM=v_();Object.defineProperty(Ca,"isFactoryProvider",{enumerable:!0,get:a(function(){return YM.isFactoryProvider},"get")});var XM=Th();Object.defineProperty(Ca,"isNormalToken",{enumerable:!0,get:a(function(){return XM.isNormalToken},"get")});var KM=E_();Object.defineProperty(Ca,"isTokenProvider",{enumerable:!0,get:a(function(){return KM.isTokenProvider},"get")});var JM=T_();Object.defineProperty(Ca,"isValueProvider",{enumerable:!0,get:a(function(){return JM.isValueProvider},"get")})});var EI=S(Ah=>{"use strict";Object.defineProperty(Ah,"__esModule",{value:!0});Ah.isProvider=void 0;var ZM=w_(),ej=T_(),tj=E_(),rj=v_();function nj(n){return ZM.isClassProvider(n)||ej.isValueProvider(n)||tj.isTokenProvider(n)||rj.isFactoryProvider(n)}a(nj,"isProvider");Ah.isProvider=nj});var R_=S(A_=>{"use strict";Object.defineProperty(A_,"__esModule",{value:!0});var x_=class{static{a(this,"RegistryBase")}constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let t=this._registryMap.get(e);return t[t.length-1]||null}set(e,t){this.ensure(e),this._registryMap.get(e).push(t)}setAll(e,t){this._registryMap.set(e,t)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}};A_.default=x_});var TI=S(P_=>{"use strict";Object.defineProperty(P_,"__esModule",{value:!0});var ij=R_(),C_=class extends ij.default{static{a(this,"Registry")}};P_.default=C_});var II=S(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});var O_=class{static{a(this,"ResolutionContext")}constructor(){this.scopedResolutions=new Map}};F_.default=O_});var D_=S(Rh=>{"use strict";Object.defineProperty(Rh,"__esModule",{value:!0});Rh.formatErrorCtor=void 0;function sj(n,e){return n===null?`at position #${e}`:`"${n.split(",")[e].trim()}" at position #${e}`}a(sj,"formatDependency");function oj(n,e,t=" "){return[n,...e.message.split(`
32
32
  `).map(r=>t+r)].join(`
33
- `)}a(oj,"composeErrorMessage");function aj(n,e,t){let[,r=null]=n.toString().match(/constructor\(([\w, ]+)\)/)||[],i=sj(r,e);return oj(`Cannot inject the dependency ${i} of "${n.name}" constructor. Reason:`,t)}a(aj,"formatErrorCtor");Rh.formatErrorCtor=aj});var xI=S(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});Ch.isDisposable=void 0;function lj(n){return!(typeof n.dispose!="function"||n.dispose.length>0)}a(lj,"isDisposable");Ch.isDisposable=lj});var RI=S(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.PostResolutionInterceptors=Pa.PreResolutionInterceptors=void 0;var AI=R_(),Ph=class extends AI.default{static{a(this,"PreResolutionInterceptors")}};Pa.PreResolutionInterceptors=Ph;var Oh=class extends AI.default{static{a(this,"PostResolutionInterceptors")}};Pa.PostResolutionInterceptors=Oh;var L_=class{static{a(this,"Interceptors")}constructor(){this.preResolution=new Ph,this.postResolution=new Oh}};Pa.default=L_});var Ro=S(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.instance=Vs.typeInfo=void 0;var cj=(bh(),Gd(_h)),cn=I_(),uj=EI(),Fh=Th(),fj=TI(),Cn=b_(),Dh=II(),dj=D_(),hj=Eh(),pj=xI(),mj=RI();Vs.typeInfo=new Map;var N_=class n{static{a(this,"InternalDependencyContainer")}constructor(e){this.parent=e,this._registry=new fj.default,this.interceptors=new mj.default,this.disposed=!1,this.disposables=new Set}register(e,t,r={lifecycle:Cn.default.Transient}){this.ensureNotDisposed();let i;if(uj.isProvider(t)?i=t:i={useClass:t},cn.isTokenProvider(i)){let s=[e],o=i;for(;o!=null;){let l=o.useToken;if(s.includes(l))throw new Error(`Token registration cycle detected! ${[...s,l].join(" -> ")}`);s.push(l);let c=this._registry.get(l);c&&cn.isTokenProvider(c.provider)?o=c.provider:o=null}}if((r.lifecycle===Cn.default.Singleton||r.lifecycle==Cn.default.ContainerScoped||r.lifecycle==Cn.default.ResolutionScoped)&&(cn.isValueProvider(i)||cn.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Cn.default[r.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:r}),this}registerType(e,t){return this.ensureNotDisposed(),cn.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),cn.isNormalToken(e)){if(cn.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:Cn.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Cn.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let r=e;return t&&!cn.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:Cn.default.Singleton})}resolve(e,t=new Dh.default,r=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&cn.isNormalToken(e)){if(r)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(Fh.isConstructorToken(e)){let s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let r=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&r.push(i),i.callback(e,t);this.interceptors.preResolution.setAll(e,r)}}executePostResolutionInterceptor(e,t,r){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,t,r);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Cn.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===Cn.default.Singleton,i=e.options.lifecycle===Cn.default.ContainerScoped,s=r||i,o;return cn.isValueProvider(e.provider)?o=e.provider.useValue:cn.isTokenProvider(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):cn.isClassProvider(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):cn.isFactoryProvider(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===Cn.default.ResolutionScoped&&t.scopedResolutions.set(e,o),o}resolveAll(e,t=new Dh.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&cn.isNormalToken(e)){if(r)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let o=i.map(l=>this.resolveRegistration(l,t));return this.executePostResolutionInterceptor(e,o,"All"),o}let s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(r=>!cn.isValueProvider(r.provider)).map(r=>(r.instance=void 0,r)))}createChildContainer(){this.ensureNotDisposed();let e=new n(this);for(let[t,r]of this._registry.entries())r.some(({options:i})=>i.lifecycle===Cn.default.ContainerScoped)&&e._registry.setAll(t,r.map(i=>i.options.lifecycle===Cn.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,t,r={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:t,options:r})}afterResolution(e,t,r={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:t,options:r})}dispose(){return cj.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let r=t.dispose();r&&e.push(r)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,t){if(e instanceof hj.DelayedConstructor)return e.createProxy(i=>this.resolve(i,t));let r=(()=>{let i=Vs.typeInfo.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error(`TypeInfo not known for "${e.name}"`)}let s=i.map(this.resolveParams(t,e));return new e(...s)})();return pj.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(r,i)=>{try{return Fh.isTokenDescriptor(r)?Fh.isTransformDescriptor(r)?r.multiple?this.resolve(r.transform).transform(this.resolveAll(r.token,new Dh.default,r.isOptional),...r.transformArgs):this.resolve(r.transform).transform(this.resolve(r.token,e,r.isOptional),...r.transformArgs):r.multiple?this.resolveAll(r.token,new Dh.default,r.isOptional):this.resolve(r.token,e,r.isOptional):Fh.isTransformDescriptor(r)?this.resolve(r.transform,e).transform(this.resolve(r.token,e),...r.transformArgs):this.resolve(r,e)}catch(s){throw new Error(dj.formatErrorCtor(t,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};Vs.instance=new N_;Vs.default=Vs.instance});var CI=S(M_=>{"use strict";Object.defineProperty(M_,"__esModule",{value:!0});var gj=Ra(),Bs=Ro(),k_=Th(),yj=D_();function _j(){return function(n){let e=gj.getParamInfo(n);return class extends n{constructor(...t){super(...t.concat(e.slice(t.length).map((r,i)=>{try{return k_.isTokenDescriptor(r)?k_.isTransformDescriptor(r)?r.multiple?Bs.instance.resolve(r.transform).transform(Bs.instance.resolveAll(r.token),...r.transformArgs):Bs.instance.resolve(r.transform).transform(Bs.instance.resolve(r.token),...r.transformArgs):r.multiple?Bs.instance.resolveAll(r.token):Bs.instance.resolve(r.token):k_.isTransformDescriptor(r)?Bs.instance.resolve(r.transform).transform(Bs.instance.resolve(r.token),...r.transformArgs):Bs.instance.resolve(r)}catch(s){let o=i+t.length;throw new Error(yj.formatErrorCtor(n,o,s))}})))}}}}a(_j,"autoInjectable");M_.default=_j});var PI=S(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var bj=Ra();function Sj(n,e){let t={token:n,multiple:!1,isOptional:e&&e.isOptional};return bj.defineInjectionTokenMetadata(t)}a(Sj,"inject");j_.default=Sj});var Lh=S($_=>{"use strict";Object.defineProperty($_,"__esModule",{value:!0});var wj=Ra(),vj=Ro(),OI=Ro();function Ej(n){return function(e){vj.typeInfo.set(e,wj.getParamInfo(e)),n&&n.token&&(Array.isArray(n.token)?n.token.forEach(t=>{OI.instance.register(t,e)}):OI.instance.register(n.token,e))}}a(Ej,"injectable");$_.default=Ej});var FI=S(U_=>{"use strict";Object.defineProperty(U_,"__esModule",{value:!0});var Tj=(bh(),Gd(_h)),Ij=Ro();function xj(n=[]){return function(e){return n.forEach(t=>{var{token:r,options:i}=t,s=Tj.__rest(t,["token","options"]);return Ij.instance.register(r,s,i)}),e}}a(xj,"registry");U_.default=xj});var DI=S(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var Aj=Lh(),Rj=Ro();function Cj(){return function(n){Aj.default()(n),Rj.instance.registerSingleton(n)}}a(Cj,"singleton");V_.default=Cj});var LI=S(B_=>{"use strict";Object.defineProperty(B_,"__esModule",{value:!0});var Pj=Ra();function Oj(n,e){let t={token:n,multiple:!0,isOptional:e&&e.isOptional};return Pj.defineInjectionTokenMetadata(t)}a(Oj,"injectAll");B_.default=Oj});var NI=S(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});var Fj=Ra();function Dj(n,e,...t){let r={token:n,multiple:!0,transform:e,transformArgs:t};return Fj.defineInjectionTokenMetadata(r)}a(Dj,"injectAllWithTransform");G_.default=Dj});var kI=S(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var Lj=Ra();function Nj(n,e,...t){return Lj.defineInjectionTokenMetadata(n,{transformToken:e,args:t})}a(Nj,"injectWithTransform");q_.default=Nj});var MI=S(W_=>{"use strict";Object.defineProperty(W_,"__esModule",{value:!0});var kj=Lh(),Mj=Ro();function jj(n,e){return function(t){kj.default()(t),Mj.instance.register(e||t,t,{lifecycle:n})}}a(jj,"scoped");W_.default=jj});var jI=S(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});var $j=CI();Object.defineProperty(yi,"autoInjectable",{enumerable:!0,get:a(function(){return $j.default},"get")});var Uj=PI();Object.defineProperty(yi,"inject",{enumerable:!0,get:a(function(){return Uj.default},"get")});var Vj=Lh();Object.defineProperty(yi,"injectable",{enumerable:!0,get:a(function(){return Vj.default},"get")});var Bj=FI();Object.defineProperty(yi,"registry",{enumerable:!0,get:a(function(){return Bj.default},"get")});var Gj=DI();Object.defineProperty(yi,"singleton",{enumerable:!0,get:a(function(){return Gj.default},"get")});var qj=LI();Object.defineProperty(yi,"injectAll",{enumerable:!0,get:a(function(){return qj.default},"get")});var Wj=NI();Object.defineProperty(yi,"injectAllWithTransform",{enumerable:!0,get:a(function(){return Wj.default},"get")});var zj=kI();Object.defineProperty(yi,"injectWithTransform",{enumerable:!0,get:a(function(){return zj.default},"get")});var Hj=MI();Object.defineProperty(yi,"scoped",{enumerable:!0,get:a(function(){return Hj.default},"get")})});var $I=S(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});function Qj(n){let e;return t=>(e==null&&(e=n(t)),e)}a(Qj,"instanceCachingFactory");z_.default=Qj});var UI=S(H_=>{"use strict";Object.defineProperty(H_,"__esModule",{value:!0});function Yj(n){let e=new WeakMap;return t=>{let r=e.get(t);return r==null&&(r=n(t),e.set(t,r)),r}}a(Yj,"instancePerContainerCachingFactory");H_.default=Yj});var VI=S(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});function Xj(n,e,t,r=!0){let i,s;return o=>{let l=n(o);return(!r||s!==l)&&((s=l)?i=o.resolve(e):i=o.resolve(t)),i}}a(Xj,"predicateAwareClassFactory");Q_.default=Xj});var BI=S(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var Kj=$I();Object.defineProperty(zu,"instanceCachingFactory",{enumerable:!0,get:a(function(){return Kj.default},"get")});var Jj=UI();Object.defineProperty(zu,"instancePerContainerCachingFactory",{enumerable:!0,get:a(function(){return Jj.default},"get")});var Zj=VI();Object.defineProperty(zu,"predicateAwareClassFactory",{enumerable:!0,get:a(function(){return Zj.default},"get")})});var Oe=S(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});var Y_=(bh(),Gd(_h));if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var e9=vI();Object.defineProperty(Co,"Lifecycle",{enumerable:!0,get:a(function(){return e9.Lifecycle},"get")});Y_.__exportStar(jI(),Co);Y_.__exportStar(BI(),Co);Y_.__exportStar(I_(),Co);var t9=Eh();Object.defineProperty(Co,"delay",{enumerable:!0,get:a(function(){return t9.delay},"get")});var r9=Ro();Object.defineProperty(Co,"container",{enumerable:!0,get:a(function(){return r9.instance},"get")})});var Cl=S(Nh=>{"use strict";Object.defineProperty(Nh,"__esModule",{value:!0});Nh.NullLogger=void 0;Nh.NullLogger={debug(){},info(){},warn(){},error(){}}});var GI=S(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.registerUniversalDefaultLoader=n9;Po.clearUniversalDefaultLoader=i9;Po.clearUniversalDefault=s9;Po.loadUniversalDefault=o9;Po.mergePropertyDefaults=a9;Po.mergeInheritanceRules=l9;var kh=null,Gs,Hu=!1;function n9(n){kh=n,Gs=void 0,Hu=!1}a(n9,"registerUniversalDefaultLoader");function i9(){kh=null,Gs=void 0,Hu=!1}a(i9,"clearUniversalDefaultLoader");function s9(){Gs=void 0,Hu=!1}a(s9,"clearUniversalDefault");async function o9(){if(Gs!==void 0)return Gs;if(!kh)return Gs=null,null;try{Gs=await kh()??null}catch(n){Hu||(console.warn("[UniversalDefaultTemplateResolver] loader threw, falling back to legacy primitives:",n),Hu=!0),Gs=null}return Gs}a(o9,"loadUniversalDefault");function a9(n,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.propertyName);o?(r.push(o),i.add(o.propertyName)):r.push(s)}for(let s of e)i.has(s.propertyName)||r.push(s);return r}a(a9,"mergePropertyDefaults");function l9(n,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.targetPropertyName);o?(r.push(o),i.add(o.targetPropertyName)):r.push(s)}for(let s of e)i.has(s.targetPropertyName)||r.push(s);return r}a(l9,"mergeInheritanceRules")});var X_=S((Jne,qI)=>{var Pl=class{static{a(this,"Wildcard")}constructor(){return c9||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(Pl.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(Pl.prototype,"termType",{enumerable:!0,value:"Wildcard"});var c9=new Pl;qI.exports.Wildcard=Pl});var zI=S((eie,WI)=>{var u9=(function(){var n=a(function(P,C,O,k){for(O=O||{},k=P.length;k--;O[P[k]]=C);return O},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],r=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],l=[13,16,45,197,224,229,308],c=[28,29,53],u=[28,53],f=[1,42],d=[1,45],h=[1,41],p=[1,44],g=[123,126],_=[1,67],v=[39,45,87],w=[13,16,45,197,224,308],E=[1,87],I=[2,281],A=[1,86],D=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],K=[6,28,29,53,63,70,73,81,83,85],oe=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],me=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],N=[6,13,16,28,29,31,39,45,47,48,53,63,70,73,81,82,83,85,87,89,109,112,121,123,126,128,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,337,338,340,341,342,343,344,345,346],Q=[13,16,308],ie=[112,132,327,334],V=[13,16,112,132,308],Y=[1,111],re=[1,117],G=[112,132,327,328,334],ne=[13,16,112,132,308,328],q=[28,29,45,53,87],U=[1,138],B=[1,151],tt=[1,128],at=[1,127],H=[1,129],De=[1,140],Be=[1,141],ae=[1,142],Xe=[1,143],Ke=[1,144],He=[1,145],Je=[1,147],Le=[1,148],Qe=[2,457],Me=[1,158],Ye=[1,159],Ze=[1,160],ge=[1,152],Se=[1,153],we=[1,156],ye=[1,171],_e=[1,172],be=[1,173],pe=[1,174],ve=[1,175],Ee=[1,176],Te=[1,167],Ie=[1,168],fe=[1,169],xe=[1,170],st=[1,157],et=[1,166],ze=[1,161],T=[1,162],x=[1,163],R=[1,164],F=[1,165],te=[6,13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],wt=[1,195],Ct=[6,31,73,81,83,85],Ue=[2,285],W=[1,199],z=[1,201],X=[6,31,70,73,81,83,85],J=[2,283],ke=[1,207],lt=[1,218],ct=[1,223],Pr=[1,219],Tn=[1,225],Vn=[1,226],sn=[1,224],T2=[6,63,70,73,81,83,85],I2=[1,236],x2=[2,334],A2=[1,243],R2=[1,241],Or=[6,193],wd=[2,349],C2=[2,339],vo=[28,128],P2=[47,48,193,272],vd=[47,48,193,242,272],pl=[47,48,193,242,246,272],ml=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],_r=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],O2=[1,271],F2=[1,270],Kt=[6,13,16,29,31,39,45,47,48,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],D2=[1,281],L2=[1,280],on=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],yu=[45,89],Ed=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],Td=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Id=[31,89],xd=[48,87],ha=[6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338],Xi=[6,13,16,39,45,48,82,87,89,231,263,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338,340],N2=[1,313],gl=[6,85],jy=[6,31,81,83,85],k2=[2,361],Cs=[2,353],pa=[1,343],_u=[31,112,335],Ps=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],$y=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335],M2=[6,109,193],ma=[31,112],Jt=[13,16,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],Uy=[1,390],Vy=[1,391],Eo=[13,16,87,197,308,314],j2=[13,16,39,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],Ad=[1,417],Rd=[1,418],$2=[13,16,48,197,229,308],To=[6,31,85],U2=[6,13,16,31,45,73,81,83,85,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],By=[6,13,16,29,31,45,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,231,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,346,347,348,349,350,351],ga=[29,31,85,112,159,160,161,163,164],Cd=[1,443],Pd=[1,444],V2=[1,449],ya=[31,112,193,232,318,335],Od=[13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],B2=[13,16,31,45,48,82,87,89,112,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Gy=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],bu=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Su=[31,45],G2=[1,507],q2=[1,508],W2=[6,13,16,29,31,39,45,47,48,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,336,338,341,342,343,344,345,346,347,348,349,350,351],Fd=[29,31,85,112,159,160,161,163,164,335],_a=[6,13,16,31,45,70,73,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],z2=[13,16,31,45,48,82,87,89,112,193,197,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],H2=[2,352],qy=[13,16,197,308,314],Q2=[1,565],yl=[6,13,16,31,45,76,78,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Y2=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Os=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],X2=[13,16,87,308],Fs=[2,364],_l=[29,31,85,112,159,160,161,163,164,193,232,318,335],Dd=[31,112,193,232,272,318,335],Ds=[2,359],K2=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Ld=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],J2=[13,16,31,45,82,87,89,112,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Z2=[2,347],Wy={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Query:7,Qry:8,Query_option0:9,Prologue_repetition0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectClauseWildcard:17,Qry_repetition0:18,WhereClause:19,SolutionModifierNoGroup:20,SelectClauseVars:21,Qry_repetition1:22,SolutionModifier:23,CONSTRUCT:24,ConstructTemplate:25,Qry_repetition2:26,Qry_repetition3:27,WHERE:28,"{":29,Qry_option0:30,"}":31,DESCRIBE:32,Qry_group0:33,Qry_repetition4:34,Qry_option1:35,ASK:36,Qry_repetition5:37,SelectClauseBase:38,"*":39,SelectClauseVars_repetition_plus0:40,SELECT:41,SelectClauseBase_option0:42,SelectClauseItem:43,Var:44,"(":45,Expression:46,AS:47,")":48,SubSelect:49,SubSelect_option0:50,SubSelect_option1:51,DatasetClause:52,FROM:53,DatasetClause_option0:54,iri:55,WhereClause_option0:56,GroupGraphPattern:57,SolutionModifier_option0:58,SolutionModifierNoGroup_option0:59,SolutionModifierNoGroup_option1:60,SolutionModifierNoGroup_option2:61,GroupClause:62,GROUP:63,BY:64,GroupClause_repetition_plus0:65,GroupCondition:66,BuiltInCall:67,FunctionCall:68,HavingClause:69,HAVING:70,HavingClause_repetition_plus0:71,OrderClause:72,ORDER:73,OrderClause_repetition_plus0:74,OrderCondition:75,ASC:76,BrackettedExpression:77,DESC:78,Constraint:79,LimitOffsetClauses:80,LIMIT:81,INTEGER:82,OFFSET:83,ValuesClause:84,VALUES:85,InlineData:86,VAR:87,InlineData_repetition0:88,NIL:89,InlineData_repetition1:90,InlineData_repetition_plus2:91,InlineData_repetition3:92,DataBlock:93,DataBlockValueList:94,DataBlockValueList_repetition_plus0:95,Update:96,Update_repetition0:97,Update1:98,Update_option0:99,LOAD:100,Update1_option0:101,Update1_option1:102,Update1_group0:103,Update1_option2:104,GraphRefAll:105,Update1_group1:106,Update1_option3:107,GraphOrDefault:108,TO:109,CREATE:110,Update1_option4:111,GRAPH:112,INSERTDATA:113,QuadPattern:114,DELETEDATA:115,DELETEWHERE:116,Update1_option5:117,InsertDeleteClause:118,Update1_repetition0:119,IntoGraphClause:120,INTO:121,GraphRef:122,DELETE:123,InsertDeleteClause_option0:124,InsertClause:125,INSERT:126,UsingClause:127,USING:128,UsingClause_option0:129,WithClause:130,WITH:131,DEFAULT:132,GraphOrDefault_option0:133,GraphRefAll_group0:134,Quads:135,Quads_option0:136,Quads_repetition0:137,QuadsNotTriples:138,VarOrIri:139,QuadsNotTriples_option0:140,QuadsNotTriples_option1:141,QuadsNotTriples_option2:142,TriplesTemplate:143,TriplesTemplate_repetition0:144,TriplesSameSubject:145,TriplesTemplate_option0:146,GroupGraphPatternSub:147,GroupGraphPatternSub_option0:148,GroupGraphPatternSub_repetition0:149,GroupGraphPatternSubTail:150,GraphPatternNotTriples:151,GroupGraphPatternSubTail_option0:152,GroupGraphPatternSubTail_option1:153,TriplesBlock:154,TriplesBlock_repetition0:155,TriplesSameSubjectPath:156,TriplesBlock_option0:157,GroupOrUnionGraphPattern:158,OPTIONAL:159,MINUS:160,SERVICE:161,GraphPatternNotTriples_option0:162,FILTER:163,BIND:164,InlineDataOneVar:165,InlineDataFull:166,InlineDataOneVar_repetition0:167,InlineDataFull_repetition0:168,InlineDataFull_repetition_plus1:169,InlineDataFull_repetition2:170,DataBlockValue:171,Literal:172,QuotedTriple:173,UNDEF:174,GroupOrUnionGraphPattern_repetition0:175,ArgList:176,ArgList_option0:177,ArgList_repetition0:178,ExpressionList:179,ExpressionList_repetition0:180,ConstructTemplate_option0:181,ConstructTriples:182,ConstructTriples_repetition0:183,ConstructTriples_option0:184,VarOrTermOrQuotedTP:185,PropertyListNotEmpty:186,TriplesNode:187,PropertyList:188,PropertyList_option0:189,VerbObjectList:190,PropertyListNotEmpty_repetition0:191,SemiOptionalVerbObjectList:192,";":193,SemiOptionalVerbObjectList_option0:194,Verb:195,ObjectList:196,a:197,ObjectList_repetition0:198,Object:199,GraphNode:200,Object_option0:201,PropertyListPathNotEmpty:202,TriplesNodePath:203,TriplesSameSubjectPath_option0:204,O:205,PropertyListPathNotEmpty_repetition0:206,PropertyListPathNotEmptyTail:207,O_group0:208,ObjectListPath:209,ObjectListPath_repetition0:210,ObjectPath:211,GraphNodePath:212,ObjectPath_option0:213,Path:214,Path_repetition0:215,PathSequence:216,PathSequence_repetition0:217,PathEltOrInverse:218,PathElt:219,PathPrimary:220,PathElt_option0:221,PathEltOrInverse_option0:222,IriOrA:223,"!":224,PathNegatedPropertySet:225,PathOneInPropertySet:226,PathNegatedPropertySet_repetition0:227,PathNegatedPropertySet_option0:228,"^":229,TriplesNode_repetition_plus0:230,"[":231,"]":232,TriplesNodePath_repetition_plus0:233,VarOrTermOrQuotedTPExpr:234,VarOrTerm:235,GraphTerm:236,BlankNode:237,ConditionalOrExpression:238,ConditionalAndExpression:239,ConditionalOrExpression_repetition0:240,ConditionalOrExpressionTail:241,"||":242,RelationalExpression:243,ConditionalAndExpression_repetition0:244,ConditionalAndExpressionTail:245,"&&":246,NumericExpression:247,RelationalExpression_group0:248,RelationalExpression_option0:249,IN:250,MultiplicativeExpression:251,NumericExpression_repetition0:252,AdditiveExpressionTail:253,AdditiveExpressionTail_group0:254,NumericLiteralPositive:255,AdditiveExpressionTail_repetition0:256,NumericLiteralNegative:257,AdditiveExpressionTail_repetition1:258,UnaryExpression:259,MultiplicativeExpression_repetition0:260,MultiplicativeExpressionTail:261,MultiplicativeExpressionTail_group0:262,"+":263,PrimaryExpression:264,"-":265,ExprQuotedTP:266,Aggregate:267,FUNC_ARITY0:268,FUNC_ARITY1:269,FUNC_ARITY1_SPARQL_STAR:270,FUNC_ARITY2:271,",":272,FUNC_ARITY3:273,FUNC_ARITY3_SPARQL_STAR:274,BuiltInCall_group0:275,BOUND:276,BNODE:277,BuiltInCall_option0:278,EXISTS:279,COUNT:280,Aggregate_option0:281,Aggregate_group0:282,FUNC_AGGREGATE:283,Aggregate_option1:284,GROUP_CONCAT:285,Aggregate_option2:286,Aggregate_option3:287,GroupConcatSeparator:288,SEPARATOR:289,"=":290,String:291,LANGTAG:292,"^^":293,DECIMAL:294,DOUBLE:295,BOOLEAN:296,INTEGER_POSITIVE:297,DECIMAL_POSITIVE:298,DOUBLE_POSITIVE:299,INTEGER_NEGATIVE:300,DECIMAL_NEGATIVE:301,DOUBLE_NEGATIVE:302,STRING_LITERAL1:303,STRING_LITERAL2:304,STRING_LITERAL_LONG1:305,STRING_LITERAL_LONG2:306,PrefixedName:307,PNAME_LN:308,BLANK_NODE_LABEL:309,ANON:310,QuotedTP:311,"<<":312,qtSubjectOrObject:313,">>":314,DataValueTerm:315,AnnotationPattern:316,"{|":317,"|}":318,AnnotationPatternPath:319,ExprVarOrTerm:320,QueryOrUpdate_group0_option0:321,Prologue_repetition0_group0:322,Qry_group0_repetition_plus0:323,SelectClauseBase_option0_group0:324,DISTINCT:325,REDUCED:326,NAMED:327,SILENT:328,CLEAR:329,DROP:330,ADD:331,MOVE:332,COPY:333,ALL:334,".":335,UNION:336,"|":337,"/":338,PathElt_option0_group0:339,"?":340,"!=":341,"<":342,">":343,"<=":344,">=":345,NOT:346,CONCAT:347,COALESCE:348,SUBSTR:349,REGEX:350,REPLACE:351,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",24:"CONSTRUCT",28:"WHERE",29:"{",31:"}",32:"DESCRIBE",36:"ASK",39:"*",41:"SELECT",45:"(",47:"AS",48:")",53:"FROM",63:"GROUP",64:"BY",70:"HAVING",73:"ORDER",76:"ASC",78:"DESC",81:"LIMIT",82:"INTEGER",83:"OFFSET",85:"VALUES",87:"VAR",89:"NIL",100:"LOAD",109:"TO",110:"CREATE",112:"GRAPH",113:"INSERTDATA",115:"DELETEDATA",116:"DELETEWHERE",121:"INTO",123:"DELETE",126:"INSERT",128:"USING",131:"WITH",132:"DEFAULT",159:"OPTIONAL",160:"MINUS",161:"SERVICE",163:"FILTER",164:"BIND",174:"UNDEF",193:";",197:"a",224:"!",229:"^",231:"[",232:"]",242:"||",246:"&&",250:"IN",263:"+",265:"-",268:"FUNC_ARITY0",269:"FUNC_ARITY1",270:"FUNC_ARITY1_SPARQL_STAR",271:"FUNC_ARITY2",272:",",273:"FUNC_ARITY3",274:"FUNC_ARITY3_SPARQL_STAR",276:"BOUND",277:"BNODE",279:"EXISTS",280:"COUNT",283:"FUNC_AGGREGATE",285:"GROUP_CONCAT",289:"SEPARATOR",290:"=",292:"LANGTAG",293:"^^",294:"DECIMAL",295:"DOUBLE",296:"BOOLEAN",297:"INTEGER_POSITIVE",298:"DECIMAL_POSITIVE",299:"DOUBLE_POSITIVE",300:"INTEGER_NEGATIVE",301:"DECIMAL_NEGATIVE",302:"DOUBLE_NEGATIVE",303:"STRING_LITERAL1",304:"STRING_LITERAL2",305:"STRING_LITERAL_LONG1",306:"STRING_LITERAL_LONG2",308:"PNAME_LN",309:"BLANK_NODE_LABEL",310:"ANON",312:"<<",314:">>",317:"{|",318:"|}",325:"DISTINCT",326:"REDUCED",327:"NAMED",328:"SILENT",329:"CLEAR",330:"DROP",331:"ADD",332:"MOVE",333:"COPY",334:"ALL",335:".",336:"UNION",337:"|",338:"/",340:"?",341:"!=",342:"<",343:">",344:"<=",345:">=",346:"NOT",347:"CONCAT",348:"COALESCE",349:"SUBSTR",350:"REGEX",351:"REPLACE"},productions_:[0,[3,3],[7,2],[4,1],[11,2],[14,3],[8,4],[8,4],[8,5],[8,7],[8,5],[8,4],[17,2],[21,2],[38,2],[43,1],[43,5],[49,4],[49,4],[52,3],[19,2],[23,2],[20,3],[62,3],[66,1],[66,1],[66,3],[66,5],[66,1],[69,2],[72,3],[75,2],[75,2],[75,1],[75,1],[80,2],[80,2],[80,4],[80,4],[84,2],[86,4],[86,4],[86,6],[86,2],[94,3],[96,3],[98,4],[98,3],[98,5],[98,4],[98,2],[98,2],[98,2],[98,5],[120,2],[118,3],[118,1],[125,2],[127,3],[130,2],[108,1],[108,2],[122,2],[105,1],[105,1],[114,3],[135,2],[138,7],[143,3],[57,3],[57,3],[147,2],[150,3],[154,3],[151,1],[151,2],[151,2],[151,3],[151,4],[151,2],[151,6],[151,1],[93,1],[93,1],[165,4],[166,4],[166,6],[171,1],[171,1],[171,1],[171,1],[158,2],[79,1],[79,1],[79,1],[68,2],[176,1],[176,5],[179,1],[179,4],[25,3],[182,3],[145,2],[145,2],[188,1],[186,2],[192,2],[190,2],[195,1],[195,1],[196,2],[199,2],[156,2],[156,2],[202,2],[207,1],[207,2],[205,2],[209,2],[211,2],[214,2],[216,2],[219,2],[218,2],[220,1],[220,2],[220,3],[225,1],[225,1],[225,4],[226,1],[226,2],[187,3],[187,3],[203,3],[203,3],[200,1],[200,1],[212,1],[212,1],[234,1],[235,1],[235,1],[139,1],[139,1],[44,1],[236,1],[236,1],[236,1],[236,1],[46,1],[238,2],[241,2],[239,2],[245,2],[243,1],[243,3],[243,4],[247,2],[253,2],[253,2],[253,2],[251,2],[261,2],[259,2],[259,2],[259,2],[259,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[77,3],[67,1],[67,2],[67,4],[67,4],[67,6],[67,8],[67,8],[67,2],[67,4],[67,2],[67,4],[67,3],[267,5],[267,5],[267,6],[288,4],[172,1],[172,2],[172,3],[172,1],[172,1],[172,1],[172,1],[172,1],[172,1],[255,1],[255,1],[255,1],[257,1],[257,1],[257,1],[291,1],[291,1],[291,1],[291,1],[55,1],[55,1],[307,1],[307,1],[237,1],[237,1],[311,5],[173,5],[313,1],[313,1],[313,1],[313,1],[313,1],[315,1],[315,1],[315,1],[185,1],[185,1],[185,1],[316,3],[319,3],[266,5],[320,1],[320,1],[320,1],[223,1],[223,1],[321,0],[321,1],[5,1],[5,1],[5,1],[9,0],[9,1],[322,1],[322,1],[10,0],[10,2],[18,0],[18,2],[22,0],[22,2],[26,0],[26,2],[27,0],[27,2],[30,0],[30,1],[323,1],[323,2],[33,1],[33,1],[34,0],[34,2],[35,0],[35,1],[37,0],[37,2],[40,1],[40,2],[324,1],[324,1],[42,0],[42,1],[50,0],[50,1],[51,0],[51,1],[54,0],[54,1],[56,0],[56,1],[58,0],[58,1],[59,0],[59,1],[60,0],[60,1],[61,0],[61,1],[65,1],[65,2],[71,1],[71,2],[74,1],[74,2],[88,0],[88,2],[90,0],[90,2],[91,1],[91,2],[92,0],[92,2],[95,1],[95,2],[97,0],[97,4],[99,0],[99,2],[101,0],[101,1],[102,0],[102,1],[103,1],[103,1],[104,0],[104,1],[106,1],[106,1],[106,1],[107,0],[107,1],[111,0],[111,1],[117,0],[117,1],[119,0],[119,2],[124,0],[124,1],[129,0],[129,1],[133,0],[133,1],[134,1],[134,1],[134,1],[136,0],[136,1],[137,0],[137,2],[140,0],[140,1],[141,0],[141,1],[142,0],[142,1],[144,0],[144,3],[146,0],[146,1],[148,0],[148,1],[149,0],[149,2],[152,0],[152,1],[153,0],[153,1],[155,0],[155,3],[157,0],[157,1],[162,0],[162,1],[167,0],[167,2],[168,0],[168,2],[169,1],[169,2],[170,0],[170,2],[175,0],[175,3],[177,0],[177,1],[178,0],[178,3],[180,0],[180,3],[181,0],[181,1],[183,0],[183,3],[184,0],[184,1],[189,0],[189,1],[191,0],[191,2],[194,0],[194,1],[198,0],[198,3],[201,0],[201,1],[204,0],[204,1],[206,0],[206,2],[208,1],[208,1],[210,0],[210,3],[213,0],[213,1],[215,0],[215,3],[217,0],[217,3],[339,1],[339,1],[339,1],[221,0],[221,1],[222,0],[222,1],[227,0],[227,3],[228,0],[228,1],[230,1],[230,2],[233,1],[233,2],[240,0],[240,2],[244,0],[244,2],[248,1],[248,1],[248,1],[248,1],[248,1],[248,1],[249,0],[249,1],[252,0],[252,2],[254,1],[254,1],[256,0],[256,2],[258,0],[258,2],[260,0],[260,2],[262,1],[262,1],[275,1],[275,1],[275,1],[275,1],[275,1],[278,0],[278,1],[281,0],[281,1],[282,1],[282,1],[284,0],[284,1],[286,0],[286,1],[287,0],[287,1]],performAction:a(function(C,O,k,le,je,y,ln){var b=y.length-1;switch(je){case 1:if(y[b-1]=y[b-1]||{},Ge.base&&(y[b-1].base=Ge.base),Ge.base="",y[b-1].prefixes=Ge.prefixes,Ge.prefixes=null,Ge.pathOnly){if(y[b-1].type==="path"||"termType"in y[b-1])return y[b-1];throw new Error("Received full SPARQL query in path only mode")}else if(y[b-1].type==="path"||"termType"in y[b-1])throw new Error("Received only path in full SPARQL mode");if(y[b-1].type==="update"){let vt={};for(let jt of y[b-1].updates)if(jt.updateType==="insert"){let ut={};for(let pt of jt.insert)if(pt.type==="bgp"||pt.type==="graph")for(let In of pt.triples)In.subject.termType==="BlankNode"&&(ut[In.subject.value]=!0),In.predicate.termType==="BlankNode"&&(ut[In.predicate.value]=!0),In.object.termType==="BlankNode"&&(ut[In.object.value]=!0);for(let pt of Object.keys(ut)){if(vt[pt])throw new Error("Detected reuse blank node across different INSERT DATA clauses");vt[pt]=!0}}}return y[b-1];case 2:this.$={...y[b-1],...y[b],type:"query"};break;case 4:Ge.base=wu(y[b]);break;case 5:Ge.prefixes||(Ge.prefixes={}),y[b-1]=y[b-1].substr(0,y[b-1].length-1),y[b]=wu(y[b]),Ge.prefixes[y[b-1]]=y[b];break;case 6:this.$={...y[b-3],...wa(y[b-2]),...y[b-1],...y[b]};break;case 7:if(!Ge.skipValidation&&(Zy(y[b-3].variables.map(jt=>Jy(jt.expression))).some(jt=>jt.aggregation==="count"&&!(jt.expression instanceof Nd))||y[b].group)){for(let jt of y[b-3].variables)if(jt.termType==="Variable"){if(!y[b].group||!y[b].group.map(ut=>vl(ut)).includes(vl(jt)))throw Error("Projection of ungrouped variable (?"+vl(jt)+")")}else if(Jy(jt.expression).length===0){let ut=qN(jt.expression);for(let pt of ut)if(!y[b].group||!y[b].group.map||!y[b].group.map(In=>vl(In)).includes(vl(pt)))throw Error("Use of ungrouped variable in projection of operation (?"+vl(pt)+")")}}let es=y[b-1].where.filter(vt=>vt.type==="query");if(es.length>0){let vt=y[b-3].variables.filter(ut=>ut.variable&&ut.variable.value).map(ut=>ut.variable.value),jt=Zy(es.map(ut=>ut.variables)).map(ut=>ut.value||ut.variable.value);for(let ut of vt)if(jt.indexOf(ut)>=0)throw Error("Target id of 'AS' (?"+ut+") already used in subquery")}this.$=zt(y[b-3],wa(y[b-2]),y[b-1],y[b]);break;case 8:this.$=zt({queryType:"CONSTRUCT",template:y[b-3]},wa(y[b-2]),y[b-1],y[b]);break;case 9:this.$=zt({queryType:"CONSTRUCT",template:y[b-2]=y[b-2]?y[b-2].triples:[]},wa(y[b-5]),{where:[{type:"bgp",triples:Sa([],y[b-2])}]},y[b]);break;case 10:this.$=zt({queryType:"DESCRIBE",variables:y[b-3]==="*"?[new Nd]:y[b-3]},wa(y[b-2]),y[b-1],y[b]);break;case 11:this.$=zt({queryType:"ASK"},wa(y[b-2]),y[b-1],y[b]);break;case 12:this.$=zt(y[b-1],{variables:[new Nd]});break;case 13:let xu=y[b].map(vt=>vt.value||vt.variable.value),El=WN(xu);if(El.length>0)throw Error("Two or more of the resulting columns have the same name (?"+El[0]+")");this.$=zt(y[b-1],{variables:y[b]});break;case 14:this.$=zt({queryType:"SELECT"},y[b]&&(y[b-1]=an(y[b]),y[b]={},y[b][y[b-1]]=!0,y[b]));break;case 16:case 27:this.$=bl(y[b-3],{variable:y[b-1]});break;case 17:case 18:this.$=zt(y[b-3],y[b-2],y[b-1],y[b],{type:"query"});break;case 19:case 58:this.$={iri:y[b],named:!!y[b-1]};break;case 20:this.$={where:y[b].patterns};break;case 21:this.$=zt(y[b-1],y[b]);break;case 22:this.$=zt(y[b-2],y[b-1],y[b]);break;case 23:this.$={group:y[b]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=bl(y[b]);break;case 26:this.$=bl(y[b-1]);break;case 29:this.$={having:y[b]};break;case 30:this.$={order:y[b]};break;case 32:this.$=bl(y[b],{descending:!0});break;case 35:this.$={limit:wl(y[b])};break;case 36:this.$={offset:wl(y[b])};break;case 37:this.$={limit:wl(y[b-2]),offset:wl(y[b])};break;case 38:this.$={limit:wl(y[b]),offset:wl(y[b-2])};break;case 39:case 43:this.$={type:"values",values:y[b]};break;case 40:case 84:this.$=y[b-1].map(vt=>({[y[b-3]]:vt}));break;case 41:case 85:this.$=y[b-1].map(()=>({}));break;case 42:case 86:var Zi=y[b-4].length;y[b-4]=y[b-4].map(zy),this.$=y[b-1].map(function(vt){if(vt.length!==Zi)throw Error("Inconsistent VALUES length");for(var jt={},ut=0;ut<Zi;ut++)jt["?"+y[b-4][ut].value]=vt[ut];return jt});break;case 44:case 65:case 100:case 126:case 175:this.$=y[b-1];break;case 45:this.$={type:"update",updates:Ls(y[b-2],y[b-1])};break;case 46:this.$=zt({type:"load",silent:!!y[b-2],source:y[b-1]},y[b]&&{destination:y[b]});break;case 47:this.$={type:an(y[b-2]),silent:!!y[b-1],graph:y[b]};break;case 48:this.$={type:an(y[b-4]),silent:!!y[b-3],source:y[b-2],destination:y[b]};break;case 49:this.$={type:"create",silent:!!y[b-2],graph:{type:"graph",name:y[b]}};break;case 50:this.$={updateType:"insert",insert:uT(y[b])};break;case 51:this.$={updateType:"delete",delete:r0(uT(y[b]))};break;case 52:this.$={updateType:"deletewhere",delete:r0(y[b])};break;case 53:this.$={updateType:"insertdelete",...y[b-4],...y[b-3],...wa(y[b-2],"using"),where:y[b].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=y[b];break;case 55:this.$={delete:r0(y[b-1]),insert:y[b]||[]};break;case 56:this.$={delete:[],insert:y[b]};break;case 59:this.$={graph:y[b]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:y[b]};break;case 64:this.$={[an(y[b])]:!0};break;case 66:this.$=y[b-1]?Ki(y[b],[y[b-1]]):Ki(y[b]);break;case 67:var Tu=zt(y[b-3]||{triples:[]},{type:"graph",name:y[b-5]});this.$=y[b]?[Tu,y[b]]:[Tu];break;case 68:case 73:this.$={type:"bgp",triples:Ki(y[b-2],[y[b-1]])};break;case 69:this.$={type:"group",patterns:[y[b-1]]};break;case 70:for(let vt of y[b-1].filter(jt=>jt.type==="bind")){let jt=y[b-1].indexOf(vt),ut=new Set;for(let pt of y[b-1].slice(0,jt))(pt.type==="group"||pt.type==="bgp")&&lT(pt).forEach(In=>ut.add(In));if(ut.has(vt.variable.value))throw Error("Variable used to bind is already bound (?"+vt.variable.value+")")}this.$={type:"group",patterns:y[b-1]};break;case 71:this.$=y[b-1]?Ki([y[b-1]],y[b]):Ki(y[b]);break;case 72:this.$=y[b]?[y[b-2],y[b]]:y[b-2];break;case 75:this.$=zt(y[b],{type:"optional"});break;case 76:this.$=zt(y[b],{type:"minus"});break;case 77:this.$=zt(y[b],{type:"graph",name:y[b-1]});break;case 78:this.$=zt(y[b],{type:"service",name:y[b-1],silent:!!y[b-2]});break;case 79:this.$={type:"filter",expression:y[b]};break;case 80:this.$={type:"bind",variable:y[b-1],expression:y[b-3]};break;case 89:this.$=Eu(y[b]);break;case 90:this.$=void 0;break;case 91:this.$=y[b-1].length?{type:"union",patterns:Ki(y[b-1].map(Qy),[Qy(y[b])])}:y[b];break;case 95:this.$={...y[b],function:y[b-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:Ls(y[b-2],y[b-1]),distinct:!!y[b-3]};break;case 98:case 115:case 128:case 247:case 249:case 251:case 253:case 255:case 263:case 267:case 297:case 299:case 303:case 307:case 328:case 341:case 349:case 355:case 361:case 367:case 369:case 373:case 375:case 379:case 381:case 385:case 391:case 395:case 401:case 405:case 409:case 411:case 420:case 428:case 430:case 440:case 444:case 446:case 448:this.$=[];break;case 99:this.$=Ls(y[b-2],y[b-1]);break;case 101:this.$=Ki(y[b-2],[y[b-1]]);break;case 102:case 112:this.$=t0(y[b].map(vt=>zt(Ns(y[b-1]),vt)));break;case 103:this.$=t0(Sa(y[b].map(vt=>zt(Ns(y[b-1].entity),vt)),y[b-1].triples));break;case 105:this.$=Ki([y[b-1]],y[b]);break;case 106:this.$=Ki(y[b]);break;case 107:this.$=Ky(y[b-1],y[b]);break;case 109:case 237:this.$=Ge.factory.namedNode(LN);break;case 110:case 118:this.$=Ls(y[b-1],y[b]);break;case 111:this.$=y[b]?{annotation:y[b],object:y[b-1]}:y[b-1];break;case 113:this.$=y[b]?t0(Sa(y[b].map(vt=>zt(Ns(y[b-1].entity),vt)),y[b-1].triples)):y[b-1].triples;break;case 114:this.$=Ky(...y[b-1],y[b]);break;case 116:this.$=Ky(...y[b]);break;case 117:case 159:case 163:this.$=[y[b-1],y[b]];break;case 119:this.$=y[b]?{object:y[b-1],annotation:y[b]}:y[b-1];break;case 120:this.$=y[b-1].length?Sl("|",Ls(y[b-1],y[b])):y[b];break;case 121:this.$=y[b-1].length?Sl("/",Ls(y[b-1],y[b])):y[b];break;case 122:this.$=y[b]?Sl(y[b],[y[b-1]]):y[b-1];break;case 123:this.$=y[b-1]?Sl(y[b-1],[y[b]]):y[b];break;case 125:case 131:this.$=Sl(y[b-1],[y[b]]);break;case 129:this.$=Sl("|",Ls(y[b-2],y[b-1]));break;case 132:case 134:this.$=BN(y[b-1]);break;case 133:case 135:this.$=GN(y[b-1]);break;case 140:this.$={entity:y[b],triples:[]};break;case 145:this.$=zy(y[b]);break;case 149:this.$=Ge.factory.namedNode(eT);break;case 151:case 153:case 158:case 162:this.$=Hy(y[b-1],y[b]);break;case 152:this.$=["||",y[b]];break;case 154:this.$=["&&",y[b]];break;case 156:this.$=Fr(y[b-1],[y[b-2],y[b]]);break;case 157:this.$=Fr(y[b-2]?"notin":"in",[y[b-3],y[b]]);break;case 160:this.$=["+",Hy(y[b-1],y[b])];break;case 161:var jd=Ji(y[b-1].value.replace("-",""),y[b-1].datatype);this.$=["-",Hy(jd,y[b])];break;case 164:this.$=Fr("UPLUS",[y[b]]);break;case 165:this.$=Fr(y[b-1],[y[b]]);break;case 166:this.$=Fr("UMINUS",[y[b]]);break;case 177:this.$=Fr(an(y[b-1]));break;case 178:this.$=Fr(an(y[b-3]),[y[b-1]]);break;case 179:this.$=Eu(Fr(an(y[b-3]),[y[b-1]]));break;case 180:this.$=Fr(an(y[b-5]),[y[b-3],y[b-1]]);break;case 181:this.$=Fr(an(y[b-7]),[y[b-5],y[b-3],y[b-1]]);break;case 182:this.$=Eu(Fr(an(y[b-7]),[y[b-5],y[b-3],y[b-1]]));break;case 183:this.$=Fr(an(y[b-1]),y[b]);break;case 184:this.$=Fr("bound",[zy(y[b-1])]);break;case 185:this.$=Fr(y[b-1],[]);break;case 186:this.$=Fr(y[b-3],[y[b-1]]);break;case 187:this.$=Fr(y[b-2]?"notexists":"exists",[Qy(y[b])]);break;case 188:case 189:this.$=bl(y[b-1],{type:"aggregate",aggregation:an(y[b-4]),distinct:!!y[b-2]});break;case 190:this.$=bl(y[b-2],{type:"aggregate",aggregation:an(y[b-5]),distinct:!!y[b-3],separator:typeof y[b-1]=="string"?y[b-1]:" "});break;case 192:this.$=Ji(y[b]);break;case 193:this.$=jN(y[b-1],an(y[b].substr(1)));break;case 194:this.$=Ji(y[b-2],y[b]);break;case 195:case 204:this.$=Ji(y[b],tT);break;case 196:case 205:this.$=Ji(y[b],rT);break;case 197:case 206:this.$=Ji(an(y[b]),nT);break;case 200:this.$=Ji(y[b].toLowerCase(),MN);break;case 201:this.$=Ji(y[b].substr(1),tT);break;case 202:this.$=Ji(y[b].substr(1),rT);break;case 203:this.$=Ji(y[b].substr(1).toLowerCase(),nT);break;case 207:case 208:this.$=aT(y[b],1);break;case 209:case 210:this.$=aT(y[b],3);break;case 211:this.$=Ge.factory.namedNode(wu(y[b]));break;case 213:var $d=y[b].indexOf(":"),Iu=y[b].substr(0,$d),Ud=Ge.prefixes[Iu];if(!Ud)throw new Error("Unknown prefix: "+Iu);var Bt=wu(Ud+y[b].substr($d+1));this.$=Ge.factory.namedNode(Bt);break;case 214:if(y[b]=y[b].substr(0,y[b].length-1),!(y[b]in Ge.prefixes))throw new Error("Unknown prefix: "+y[b]);var Bt=wu(Ge.prefixes[y[b]]);this.$=Ge.factory.namedNode(Bt);break;case 215:this.$=vu(y[b].replace(/^(_:)/,""));break;case 216:this.$=vu();break;case 217:case 218:case 232:this.$=Eu(Yy(y[b-3],y[b-2],y[b-1]));break;case 230:case 231:this.$=Eu(y[b-1]);break;case 248:case 250:case 252:case 254:case 256:case 260:case 264:case 268:case 270:case 292:case 294:case 296:case 298:case 300:case 302:case 304:case 306:case 329:case 342:case 356:case 368:case 370:case 372:case 374:case 392:case 402:case 425:case 427:case 429:case 431:case 441:case 445:case 447:case 449:y[b-1].push(y[b]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[y[b]];break;case 308:y[b-3].push(y[b-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:y[b-2].push(y[b-1]);break}},"anonymous"),table:[n(e,t,{3:1,4:2,10:3}),{1:[3]},n(r,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),n([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:o},{6:[2,239]},n(l,[2,411],{216:28,217:29}),n(c,[2,249],{18:30}),n(c,[2,251],{22:31}),n(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:h,139:38,307:43,308:p,323:36},n(c,[2,267],{37:46}),n(g,[2,326],{98:47,103:49,106:50,117:55,130:61,100:[1,48],110:[1,51],113:[1,52],115:[1,53],116:[1,54],131:[1,62],329:[1,56],330:[1,57],331:[1,58],332:[1,59],333:[1,60]}),{39:[1,63],40:64,43:65,44:66,45:_,87:h},n(v,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),n(e,[2,248]),n(e,[2,245]),n(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),n(w,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:E,29:I,52:84,53:A,56:85},{19:88,28:E,29:I,52:89,53:A,56:85},n(c,[2,253],{26:90}),{28:[1,91],52:92,53:A},n(D,[2,385],{181:93,182:94,183:95,31:[2,383]}),n(K,[2,263],{34:96}),n(K,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:h,308:p}),n(K,[2,262]),n(oe,[2,259]),n(me,[2,143]),n(me,[2,144]),n([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),n(N,[2,211]),n(N,[2,212]),n(N,[2,213]),n(N,[2,214]),{19:98,28:E,29:I,52:99,53:A,56:85},{6:[2,309],99:100,193:[1,101]},n(Q,[2,311],{101:102,328:[1,103]}),n(ie,[2,317],{104:104,328:[1,105]}),n(V,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:Y,114:110},{29:Y,114:112},{29:Y,114:113},{118:114,123:[1,115],125:116,126:re},n(G,[2,315]),n(G,[2,316]),n(ne,[2,319]),n(ne,[2,320]),n(ne,[2,321]),n(g,[2,327]),{13:f,16:d,55:118,307:43,308:p},n(c,[2,12]),n(c,[2,13],{44:66,43:119,45:_,87:h}),n(q,[2,269]),n(q,[2,15]),{13:f,16:d,44:136,45:U,46:120,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(v,[2,14]),n(v,[2,274]),n(v,[2,271]),n(v,[2,272]),n(e,[2,4]),{13:[1,177]},n(te,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},n(l,[2,410]),n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:d,45:[1,193],55:194,197:wt,219:189,220:190,223:191,224:[1,192],307:43,308:p},n(w,[2,419]),n(Ct,Ue,{20:196,59:197,69:198,70:W}),n(c,[2,250]),{29:z,57:200},n(Q,[2,279],{54:202,327:[1,203]}),{29:[2,282]},n(X,J,{23:204,58:205,62:206,63:ke}),n(c,[2,252]),{19:208,28:E,29:I,52:209,53:A,56:85},{29:[1,210]},n(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,145:212,172:221,185:213,187:214,231:Pr,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(T2,[2,265],{56:85,35:227,52:228,19:229,28:E,29:I,53:A}),n(oe,[2,260]),n(X,J,{58:205,62:206,23:230,63:ke}),n(c,[2,268]),{6:[2,45]},n(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:p},n(Q,[2,312]),{105:233,112:I2,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},n(ie,[2,318]),n(Q,x2,{108:240,133:242,112:A2,132:R2}),n(V,[2,323]),{112:[1,244]},{112:[2,325]},n(Or,[2,50]),n(D,wd,{135:245,136:246,143:247,144:248,31:C2,112:C2}),n(Or,[2,51]),n(Or,[2,52]),n(vo,[2,328],{119:249}),{29:Y,114:250},n(vo,[2,56]),{29:Y,114:251},n(g,[2,59]),n(q,[2,270]),{47:[1,252]},n(P2,[2,150]),n(vd,[2,428],{240:253}),n(pl,[2,430],{244:254}),n(pl,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),n(ml,[2,440],{252:264}),n(_r,[2,448],{260:265}),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,255:154,257:155,264:266,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,255:154,257:155,264:267,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,255:154,257:155,264:268,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(_r,[2,167]),n(_r,[2,168]),n(_r,[2,169]),n(_r,[2,170],{176:269,45:O2,89:F2}),n(_r,[2,171]),n(_r,[2,172]),n(_r,[2,173]),n(_r,[2,174]),{13:f,16:d,44:136,45:U,46:272,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Kt,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:D2,89:L2,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},n(on,[2,192],{292:[1,286],293:[1,287]}),n(on,[2,195]),n(on,[2,196]),n(on,[2,197]),n(on,[2,198]),n(on,[2,199]),n(on,[2,200]),{13:f,16:d,44:39,55:40,82:B,87:h,139:289,172:291,255:154,257:155,266:290,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},n(yu,[2,452]),n(yu,[2,453]),n(yu,[2,454]),n(yu,[2,455]),n(yu,[2,456]),{279:[2,458]},n(Ed,[2,207]),n(Ed,[2,208]),n(Ed,[2,209]),n(Ed,[2,210]),n(on,[2,201]),n(on,[2,202]),n(on,[2,203]),n(on,[2,204]),n(on,[2,205]),n(on,[2,206]),n(e,[2,5]),n(Td,[2,297],{88:295}),n(Id,[2,299],{90:296}),{48:[1,297],87:[1,298]},n(xd,[2,301]),n(te,[2,43]),n(te,[2,82]),n(te,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},n(l,[2,412]),n(ha,[2,123]),n(ha,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),n(Xi,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:wt,223:312,225:308,226:309,229:N2,307:43,308:p},n(l,i,{215:10,214:314}),n(Xi,[2,236]),n(Xi,[2,237]),n(gl,[2,6]),n(jy,[2,287],{60:315,72:316,73:[1,317]}),n(Ct,[2,286]),{13:f,16:d,45:U,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:R,351:F},n([6,31,63,70,73,81,83,85],[2,20]),n(D,k2,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:Cs,31:Cs,85:Cs,112:Cs,159:Cs,160:Cs,161:Cs,163:Cs,164:Cs,41:s}),{13:f,16:d,55:331,307:43,308:p},n(Q,[2,280]),n(gl,[2,7]),n(Ct,Ue,{59:197,69:198,20:332,70:W}),n(X,[2,284]),{64:[1,333]},n(X,J,{58:205,62:206,23:334,63:ke}),n(c,[2,254]),n(D,wd,{144:248,30:335,143:336,31:[2,257]}),n(c,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:h,139:342,186:339,190:340,195:341,197:pa,307:43,308:p},n(_u,[2,389],{44:39,55:40,307:43,190:340,195:341,139:342,188:344,189:345,186:346,13:f,16:d,87:h,197:pa,308:p}),n(Ps,[2,227]),n(Ps,[2,228]),n(Ps,[2,229]),{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,172:221,185:351,187:350,200:348,230:347,231:Pr,234:349,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},{13:f,16:d,44:39,55:40,87:h,139:342,186:352,190:340,195:341,197:pa,307:43,308:p},n(Ps,[2,146]),n(Ps,[2,147]),n(Ps,[2,148]),n(Ps,[2,149]),{13:f,16:d,44:354,55:355,82:B,87:h,172:357,237:356,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:358,312:sn,313:353},n($y,[2,215]),n($y,[2,216]),n(X,J,{58:205,62:206,23:359,63:ke}),n(K,[2,264]),n(T2,[2,266]),n(gl,[2,11]),n(r,[2,308],{6:[2,310]}),n(Or,[2,313],{102:360,120:361,121:[1,362]}),n(Or,[2,47]),n(Or,[2,63]),n(Or,[2,64]),{13:f,16:d,55:363,307:43,308:p},n(Or,[2,336]),n(Or,[2,337]),n(Or,[2,338]),{109:[1,364]},n(M2,[2,60]),{13:f,16:d,55:365,307:43,308:p},n(Q,[2,335]),{13:f,16:d,55:366,307:43,308:p},{31:[1,367]},n(ma,[2,341],{137:368}),n(ma,[2,340]),{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,145:369,172:221,185:213,187:214,231:Pr,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},{28:[1,370],127:371,128:[1,372]},n(vo,[2,330],{124:373,125:374,126:re}),n(vo,[2,57]),{44:375,87:h},n(P2,[2,151],{241:376,242:[1,377]}),n(vd,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,247:380,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{250:[1,381]},n(Jt,[2,432]),n(Jt,[2,433]),n(Jt,[2,434]),n(Jt,[2,435]),n(Jt,[2,436]),n(Jt,[2,437]),{250:[2,439]},n([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:ye,298:_e,299:be,300:pe,301:ve,302:Ee}),n(ml,[2,162],{261:388,262:389,39:Uy,338:Vy}),n(_r,[2,164]),n(_r,[2,165]),n(_r,[2,166]),n(Kt,[2,95]),n(Kt,[2,96]),n(Jt,[2,377],{177:392,325:[1,393]}),{48:[1,394]},n(Kt,[2,177]),{13:f,16:d,44:136,45:U,46:395,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,46:396,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,46:397,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,46:398,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,46:399,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Kt,[2,183]),n(Kt,[2,98]),n(Jt,[2,381],{180:400}),{87:[1,401]},n(Kt,[2,185]),{13:f,16:d,44:136,45:U,46:402,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{29:z,57:403},n(on,[2,193]),{13:f,16:d,55:404,307:43,308:p},{13:f,16:d,44:39,55:40,87:h,139:342,195:405,197:pa,307:43,308:p},n(Eo,[2,233]),n(Eo,[2,234]),n(Eo,[2,235]),n(j2,[2,459],{281:406,325:[1,407]}),n(Jt,[2,463],{284:408,325:[1,409]}),n(Jt,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:B,171:413,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},{31:[1,419],89:[1,420]},{29:[1,421]},n(xd,[2,302]),n(Td,[2,367],{167:422}),n(Id,[2,369],{168:423}),{48:[1,424],87:[1,425]},n(xd,[2,371]),n(ha,[2,122]),n(ha,[2,417]),n(ha,[2,413]),n(ha,[2,414]),n(ha,[2,415]),n(Xi,[2,125]),n(Xi,[2,127]),n(Xi,[2,128]),n($2,[2,420],{227:426}),n(Xi,[2,130]),{13:f,16:d,55:194,197:wt,223:427,307:43,308:p},{48:[1,428]},n(To,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),n(jy,[2,288]),{64:[1,433]},n(Ct,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:f,16:d,45:U,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,276:Je,277:Le,279:Qe,280:Me,283:Ye,285:Ze,308:p,346:et,347:ze,348:T,349:x,350:R,351:F}),n(U2,[2,293]),n(By,[2,92]),n(By,[2,93]),n(By,[2,94]),{45:O2,89:F2,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:E,29:I,56:85},{19:438,28:E,29:I,56:85},n(ga,[2,355],{149:439}),n(ga,[2,354]),{13:f,16:d,44:215,45:Cd,55:220,82:B,87:h,89:ct,156:440,172:221,185:441,203:442,231:Pd,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(K,[2,19]),n(To,[2,21]),{13:f,16:d,44:450,45:V2,55:323,65:445,66:446,67:447,68:448,87:h,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:R,351:F},n(gl,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},n(D,[2,386],{31:[2,388]}),n(_u,[2,102]),n(ya,[2,391],{191:452}),n(D,[2,395],{196:453,198:454}),n(D,[2,108]),n(D,[2,109]),n(_u,[2,103]),n(_u,[2,104]),n(_u,[2,390]),{13:f,16:d,44:215,45:lt,48:[1,455],55:220,82:B,87:h,89:ct,172:221,185:351,187:350,200:456,231:Pr,234:349,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(Od,[2,424]),n(B2,[2,136]),n(B2,[2,137]),n(Gy,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:h,139:342,195:458,197:pa,307:43,308:p},n(Eo,[2,219]),n(Eo,[2,220]),n(Eo,[2,221]),n(Eo,[2,222]),n(Eo,[2,223]),n(gl,[2,10]),n(Or,[2,46]),n(Or,[2,314]),{112:I2,122:459},n(Or,[2,62]),n(Q,x2,{133:242,108:460,112:A2,132:R2}),n(M2,[2,61]),n(Or,[2,49]),n([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},n(ma,[2,351],{146:463,335:[1,464]}),{29:z,57:465},n(vo,[2,329]),n(Q,[2,332],{129:466,327:[1,467]}),n(vo,[2,55]),n(vo,[2,331]),{48:[1,468]},n(vd,[2,429]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(pl,[2,431]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,243:470,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(pl,[2,156]),{45:D2,89:L2,179:471},n(ml,[2,441]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,251:472,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(_r,[2,444],{256:473}),n(_r,[2,446],{258:474}),n(Jt,[2,442]),n(Jt,[2,443]),n(_r,[2,449]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,255:154,257:155,259:475,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Jt,[2,450]),n(Jt,[2,451]),n(Jt,[2,379],{178:476}),n(Jt,[2,378]),n([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:d,44:136,45:U,46:482,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{48:[1,483]},{48:[1,484]},n(Kt,[2,187]),n(on,[2,194]),{13:f,16:d,44:39,55:40,82:B,87:h,139:289,172:291,255:154,257:155,266:290,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,320:485},{13:f,16:d,39:[1,487],44:136,45:U,46:488,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,282:486,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(j2,[2,460]),{13:f,16:d,44:136,45:U,46:489,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Jt,[2,464]),{13:f,16:d,44:136,45:U,46:490,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Jt,[2,466]),n(te,[2,40]),n(Td,[2,298]),n(bu,[2,87]),n(bu,[2,88]),n(bu,[2,89]),n(bu,[2,90]),{13:f,16:d,55:492,82:B,172:493,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,311:494,312:sn,315:491},n(te,[2,41]),n(Id,[2,300]),n(Su,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:B,171:497,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},{31:[1,498],89:[1,499]},{29:[1,500]},n(xd,[2,372]),{13:f,16:d,48:[2,422],55:194,197:wt,223:312,226:502,228:501,229:N2,307:43,308:p},n(Xi,[2,131]),n(Xi,[2,126]),n(To,[2,22]),n(To,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:U,55:323,67:321,68:322,74:505,75:506,76:G2,77:320,78:q2,79:509,87:h,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:R,351:F},n(U2,[2,294]),n(W2,[2,69]),n(W2,[2,70]),n(Ct,Ue,{59:197,69:198,20:511,70:W}),n(X,J,{58:205,62:206,23:512,63:ke}),{29:[2,375],31:[2,71],84:522,85:o,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},n(ga,[2,363],{157:524,335:[1,525]}),n(l,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:h}),n(Fd,[2,399],{215:10,205:527,208:528,214:529,44:530,204:531,202:532,13:i,16:i,45:i,197:i,224:i,229:i,308:i,87:h}),{13:f,16:d,44:215,45:Cd,55:220,82:B,87:h,89:ct,172:221,185:351,203:536,212:534,231:Pd,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(l,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:h}),n(X,[2,23],{307:43,267:139,275:146,278:149,55:323,67:447,68:448,44:450,66:538,13:f,16:d,45:V2,87:h,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,276:Je,277:Le,279:Qe,280:Me,283:Ye,285:Ze,308:p,346:et,347:ze,348:T,349:x,350:R,351:F}),n(_a,[2,291]),n(_a,[2,24]),n(_a,[2,25]),{13:f,16:d,44:136,45:U,46:539,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(_a,[2,28]),n(X,J,{58:205,62:206,23:540,63:ke}),n([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),n(ya,[2,107]),{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,172:221,185:351,187:350,199:543,200:544,231:Pr,234:349,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(z2,[2,132]),n(Od,[2,425]),n(z2,[2,133]),{13:f,16:d,44:354,55:355,82:B,87:h,172:357,237:356,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:358,312:sn,313:545},n(Or,[2,54]),n(Or,[2,48]),n(ma,[2,342]),{13:f,16:d,44:39,55:40,87:h,139:546,307:43,308:p},n(ma,[2,68]),n(D,[2,350],{31:H2,112:H2}),n(Or,[2,53]),{13:f,16:d,55:547,307:43,308:p},n(Q,[2,333]),n(q,[2,16]),n(vd,[2,152]),n(pl,[2,154]),n(pl,[2,157]),n(ml,[2,159]),n(ml,[2,160],{262:389,261:548,39:Uy,338:Vy}),n(ml,[2,161],{262:389,261:549,39:Uy,338:Vy}),n(_r,[2,163]),{13:f,16:d,44:136,45:U,46:550,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Kt,[2,178]),n(Kt,[2,179]),{13:f,16:d,44:136,45:U,46:551,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,46:552,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,46:553,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{48:[1,554],272:[1,555]},n(Kt,[2,184]),n(Kt,[2,186]),{314:[1,556]},{48:[1,557]},{48:[2,461]},{48:[2,462]},{48:[1,558]},{48:[2,467],193:[1,561],287:559,288:560},{13:f,16:d,55:194,197:wt,223:562,307:43,308:p},n(qy,[2,224]),n(qy,[2,225]),n(qy,[2,226]),{31:[1,563],45:Q2,94:564},n(te,[2,84]),n(Td,[2,368]),n(te,[2,85]),n(Id,[2,370]),n(Su,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},n(To,[2,35],{83:[1,569]}),n(To,[2,36],{81:[1,570]}),n(jy,[2,30],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:509,44:510,75:571,13:f,16:d,45:U,76:G2,78:q2,87:h,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,276:Je,277:Le,279:Qe,280:Me,283:Ye,285:Ze,308:p,346:et,347:ze,348:T,349:x,350:R,351:F}),n(yl,[2,295]),{45:U,77:572},{45:U,77:573},n(yl,[2,33]),n(yl,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},n(ga,[2,356]),n(Y2,[2,357],{152:578,335:[1,579]}),n(Os,[2,74]),{29:z,57:580},{29:z,57:581},{13:f,16:d,44:39,55:40,87:h,139:582,307:43,308:p},n(X2,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:U,55:323,67:321,68:322,77:320,79:585,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:R,351:F},{45:[1,586]},n(Os,[2,81]),{29:z,57:587},n(ga,[2,73]),n(D,[2,362],{29:Fs,31:Fs,85:Fs,112:Fs,159:Fs,160:Fs,161:Fs,163:Fs,164:Fs}),n(Fd,[2,112]),n(_l,[2,401],{206:588}),n(D,[2,405],{209:589,210:590}),n(D,[2,403]),n(D,[2,404]),n(Fd,[2,113]),n(Fd,[2,400]),{13:f,16:d,44:215,45:Cd,48:[1,591],55:220,82:B,87:h,89:ct,172:221,185:351,203:536,212:592,231:Pd,234:535,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(Od,[2,426]),n(Gy,[2,138]),n(Gy,[2,139]),{232:[1,593]},n(_a,[2,292]),{47:[1,595],48:[1,594]},n(gl,[2,9]),n(ya,[2,392]),n(ya,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:h,197:pa,308:p}),n(ya,[2,110],{272:[1,598]}),n(Dd,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},n(vo,[2,58]),n(_r,[2,445]),n(_r,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},n(Kt,[2,99]),n(Jt,[2,382]),n([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),n(Kt,[2,188]),n(Kt,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:B,172:493,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,311:494,312:sn,315:611},n(te,[2,42]),n(Su,[2,304]),{13:f,16:d,55:414,82:B,95:612,171:613,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},{31:[1,614],45:Q2,94:615},n(Xi,[2,129]),n($2,[2,421]),{82:[1,616]},{82:[1,617]},n(yl,[2,296]),n(yl,[2,31]),n(yl,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},n(D,k2,{155:330,153:618,154:619,29:Ds,31:Ds,85:Ds,112:Ds,159:Ds,160:Ds,161:Ds,163:Ds,164:Ds}),n(Y2,[2,358]),n(Os,[2,75]),n(Os,[2,76]),{29:z,57:620},{13:f,16:d,44:39,55:40,87:h,139:621,307:43,308:p},n(X2,[2,366]),n(Os,[2,79]),{13:f,16:d,44:136,45:U,46:622,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Os,[2,91],{336:[1,623]}),n([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),n(_l,[2,117]),{13:f,16:d,44:215,45:Cd,55:220,82:B,87:h,89:ct,172:221,185:351,203:536,211:626,212:627,231:Pd,234:535,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(Ps,[2,134]),n(Od,[2,427]),n(Ps,[2,135]),n(_a,[2,26]),{44:628,87:h},n(ya,[2,106]),n(ya,[2,394]),n(D,[2,396]),n(Dd,[2,111]),n(Dd,[2,398]),{13:f,16:d,44:39,55:40,87:h,139:342,186:629,190:340,195:341,197:pa,307:43,308:p},n($y,[2,217]),n(D,wd,{144:248,140:630,143:631,31:[2,343]}),n(Kt,[2,97]),n(Jt,[2,380]),n(Kt,[2,180]),{13:f,16:d,44:136,45:U,46:632,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},{13:f,16:d,44:136,45:U,46:633,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:H,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:R,351:F},n(Kt,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:B,171:637,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:pe,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},n(K2,[2,305]),n(te,[2,86]),n(Su,[2,374]),n(To,[2,37]),n(To,[2,38]),n(ga,[2,72]),n(ga,[2,360]),n(Os,[2,77]),{29:z,57:638},{47:[1,639]},{29:[2,376]},n(_l,[2,402]),n(_l,[2,115],{215:10,208:528,214:529,44:530,205:640,13:i,16:i,45:i,197:i,224:i,229:i,308:i,87:h}),n(_l,[2,118],{272:[1,641]}),n(Ld,[2,407],{213:642,319:643,317:[1,644]}),{48:[1,645]},{318:[1,646]},{31:[1,647]},{31:[2,344]},{48:[1,648]},{48:[1,649]},{291:650,303:Te,304:Ie,305:fe,306:xe},n(bu,[2,218]),n(Su,[2,44]),n(K2,[2,306]),n(Os,[2,78]),{44:651,87:h},n(_l,[2,116]),n(D,[2,406]),n(Ld,[2,119]),n(Ld,[2,408]),n(l,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:h}),n(_a,[2,27]),n(Dd,[2,230]),n(J2,[2,345],{141:653,335:[1,654]}),n(Kt,[2,181]),n(Kt,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},n(D,wd,{144:248,142:657,143:658,31:Z2,112:Z2}),n(J2,[2,346]),n(Os,[2,80]),n(Ld,[2,231]),n(ma,[2,67]),n(ma,[2,348])],defaultActions:{5:[2,240],6:[2,241],7:[2,242],9:[2,239],24:[2,1],25:[2,2],26:[2,244],87:[2,282],94:[2,384],100:[2,45],109:[2,325],166:[2,458],263:[2,439],336:[2,258],337:[2,101],487:[2,461],488:[2,462],560:[2,468],574:[2,17],575:[2,276],576:[2,18],577:[2,278],623:[2,376],631:[2,344],650:[2,191]},parseError:a(function(C,O){if(O.recoverable)this.trace(C);else{var k=new Error(C);throw k.hash=O,k}},"parseError"),parse:a(function(C){var O=this,k=[0],le=[],je=[null],y=[],ln=this.table,b="",Zi=0,Tu=0,jd=0,$d=2,Iu=1,Ud=y.slice.call(arguments,1),Bt=Object.create(this.lexer),es={yy:{}};for(var xu in this.yy)Object.prototype.hasOwnProperty.call(this.yy,xu)&&(es.yy[xu]=this.yy[xu]);Bt.setInput(C,es.yy),es.yy.lexer=Bt,es.yy.parser=this,typeof Bt.yylloc>"u"&&(Bt.yylloc={});var El=Bt.yylloc;y.push(El);var vt=Bt.options&&Bt.options.ranges;typeof es.yy.parseError=="function"?this.parseError=es.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function jt(ts){k.length=k.length-2*ts,je.length=je.length-ts,y.length=y.length-ts}a(jt,"popStack");for(var ut=a(function(){var ts;return ts=Bt.lex()||Iu,typeof ts!="number"&&(ts=O.symbols_[ts]||ts),ts},"lex"),pt,In,va,Jn,vee,n0,Tl={},Vd,ks,fT,Bd;;){if(va=k[k.length-1],this.defaultActions[va]?Jn=this.defaultActions[va]:((pt===null||typeof pt>"u")&&(pt=ut()),Jn=ln[va]&&ln[va][pt]),typeof Jn>"u"||!Jn.length||!Jn[0]){var i0="";Bd=[];for(Vd in ln[va])this.terminals_[Vd]&&Vd>$d&&Bd.push("'"+this.terminals_[Vd]+"'");Bt.showPosition?i0="Parse error on line "+(Zi+1)+`:
33
+ `)}a(oj,"composeErrorMessage");function aj(n,e,t){let[,r=null]=n.toString().match(/constructor\(([\w, ]+)\)/)||[],i=sj(r,e);return oj(`Cannot inject the dependency ${i} of "${n.name}" constructor. Reason:`,t)}a(aj,"formatErrorCtor");Rh.formatErrorCtor=aj});var xI=S(Ch=>{"use strict";Object.defineProperty(Ch,"__esModule",{value:!0});Ch.isDisposable=void 0;function lj(n){return!(typeof n.dispose!="function"||n.dispose.length>0)}a(lj,"isDisposable");Ch.isDisposable=lj});var RI=S(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.PostResolutionInterceptors=Pa.PreResolutionInterceptors=void 0;var AI=R_(),Ph=class extends AI.default{static{a(this,"PreResolutionInterceptors")}};Pa.PreResolutionInterceptors=Ph;var Oh=class extends AI.default{static{a(this,"PostResolutionInterceptors")}};Pa.PostResolutionInterceptors=Oh;var L_=class{static{a(this,"Interceptors")}constructor(){this.preResolution=new Ph,this.postResolution=new Oh}};Pa.default=L_});var Ro=S(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.instance=Vs.typeInfo=void 0;var cj=(bh(),Gd(_h)),cn=I_(),uj=EI(),Fh=Th(),fj=TI(),Cn=b_(),Dh=II(),dj=D_(),hj=Eh(),pj=xI(),mj=RI();Vs.typeInfo=new Map;var N_=class n{static{a(this,"InternalDependencyContainer")}constructor(e){this.parent=e,this._registry=new fj.default,this.interceptors=new mj.default,this.disposed=!1,this.disposables=new Set}register(e,t,r={lifecycle:Cn.default.Transient}){this.ensureNotDisposed();let i;if(uj.isProvider(t)?i=t:i={useClass:t},cn.isTokenProvider(i)){let s=[e],o=i;for(;o!=null;){let l=o.useToken;if(s.includes(l))throw new Error(`Token registration cycle detected! ${[...s,l].join(" -> ")}`);s.push(l);let c=this._registry.get(l);c&&cn.isTokenProvider(c.provider)?o=c.provider:o=null}}if((r.lifecycle===Cn.default.Singleton||r.lifecycle==Cn.default.ContainerScoped||r.lifecycle==Cn.default.ResolutionScoped)&&(cn.isValueProvider(i)||cn.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Cn.default[r.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:r}),this}registerType(e,t){return this.ensureNotDisposed(),cn.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),cn.isNormalToken(e)){if(cn.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:Cn.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Cn.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let r=e;return t&&!cn.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:Cn.default.Singleton})}resolve(e,t=new Dh.default,r=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&cn.isNormalToken(e)){if(r)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(Fh.isConstructorToken(e)){let s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let r=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&r.push(i),i.callback(e,t);this.interceptors.preResolution.setAll(e,r)}}executePostResolutionInterceptor(e,t,r){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,t,r);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Cn.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===Cn.default.Singleton,i=e.options.lifecycle===Cn.default.ContainerScoped,s=r||i,o;return cn.isValueProvider(e.provider)?o=e.provider.useValue:cn.isTokenProvider(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):cn.isClassProvider(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):cn.isFactoryProvider(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===Cn.default.ResolutionScoped&&t.scopedResolutions.set(e,o),o}resolveAll(e,t=new Dh.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&cn.isNormalToken(e)){if(r)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let o=i.map(l=>this.resolveRegistration(l,t));return this.executePostResolutionInterceptor(e,o,"All"),o}let s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(r=>!cn.isValueProvider(r.provider)).map(r=>(r.instance=void 0,r)))}createChildContainer(){this.ensureNotDisposed();let e=new n(this);for(let[t,r]of this._registry.entries())r.some(({options:i})=>i.lifecycle===Cn.default.ContainerScoped)&&e._registry.setAll(t,r.map(i=>i.options.lifecycle===Cn.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,t,r={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:t,options:r})}afterResolution(e,t,r={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:t,options:r})}dispose(){return cj.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let r=t.dispose();r&&e.push(r)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,t){if(e instanceof hj.DelayedConstructor)return e.createProxy(i=>this.resolve(i,t));let r=(()=>{let i=Vs.typeInfo.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error(`TypeInfo not known for "${e.name}"`)}let s=i.map(this.resolveParams(t,e));return new e(...s)})();return pj.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(r,i)=>{try{return Fh.isTokenDescriptor(r)?Fh.isTransformDescriptor(r)?r.multiple?this.resolve(r.transform).transform(this.resolveAll(r.token,new Dh.default,r.isOptional),...r.transformArgs):this.resolve(r.transform).transform(this.resolve(r.token,e,r.isOptional),...r.transformArgs):r.multiple?this.resolveAll(r.token,new Dh.default,r.isOptional):this.resolve(r.token,e,r.isOptional):Fh.isTransformDescriptor(r)?this.resolve(r.transform,e).transform(this.resolve(r.token,e),...r.transformArgs):this.resolve(r,e)}catch(s){throw new Error(dj.formatErrorCtor(t,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};Vs.instance=new N_;Vs.default=Vs.instance});var CI=S(M_=>{"use strict";Object.defineProperty(M_,"__esModule",{value:!0});var gj=Ra(),Bs=Ro(),k_=Th(),yj=D_();function _j(){return function(n){let e=gj.getParamInfo(n);return class extends n{constructor(...t){super(...t.concat(e.slice(t.length).map((r,i)=>{try{return k_.isTokenDescriptor(r)?k_.isTransformDescriptor(r)?r.multiple?Bs.instance.resolve(r.transform).transform(Bs.instance.resolveAll(r.token),...r.transformArgs):Bs.instance.resolve(r.transform).transform(Bs.instance.resolve(r.token),...r.transformArgs):r.multiple?Bs.instance.resolveAll(r.token):Bs.instance.resolve(r.token):k_.isTransformDescriptor(r)?Bs.instance.resolve(r.transform).transform(Bs.instance.resolve(r.token),...r.transformArgs):Bs.instance.resolve(r)}catch(s){let o=i+t.length;throw new Error(yj.formatErrorCtor(n,o,s))}})))}}}}a(_j,"autoInjectable");M_.default=_j});var PI=S(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var bj=Ra();function Sj(n,e){let t={token:n,multiple:!1,isOptional:e&&e.isOptional};return bj.defineInjectionTokenMetadata(t)}a(Sj,"inject");j_.default=Sj});var Lh=S($_=>{"use strict";Object.defineProperty($_,"__esModule",{value:!0});var wj=Ra(),vj=Ro(),OI=Ro();function Ej(n){return function(e){vj.typeInfo.set(e,wj.getParamInfo(e)),n&&n.token&&(Array.isArray(n.token)?n.token.forEach(t=>{OI.instance.register(t,e)}):OI.instance.register(n.token,e))}}a(Ej,"injectable");$_.default=Ej});var FI=S(U_=>{"use strict";Object.defineProperty(U_,"__esModule",{value:!0});var Tj=(bh(),Gd(_h)),Ij=Ro();function xj(n=[]){return function(e){return n.forEach(t=>{var{token:r,options:i}=t,s=Tj.__rest(t,["token","options"]);return Ij.instance.register(r,s,i)}),e}}a(xj,"registry");U_.default=xj});var DI=S(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var Aj=Lh(),Rj=Ro();function Cj(){return function(n){Aj.default()(n),Rj.instance.registerSingleton(n)}}a(Cj,"singleton");V_.default=Cj});var LI=S(B_=>{"use strict";Object.defineProperty(B_,"__esModule",{value:!0});var Pj=Ra();function Oj(n,e){let t={token:n,multiple:!0,isOptional:e&&e.isOptional};return Pj.defineInjectionTokenMetadata(t)}a(Oj,"injectAll");B_.default=Oj});var NI=S(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});var Fj=Ra();function Dj(n,e,...t){let r={token:n,multiple:!0,transform:e,transformArgs:t};return Fj.defineInjectionTokenMetadata(r)}a(Dj,"injectAllWithTransform");G_.default=Dj});var kI=S(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var Lj=Ra();function Nj(n,e,...t){return Lj.defineInjectionTokenMetadata(n,{transformToken:e,args:t})}a(Nj,"injectWithTransform");q_.default=Nj});var MI=S(W_=>{"use strict";Object.defineProperty(W_,"__esModule",{value:!0});var kj=Lh(),Mj=Ro();function jj(n,e){return function(t){kj.default()(t),Mj.instance.register(e||t,t,{lifecycle:n})}}a(jj,"scoped");W_.default=jj});var jI=S(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});var $j=CI();Object.defineProperty(yi,"autoInjectable",{enumerable:!0,get:a(function(){return $j.default},"get")});var Uj=PI();Object.defineProperty(yi,"inject",{enumerable:!0,get:a(function(){return Uj.default},"get")});var Vj=Lh();Object.defineProperty(yi,"injectable",{enumerable:!0,get:a(function(){return Vj.default},"get")});var Bj=FI();Object.defineProperty(yi,"registry",{enumerable:!0,get:a(function(){return Bj.default},"get")});var Gj=DI();Object.defineProperty(yi,"singleton",{enumerable:!0,get:a(function(){return Gj.default},"get")});var qj=LI();Object.defineProperty(yi,"injectAll",{enumerable:!0,get:a(function(){return qj.default},"get")});var Wj=NI();Object.defineProperty(yi,"injectAllWithTransform",{enumerable:!0,get:a(function(){return Wj.default},"get")});var zj=kI();Object.defineProperty(yi,"injectWithTransform",{enumerable:!0,get:a(function(){return zj.default},"get")});var Hj=MI();Object.defineProperty(yi,"scoped",{enumerable:!0,get:a(function(){return Hj.default},"get")})});var $I=S(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});function Qj(n){let e;return t=>(e==null&&(e=n(t)),e)}a(Qj,"instanceCachingFactory");z_.default=Qj});var UI=S(H_=>{"use strict";Object.defineProperty(H_,"__esModule",{value:!0});function Yj(n){let e=new WeakMap;return t=>{let r=e.get(t);return r==null&&(r=n(t),e.set(t,r)),r}}a(Yj,"instancePerContainerCachingFactory");H_.default=Yj});var VI=S(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});function Xj(n,e,t,r=!0){let i,s;return o=>{let l=n(o);return(!r||s!==l)&&((s=l)?i=o.resolve(e):i=o.resolve(t)),i}}a(Xj,"predicateAwareClassFactory");Q_.default=Xj});var BI=S(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var Kj=$I();Object.defineProperty(zu,"instanceCachingFactory",{enumerable:!0,get:a(function(){return Kj.default},"get")});var Jj=UI();Object.defineProperty(zu,"instancePerContainerCachingFactory",{enumerable:!0,get:a(function(){return Jj.default},"get")});var Zj=VI();Object.defineProperty(zu,"predicateAwareClassFactory",{enumerable:!0,get:a(function(){return Zj.default},"get")})});var Oe=S(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});var Y_=(bh(),Gd(_h));if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var e9=vI();Object.defineProperty(Co,"Lifecycle",{enumerable:!0,get:a(function(){return e9.Lifecycle},"get")});Y_.__exportStar(jI(),Co);Y_.__exportStar(BI(),Co);Y_.__exportStar(I_(),Co);var t9=Eh();Object.defineProperty(Co,"delay",{enumerable:!0,get:a(function(){return t9.delay},"get")});var r9=Ro();Object.defineProperty(Co,"container",{enumerable:!0,get:a(function(){return r9.instance},"get")})});var Cl=S(Nh=>{"use strict";Object.defineProperty(Nh,"__esModule",{value:!0});Nh.NullLogger=void 0;Nh.NullLogger={debug(){},info(){},warn(){},error(){}}});var GI=S(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.registerUniversalDefaultLoader=n9;Po.clearUniversalDefaultLoader=i9;Po.clearUniversalDefault=s9;Po.loadUniversalDefault=o9;Po.mergePropertyDefaults=a9;Po.mergeInheritanceRules=l9;var kh=null,Gs,Hu=!1;function n9(n){kh=n,Gs=void 0,Hu=!1}a(n9,"registerUniversalDefaultLoader");function i9(){kh=null,Gs=void 0,Hu=!1}a(i9,"clearUniversalDefaultLoader");function s9(){Gs=void 0,Hu=!1}a(s9,"clearUniversalDefault");async function o9(){if(Gs!==void 0)return Gs;if(!kh)return Gs=null,null;try{Gs=await kh()??null}catch(n){Hu||(console.warn("[UniversalDefaultTemplateResolver] loader threw, falling back to legacy primitives:",n),Hu=!0),Gs=null}return Gs}a(o9,"loadUniversalDefault");function a9(n,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.propertyName);o?(r.push(o),i.add(o.propertyName)):r.push(s)}for(let s of e)i.has(s.propertyName)||r.push(s);return r}a(a9,"mergePropertyDefaults");function l9(n,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.targetPropertyName);o?(r.push(o),i.add(o.targetPropertyName)):r.push(s)}for(let s of e)i.has(s.targetPropertyName)||r.push(s);return r}a(l9,"mergeInheritanceRules")});var X_=S((Jne,qI)=>{var Pl=class{static{a(this,"Wildcard")}constructor(){return c9||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(Pl.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(Pl.prototype,"termType",{enumerable:!0,value:"Wildcard"});var c9=new Pl;qI.exports.Wildcard=Pl});var zI=S((eie,WI)=>{var u9=(function(){var n=a(function(P,R,F,k){for(F=F||{},k=P.length;k--;F[P[k]]=R);return F},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],r=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],l=[13,16,45,197,224,229,308],c=[28,29,53],u=[28,53],f=[1,42],d=[1,45],h=[1,41],p=[1,44],g=[123,126],_=[1,67],v=[39,45,87],w=[13,16,45,197,224,308],E=[1,87],I=[2,281],O=[1,86],C=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],H=[6,28,29,53,63,70,73,81,83,85],ne=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],de=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],N=[6,13,16,28,29,31,39,45,47,48,53,63,70,73,81,82,83,85,87,89,109,112,121,123,126,128,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,337,338,340,341,342,343,344,345,346],Y=[13,16,308],se=[112,132,327,334],V=[13,16,112,132,308],X=[1,111],re=[1,117],G=[112,132,327,328,334],ie=[13,16,112,132,308,328],q=[28,29,45,53,87],U=[1,138],B=[1,151],tt=[1,128],at=[1,127],Q=[1,129],De=[1,140],Be=[1,141],ae=[1,142],Xe=[1,143],Ke=[1,144],He=[1,145],Je=[1,147],Le=[1,148],Qe=[2,457],Me=[1,158],Ye=[1,159],Ze=[1,160],ge=[1,152],Se=[1,153],we=[1,156],ye=[1,171],_e=[1,172],be=[1,173],me=[1,174],ve=[1,175],Ee=[1,176],Te=[1,167],Ie=[1,168],fe=[1,169],xe=[1,170],st=[1,157],et=[1,166],ze=[1,161],T=[1,162],x=[1,163],A=[1,164],D=[1,165],te=[6,13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],wt=[1,195],Ct=[6,31,73,81,83,85],Ue=[2,285],W=[1,199],z=[1,201],K=[6,31,70,73,81,83,85],J=[2,283],ke=[1,207],lt=[1,218],ct=[1,223],Pr=[1,219],Tn=[1,225],Vn=[1,226],sn=[1,224],T2=[6,63,70,73,81,83,85],I2=[1,236],x2=[2,334],A2=[1,243],R2=[1,241],Or=[6,193],wd=[2,349],C2=[2,339],vo=[28,128],P2=[47,48,193,272],vd=[47,48,193,242,272],pl=[47,48,193,242,246,272],ml=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],_r=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],O2=[1,271],F2=[1,270],Kt=[6,13,16,29,31,39,45,47,48,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],D2=[1,281],L2=[1,280],on=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],yu=[45,89],Ed=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],Td=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Id=[31,89],xd=[48,87],ha=[6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338],Xi=[6,13,16,39,45,48,82,87,89,231,263,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338,340],N2=[1,313],gl=[6,85],jy=[6,31,81,83,85],k2=[2,361],Cs=[2,353],pa=[1,343],_u=[31,112,335],Ps=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],$y=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335],M2=[6,109,193],ma=[31,112],Jt=[13,16,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],Uy=[1,390],Vy=[1,391],Eo=[13,16,87,197,308,314],j2=[13,16,39,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],Ad=[1,417],Rd=[1,418],$2=[13,16,48,197,229,308],To=[6,31,85],U2=[6,13,16,31,45,73,81,83,85,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],By=[6,13,16,29,31,45,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,231,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,346,347,348,349,350,351],ga=[29,31,85,112,159,160,161,163,164],Cd=[1,443],Pd=[1,444],V2=[1,449],ya=[31,112,193,232,318,335],Od=[13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],B2=[13,16,31,45,48,82,87,89,112,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Gy=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],bu=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Su=[31,45],G2=[1,507],q2=[1,508],W2=[6,13,16,29,31,39,45,47,48,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,336,338,341,342,343,344,345,346,347,348,349,350,351],Fd=[29,31,85,112,159,160,161,163,164,335],_a=[6,13,16,31,45,70,73,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],z2=[13,16,31,45,48,82,87,89,112,193,197,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],H2=[2,352],qy=[13,16,197,308,314],Q2=[1,565],yl=[6,13,16,31,45,76,78,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Y2=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Os=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],X2=[13,16,87,308],Fs=[2,364],_l=[29,31,85,112,159,160,161,163,164,193,232,318,335],Dd=[31,112,193,232,272,318,335],Ds=[2,359],K2=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Ld=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],J2=[13,16,31,45,82,87,89,112,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Z2=[2,347],Wy={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Query:7,Qry:8,Query_option0:9,Prologue_repetition0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectClauseWildcard:17,Qry_repetition0:18,WhereClause:19,SolutionModifierNoGroup:20,SelectClauseVars:21,Qry_repetition1:22,SolutionModifier:23,CONSTRUCT:24,ConstructTemplate:25,Qry_repetition2:26,Qry_repetition3:27,WHERE:28,"{":29,Qry_option0:30,"}":31,DESCRIBE:32,Qry_group0:33,Qry_repetition4:34,Qry_option1:35,ASK:36,Qry_repetition5:37,SelectClauseBase:38,"*":39,SelectClauseVars_repetition_plus0:40,SELECT:41,SelectClauseBase_option0:42,SelectClauseItem:43,Var:44,"(":45,Expression:46,AS:47,")":48,SubSelect:49,SubSelect_option0:50,SubSelect_option1:51,DatasetClause:52,FROM:53,DatasetClause_option0:54,iri:55,WhereClause_option0:56,GroupGraphPattern:57,SolutionModifier_option0:58,SolutionModifierNoGroup_option0:59,SolutionModifierNoGroup_option1:60,SolutionModifierNoGroup_option2:61,GroupClause:62,GROUP:63,BY:64,GroupClause_repetition_plus0:65,GroupCondition:66,BuiltInCall:67,FunctionCall:68,HavingClause:69,HAVING:70,HavingClause_repetition_plus0:71,OrderClause:72,ORDER:73,OrderClause_repetition_plus0:74,OrderCondition:75,ASC:76,BrackettedExpression:77,DESC:78,Constraint:79,LimitOffsetClauses:80,LIMIT:81,INTEGER:82,OFFSET:83,ValuesClause:84,VALUES:85,InlineData:86,VAR:87,InlineData_repetition0:88,NIL:89,InlineData_repetition1:90,InlineData_repetition_plus2:91,InlineData_repetition3:92,DataBlock:93,DataBlockValueList:94,DataBlockValueList_repetition_plus0:95,Update:96,Update_repetition0:97,Update1:98,Update_option0:99,LOAD:100,Update1_option0:101,Update1_option1:102,Update1_group0:103,Update1_option2:104,GraphRefAll:105,Update1_group1:106,Update1_option3:107,GraphOrDefault:108,TO:109,CREATE:110,Update1_option4:111,GRAPH:112,INSERTDATA:113,QuadPattern:114,DELETEDATA:115,DELETEWHERE:116,Update1_option5:117,InsertDeleteClause:118,Update1_repetition0:119,IntoGraphClause:120,INTO:121,GraphRef:122,DELETE:123,InsertDeleteClause_option0:124,InsertClause:125,INSERT:126,UsingClause:127,USING:128,UsingClause_option0:129,WithClause:130,WITH:131,DEFAULT:132,GraphOrDefault_option0:133,GraphRefAll_group0:134,Quads:135,Quads_option0:136,Quads_repetition0:137,QuadsNotTriples:138,VarOrIri:139,QuadsNotTriples_option0:140,QuadsNotTriples_option1:141,QuadsNotTriples_option2:142,TriplesTemplate:143,TriplesTemplate_repetition0:144,TriplesSameSubject:145,TriplesTemplate_option0:146,GroupGraphPatternSub:147,GroupGraphPatternSub_option0:148,GroupGraphPatternSub_repetition0:149,GroupGraphPatternSubTail:150,GraphPatternNotTriples:151,GroupGraphPatternSubTail_option0:152,GroupGraphPatternSubTail_option1:153,TriplesBlock:154,TriplesBlock_repetition0:155,TriplesSameSubjectPath:156,TriplesBlock_option0:157,GroupOrUnionGraphPattern:158,OPTIONAL:159,MINUS:160,SERVICE:161,GraphPatternNotTriples_option0:162,FILTER:163,BIND:164,InlineDataOneVar:165,InlineDataFull:166,InlineDataOneVar_repetition0:167,InlineDataFull_repetition0:168,InlineDataFull_repetition_plus1:169,InlineDataFull_repetition2:170,DataBlockValue:171,Literal:172,QuotedTriple:173,UNDEF:174,GroupOrUnionGraphPattern_repetition0:175,ArgList:176,ArgList_option0:177,ArgList_repetition0:178,ExpressionList:179,ExpressionList_repetition0:180,ConstructTemplate_option0:181,ConstructTriples:182,ConstructTriples_repetition0:183,ConstructTriples_option0:184,VarOrTermOrQuotedTP:185,PropertyListNotEmpty:186,TriplesNode:187,PropertyList:188,PropertyList_option0:189,VerbObjectList:190,PropertyListNotEmpty_repetition0:191,SemiOptionalVerbObjectList:192,";":193,SemiOptionalVerbObjectList_option0:194,Verb:195,ObjectList:196,a:197,ObjectList_repetition0:198,Object:199,GraphNode:200,Object_option0:201,PropertyListPathNotEmpty:202,TriplesNodePath:203,TriplesSameSubjectPath_option0:204,O:205,PropertyListPathNotEmpty_repetition0:206,PropertyListPathNotEmptyTail:207,O_group0:208,ObjectListPath:209,ObjectListPath_repetition0:210,ObjectPath:211,GraphNodePath:212,ObjectPath_option0:213,Path:214,Path_repetition0:215,PathSequence:216,PathSequence_repetition0:217,PathEltOrInverse:218,PathElt:219,PathPrimary:220,PathElt_option0:221,PathEltOrInverse_option0:222,IriOrA:223,"!":224,PathNegatedPropertySet:225,PathOneInPropertySet:226,PathNegatedPropertySet_repetition0:227,PathNegatedPropertySet_option0:228,"^":229,TriplesNode_repetition_plus0:230,"[":231,"]":232,TriplesNodePath_repetition_plus0:233,VarOrTermOrQuotedTPExpr:234,VarOrTerm:235,GraphTerm:236,BlankNode:237,ConditionalOrExpression:238,ConditionalAndExpression:239,ConditionalOrExpression_repetition0:240,ConditionalOrExpressionTail:241,"||":242,RelationalExpression:243,ConditionalAndExpression_repetition0:244,ConditionalAndExpressionTail:245,"&&":246,NumericExpression:247,RelationalExpression_group0:248,RelationalExpression_option0:249,IN:250,MultiplicativeExpression:251,NumericExpression_repetition0:252,AdditiveExpressionTail:253,AdditiveExpressionTail_group0:254,NumericLiteralPositive:255,AdditiveExpressionTail_repetition0:256,NumericLiteralNegative:257,AdditiveExpressionTail_repetition1:258,UnaryExpression:259,MultiplicativeExpression_repetition0:260,MultiplicativeExpressionTail:261,MultiplicativeExpressionTail_group0:262,"+":263,PrimaryExpression:264,"-":265,ExprQuotedTP:266,Aggregate:267,FUNC_ARITY0:268,FUNC_ARITY1:269,FUNC_ARITY1_SPARQL_STAR:270,FUNC_ARITY2:271,",":272,FUNC_ARITY3:273,FUNC_ARITY3_SPARQL_STAR:274,BuiltInCall_group0:275,BOUND:276,BNODE:277,BuiltInCall_option0:278,EXISTS:279,COUNT:280,Aggregate_option0:281,Aggregate_group0:282,FUNC_AGGREGATE:283,Aggregate_option1:284,GROUP_CONCAT:285,Aggregate_option2:286,Aggregate_option3:287,GroupConcatSeparator:288,SEPARATOR:289,"=":290,String:291,LANGTAG:292,"^^":293,DECIMAL:294,DOUBLE:295,BOOLEAN:296,INTEGER_POSITIVE:297,DECIMAL_POSITIVE:298,DOUBLE_POSITIVE:299,INTEGER_NEGATIVE:300,DECIMAL_NEGATIVE:301,DOUBLE_NEGATIVE:302,STRING_LITERAL1:303,STRING_LITERAL2:304,STRING_LITERAL_LONG1:305,STRING_LITERAL_LONG2:306,PrefixedName:307,PNAME_LN:308,BLANK_NODE_LABEL:309,ANON:310,QuotedTP:311,"<<":312,qtSubjectOrObject:313,">>":314,DataValueTerm:315,AnnotationPattern:316,"{|":317,"|}":318,AnnotationPatternPath:319,ExprVarOrTerm:320,QueryOrUpdate_group0_option0:321,Prologue_repetition0_group0:322,Qry_group0_repetition_plus0:323,SelectClauseBase_option0_group0:324,DISTINCT:325,REDUCED:326,NAMED:327,SILENT:328,CLEAR:329,DROP:330,ADD:331,MOVE:332,COPY:333,ALL:334,".":335,UNION:336,"|":337,"/":338,PathElt_option0_group0:339,"?":340,"!=":341,"<":342,">":343,"<=":344,">=":345,NOT:346,CONCAT:347,COALESCE:348,SUBSTR:349,REGEX:350,REPLACE:351,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",24:"CONSTRUCT",28:"WHERE",29:"{",31:"}",32:"DESCRIBE",36:"ASK",39:"*",41:"SELECT",45:"(",47:"AS",48:")",53:"FROM",63:"GROUP",64:"BY",70:"HAVING",73:"ORDER",76:"ASC",78:"DESC",81:"LIMIT",82:"INTEGER",83:"OFFSET",85:"VALUES",87:"VAR",89:"NIL",100:"LOAD",109:"TO",110:"CREATE",112:"GRAPH",113:"INSERTDATA",115:"DELETEDATA",116:"DELETEWHERE",121:"INTO",123:"DELETE",126:"INSERT",128:"USING",131:"WITH",132:"DEFAULT",159:"OPTIONAL",160:"MINUS",161:"SERVICE",163:"FILTER",164:"BIND",174:"UNDEF",193:";",197:"a",224:"!",229:"^",231:"[",232:"]",242:"||",246:"&&",250:"IN",263:"+",265:"-",268:"FUNC_ARITY0",269:"FUNC_ARITY1",270:"FUNC_ARITY1_SPARQL_STAR",271:"FUNC_ARITY2",272:",",273:"FUNC_ARITY3",274:"FUNC_ARITY3_SPARQL_STAR",276:"BOUND",277:"BNODE",279:"EXISTS",280:"COUNT",283:"FUNC_AGGREGATE",285:"GROUP_CONCAT",289:"SEPARATOR",290:"=",292:"LANGTAG",293:"^^",294:"DECIMAL",295:"DOUBLE",296:"BOOLEAN",297:"INTEGER_POSITIVE",298:"DECIMAL_POSITIVE",299:"DOUBLE_POSITIVE",300:"INTEGER_NEGATIVE",301:"DECIMAL_NEGATIVE",302:"DOUBLE_NEGATIVE",303:"STRING_LITERAL1",304:"STRING_LITERAL2",305:"STRING_LITERAL_LONG1",306:"STRING_LITERAL_LONG2",308:"PNAME_LN",309:"BLANK_NODE_LABEL",310:"ANON",312:"<<",314:">>",317:"{|",318:"|}",325:"DISTINCT",326:"REDUCED",327:"NAMED",328:"SILENT",329:"CLEAR",330:"DROP",331:"ADD",332:"MOVE",333:"COPY",334:"ALL",335:".",336:"UNION",337:"|",338:"/",340:"?",341:"!=",342:"<",343:">",344:"<=",345:">=",346:"NOT",347:"CONCAT",348:"COALESCE",349:"SUBSTR",350:"REGEX",351:"REPLACE"},productions_:[0,[3,3],[7,2],[4,1],[11,2],[14,3],[8,4],[8,4],[8,5],[8,7],[8,5],[8,4],[17,2],[21,2],[38,2],[43,1],[43,5],[49,4],[49,4],[52,3],[19,2],[23,2],[20,3],[62,3],[66,1],[66,1],[66,3],[66,5],[66,1],[69,2],[72,3],[75,2],[75,2],[75,1],[75,1],[80,2],[80,2],[80,4],[80,4],[84,2],[86,4],[86,4],[86,6],[86,2],[94,3],[96,3],[98,4],[98,3],[98,5],[98,4],[98,2],[98,2],[98,2],[98,5],[120,2],[118,3],[118,1],[125,2],[127,3],[130,2],[108,1],[108,2],[122,2],[105,1],[105,1],[114,3],[135,2],[138,7],[143,3],[57,3],[57,3],[147,2],[150,3],[154,3],[151,1],[151,2],[151,2],[151,3],[151,4],[151,2],[151,6],[151,1],[93,1],[93,1],[165,4],[166,4],[166,6],[171,1],[171,1],[171,1],[171,1],[158,2],[79,1],[79,1],[79,1],[68,2],[176,1],[176,5],[179,1],[179,4],[25,3],[182,3],[145,2],[145,2],[188,1],[186,2],[192,2],[190,2],[195,1],[195,1],[196,2],[199,2],[156,2],[156,2],[202,2],[207,1],[207,2],[205,2],[209,2],[211,2],[214,2],[216,2],[219,2],[218,2],[220,1],[220,2],[220,3],[225,1],[225,1],[225,4],[226,1],[226,2],[187,3],[187,3],[203,3],[203,3],[200,1],[200,1],[212,1],[212,1],[234,1],[235,1],[235,1],[139,1],[139,1],[44,1],[236,1],[236,1],[236,1],[236,1],[46,1],[238,2],[241,2],[239,2],[245,2],[243,1],[243,3],[243,4],[247,2],[253,2],[253,2],[253,2],[251,2],[261,2],[259,2],[259,2],[259,2],[259,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[77,3],[67,1],[67,2],[67,4],[67,4],[67,6],[67,8],[67,8],[67,2],[67,4],[67,2],[67,4],[67,3],[267,5],[267,5],[267,6],[288,4],[172,1],[172,2],[172,3],[172,1],[172,1],[172,1],[172,1],[172,1],[172,1],[255,1],[255,1],[255,1],[257,1],[257,1],[257,1],[291,1],[291,1],[291,1],[291,1],[55,1],[55,1],[307,1],[307,1],[237,1],[237,1],[311,5],[173,5],[313,1],[313,1],[313,1],[313,1],[313,1],[315,1],[315,1],[315,1],[185,1],[185,1],[185,1],[316,3],[319,3],[266,5],[320,1],[320,1],[320,1],[223,1],[223,1],[321,0],[321,1],[5,1],[5,1],[5,1],[9,0],[9,1],[322,1],[322,1],[10,0],[10,2],[18,0],[18,2],[22,0],[22,2],[26,0],[26,2],[27,0],[27,2],[30,0],[30,1],[323,1],[323,2],[33,1],[33,1],[34,0],[34,2],[35,0],[35,1],[37,0],[37,2],[40,1],[40,2],[324,1],[324,1],[42,0],[42,1],[50,0],[50,1],[51,0],[51,1],[54,0],[54,1],[56,0],[56,1],[58,0],[58,1],[59,0],[59,1],[60,0],[60,1],[61,0],[61,1],[65,1],[65,2],[71,1],[71,2],[74,1],[74,2],[88,0],[88,2],[90,0],[90,2],[91,1],[91,2],[92,0],[92,2],[95,1],[95,2],[97,0],[97,4],[99,0],[99,2],[101,0],[101,1],[102,0],[102,1],[103,1],[103,1],[104,0],[104,1],[106,1],[106,1],[106,1],[107,0],[107,1],[111,0],[111,1],[117,0],[117,1],[119,0],[119,2],[124,0],[124,1],[129,0],[129,1],[133,0],[133,1],[134,1],[134,1],[134,1],[136,0],[136,1],[137,0],[137,2],[140,0],[140,1],[141,0],[141,1],[142,0],[142,1],[144,0],[144,3],[146,0],[146,1],[148,0],[148,1],[149,0],[149,2],[152,0],[152,1],[153,0],[153,1],[155,0],[155,3],[157,0],[157,1],[162,0],[162,1],[167,0],[167,2],[168,0],[168,2],[169,1],[169,2],[170,0],[170,2],[175,0],[175,3],[177,0],[177,1],[178,0],[178,3],[180,0],[180,3],[181,0],[181,1],[183,0],[183,3],[184,0],[184,1],[189,0],[189,1],[191,0],[191,2],[194,0],[194,1],[198,0],[198,3],[201,0],[201,1],[204,0],[204,1],[206,0],[206,2],[208,1],[208,1],[210,0],[210,3],[213,0],[213,1],[215,0],[215,3],[217,0],[217,3],[339,1],[339,1],[339,1],[221,0],[221,1],[222,0],[222,1],[227,0],[227,3],[228,0],[228,1],[230,1],[230,2],[233,1],[233,2],[240,0],[240,2],[244,0],[244,2],[248,1],[248,1],[248,1],[248,1],[248,1],[248,1],[249,0],[249,1],[252,0],[252,2],[254,1],[254,1],[256,0],[256,2],[258,0],[258,2],[260,0],[260,2],[262,1],[262,1],[275,1],[275,1],[275,1],[275,1],[275,1],[278,0],[278,1],[281,0],[281,1],[282,1],[282,1],[284,0],[284,1],[286,0],[286,1],[287,0],[287,1]],performAction:a(function(R,F,k,le,je,y,ln){var b=y.length-1;switch(je){case 1:if(y[b-1]=y[b-1]||{},Ge.base&&(y[b-1].base=Ge.base),Ge.base="",y[b-1].prefixes=Ge.prefixes,Ge.prefixes=null,Ge.pathOnly){if(y[b-1].type==="path"||"termType"in y[b-1])return y[b-1];throw new Error("Received full SPARQL query in path only mode")}else if(y[b-1].type==="path"||"termType"in y[b-1])throw new Error("Received only path in full SPARQL mode");if(y[b-1].type==="update"){let vt={};for(let jt of y[b-1].updates)if(jt.updateType==="insert"){let ut={};for(let pt of jt.insert)if(pt.type==="bgp"||pt.type==="graph")for(let In of pt.triples)In.subject.termType==="BlankNode"&&(ut[In.subject.value]=!0),In.predicate.termType==="BlankNode"&&(ut[In.predicate.value]=!0),In.object.termType==="BlankNode"&&(ut[In.object.value]=!0);for(let pt of Object.keys(ut)){if(vt[pt])throw new Error("Detected reuse blank node across different INSERT DATA clauses");vt[pt]=!0}}}return y[b-1];case 2:this.$={...y[b-1],...y[b],type:"query"};break;case 4:Ge.base=wu(y[b]);break;case 5:Ge.prefixes||(Ge.prefixes={}),y[b-1]=y[b-1].substr(0,y[b-1].length-1),y[b]=wu(y[b]),Ge.prefixes[y[b-1]]=y[b];break;case 6:this.$={...y[b-3],...wa(y[b-2]),...y[b-1],...y[b]};break;case 7:if(!Ge.skipValidation&&(Zy(y[b-3].variables.map(jt=>Jy(jt.expression))).some(jt=>jt.aggregation==="count"&&!(jt.expression instanceof Nd))||y[b].group)){for(let jt of y[b-3].variables)if(jt.termType==="Variable"){if(!y[b].group||!y[b].group.map(ut=>vl(ut)).includes(vl(jt)))throw Error("Projection of ungrouped variable (?"+vl(jt)+")")}else if(Jy(jt.expression).length===0){let ut=qN(jt.expression);for(let pt of ut)if(!y[b].group||!y[b].group.map||!y[b].group.map(In=>vl(In)).includes(vl(pt)))throw Error("Use of ungrouped variable in projection of operation (?"+vl(pt)+")")}}let es=y[b-1].where.filter(vt=>vt.type==="query");if(es.length>0){let vt=y[b-3].variables.filter(ut=>ut.variable&&ut.variable.value).map(ut=>ut.variable.value),jt=Zy(es.map(ut=>ut.variables)).map(ut=>ut.value||ut.variable.value);for(let ut of vt)if(jt.indexOf(ut)>=0)throw Error("Target id of 'AS' (?"+ut+") already used in subquery")}this.$=zt(y[b-3],wa(y[b-2]),y[b-1],y[b]);break;case 8:this.$=zt({queryType:"CONSTRUCT",template:y[b-3]},wa(y[b-2]),y[b-1],y[b]);break;case 9:this.$=zt({queryType:"CONSTRUCT",template:y[b-2]=y[b-2]?y[b-2].triples:[]},wa(y[b-5]),{where:[{type:"bgp",triples:Sa([],y[b-2])}]},y[b]);break;case 10:this.$=zt({queryType:"DESCRIBE",variables:y[b-3]==="*"?[new Nd]:y[b-3]},wa(y[b-2]),y[b-1],y[b]);break;case 11:this.$=zt({queryType:"ASK"},wa(y[b-2]),y[b-1],y[b]);break;case 12:this.$=zt(y[b-1],{variables:[new Nd]});break;case 13:let xu=y[b].map(vt=>vt.value||vt.variable.value),El=WN(xu);if(El.length>0)throw Error("Two or more of the resulting columns have the same name (?"+El[0]+")");this.$=zt(y[b-1],{variables:y[b]});break;case 14:this.$=zt({queryType:"SELECT"},y[b]&&(y[b-1]=an(y[b]),y[b]={},y[b][y[b-1]]=!0,y[b]));break;case 16:case 27:this.$=bl(y[b-3],{variable:y[b-1]});break;case 17:case 18:this.$=zt(y[b-3],y[b-2],y[b-1],y[b],{type:"query"});break;case 19:case 58:this.$={iri:y[b],named:!!y[b-1]};break;case 20:this.$={where:y[b].patterns};break;case 21:this.$=zt(y[b-1],y[b]);break;case 22:this.$=zt(y[b-2],y[b-1],y[b]);break;case 23:this.$={group:y[b]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=bl(y[b]);break;case 26:this.$=bl(y[b-1]);break;case 29:this.$={having:y[b]};break;case 30:this.$={order:y[b]};break;case 32:this.$=bl(y[b],{descending:!0});break;case 35:this.$={limit:wl(y[b])};break;case 36:this.$={offset:wl(y[b])};break;case 37:this.$={limit:wl(y[b-2]),offset:wl(y[b])};break;case 38:this.$={limit:wl(y[b]),offset:wl(y[b-2])};break;case 39:case 43:this.$={type:"values",values:y[b]};break;case 40:case 84:this.$=y[b-1].map(vt=>({[y[b-3]]:vt}));break;case 41:case 85:this.$=y[b-1].map(()=>({}));break;case 42:case 86:var Zi=y[b-4].length;y[b-4]=y[b-4].map(zy),this.$=y[b-1].map(function(vt){if(vt.length!==Zi)throw Error("Inconsistent VALUES length");for(var jt={},ut=0;ut<Zi;ut++)jt["?"+y[b-4][ut].value]=vt[ut];return jt});break;case 44:case 65:case 100:case 126:case 175:this.$=y[b-1];break;case 45:this.$={type:"update",updates:Ls(y[b-2],y[b-1])};break;case 46:this.$=zt({type:"load",silent:!!y[b-2],source:y[b-1]},y[b]&&{destination:y[b]});break;case 47:this.$={type:an(y[b-2]),silent:!!y[b-1],graph:y[b]};break;case 48:this.$={type:an(y[b-4]),silent:!!y[b-3],source:y[b-2],destination:y[b]};break;case 49:this.$={type:"create",silent:!!y[b-2],graph:{type:"graph",name:y[b]}};break;case 50:this.$={updateType:"insert",insert:uT(y[b])};break;case 51:this.$={updateType:"delete",delete:r0(uT(y[b]))};break;case 52:this.$={updateType:"deletewhere",delete:r0(y[b])};break;case 53:this.$={updateType:"insertdelete",...y[b-4],...y[b-3],...wa(y[b-2],"using"),where:y[b].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=y[b];break;case 55:this.$={delete:r0(y[b-1]),insert:y[b]||[]};break;case 56:this.$={delete:[],insert:y[b]};break;case 59:this.$={graph:y[b]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:y[b]};break;case 64:this.$={[an(y[b])]:!0};break;case 66:this.$=y[b-1]?Ki(y[b],[y[b-1]]):Ki(y[b]);break;case 67:var Tu=zt(y[b-3]||{triples:[]},{type:"graph",name:y[b-5]});this.$=y[b]?[Tu,y[b]]:[Tu];break;case 68:case 73:this.$={type:"bgp",triples:Ki(y[b-2],[y[b-1]])};break;case 69:this.$={type:"group",patterns:[y[b-1]]};break;case 70:for(let vt of y[b-1].filter(jt=>jt.type==="bind")){let jt=y[b-1].indexOf(vt),ut=new Set;for(let pt of y[b-1].slice(0,jt))(pt.type==="group"||pt.type==="bgp")&&lT(pt).forEach(In=>ut.add(In));if(ut.has(vt.variable.value))throw Error("Variable used to bind is already bound (?"+vt.variable.value+")")}this.$={type:"group",patterns:y[b-1]};break;case 71:this.$=y[b-1]?Ki([y[b-1]],y[b]):Ki(y[b]);break;case 72:this.$=y[b]?[y[b-2],y[b]]:y[b-2];break;case 75:this.$=zt(y[b],{type:"optional"});break;case 76:this.$=zt(y[b],{type:"minus"});break;case 77:this.$=zt(y[b],{type:"graph",name:y[b-1]});break;case 78:this.$=zt(y[b],{type:"service",name:y[b-1],silent:!!y[b-2]});break;case 79:this.$={type:"filter",expression:y[b]};break;case 80:this.$={type:"bind",variable:y[b-1],expression:y[b-3]};break;case 89:this.$=Eu(y[b]);break;case 90:this.$=void 0;break;case 91:this.$=y[b-1].length?{type:"union",patterns:Ki(y[b-1].map(Qy),[Qy(y[b])])}:y[b];break;case 95:this.$={...y[b],function:y[b-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:Ls(y[b-2],y[b-1]),distinct:!!y[b-3]};break;case 98:case 115:case 128:case 247:case 249:case 251:case 253:case 255:case 263:case 267:case 297:case 299:case 303:case 307:case 328:case 341:case 349:case 355:case 361:case 367:case 369:case 373:case 375:case 379:case 381:case 385:case 391:case 395:case 401:case 405:case 409:case 411:case 420:case 428:case 430:case 440:case 444:case 446:case 448:this.$=[];break;case 99:this.$=Ls(y[b-2],y[b-1]);break;case 101:this.$=Ki(y[b-2],[y[b-1]]);break;case 102:case 112:this.$=t0(y[b].map(vt=>zt(Ns(y[b-1]),vt)));break;case 103:this.$=t0(Sa(y[b].map(vt=>zt(Ns(y[b-1].entity),vt)),y[b-1].triples));break;case 105:this.$=Ki([y[b-1]],y[b]);break;case 106:this.$=Ki(y[b]);break;case 107:this.$=Ky(y[b-1],y[b]);break;case 109:case 237:this.$=Ge.factory.namedNode(LN);break;case 110:case 118:this.$=Ls(y[b-1],y[b]);break;case 111:this.$=y[b]?{annotation:y[b],object:y[b-1]}:y[b-1];break;case 113:this.$=y[b]?t0(Sa(y[b].map(vt=>zt(Ns(y[b-1].entity),vt)),y[b-1].triples)):y[b-1].triples;break;case 114:this.$=Ky(...y[b-1],y[b]);break;case 116:this.$=Ky(...y[b]);break;case 117:case 159:case 163:this.$=[y[b-1],y[b]];break;case 119:this.$=y[b]?{object:y[b-1],annotation:y[b]}:y[b-1];break;case 120:this.$=y[b-1].length?Sl("|",Ls(y[b-1],y[b])):y[b];break;case 121:this.$=y[b-1].length?Sl("/",Ls(y[b-1],y[b])):y[b];break;case 122:this.$=y[b]?Sl(y[b],[y[b-1]]):y[b-1];break;case 123:this.$=y[b-1]?Sl(y[b-1],[y[b]]):y[b];break;case 125:case 131:this.$=Sl(y[b-1],[y[b]]);break;case 129:this.$=Sl("|",Ls(y[b-2],y[b-1]));break;case 132:case 134:this.$=BN(y[b-1]);break;case 133:case 135:this.$=GN(y[b-1]);break;case 140:this.$={entity:y[b],triples:[]};break;case 145:this.$=zy(y[b]);break;case 149:this.$=Ge.factory.namedNode(eT);break;case 151:case 153:case 158:case 162:this.$=Hy(y[b-1],y[b]);break;case 152:this.$=["||",y[b]];break;case 154:this.$=["&&",y[b]];break;case 156:this.$=Fr(y[b-1],[y[b-2],y[b]]);break;case 157:this.$=Fr(y[b-2]?"notin":"in",[y[b-3],y[b]]);break;case 160:this.$=["+",Hy(y[b-1],y[b])];break;case 161:var jd=Ji(y[b-1].value.replace("-",""),y[b-1].datatype);this.$=["-",Hy(jd,y[b])];break;case 164:this.$=Fr("UPLUS",[y[b]]);break;case 165:this.$=Fr(y[b-1],[y[b]]);break;case 166:this.$=Fr("UMINUS",[y[b]]);break;case 177:this.$=Fr(an(y[b-1]));break;case 178:this.$=Fr(an(y[b-3]),[y[b-1]]);break;case 179:this.$=Eu(Fr(an(y[b-3]),[y[b-1]]));break;case 180:this.$=Fr(an(y[b-5]),[y[b-3],y[b-1]]);break;case 181:this.$=Fr(an(y[b-7]),[y[b-5],y[b-3],y[b-1]]);break;case 182:this.$=Eu(Fr(an(y[b-7]),[y[b-5],y[b-3],y[b-1]]));break;case 183:this.$=Fr(an(y[b-1]),y[b]);break;case 184:this.$=Fr("bound",[zy(y[b-1])]);break;case 185:this.$=Fr(y[b-1],[]);break;case 186:this.$=Fr(y[b-3],[y[b-1]]);break;case 187:this.$=Fr(y[b-2]?"notexists":"exists",[Qy(y[b])]);break;case 188:case 189:this.$=bl(y[b-1],{type:"aggregate",aggregation:an(y[b-4]),distinct:!!y[b-2]});break;case 190:this.$=bl(y[b-2],{type:"aggregate",aggregation:an(y[b-5]),distinct:!!y[b-3],separator:typeof y[b-1]=="string"?y[b-1]:" "});break;case 192:this.$=Ji(y[b]);break;case 193:this.$=jN(y[b-1],an(y[b].substr(1)));break;case 194:this.$=Ji(y[b-2],y[b]);break;case 195:case 204:this.$=Ji(y[b],tT);break;case 196:case 205:this.$=Ji(y[b],rT);break;case 197:case 206:this.$=Ji(an(y[b]),nT);break;case 200:this.$=Ji(y[b].toLowerCase(),MN);break;case 201:this.$=Ji(y[b].substr(1),tT);break;case 202:this.$=Ji(y[b].substr(1),rT);break;case 203:this.$=Ji(y[b].substr(1).toLowerCase(),nT);break;case 207:case 208:this.$=aT(y[b],1);break;case 209:case 210:this.$=aT(y[b],3);break;case 211:this.$=Ge.factory.namedNode(wu(y[b]));break;case 213:var $d=y[b].indexOf(":"),Iu=y[b].substr(0,$d),Ud=Ge.prefixes[Iu];if(!Ud)throw new Error("Unknown prefix: "+Iu);var Bt=wu(Ud+y[b].substr($d+1));this.$=Ge.factory.namedNode(Bt);break;case 214:if(y[b]=y[b].substr(0,y[b].length-1),!(y[b]in Ge.prefixes))throw new Error("Unknown prefix: "+y[b]);var Bt=wu(Ge.prefixes[y[b]]);this.$=Ge.factory.namedNode(Bt);break;case 215:this.$=vu(y[b].replace(/^(_:)/,""));break;case 216:this.$=vu();break;case 217:case 218:case 232:this.$=Eu(Yy(y[b-3],y[b-2],y[b-1]));break;case 230:case 231:this.$=Eu(y[b-1]);break;case 248:case 250:case 252:case 254:case 256:case 260:case 264:case 268:case 270:case 292:case 294:case 296:case 298:case 300:case 302:case 304:case 306:case 329:case 342:case 356:case 368:case 370:case 372:case 374:case 392:case 402:case 425:case 427:case 429:case 431:case 441:case 445:case 447:case 449:y[b-1].push(y[b]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[y[b]];break;case 308:y[b-3].push(y[b-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:y[b-2].push(y[b-1]);break}},"anonymous"),table:[n(e,t,{3:1,4:2,10:3}),{1:[3]},n(r,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),n([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:o},{6:[2,239]},n(l,[2,411],{216:28,217:29}),n(c,[2,249],{18:30}),n(c,[2,251],{22:31}),n(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:h,139:38,307:43,308:p,323:36},n(c,[2,267],{37:46}),n(g,[2,326],{98:47,103:49,106:50,117:55,130:61,100:[1,48],110:[1,51],113:[1,52],115:[1,53],116:[1,54],131:[1,62],329:[1,56],330:[1,57],331:[1,58],332:[1,59],333:[1,60]}),{39:[1,63],40:64,43:65,44:66,45:_,87:h},n(v,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),n(e,[2,248]),n(e,[2,245]),n(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),n(w,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:E,29:I,52:84,53:O,56:85},{19:88,28:E,29:I,52:89,53:O,56:85},n(c,[2,253],{26:90}),{28:[1,91],52:92,53:O},n(C,[2,385],{181:93,182:94,183:95,31:[2,383]}),n(H,[2,263],{34:96}),n(H,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:h,308:p}),n(H,[2,262]),n(ne,[2,259]),n(de,[2,143]),n(de,[2,144]),n([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),n(N,[2,211]),n(N,[2,212]),n(N,[2,213]),n(N,[2,214]),{19:98,28:E,29:I,52:99,53:O,56:85},{6:[2,309],99:100,193:[1,101]},n(Y,[2,311],{101:102,328:[1,103]}),n(se,[2,317],{104:104,328:[1,105]}),n(V,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:X,114:110},{29:X,114:112},{29:X,114:113},{118:114,123:[1,115],125:116,126:re},n(G,[2,315]),n(G,[2,316]),n(ie,[2,319]),n(ie,[2,320]),n(ie,[2,321]),n(g,[2,327]),{13:f,16:d,55:118,307:43,308:p},n(c,[2,12]),n(c,[2,13],{44:66,43:119,45:_,87:h}),n(q,[2,269]),n(q,[2,15]),{13:f,16:d,44:136,45:U,46:120,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(v,[2,14]),n(v,[2,274]),n(v,[2,271]),n(v,[2,272]),n(e,[2,4]),{13:[1,177]},n(te,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},n(l,[2,410]),n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:d,45:[1,193],55:194,197:wt,219:189,220:190,223:191,224:[1,192],307:43,308:p},n(w,[2,419]),n(Ct,Ue,{20:196,59:197,69:198,70:W}),n(c,[2,250]),{29:z,57:200},n(Y,[2,279],{54:202,327:[1,203]}),{29:[2,282]},n(K,J,{23:204,58:205,62:206,63:ke}),n(c,[2,252]),{19:208,28:E,29:I,52:209,53:O,56:85},{29:[1,210]},n(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,145:212,172:221,185:213,187:214,231:Pr,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(T2,[2,265],{56:85,35:227,52:228,19:229,28:E,29:I,53:O}),n(ne,[2,260]),n(K,J,{58:205,62:206,23:230,63:ke}),n(c,[2,268]),{6:[2,45]},n(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:p},n(Y,[2,312]),{105:233,112:I2,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},n(se,[2,318]),n(Y,x2,{108:240,133:242,112:A2,132:R2}),n(V,[2,323]),{112:[1,244]},{112:[2,325]},n(Or,[2,50]),n(C,wd,{135:245,136:246,143:247,144:248,31:C2,112:C2}),n(Or,[2,51]),n(Or,[2,52]),n(vo,[2,328],{119:249}),{29:X,114:250},n(vo,[2,56]),{29:X,114:251},n(g,[2,59]),n(q,[2,270]),{47:[1,252]},n(P2,[2,150]),n(vd,[2,428],{240:253}),n(pl,[2,430],{244:254}),n(pl,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),n(ml,[2,440],{252:264}),n(_r,[2,448],{260:265}),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,255:154,257:155,264:266,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,255:154,257:155,264:267,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,255:154,257:155,264:268,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(_r,[2,167]),n(_r,[2,168]),n(_r,[2,169]),n(_r,[2,170],{176:269,45:O2,89:F2}),n(_r,[2,171]),n(_r,[2,172]),n(_r,[2,173]),n(_r,[2,174]),{13:f,16:d,44:136,45:U,46:272,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Kt,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:D2,89:L2,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},n(on,[2,192],{292:[1,286],293:[1,287]}),n(on,[2,195]),n(on,[2,196]),n(on,[2,197]),n(on,[2,198]),n(on,[2,199]),n(on,[2,200]),{13:f,16:d,44:39,55:40,82:B,87:h,139:289,172:291,255:154,257:155,266:290,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},n(yu,[2,452]),n(yu,[2,453]),n(yu,[2,454]),n(yu,[2,455]),n(yu,[2,456]),{279:[2,458]},n(Ed,[2,207]),n(Ed,[2,208]),n(Ed,[2,209]),n(Ed,[2,210]),n(on,[2,201]),n(on,[2,202]),n(on,[2,203]),n(on,[2,204]),n(on,[2,205]),n(on,[2,206]),n(e,[2,5]),n(Td,[2,297],{88:295}),n(Id,[2,299],{90:296}),{48:[1,297],87:[1,298]},n(xd,[2,301]),n(te,[2,43]),n(te,[2,82]),n(te,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},n(l,[2,412]),n(ha,[2,123]),n(ha,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),n(Xi,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:wt,223:312,225:308,226:309,229:N2,307:43,308:p},n(l,i,{215:10,214:314}),n(Xi,[2,236]),n(Xi,[2,237]),n(gl,[2,6]),n(jy,[2,287],{60:315,72:316,73:[1,317]}),n(Ct,[2,286]),{13:f,16:d,45:U,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:A,351:D},n([6,31,63,70,73,81,83,85],[2,20]),n(C,k2,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:Cs,31:Cs,85:Cs,112:Cs,159:Cs,160:Cs,161:Cs,163:Cs,164:Cs,41:s}),{13:f,16:d,55:331,307:43,308:p},n(Y,[2,280]),n(gl,[2,7]),n(Ct,Ue,{59:197,69:198,20:332,70:W}),n(K,[2,284]),{64:[1,333]},n(K,J,{58:205,62:206,23:334,63:ke}),n(c,[2,254]),n(C,wd,{144:248,30:335,143:336,31:[2,257]}),n(c,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:h,139:342,186:339,190:340,195:341,197:pa,307:43,308:p},n(_u,[2,389],{44:39,55:40,307:43,190:340,195:341,139:342,188:344,189:345,186:346,13:f,16:d,87:h,197:pa,308:p}),n(Ps,[2,227]),n(Ps,[2,228]),n(Ps,[2,229]),{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,172:221,185:351,187:350,200:348,230:347,231:Pr,234:349,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},{13:f,16:d,44:39,55:40,87:h,139:342,186:352,190:340,195:341,197:pa,307:43,308:p},n(Ps,[2,146]),n(Ps,[2,147]),n(Ps,[2,148]),n(Ps,[2,149]),{13:f,16:d,44:354,55:355,82:B,87:h,172:357,237:356,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:358,312:sn,313:353},n($y,[2,215]),n($y,[2,216]),n(K,J,{58:205,62:206,23:359,63:ke}),n(H,[2,264]),n(T2,[2,266]),n(gl,[2,11]),n(r,[2,308],{6:[2,310]}),n(Or,[2,313],{102:360,120:361,121:[1,362]}),n(Or,[2,47]),n(Or,[2,63]),n(Or,[2,64]),{13:f,16:d,55:363,307:43,308:p},n(Or,[2,336]),n(Or,[2,337]),n(Or,[2,338]),{109:[1,364]},n(M2,[2,60]),{13:f,16:d,55:365,307:43,308:p},n(Y,[2,335]),{13:f,16:d,55:366,307:43,308:p},{31:[1,367]},n(ma,[2,341],{137:368}),n(ma,[2,340]),{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,145:369,172:221,185:213,187:214,231:Pr,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},{28:[1,370],127:371,128:[1,372]},n(vo,[2,330],{124:373,125:374,126:re}),n(vo,[2,57]),{44:375,87:h},n(P2,[2,151],{241:376,242:[1,377]}),n(vd,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,247:380,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{250:[1,381]},n(Jt,[2,432]),n(Jt,[2,433]),n(Jt,[2,434]),n(Jt,[2,435]),n(Jt,[2,436]),n(Jt,[2,437]),{250:[2,439]},n([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:ye,298:_e,299:be,300:me,301:ve,302:Ee}),n(ml,[2,162],{261:388,262:389,39:Uy,338:Vy}),n(_r,[2,164]),n(_r,[2,165]),n(_r,[2,166]),n(Kt,[2,95]),n(Kt,[2,96]),n(Jt,[2,377],{177:392,325:[1,393]}),{48:[1,394]},n(Kt,[2,177]),{13:f,16:d,44:136,45:U,46:395,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,46:396,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,46:397,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,46:398,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,46:399,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Kt,[2,183]),n(Kt,[2,98]),n(Jt,[2,381],{180:400}),{87:[1,401]},n(Kt,[2,185]),{13:f,16:d,44:136,45:U,46:402,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{29:z,57:403},n(on,[2,193]),{13:f,16:d,55:404,307:43,308:p},{13:f,16:d,44:39,55:40,87:h,139:342,195:405,197:pa,307:43,308:p},n(Eo,[2,233]),n(Eo,[2,234]),n(Eo,[2,235]),n(j2,[2,459],{281:406,325:[1,407]}),n(Jt,[2,463],{284:408,325:[1,409]}),n(Jt,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:B,171:413,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},{31:[1,419],89:[1,420]},{29:[1,421]},n(xd,[2,302]),n(Td,[2,367],{167:422}),n(Id,[2,369],{168:423}),{48:[1,424],87:[1,425]},n(xd,[2,371]),n(ha,[2,122]),n(ha,[2,417]),n(ha,[2,413]),n(ha,[2,414]),n(ha,[2,415]),n(Xi,[2,125]),n(Xi,[2,127]),n(Xi,[2,128]),n($2,[2,420],{227:426}),n(Xi,[2,130]),{13:f,16:d,55:194,197:wt,223:427,307:43,308:p},{48:[1,428]},n(To,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),n(jy,[2,288]),{64:[1,433]},n(Ct,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:f,16:d,45:U,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,276:Je,277:Le,279:Qe,280:Me,283:Ye,285:Ze,308:p,346:et,347:ze,348:T,349:x,350:A,351:D}),n(U2,[2,293]),n(By,[2,92]),n(By,[2,93]),n(By,[2,94]),{45:O2,89:F2,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:E,29:I,56:85},{19:438,28:E,29:I,56:85},n(ga,[2,355],{149:439}),n(ga,[2,354]),{13:f,16:d,44:215,45:Cd,55:220,82:B,87:h,89:ct,156:440,172:221,185:441,203:442,231:Pd,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(H,[2,19]),n(To,[2,21]),{13:f,16:d,44:450,45:V2,55:323,65:445,66:446,67:447,68:448,87:h,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:A,351:D},n(gl,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},n(C,[2,386],{31:[2,388]}),n(_u,[2,102]),n(ya,[2,391],{191:452}),n(C,[2,395],{196:453,198:454}),n(C,[2,108]),n(C,[2,109]),n(_u,[2,103]),n(_u,[2,104]),n(_u,[2,390]),{13:f,16:d,44:215,45:lt,48:[1,455],55:220,82:B,87:h,89:ct,172:221,185:351,187:350,200:456,231:Pr,234:349,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(Od,[2,424]),n(B2,[2,136]),n(B2,[2,137]),n(Gy,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:h,139:342,195:458,197:pa,307:43,308:p},n(Eo,[2,219]),n(Eo,[2,220]),n(Eo,[2,221]),n(Eo,[2,222]),n(Eo,[2,223]),n(gl,[2,10]),n(Or,[2,46]),n(Or,[2,314]),{112:I2,122:459},n(Or,[2,62]),n(Y,x2,{133:242,108:460,112:A2,132:R2}),n(M2,[2,61]),n(Or,[2,49]),n([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},n(ma,[2,351],{146:463,335:[1,464]}),{29:z,57:465},n(vo,[2,329]),n(Y,[2,332],{129:466,327:[1,467]}),n(vo,[2,55]),n(vo,[2,331]),{48:[1,468]},n(vd,[2,429]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(pl,[2,431]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,243:470,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(pl,[2,156]),{45:D2,89:L2,179:471},n(ml,[2,441]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,251:472,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(_r,[2,444],{256:473}),n(_r,[2,446],{258:474}),n(Jt,[2,442]),n(Jt,[2,443]),n(_r,[2,449]),{13:f,16:d,44:136,45:U,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,255:154,257:155,259:475,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Jt,[2,450]),n(Jt,[2,451]),n(Jt,[2,379],{178:476}),n(Jt,[2,378]),n([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:d,44:136,45:U,46:482,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{48:[1,483]},{48:[1,484]},n(Kt,[2,187]),n(on,[2,194]),{13:f,16:d,44:39,55:40,82:B,87:h,139:289,172:291,255:154,257:155,266:290,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,320:485},{13:f,16:d,39:[1,487],44:136,45:U,46:488,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,282:486,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(j2,[2,460]),{13:f,16:d,44:136,45:U,46:489,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Jt,[2,464]),{13:f,16:d,44:136,45:U,46:490,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Jt,[2,466]),n(te,[2,40]),n(Td,[2,298]),n(bu,[2,87]),n(bu,[2,88]),n(bu,[2,89]),n(bu,[2,90]),{13:f,16:d,55:492,82:B,172:493,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,311:494,312:sn,315:491},n(te,[2,41]),n(Id,[2,300]),n(Su,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:B,171:497,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},{31:[1,498],89:[1,499]},{29:[1,500]},n(xd,[2,372]),{13:f,16:d,48:[2,422],55:194,197:wt,223:312,226:502,228:501,229:N2,307:43,308:p},n(Xi,[2,131]),n(Xi,[2,126]),n(To,[2,22]),n(To,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:U,55:323,67:321,68:322,74:505,75:506,76:G2,77:320,78:q2,79:509,87:h,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:A,351:D},n(U2,[2,294]),n(W2,[2,69]),n(W2,[2,70]),n(Ct,Ue,{59:197,69:198,20:511,70:W}),n(K,J,{58:205,62:206,23:512,63:ke}),{29:[2,375],31:[2,71],84:522,85:o,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},n(ga,[2,363],{157:524,335:[1,525]}),n(l,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:h}),n(Fd,[2,399],{215:10,205:527,208:528,214:529,44:530,204:531,202:532,13:i,16:i,45:i,197:i,224:i,229:i,308:i,87:h}),{13:f,16:d,44:215,45:Cd,55:220,82:B,87:h,89:ct,172:221,185:351,203:536,212:534,231:Pd,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(l,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:h}),n(K,[2,23],{307:43,267:139,275:146,278:149,55:323,67:447,68:448,44:450,66:538,13:f,16:d,45:V2,87:h,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,276:Je,277:Le,279:Qe,280:Me,283:Ye,285:Ze,308:p,346:et,347:ze,348:T,349:x,350:A,351:D}),n(_a,[2,291]),n(_a,[2,24]),n(_a,[2,25]),{13:f,16:d,44:136,45:U,46:539,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(_a,[2,28]),n(K,J,{58:205,62:206,23:540,63:ke}),n([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),n(ya,[2,107]),{13:f,16:d,44:215,45:lt,55:220,82:B,87:h,89:ct,172:221,185:351,187:350,199:543,200:544,231:Pr,234:349,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(z2,[2,132]),n(Od,[2,425]),n(z2,[2,133]),{13:f,16:d,44:354,55:355,82:B,87:h,172:357,237:356,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:358,312:sn,313:545},n(Or,[2,54]),n(Or,[2,48]),n(ma,[2,342]),{13:f,16:d,44:39,55:40,87:h,139:546,307:43,308:p},n(ma,[2,68]),n(C,[2,350],{31:H2,112:H2}),n(Or,[2,53]),{13:f,16:d,55:547,307:43,308:p},n(Y,[2,333]),n(q,[2,16]),n(vd,[2,152]),n(pl,[2,154]),n(pl,[2,157]),n(ml,[2,159]),n(ml,[2,160],{262:389,261:548,39:Uy,338:Vy}),n(ml,[2,161],{262:389,261:549,39:Uy,338:Vy}),n(_r,[2,163]),{13:f,16:d,44:136,45:U,46:550,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Kt,[2,178]),n(Kt,[2,179]),{13:f,16:d,44:136,45:U,46:551,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,46:552,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,46:553,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{48:[1,554],272:[1,555]},n(Kt,[2,184]),n(Kt,[2,186]),{314:[1,556]},{48:[1,557]},{48:[2,461]},{48:[2,462]},{48:[1,558]},{48:[2,467],193:[1,561],287:559,288:560},{13:f,16:d,55:194,197:wt,223:562,307:43,308:p},n(qy,[2,224]),n(qy,[2,225]),n(qy,[2,226]),{31:[1,563],45:Q2,94:564},n(te,[2,84]),n(Td,[2,368]),n(te,[2,85]),n(Id,[2,370]),n(Su,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},n(To,[2,35],{83:[1,569]}),n(To,[2,36],{81:[1,570]}),n(jy,[2,30],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:509,44:510,75:571,13:f,16:d,45:U,76:G2,78:q2,87:h,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,276:Je,277:Le,279:Qe,280:Me,283:Ye,285:Ze,308:p,346:et,347:ze,348:T,349:x,350:A,351:D}),n(yl,[2,295]),{45:U,77:572},{45:U,77:573},n(yl,[2,33]),n(yl,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},n(ga,[2,356]),n(Y2,[2,357],{152:578,335:[1,579]}),n(Os,[2,74]),{29:z,57:580},{29:z,57:581},{13:f,16:d,44:39,55:40,87:h,139:582,307:43,308:p},n(X2,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:U,55:323,67:321,68:322,77:320,79:585,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,307:43,308:p,346:et,347:ze,348:T,349:x,350:A,351:D},{45:[1,586]},n(Os,[2,81]),{29:z,57:587},n(ga,[2,73]),n(C,[2,362],{29:Fs,31:Fs,85:Fs,112:Fs,159:Fs,160:Fs,161:Fs,163:Fs,164:Fs}),n(Fd,[2,112]),n(_l,[2,401],{206:588}),n(C,[2,405],{209:589,210:590}),n(C,[2,403]),n(C,[2,404]),n(Fd,[2,113]),n(Fd,[2,400]),{13:f,16:d,44:215,45:Cd,48:[1,591],55:220,82:B,87:h,89:ct,172:221,185:351,203:536,212:592,231:Pd,234:535,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(Od,[2,426]),n(Gy,[2,138]),n(Gy,[2,139]),{232:[1,593]},n(_a,[2,292]),{47:[1,595],48:[1,594]},n(gl,[2,9]),n(ya,[2,392]),n(ya,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:h,197:pa,308:p}),n(ya,[2,110],{272:[1,598]}),n(Dd,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},n(vo,[2,58]),n(_r,[2,445]),n(_r,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},n(Kt,[2,99]),n(Jt,[2,382]),n([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),n(Kt,[2,188]),n(Kt,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:B,172:493,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,311:494,312:sn,315:611},n(te,[2,42]),n(Su,[2,304]),{13:f,16:d,55:414,82:B,95:612,171:613,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},{31:[1,614],45:Q2,94:615},n(Xi,[2,129]),n($2,[2,421]),{82:[1,616]},{82:[1,617]},n(yl,[2,296]),n(yl,[2,31]),n(yl,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},n(C,k2,{155:330,153:618,154:619,29:Ds,31:Ds,85:Ds,112:Ds,159:Ds,160:Ds,161:Ds,163:Ds,164:Ds}),n(Y2,[2,358]),n(Os,[2,75]),n(Os,[2,76]),{29:z,57:620},{13:f,16:d,44:39,55:40,87:h,139:621,307:43,308:p},n(X2,[2,366]),n(Os,[2,79]),{13:f,16:d,44:136,45:U,46:622,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Os,[2,91],{336:[1,623]}),n([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),n(_l,[2,117]),{13:f,16:d,44:215,45:Cd,55:220,82:B,87:h,89:ct,172:221,185:351,203:536,211:626,212:627,231:Pd,234:535,236:216,237:222,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,309:Tn,310:Vn,311:217,312:sn},n(Ps,[2,134]),n(Od,[2,427]),n(Ps,[2,135]),n(_a,[2,26]),{44:628,87:h},n(ya,[2,106]),n(ya,[2,394]),n(C,[2,396]),n(Dd,[2,111]),n(Dd,[2,398]),{13:f,16:d,44:39,55:40,87:h,139:342,186:629,190:340,195:341,197:pa,307:43,308:p},n($y,[2,217]),n(C,wd,{144:248,140:630,143:631,31:[2,343]}),n(Kt,[2,97]),n(Jt,[2,380]),n(Kt,[2,180]),{13:f,16:d,44:136,45:U,46:632,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},{13:f,16:d,44:136,45:U,46:633,55:133,67:132,68:134,77:131,82:B,87:h,172:135,224:tt,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:at,264:130,265:Q,266:137,267:139,268:De,269:Be,270:ae,271:Xe,273:Ke,274:He,275:146,276:Je,277:Le,278:149,279:Qe,280:Me,283:Ye,285:Ze,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:st,346:et,347:ze,348:T,349:x,350:A,351:D},n(Kt,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:B,171:637,172:415,173:416,174:Ad,255:154,257:155,291:150,294:ge,295:Se,296:we,297:ye,298:_e,299:be,300:me,301:ve,302:Ee,303:Te,304:Ie,305:fe,306:xe,307:43,308:p,312:Rd},n(K2,[2,305]),n(te,[2,86]),n(Su,[2,374]),n(To,[2,37]),n(To,[2,38]),n(ga,[2,72]),n(ga,[2,360]),n(Os,[2,77]),{29:z,57:638},{47:[1,639]},{29:[2,376]},n(_l,[2,402]),n(_l,[2,115],{215:10,208:528,214:529,44:530,205:640,13:i,16:i,45:i,197:i,224:i,229:i,308:i,87:h}),n(_l,[2,118],{272:[1,641]}),n(Ld,[2,407],{213:642,319:643,317:[1,644]}),{48:[1,645]},{318:[1,646]},{31:[1,647]},{31:[2,344]},{48:[1,648]},{48:[1,649]},{291:650,303:Te,304:Ie,305:fe,306:xe},n(bu,[2,218]),n(Su,[2,44]),n(K2,[2,306]),n(Os,[2,78]),{44:651,87:h},n(_l,[2,116]),n(C,[2,406]),n(Ld,[2,119]),n(Ld,[2,408]),n(l,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:h}),n(_a,[2,27]),n(Dd,[2,230]),n(J2,[2,345],{141:653,335:[1,654]}),n(Kt,[2,181]),n(Kt,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},n(C,wd,{144:248,142:657,143:658,31:Z2,112:Z2}),n(J2,[2,346]),n(Os,[2,80]),n(Ld,[2,231]),n(ma,[2,67]),n(ma,[2,348])],defaultActions:{5:[2,240],6:[2,241],7:[2,242],9:[2,239],24:[2,1],25:[2,2],26:[2,244],87:[2,282],94:[2,384],100:[2,45],109:[2,325],166:[2,458],263:[2,439],336:[2,258],337:[2,101],487:[2,461],488:[2,462],560:[2,468],574:[2,17],575:[2,276],576:[2,18],577:[2,278],623:[2,376],631:[2,344],650:[2,191]},parseError:a(function(R,F){if(F.recoverable)this.trace(R);else{var k=new Error(R);throw k.hash=F,k}},"parseError"),parse:a(function(R){var F=this,k=[0],le=[],je=[null],y=[],ln=this.table,b="",Zi=0,Tu=0,jd=0,$d=2,Iu=1,Ud=y.slice.call(arguments,1),Bt=Object.create(this.lexer),es={yy:{}};for(var xu in this.yy)Object.prototype.hasOwnProperty.call(this.yy,xu)&&(es.yy[xu]=this.yy[xu]);Bt.setInput(R,es.yy),es.yy.lexer=Bt,es.yy.parser=this,typeof Bt.yylloc>"u"&&(Bt.yylloc={});var El=Bt.yylloc;y.push(El);var vt=Bt.options&&Bt.options.ranges;typeof es.yy.parseError=="function"?this.parseError=es.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function jt(ts){k.length=k.length-2*ts,je.length=je.length-ts,y.length=y.length-ts}a(jt,"popStack");for(var ut=a(function(){var ts;return ts=Bt.lex()||Iu,typeof ts!="number"&&(ts=F.symbols_[ts]||ts),ts},"lex"),pt,In,va,Jn,vee,n0,Tl={},Vd,ks,fT,Bd;;){if(va=k[k.length-1],this.defaultActions[va]?Jn=this.defaultActions[va]:((pt===null||typeof pt>"u")&&(pt=ut()),Jn=ln[va]&&ln[va][pt]),typeof Jn>"u"||!Jn.length||!Jn[0]){var i0="";Bd=[];for(Vd in ln[va])this.terminals_[Vd]&&Vd>$d&&Bd.push("'"+this.terminals_[Vd]+"'");Bt.showPosition?i0="Parse error on line "+(Zi+1)+`:
34
34
  `+Bt.showPosition()+`
35
- Expecting `+Bd.join(", ")+", got '"+(this.terminals_[pt]||pt)+"'":i0="Parse error on line "+(Zi+1)+": Unexpected "+(pt==Iu?"end of input":"'"+(this.terminals_[pt]||pt)+"'"),this.parseError(i0,{text:Bt.match,token:this.terminals_[pt]||pt,line:Bt.yylineno,loc:El,expected:Bd})}if(Jn[0]instanceof Array&&Jn.length>1)throw new Error("Parse Error: multiple actions possible at state: "+va+", token: "+pt);switch(Jn[0]){case 1:k.push(pt),je.push(Bt.yytext),y.push(Bt.yylloc),k.push(Jn[1]),pt=null,In?(pt=In,In=null):(Tu=Bt.yyleng,b=Bt.yytext,Zi=Bt.yylineno,El=Bt.yylloc,jd>0&&jd--);break;case 2:if(ks=this.productions_[Jn[1]][1],Tl.$=je[je.length-ks],Tl._$={first_line:y[y.length-(ks||1)].first_line,last_line:y[y.length-1].last_line,first_column:y[y.length-(ks||1)].first_column,last_column:y[y.length-1].last_column},vt&&(Tl._$.range=[y[y.length-(ks||1)].range[0],y[y.length-1].range[1]]),n0=this.performAction.apply(Tl,[b,Tu,Zi,es.yy,Jn[1],je,y].concat(Ud)),typeof n0<"u")return n0;ks&&(k=k.slice(0,-1*ks*2),je=je.slice(0,-1*ks),y=y.slice(0,-1*ks)),k.push(this.productions_[Jn[1]][0]),je.push(Tl.$),y.push(Tl._$),fT=ln[k[k.length-2]][k[k.length-1]],k.push(fT);break;case 3:return!0}}return!0},"parse")},Nd=X_().Wildcard,kd="http://www.w3.org/1999/02/22-rdf-syntax-ns#",LN=kd+"type",NN=kd+"first",kN=kd+"rest",eT=kd+"nil",Md="http://www.w3.org/2001/XMLSchema#",tT=Md+"integer",rT=Md+"decimal",nT=Md+"double",MN=Md+"boolean",ba="",iT="",sT="";function an(P){return P.toLowerCase()}a(an,"lowercase");function Ls(P,C){return P.push(C),P}a(Ls,"appendTo");function Sa(P,C){return P.push.apply(P,C),P}a(Sa,"appendAllTo");function zt(P){P||(P={});for(var C=1,O=arguments.length,k;C<O&&(k=arguments[C]||{});C++)for(var le in k)P[le]=k[le];return P}a(zt,"extend");function Ki(){for(var P=[],C=0,O=arguments.length;C<O;C++)P=P.concat.apply(P,arguments[C]);return P}a(Ki,"unionAll");function wu(P){if(P[0]==="<"&&(P=P.substring(1,P.length-1)),/^[a-z][a-z0-9.+-]*:/i.test(P))return P;if(!Ge.base)throw new Error("Cannot resolve relative IRI "+P+" because no base IRI was set.");switch(ba!==Ge.base&&(ba=Ge.base,iT=ba.replace(/[^\/:]*$/,""),sT=ba.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),P[0]){case void 0:return ba;case"#":return ba+P;case"?":return ba.replace(/(?:\?.*)?$/,P);case"/":return sT+P;default:return iT+P}}a(wu,"resolveIRI");function zy(P){if(P){var C=P[0];if(C==="?"||C==="$")return Ge.factory.variable(P.substr(1))}return P}a(zy,"toVar");function Fr(P,C){return{type:"operation",operator:P,args:C||[]}}a(Fr,"operation");function bl(P,C){var O={expression:P==="*"?new Nd:P};if(C)for(var k in C)O[k]=C[k];return O}a(bl,"expression");function Sl(P,C){return{type:"path",pathType:P,items:C}}a(Sl,"path");function Hy(P,C){for(var O=0,k=C.length,le;O<k&&(le=C[O]);O++)P=Fr(le[0],[P,le[1]]);return P}a(Hy,"createOperationTree");function wa(P,C){var O=[],k=[],le=P.length,je,y={};if(!le)return null;for(var ln=0;ln<le&&(je=P[ln]);ln++)(je.named?k:O).push(je.iri);return y[C||"from"]={default:O,named:k},y}a(wa,"groupDatasets");function wl(P){return parseInt(P,10)}a(wl,"toInt");function Qy(P){return P.type==="group"&&P.patterns.length===1?P.patterns[0]:P}a(Qy,"degroupSingle");function Ji(P,C){return C&&C.termType!=="NamedNode"&&(C=Ge.factory.namedNode(C)),Ge.factory.literal(P,C)}a(Ji,"createTypedLiteral");function jN(P,C){return Ge.factory.literal(P,C)}a(jN,"createLangLiteral");function Yy(P,C,O){if(!("termType"in C))throw new Error("Nested triples cannot contain paths");return Ge.factory.quad(P,C,O)}a(Yy,"nestedTriple");function Ns(P,C,O,k){var le={};return P!=null&&(le.subject=P),C!=null&&(le.predicate=C),O!=null&&(le.object=O),k!=null&&(le.annotations=k),le}a(Ns,"triple");function vu(P){return typeof P=="string"?P.startsWith("e_")?Ge.factory.blankNode(P):Ge.factory.blankNode("e_"+P):Ge.factory.blankNode("g_"+oT++)}a(vu,"blank");var oT=0;Ge._resetBlanks=function(){oT=0};var $N=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,UN={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
36
- `,r:"\r",f:"\f"},VN=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,Xy=String.fromCharCode;function aT(P,C){P=P.substring(C,P.length-C);try{P=P.replace($N,function(O,k,le,je){var y;if(k){if(y=parseInt(k,16),isNaN(y))throw new Error;return Xy(y)}else if(le){if(y=parseInt(le,16),isNaN(y))throw new Error;return y<65535?Xy(y):Xy(55296+((y-=65536)>>10),56320+(y&1023))}else{var ln=UN[je];if(!ln)throw new Error;return ln}})}catch{return""}if(VN.exec(P))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+P);return P}a(aT,"unescapeString");function BN(P){var C=vu(),O=C,k=[],le,je=[];P.forEach(function(Zi){k.push(Zi.entity),Sa(je,Zi.triples)});for(var y=0,ln=0,b=k.length,le=Array(b*2);y<b;)le[ln++]=Ns(O,Ge.factory.namedNode(NN),k[y]),le[ln++]=Ns(O,Ge.factory.namedNode(kN),O=++y<b?vu():Ge.factory.namedNode(eT));return{entity:C,triples:Sa(le,je)}}a(BN,"createList");function GN(P){var C=vu();return{entity:C,triples:P.map(function(O){return zt(Ns(C),O)})}}a(GN,"createAnonymousObject");function Ky(P,C,O){var k=[],le=[];return C.forEach(function(je){let y=null;je.annotation&&(y=je.annotation,je=je.object),k.push(Ns(null,P,je.entity,y)),Sa(le,je.triples)}),Ki(k,O||[],le)}a(Ky,"objectListToTriples");function See(P){for(var C=[],O,k=0,le;le=P[k];k++)switch(le.type){case"bgp":le.triples.length&&(O?Sa(O.triples,le.triples):Ls(C,O=le));break;default:(!le.patterns||le.patterns.length>0)&&(Ls(C,le),O=null)}return C}a(See,"mergeAdjacentBGPs");function vl(P){return P.variable?P.variable.value:P.value||P.expression.value}a(vl,"getExpressionId");function Jy(P){if(!P)return[];if(P.type==="aggregate")return[P];if(P.type==="operation"){let C=[];for(let O of P.args)C.push(...Jy(O));return C}return[]}a(Jy,"getAggregatesOfExpression");function qN(P){let C=new Set,O=a(function(k){k&&(k.termType==="Variable"?C.add(k):k.type==="operation"&&k.args.forEach(O))},"visitExpression");return O(P),C}a(qN,"getVariablesFromExpression");function Zy(P,C=1,O=[]){for(let k of P)C>0&&k instanceof Array?Zy(k,C-1,O):O.push(k);return O}a(Zy,"flatten");function e0(P){return P.termType==="Variable"}a(e0,"isVariable");function lT(P){if(P.triples){let C=[];for(let O of P.triples)e0(O.subject)&&C.push(O.subject.value),e0(O.predicate)&&C.push(O.predicate.value),e0(O.object)&&C.push(O.object.value);return C}else if(P.patterns){let C=[];for(let O of P.patterns)C.push(...lT(O));return C}return[]}a(lT,"getBoundVarsFromGroupGraphPattern");function WN(P){let C=P.slice().sort(),O=[];for(let k=0;k<C.length-1;k++)C[k+1]==C[k]&&O.push(C[k]);return O}a(WN,"getDuplicatesInArray");function Eu(P){if(!Ge.sparqlStar)throw new Error("SPARQL-star support is not enabled");return P}a(Eu,"ensureSparqlStar");function cT(P,C,O){for(let k of C){let le=Ns("subject"in k?k.subject:P,k.predicate,k.object);O.push(le),k.annotations&&cT(Yy(P,k.predicate,k.object),k.annotations,O)}}a(cT,"_applyAnnotations");function t0(P){if(Ge.sparqlStar){let C=[];return P.forEach(O=>{let k=Ns(O.subject,O.predicate,O.object);C.push(k),O.annotations&&cT(Yy(O.subject,O.predicate,O.object),O.annotations,C)}),C}return P}a(t0,"applyAnnotations");function wee(P){if(!Ge.sparqlStarNestedQuads)throw new Error("Lenient SPARQL-star support with nested quads is not enabled");return P}a(wee,"ensureSparqlStarNestedQuads");function uT(P){for(let C of P){if(C.type==="graph"&&C.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(C.type==="bgp"||C.type==="graph"){for(let O of C.triples)if(O.subject.termType==="Variable"||O.predicate.termType==="Variable"||O.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return P}a(uT,"ensureNoVariables");function r0(P){for(let C of P)if(C.type==="bgp"){for(let O of C.triples)if(O.subject.termType==="BlankNode"||O.predicate.termType==="BlankNode"||O.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return P}a(r0,"ensureNoBnodes");var zN=(function(){var P={EOF:1,parseError:a(function(O,k){if(this.yy.parser)this.yy.parser.parseError(O,k);else throw new Error(O)},"parseError"),setInput:a(function(C,O){return this.yy=O||this.yy||{},this._input=C,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:a(function(){var C=this._input[0];this.yytext+=C,this.yyleng++,this.offset++,this.match+=C,this.matched+=C;var O=C.match(/(?:\r\n?|\n).*/g);return O?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),C},"input"),unput:a(function(C){var O=C.length,k=C.split(/(?:\r\n?|\n)/g);this._input=C+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-O),this.offset-=O;var le=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),k.length-1&&(this.yylineno-=k.length-1);var je=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:k?(k.length===le.length?this.yylloc.first_column:0)+le[le.length-k.length].length-k[0].length:this.yylloc.first_column-O},this.options.ranges&&(this.yylloc.range=[je[0],je[0]+this.yyleng-O]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
37
- `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:a(function(C){this.unput(this.match.slice(C))},"less"),pastInput:a(function(){var C=this.matched.substr(0,this.matched.length-this.match.length);return(C.length>20?"...":"")+C.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var C=this.match;return C.length<20&&(C+=this._input.substr(0,20-C.length)),(C.substr(0,20)+(C.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var C=this.pastInput(),O=new Array(C.length+1).join("-");return C+this.upcomingInput()+`
38
- `+O+"^"},"showPosition"),test_match:a(function(C,O){var k,le,je;if(this.options.backtrack_lexer&&(je={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(je.yylloc.range=this.yylloc.range.slice(0))),le=C[0].match(/(?:\r\n?|\n).*/g),le&&(this.yylineno+=le.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:le?le[le.length-1].length-le[le.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+C[0].length},this.yytext+=C[0],this.match+=C[0],this.matches=C,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(C[0].length),this.matched+=C[0],k=this.performAction.call(this,this.yy,this,O,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),k)return k;if(this._backtrack){for(var y in je)this[y]=je[y];return!1}return!1},"test_match"),next:a(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var C,O,k,le;this._more||(this.yytext="",this.match="");for(var je=this._currentRules(),y=0;y<je.length;y++)if(k=this._input.match(this.rules[je[y]]),k&&(!O||k[0].length>O[0].length)){if(O=k,le=y,this.options.backtrack_lexer){if(C=this.test_match(k,je[y]),C!==!1)return C;if(this._backtrack){O=!1;continue}else return!1}else if(!this.options.flex)break}return O?(C=this.test_match(O,je[le]),C!==!1?C:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
39
- `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:a(function(){var O=this.next();return O||this.lex()},"lex"),begin:a(function(O){this.conditionStack.push(O)},"begin"),popState:a(function(){var O=this.conditionStack.length-1;return O>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:a(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:a(function(O){return O=this.conditionStack.length-1-Math.abs(O||0),O>=0?this.conditionStack[O]:"INITIAL"},"topState"),pushState:a(function(O){this.begin(O)},"pushState"),stateStackSize:a(function(){return this.conditionStack.length},"stateStackSize"),options:{flex:!0,"case-insensitive":!0},performAction:a(function(O,k,le,je){var y=je;switch(le){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(k.yytext);break}},"anonymous"),rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};return P})();Wy.lexer=zN;function Ge(){this.yy={}}return a(Ge,"Parser"),Ge.prototype=Wy,Wy.Parser=Ge,new Ge})();WI.exports=u9});var XI=S((rie,YI)=>{var f9="http://www.w3.org/2001/XMLSchema#integer",d9="http://www.w3.org/2001/XMLSchema#string";function Pt(n){this._options=n=n||{};var e=n.prefixes||{};this._prefixByIri={};var t=[];for(var r in e){var i=e[r];Qu(i)&&(this._prefixByIri[i]=r,t.push(i))}var s=t.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=n.sparqlStar,this._indent=Qu(n.indent)?n.indent:" ",this._newline=Qu(n.newline)?n.newline:`
35
+ Expecting `+Bd.join(", ")+", got '"+(this.terminals_[pt]||pt)+"'":i0="Parse error on line "+(Zi+1)+": Unexpected "+(pt==Iu?"end of input":"'"+(this.terminals_[pt]||pt)+"'"),this.parseError(i0,{text:Bt.match,token:this.terminals_[pt]||pt,line:Bt.yylineno,loc:El,expected:Bd})}if(Jn[0]instanceof Array&&Jn.length>1)throw new Error("Parse Error: multiple actions possible at state: "+va+", token: "+pt);switch(Jn[0]){case 1:k.push(pt),je.push(Bt.yytext),y.push(Bt.yylloc),k.push(Jn[1]),pt=null,In?(pt=In,In=null):(Tu=Bt.yyleng,b=Bt.yytext,Zi=Bt.yylineno,El=Bt.yylloc,jd>0&&jd--);break;case 2:if(ks=this.productions_[Jn[1]][1],Tl.$=je[je.length-ks],Tl._$={first_line:y[y.length-(ks||1)].first_line,last_line:y[y.length-1].last_line,first_column:y[y.length-(ks||1)].first_column,last_column:y[y.length-1].last_column},vt&&(Tl._$.range=[y[y.length-(ks||1)].range[0],y[y.length-1].range[1]]),n0=this.performAction.apply(Tl,[b,Tu,Zi,es.yy,Jn[1],je,y].concat(Ud)),typeof n0<"u")return n0;ks&&(k=k.slice(0,-1*ks*2),je=je.slice(0,-1*ks),y=y.slice(0,-1*ks)),k.push(this.productions_[Jn[1]][0]),je.push(Tl.$),y.push(Tl._$),fT=ln[k[k.length-2]][k[k.length-1]],k.push(fT);break;case 3:return!0}}return!0},"parse")},Nd=X_().Wildcard,kd="http://www.w3.org/1999/02/22-rdf-syntax-ns#",LN=kd+"type",NN=kd+"first",kN=kd+"rest",eT=kd+"nil",Md="http://www.w3.org/2001/XMLSchema#",tT=Md+"integer",rT=Md+"decimal",nT=Md+"double",MN=Md+"boolean",ba="",iT="",sT="";function an(P){return P.toLowerCase()}a(an,"lowercase");function Ls(P,R){return P.push(R),P}a(Ls,"appendTo");function Sa(P,R){return P.push.apply(P,R),P}a(Sa,"appendAllTo");function zt(P){P||(P={});for(var R=1,F=arguments.length,k;R<F&&(k=arguments[R]||{});R++)for(var le in k)P[le]=k[le];return P}a(zt,"extend");function Ki(){for(var P=[],R=0,F=arguments.length;R<F;R++)P=P.concat.apply(P,arguments[R]);return P}a(Ki,"unionAll");function wu(P){if(P[0]==="<"&&(P=P.substring(1,P.length-1)),/^[a-z][a-z0-9.+-]*:/i.test(P))return P;if(!Ge.base)throw new Error("Cannot resolve relative IRI "+P+" because no base IRI was set.");switch(ba!==Ge.base&&(ba=Ge.base,iT=ba.replace(/[^\/:]*$/,""),sT=ba.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),P[0]){case void 0:return ba;case"#":return ba+P;case"?":return ba.replace(/(?:\?.*)?$/,P);case"/":return sT+P;default:return iT+P}}a(wu,"resolveIRI");function zy(P){if(P){var R=P[0];if(R==="?"||R==="$")return Ge.factory.variable(P.substr(1))}return P}a(zy,"toVar");function Fr(P,R){return{type:"operation",operator:P,args:R||[]}}a(Fr,"operation");function bl(P,R){var F={expression:P==="*"?new Nd:P};if(R)for(var k in R)F[k]=R[k];return F}a(bl,"expression");function Sl(P,R){return{type:"path",pathType:P,items:R}}a(Sl,"path");function Hy(P,R){for(var F=0,k=R.length,le;F<k&&(le=R[F]);F++)P=Fr(le[0],[P,le[1]]);return P}a(Hy,"createOperationTree");function wa(P,R){var F=[],k=[],le=P.length,je,y={};if(!le)return null;for(var ln=0;ln<le&&(je=P[ln]);ln++)(je.named?k:F).push(je.iri);return y[R||"from"]={default:F,named:k},y}a(wa,"groupDatasets");function wl(P){return parseInt(P,10)}a(wl,"toInt");function Qy(P){return P.type==="group"&&P.patterns.length===1?P.patterns[0]:P}a(Qy,"degroupSingle");function Ji(P,R){return R&&R.termType!=="NamedNode"&&(R=Ge.factory.namedNode(R)),Ge.factory.literal(P,R)}a(Ji,"createTypedLiteral");function jN(P,R){return Ge.factory.literal(P,R)}a(jN,"createLangLiteral");function Yy(P,R,F){if(!("termType"in R))throw new Error("Nested triples cannot contain paths");return Ge.factory.quad(P,R,F)}a(Yy,"nestedTriple");function Ns(P,R,F,k){var le={};return P!=null&&(le.subject=P),R!=null&&(le.predicate=R),F!=null&&(le.object=F),k!=null&&(le.annotations=k),le}a(Ns,"triple");function vu(P){return typeof P=="string"?P.startsWith("e_")?Ge.factory.blankNode(P):Ge.factory.blankNode("e_"+P):Ge.factory.blankNode("g_"+oT++)}a(vu,"blank");var oT=0;Ge._resetBlanks=function(){oT=0};var $N=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,UN={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
36
+ `,r:"\r",f:"\f"},VN=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,Xy=String.fromCharCode;function aT(P,R){P=P.substring(R,P.length-R);try{P=P.replace($N,function(F,k,le,je){var y;if(k){if(y=parseInt(k,16),isNaN(y))throw new Error;return Xy(y)}else if(le){if(y=parseInt(le,16),isNaN(y))throw new Error;return y<65535?Xy(y):Xy(55296+((y-=65536)>>10),56320+(y&1023))}else{var ln=UN[je];if(!ln)throw new Error;return ln}})}catch{return""}if(VN.exec(P))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+P);return P}a(aT,"unescapeString");function BN(P){var R=vu(),F=R,k=[],le,je=[];P.forEach(function(Zi){k.push(Zi.entity),Sa(je,Zi.triples)});for(var y=0,ln=0,b=k.length,le=Array(b*2);y<b;)le[ln++]=Ns(F,Ge.factory.namedNode(NN),k[y]),le[ln++]=Ns(F,Ge.factory.namedNode(kN),F=++y<b?vu():Ge.factory.namedNode(eT));return{entity:R,triples:Sa(le,je)}}a(BN,"createList");function GN(P){var R=vu();return{entity:R,triples:P.map(function(F){return zt(Ns(R),F)})}}a(GN,"createAnonymousObject");function Ky(P,R,F){var k=[],le=[];return R.forEach(function(je){let y=null;je.annotation&&(y=je.annotation,je=je.object),k.push(Ns(null,P,je.entity,y)),Sa(le,je.triples)}),Ki(k,F||[],le)}a(Ky,"objectListToTriples");function See(P){for(var R=[],F,k=0,le;le=P[k];k++)switch(le.type){case"bgp":le.triples.length&&(F?Sa(F.triples,le.triples):Ls(R,F=le));break;default:(!le.patterns||le.patterns.length>0)&&(Ls(R,le),F=null)}return R}a(See,"mergeAdjacentBGPs");function vl(P){return P.variable?P.variable.value:P.value||P.expression.value}a(vl,"getExpressionId");function Jy(P){if(!P)return[];if(P.type==="aggregate")return[P];if(P.type==="operation"){let R=[];for(let F of P.args)R.push(...Jy(F));return R}return[]}a(Jy,"getAggregatesOfExpression");function qN(P){let R=new Set,F=a(function(k){k&&(k.termType==="Variable"?R.add(k):k.type==="operation"&&k.args.forEach(F))},"visitExpression");return F(P),R}a(qN,"getVariablesFromExpression");function Zy(P,R=1,F=[]){for(let k of P)R>0&&k instanceof Array?Zy(k,R-1,F):F.push(k);return F}a(Zy,"flatten");function e0(P){return P.termType==="Variable"}a(e0,"isVariable");function lT(P){if(P.triples){let R=[];for(let F of P.triples)e0(F.subject)&&R.push(F.subject.value),e0(F.predicate)&&R.push(F.predicate.value),e0(F.object)&&R.push(F.object.value);return R}else if(P.patterns){let R=[];for(let F of P.patterns)R.push(...lT(F));return R}return[]}a(lT,"getBoundVarsFromGroupGraphPattern");function WN(P){let R=P.slice().sort(),F=[];for(let k=0;k<R.length-1;k++)R[k+1]==R[k]&&F.push(R[k]);return F}a(WN,"getDuplicatesInArray");function Eu(P){if(!Ge.sparqlStar)throw new Error("SPARQL-star support is not enabled");return P}a(Eu,"ensureSparqlStar");function cT(P,R,F){for(let k of R){let le=Ns("subject"in k?k.subject:P,k.predicate,k.object);F.push(le),k.annotations&&cT(Yy(P,k.predicate,k.object),k.annotations,F)}}a(cT,"_applyAnnotations");function t0(P){if(Ge.sparqlStar){let R=[];return P.forEach(F=>{let k=Ns(F.subject,F.predicate,F.object);R.push(k),F.annotations&&cT(Yy(F.subject,F.predicate,F.object),F.annotations,R)}),R}return P}a(t0,"applyAnnotations");function wee(P){if(!Ge.sparqlStarNestedQuads)throw new Error("Lenient SPARQL-star support with nested quads is not enabled");return P}a(wee,"ensureSparqlStarNestedQuads");function uT(P){for(let R of P){if(R.type==="graph"&&R.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(R.type==="bgp"||R.type==="graph"){for(let F of R.triples)if(F.subject.termType==="Variable"||F.predicate.termType==="Variable"||F.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return P}a(uT,"ensureNoVariables");function r0(P){for(let R of P)if(R.type==="bgp"){for(let F of R.triples)if(F.subject.termType==="BlankNode"||F.predicate.termType==="BlankNode"||F.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return P}a(r0,"ensureNoBnodes");var zN=(function(){var P={EOF:1,parseError:a(function(F,k){if(this.yy.parser)this.yy.parser.parseError(F,k);else throw new Error(F)},"parseError"),setInput:a(function(R,F){return this.yy=F||this.yy||{},this._input=R,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:a(function(){var R=this._input[0];this.yytext+=R,this.yyleng++,this.offset++,this.match+=R,this.matched+=R;var F=R.match(/(?:\r\n?|\n).*/g);return F?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),R},"input"),unput:a(function(R){var F=R.length,k=R.split(/(?:\r\n?|\n)/g);this._input=R+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-F),this.offset-=F;var le=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),k.length-1&&(this.yylineno-=k.length-1);var je=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:k?(k.length===le.length?this.yylloc.first_column:0)+le[le.length-k.length].length-k[0].length:this.yylloc.first_column-F},this.options.ranges&&(this.yylloc.range=[je[0],je[0]+this.yyleng-F]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
37
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:a(function(R){this.unput(this.match.slice(R))},"less"),pastInput:a(function(){var R=this.matched.substr(0,this.matched.length-this.match.length);return(R.length>20?"...":"")+R.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var R=this.match;return R.length<20&&(R+=this._input.substr(0,20-R.length)),(R.substr(0,20)+(R.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var R=this.pastInput(),F=new Array(R.length+1).join("-");return R+this.upcomingInput()+`
38
+ `+F+"^"},"showPosition"),test_match:a(function(R,F){var k,le,je;if(this.options.backtrack_lexer&&(je={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(je.yylloc.range=this.yylloc.range.slice(0))),le=R[0].match(/(?:\r\n?|\n).*/g),le&&(this.yylineno+=le.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:le?le[le.length-1].length-le[le.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+R[0].length},this.yytext+=R[0],this.match+=R[0],this.matches=R,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(R[0].length),this.matched+=R[0],k=this.performAction.call(this,this.yy,this,F,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),k)return k;if(this._backtrack){for(var y in je)this[y]=je[y];return!1}return!1},"test_match"),next:a(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var R,F,k,le;this._more||(this.yytext="",this.match="");for(var je=this._currentRules(),y=0;y<je.length;y++)if(k=this._input.match(this.rules[je[y]]),k&&(!F||k[0].length>F[0].length)){if(F=k,le=y,this.options.backtrack_lexer){if(R=this.test_match(k,je[y]),R!==!1)return R;if(this._backtrack){F=!1;continue}else return!1}else if(!this.options.flex)break}return F?(R=this.test_match(F,je[le]),R!==!1?R:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
39
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:a(function(){var F=this.next();return F||this.lex()},"lex"),begin:a(function(F){this.conditionStack.push(F)},"begin"),popState:a(function(){var F=this.conditionStack.length-1;return F>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:a(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:a(function(F){return F=this.conditionStack.length-1-Math.abs(F||0),F>=0?this.conditionStack[F]:"INITIAL"},"topState"),pushState:a(function(F){this.begin(F)},"pushState"),stateStackSize:a(function(){return this.conditionStack.length},"stateStackSize"),options:{flex:!0,"case-insensitive":!0},performAction:a(function(F,k,le,je){var y=je;switch(le){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(k.yytext);break}},"anonymous"),rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};return P})();Wy.lexer=zN;function Ge(){this.yy={}}return a(Ge,"Parser"),Ge.prototype=Wy,Wy.Parser=Ge,new Ge})();WI.exports=u9});var XI=S((rie,YI)=>{var f9="http://www.w3.org/2001/XMLSchema#integer",d9="http://www.w3.org/2001/XMLSchema#string";function Pt(n){this._options=n=n||{};var e=n.prefixes||{};this._prefixByIri={};var t=[];for(var r in e){var i=e[r];Qu(i)&&(this._prefixByIri[i]=r,t.push(i))}var s=t.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=n.sparqlStar,this._indent=Qu(n.indent)?n.indent:" ",this._newline=Qu(n.newline)?n.newline:`
40
40
  `,this._explicitDatatype=!!n.explicitDatatype}a(Pt,"Generator");Pt.prototype.toQuery=function(n){var e="";return n.queryType&&(e+=n.queryType.toUpperCase()+" "),n.reduced&&(e+="REDUCED "),n.distinct&&(e+="DISTINCT "),n.variables?e+=Gn(n.variables,void 0,function(t){return/^[?$]/.test(t)?t:Oo(t)?this.toEntity(t):"("+this.toExpression(t.expression)+" AS "+Mh(t.variable)+")"},this)+" ":n.template&&(e+=this.group(n.template,!0)+this._newline),n.from&&(e+=this.graphs("FROM ",n.from.default)+this.graphs("FROM NAMED ",n.from.named)),n.where&&(e+="WHERE "+this.group(n.where,!0)+this._newline),n.updates&&(e+=Gn(n.updates,";"+this._newline,this.toUpdate,this)),n.group&&(e+="GROUP BY "+Gn(n.group,void 0,function(t){var r=Oo(t.expression)?this.toEntity(t.expression):"("+this.toExpression(t.expression)+")";return t.variable?"("+r+" AS "+Mh(t.variable)+")":r},this)+this._newline),n.having&&(e+="HAVING ("+Gn(n.having,void 0,this.toExpression,this)+")"+this._newline),n.order&&(e+="ORDER BY "+Gn(n.order,void 0,function(t){var r="("+this.toExpression(t.expression)+")";return t.descending?"DESC "+r:r},this)+this._newline),n.offset&&(e+="OFFSET "+n.offset+this._newline),n.limit&&(e+="LIMIT "+n.limit+this._newline),n.values&&(e+=this.values(n)),e=this.baseAndPrefixes(n)+e,e.trim()};Pt.prototype.baseAndPrefixes=function(n){var e=n.base?"BASE <"+n.base+">"+this._newline:"",t="";for(var r in n.prefixes)(this._options.allPrefixes||this._usedPrefixes[r])&&(t+="PREFIX "+r+": <"+n.prefixes[r]+">"+this._newline);return e+t};Pt.prototype.toPattern=function(n){var e=n.type||n instanceof Array&&"array"||(n.subject&&n.predicate&&n.object?"triple":"");if(!(e in this))throw new Error("Unknown entry type: "+e);return this[e](n)};Pt.prototype.triple=function(n){return this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+"."};Pt.prototype.array=function(n){return Gn(n,this._newline,this.toPattern,this)};Pt.prototype.bgp=function(n){return this.encodeTriples(n.triples)};Pt.prototype.encodeTriples=function(n){if(!n.length)return"";for(var e=[],t=void 0,r=void 0,i=0;i<n.length;i++){var s=n[i];Oa(s.subject,t)?Oa(s.predicate,r)?e.push(","):(r=s.predicate,e.push(";"+this._newline,this._indent,this.toEntity(r))):(t&&e.push("."+this._newline),t=s.subject,r=s.predicate,e.push(this.toEntity(t)," ",this.toEntity(r))),e.push(" ",this.toEntity(s.object))}return e.push("."),e.join("")};Pt.prototype.graph=function(n){return"GRAPH "+this.toEntity(n.name)+" "+this.group(n)};Pt.prototype.graphs=function(n,e){return!e||e.length===0?"":Gn(e,"",function(t){return n+this.toEntity(t)+this._newline},this)};Pt.prototype.group=function(n,e){return n=e!==!0?this.array(n.patterns||n.triples):this.toPattern(n.type!=="group"?n:n.patterns),n.indexOf(this._newline)===-1?"{ "+n+" }":"{"+this._newline+this.indent(n)+this._newline+"}"};Pt.prototype.query=function(n){return this.toQuery(n)};Pt.prototype.filter=function(n){return"FILTER("+this.toExpression(n.expression)+")"};Pt.prototype.bind=function(n){return"BIND("+this.toExpression(n.expression)+" AS "+Mh(n.variable)+")"};Pt.prototype.optional=function(n){return"OPTIONAL "+this.group(n)};Pt.prototype.union=function(n){return Gn(n.patterns,this._newline+"UNION"+this._newline,function(e){return this.group(e,!0)},this)};Pt.prototype.minus=function(n){return"MINUS "+this.group(n)};Pt.prototype.values=function(n){var e=Object.keys(n.values.reduce(function(i,s){for(var o in s)i[o]=!0;return i},{})),t,r;return e.length===1?t=r="":(t="(",r=")"),"VALUES "+t+e.join(" ")+r+" {"+this._newline+Gn(n.values,this._newline,function(i){return" "+t+Gn(e,void 0,function(s){return i[s]?this.toEntity(i[s]):"UNDEF"},this)+r},this)+this._newline+"}"};Pt.prototype.service=function(n){return"SERVICE "+(n.silent?"SILENT ":"")+this.toEntity(n.name)+" "+this.group(n)};Pt.prototype.toExpression=function(n){if(Oo(n))return this.toEntity(n);switch(n.type.toLowerCase()){case"aggregate":return n.aggregation.toUpperCase()+"("+(n.distinct?"DISTINCT ":"")+this.toExpression(n.expression)+(typeof n.separator=="string"?'; SEPARATOR = "'+n.separator.replace(HI,QI)+'"':"")+")";case"functioncall":return this.toEntity(n.function)+"("+Gn(n.args,", ",this.toExpression,this)+")";case"operation":var e=n.operator.toUpperCase(),t=n.args||[];switch(n.operator.toLowerCase()){case"<":case">":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(Oo(t[0])?this.toEntity(t[0]):"("+this.toExpression(t[0])+")")+" "+e+" "+(Oo(t[1])?this.toEntity(t[1]):"("+this.toExpression(t[1])+")");case"!":return"!("+this.toExpression(t[0])+")";case"uplus":return"+("+this.toExpression(t[0])+")";case"uminus":return"-("+this.toExpression(t[0])+")";case"notin":e="NOT IN";case"in":return this.toExpression(t[0])+" "+e+"("+(Qu(t[1])?t[1]:Gn(t[1],", ",this.toExpression,this))+")";case"notexists":e="NOT EXISTS";case"exists":return e+" "+this.group(t[0],!0);default:return e+"("+Gn(t,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+n.type)}};Pt.prototype.toEntity=function(n){if(Oo(n))switch(n.termType){case"Wildcard":return"*";case"Variable":return Mh(n);case"BlankNode":return"_:"+n.value;case"Literal":var e=n.value||"",t=n.language||"",r=n.datatype;if(n='"'+e.replace(HI,QI)+'"',t)n+="@"+t;else if(r){if(!this._explicitDatatype)switch(r.value){case d9:return n;case f9:if(/^\d+$/.test(e))return e+" "}n+="^^"+this.encodeIRI(r.value)}return n;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return n.graph&&n.graph.termType!=="DefaultGraph"?"<< GRAPH "+this.toEntity(n.graph)+" { "+this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+" } >>":"<< "+this.toEntity(n.subject)+" "+this.toEntity(n.predicate)+" "+this.toEntity(n.object)+" >>";default:return this.encodeIRI(n.value)}else{var i=n.items.map(this.toEntity,this),s=n.pathType;switch(s){case"^":case"!":return s+i[0];case"*":case"+":case"?":return"("+i[0]+s+")";default:return"("+i.join(s)+")"}}};var HI=/["\\\t\n\r\b\f]/g,QI=a(function(n){return h9[n]},"escapeReplacer"),h9={"\\":"\\\\",'"':'\\"'," ":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};Pt.prototype.encodeIRI=function(n){var e=this._prefixRegex.exec(n);if(e){var t=this._prefixByIri[e[1]];return this._usedPrefixes[t]=!0,t+":"+e[2]}return"<"+n+">"};Pt.prototype.toUpdate=function(n){switch(n.type||n.updateType){case"load":return"LOAD"+(n.source?" "+this.toEntity(n.source):"")+(n.destination?" INTO GRAPH "+this.toEntity(n.destination):"");case"insert":return"INSERT DATA "+this.group(n.insert,!0);case"delete":return"DELETE DATA "+this.group(n.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(n.delete,!0);case"insertdelete":return(n.graph?"WITH "+this.toEntity(n.graph)+this._newline:"")+(n.delete.length?"DELETE "+this.group(n.delete,!0)+this._newline:"")+(n.insert.length?"INSERT "+this.group(n.insert,!0)+this._newline:"")+(n.using?this.graphs("USING ",n.using.default):"")+(n.using?this.graphs("USING NAMED ",n.using.named):"")+"WHERE "+this.group(n.where,!0);case"add":case"copy":case"move":return n.type.toUpperCase()+" "+(n.silent?"SILENT ":"")+(n.source.default?"DEFAULT":this.toEntity(n.source.name))+" TO "+this.toEntity(n.destination.name);case"create":case"clear":case"drop":return n.type.toUpperCase()+(n.silent?" SILENT ":" ")+(n.graph.default?"DEFAULT":n.graph.named?"NAMED":n.graph.all?"ALL":"GRAPH "+this.toEntity(n.graph.name));default:throw new Error("Unknown update query type: "+n.type)}};Pt.prototype.indent=function(n){return n.replace(/^/gm,this._indent)};function Mh(n){return"?"+n.value}a(Mh,"variableToString");function Qu(n){return typeof n=="string"}a(Qu,"isString");function Oo(n){return typeof n.termType=="string"}a(Oo,"isTerm");function Oa(n,e){if(!n||!Oo(n)||!e||!Oo(e)||n.termType!==e.termType)return!1;switch(n.termType){case"Literal":return n.value===e.value&&n.language===e.language&&Oa(n.datatype,e.datatype);case"Quad":return Oa(n.subject,e.subject)&&Oa(n.predicate,e.predicate)&&Oa(n.object,e.object)&&Oa(n.graph,e.graph);default:return n.value===e.value}}a(Oa,"equalTerms");function Gn(n,e,t,r){return n.map(t,r).join(Qu(e)?e:" ")}a(Gn,"mapJoin");function p9(n={}){return{stringify:a(function(e){var t=Object.create(n);return t.prefixes=e.prefixes,new Pt(t).toQuery(e)},"stringify"),createGenerator:a(function(){return new Pt(n)},"createGenerator")}}a(p9,"_Generator");YI.exports={Generator:p9}});var J_=S(jh=>{"use strict";Object.defineProperty(jh,"__esModule",{value:!0});jh.BlankNode=void 0;var K_=class{static{a(this,"BlankNode")}constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&e.termType==="BlankNode"&&e.value===this.value}};jh.BlankNode=K_});var Z_=S($h=>{"use strict";Object.defineProperty($h,"__esModule",{value:!0});$h.DefaultGraph=void 0;var Yu=class{static{a(this,"DefaultGraph")}constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&e.termType==="DefaultGraph"}};$h.DefaultGraph=Yu;Yu.INSTANCE=new Yu});var Vh=S(Uh=>{"use strict";Object.defineProperty(Uh,"__esModule",{value:!0});Uh.NamedNode=void 0;var eb=class{static{a(this,"NamedNode")}constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&e.termType==="NamedNode"&&e.value===this.value}};Uh.NamedNode=eb});var tb=S(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});Bh.Literal=void 0;var KI=Vh(),Xu=class n{static{a(this,"Literal")}constructor(e,t){this.termType="Literal",this.value=e,typeof t=="string"?(this.language=t,this.datatype=n.RDF_LANGUAGE_STRING):t?(this.language="",this.datatype=t):(this.language="",this.datatype=n.XSD_STRING)}equals(e){return!!e&&e.termType==="Literal"&&e.value===this.value&&e.language===this.language&&this.datatype.equals(e.datatype)}};Bh.Literal=Xu;Xu.RDF_LANGUAGE_STRING=new KI.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");Xu.XSD_STRING=new KI.NamedNode("http://www.w3.org/2001/XMLSchema#string")});var nb=S(Gh=>{"use strict";Object.defineProperty(Gh,"__esModule",{value:!0});Gh.Quad=void 0;var rb=class{static{a(this,"Quad")}constructor(e,t,r,i){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=i}equals(e){return!!e&&(e.termType==="Quad"||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}};Gh.Quad=rb});var sb=S(qh=>{"use strict";Object.defineProperty(qh,"__esModule",{value:!0});qh.Variable=void 0;var ib=class{static{a(this,"Variable")}constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&e.termType==="Variable"&&e.value===this.value}};qh.Variable=ib});var ZI=S(Wh=>{"use strict";Object.defineProperty(Wh,"__esModule",{value:!0});Wh.DataFactory=void 0;var m9=J_(),g9=Z_(),JI=tb(),y9=Vh(),_9=nb(),b9=sb(),S9=0,ob=class{static{a(this,"DataFactory")}constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${S9++}_`}namedNode(e){return new y9.NamedNode(e)}blankNode(e){return new m9.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new JI.Literal(e,t)}variable(e){return new b9.Variable(e)}defaultGraph(){return g9.DefaultGraph.INSTANCE}quad(e,t,r,i){return new _9.Quad(e,t,r,i||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(JI.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}};Wh.DataFactory=ob});var ex=S(qn=>{"use strict";var w9=qn&&qn.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),Fa=qn&&qn.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&w9(e,n,t)};Object.defineProperty(qn,"__esModule",{value:!0});Fa(J_(),qn);Fa(ZI(),qn);Fa(Z_(),qn);Fa(tb(),qn);Fa(Vh(),qn);Fa(nb(),qn);Fa(sb(),qn)});var rx=S((Sie,tx)=>{var{Parser:qs}=zI(),{Generator:v9}=XI(),{Wildcard:E9}=X_(),{DataFactory:T9}=ex();function I9({prefixes:n,baseIRI:e,factory:t,pathOnly:r,sparqlStar:i,skipValidation:s,skipUngroupedVariableCheck:o}={}){let l={};for(let u in n??{})l[u]=n[u];let c=new qs;return c.parse=function(){return qs.base=e||"",qs.prefixes=Object.create(l),qs.factory=t||new T9,qs.sparqlStar=!!i,qs.pathOnly=!!r,qs.skipValidation=!!s||!!o,qs.prototype.parse.apply(c,arguments)},c._resetBlanks=qs._resetBlanks,c}a(I9,"_Parser");tx.exports={Parser:I9,Generator:v9,Wildcard:E9}});var lb=S(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.CaseWhenTransformerError=Ol.CaseWhenTransformer=void 0;var ab=class{static{a(this,"CaseWhenTransformer")}transform(e){let t=this.stripLineComments(e),r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new Ws("Too many nested CASE expressions (max 100 iterations)");while(t!==r);return t}stripLineComments(e){let t="",r=0;for(;r<e.length;){let i=e[r];if(i==="'"||i==='"'){let s=i;for(t+=i,r++;r<e.length&&e[r]!==s;){if(e[r]==="\\"&&r+1<e.length){t+=e[r]+e[r+1],r+=2;continue}t+=e[r],r++}r<e.length&&(t+=e[r],r++);continue}if(i==="<"){let s=e.indexOf(">",r),o=e.indexOf(`
41
41
  `,r);if(s!==-1&&(o===-1||s<o)){t+=e.substring(r,s+1),r=s+1;continue}}if(i==="#"){let s=e.indexOf(`
42
42
  `,r),o=s===-1?e.length:s;t+=" ".repeat(o-r),r=o;continue}t+=i,r++}return t}transformSinglePass(e){let t=this.findCasePositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],o=this.extractCaseExpression(r,s);if(o){let l=this.convertCaseToIf(o.content);r=r.substring(0,s)+l+r.substring(s+o.length)}}return r}findCasePositions(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(r.substring(i,i+4)==="CASE"&&this.isWordBoundary(e,i,4)){t.push(i),i+=4;continue}i++}return t}extractCaseExpression(e,t){let r=1,i=t+4,s=e.toUpperCase();for(;i<e.length&&r>0;){if(e[i]==="'"||e[i]==='"'){let o=e[i];for(i++;i<e.length&&e[i]!==o;)e[i]==="\\"&&i++,i++;i++;continue}if(s.substring(i,i+4)==="CASE"&&this.isWordBoundary(e,i,4)){r++,i+=4;continue}if(s.substring(i,i+3)==="END"&&this.isWordBoundary(e,i,3)){if(r--,r===0){let o=e.substring(t,i+3);return{content:o,length:o.length}}i+=3;continue}i++}if(r>0)throw new Ws(`Unclosed CASE expression at position ${t}`);return null}isWordBoundary(e,t,r){let i=t>0?e[t-1]:"",s=t===0||!/[a-zA-Z0-9_?$]/.test(i),o=t+r<e.length?e[t+r]:"",l=t+r>=e.length||!/[a-zA-Z0-9_]/.test(o);return s&&l}convertCaseToIf(e){let t=this.extractWhenClauses(e),r=this.extractElseClause(e);if(t.length===0)throw new Ws("CASE expression must have at least one WHEN clause");let i=r!==null?r:'""';for(let s=t.length-1;s>=0;s--){let{condition:o,result:l}=t[s];i=`IF(${o}, ${l}, ${i})`}return i}extractWhenClauses(e){let t=[],r=e.replace(/^\s*CASE\s+/i,"").replace(/\s*END\s*$/i,""),i=this.findKeywordPositions(r,"WHEN"),s=this.findKeywordPositions(r,"ELSE"),o=s.length>0?s[0]:r.length;for(let l=0;l<i.length;l++){let c=i[l]+4,u=l+1<i.length?i[l+1]:o,f=r.substring(c,u).trim(),d=this.parseWhenClause(f);d&&t.push(d)}return t}findKeywordPositions(e,t){let r=[],i=e.toUpperCase(),s=0,o=0;for(;s<e.length;){let l=e[s];if(l==="'"||l==='"'){let c=l;for(s++;s<e.length&&e[s]!==c;)e[s]==="\\"&&s++,s++;s++;continue}if(l==="("){o++,s++;continue}if(l===")"){o--,s++;continue}if(o===0&&i.substring(s,s+t.length)===t&&this.isWordBoundary(e,s,t.length)){r.push(s),s+=t.length;continue}s++}return r}parseWhenClause(e){let t=this.findKeywordPositions(e,"THEN");if(t.length===0)throw new Ws(`WHEN clause missing THEN keyword: ${e.substring(0,50)}...`);let r=t[0],i=e.substring(0,r).trim(),s=e.substring(r+4).trim();if(!i)throw new Ws("WHEN clause has empty condition");if(!s)throw new Ws("WHEN clause has empty result");return{condition:i,result:s}}extractElseClause(e){let t=e.replace(/^\s*CASE\s+/i,"").replace(/\s*END\s*$/i,""),r=this.findKeywordPositions(t,"ELSE");if(r.length>0){let i=r[0];return t.substring(i+4).trim()}return null}};Ol.CaseWhenTransformer=ab;var Ws=class extends Error{static{a(this,"CaseWhenTransformerError")}constructor(e){super(`CASE WHEN transformation error: ${e}`),this.name="CaseWhenTransformerError"}};Ol.CaseWhenTransformerError=Ws});var cb=S(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});Fl.LateralTransformerError=Fl.LateralTransformer=void 0;var zh=class n{static{a(this,"LateralTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new Fo("Too many nested LATERAL joins (max 100 iterations)");while(t!==r);return t}hasLateral(e){return this.findLateralPositions(e).length>0}static isLateralJoin(e){if(e.type==="group"&&e.patterns){for(let t of e.patterns)if(t.type==="query"&&t.queryType==="SELECT"&&t.variables&&Array.isArray(t.variables)){for(let r of t.variables)if(r.termType==="Variable"&&r.value===n.LATERAL_MARKER)return!0}}if(e.type==="query"&&e.queryType==="SELECT"&&e.variables&&Array.isArray(e.variables)){for(let t of e.variables)if(t.termType==="Variable"&&t.value===n.LATERAL_MARKER)return!0}return!1}transformSinglePass(e){let t=this.findLateralPositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],o=this.extractLateralExpression(r,s);if(o){let l=this.transformLateral(o.content);r=r.substring(0,s)+l+r.substring(s+o.length)}}return r}findLateralPositions(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(e[i]==="#"){for(;i<e.length&&e[i]!==`
@@ -45,7 +45,7 @@ Expecting `+Bd.join(", ")+", got '"+(this.terminals_[pt]||pt)+"'":i0="Parse erro
45
45
  `)+`
46
46
  `+s.trimStart()),s}findPrefixStarDeclarations(e){let t=[],r=e.toUpperCase(),i=0;for(;i<e.length;){if(e[i]==="'"||e[i]==='"'){let s=e[i];for(i++;i<e.length&&e[i]!==s;)e[i]==="\\"&&i++,i++;i++;continue}if(r.substring(i,i+6)==="PREFIX"){let s=i;for(i+=6;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]==="*"){for(i++;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]==="<"){i++;let o=i;for(;i<e.length&&e[i]!==">";)i++;if(e[i]===">"){let l=e.substring(o,i);i++;let c=this.findDeclarationEnd(e,i);t.push({uri:l,startPos:s,endPos:c}),i=c;continue}else throw new Dl(`Unclosed IRI in PREFIX* declaration at position ${o}`)}else throw new Dl(`Expected IRI after PREFIX* at position ${i}`)}else continue}i++}return t}findDeclarationEnd(e,t){let r=t;for(;r<e.length;){let i=e[r];if(i===`
47
47
  `)return r+1;let s=e.substring(r).toUpperCase();if(s.startsWith("PREFIX")||s.startsWith("BASE")||s.startsWith("SELECT")||s.startsWith("CONSTRUCT")||s.startsWith("DESCRIBE")||s.startsWith("ASK"))return r;if(/\s/.test(i)){r++;continue}break}return r}extractPrefixFromUri(e){let t=e.replace(/^https?:\/\//,"");t=t.replace(/\/$/,"").replace(/#$/,"");let r=t.split(/[/.#]+/).filter(Boolean);if(r.length===0)return null;let i=r[r.length-1];return/^(ontology|vocab|schema|ns|core)$/i.test(i)&&r.length>1?r[r.length-2].toLowerCase():i.toLowerCase().replace(/[^a-z0-9]/g,"")}};Do.PrefixStarTransformer=ub;var Dl=class extends Error{static{a(this,"PrefixStarTransformerError")}constructor(e){super(`PREFIX* transformation error: ${e}`),this.name="PrefixStarTransformerError"}};Do.PrefixStarTransformerError=Dl});var fb=S(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.DescribeOptionsTransformer=Nl.DescribeOptionsTransformerError=void 0;var Qh=class extends Error{static{a(this,"DescribeOptionsTransformerError")}constructor(e){super(e),this.name="DescribeOptionsTransformerError"}};Nl.DescribeOptionsTransformerError=Qh;var Ll=class n{static{a(this,"DescribeOptionsTransformer")}transform(e){if(!n.DESCRIBE_QUERY_PATTERN.test(e))return{query:e};let t=e,r={},i=!1,s=n.DEPTH_PATTERN.exec(e);if(s){let o=parseInt(s[1],10);if(o<0)throw new Qh(`DESCRIBE DEPTH must be a non-negative integer, got: ${o}`);r.depth=o,i=!0,n.DEPTH_PATTERN.lastIndex=0,t=t.replace(n.DEPTH_PATTERN,"")}return n.DEPTH_PATTERN.lastIndex=0,n.SYMMETRIC_PATTERN.test(e)&&(r.symmetric=!0,i=!0,n.SYMMETRIC_PATTERN.lastIndex=0,t=t.replace(n.SYMMETRIC_PATTERN,"")),n.SYMMETRIC_PATTERN.lastIndex=0,t=t.replace(/\s{2,}/g," ").trim(),{query:t,options:i?r:void 0}}hasDescribeOptions(e){let t=n.DEPTH_PATTERN.test(e);n.DEPTH_PATTERN.lastIndex=0;let r=n.SYMMETRIC_PATTERN.test(e);return n.SYMMETRIC_PATTERN.lastIndex=0,t||r}};Nl.DescribeOptionsTransformer=Ll;Ll.DEPTH_PATTERN=/\bDEPTH\s+(\d+)/gi;Ll.SYMMETRIC_PATTERN=/\bSYMMETRIC\b/gi;Ll.DESCRIBE_QUERY_PATTERN=/\bDESCRIBE\b/i});var ix=S(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});kl.DirectionalLangTagTransformerError=kl.DirectionalLangTagTransformer=void 0;var Yh=class n{static{a(this,"DirectionalLangTagTransformer")}constructor(){this.directionMappings=new Map}transform(e){return this.directionMappings.clear(),e.replace(n.DIRECTIONAL_TAG_REGEX,(t,r,i,s,o)=>{let l=s.toLowerCase();return this.directionMappings.set(l,o),`${r}${i}${r}@${s}`})}getDirection(e){return this.directionMappings.get(e.toLowerCase())}getAllMappings(){return new Map(this.directionMappings)}hasDirectionalTags(e){return n.DIRECTIONAL_TAG_REGEX.lastIndex=0,n.DIRECTIONAL_TAG_REGEX.test(e)}clearMappings(){this.directionMappings.clear()}};kl.DirectionalLangTagTransformer=Yh;Yh.DIRECTIONAL_TAG_REGEX=/(["'])((?:[^\\]|\\.)*?)\1@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)--(ltr|rtl)/g;var db=class extends Error{static{a(this,"DirectionalLangTagTransformerError")}constructor(e){super(`Directional language tag transformation error: ${e}`),this.name="DirectionalLangTagTransformerError"}};kl.DirectionalLangTagTransformerError=db});var sx=S(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:!0});jl.TripleTermTransformerError=jl.TripleTermTransformer=void 0;var hb=class{static{a(this,"TripleTermTransformer")}transform(e){let t=e,r,i=0,s=100;do if(r=t,t=this.transformSinglePass(t),i++,i>s)throw new Ml("Too many nested triple terms (max 100 iterations)");while(t!==r);return t}hasTripleTermSyntax(e){return this.findTripleTermPositions(e).length>0}transformSinglePass(e){let t=this.findTripleTermPositions(e);if(t.length===0)return e;let r=e;for(let i=t.length-1;i>=0;i--){let s=t[i],o=this.extractTripleTerm(r,s);if(o){let l=this.convertToStandardSyntax(o.content);r=r.substring(0,s)+l+r.substring(s+o.length)}}return r}findTripleTermPositions(e){let t=[],r=0;for(;r<e.length;){if(e[r]==="'"){r=this.skipStringLiteral(e,r,"'");continue}if(e[r]==='"'){r=this.skipStringLiteral(e,r,'"');continue}if(e.substring(r,r+2)==="<<"&&this.isParenthesizedTripleTerm(e,r)){t.push(r),r+=2;continue}r++}return t}skipStringLiteral(e,t,r){let i=r.repeat(3);if(e.substring(t,t+3)===i){for(t+=3;t<e.length;){if(e.substring(t,t+3)===i)return t+3;e[t]==="\\"&&t++,t++}return t}for(t++;t<e.length&&e[t]!==r;)e[t]==="\\"&&t++,t++;return t+1}isParenthesizedTripleTerm(e,t){let r=t+2;for(;r<e.length&&/\s/.test(e[r]);)r++;return e[r]==="("}extractTripleTerm(e,t){let r=t+2;for(;r<e.length&&/\s/.test(e[r]);)r++;if(e[r]!=="(")return null;r++;let i=1;for(;r<e.length&&i>0;){if(e[r]==="'"||e[r]==='"'){r=this.skipStringLiteral(e,r,e[r]);continue}if(e.substring(r,r+2)==="<<"&&this.isParenthesizedTripleTerm(e,r)){for(r+=2;r<e.length&&/\s/.test(e[r]);)r++;e[r]==="("&&(i++,r++);continue}if(e.substring(r,r+2)==="<<"){r+=2;let s=1;for(;r<e.length&&s>0;){if(e[r]==="'"||e[r]==='"'){r=this.skipStringLiteral(e,r,e[r]);continue}if(e.substring(r,r+2)==="<<"){s++,r+=2;continue}if(e.substring(r,r+2)===">>"){s--,r+=2;continue}r++}continue}if(e[r]==="("){i++,r++;continue}if(e[r]===")"){let s=r+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(e.substring(s,s+2)===">>"){if(i--,i===0){let o=e.substring(t,s+2);return{content:o,length:o.length}}r=s+2;continue}r++;continue}r++}if(i>0)throw new Ml(`Unclosed triple term at position ${t}: missing )>>`);return null}convertToStandardSyntax(e){let t=e.match(/^<<\s*\(\s*([\s\S]*?)\s*\)\s*>>$/);if(!t)throw new Ml(`Invalid triple term syntax: ${e.substring(0,50)}...`);return`<< ${t[1]} >>`}};jl.TripleTermTransformer=hb;var Ml=class extends Error{static{a(this,"TripleTermTransformerError")}constructor(e){super(`Triple term transformation error: ${e}`),this.name="TripleTermTransformerError"}};jl.TripleTermTransformerError=Ml});var mb=S(Xh=>{"use strict";Object.defineProperty(Xh,"__esModule",{value:!0});Xh.VaultPrefixTransformer=void 0;var x9=/PREFIX\s+(\w+)\s*:/gi,A9=new Set(["mailto","http","https","urn","ftp","prefix","base","select","construct","describe","ask","where","filter","optional","union","graph","order","group","having","limit","offset","values","bind","minus","service","insert","delete","load","clear","drop","create","move","copy","add"]),pb=class{static{a(this,"VaultPrefixTransformer")}constructor(){this.vaultPrefixes=new Map}setVaultPrefixes(e){this.vaultPrefixes=new Map(e)}getVaultPrefixes(){return new Map(this.vaultPrefixes)}transform(e){if(this.vaultPrefixes.size===0)return e;let t=this.findDeclaredPrefixes(e),r=[];for(let[o,l]of this.vaultPrefixes)!t.has(o.toLowerCase())&&!A9.has(o.toLowerCase())&&r.push({prefix:o,baseIRI:l});if(r.length===0)return e;let i="",s=0;for(;s<e.length;){let o=e[s];if(o==='"'||o==="'"){let c=this.skipLiteral(e,s);i+=e.substring(s,c),s=c;continue}if(o==="<"){let c=e.indexOf(">",s);c!==-1?(i+=e.substring(s,c+1),s=c+1):(i+=o,s++);continue}if(o==="#"){let c=e.indexOf(`
48
- `,s);c!==-1?(i+=e.substring(s,c),s=c):(i+=e.substring(s),s=e.length);continue}let l=this.tryReplacePrefixedName(e,s,r);if(l){i+=l.iri,s=l.endIndex;continue}i+=o,s++}return i}tryReplacePrefixedName(e,t,r){if(t>0&&/[a-zA-Z0-9_]/.test(e[t-1]))return null;for(let{prefix:i,baseIRI:s}of r){if(e.substring(t,t+i.length+1)!==i+":")continue;let o=t+i.length+1,l=o;for(;l<e.length&&/[a-zA-Z0-9_.%-]/.test(e[l]);)l++;if(l===o)continue;let c=e.substring(o,l);return{iri:`<${s}${c}.md>`,endIndex:l}}return null}findDeclaredPrefixes(e){let t=new Set,r=new RegExp(x9.source,"gi"),i;for(;(i=r.exec(e))!==null;)t.add(i[1].toLowerCase());return t}skipLiteral(e,t){let r=e[t];if(t+2<e.length&&e.substring(t,t+3)===r+r+r){let s=e.indexOf(r+r+r,t+3);return s!==-1?s+3:e.length}let i=t+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;return i<e.length?i+1:e.length}};Xh.VaultPrefixTransformer=pb});var $l=S(Pn=>{"use strict";var R9=Pn&&Pn.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),C9=Pn&&Pn.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),P9=Pn&&Pn.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&R9(t,e,r[i]);return C9(t,e),t}})();Object.defineProperty(Pn,"__esModule",{value:!0});Pn.SPARQLParser=Pn.ExoQLParser=Pn.SPARQLParseError=void 0;var ox=P9(rx()),gb=lb(),yb=cb(),ax=nx(),_b=fb(),O9=ix(),bb=sx(),F9=mb(),cr=class extends Error{static{a(this,"SPARQLParseError")}constructor(e,t,r,i){super(e,i?{cause:i}:void 0),this.name="SPARQLParseError",this.line=t,this.column=r}};Pn.SPARQLParseError=cr;var Kh=class{static{a(this,"ExoQLParser")}constructor(e){this.lastDirectionMappings=new Map,this.parser=new ox.Parser({sparqlStar:!0}),this.generator=new ox.Generator({sparqlStar:!0}),this.caseWhenTransformer=new gb.CaseWhenTransformer,this.lateralTransformer=new yb.LateralTransformer,this.prefixStarTransformer=new ax.PrefixStarTransformer(e?.vocabularyResolver),this.describeOptionsTransformer=new _b.DescribeOptionsTransformer,this.directionalLangTagTransformer=new O9.DirectionalLangTagTransformer,this.tripleTermTransformer=new bb.TripleTermTransformer,this.vaultPrefixTransformer=new F9.VaultPrefixTransformer}setVaultPrefixes(e){this.vaultPrefixTransformer.setVaultPrefixes(e)}parse(e){try{let t=this.vaultPrefixTransformer.transform(e),r=this.describeOptionsTransformer.transform(t);this.lastDescribeOptions=r.options;let i=r.query;i=this.directionalLangTagTransformer.transform(i),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),i=this.lateralTransformer.transform(i),i=this.caseWhenTransformer.transform(i),i=this.tripleTermTransformer.transform(i);let s=this.parser.parse(i);return this.validateQuery(s),this.lastDescribeOptions&&this.isDescribeQuery(s)&&(s.describeOptions=this.lastDescribeOptions),s}catch(t){if(t instanceof _b.DescribeOptionsTransformerError)throw new cr(t.message);if(t instanceof yb.LateralTransformerError)throw new cr(t.message);if(t instanceof gb.CaseWhenTransformerError)throw new cr(t.message);if(t instanceof bb.TripleTermTransformerError)throw new cr(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new cr(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}parseWithOptions(e){return{query:this.parse(e),describeOptions:this.lastDescribeOptions}}getLastDescribeOptions(){return this.lastDescribeOptions}async parseAsync(e){try{let t=this.vaultPrefixTransformer.transform(e),r=this.describeOptionsTransformer.transform(t);this.lastDescribeOptions=r.options;let i=r.query;i=this.directionalLangTagTransformer.transform(i),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),i=await this.prefixStarTransformer.transform(i),i=this.lateralTransformer.transform(i),i=this.caseWhenTransformer.transform(i),i=this.tripleTermTransformer.transform(i);let s=this.parser.parse(i);return this.validateQuery(s),this.lastDescribeOptions&&this.isDescribeQuery(s)&&(s.describeOptions=this.lastDescribeOptions),s}catch(t){if(t instanceof _b.DescribeOptionsTransformerError)throw new cr(t.message);if(t instanceof ax.PrefixStarTransformerError)throw new cr(t.message);if(t instanceof yb.LateralTransformerError)throw new cr(t.message);if(t instanceof gb.CaseWhenTransformerError)throw new cr(t.message);if(t instanceof bb.TripleTermTransformerError)throw new cr(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new cr(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}async parseAsyncWithOptions(e){return{query:await this.parseAsync(e),describeOptions:this.lastDescribeOptions}}hasPrefixStar(e){return/PREFIX\s*\*/i.test(e)}hasLateral(e){return this.lateralTransformer.hasLateral(e)}hasDescribeOptions(e){return this.describeOptionsTransformer.hasDescribeOptions(e)}hasDirectionalLangTags(e){return this.directionalLangTagTransformer.hasDirectionalTags(e)}hasTripleTermSyntax(e){return this.tripleTermTransformer.hasTripleTermSyntax(e)}getLastDirectionMappings(){return new Map(this.lastDirectionMappings)}getDirectionForLanguage(e){return this.lastDirectionMappings.get(e.toLowerCase())}toString(e){try{return this.generator.stringify(e)}catch(t){throw t instanceof Error?new cr(`Failed to serialize SPARQL query: ${t.message}`,void 0,void 0,t):t}}getQueryType(e){if("queryType"in e&&e.type==="query")return e.queryType;throw new cr("Query does not have a valid queryType property")}isSelectQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="SELECT"}isConstructQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="CONSTRUCT"}isAskQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="ASK"}isDescribeQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="DESCRIBE"}isUpdateQuery(e){return e.type==="update"}isInsertDataOperation(e){return"updateType"in e&&e.updateType==="insert"}isDeleteDataOperation(e){return"updateType"in e&&e.updateType==="delete"}validateQuery(e){if(!e||typeof e!="object")throw new cr("Invalid query: not an object");if(e.type!=="query"&&e.type!=="update")throw new cr(`Invalid type: expected "query" or "update", got "${e.type}"`);if(e.type==="query"){let t=["SELECT","CONSTRUCT","ASK","DESCRIBE"];if(!t.includes(e.queryType))throw new cr(`Invalid query type: expected one of ${t.join(", ")}, got "${e.queryType}"`)}}};Pn.ExoQLParser=Kh;Pn.SPARQLParser=Kh});var Da=S(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});Jh.AlgebraTranslatorError=void 0;var Sb=class extends Error{static{a(this,"AlgebraTranslatorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AlgebraTranslatorError"}};Jh.AlgebraTranslatorError=Sb});var Zh=S(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.isVariableExpression=D9;is.isVariableTerm=L9;is.isNamedNode=N9;is.isLiteral=k9;is.isPropertyPath=M9;is.isAggregateExpression=j9;is.isOperationExpression=$9;is.isFunctionCallExpression=U9;function D9(n){return typeof n=="object"&&n!==null&&"expression"in n&&"variable"in n}a(D9,"isVariableExpression");function L9(n){return typeof n=="object"&&n!==null&&"termType"in n&&n.termType==="Variable"}a(L9,"isVariableTerm");function N9(n){return typeof n=="object"&&n!==null&&"termType"in n&&n.termType==="NamedNode"}a(N9,"isNamedNode");function k9(n){return typeof n=="object"&&n!==null&&"termType"in n&&n.termType==="Literal"}a(k9,"isLiteral");function M9(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="path"}a(M9,"isPropertyPath");function j9(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="aggregate"}a(j9,"isAggregateExpression");function $9(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="operation"}a($9,"isOperationExpression");function U9(n){return typeof n=="object"&&n!==null&&"type"in n&&(n.type==="functionCall"||n.type==="functioncall")}a(U9,"isFunctionCallExpression")});var lx=S(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.TripleTranslator=void 0;var un=Da(),wb=class{static{a(this,"TripleTranslator")}constructor(){this.directionMappings=new Map}setDirectionMappings(e){this.directionMappings=e}translateBGP(e){if(!("triples"in e)||!Array.isArray(e.triples))throw new un.AlgebraTranslatorError("BGP pattern must have triples array");return{type:"bgp",triples:e.triples.map(t=>this.translateTriple(t))}}translateTriple(e){if(!e.subject||!e.predicate||!e.object)throw new un.AlgebraTranslatorError("Triple must have subject, predicate, and object");return{subject:this.translateTripleElement(e.subject),predicate:this.translatePredicate(e.predicate),object:this.translateTripleElement(e.object)}}translateConstructTemplate(e){return!e||!Array.isArray(e)?[]:e.map(t=>this.translateTriple(t))}translatePredicate(e){return"type"in e&&e.type==="path"?this.translatePropertyPath(e):this.translateTripleElement(e)}translatePropertyPath(e){if(!("pathType"in e)||!e.pathType)throw new un.AlgebraTranslatorError("Property path must have pathType");if(!("items"in e)||!Array.isArray(e.items))throw new un.AlgebraTranslatorError("Property path must have items array");let t=e.items.map(r=>this.translatePathItem(r));switch(e.pathType){case"/":return{type:"path",pathType:"/",items:t};case"|":return{type:"path",pathType:"|",items:t};case"^":if(t.length!==1)throw new un.AlgebraTranslatorError("Inverse path must have exactly one item");return{type:"path",pathType:"^",items:[t[0]]};case"+":if(t.length!==1)throw new un.AlgebraTranslatorError("OneOrMore path must have exactly one item");return{type:"path",pathType:"+",items:[t[0]]};case"*":if(t.length!==1)throw new un.AlgebraTranslatorError("ZeroOrMore path must have exactly one item");return{type:"path",pathType:"*",items:[t[0]]};case"?":if(t.length!==1)throw new un.AlgebraTranslatorError("ZeroOrOne path must have exactly one item");return{type:"path",pathType:"?",items:[t[0]]};default:throw new un.AlgebraTranslatorError(`Unsupported property path type: ${e.pathType}`)}}translatePathItem(e){if("type"in e&&e.type==="path")return this.translatePropertyPath(e);if("termType"in e&&e.termType==="NamedNode")return{type:"iri",value:e.value};let t="type"in e?e.type:"termType"in e?e.termType:"unknown";throw new un.AlgebraTranslatorError(`Unsupported path item type: ${String(t)}`)}translateTripleElement(e){if(!e||!("termType"in e))throw new un.AlgebraTranslatorError("Triple element must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};case"Literal":{let t={type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language};if(e.language){let r=this.directionMappings.get(e.language.toLowerCase());r&&(t.direction=r)}return t}case"BlankNode":return{type:"blank",value:e.value};case"Quad":return this.translateQuotedTriple(e);default:throw new un.AlgebraTranslatorError(`Unsupported term type: ${e.termType}`)}}translateQuotedTriple(e){if(!e.subject||!e.predicate||!e.object)throw new un.AlgebraTranslatorError("Quoted triple must have subject, predicate, and object");return{type:"quoted",subject:this.translateTripleElement(e.subject),predicate:this.translateQuotedTriplePredicate(e.predicate),object:this.translateTripleElement(e.object)}}translateQuotedTriplePredicate(e){if(!e||!("termType"in e))throw new un.AlgebraTranslatorError("Quoted triple predicate must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};default:throw new un.AlgebraTranslatorError(`Quoted triple predicate must be IRI or Variable, got: ${e.termType}`)}}};ep.TripleTranslator=wb});var cx=S(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.ExpressionTranslator=void 0;var Ul=Da(),vb=class{static{a(this,"ExpressionTranslator")}constructor(e){this.translateWhereFn=e.translateWhere,this.translateBGPFn=e.translateBGP,this.translatePatternFn=e.translatePattern}translateExpression(e){if(!e)throw new Ul.AlgebraTranslatorError("Expression cannot be null or undefined");if("type"in e&&e.type==="operation")return this.translateOperationExpression(e);let t="type"in e?e.type:void 0;if(t==="functioncall"||t==="functionCall"){let r=e;return{type:"functionCall",function:r.function,args:r.args.map(i=>this.translateExpression(i))}}if("termType"in e)return this.translateTermExpression(e);throw new Ul.AlgebraTranslatorError(`Unsupported expression structure: ${JSON.stringify(e)}`)}translateFilter(e){if(!e.expression)throw new Ul.AlgebraTranslatorError("Filter pattern must have expression");let t={type:"bgp",triples:[]};return{type:"filter",expression:this.translateExpression(e.expression),input:t}}translateTermExpression(e){if(e.termType==="Variable")return{type:"variable",name:e.value};if(e.termType==="Literal"){let t=e.value;return e.datatype&&(e.datatype.value.includes("#integer")||e.datatype.value.includes("#decimal")?t=parseFloat(e.value):e.datatype.value.includes("#boolean")&&(t=e.value==="true")),{type:"literal",value:t,datatype:e.datatype?.value}}return{type:"literal",value:String(e.value||e)}}translateOperationExpression(e){let t=["=","!=","<",">","<=",">="],r=["&&","||","!"],i=["+","-","*","/"],s=e.args.filter(o=>!("patterns"in o)||"termType"in o);return t.includes(e.operator)?{type:"comparison",operator:e.operator,left:this.translateExpression(s[0]),right:this.translateExpression(s[1])}:r.includes(e.operator)?{type:"logical",operator:e.operator,operands:s.map(o=>this.translateExpression(o))}:i.includes(e.operator)?{type:"arithmetic",operator:e.operator,left:this.translateExpression(s[0]),right:this.translateExpression(s[1])}:e.operator==="exists"||e.operator==="notexists"?this.translateExistsExpression(e):e.operator==="in"||e.operator==="notin"?this.translateInExpression(e):{type:"function",function:e.operator,args:s.map(o=>this.translateExpression(o))}}translateExistsExpression(e){if(!e.args||e.args.length!==1)throw new Ul.AlgebraTranslatorError("EXISTS/NOT EXISTS must have exactly one pattern argument");let t=e.args[0],r;return t.type==="group"&&"patterns"in t&&t.patterns?r=this.translateWhereFn(t.patterns):t.type==="bgp"?r=this.translateBGPFn(t):r=this.translatePatternFn(t),{type:"exists",negated:e.operator==="notexists",pattern:r}}translateInExpression(e){if(!e.args||e.args.length!==2)throw new Ul.AlgebraTranslatorError("IN/NOT IN must have exactly 2 arguments (expression and list)");let t=e.args[0],r=e.args[1];if(!Array.isArray(r))throw new Ul.AlgebraTranslatorError("IN/NOT IN second argument must be an array of values");return{type:"in",expression:this.translateExpression(t),list:r.map(i=>this.translateExpression(i)),negated:e.operator==="notin"}}};tp.ExpressionTranslator=vb});var dx=S(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.PatternTranslator=void 0;var ux=cb(),Nr=Da(),fx=Zh(),Eb=class{static{a(this,"PatternTranslator")}constructor(e){this.directionMappings=new Map,this.translateExpressionFn=e.translateExpression,this.translateSelectFn=e.translateSelect,this.translateBGPFn=e.translateBGP}setDirectionMappings(e){this.directionMappings=e}translateWhere(e){if(e.length===0)throw new Nr.AlgebraTranslatorError("Empty WHERE clause");let t=e.filter(o=>o.type==="filter"),r=e.filter(o=>o.type==="bind"),i=e.filter(o=>o.type!=="filter"&&o.type!=="bind"),s;if(i.length===0)s={type:"bgp",triples:[]};else if(i.length===1)if(i[0].type==="optional"){let o=i[0].expression;s={type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(i[0].patterns),expression:o?this.translateExpressionFn(o):void 0}}else s=this.translatePattern(i[0]);else{if(i[0].type==="optional"){let o=i[0].expression;s={type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(i[0].patterns),expression:o?this.translateExpressionFn(o):void 0}}else s=this.translatePattern(i[0]);for(let o=1;o<i.length;o++){let l=i[o];if(this.isLateralPattern(l)){let c=this.extractLateralSubquery(l),u=this.removeLateralMarker(c),f=this.translateSelectFn(u);s={type:"lateraljoin",left:s,right:f}}else if(l.type==="optional"){let c=l.expression;s={type:"leftjoin",left:s,right:this.translateWhere(l.patterns),expression:c?this.translateExpressionFn(c):void 0}}else{let c=this.translatePattern(l);s={type:"join",left:s,right:c}}}}for(let o of r)s=this.translateBind(o,s);for(let o of t)s={type:"filter",expression:this.translateExpressionFn(o.expression),input:s};return s}translatePattern(e){if(!e||!e.type)throw new Nr.AlgebraTranslatorError("Invalid pattern: missing type");switch(e.type){case"bgp":return this.translateBGPFn(e);case"filter":return this.translateFilter(e);case"optional":return this.translateOptional(e);case"union":return this.translateUnion(e);case"minus":return this.translateMinus(e);case"values":return this.translateValues(e);case"group":return this.translateWhere(e.patterns);case"query":return this.translateSubquery(e);case"service":return this.translateService(e);case"graph":return this.translateGraph(e);default:throw new Nr.AlgebraTranslatorError(`Unsupported pattern type: ${e.type}`)}}translateFilter(e){if(!e.expression)throw new Nr.AlgebraTranslatorError("Filter pattern must have expression");let t={type:"bgp",triples:[]};return{type:"filter",expression:this.translateExpressionFn(e.expression),input:t}}translateOptional(e){if(!e.patterns||e.patterns.length===0)throw new Nr.AlgebraTranslatorError("OPTIONAL pattern must have patterns");let t=e.expression;return{type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns),expression:t?this.translateExpressionFn(t):void 0}}translateUnion(e){if(!e.patterns||e.patterns.length<2)throw new Nr.AlgebraTranslatorError("UNION pattern must have at least 2 patterns");let t=a(i=>i.type==="graph"?this.translateGraph(i):i.type==="service"?this.translateService(i):"patterns"in i&&i.patterns&&Array.isArray(i.patterns)?this.translateWhere(i.patterns):this.translateWhere([i]),"translateBranch"),r={type:"union",left:t(e.patterns[0]),right:t(e.patterns[1])};for(let i=2;i<e.patterns.length;i++)r={type:"union",left:r,right:t(e.patterns[i])};return r}translateMinus(e){if(!e.patterns||e.patterns.length===0)throw new Nr.AlgebraTranslatorError("MINUS pattern must have patterns");return{type:"minus",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns)}}translateValues(e){if(!e.values||!Array.isArray(e.values))throw new Nr.AlgebraTranslatorError("VALUES pattern must have values array");let t=new Set;for(let i of e.values)for(let s of Object.keys(i)){let o=s.startsWith("?")?s.slice(1):s;t.add(o)}let r=e.values.map(i=>this.translateValuesBinding(i));return{type:"values",variables:Array.from(t),bindings:r}}translateValuesBinding(e){let t={};for(let[r,i]of Object.entries(e)){let s=r.startsWith("?")?r.slice(1):r,o=i;if(o)if(o.termType==="NamedNode")t[s]={type:"iri",value:o.value};else if(o.termType==="Literal"){let l=o,c={type:"literal",value:l.value,datatype:l.datatype?.value,language:l.language||void 0};if(l.language){let u=this.directionMappings.get(l.language.toLowerCase());u&&(c.direction=u)}t[s]=c}else throw new Nr.AlgebraTranslatorError(`Unsupported VALUES term type: ${o.termType}`)}return t}translateBind(e,t){if(!e.variable||!e.expression)throw new Nr.AlgebraTranslatorError("BIND pattern must have variable and expression");return{type:"extend",variable:e.variable.value,expression:this.translateExpressionFn(e.expression),input:t}}translateSubquery(e){if(e.queryType!=="SELECT")throw new Nr.AlgebraTranslatorError(`Only SELECT subqueries are supported, got: ${String(e.queryType)}`);let t=this.removeLateralMarker(e);return{type:"subquery",query:this.translateSelectFn(t)}}translateService(e){if(!e.name||e.name.termType!=="NamedNode")throw new Nr.AlgebraTranslatorError("SERVICE pattern must have a NamedNode endpoint");if(!e.patterns||!Array.isArray(e.patterns))throw new Nr.AlgebraTranslatorError("SERVICE pattern must have patterns array");return{type:"service",endpoint:e.name.value,pattern:this.translateWhere(e.patterns),silent:e.silent||!1}}translateGraph(e){if(!e.name)throw new Nr.AlgebraTranslatorError("GRAPH pattern must have a name (IRI or variable)");if(!e.patterns||!Array.isArray(e.patterns))throw new Nr.AlgebraTranslatorError("GRAPH pattern must have patterns array");let t;if(e.name.termType==="NamedNode")t={type:"iri",value:e.name.value};else if(e.name.termType==="Variable")t={type:"variable",value:e.name.value};else throw new Nr.AlgebraTranslatorError(`GRAPH pattern name must be NamedNode or Variable, got: ${e.name.termType}`);return{type:"graph",name:t,pattern:this.translateWhere(e.patterns)}}isLateralPattern(e){if(e.type==="query"&&this.isLateralSubquery(e))return!0;if(e.type==="group"&&e.patterns?.length===1){let t=e.patterns[0];if(t.type==="query"&&this.isLateralSubquery(t))return!0}return!1}extractLateralSubquery(e){if(e.type==="query")return e;if(e.type==="group"&&e.patterns?.length===1){let t=e.patterns[0];if(t.type==="query")return t}throw new Nr.AlgebraTranslatorError("Invalid lateral pattern structure")}isLateralSubquery(e){return!("queryType"in e)||e.queryType!=="SELECT"||!("variables"in e)||!e.variables?!1:e.variables.some(i=>(0,fx.isVariableTerm)(i)&&i.value===ux.LateralTransformer.LATERAL_MARKER)}removeLateralMarker(e){if(!("variables"in e)||!e.variables)return e;let t=e,r=t.variables;return{...t,variables:r.filter(i=>!((0,fx.isVariableTerm)(i)&&i.value===ux.LateralTransformer.LATERAL_MARKER))}}};rp.PatternTranslator=Eb});var px=S(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});np.AggregateTranslator=void 0;var hx=Da(),V9=Zh(),Tb=class{static{a(this,"AggregateTranslator")}constructor(e){this.aggregateCounter=0,this.translateExpressionFn=e.translateExpression}resetCounter(){this.aggregateCounter=0}extractAggregatesWithMapping(e,t){if(!e)return[];let r=[];for(let i of e)(0,V9.isVariableExpression)(i)&&("type"in i.expression&&i.expression.type==="aggregate"?(r.push({variable:i.variable.value,expression:this.translateAggregateExpression(i.expression)}),t.set(i.expression,i.variable.value)):this.collectNestedAggregates(i.expression,r,t));return r}extractGroupVariables(e){return e?e.filter(t=>t.expression&&"termType"in t.expression&&t.expression.termType==="Variable").map(t=>t.expression.value):[]}extractHavingExpressions(e,t,r){if(!e||e.length===0)return[];for(let i of e)this.collectNestedAggregates(i,t,r);return e.map(i=>this.transformExpressionWithAggregateVars(i,r))}transformExpressionWithAggregateVars(e,t){let r=t.get(e);if(r!==void 0)return{type:"variable",name:r};if("type"in e&&e.type==="operation"&&"args"in e){let i=e,s=i.args.filter(u=>!Array.isArray(u)&&!("patterns"in u)).map(u=>this.transformExpressionWithAggregateVars(u,t)),o=["=","!=","<",">","<=",">="],l=["&&","||","!"],c=["+","-","*","/"];return o.includes(i.operator)?{type:"comparison",operator:i.operator,left:s[0],right:s[1]}:l.includes(i.operator)?{type:"logical",operator:i.operator,operands:s}:c.includes(i.operator)?{type:"arithmetic",operator:i.operator,left:s[0],right:s[1]}:{type:"function",function:i.operator,args:s}}return this.translateExpressionFn(e)}translateOrderComparator(e){return{expression:this.translateExpressionFn(e.expression),descending:e.descending||!1}}translateAggregateExpression(e){let t=e.aggregation,r=a(()=>{if(e.expression&&!("termType"in e.expression&&e.expression.termType==="Wildcard"))return this.translateExpressionFn(e.expression)},"translateInnerExpr");if(typeof t=="string"){let s=t.toLowerCase();return["count","sum","avg","min","max","group_concat","sample"].includes(s)?{type:"aggregate",aggregation:s,expression:r(),distinct:e.distinct||!1,separator:e.separator}:{type:"aggregate",aggregation:{type:"custom",iri:t},expression:r(),distinct:e.distinct||!1,separator:e.separator}}let i=t;if(i&&typeof i=="object"){let s,o=i;if(o.termType==="NamedNode"&&typeof o.value=="string")s=o.value;else if("value"in o)s=String(o.value);else throw new hx.AlgebraTranslatorError(`Invalid custom aggregate: expected IRI but got ${JSON.stringify(i)}`);return{type:"aggregate",aggregation:{type:"custom",iri:s},expression:r(),distinct:e.distinct||!1,separator:e.separator}}throw new hx.AlgebraTranslatorError(`Unknown aggregate format: ${JSON.stringify(t)}`)}collectNestedAggregates(e,t,r){if(e){if("type"in e&&e.type==="aggregate"){let i=`__agg${this.aggregateCounter++}`;t.push({variable:i,expression:this.translateAggregateExpression(e)}),r.set(e,i)}else if("type"in e&&e.type==="operation"&&"args"in e){let i=e;for(let s of i.args)!Array.isArray(s)&&"type"in s&&!("patterns"in s)?this.collectNestedAggregates(s,t,r):"termType"in s&&this.collectNestedAggregates(s,t,r)}}}};np.AggregateTranslator=Tb});var Vl=S(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.AlgebraTranslator=Lo.ExoQLAlgebraTranslator=Lo.AlgebraTranslatorError=void 0;var ip=Da(),sp=Zh(),B9=lx(),G9=cx(),q9=dx(),W9=px(),z9=Da();Object.defineProperty(Lo,"AlgebraTranslatorError",{enumerable:!0,get:a(function(){return z9.AlgebraTranslatorError},"get")});var op=class{static{a(this,"ExoQLAlgebraTranslator")}constructor(){this.tripleTranslator=new B9.TripleTranslator,this.expressionTranslator=new G9.ExpressionTranslator({translateWhere:a(e=>this.patternTranslator.translateWhere(e),"translateWhere"),translateBGP:a(e=>this.tripleTranslator.translateBGP(e),"translateBGP"),translatePattern:a(e=>this.patternTranslator.translatePattern(e),"translatePattern")}),this.patternTranslator=new q9.PatternTranslator({translateExpression:a(e=>this.expressionTranslator.translateExpression(e),"translateExpression"),translateSelect:a(e=>this.translateSelect(e),"translateSelect"),translateBGP:a(e=>this.tripleTranslator.translateBGP(e),"translateBGP")}),this.aggregateTranslator=new W9.AggregateTranslator({translateExpression:a(e=>this.expressionTranslator.translateExpression(e),"translateExpression")})}setDirectionMappings(e){this.tripleTranslator.setDirectionMappings(e),this.patternTranslator.setDirectionMappings(e)}translate(e){if(e.type!=="query")throw new ip.AlgebraTranslatorError("Only query operations are supported (not updates)");if(e.queryType==="SELECT")return this.translateSelect(e);if(e.queryType==="CONSTRUCT")return this.translateConstruct(e);if(e.queryType==="ASK")return this.translateAsk(e);if(e.queryType==="DESCRIBE")return this.translateDescribe(e);throw new ip.AlgebraTranslatorError(`Query type ${String(e.queryType)} not yet supported`)}translateSelect(e){if(!e.where||e.where.length===0)throw new ip.AlgebraTranslatorError("SELECT query must have WHERE clause");let t=this.patternTranslator.translateWhere(e.where);this.aggregateTranslator.resetCounter();let r=new Map,i=Array.isArray(e.variables)?e.variables.filter(c=>!("termType"in c&&c.termType==="Wildcard")):[],s=this.aggregateTranslator.extractAggregatesWithMapping(i,r),o=this.aggregateTranslator.extractGroupVariables(e.group),l=this.aggregateTranslator.extractHavingExpressions(e.having,s,r);if((s.length>0||o.length>0||l.length>0)&&(t={type:"group",variables:o,aggregates:s,having:l.length>0?l:void 0,input:t}),i.length>0){for(let u of i)if((0,sp.isVariableExpression)(u)){if("type"in u.expression&&u.expression.type==="aggregate")continue;let f=this.aggregateTranslator.transformExpressionWithAggregateVars(u.expression,r);t={type:"extend",variable:u.variable.value,expression:f,input:t}}let c=i.filter(u=>(0,sp.isVariableTerm)(u)||(0,sp.isVariableExpression)(u)).map(u=>(0,sp.isVariableTerm)(u)?u.value:u.variable.value);c.length>0&&(t={type:"project",variables:c,input:t})}return e.distinct&&(t={type:"distinct",input:t}),e.reduced&&(t={type:"reduced",input:t}),e.order&&e.order.length>0&&(t={type:"orderby",comparators:e.order.map(c=>this.aggregateTranslator.translateOrderComparator(c)),input:t}),(e.limit!==void 0||e.offset!==void 0)&&(t={type:"slice",limit:e.limit,offset:e.offset,input:t}),t}translateConstruct(e){let t=this.tripleTranslator.translateConstructTemplate(e.template??[]);if(!e.where||e.where.length===0)throw new ip.AlgebraTranslatorError("CONSTRUCT query must have WHERE clause");let r=this.patternTranslator.translateWhere(e.where),i=e;return(i.limit!==void 0||i.offset!==void 0)&&(r={type:"slice",limit:i.limit,offset:i.offset,input:r}),{type:"construct",template:t,where:r}}translateAsk(e){return{type:"ask",where:e.where&&e.where.length>0?this.patternTranslator.translateWhere(e.where):{type:"bgp",triples:[]}}}translateDescribe(e){let t=[];if(e.variables&&Array.isArray(e.variables)){let s=e.variables;for(let o of s)o.termType==="Wildcard"||o.value==="*"||(o.termType==="Variable"?t.push({type:"variable",value:o.value}):o.termType==="NamedNode"&&t.push({type:"iri",value:o.value}))}let r;e.where&&e.where.length>0&&(r=this.patternTranslator.translateWhere(e.where));let i=e.describeOptions;return{type:"describe",resources:t,where:r,depth:i?.depth,symmetric:i?.symmetric}}};Lo.ExoQLAlgebraTranslator=op;Lo.AlgebraTranslator=op});var ss=S(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.SolutionMapping=void 0;var mx=$e(),gx=Ae(),yx=$t(),Ib=class n{static{a(this,"SolutionMapping")}constructor(e){this.bindings=e?new Map(e):new Map}get(e){return this.bindings.get(e)}set(e,t){this.bindings.set(e,t)}has(e){return this.bindings.has(e)}variables(){return Array.from(this.bindings.keys())}getBindings(){return new Map(this.bindings)}isCompatibleWith(e){for(let[t,r]of this.bindings.entries()){let i=e.get(t);if(i!==void 0&&!this.areEqual(r,i))return!1}return!0}merge(e){if(!this.isCompatibleWith(e))return null;let t=new n(this.bindings);for(let[r,i]of e.getBindings().entries())t.set(r,i);return t}clone(){return new n(this.bindings)}areEqual(e,t){return e instanceof mx.Literal&&t instanceof mx.Literal?e.equals(t):e instanceof gx.IRI&&t instanceof gx.IRI?e.value===t.value:e instanceof yx.BlankNode&&t instanceof yx.BlankNode?e.id===t.id:!1}toJSON(){let e={};for(let[t,r]of this.bindings.entries())e[t]=r.toString();return e}size(){return this.bindings.size}};ap.SolutionMapping=Ib});var bx=S(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.PropertyPathExecutor=Gl.PropertyPathExecutorError=void 0;var H9=ss(),lp=Ae(),_x=$t(),Q9=$e(),Bl=class extends Error{static{a(this,"PropertyPathExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="PropertyPathExecutorError"}};Gl.PropertyPathExecutorError=Bl;var xb=class n{static{a(this,"PropertyPathExecutor")}constructor(e){this.tripleStore=e,this.MAX_DEPTH=100}async*execute(e,t,r){if(this.isLiteralElement(e)||this.isLiteralElement(r)){let o=this.isLiteralElement(e)?"subject":"object",l=this.isLiteralElement(e)?e:r,c="value"in l?String(l.value):"<unknown>",u=c.length>80?`${c.slice(0,77)}...`:c,f=this.describePath(t),d={position:o,value:u,path:f,hint:"Wikilink could not be resolved to IRI (likely label-form wikilink with no matching basename/alias). Check whether the target file exists in the queried vault, add an alias, or load the target vault via --also. See issue #3282."};if(console.error(`[PropertyPathExecutor] literal-safety guard fired: literal in ${o} position \u2014 yielding 0 solutions. value="${u}" path=${f}`,d),n.isStrictModeEnabled())throw new Bl(`Literal subject in property path: "${u}" (path=${f}). Set EXOCORTEX_SPARQL_STRICT=0 or omit --strict to fall back to warn-and-empty behaviour.`);return}let i=await this.resolveElement(e),s=this.isVariable(r)?null:await this.resolveElement(r);for(let o of i){let l=await this.evaluatePath(o,t,s);for(let c of l){let u=new H9.SolutionMapping;this.isVariable(e)&&u.set(e.value,o),this.isVariable(r)&&u.set(r.value,c),yield u}}}async*executeWithBindings(e,t){if(!this.isPropertyPath(e.predicate))throw new Bl("Predicate is not a property path");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.object,t);for await(let s of this.execute(r,e.predicate,i)){let o=t.merge(s);o!==null&&(yield o)}}async evaluatePath(e,t,r){switch(t.pathType){case"/":return this.evaluateSequencePath(e,t.items,r);case"|":return this.evaluateAlternativePath(e,t.items,r);case"^":return this.evaluateInversePath(e,t.items[0],r);case"+":return this.evaluateOneOrMorePath(e,t.items[0],r);case"*":return this.evaluateZeroOrMorePath(e,t.items[0],r);case"?":return this.evaluateZeroOrOnePath(e,t.items[0],r)}}async evaluateSequencePath(e,t,r){let i=new Set([e]);for(let s=0;s<t.length;s++){let o=t[s],l=s===t.length-1,c=new Set;for(let u of i){let f=await this.evaluatePathItem(u,o,l?r:null);for(let d of f)c.add(d)}if(i=c,i.size===0)break}return i}async evaluateAlternativePath(e,t,r){let i=new Set;for(let s of t){let o=await this.evaluatePathItem(e,s,r);for(let l of o)i.add(l)}return i}async evaluateInversePath(e,t,r){if(t.type==="iri"){let i=new lp.IRI(t.value),s=await this.tripleStore.match(void 0,i,e),o=new Set;for(let l of s)(r===null||this.nodeInSet(l.subject,r))&&o.add(l.subject);return o}else return this.evaluatePath(e,this.invertPath(t),r)}async evaluateOneOrMorePath(e,t,r){let i=new Set,s=new Set,o=[{node:e,depth:0}];for(;o.length>0;){let l=o.shift();if(!l)break;let{node:c,depth:u}=l;if(u>=this.MAX_DEPTH)continue;let f=await this.evaluatePathItem(c,t,null);for(let d of f){let h=this.nodeToKey(d);(r===null||this.nodeInSet(d,r))&&s.add(d),i.has(h)||(i.add(h),o.push({node:d,depth:u+1}))}}return s}async evaluateZeroOrMorePath(e,t,r){let i=await this.evaluateOneOrMorePath(e,t,r);return(r===null||this.nodeInSet(e,r))&&i.add(e),i}async evaluateZeroOrOnePath(e,t,r){let i=new Set;(r===null||this.nodeInSet(e,r))&&i.add(e);let s=await this.evaluatePathItem(e,t,r);for(let o of s)i.add(o);return i}async evaluatePathItem(e,t,r){if(t.type==="iri"){let i=new lp.IRI(t.value),s=await this.tripleStore.match(e,i,void 0),o=new Set;for(let l of s)(r===null||this.nodeInSet(l.object,r))&&o.add(l.object);return o}else return this.evaluatePath(e,t,r)}invertPath(e){switch(e.pathType){case"^":return e.items[0];case"/":return{type:"path",pathType:"/",items:[...e.items].reverse().map(t=>t.type==="iri"?{type:"path",pathType:"^",items:[t]}:this.invertPath(t))};case"|":return{type:"path",pathType:"|",items:e.items.map(t=>t.type==="iri"?{type:"path",pathType:"^",items:[t]}:this.invertPath(t))};case"+":case"*":case"?":{let t=e.items[0].type==="iri"?{type:"path",pathType:"^",items:[e.items[0]]}:this.invertPath(e.items[0]);return{type:"path",pathType:e.pathType,items:[t]}}}}async resolveElement(e){if(this.isVariable(e)){let r=new Set,i=await this.tripleStore.match(void 0,void 0,void 0);for(let s of i)r.add(s.subject),r.add(s.object);return r}let t=new Set;switch(e.type){case"iri":t.add(new lp.IRI(e.value));break;case"blank":t.add(new _x.BlankNode(e.value));break;default:throw new Bl(`Unsupported element type in subject/object position: ${e.type}`)}return t}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r){if(r instanceof lp.IRI)return{type:"iri",value:r.value};if(r instanceof _x.BlankNode)return{type:"blank",value:r.id};if(r instanceof Q9.Literal)return{type:"literal",value:r.value,datatype:r.datatype?.value,language:r.language,direction:r.direction}}}return e}isVariable(e){return e.type==="variable"}isLiteralElement(e){return e.type==="literal"}isPropertyPath(e){return e.type==="path"}nodeToKey(e){return e.toString()}nodeInSet(e,t){let r=this.nodeToKey(e);for(let i of t)if(this.nodeToKey(i)===r)return!0;return!1}describePath(e){try{let t=e.items,r=a(s=>{if(s&&typeof s=="object"&&"type"in s){let o=s;if(o.type==="iri")return`<${String(o.value)}>`;if(o.type==="path")return this.describePath(o)}return"?"},"renderItem");if(!Array.isArray(t)||t.length===0)return"(?)";if(t.length===1){let s=r(t[0]);return e.pathType==="^"?`(^${s})`:e.pathType==="+"||e.pathType==="*"||e.pathType==="?"?`(${s}${e.pathType})`:`(${s})`}return`(${t.map(r).join(` ${e.pathType} `)})`}catch{return"<unprintable-path>"}}static isStrictModeEnabled(){let e=process.env?.EXOCORTEX_SPARQL_STRICT;if(!e)return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"}};Gl.PropertyPathExecutor=xb});var Cb=S(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});ql.BGPExecutor=ql.BGPExecutorError=void 0;var cp=ss(),No=Ae(),Ab=$e(),up=$t(),fp=Ou(),Sx=bx(),kr=class extends Error{static{a(this,"BGPExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="BGPExecutorError"}};ql.BGPExecutorError=kr;var Rb=class{static{a(this,"BGPExecutor")}constructor(e){this.tripleStore=e,this.propertyPathExecutor=new Sx.PropertyPathExecutor(e)}async*execute(e){if(e.triples.length===0){yield new cp.SolutionMapping;return}let t=this.matchTriplePattern(e.triples[0]);for(let r=1;r<e.triples.length;r++)t=this.joinWithPattern(t,e.triples[r]);for await(let r of t)yield r}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*executeInGraph(e,t){if(e.triples.length===0){yield new cp.SolutionMapping;return}let r=this.matchTriplePatternInGraph(e.triples[0],t);for(let i=1;i<e.triples.length;i++)r=this.joinWithPatternInGraph(r,e.triples[i],t);for await(let i of r)yield i}async*matchTriplePatternInGraph(e,t){if(this.isPropertyPath(e.predicate))throw new kr("Property paths within named graphs are not yet supported");let r=e.predicate;if(this.isLiteral(e.subject)||this.isLiteral(r)){this.warnLiteralGuard("matchTriplePatternInGraph",this.isLiteral(e.subject)?"subject":"predicate",this.isLiteral(e.subject)?e.subject:r);return}let i=this.isVariable(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),s=this.isVariable(r)?void 0:this.toRDFTermAsPredicate(r),o=this.isVariable(e.object)?void 0:this.toRDFTerm(e.object);if(!this.tripleStore.matchInGraph)throw new kr("Triple store does not support named graph operations");let l=await this.tripleStore.matchInGraph(i,s,o,t);for(let c of l){let u=new cp.SolutionMapping;this.isVariable(e.subject)&&u.set(e.subject.value,c.subject),this.isVariable(r)&&u.set(r.value,c.predicate),this.isVariable(e.object)&&u.set(e.object.value,c.object),yield u}}async*joinWithPatternInGraph(e,t,r){let i=[];for await(let s of e)i.push(s);for(let s of i){let o=this.instantiatePattern(t,s);for await(let l of this.matchTriplePatternInGraph(o,r)){let c=s.merge(l);c!==null&&(yield c)}}}async*matchTriplePattern(e){if(this.isPropertyPath(e.predicate)){if(this.isLiteral(e.subject)||this.isLiteral(e.object)){this.warnLiteralGuard("matchTriplePattern.propertyPath",this.isLiteral(e.subject)?"subject":"object",this.isLiteral(e.subject)?e.subject:e.object);return}yield*this.propertyPathExecutor.execute(e.subject,e.predicate,e.object);return}let t=e.predicate;if(this.isLiteral(e.subject)||this.isLiteral(t)){this.warnLiteralGuard("matchTriplePattern",this.isLiteral(e.subject)?"subject":"predicate",this.isLiteral(e.subject)?e.subject:t);return}let r=this.isVariable(e.subject)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),i=this.isVariable(t)?void 0:this.toRDFTermAsPredicate(t),s=this.isVariable(e.object)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object)?void 0:this.toRDFTerm(e.object),o=await this.tripleStore.match(r,i,s);for(let l of o){let c=new cp.SolutionMapping;if(this.isVariable(e.subject))c.set(e.subject.value,l.subject);else if(this.isQuotedTriple(e.subject)){let u=this.matchQuotedTriplePattern(e.subject,l.subject);if(u===null)continue;for(let[f,d]of u.entries())c.set(f,d)}if(this.isVariable(t)&&c.set(t.value,l.predicate),this.isVariable(e.object))c.set(e.object.value,l.object);else if(this.isQuotedTriple(e.object)){let u=this.matchQuotedTriplePattern(e.object,l.object);if(u===null)continue;for(let[f,d]of u.entries())c.set(f,d)}yield c}}hasVariablesInQuotedTriple(e){return!!(this.isVariable(e.subject)||e.predicate.type==="variable"||this.isVariable(e.object)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object))}matchQuotedTriplePattern(e,t){if(!(t instanceof fp.QuotedTriple))return null;let r=new Map;if(this.isVariable(e.subject))r.set(e.subject.value,t.subject);else if(this.isQuotedTriple(e.subject)){let i=this.matchQuotedTriplePattern(e.subject,t.subject);if(i===null)return null;for(let[s,o]of i)r.set(s,o)}else if(!this.elementsMatch(e.subject,t.subject))return null;if(e.predicate.type==="variable")r.set(e.predicate.value,t.predicate);else if(e.predicate.value!==t.predicate.value)return null;if(this.isVariable(e.object))r.set(e.object.value,t.object);else if(this.isQuotedTriple(e.object)){let i=this.matchQuotedTriplePattern(e.object,t.object);if(i===null)return null;for(let[s,o]of i)r.set(s,o)}else if(!this.elementsMatch(e.object,t.object))return null;return r}elementsMatch(e,t){switch(e.type){case"iri":return t instanceof No.IRI&&e.value===t.value;case"literal":return!(!(t instanceof Ab.Literal)||e.value!==t.value||e.datatype!==t.datatype?.value||e.language!==t.language||e.direction!==t.direction);case"blank":return t instanceof up.BlankNode&&e.value===t.id;case"quoted":return t instanceof fp.QuotedTriple?this.toRDFQuotedTriple(e).equals(t):!1;default:return!1}}isPropertyPath(e){return e.type==="path"}async*joinWithPattern(e,t){let r=[];for await(let i of e)r.push(i);for(let i of r){let s=this.instantiatePattern(t,i);for await(let o of this.matchTriplePattern(s)){let l=i.merge(o);l!==null&&(yield l)}}}instantiatePattern(e,t){let r=this.isPropertyPath(e.predicate)?e.predicate:this.instantiateElement(e.predicate,t);return{subject:this.instantiateElement(e.subject,t),predicate:r,object:this.instantiateElement(e.object,t)}}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r)return this.toAlgebraElement(r)}return this.isQuotedTriple(e)?this.instantiateQuotedTriple(e,t):e}instantiateQuotedTriple(e,t){let r=this.instantiateElement(e.subject,t),i=e.predicate.type==="variable"?this.instantiatePredicateVariable(e.predicate,t):e.predicate,s=this.instantiateElement(e.object,t);return{type:"quoted",subject:r,predicate:i,object:s}}instantiatePredicateVariable(e,t){let r=t.get(e.value);return r&&r instanceof No.IRI?{type:"iri",value:r.value}:e}isVariable(e){return e.type==="variable"}isQuotedTriple(e){return e.type==="quoted"}isLiteral(e){return e.type==="literal"}warnLiteralGuard(e,t,r){let i="value"in r?String(r.value):"<unknown>",s=i.length>80?`${i.slice(0,77)}...`:i,o={executor:"BGPExecutor",context:e,position:t,value:s,hint:"Wikilink could not be resolved to IRI (likely label-form wikilink with no matching basename/alias). Check whether the target file exists in the queried vault, add an alias, or load the target vault via --also. See issue #3282."};if(console.error(`[BGPExecutor] literal-safety guard fired in ${e}: literal in ${t} position \u2014 yielding 0 solutions. value="${s}"`,o),Sx.PropertyPathExecutor.isStrictModeEnabled())throw new kr(`Literal in ${t} position (${e}): "${s}". Set EXOCORTEX_SPARQL_STRICT=0 or omit --strict to fall back to warn-and-empty behaviour.`)}toRDFTermAsSubject(e){switch(e.type){case"iri":return new No.IRI(e.value);case"blank":return new up.BlankNode(e.value);case"literal":throw new kr("Literals cannot appear in subject position");case"variable":throw new kr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new kr(`Unknown element type: ${String(e)}`)}}toRDFQuotedTriple(e){let t=this.toRDFTermAsSubject(e.subject),r=e.predicate.type==="iri"?new No.IRI(e.predicate.value):(()=>{throw new kr("Quoted triple predicate must be IRI")})(),i=this.toRDFTerm(e.object);return new fp.QuotedTriple(t,r,i)}toRDFTermAsPredicate(e){switch(e.type){case"iri":return new No.IRI(e.value);case"literal":throw new kr("Literals cannot appear in predicate position");case"blank":throw new kr("Blank nodes cannot appear in predicate position");case"variable":throw new kr(`Cannot convert variable to RDF term: ${e.value}`);default:throw new kr(`Unknown element type: ${String(e)}`)}}toRDFTerm(e){switch(e.type){case"iri":return new No.IRI(e.value);case"literal":return new Ab.Literal(e.value,e.datatype?new No.IRI(e.datatype):void 0,e.language,e.direction);case"blank":return new up.BlankNode(e.value);case"variable":throw new kr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new kr(`Unknown element type: ${String(e)}`)}}toAlgebraElement(e){if(e instanceof No.IRI)return{type:"iri",value:e.value};if(e instanceof Ab.Literal)return{type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language,direction:e.direction};if(e instanceof up.BlankNode)return{type:"blank",value:e.id};if(e instanceof fp.QuotedTriple)return this.toAlgebraQuotedTriple(e);throw new kr(`Unknown RDF term type: ${String(e)}`)}toAlgebraQuotedTriple(e){return{type:"quoted",subject:this.toAlgebraElement(e.subject),predicate:{type:"iri",value:e.predicate.value},object:this.toAlgebraElement(e.object)}}};ql.BGPExecutor=Rb});var wx=S(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});dp.StringFunctions=void 0;var Wl=Ae(),ko=$e(),Pb=$t(),Ku=class n{static{a(this,"StringFunctions")}static str(e){if(e===void 0)throw new Error("STR: argument is undefined");return e instanceof Wl.IRI||e instanceof ko.Literal?e.value:e instanceof Pb.BlankNode?e.id:String(e)}static lang(e){if(e===void 0)throw new Error("LANG: argument is undefined");return e instanceof ko.Literal&&e.language?e.language:""}static langdir(e){if(e===void 0)throw new Error("LANGDIR: argument is undefined");return!(e instanceof ko.Literal)||!e.language?"":e.direction?`${e.language}--${e.direction}`:e.language}static langMatches(e,t){let[r,i]=n.parseDirectionalLangTag(e),[s,o]=n.parseDirectionalLangTag(t),l=r.toLowerCase(),c=s.toLowerCase();return c==="*"?l!=="":l===""?c==="":o&&i!==o?!1:l===c?!0:l.startsWith(c+"-")}static parseDirectionalLangTag(e){let t=e.indexOf("--");if(t===-1)return[e,void 0];let r=e.substring(0,t),i=e.substring(t+2).toLowerCase();return[r,i]}static regex(e,t,r){try{let i=r?r.includes("u")?r:r+"u":"u";return new RegExp(t,i).test(e)}catch(i){throw new Error(`REGEX: invalid pattern '${t}': ${i.message}`)}}static contains(e,t){return e.includes(t)}static strStarts(e,t){return e.startsWith(t)}static strEnds(e,t){return e.endsWith(t)}static strlen(e){return e.length}static ucase(e){return e.toUpperCase()}static lcase(e){return e.toLowerCase()}static substr(e,t,r){let i=t-1;if(i<0){if(r!==void 0){let s=r+i;return s<=0?"":e.substring(0,s)}return e}return r!==void 0?e.substring(i,i+r):e.substring(i)}static strBefore(e,t){if(t==="")return"";let r=e.indexOf(t);return r===-1?"":e.substring(0,r)}static strAfter(e,t){if(t==="")return e;let r=e.indexOf(t);return r===-1?"":e.substring(r+t.length)}static concat(...e){return e.join("")}static replace(e,t,r,i){try{let s=i||"g",o=s.includes("u")?s:s+"u",l=new RegExp(t,o);return e.replace(l,r)}catch(s){throw new Error(`REPLACE: invalid pattern '${t}': ${s.message}`)}}static encodeForUri(e){return encodeURIComponent(e)}static normalize(e,t){if(e===void 0)throw new Error("NORMALIZE: string argument is undefined");let r;if(e instanceof ko.Literal)r=e.value;else if(e instanceof Wl.IRI)r=e.value;else if(e instanceof Pb.BlankNode)r=e.id;else if(typeof e=="string")r=e;else throw new Error("NORMALIZE: first argument must be a string or literal");let i="NFC";if(t!==void 0)if(t instanceof ko.Literal)i=t.value.toUpperCase();else if(typeof t=="string")i=t.toUpperCase();else if(t instanceof Wl.IRI)i=t.value.toUpperCase();else throw new Error("NORMALIZE: second argument must be a string literal");if(!n.VALID_NORMALIZATION_FORMS.includes(i))throw new Error(`NORMALIZE: invalid normalization form '${i}'. Valid forms are: NFC, NFD, NFKC, NFKD`);let s=r.normalize(i);return new ko.Literal(s,new Wl.IRI("http://www.w3.org/2001/XMLSchema#string"))}static fold(e){if(e===void 0)throw new Error("FOLD: string argument is undefined");let t;if(e instanceof ko.Literal)t=e.value;else if(e instanceof Wl.IRI)t=e.value;else if(e instanceof Pb.BlankNode)t=e.id;else if(typeof e=="string")t=e;else throw new Error("FOLD: argument must be a string or literal");let r=n.unicodeCaseFold(t);return new ko.Literal(r,new Wl.IRI("http://www.w3.org/2001/XMLSchema#string"))}static unicodeCaseFold(e){let t="";for(let r of e){let i=n.CASE_FOLDING_MAP.get(r);i!==void 0?t+=i:t+=r.toLowerCase()}return t}};dp.StringFunctions=Ku;Ku.VALID_NORMALIZATION_FORMS=["NFC","NFD","NFKC","NFKD"];Ku.CASE_FOLDING_MAP=new Map([["\xDF","ss"],["\u1E9E","ss"],["\u03A3","\u03C3"],["\u03C2","\u03C3"],["\u0130","i\u0307"],["I","i"],["\u0587","\u0565\u0582"],["\uFB00","ff"],["\uFB01","fi"],["\uFB02","fl"],["\uFB03","ffi"],["\uFB04","ffl"],["\uFB05","st"],["\uFB06","st"],["\u0390","\u03B9\u0308\u0301"],["\u03B0","\u03C5\u0308\u0301"],["\u017F","s"],["\u1E9B","\u1E61"],["\u212A","k"],["\u212B","\xE5"]])});var vx=S(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.MathFunctions=void 0;var Ob=class{static{a(this,"MathFunctions")}static msToMinutes(e){return Math.round(e/(1e3*60))}static msToHours(e){return Math.round(e/(1e3*60*60)*100)/100}static msToSeconds(e){return Math.round(e/1e3)}static abs(e){return Math.abs(e)}static round(e){return Math.round(e)}static ceil(e){return Math.ceil(e)}static floor(e){return Math.floor(e)}static rand(){return Math.random()}};hp.MathFunctions=Ob});var Ju=S(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});pp.DateTimeParsing=void 0;var Y9=Ae(),X9=$e(),Fb=class n{static{a(this,"DateTimeParsing")}static parseDate(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`PARSEDATE: invalid date string '${e}'`);return t.getTime()}static parseDayTimeDuration(e){if(!e)throw new Error("parseDayTimeDuration: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDayTimeDuration: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=r.indexOf("T"),o="",l="";if(s===-1?o=r:(o=r.substring(0,s),l=r.substring(s+1)),o){let c=o.match(/^(\d+(?:\.\d+)?)D$/);if(c){let u=parseFloat(c[1]);i+=u*24*60*60*1e3}else if(o!=="")throw new Error(`parseDayTimeDuration: invalid day component: '${o}' in '${e}'`)}if(l){let c=l,u=c.match(/^(\d+(?:\.\d+)?)H/);if(u){let h=parseFloat(u[1]);i+=h*60*60*1e3,c=c.substring(u[0].length)}let f=c.match(/^(\d+(?:\.\d+)?)M/);if(f){let h=parseFloat(f[1]);i+=h*60*1e3,c=c.substring(f[0].length)}let d=c.match(/^(\d+(?:\.\d+)?)S$/);if(d){let h=parseFloat(d[1]);i+=h*1e3,c=c.substring(d[0].length)}if(c!=="")throw new Error(`parseDayTimeDuration: invalid time component: '${c}' in '${e}'`)}return t?-i:i}static formatDayTimeDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/(1440*60*1e3));r=r%(1440*60*1e3);let s=Math.floor(r/(3600*1e3));r=r%(3600*1e3);let o=Math.floor(r/(60*1e3));r=r%(60*1e3);let l=r/1e3,c=t?"-P":"P";return i>0&&(c+=`${i}D`),(s>0||o>0||l>0||i===0)&&(c+="T",s>0&&(c+=`${s}H`),o>0&&(c+=`${o}M`),(l>0||s===0&&o===0)&&(Number.isInteger(l)?c+=`${l}S`:c+=`${parseFloat(l.toFixed(3))}S`)),c}static xsdDayTimeDuration(e){return n.parseDayTimeDuration(e),new X9.Literal(e,new Y9.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static parseXSDDate(e){let t=/^(-?\d{4})-(\d{2})-(\d{2})(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r){let u=new Date(e);return isNaN(u.getTime())?null:new Date(Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()))}let i=parseInt(r[1],10),s=parseInt(r[2],10)-1,o=parseInt(r[3],10),l=r[4],c=new Date(Date.UTC(i,s,o));if(l&&l!=="Z"){let u=l.match(/([+-])(\d{2}):(\d{2})/);if(u){let f=u[1]==="+"?1:-1,d=parseInt(u[2],10),h=parseInt(u[3],10),p=f*(d*60+h)*60*1e3;c=new Date(c.getTime()-p)}}return c}static parseXSDTime(e){let t=/^(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r)return null;let i=parseInt(r[1],10),s=parseInt(r[2],10),o=parseInt(r[3],10),l=r[4],c=r[5];if(i<0||i>24||s<0||s>59||o<0||o>59||i===24&&(s!==0||o!==0))return null;let u=0;if(l){let d=l.padEnd(3,"0").slice(0,3);u=parseInt(d,10)}let f=i*60*60*1e3+s*60*1e3+o*1e3+u;if(i===24&&(f=1440*60*1e3),c&&c!=="Z"){let d=c.match(/([+-])(\d{2}):(\d{2})/);if(d){let h=d[1]==="+"?1:-1,p=parseInt(d[2],10),g=parseInt(d[3],10),_=h*(p*60+g)*60*1e3;f-=_}}return f}static formatDateDuration(e){if(e===0)return"P0D";let t=e<0,r=Math.abs(e);return t?`-P${r}D`:`P${r}D`}static parseYearMonthDuration(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDuration: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),o=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDuration: invalid format (no duration components): '${e}'`);let l=s*12+o;return i?-l:l}static formatYearMonthDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/12),s=r%12,o=t?"-P":"P";return i>0&&(o+=`${i}Y`),(s>0||i===0)&&(o+=`${s}M`),o}static parseYearMonthDurationComponents(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDurationComponents: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),o=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDurationComponents: invalid format (no duration components): '${e}'`);return{years:s,months:o,negative:i}}static parseDurationComponents(e){if(!e)throw new Error("parseDurationComponents: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDurationComponents: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=0,o=0,l=0,c=r.indexOf("T"),u="",f="";if(c===-1?u=r:(u=r.substring(0,c),f=r.substring(c+1)),u){let d=u.match(/^(\d+(?:\.\d+)?)D$/);if(d)i=parseFloat(d[1]);else if(u!=="")throw new Error(`parseDurationComponents: invalid day component: '${u}' in '${e}'`)}if(f){let d=f,h=d.match(/^(\d+(?:\.\d+)?)H/);h&&(s=parseFloat(h[1]),d=d.substring(h[0].length));let p=d.match(/^(\d+(?:\.\d+)?)M/);p&&(o=parseFloat(p[1]),d=d.substring(p[0].length));let g=d.match(/^(\d+(?:\.\d+)?)S$/);if(g&&(l=parseFloat(g[1]),d=d.substring(g[0].length)),d!=="")throw new Error(`parseDurationComponents: invalid time component: '${d}' in '${e}'`)}return{negative:t,days:i,hours:s,minutes:o,seconds:l}}};pp.DateTimeParsing=Fb});var Ex=S(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.DateTimeArithmetic=void 0;var fn=Ae(),Fe=$e(),rt=Ju(),Db=class{static{a(this,"DateTimeArithmetic")}static dateTimeDiff(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r),o=new Date(i);if(isNaN(s.getTime()))throw new Error(`dateTimeDiff: invalid first dateTime: '${r}'`);if(isNaN(o.getTime()))throw new Error(`dateTimeDiff: invalid second dateTime: '${i}'`);let l=s.getTime()-o.getTime(),c=rt.DateTimeParsing.formatDayTimeDuration(l);return new Fe.Literal(c,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static dateTimeAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAdd: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()+o,c=new Date(l);return new Fe.Literal(c.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtract: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()-o,c=new Date(l);return new Fe.Literal(c.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateAdd: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()+o,c=new Date(l),u=c.getUTCFullYear(),f=String(c.getUTCMonth()+1).padStart(2,"0"),d=String(c.getUTCDate()).padStart(2,"0"),h=`${u}-${f}-${d}`;return new Fe.Literal(h,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateSubtract: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()-o,c=new Date(l),u=c.getUTCFullYear(),f=String(c.getUTCMonth()+1).padStart(2,"0"),d=String(c.getUTCDate()).padStart(2,"0"),h=`${u}-${f}-${d}`;return new Fe.Literal(h,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateTimeAddYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAddYearMonth: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()+o),s.getUTCDate()!==l&&s.setUTCDate(0),new Fe.Literal(s.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtractYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtractYearMonth: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()-o),s.getUTCDate()!==l&&s.setUTCDate(0),new Fe.Literal(s.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAddYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateAddYearMonth: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()+o),s.getUTCDate()!==l&&s.setUTCDate(0);let c=s.getUTCFullYear(),u=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),d=`${c}-${u}-${f}`;return new Fe.Literal(d,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtractYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateSubtractYearMonth: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()-o),s.getUTCDate()!==l&&s.setUTCDate(0);let c=s.getUTCFullYear(),u=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),d=`${c}-${u}-${f}`;return new Fe.Literal(d,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static durationAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseDayTimeDuration(r),o=rt.DateTimeParsing.parseDayTimeDuration(i),l=rt.DateTimeParsing.formatDayTimeDuration(s+o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseDayTimeDuration(r),o=rt.DateTimeParsing.parseDayTimeDuration(i),l=rt.DateTimeParsing.formatDayTimeDuration(s-o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationMultiply(e,t){let r=e instanceof Fe.Literal?e.value:e,i=rt.DateTimeParsing.parseDayTimeDuration(r),s=rt.DateTimeParsing.formatDayTimeDuration(i*t);return new Fe.Literal(s,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationDivide(e,t){if(t===0)throw new Error("durationDivide: division by zero");let r=e instanceof Fe.Literal?e.value:e,i=rt.DateTimeParsing.parseDayTimeDuration(r),s=rt.DateTimeParsing.formatDayTimeDuration(i/t);return new Fe.Literal(s,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static yearMonthDurationAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseYearMonthDuration(r),o=rt.DateTimeParsing.parseYearMonthDuration(i),l=rt.DateTimeParsing.formatYearMonthDuration(s+o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static yearMonthDurationSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseYearMonthDuration(r),o=rt.DateTimeParsing.parseYearMonthDuration(i),l=rt.DateTimeParsing.formatYearMonthDuration(s-o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static durationToDays(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/(1440*60*1e3)}static durationToHours(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/(3600*1e3)}static durationToMinutes(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/(60*1e3)}static durationToSeconds(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/1e3}};mp.DateTimeArithmetic=Db});var Tx=S(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});gp.DateTimeAccessors=void 0;var Zu=Ae(),Ut=$e(),At=Ju(),Lb=class{static{a(this,"DateTimeAccessors")}static year(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`YEAR: invalid date string '${e}'`);return t.getFullYear()}static month(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MONTH: invalid date string '${e}'`);return t.getMonth()+1}static day(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`DAY: invalid date string '${e}'`);return t.getDate()}static hours(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`HOURS: invalid date string '${e}'`);return t.getHours()}static minutes(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MINUTES: invalid date string '${e}'`);return t.getMinutes()}static seconds(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`SECONDS: invalid date string '${e}'`);return t.getSeconds()+t.getMilliseconds()/1e3}static durationDays(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t),i=Math.floor(r.days);return r.negative?-i:i}static durationHours(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t),i=Math.floor(r.hours);return r.negative?-i:i}static durationMinutes(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t),i=Math.floor(r.minutes);return r.negative?-i:i}static durationSeconds(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t);return r.negative?-r.seconds:r.seconds}static durationYears(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseYearMonthDurationComponents(t);return r.negative?-r.years:r.years}static durationMonths(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseYearMonthDurationComponents(t);return r.negative?-r.months:r.months}static timezone(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TIMEZONE: invalid date string '${e}'`);let r;if(e.endsWith("Z"))r="PT0S";else{let i=e.match(/([+-]\d{2}):?(\d{2})$/);if(i){let s=parseInt(i[1],10),o=parseInt(i[2],10),l=s>=0?"":"-",c=Math.abs(s);o===0?r=`${l}PT${c}H`:r=`${l}PT${c}H${o}M`}else{let s=-t.getTimezoneOffset(),o=Math.floor(Math.abs(s)/60),l=Math.abs(s)%60,c=s>=0?"":"-";l===0?r=`${c}PT${o}H`:r=`${c}PT${o}H${l}M`}}return new Ut.Literal(r,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static tz(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TZ: invalid date string '${e}'`);if(e.endsWith("Z"))return"Z";let r=e.match(/([+-]\d{2}:\d{2})$/);if(r)return r[1];let i=e.match(/([+-])(\d{2})(\d{2})$/);return i?`${i[1]}${i[2]}:${i[3]}`:""}static adjust(e,t){let r=e instanceof Ut.Literal?e.value:e,i=new Date(r);if(isNaN(i.getTime()))throw new Error(`ADJUST: invalid dateTime: '${r}'`);if(t==null){let K=i.getUTCFullYear(),oe=String(i.getUTCMonth()+1).padStart(2,"0"),me=String(i.getUTCDate()).padStart(2,"0"),N=String(i.getUTCHours()).padStart(2,"0"),Q=String(i.getUTCMinutes()).padStart(2,"0"),ie=String(i.getUTCSeconds()).padStart(2,"0"),V=i.getUTCMilliseconds(),Y=`${K}-${oe}-${me}T${N}:${Q}:${ie}`;return V>0&&(Y+=`.${String(V).padStart(3,"0")}`),new Ut.Literal(Y,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}let s=t instanceof Ut.Literal?t.value:t,o=At.DateTimeParsing.parseDayTimeDuration(s),l=840*60*1e3;if(Math.abs(o)>l)throw new Error(`ADJUST: timezone offset out of range: '${s}'`);let c=i.getTime(),u=new Date(c+o),f=u.getUTCFullYear(),d=String(u.getUTCMonth()+1).padStart(2,"0"),h=String(u.getUTCDate()).padStart(2,"0"),p=String(u.getUTCHours()).padStart(2,"0"),g=String(u.getUTCMinutes()).padStart(2,"0"),_=String(u.getUTCSeconds()).padStart(2,"0"),v=u.getUTCMilliseconds(),w=o>=0?"+":"-",E=Math.floor(Math.abs(o)/(3600*1e3)),I=Math.floor(Math.abs(o)%(3600*1e3)/(60*1e3)),A=`${w}${String(E).padStart(2,"0")}:${String(I).padStart(2,"0")}`,D=`${f}-${d}-${h}T${p}:${g}:${_}`;return v>0&&(D+=`.${String(v).padStart(3,"0")}`),D+=A,new Ut.Literal(D,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static now(){return new Date().toISOString()}static dateBefore(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t);return r<i}static dateAfter(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t);return r>i}static dateInRange(e,t,r){let i=At.DateTimeParsing.parseDate(e),s=At.DateTimeParsing.parseDate(t),o=At.DateTimeParsing.parseDate(r);return i>=s&&i<=o}static compareDurations(e,t,r){let i=e instanceof Ut.Literal?e.value:e,s=t instanceof Ut.Literal?t.value:t,o=At.DateTimeParsing.parseDayTimeDuration(i),l=At.DateTimeParsing.parseDayTimeDuration(s);switch(r){case"=":return o===l;case"!=":return o!==l;case"<":return o<l;case">":return o>l;case"<=":return o<=l;case">=":return o>=l;default:throw new Error(`compareDurations: unknown operator: ${r}`)}}static dateDiffMinutes(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60))}static dateDiffHours(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60*60)*100)/100}static timeDiff(e,t){let r=e instanceof Ut.Literal?e.value:e,i=t instanceof Ut.Literal?t.value:t,s=At.DateTimeParsing.parseXSDTime(r),o=At.DateTimeParsing.parseXSDTime(i);if(s===null)throw new Error(`timeDiff: invalid first time: '${r}'`);if(o===null)throw new Error(`timeDiff: invalid second time: '${i}'`);let l=s-o,c=At.DateTimeParsing.formatDayTimeDuration(l);return new Ut.Literal(c,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static isDayTimeDuration(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static isDate(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}static isYearMonthDuration(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}static isTime(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}static dateDiff(e,t){let r=e instanceof Ut.Literal?e.value:e,i=t instanceof Ut.Literal?t.value:t,s=At.DateTimeParsing.parseXSDDate(r),o=At.DateTimeParsing.parseXSDDate(i);if(s===null)throw new Error(`dateDiff: invalid first date: '${r}'`);if(o===null)throw new Error(`dateDiff: invalid second date: '${i}'`);let l=s.getTime()-o.getTime(),c=Math.round(l/(1440*60*1e3)),u=At.DateTimeParsing.formatDateDuration(c);return new Ut.Literal(u,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}};gp.DateTimeAccessors=Lb});var _p=S(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});yp.DateTimeFunctions=void 0;var zl=Ju(),ur=Ex(),_t=Tx(),Nb=class{static{a(this,"DateTimeFunctions")}static parseDate(e){return zl.DateTimeParsing.parseDate(e)}static parseDayTimeDuration(e){return zl.DateTimeParsing.parseDayTimeDuration(e)}static formatDayTimeDuration(e){return zl.DateTimeParsing.formatDayTimeDuration(e)}static xsdDayTimeDuration(e){return zl.DateTimeParsing.xsdDayTimeDuration(e)}static parseYearMonthDuration(e){return zl.DateTimeParsing.parseYearMonthDuration(e)}static formatYearMonthDuration(e){return zl.DateTimeParsing.formatYearMonthDuration(e)}static year(e){return _t.DateTimeAccessors.year(e)}static month(e){return _t.DateTimeAccessors.month(e)}static day(e){return _t.DateTimeAccessors.day(e)}static hours(e){return _t.DateTimeAccessors.hours(e)}static minutes(e){return _t.DateTimeAccessors.minutes(e)}static seconds(e){return _t.DateTimeAccessors.seconds(e)}static durationDays(e){return _t.DateTimeAccessors.durationDays(e)}static durationHours(e){return _t.DateTimeAccessors.durationHours(e)}static durationMinutes(e){return _t.DateTimeAccessors.durationMinutes(e)}static durationSeconds(e){return _t.DateTimeAccessors.durationSeconds(e)}static durationYears(e){return _t.DateTimeAccessors.durationYears(e)}static durationMonths(e){return _t.DateTimeAccessors.durationMonths(e)}static timezone(e){return _t.DateTimeAccessors.timezone(e)}static tz(e){return _t.DateTimeAccessors.tz(e)}static adjust(e,t){return _t.DateTimeAccessors.adjust(e,t)}static now(){return _t.DateTimeAccessors.now()}static dateBefore(e,t){return _t.DateTimeAccessors.dateBefore(e,t)}static dateAfter(e,t){return _t.DateTimeAccessors.dateAfter(e,t)}static dateInRange(e,t,r){return _t.DateTimeAccessors.dateInRange(e,t,r)}static compareDurations(e,t,r){return _t.DateTimeAccessors.compareDurations(e,t,r)}static dateDiffMinutes(e,t){return _t.DateTimeAccessors.dateDiffMinutes(e,t)}static dateDiffHours(e,t){return _t.DateTimeAccessors.dateDiffHours(e,t)}static timeDiff(e,t){return _t.DateTimeAccessors.timeDiff(e,t)}static dateDiff(e,t){return _t.DateTimeAccessors.dateDiff(e,t)}static isDayTimeDuration(e){return _t.DateTimeAccessors.isDayTimeDuration(e)}static isDate(e){return _t.DateTimeAccessors.isDate(e)}static isYearMonthDuration(e){return _t.DateTimeAccessors.isYearMonthDuration(e)}static isTime(e){return _t.DateTimeAccessors.isTime(e)}static dateTimeDiff(e,t){return ur.DateTimeArithmetic.dateTimeDiff(e,t)}static dateTimeAdd(e,t){return ur.DateTimeArithmetic.dateTimeAdd(e,t)}static dateTimeSubtract(e,t){return ur.DateTimeArithmetic.dateTimeSubtract(e,t)}static dateAdd(e,t){return ur.DateTimeArithmetic.dateAdd(e,t)}static dateSubtract(e,t){return ur.DateTimeArithmetic.dateSubtract(e,t)}static dateTimeAddYearMonth(e,t){return ur.DateTimeArithmetic.dateTimeAddYearMonth(e,t)}static dateTimeSubtractYearMonth(e,t){return ur.DateTimeArithmetic.dateTimeSubtractYearMonth(e,t)}static dateAddYearMonth(e,t){return ur.DateTimeArithmetic.dateAddYearMonth(e,t)}static dateSubtractYearMonth(e,t){return ur.DateTimeArithmetic.dateSubtractYearMonth(e,t)}static durationAdd(e,t){return ur.DateTimeArithmetic.durationAdd(e,t)}static durationSubtract(e,t){return ur.DateTimeArithmetic.durationSubtract(e,t)}static durationMultiply(e,t){return ur.DateTimeArithmetic.durationMultiply(e,t)}static durationDivide(e,t){return ur.DateTimeArithmetic.durationDivide(e,t)}static yearMonthDurationAdd(e,t){return ur.DateTimeArithmetic.yearMonthDurationAdd(e,t)}static yearMonthDurationSubtract(e,t){return ur.DateTimeArithmetic.yearMonthDurationSubtract(e,t)}static durationToDays(e){return ur.DateTimeArithmetic.durationToDays(e)}static durationToHours(e){return ur.DateTimeArithmetic.durationToHours(e)}static durationToMinutes(e){return ur.DateTimeArithmetic.durationToMinutes(e)}static durationToSeconds(e){return ur.DateTimeArithmetic.durationToSeconds(e)}};yp.DateTimeFunctions=Nb});var Ix=S(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});Sp.LogicalFunctions=void 0;var K9=Ae(),Hl=$e(),J9=$t(),bp=_p(),kb=class n{static{a(this,"LogicalFunctions")}static compare(e,t,r){if(n.isDayTimeDurationValue(e)&&n.isDayTimeDurationValue(t))return bp.DateTimeFunctions.compareDurations(e instanceof Hl.Literal?e:String(e),t instanceof Hl.Literal?t:String(t),r);if(n.isDayTimeDurationValue(e)&&typeof t=="string"&&/^-?P/.test(t))return bp.DateTimeFunctions.compareDurations(e instanceof Hl.Literal?e:String(e),t,r);if(typeof e=="string"&&/^-?P/.test(e)&&n.isDayTimeDurationValue(t))return bp.DateTimeFunctions.compareDurations(e,t instanceof Hl.Literal?t:String(t),r);let i=n.toComparableValue(e),s=n.toComparableValue(t);switch(r){case"=":return i===s;case"!=":return i!==s;case"<":return i<s;case">":return i>s;case"<=":return i<=s;case">=":return i>=s;default:throw new Error(`Unknown comparison operator: ${r}`)}}static isDayTimeDurationValue(e){return e instanceof Hl.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static toComparableValue(e){if(typeof e=="string"||typeof e=="number")return e;if(e instanceof Hl.Literal){let t=e.datatype?.value;if(t?.includes("#integer")||t?.includes("#decimal")||t?.includes("#double")){let r=parseFloat(e.value);if(!isNaN(r))return r}if(t==="http://www.w3.org/2001/XMLSchema#dayTimeDuration")try{return bp.DateTimeFunctions.parseDayTimeDuration(e.value)}catch{return e.value}return e.value}return e instanceof K9.IRI?e.value:e instanceof J9.BlankNode?e.id:String(e)}static logicalAnd(e){return e.every(t=>t===!0)}static logicalOr(e){return e.some(t=>t===!0)}static logicalNot(e){return!e}static coalesce(e){for(let t of e)if(t!=null)return t}static if(e,t,r){return e?t:r}};Sp.LogicalFunctions=kb});var xx=S(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});wp.RDFTermFunctions=void 0;var Mr=Ae(),Et=$e(),_i=$t(),Ql=Ou(),Mb=mi(),jb=class n{static{a(this,"RDFTermFunctions")}static datatype(e){if(e===void 0)throw new Error("DATATYPE: argument is undefined");if(e instanceof Et.Literal)return e.datatype?e.datatype:e.language?new Mr.IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"):new Mr.IRI("http://www.w3.org/2001/XMLSchema#string");throw new Error("DATATYPE: argument must be a literal")}static bound(e){return e!==void 0}static isIRI(e){return e===void 0?!1:e instanceof Mr.IRI}static isBlank(e){return e===void 0?!1:e instanceof _i.BlankNode}static isLiteral(e){return e===void 0?!1:e instanceof Et.Literal}static isTriple(e){return e===void 0?!1:e instanceof Ql.QuotedTriple}static hasLangdir(e){return e===void 0||!(e instanceof Et.Literal)?!1:!!e.language&&!!e.direction}static isNumeric(e){if(e===void 0||!(e instanceof Et.Literal))return!1;let t=e.datatype?.value;return t?["http://www.w3.org/2001/XMLSchema#integer","http://www.w3.org/2001/XMLSchema#decimal","http://www.w3.org/2001/XMLSchema#float","http://www.w3.org/2001/XMLSchema#double","http://www.w3.org/2001/XMLSchema#nonPositiveInteger","http://www.w3.org/2001/XMLSchema#negativeInteger","http://www.w3.org/2001/XMLSchema#long","http://www.w3.org/2001/XMLSchema#int","http://www.w3.org/2001/XMLSchema#short","http://www.w3.org/2001/XMLSchema#byte","http://www.w3.org/2001/XMLSchema#nonNegativeInteger","http://www.w3.org/2001/XMLSchema#unsignedLong","http://www.w3.org/2001/XMLSchema#unsignedInt","http://www.w3.org/2001/XMLSchema#unsignedShort","http://www.w3.org/2001/XMLSchema#unsignedByte","http://www.w3.org/2001/XMLSchema#positiveInteger"].includes(t):!1}static xsdDateTime(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`xsd:dateTime: invalid date string '${e}'`);return new Et.Literal(t.toISOString(),new Mr.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static xsdInteger(e){let t=parseInt(e,10);if(isNaN(t))throw new Error(`xsd:integer: cannot convert '${e}' to integer`);return new Et.Literal(String(t),new Mr.IRI("http://www.w3.org/2001/XMLSchema#integer"))}static xsdDecimal(e){let t=parseFloat(e);if(isNaN(t))throw new Error(`xsd:decimal: cannot convert '${e}' to decimal`);return new Et.Literal(String(t),new Mr.IRI("http://www.w3.org/2001/XMLSchema#decimal"))}static sameTerm(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0||e.constructor!==t.constructor)return!1;if(e instanceof Mr.IRI&&t instanceof Mr.IRI)return e.value===t.value;if(e instanceof _i.BlankNode&&t instanceof _i.BlankNode)return e.id===t.id;if(e instanceof Et.Literal&&t instanceof Et.Literal){if(e.value!==t.value||e.language!==t.language)return!1;let r=e.datatype?.value,i=t.datatype?.value;return r===i}return!1}static iri(e){if(e===void 0)throw new Error("IRI: argument is undefined");if(e instanceof Mr.IRI)return e;if(e instanceof Et.Literal)return new Mr.IRI(e.value);throw e instanceof _i.BlankNode?new Error("IRI: cannot convert blank node to IRI"):new Error("IRI: unsupported term type")}static uri(e){return n.iri(e)}static bnode(e){if(e===void 0){let t=`b${(0,Mb.v4)().replace(/-/g,"").substring(0,12)}`;return new _i.BlankNode(t)}if(e instanceof Et.Literal)return new _i.BlankNode(e.value);if(e instanceof _i.BlankNode)return e;throw new Error("BNODE: argument must be a string literal or omitted")}static strdt(e,t){if(e===void 0)throw new Error("STRDT: lexical form is undefined");if(t===void 0)throw new Error("STRDT: datatype IRI is undefined");let r;if(e instanceof Et.Literal){if(e.language)throw new Error("STRDT: lexical form must not have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRDT: lexical form must be a string literal");let i;if(t instanceof Mr.IRI)i=t;else if(t instanceof Et.Literal)i=new Mr.IRI(t.value);else throw new Error("STRDT: datatype must be an IRI");return new Et.Literal(r,i)}static strlang(e,t){if(e===void 0)throw new Error("STRLANG: lexical form is undefined");if(t===void 0)throw new Error("STRLANG: language tag is undefined");let r;if(e instanceof Et.Literal){if(e.language)throw new Error("STRLANG: lexical form must not already have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRLANG: lexical form must be a string literal");let i;if(t instanceof Et.Literal)i=t.value;else if(typeof t=="string")i=t;else throw new Error("STRLANG: language tag must be a string literal");if(i==="")throw new Error("STRLANG: language tag cannot be empty");return new Et.Literal(r,void 0,i)}static strlangdir(e,t,r){if(e===void 0)throw new Error("STRLANGDIR: lexical form is undefined");if(t===void 0)throw new Error("STRLANGDIR: language tag is undefined");if(r===void 0)throw new Error("STRLANGDIR: direction is undefined");let i;if(e instanceof Et.Literal){if(e.language)throw new Error("STRLANGDIR: lexical form must not already have a language tag");i=e.value}else if(typeof e=="string")i=e;else throw new Error("STRLANGDIR: lexical form must be a string literal");let s;if(t instanceof Et.Literal)s=t.value;else if(typeof t=="string")s=t;else throw new Error("STRLANGDIR: language tag must be a string literal");if(s==="")throw new Error("STRLANGDIR: language tag cannot be empty");let o;if(r instanceof Et.Literal)o=r.value.toLowerCase();else throw new Error("STRLANGDIR: direction must be a string literal");if(o!=="ltr"&&o!=="rtl")throw new Error(`STRLANGDIR: invalid direction '${o}'. Must be 'ltr' or 'rtl'`);return new Et.Literal(i,void 0,s,o)}static uuid(){let e=(0,Mb.v4)();return new Mr.IRI(`urn:uuid:${e}`)}static struuid(){let e=(0,Mb.v4)();return new Et.Literal(e)}static triple(e,t,r){if(e===void 0)throw new Error("TRIPLE: subject is undefined");if(t===void 0)throw new Error("TRIPLE: predicate is undefined");if(r===void 0)throw new Error("TRIPLE: object is undefined");if(e instanceof Et.Literal)throw new Error("TRIPLE: subject must be IRI, BlankNode, or QuotedTriple, got Literal");if(!(t instanceof Mr.IRI)){let l=t instanceof Et.Literal?"Literal":t instanceof _i.BlankNode?"BlankNode":t instanceof Ql.QuotedTriple?"QuotedTriple":typeof t;throw new Error(`TRIPLE: predicate must be IRI, got ${l}`)}let i=e,s=t,o=r;return new Ql.QuotedTriple(i,s,o)}static subject(e){if(e===void 0)throw new Error("SUBJECT: argument is undefined");if(!(e instanceof Ql.QuotedTriple)){let t=e instanceof Mr.IRI?"IRI":e instanceof Et.Literal?"Literal":e instanceof _i.BlankNode?"BlankNode":typeof e;throw new Error(`SUBJECT: argument must be QuotedTriple, got ${t}`)}return e.subject}static predicate(e){if(e===void 0)throw new Error("PREDICATE: argument is undefined");if(!(e instanceof Ql.QuotedTriple)){let t=e instanceof Mr.IRI?"IRI":e instanceof Et.Literal?"Literal":e instanceof _i.BlankNode?"BlankNode":typeof e;throw new Error(`PREDICATE: argument must be QuotedTriple, got ${t}`)}return e.predicate}static object(e){if(e===void 0)throw new Error("OBJECT: argument is undefined");if(!(e instanceof Ql.QuotedTriple)){let t=e instanceof Mr.IRI?"IRI":e instanceof Et.Literal?"Literal":e instanceof _i.BlankNode?"BlankNode":typeof e;throw new Error(`OBJECT: argument must be QuotedTriple, got ${t}`)}return e.object}};wp.RDFTermFunctions=jb});var Ax=S(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});vp.HashFunctions=void 0;var $b=class{static{a(this,"HashFunctions")}static md5(e){return require("crypto").createHash("md5").update(e).digest("hex")}static sha1(e){return require("crypto").createHash("sha1").update(e).digest("hex")}static sha256(e){return require("crypto").createHash("sha256").update(e).digest("hex")}static sha384(e){return require("crypto").createHash("sha384").update(e).digest("hex")}static sha512(e){return require("crypto").createHash("sha512").update(e).digest("hex")}};vp.HashFunctions=$b});var Tp=S(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});Ep.BuiltInFunctions=void 0;var fr=wx(),Mo=vx(),de=_p(),Yl=Ix(),Ot=xx(),ef=Ax(),Ub=class{static{a(this,"BuiltInFunctions")}static str(...e){return fr.StringFunctions.str(...e)}static lang(...e){return fr.StringFunctions.lang(...e)}static langdir(...e){return fr.StringFunctions.langdir(...e)}static langMatches(...e){return fr.StringFunctions.langMatches(...e)}static regex(...e){return fr.StringFunctions.regex(...e)}static contains(...e){return fr.StringFunctions.contains(...e)}static strStarts(...e){return fr.StringFunctions.strStarts(...e)}static strEnds(...e){return fr.StringFunctions.strEnds(...e)}static strlen(...e){return fr.StringFunctions.strlen(...e)}static ucase(...e){return fr.StringFunctions.ucase(...e)}static lcase(...e){return fr.StringFunctions.lcase(...e)}static substr(...e){return fr.StringFunctions.substr(...e)}static strBefore(...e){return fr.StringFunctions.strBefore(...e)}static strAfter(...e){return fr.StringFunctions.strAfter(...e)}static concat(...e){return fr.StringFunctions.concat(...e)}static replace(...e){return fr.StringFunctions.replace(...e)}static encodeForUri(...e){return fr.StringFunctions.encodeForUri(...e)}static normalize(...e){return fr.StringFunctions.normalize(...e)}static fold(...e){return fr.StringFunctions.fold(...e)}static abs(...e){return Mo.MathFunctions.abs(...e)}static round(...e){return Mo.MathFunctions.round(...e)}static ceil(...e){return Mo.MathFunctions.ceil(...e)}static floor(...e){return Mo.MathFunctions.floor(...e)}static rand(){return Mo.MathFunctions.rand()}static msToMinutes(...e){return Mo.MathFunctions.msToMinutes(...e)}static msToHours(...e){return Mo.MathFunctions.msToHours(...e)}static msToSeconds(...e){return Mo.MathFunctions.msToSeconds(...e)}static parseDate(...e){return de.DateTimeFunctions.parseDate(...e)}static dateBefore(...e){return de.DateTimeFunctions.dateBefore(...e)}static dateAfter(...e){return de.DateTimeFunctions.dateAfter(...e)}static dateInRange(...e){return de.DateTimeFunctions.dateInRange(...e)}static dateDiffMinutes(...e){return de.DateTimeFunctions.dateDiffMinutes(...e)}static dateDiffHours(...e){return de.DateTimeFunctions.dateDiffHours(...e)}static year(...e){return de.DateTimeFunctions.year(...e)}static month(...e){return de.DateTimeFunctions.month(...e)}static day(...e){return de.DateTimeFunctions.day(...e)}static hours(...e){return de.DateTimeFunctions.hours(...e)}static minutes(...e){return de.DateTimeFunctions.minutes(...e)}static seconds(...e){return de.DateTimeFunctions.seconds(...e)}static timezone(...e){return de.DateTimeFunctions.timezone(...e)}static tz(...e){return de.DateTimeFunctions.tz(...e)}static now(){return de.DateTimeFunctions.now()}static parseDayTimeDuration(...e){return de.DateTimeFunctions.parseDayTimeDuration(...e)}static formatDayTimeDuration(...e){return de.DateTimeFunctions.formatDayTimeDuration(...e)}static xsdDayTimeDuration(...e){return de.DateTimeFunctions.xsdDayTimeDuration(...e)}static compareDurations(...e){return de.DateTimeFunctions.compareDurations(...e)}static isDayTimeDuration(...e){return de.DateTimeFunctions.isDayTimeDuration(...e)}static isDate(...e){return de.DateTimeFunctions.isDate(...e)}static dateDiff(...e){return de.DateTimeFunctions.dateDiff(...e)}static dateTimeDiff(...e){return de.DateTimeFunctions.dateTimeDiff(...e)}static dateTimeAdd(...e){return de.DateTimeFunctions.dateTimeAdd(...e)}static dateTimeSubtract(...e){return de.DateTimeFunctions.dateTimeSubtract(...e)}static dateAdd(...e){return de.DateTimeFunctions.dateAdd(...e)}static dateSubtract(...e){return de.DateTimeFunctions.dateSubtract(...e)}static parseYearMonthDuration(...e){return de.DateTimeFunctions.parseYearMonthDuration(...e)}static isYearMonthDuration(...e){return de.DateTimeFunctions.isYearMonthDuration(...e)}static dateTimeAddYearMonth(...e){return de.DateTimeFunctions.dateTimeAddYearMonth(...e)}static dateTimeSubtractYearMonth(...e){return de.DateTimeFunctions.dateTimeSubtractYearMonth(...e)}static dateAddYearMonth(...e){return de.DateTimeFunctions.dateAddYearMonth(...e)}static dateSubtractYearMonth(...e){return de.DateTimeFunctions.dateSubtractYearMonth(...e)}static durationAdd(...e){return de.DateTimeFunctions.durationAdd(...e)}static durationSubtract(...e){return de.DateTimeFunctions.durationSubtract(...e)}static durationMultiply(...e){return de.DateTimeFunctions.durationMultiply(...e)}static durationDivide(...e){return de.DateTimeFunctions.durationDivide(...e)}static formatYearMonthDuration(...e){return de.DateTimeFunctions.formatYearMonthDuration(...e)}static yearMonthDurationAdd(...e){return de.DateTimeFunctions.yearMonthDurationAdd(...e)}static yearMonthDurationSubtract(...e){return de.DateTimeFunctions.yearMonthDurationSubtract(...e)}static durationYears(...e){return de.DateTimeFunctions.durationYears(...e)}static durationMonths(...e){return de.DateTimeFunctions.durationMonths(...e)}static durationToDays(...e){return de.DateTimeFunctions.durationToDays(...e)}static durationToHours(...e){return de.DateTimeFunctions.durationToHours(...e)}static durationToMinutes(...e){return de.DateTimeFunctions.durationToMinutes(...e)}static durationToSeconds(...e){return de.DateTimeFunctions.durationToSeconds(...e)}static durationDays(...e){return de.DateTimeFunctions.durationDays(...e)}static durationHours(...e){return de.DateTimeFunctions.durationHours(...e)}static durationMinutes(...e){return de.DateTimeFunctions.durationMinutes(...e)}static durationSeconds(...e){return de.DateTimeFunctions.durationSeconds(...e)}static adjust(...e){return de.DateTimeFunctions.adjust(...e)}static isTime(...e){return de.DateTimeFunctions.isTime(...e)}static timeDiff(...e){return de.DateTimeFunctions.timeDiff(...e)}static compare(...e){return Yl.LogicalFunctions.compare(...e)}static logicalAnd(...e){return Yl.LogicalFunctions.logicalAnd(...e)}static logicalOr(...e){return Yl.LogicalFunctions.logicalOr(...e)}static logicalNot(...e){return Yl.LogicalFunctions.logicalNot(...e)}static coalesce(...e){return Yl.LogicalFunctions.coalesce(...e)}static if(...e){return Yl.LogicalFunctions.if(...e)}static datatype(...e){return Ot.RDFTermFunctions.datatype(...e)}static bound(...e){return Ot.RDFTermFunctions.bound(...e)}static isIRI(...e){return Ot.RDFTermFunctions.isIRI(...e)}static isBlank(...e){return Ot.RDFTermFunctions.isBlank(...e)}static isLiteral(...e){return Ot.RDFTermFunctions.isLiteral(...e)}static isTriple(...e){return Ot.RDFTermFunctions.isTriple(...e)}static isNumeric(...e){return Ot.RDFTermFunctions.isNumeric(...e)}static hasLangdir(...e){return Ot.RDFTermFunctions.hasLangdir(...e)}static sameTerm(...e){return Ot.RDFTermFunctions.sameTerm(...e)}static iri(...e){return Ot.RDFTermFunctions.iri(...e)}static uri(...e){return Ot.RDFTermFunctions.uri(...e)}static bnode(...e){return Ot.RDFTermFunctions.bnode(...e)}static strdt(...e){return Ot.RDFTermFunctions.strdt(...e)}static strlang(...e){return Ot.RDFTermFunctions.strlang(...e)}static strlangdir(...e){return Ot.RDFTermFunctions.strlangdir(...e)}static uuid(){return Ot.RDFTermFunctions.uuid()}static struuid(){return Ot.RDFTermFunctions.struuid()}static xsdDateTime(...e){return Ot.RDFTermFunctions.xsdDateTime(...e)}static xsdInteger(...e){return Ot.RDFTermFunctions.xsdInteger(...e)}static xsdDecimal(...e){return Ot.RDFTermFunctions.xsdDecimal(...e)}static triple(...e){return Ot.RDFTermFunctions.triple(...e)}static subject(...e){return Ot.RDFTermFunctions.subject(...e)}static predicate(...e){return Ot.RDFTermFunctions.predicate(...e)}static object(...e){return Ot.RDFTermFunctions.object(...e)}static md5(...e){return ef.HashFunctions.md5(...e)}static sha1(...e){return ef.HashFunctions.sha1(...e)}static sha256(...e){return ef.HashFunctions.sha256(...e)}static sha384(...e){return ef.HashFunctions.sha384(...e)}static sha512(...e){return ef.HashFunctions.sha512(...e)}};Ep.BuiltInFunctions=Ub});var tf=S(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.ExoQLBudgetExceededError=os.ExoQLCycleError=os.ExoQLEvalDisabledError=os.ExoQLForbiddenKeywordError=void 0;var Vb=class extends Error{static{a(this,"ExoQLForbiddenKeywordError")}constructor(e,t){super(t??`ExoQLForbiddenKeywordError: keyword "${e}" is not permitted by the exoql__Query AST allowlist`),this.name="ExoQLForbiddenKeywordError",this.keyword=e}};os.ExoQLForbiddenKeywordError=Vb;var Bb=class extends Error{static{a(this,"ExoQLEvalDisabledError")}constructor(e){super(e??"ExoQLEvalDisabledError: exoql.eval.enabled is false (default). Flip the feature flag to opt in."),this.name="ExoQLEvalDisabledError"}};os.ExoQLEvalDisabledError=Bb;var Gb=class extends Error{static{a(this,"ExoQLCycleError")}constructor(e,t){super(t??`ExoQLCycleError: cycle detected in nested exo:eval invocations: ${e.join(" \u2192 ")}`),this.name="ExoQLCycleError",this.path=e}};os.ExoQLCycleError=Gb;var qb=class extends Error{static{a(this,"ExoQLBudgetExceededError")}constructor(e,t,r,i){super(i??`ExoQLBudgetExceededError: ${e} budget exceeded (limit=${t}, observed=${r})`),this.name="ExoQLBudgetExceededError",this.budget=e,this.limit=t,this.observed=r}};os.ExoQLBudgetExceededError=qb});var kx=S(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.functionHandlers=void 0;var M=Tp();j.functionHandlers=new Map;j.functionHandlers.set("str",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.str(t)});j.functionHandlers.set("lang",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.lang(t)});j.functionHandlers.set("langmatches",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.langMatches(t,r)});j.functionHandlers.set("contains",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.contains(t,r)});j.functionHandlers.set("strstarts",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strStarts(t,r)});j.functionHandlers.set("strends",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strEnds(t,r)});j.functionHandlers.set("strlen",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.strlen(t)});j.functionHandlers.set("ucase",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.ucase(t)});j.functionHandlers.set("lcase",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.lcase(t)});j.functionHandlers.set("substr",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=Number(e.evaluateExpression(n[1],e.solution));if(n[2]){let i=Number(e.evaluateExpression(n[2],e.solution));return M.BuiltInFunctions.substr(t,r,i)}return M.BuiltInFunctions.substr(t,r)});j.functionHandlers.set("strbefore",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strBefore(t,r)});j.functionHandlers.set("strafter",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strAfter(t,r)});j.functionHandlers.set("concat",(n,e)=>{let t=n.map(r=>e.getStringValue(e.evaluateExpression(r,e.solution)));return M.BuiltInFunctions.concat(...t)});j.functionHandlers.set("replace",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=e.getStringValue(e.evaluateExpression(n[2],e.solution)),s=n[3]?e.getStringValue(e.evaluateExpression(n[3],e.solution)):void 0;return M.BuiltInFunctions.replace(t,r,i,s)});j.functionHandlers.set("regex",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=n[2]?e.getStringValue(e.evaluateExpression(n[2],e.solution)):void 0;return M.BuiltInFunctions.regex(t,r,i)});j.functionHandlers.set("encode_for_uri",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.encodeForUri(t)});j.functionHandlers.set("datatype",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.datatype(t).value});j.functionHandlers.set("bound",(n,e)=>{let t=n[0];if(t.type==="variable"&&t.name){let r=e.solution.get(t.name);return M.BuiltInFunctions.bound(r)}return!0});var Rx=a((n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isIRI(t)},"isIriHandler");j.functionHandlers.set("isiri",Rx);j.functionHandlers.set("isuri",Rx);j.functionHandlers.set("isblank",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isBlank(t)});j.functionHandlers.set("isliteral",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isLiteral(t)});j.functionHandlers.set("isnumeric",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isNumeric(t)});j.functionHandlers.set("haslangdir",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.hasLangdir(t)});j.functionHandlers.set("istriple",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isTriple(t)});j.functionHandlers.set("sameterm",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution),r=e.getTermFromExpression(n[1],e.solution);return M.BuiltInFunctions.sameTerm(t,r)});j.functionHandlers.set("abs",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.abs(t)});j.functionHandlers.set("round",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.round(t)});j.functionHandlers.set("ceil",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.ceil(t)});j.functionHandlers.set("floor",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.floor(t)});j.functionHandlers.set("rand",()=>M.BuiltInFunctions.rand());j.functionHandlers.set("parsedate",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.parseDate(t)});j.functionHandlers.set("datebefore",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateBefore(t,r)});j.functionHandlers.set("dateafter",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateAfter(t,r)});j.functionHandlers.set("dateinrange",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=e.getStringValue(e.evaluateExpression(n[2],e.solution));return M.BuiltInFunctions.dateInRange(t,r,i)});j.functionHandlers.set("datediffminutes",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateDiffMinutes(t,r)});j.functionHandlers.set("datediffhours",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateDiffHours(t,r)});var Xl=a((n,e,t)=>(r,i)=>{let s=i.evaluateExpression(r[0],i.solution);return e&&i.isYearMonthDurationValue(s)?e(s):t&&i.isDayTimeDurationValue(s)?t(s):n(i.getStringValue(s))},"createDateTimeAccessor"),Cx=Xl(M.BuiltInFunctions.year.bind(M.BuiltInFunctions),M.BuiltInFunctions.durationYears.bind(M.BuiltInFunctions),null);j.functionHandlers.set("year",Cx);j.functionHandlers.set("years",Cx);var Px=Xl(M.BuiltInFunctions.month.bind(M.BuiltInFunctions),M.BuiltInFunctions.durationMonths.bind(M.BuiltInFunctions),null);j.functionHandlers.set("month",Px);j.functionHandlers.set("months",Px);var Ox=Xl(M.BuiltInFunctions.day.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationDays.bind(M.BuiltInFunctions));j.functionHandlers.set("day",Ox);j.functionHandlers.set("days",Ox);j.functionHandlers.set("hours",Xl(M.BuiltInFunctions.hours.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationHours.bind(M.BuiltInFunctions)));j.functionHandlers.set("minutes",Xl(M.BuiltInFunctions.minutes.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationMinutes.bind(M.BuiltInFunctions)));j.functionHandlers.set("seconds",Xl(M.BuiltInFunctions.seconds.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationSeconds.bind(M.BuiltInFunctions)));j.functionHandlers.set("timezone",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.timezone(t)});j.functionHandlers.set("tz",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.tz(t)});j.functionHandlers.set("adjust",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=n.length>1?e.evaluateExpression(n[1],e.solution):void 0;return M.BuiltInFunctions.adjust(t,r)});j.functionHandlers.set("now",()=>M.BuiltInFunctions.now());var Fx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdDateTime(e.getStringValue(t))},"dateTimeHandler");j.functionHandlers.set("datetime",Fx);j.functionHandlers.set("xsd:datetime",Fx);var Dx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdInteger(e.getStringValue(t))},"integerHandler");j.functionHandlers.set("integer",Dx);j.functionHandlers.set("xsd:integer",Dx);var Lx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdDecimal(e.getStringValue(t))},"decimalHandler");j.functionHandlers.set("decimal",Lx);j.functionHandlers.set("xsd:decimal",Lx);var Nx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdDayTimeDuration(e.getStringValue(t))},"dayTimeDurationHandler");j.functionHandlers.set("daytimeduration",Nx);j.functionHandlers.set("xsd:daytimeduration",Nx);j.functionHandlers.set("durationtodays",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToDays(t)});j.functionHandlers.set("durationtohours",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToHours(t)});j.functionHandlers.set("durationtominutes",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToMinutes(t)});j.functionHandlers.set("durationtoseconds",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToSeconds(t)});j.functionHandlers.set("durationdays",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationDays(t)});j.functionHandlers.set("durationhours",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationHours(t)});j.functionHandlers.set("durationminutes",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationMinutes(t)});j.functionHandlers.set("durationseconds",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationSeconds(t)});j.functionHandlers.set("durationyears",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationYears(t)});j.functionHandlers.set("durationmonths",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationMonths(t)});j.functionHandlers.set("datetimediff",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=e.evaluateExpression(n[1],e.solution);return M.BuiltInFunctions.dateTimeDiff(t,r)});j.functionHandlers.set("datetimeadd",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=e.evaluateExpression(n[1],e.solution);return M.BuiltInFunctions.dateTimeAdd(t,r)});j.functionHandlers.set("datetimesubtract",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=e.evaluateExpression(n[1],e.solution);return M.BuiltInFunctions.dateTimeSubtract(t,r)});j.functionHandlers.set("mstominutes",(n,e)=>{let t=Number(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.msToMinutes(t)});j.functionHandlers.set("mstohours",(n,e)=>{let t=Number(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.msToHours(t)});j.functionHandlers.set("mstoseconds",(n,e)=>{let t=Number(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.msToSeconds(t)});j.functionHandlers.set("md5",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.md5(t)});j.functionHandlers.set("sha1",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha1(t)});j.functionHandlers.set("sha256",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha256(t)});j.functionHandlers.set("sha384",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha384(t)});j.functionHandlers.set("sha512",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha512(t)});j.functionHandlers.set("subject",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.subject(t)});j.functionHandlers.set("predicate",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.predicate(t)});j.functionHandlers.set("object",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.object(t)});j.functionHandlers.set("triple",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution),r=e.getTermFromExpression(n[1],e.solution),i=e.getTermFromExpression(n[2],e.solution);return M.BuiltInFunctions.triple(t,r,i)});j.functionHandlers.set("days_between",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t),s=new Date(r);return Math.floor((s.getTime()-i.getTime())/(1440*60*1e3))});j.functionHandlers.set("minutes_between",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t),s=new Date(r);return Math.floor((s.getTime()-i.getTime())/(60*1e3))});j.functionHandlers.set("hours_between",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t);return(new Date(r).getTime()-i.getTime())/(3600*1e3)});j.functionHandlers.set("age_days",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=new Date(t);return Math.floor((new Date().getTime()-r.getTime())/(1440*60*1e3))});j.functionHandlers.set("week_number",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=new Date(t),i=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()));i.setUTCDate(i.getUTCDate()+4-(i.getUTCDay()||7));let s=new Date(Date.UTC(i.getUTCFullYear(),0,1));return Math.ceil(((i.getTime()-s.getTime())/(1440*60*1e3)+1)/7)});j.functionHandlers.set("format_date",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t);return r.replace("YYYY",String(i.getFullYear())).replace("MM",String(i.getMonth()+1).padStart(2,"0")).replace("DD",String(i.getDate()).padStart(2,"0")).replace("HH",String(i.getHours()).padStart(2,"0")).replace("mm",String(i.getMinutes()).padStart(2,"0")).replace("ss",String(i.getSeconds()).padStart(2,"0"))});j.functionHandlers.set("exo:eval",()=>{let{ExoQLEvalDisabledError:n}=tf();throw new n})});var Ip=S(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.FilterExecutor=Kl.FilterExecutorError=void 0;var bt=Tp(),Z9=kx(),Wb=Ae(),as=$e(),br=class extends Error{static{a(this,"FilterExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="FilterExecutorError"}};Kl.FilterExecutorError=br;var zb=class{static{a(this,"FilterExecutor")}constructor(){this.existsEvaluator=null,this.tripleStore=null,this.uuidCache=new Map}setExistsEvaluator(e){this.existsEvaluator=e}setTripleStore(e){this.tripleStore=e,this.uuidCache.clear()}async*execute(e,t){let r=this.expressionContainsExists(e.expression);for await(let i of t)try{let s;r?s=await this.evaluateExpressionAsync(e.expression,i):s=this.evaluateExpression(e.expression,i),s===!0&&(yield i)}catch{continue}}expressionContainsExists(e){if(!e||typeof e!="object")return!1;if(e.type==="exists")return!0;if(e.type==="logical")return e.operands.some(t=>this.expressionContainsExists(t));if(e.type==="comparison"){let t=e;return this.expressionContainsExists(t.left)||this.expressionContainsExists(t.right)}if(e.type==="arithmetic"){let t=e;return this.expressionContainsExists(t.left)||this.expressionContainsExists(t.right)}if(e.type==="in"){let t=e;return this.expressionContainsExists(t.expression)||t.list.some(r=>this.expressionContainsExists(r))}if(e.type==="function"||e.type==="functionCall"){let t=e;return Array.isArray(t.args)?t.args.some(r=>this.expressionContainsExists(r)):!1}return!1}async executeAll(e,t){let r=[];async function*i(){for(let s of t)yield s}a(i,"generator");for await(let s of this.execute(e,i()))r.push(s);return r}evaluateExpression(e,t){let r=e;if("termType"in e)switch(r.termType){case"Variable":return t.get(r.value);case"Literal":{let i=r.value,s=r.datatype,o=typeof s=="string"?s:s?.value;return o&&i.length>0&&this.shouldPreserveDatatype(o)?new as.Literal(i,new Wb.IRI(o)):i}case"NamedNode":return r.value;default:throw new br(`Unsupported termType: ${String(r.termType)}`)}switch(e.type){case"comparison":return this.evaluateComparison(e,t);case"logical":return this.evaluateLogical(e,t);case"arithmetic":return this.evaluateArithmetic(e,t);case"function":case"functionCall":return this.evaluateFunction(e,t);case"variable":return t.get(e.name);case"literal":{let i=e;return i.datatype&&i.value.length>0&&this.shouldPreserveDatatype(i.datatype)?new as.Literal(i.value,new Wb.IRI(i.datatype)):i.value}case"in":return this.evaluateIn(e,t);case"exists":throw new br("EXISTS expressions require async evaluation. Use evaluateExpressionAsync instead.");default:throw new br(`Unsupported expression type: ${e.type}`)}}async evaluateExpressionAsync(e,t){if(!this.expressionContainsExists(e))return this.evaluateExpression(e,t);if(e.type==="exists")return this.evaluateExists(e,t);if(e.type==="logical")return this.evaluateLogicalAsync(e,t);if(e.type==="comparison"){let r=e,i=await this.evaluateExpressionAsync(r.left,t),s=await this.evaluateExpressionAsync(r.right,t);return bt.BuiltInFunctions.compare(i,s,r.operator)}return e.type==="in"?this.evaluateInAsync(e,t):e.type==="function"||e.type==="functionCall"?this.evaluateFunctionAsync(e,t):this.evaluateExpression(e,t)}async evaluateExists(e,t){if(!this.existsEvaluator)throw new br("EXISTS evaluator not set. Call setExistsEvaluator before evaluating EXISTS expressions.");let r=await this.existsEvaluator(e.pattern,t);return e.negated?!r:r}async evaluateLogicalAsync(e,t){if(e.operator==="!"){let i=await this.evaluateExpressionAsync(e.operands[0],t);return bt.BuiltInFunctions.logicalNot(i)}let r=[];for(let i of e.operands){let s=await this.evaluateExpressionAsync(i,t);r.push(s)}if(e.operator==="&&")return bt.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return bt.BuiltInFunctions.logicalOr(r);throw new br(`Unknown logical operator: ${String(e.operator)}`)}async evaluateInAsync(e,t){let r=await this.evaluateExpressionAsync(e.expression,t),i=!1;for(let s of e.list){let o=await this.evaluateExpressionAsync(s,t);if(bt.BuiltInFunctions.compare(r,o,"=")){i=!0;break}}return e.negated?!i:i}async evaluateFunctionAsync(e,t){let r=e,i=this.extractFunctionName(r.function),s=r.args??[];if(i==="if"){if(s.length!==3)throw new br("IF requires exactly 3 arguments");let c=await this.evaluateExpressionAsync(s[0],t);return this.toBoolean(c)?this.evaluateExpressionAsync(s[1],t):this.evaluateExpressionAsync(s[2],t)}if(i==="coalesce"){for(let c of s)try{let u=await this.evaluateExpressionAsync(c,t);if(u!=null)return u}catch{continue}return}let o=[];for(let c of s){let u=await this.evaluateExpressionAsync(c,t);o.push(this.wrapAsLiteralExpression(u))}let l={...r,args:o};return this.evaluateFunction(l,t)}wrapAsLiteralExpression(e){return e==null?{type:"literal",value:""}:typeof e=="object"&&"termType"in e?e:e instanceof Wb.IRI||e instanceof as.Literal?{type:"literal",value:e.value}:typeof e=="number"||typeof e=="boolean"||typeof e=="string"?{type:"literal",value:e}:{type:"literal",value:String(e)}}evaluateComparison(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);return bt.BuiltInFunctions.compare(r,i,e.operator)}evaluateLogical(e,t){if(e.operator==="!"){let i=this.evaluateExpression(e.operands[0],t);return bt.BuiltInFunctions.logicalNot(i)}let r=e.operands.map(i=>this.evaluateExpression(i,t));if(e.operator==="&&")return bt.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return bt.BuiltInFunctions.logicalOr(r);throw new br(`Unknown logical operator: ${String(e.operator)}`)}evaluateIn(e,t){let r=this.evaluateExpression(e.expression,t),i=e.list.some(s=>{let o=this.evaluateExpression(s,t);return bt.BuiltInFunctions.compare(r,o,"=")});return e.negated?!i:i}evaluateArithmetic(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);if(e.operator==="-"&&this.isDateValue(r)&&this.isDateValue(i))return bt.BuiltInFunctions.dateDiff(r,i);if(e.operator==="-"&&this.isTimeValue(r)&&this.isTimeValue(i))return bt.BuiltInFunctions.timeDiff(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDateTimeValue(i))return bt.BuiltInFunctions.dateTimeDiff(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateAdd(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateSubtract(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateAddYearMonth(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateTimeAdd(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateTimeSubtract(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateTimeAddYearMonth(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateTimeSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.durationAdd(r,i);if(e.operator==="-"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.durationSubtract(r,i);if(e.operator==="*"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let l=this.toNumericValue(i);return bt.BuiltInFunctions.durationMultiply(r,l)}if(e.operator==="*"&&!this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i)){let l=this.toNumericValue(r);return bt.BuiltInFunctions.durationMultiply(i,l)}if(e.operator==="/"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let l=this.toNumericValue(i);if(l===0)throw new br("Division by zero");return bt.BuiltInFunctions.durationDivide(r,l)}if(e.operator==="+"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.yearMonthDurationAdd(r,i);if(e.operator==="-"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.yearMonthDurationSubtract(r,i);let s=this.toNumericValue(r),o=this.toNumericValue(i);switch(e.operator){case"+":return s+o;case"-":return s-o;case"*":return s*o;case"/":if(o===0)throw new br("Division by zero");return s/o;default:throw new br(`Unknown arithmetic operator: ${String(e.operator)}`)}}shouldPreserveDatatype(e){return e==="http://www.w3.org/2001/XMLSchema#dateTime"||e==="http://www.w3.org/2001/XMLSchema#date"||e==="http://www.w3.org/2001/XMLSchema#time"||e==="http://www.w3.org/2001/XMLSchema#dayTimeDuration"||e==="http://www.w3.org/2001/XMLSchema#yearMonthDuration"||e==="http://www.w3.org/2001/XMLSchema#duration"}isDayTimeDurationValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}isYearMonthDurationValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}toNumericValue(e){if(typeof e=="number")return e;if(e instanceof as.Literal){let t=e.datatype?.value||"";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let i=parseFloat(e.value);if(!isNaN(i))return i}let r=parseFloat(e.value);if(!isNaN(r))return r}if(typeof e=="string"){let t=parseFloat(e);if(!isNaN(t))return t}if(e&&typeof e=="object"&&"value"in e){let t=parseFloat(String(e.value));if(!isNaN(t))return t}throw new br(`Cannot convert to number: ${e}`)}isDateTimeValue(e){if(e instanceof as.Literal){let t=e.datatype?.value||"";return t.includes("#dateTime")||t.includes("#date")?!0:/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e.value)}return typeof e=="string"?/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e):!1}isDateValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}isTimeValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}evaluateFunction(e,t){let r=e,i=this.extractFunctionName(r.function),s=this.evaluateSpecialFunction(i,r.args,t);if(s!==void 0)return s.value;let o=Z9.functionHandlers.get(i);if(!o)throw new br(`Unknown function: ${i}`);let l={evaluateExpression:a((c,u)=>this.evaluateExpression(c,u),"evaluateExpression"),getTermFromExpression:a((c,u)=>this.getTermFromExpression(c,u),"getTermFromExpression"),getStringValue:a(c=>this.getStringValue(c),"getStringValue"),solution:t,isYearMonthDurationValue:a(c=>this.isYearMonthDurationValue(c),"isYearMonthDurationValue"),isDayTimeDurationValue:a(c=>this.isDayTimeDurationValue(c),"isDayTimeDurationValue")};return o(r.args,l)}extractFunctionName(e){if(typeof e=="string")return e.toLowerCase();if(e&&typeof e=="object"&&"value"in e){let t=e.value;return((t.includes("#")?t.split("#").pop():t.split("/").pop())||t).toLowerCase()}throw new br(`Unknown function format: ${String(e)}`)}evaluateSpecialFunction(e,t,r){switch(e){case"coalesce":for(let i of t)try{let s=this.evaluateExpression(i,r);if(s!=null)return{value:s}}catch{continue}return{value:void 0};case"if":{if(!t||t.length!==3)throw new br("IF requires exactly 3 arguments");let i=this.evaluateExpression(t[0],r);return{value:this.toBoolean(i)?this.evaluateExpression(t[1],r):this.evaluateExpression(t[2],r)}}case"byuuid":return{value:this.evaluateByUUID({type:"function",function:"byuuid",args:t},r)};default:return}}getTermFromExpression(e,t){let r=e;if(r.type==="variable"&&r.name)return t.get(r.name)}getStringValue(e){return e==null?"":typeof e=="object"&&"value"in e?String(e.value):String(e)}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number")return!isNaN(e)&&e!==0;if(typeof e=="string")return e.length>0;if(e instanceof as.Literal){let t=e.datatype?.value||"";if(t.includes("#boolean"))return e.value==="true"||e.value==="1";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let r=parseFloat(e.value);return!isNaN(r)&&r!==0}return e.value.length>0}return!!e}evaluateByUUID(e,t){if(!e.args||e.args.length!==1)throw new br("exo:byUUID requires exactly 1 argument (UUID string)");let r=this.evaluateExpression(e.args[0],t),i=this.getStringValue(r);if(!i)return;let s=i.toLowerCase();if(this.uuidCache.has(s))return this.uuidCache.get(s)??void 0;if(!this.tripleStore){this.uuidCache.set(s,null);return}if(this.tripleStore.findSubjectsByUUIDSync){let o=this.tripleStore.findSubjectsByUUIDSync(s);if(o.length===0){this.uuidCache.set(s,null);return}let l=o[0];return this.uuidCache.set(s,l),l}this.uuidCache.set(s,null)}cacheUUIDResult(e,t){let r=e.toLowerCase();this.uuidCache.set(r,t)}getCachedUUID(e){let t=e.toLowerCase();if(this.uuidCache.has(t))return this.uuidCache.get(t)}};Kl.FilterExecutor=zb});var Qb=S(xp=>{"use strict";Object.defineProperty(xp,"__esModule",{value:!0});xp.OptionalExecutor=void 0;var Hb=class{static{a(this,"OptionalExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);yield*this.hashJoin(r,i)}async executeAll(e,t){let r=[];for(let i of this.hashJoin(e,t))r.push(i);return r}*hashJoin(e,t){if(e.length===0)return;if(t.length===0){yield*e;return}let r=new Set;for(let c of e)for(let u of c.variables())r.add(u);let i=new Set;for(let c of t)for(let u of c.variables())i.add(u);let s=[];for(let c of r)i.has(c)&&s.push(c);if(s.sort(),s.length===0){yield*this.nestedLoopJoin(e,t);return}let o="\0",l=new Map;for(let c of t){let u=this.computeHashKey(c,s,o),f=l.get(u);f||(f=[],l.set(u,f)),f.push(c)}for(let c of e){let u=this.computeHashKey(c,s,o),f=l.get(u),d=!1;if(f)for(let h of f){let p=c.merge(h);p!==null&&(yield p,d=!0)}d||(yield c)}}computeHashKey(e,t,r){let i=[];for(let s of t){let o=e.get(s);i.push(o!==void 0?o.toString():"UNBOUND")}return i.join(r)}*nestedLoopJoin(e,t){for(let r of e){let i=!1;for(let s of t){let o=r.merge(s);o!==null&&(yield o,i=!0)}i||(yield r)}}};xp.OptionalExecutor=Hb});var Xb=S(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});Ap.UnionExecutor=void 0;var Yb=class{static{a(this,"UnionExecutor")}async*execute(e,t){let r=new Set;for await(let i of e){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}for await(let i of t){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}}async executeAll(e,t){let r=[];async function*i(){for(let o of e)yield o}a(i,"generateLeft");async function*s(){for(let o of t)yield o}a(s,"generateRight");for await(let o of this.execute(i(),s()))r.push(o);return r}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}};Ap.UnionExecutor=Yb});var Mx=S(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});Rp.MinusExecutor=void 0;var Kb=class{static{a(this,"MinusExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);for(let s of r){let o=!1;for(let l of i)if(this.areCompatible(s,l)){o=!0;break}o||(yield s)}}async executeAll(e,t){let r=[];async function*i(){for(let o of e)yield o}a(i,"generateLeft");async function*s(){for(let o of t)yield o}a(s,"generateRight");for await(let o of this.execute(i(),s()))r.push(o);return r}areCompatible(e,t){let r=e.variables(),i=new Set(t.variables()),s=r.filter(o=>i.has(o));if(s.length===0)return!1;for(let o of s){let l=e.get(o),c=t.get(o);if(l===void 0||c===void 0||l.toString()!==c.toString())return!1}return!0}};Rp.MinusExecutor=Kb});var $x=S(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.ValuesExecutor=Jl.ValuesExecutorError=void 0;var e5=ss(),jx=Ae(),t5=$e(),Cp=class extends Error{static{a(this,"ValuesExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ValuesExecutorError"}};Jl.ValuesExecutorError=Cp;var Jb=class{static{a(this,"ValuesExecutor")}async*execute(e){if(e.bindings.length!==0)for(let t of e.bindings)yield this.createSolutionMapping(t)}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}createSolutionMapping(e){let t=new e5.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.toRDFTerm(i);t.set(r,s)}return t}toRDFTerm(e){if(e.type==="iri")return new jx.IRI(e.value);if(e.type==="literal")return new t5.Literal(e.value,e.datatype?new jx.IRI(e.datatype):void 0,e.language,e.direction);throw new Cp(`Unknown term type: ${e.type}`)}};Jl.ValuesExecutor=Jb});var Zb=S(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.CustomAggregateRegistry=ec.CustomAggregateError=void 0;var Zl=class extends Error{static{a(this,"CustomAggregateError")}constructor(e,t){super(e),this.iri=t,this.name="CustomAggregateError"}};ec.CustomAggregateError=Zl;var Pp=class n{static{a(this,"CustomAggregateRegistry")}constructor(){this.aggregates=new Map}static getInstance(){return n.instance||(n.instance=new n),n.instance}static resetInstance(){n.instance&&n.instance.clear(),n.instance=null}register(e,t){if(!e||typeof e!="string")throw new Zl("Aggregate IRI must be a non-empty string");if(!t||typeof t.init!="function"||typeof t.step!="function"||typeof t.finalize!="function")throw new Zl("Aggregate must implement init(), step(), and finalize() methods",e);if(this.aggregates.has(e))throw new Zl(`Aggregate with IRI "${e}" is already registered`,e);this.aggregates.set(e,t)}unregister(e){return this.aggregates.delete(e)}get(e){return this.aggregates.get(e)}has(e){return this.aggregates.has(e)}getRegisteredIris(){return Array.from(this.aggregates.keys())}clear(){this.aggregates.clear()}get size(){return this.aggregates.size}};ec.CustomAggregateRegistry=Pp;Pp.instance=null});var e1=S(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.BUILT_IN_AGGREGATES=nt.modeAggregate=nt.stddevAggregate=nt.varianceAggregate=nt.medianAggregate=nt.EXO_AGGREGATE_NS=void 0;nt.getNumericValue=Op;nt.createDecimalLiteral=bi;nt.createDoubleLiteral=i5;nt.createPercentileAggregate=La;var Na=$e(),tc=Ae(),r5=new tc.IRI("http://www.w3.org/2001/XMLSchema#decimal"),n5=new tc.IRI("http://www.w3.org/2001/XMLSchema#double");nt.EXO_AGGREGATE_NS="https://exocortex.my/ontology/agg#";function Op(n){return n==null?NaN:typeof n=="number"?n:typeof n=="string"?parseFloat(n):n instanceof Na.Literal?parseFloat(n.value):n instanceof tc.IRI?NaN:typeof n=="boolean"?n?1:0:NaN}a(Op,"getNumericValue");function bi(n){return new Na.Literal(String(n),r5)}a(bi,"createDecimalLiteral");function i5(n){return new Na.Literal(String(n),n5)}a(i5,"createDoubleLiteral");nt.medianAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Op(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return bi(0);let r=[...t].sort((o,l)=>o-l),i=Math.floor(r.length/2),s=r.length%2!==0?r[i]:(r[i-1]+r[i])/2;return bi(s)}};nt.varianceAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Op(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return bi(0);let r=t.reduce((s,o)=>s+o,0)/t.length,i=t.reduce((s,o)=>s+Math.pow(o-r,2),0)/t.length;return bi(i)}};nt.stddevAggregate={init(){return{values:[]}},step(n,e){nt.varianceAggregate.step(n,e)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return bi(0);let r=t.reduce((s,o)=>s+o,0)/t.length,i=t.reduce((s,o)=>s+Math.pow(o-r,2),0)/t.length;return bi(Math.sqrt(i))}};nt.modeAggregate={init(){return{counts:new Map,values:new Map}},step(n,e){if(e==null)return;let t=n,r=String(e instanceof Na.Literal||e instanceof tc.IRI?e.value:e),i=t.counts.get(r)||0;t.counts.set(r,i+1),t.values.set(r,e)},finalize(n){let e=n;if(e.counts.size===0)return new Na.Literal(" ",new tc.IRI("http://www.w3.org/2001/XMLSchema#string"));let t="",r=0;for(let[o,l]of e.counts)l>r&&(r=l,t=o);let i=e.values.get(t);if(i instanceof Na.Literal)return i;let s=parseFloat(t);return isNaN(s)?new Na.Literal(t,new tc.IRI("http://www.w3.org/2001/XMLSchema#string")):bi(s)}};function La(n){let e=Math.max(0,Math.min(100,n))/100;return{init(){return{values:[],percentile:e}},step(t,r){let i=t,s=Op(r);isNaN(s)||i.values.push(s)},finalize(t){let r=t,{values:i}=r;if(i.length===0)return bi(0);let s=[...i].sort((d,h)=>d-h),o=r.percentile*(s.length-1),l=Math.floor(o),c=Math.ceil(o);if(l===c)return bi(s[l]);let u=o-l,f=s[l]*(1-u)+s[c]*u;return bi(f)}}}a(La,"createPercentileAggregate");nt.BUILT_IN_AGGREGATES={[`${nt.EXO_AGGREGATE_NS}median`]:nt.medianAggregate,[`${nt.EXO_AGGREGATE_NS}variance`]:nt.varianceAggregate,[`${nt.EXO_AGGREGATE_NS}stddev`]:nt.stddevAggregate,[`${nt.EXO_AGGREGATE_NS}mode`]:nt.modeAggregate,[`${nt.EXO_AGGREGATE_NS}percentile25`]:La(25),[`${nt.EXO_AGGREGATE_NS}percentile50`]:La(50),[`${nt.EXO_AGGREGATE_NS}percentile75`]:La(75),[`${nt.EXO_AGGREGATE_NS}percentile90`]:La(90),[`${nt.EXO_AGGREGATE_NS}percentile95`]:La(95),[`${nt.EXO_AGGREGATE_NS}percentile99`]:La(99)}});var Bx=S(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.AggregateExecutor=rc.AggregateExecutorError=void 0;var dr=$e(),r1=Ae(),s5=Ip(),o5=Zb(),a5=e1(),Ux=new r1.IRI("http://www.w3.org/2001/XMLSchema#integer"),ka=new r1.IRI("http://www.w3.org/2001/XMLSchema#decimal"),ls=new r1.IRI("http://www.w3.org/2001/XMLSchema#string");function Vx(n){return typeof n=="object"&&n.type==="custom"}a(Vx,"isCustomAggregation");var rf=class extends Error{static{a(this,"AggregateExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AggregateExecutorError"}};rc.AggregateExecutorError=rf;var t1=class{static{a(this,"AggregateExecutor")}constructor(){this.filterExecutor=new s5.FilterExecutor}execute(e,t){let r=this.groupSolutions(t,e.variables),i=[];for(let[s,o]of r.entries()){let l=new Map;for(let f of e.variables)if(o.length>0){let d=o[0].get(f);d&&l.set(f,d)}for(let f of e.aggregates){let d=this.computeAggregate(f.expression,o);l.set(f.variable,d)}let{SolutionMapping:c}=ss(),u=new c;for(let[f,d]of l.entries())u.set(f,d);i.push(u)}if(i.length===0&&e.aggregates.length>0){let s=this.createEmptyAggregateResult(e);s&&i.push(s)}return i}groupSolutions(e,t){let r=new Map;if(t.length===0)return r.set("",e),r;for(let i of e){let s=this.computeGroupKey(i,t),o=r.get(s);o?o.push(i):r.set(s,[i])}return r}computeGroupKey(e,t){return t.map(r=>{let i=e.get(r);return i?this.termToString(i):""}).join("|")}termToString(e){if(e&&typeof e=="object"){if("value"in e)return String(e.value);if("id"in e)return String(e.id)}return String(e)}computeAggregate(e,t){if(Vx(e.aggregation))return this.computeCustomAggregate(e,t);let r=this.extractValues(e,t),i=e.aggregation;switch(i){case"count":{let s=this.computeCount(r,e.distinct);return new dr.Literal(String(s),Ux)}case"sum":{let s=this.computeSum(r);return new dr.Literal(String(s),ka)}case"avg":{let s=this.computeAvg(r);return new dr.Literal(String(s),ka)}case"min":{let s=this.computeMin(r);return s===void 0?new dr.Literal("",ls):typeof s=="number"?new dr.Literal(String(s),ka):new dr.Literal(String(s),ls)}case"max":{let s=this.computeMax(r);return s===void 0?new dr.Literal("",ls):typeof s=="number"?new dr.Literal(String(s),ka):new dr.Literal(String(s),ls)}case"group_concat":{let s=this.computeGroupConcat(r,e.separator||" ",e.distinct);return new dr.Literal(s||" ",ls)}case"sample":{let s=this.computeSample(r,e.distinct);return s===void 0?new dr.Literal(" ",ls):typeof s=="number"?new dr.Literal(String(s),ka):new dr.Literal(String(s),ls)}default:{let s=i;throw new rf(`Unknown aggregation function: ${s}`)}}}computeCustomAggregate(e,t){let i=e.aggregation.iri,o=o5.CustomAggregateRegistry.getInstance().get(i);if(o||(o=a5.BUILT_IN_AGGREGATES[i]),!o)throw new rf(`Unknown custom aggregate function: ${i}. Register it with CustomAggregateRegistry.getInstance().register() or use a built-in aggregate.`);let l=o.init();for(let c of t){let u=null;if(e.expression){let f=this.evaluateExpression(e.expression,c);f!==void 0&&(u=f)}else u=1;o.step(l,u)}return o.finalize(l)}extractValues(e,t){if(!e.expression)return t.map(()=>1);let r=[];for(let i of t){let s=this.evaluateExpression(e.expression,i);s!=null&&r.push(s)}return r}evaluateExpression(e,t){if(e.type==="variable"){let r=t.get(e.name);return r==null?void 0:typeof r=="number"||typeof r=="string"||typeof r=="boolean"?r:typeof r=="object"&&"value"in r?r.value:r}if(e.type==="literal")return e.value;try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}computeCount(e,t){return t?new Set(e.map(r=>String(r))).size:e.length}computeSum(e){return e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r)).reduce((r,i)=>r+i,0)}computeAvg(e){let t=e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r));return t.length===0?0:t.reduce((r,i)=>r+i,0)/t.length}computeMin(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.min(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s<i?s:i,r[0])}computeMax(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.max(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s>i?s:i,r[0])}computeGroupConcat(e,t,r){let i=e.map(s=>String(s));return r&&(i=[...new Set(i)]),i.join(t)}computeSample(e,t){if(e.length===0)return;if(t){let s=[...new Set(e.map(c=>String(c)))];if(s.length===0)return;let o=s[0],l=parseFloat(o);return isNaN(l)?o:l}let r=e[0];if(typeof r=="number")return r;let i=parseFloat(String(r));return isNaN(i)?String(r):i}createEmptyAggregateResult(e){let{SolutionMapping:t}=ss(),r=new t;for(let i of e.aggregates){let s=i.expression.aggregation;if(Vx(s)){r.set(i.variable,new dr.Literal("0",ka));continue}switch(s){case"count":r.set(i.variable,new dr.Literal("0",Ux));break;case"sum":case"avg":r.set(i.variable,new dr.Literal("0",ka));break;case"group_concat":r.set(i.variable,new dr.Literal(" ",ls));break;case"min":case"max":case"sample":r.set(i.variable,new dr.Literal("",ls));break;default:r.set(i.variable,new dr.Literal("",ls))}}return r}};rc.AggregateExecutor=t1});var o1=S(Fp=>{"use strict";Object.defineProperty(Fp,"__esModule",{value:!0});Fp.ConstructExecutor=void 0;var l5=Bn(),Ma=Ae(),n1=$e(),i1=$t(),c5=Ou(),s1=class{static{a(this,"ConstructExecutor")}async execute(e,t){let r=[],i=new Set;for(let s of t)for(let o of e)try{let l=this.instantiateTriple(o,s),c=`${l.subject.toString()}|${l.predicate.toString()}|${l.object.toString()}`;i.has(c)||(i.add(c),r.push(l))}catch{continue}return r}instantiateTriple(e,t){if(this.isPropertyPath(e.predicate))throw new Error("Property paths are not supported in CONSTRUCT templates");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.predicate,t),s=this.instantiateElement(e.object,t);return new l5.Triple(r,i,s)}isPropertyPath(e){return e.type==="path"}instantiateElement(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable: ${e.value}`);return r}if(e.type==="iri")return new Ma.IRI(e.value);if(e.type==="literal")return new n1.Literal(e.value,e.datatype?new Ma.IRI(e.datatype):void 0,e.language);if(e.type==="blank")return new i1.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Unknown element type: ${e.type}`)}instantiateQuotedTriple(e,t){let r=this.instantiateQuotedSubject(e.subject,t),i=this.instantiateQuotedPredicate(e.predicate,t),s=this.instantiateQuotedObject(e.object,t);return new c5.QuotedTriple(r,i,s)}instantiateQuotedSubject(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple subject: ${e.value}`);if(r instanceof n1.Literal)throw new Error("Literals cannot appear in quoted triple subject position");return r}if(e.type==="iri")return new Ma.IRI(e.value);if(e.type==="blank")return new i1.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Invalid element type for quoted triple subject: ${e.type}`)}instantiateQuotedPredicate(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple predicate: ${e.value}`);if(!(r instanceof Ma.IRI))throw new Error("Quoted triple predicate must be an IRI");return r}return new Ma.IRI(e.value)}instantiateQuotedObject(e,t){if(e.type==="variable"){let i=t.get(e.value);if(!i)throw new Error(`Unbound variable in quoted triple object: ${e.value}`);return i}if(e.type==="iri")return new Ma.IRI(e.value);if(e.type==="blank")return new i1.BlankNode(e.value);if(e.type==="literal")return new n1.Literal(e.value,e.datatype?new Ma.IRI(e.datatype):void 0,e.language);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);let r=e;throw new Error(`Invalid element type for quoted triple object: ${r.type}`)}};Fp.ConstructExecutor=s1});var qx=S(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.ServiceExecutor=nc.ServiceExecutorError=void 0;var u5=ss(),Gx=Ae(),f5=$e(),d5=$t(),ja=class extends Error{static{a(this,"ServiceExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ServiceExecutorError"}};nc.ServiceExecutorError=ja;var a1=class{static{a(this,"ServiceExecutor")}constructor(e={}){this.timeout=e.timeout??3e4,this.httpClient=e.httpClient??((t,r)=>fetch(t,r)),this.maxRetries=e.maxRetries??2,this.retryDelay=e.retryDelay??1e3}async*execute(e,t){try{let r=t(e.pattern),i=await this.executeRemoteQuery(e.endpoint,r);for(let s of i)yield s}catch(r){if(e.silent)return;throw r}}async executeRemoteQuery(e,t){let r;for(let i=0;i<=this.maxRetries;i++)try{let s=new AbortController,o=setTimeout(()=>s.abort(),this.timeout);try{let l=await this.httpClient(e,{method:"POST",headers:{"Content-Type":"application/sparql-query",Accept:"application/sparql-results+json"},body:t,signal:s.signal});if(!l.ok)throw new ja(`Remote SPARQL endpoint returned ${l.status}: ${l.statusText}`);let c=await l.json();return this.parseJsonResults(c)}finally{clearTimeout(o)}}catch(s){if(r=s instanceof Error?s:new Error(String(s)),this.isRetryableError(r)&&i<this.maxRetries){await this.delay(this.retryDelay);continue}throw new ja(`Failed to query remote SPARQL endpoint ${e}: ${r.message}`,r)}throw new ja(`Failed to query remote SPARQL endpoint ${e} after ${this.maxRetries+1} attempts`,r)}parseJsonResults(e){return!e.results||!Array.isArray(e.results.bindings)?[]:e.results.bindings.map(t=>this.parseBinding(t))}parseBinding(e){let t=new u5.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.parseRDFTerm(i);t.set(r,s)}return t}parseRDFTerm(e){switch(e.type){case"uri":return new Gx.IRI(e.value);case"literal":{let t=e.datatype?new Gx.IRI(e.datatype):void 0;return new f5.Literal(e.value,t,e["xml:lang"])}case"bnode":return new d5.BlankNode(e.value);default:throw new ja(`Unknown RDF term type: ${e.type}`)}}isRetryableError(e){let t=e.message.toLowerCase();return!!(e.name==="AbortError"||t.includes("network")||t.includes("econnreset")||t.includes("econnrefused")||t.includes("etimedout")||t.includes("returned 5"))}delay(e){return new Promise(t=>setTimeout(t,e))}};nc.ServiceExecutor=a1});var zx=S(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.GraphExecutor=ic.GraphExecutorError=void 0;var Wx=Ae(),Dp=class extends Error{static{a(this,"GraphExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="GraphExecutorError"}};ic.GraphExecutorError=Dp;var l1=class{static{a(this,"GraphExecutor")}constructor(e){this.tripleStore=e}async*execute(e,t,r){let i=e.name;if(i.type==="iri")yield*this.executeWithGraph(e.pattern,i,t);else if(i.type==="variable")yield*this.executeWithGraphVariable(e,i,t,r);else throw new Dp(`Invalid graph name type: ${i.type}`)}async*executeWithGraph(e,t,r){let i=new Wx.IRI(t.value);this.tripleStore.hasGraph&&!await this.tripleStore.hasGraph(i)||(yield*r(e,i))}async*executeWithGraphVariable(e,t,r,i){if(i){let o=i.get(t.value);if(o&&o instanceof Wx.IRI){yield*this.executeWithGraph(e.pattern,{type:"iri",value:o.value},r);return}}if(!this.tripleStore.getNamedGraphs)return;let s=await this.tripleStore.getNamedGraphs();for(let o of s)for await(let l of r(e.pattern,o)){let c=l.clone();c.set(t.value,o),yield c}}};ic.GraphExecutor=l1});var Hx=S(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.SPARQLGenerator=oc.SPARQLGeneratorError=void 0;var sc=class extends Error{static{a(this,"SPARQLGeneratorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="SPARQLGeneratorError"}};oc.SPARQLGeneratorError=sc;var c1=class{static{a(this,"SPARQLGenerator")}collectVariables(e){let t=new Set;return this.collectVariablesFromOperation(e,t),t}generateSelect(e){let t=this.collectVariables(e),r=t.size>0?Array.from(t).map(s=>`?${s}`).join(" "):"*",i=this.generateWhereClause(e);return`SELECT ${r} WHERE {
48
+ `,s);c!==-1?(i+=e.substring(s,c),s=c):(i+=e.substring(s),s=e.length);continue}let l=this.tryReplacePrefixedName(e,s,r);if(l){i+=l.iri,s=l.endIndex;continue}i+=o,s++}return i}tryReplacePrefixedName(e,t,r){if(t>0&&/[a-zA-Z0-9_]/.test(e[t-1]))return null;for(let{prefix:i,baseIRI:s}of r){if(e.substring(t,t+i.length+1)!==i+":")continue;let o=t+i.length+1,l=o;for(;l<e.length&&/[a-zA-Z0-9_.%-]/.test(e[l]);)l++;if(l===o)continue;let c=e.substring(o,l);return{iri:`<${s}${c}.md>`,endIndex:l}}return null}findDeclaredPrefixes(e){let t=new Set,r=new RegExp(x9.source,"gi"),i;for(;(i=r.exec(e))!==null;)t.add(i[1].toLowerCase());return t}skipLiteral(e,t){let r=e[t];if(t+2<e.length&&e.substring(t,t+3)===r+r+r){let s=e.indexOf(r+r+r,t+3);return s!==-1?s+3:e.length}let i=t+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;return i<e.length?i+1:e.length}};Xh.VaultPrefixTransformer=pb});var $l=S(Pn=>{"use strict";var R9=Pn&&Pn.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),C9=Pn&&Pn.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),P9=Pn&&Pn.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&R9(t,e,r[i]);return C9(t,e),t}})();Object.defineProperty(Pn,"__esModule",{value:!0});Pn.SPARQLParser=Pn.ExoQLParser=Pn.SPARQLParseError=void 0;var ox=P9(rx()),gb=lb(),yb=cb(),ax=nx(),_b=fb(),O9=ix(),bb=sx(),F9=mb(),cr=class extends Error{static{a(this,"SPARQLParseError")}constructor(e,t,r,i){super(e,i?{cause:i}:void 0),this.name="SPARQLParseError",this.line=t,this.column=r}};Pn.SPARQLParseError=cr;var Kh=class{static{a(this,"ExoQLParser")}constructor(e){this.lastDirectionMappings=new Map,this.parser=new ox.Parser({sparqlStar:!0}),this.generator=new ox.Generator({sparqlStar:!0}),this.caseWhenTransformer=new gb.CaseWhenTransformer,this.lateralTransformer=new yb.LateralTransformer,this.prefixStarTransformer=new ax.PrefixStarTransformer(e?.vocabularyResolver),this.describeOptionsTransformer=new _b.DescribeOptionsTransformer,this.directionalLangTagTransformer=new O9.DirectionalLangTagTransformer,this.tripleTermTransformer=new bb.TripleTermTransformer,this.vaultPrefixTransformer=new F9.VaultPrefixTransformer}setVaultPrefixes(e){this.vaultPrefixTransformer.setVaultPrefixes(e)}parse(e){try{let t=this.vaultPrefixTransformer.transform(e),r=this.describeOptionsTransformer.transform(t);this.lastDescribeOptions=r.options;let i=r.query;i=this.directionalLangTagTransformer.transform(i),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),i=this.lateralTransformer.transform(i),i=this.caseWhenTransformer.transform(i),i=this.tripleTermTransformer.transform(i);let s=this.parser.parse(i);return this.validateQuery(s),this.lastDescribeOptions&&this.isDescribeQuery(s)&&(s.describeOptions=this.lastDescribeOptions),s}catch(t){if(t instanceof _b.DescribeOptionsTransformerError)throw new cr(t.message);if(t instanceof yb.LateralTransformerError)throw new cr(t.message);if(t instanceof gb.CaseWhenTransformerError)throw new cr(t.message);if(t instanceof bb.TripleTermTransformerError)throw new cr(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new cr(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}parseWithOptions(e){return{query:this.parse(e),describeOptions:this.lastDescribeOptions}}getLastDescribeOptions(){return this.lastDescribeOptions}async parseAsync(e){try{let t=this.vaultPrefixTransformer.transform(e),r=this.describeOptionsTransformer.transform(t);this.lastDescribeOptions=r.options;let i=r.query;i=this.directionalLangTagTransformer.transform(i),this.lastDirectionMappings=this.directionalLangTagTransformer.getAllMappings(),i=await this.prefixStarTransformer.transform(i),i=this.lateralTransformer.transform(i),i=this.caseWhenTransformer.transform(i),i=this.tripleTermTransformer.transform(i);let s=this.parser.parse(i);return this.validateQuery(s),this.lastDescribeOptions&&this.isDescribeQuery(s)&&(s.describeOptions=this.lastDescribeOptions),s}catch(t){if(t instanceof _b.DescribeOptionsTransformerError)throw new cr(t.message);if(t instanceof ax.PrefixStarTransformerError)throw new cr(t.message);if(t instanceof yb.LateralTransformerError)throw new cr(t.message);if(t instanceof gb.CaseWhenTransformerError)throw new cr(t.message);if(t instanceof bb.TripleTermTransformerError)throw new cr(t.message);if(t instanceof Error){let r=t.message.match(/line (\d+), column (\d+)/),i=r?parseInt(r[1],10):void 0,s=r?parseInt(r[2],10):void 0;throw new cr(`SPARQL syntax error: ${t.message}`,i,s,t)}throw t}}async parseAsyncWithOptions(e){return{query:await this.parseAsync(e),describeOptions:this.lastDescribeOptions}}hasPrefixStar(e){return/PREFIX\s*\*/i.test(e)}hasLateral(e){return this.lateralTransformer.hasLateral(e)}hasDescribeOptions(e){return this.describeOptionsTransformer.hasDescribeOptions(e)}hasDirectionalLangTags(e){return this.directionalLangTagTransformer.hasDirectionalTags(e)}hasTripleTermSyntax(e){return this.tripleTermTransformer.hasTripleTermSyntax(e)}getLastDirectionMappings(){return new Map(this.lastDirectionMappings)}getDirectionForLanguage(e){return this.lastDirectionMappings.get(e.toLowerCase())}toString(e){try{return this.generator.stringify(e)}catch(t){throw t instanceof Error?new cr(`Failed to serialize SPARQL query: ${t.message}`,void 0,void 0,t):t}}getQueryType(e){if("queryType"in e&&e.type==="query")return e.queryType;throw new cr("Query does not have a valid queryType property")}isSelectQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="SELECT"}isConstructQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="CONSTRUCT"}isAskQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="ASK"}isDescribeQuery(e){return"queryType"in e&&e.type==="query"&&e.queryType==="DESCRIBE"}isUpdateQuery(e){return e.type==="update"}isInsertDataOperation(e){return"updateType"in e&&e.updateType==="insert"}isDeleteDataOperation(e){return"updateType"in e&&e.updateType==="delete"}validateQuery(e){if(!e||typeof e!="object")throw new cr("Invalid query: not an object");if(e.type!=="query"&&e.type!=="update")throw new cr(`Invalid type: expected "query" or "update", got "${e.type}"`);if(e.type==="query"){let t=["SELECT","CONSTRUCT","ASK","DESCRIBE"];if(!t.includes(e.queryType))throw new cr(`Invalid query type: expected one of ${t.join(", ")}, got "${e.queryType}"`)}}};Pn.ExoQLParser=Kh;Pn.SPARQLParser=Kh});var Da=S(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});Jh.AlgebraTranslatorError=void 0;var Sb=class extends Error{static{a(this,"AlgebraTranslatorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AlgebraTranslatorError"}};Jh.AlgebraTranslatorError=Sb});var Zh=S(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.isVariableExpression=D9;is.isVariableTerm=L9;is.isNamedNode=N9;is.isLiteral=k9;is.isPropertyPath=M9;is.isAggregateExpression=j9;is.isOperationExpression=$9;is.isFunctionCallExpression=U9;function D9(n){return typeof n=="object"&&n!==null&&"expression"in n&&"variable"in n}a(D9,"isVariableExpression");function L9(n){return typeof n=="object"&&n!==null&&"termType"in n&&n.termType==="Variable"}a(L9,"isVariableTerm");function N9(n){return typeof n=="object"&&n!==null&&"termType"in n&&n.termType==="NamedNode"}a(N9,"isNamedNode");function k9(n){return typeof n=="object"&&n!==null&&"termType"in n&&n.termType==="Literal"}a(k9,"isLiteral");function M9(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="path"}a(M9,"isPropertyPath");function j9(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="aggregate"}a(j9,"isAggregateExpression");function $9(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="operation"}a($9,"isOperationExpression");function U9(n){return typeof n=="object"&&n!==null&&"type"in n&&(n.type==="functionCall"||n.type==="functioncall")}a(U9,"isFunctionCallExpression")});var lx=S(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});ep.TripleTranslator=void 0;var un=Da(),wb=class{static{a(this,"TripleTranslator")}constructor(){this.directionMappings=new Map}setDirectionMappings(e){this.directionMappings=e}translateBGP(e){if(!("triples"in e)||!Array.isArray(e.triples))throw new un.AlgebraTranslatorError("BGP pattern must have triples array");return{type:"bgp",triples:e.triples.map(t=>this.translateTriple(t))}}translateTriple(e){if(!e.subject||!e.predicate||!e.object)throw new un.AlgebraTranslatorError("Triple must have subject, predicate, and object");return{subject:this.translateTripleElement(e.subject),predicate:this.translatePredicate(e.predicate),object:this.translateTripleElement(e.object)}}translateConstructTemplate(e){return!e||!Array.isArray(e)?[]:e.map(t=>this.translateTriple(t))}translatePredicate(e){return"type"in e&&e.type==="path"?this.translatePropertyPath(e):this.translateTripleElement(e)}translatePropertyPath(e){if(!("pathType"in e)||!e.pathType)throw new un.AlgebraTranslatorError("Property path must have pathType");if(!("items"in e)||!Array.isArray(e.items))throw new un.AlgebraTranslatorError("Property path must have items array");let t=e.items.map(r=>this.translatePathItem(r));switch(e.pathType){case"/":return{type:"path",pathType:"/",items:t};case"|":return{type:"path",pathType:"|",items:t};case"^":if(t.length!==1)throw new un.AlgebraTranslatorError("Inverse path must have exactly one item");return{type:"path",pathType:"^",items:[t[0]]};case"+":if(t.length!==1)throw new un.AlgebraTranslatorError("OneOrMore path must have exactly one item");return{type:"path",pathType:"+",items:[t[0]]};case"*":if(t.length!==1)throw new un.AlgebraTranslatorError("ZeroOrMore path must have exactly one item");return{type:"path",pathType:"*",items:[t[0]]};case"?":if(t.length!==1)throw new un.AlgebraTranslatorError("ZeroOrOne path must have exactly one item");return{type:"path",pathType:"?",items:[t[0]]};default:throw new un.AlgebraTranslatorError(`Unsupported property path type: ${e.pathType}`)}}translatePathItem(e){if("type"in e&&e.type==="path")return this.translatePropertyPath(e);if("termType"in e&&e.termType==="NamedNode")return{type:"iri",value:e.value};let t="type"in e?e.type:"termType"in e?e.termType:"unknown";throw new un.AlgebraTranslatorError(`Unsupported path item type: ${String(t)}`)}translateTripleElement(e){if(!e||!("termType"in e))throw new un.AlgebraTranslatorError("Triple element must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};case"Literal":{let t={type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language};if(e.language){let r=this.directionMappings.get(e.language.toLowerCase());r&&(t.direction=r)}return t}case"BlankNode":return{type:"blank",value:e.value};case"Quad":return this.translateQuotedTriple(e);default:throw new un.AlgebraTranslatorError(`Unsupported term type: ${e.termType}`)}}translateQuotedTriple(e){if(!e.subject||!e.predicate||!e.object)throw new un.AlgebraTranslatorError("Quoted triple must have subject, predicate, and object");return{type:"quoted",subject:this.translateTripleElement(e.subject),predicate:this.translateQuotedTriplePredicate(e.predicate),object:this.translateTripleElement(e.object)}}translateQuotedTriplePredicate(e){if(!e||!("termType"in e))throw new un.AlgebraTranslatorError("Quoted triple predicate must have termType");switch(e.termType){case"Variable":return{type:"variable",value:e.value};case"NamedNode":return{type:"iri",value:e.value};default:throw new un.AlgebraTranslatorError(`Quoted triple predicate must be IRI or Variable, got: ${e.termType}`)}}};ep.TripleTranslator=wb});var cx=S(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.ExpressionTranslator=void 0;var Ul=Da(),vb=class{static{a(this,"ExpressionTranslator")}constructor(e){this.translateWhereFn=e.translateWhere,this.translateBGPFn=e.translateBGP,this.translatePatternFn=e.translatePattern}translateExpression(e){if(!e)throw new Ul.AlgebraTranslatorError("Expression cannot be null or undefined");if("type"in e&&e.type==="operation")return this.translateOperationExpression(e);let t="type"in e?e.type:void 0;if(t==="functioncall"||t==="functionCall"){let r=e;return{type:"functionCall",function:r.function,args:r.args.map(i=>this.translateExpression(i))}}if("termType"in e)return this.translateTermExpression(e);throw new Ul.AlgebraTranslatorError(`Unsupported expression structure: ${JSON.stringify(e)}`)}translateFilter(e){if(!e.expression)throw new Ul.AlgebraTranslatorError("Filter pattern must have expression");let t={type:"bgp",triples:[]};return{type:"filter",expression:this.translateExpression(e.expression),input:t}}translateTermExpression(e){if(e.termType==="Variable")return{type:"variable",name:e.value};if(e.termType==="Literal"){let t=e.value;return e.datatype&&(e.datatype.value.includes("#integer")||e.datatype.value.includes("#decimal")?t=parseFloat(e.value):e.datatype.value.includes("#boolean")&&(t=e.value==="true")),{type:"literal",value:t,datatype:e.datatype?.value}}return{type:"literal",value:String(e.value||e)}}translateOperationExpression(e){let t=["=","!=","<",">","<=",">="],r=["&&","||","!"],i=["+","-","*","/"],s=e.args.filter(o=>!("patterns"in o)||"termType"in o);return t.includes(e.operator)?{type:"comparison",operator:e.operator,left:this.translateExpression(s[0]),right:this.translateExpression(s[1])}:r.includes(e.operator)?{type:"logical",operator:e.operator,operands:s.map(o=>this.translateExpression(o))}:i.includes(e.operator)?{type:"arithmetic",operator:e.operator,left:this.translateExpression(s[0]),right:this.translateExpression(s[1])}:e.operator==="exists"||e.operator==="notexists"?this.translateExistsExpression(e):e.operator==="in"||e.operator==="notin"?this.translateInExpression(e):{type:"function",function:e.operator,args:s.map(o=>this.translateExpression(o))}}translateExistsExpression(e){if(!e.args||e.args.length!==1)throw new Ul.AlgebraTranslatorError("EXISTS/NOT EXISTS must have exactly one pattern argument");let t=e.args[0],r;return t.type==="group"&&"patterns"in t&&t.patterns?r=this.translateWhereFn(t.patterns):t.type==="bgp"?r=this.translateBGPFn(t):r=this.translatePatternFn(t),{type:"exists",negated:e.operator==="notexists",pattern:r}}translateInExpression(e){if(!e.args||e.args.length!==2)throw new Ul.AlgebraTranslatorError("IN/NOT IN must have exactly 2 arguments (expression and list)");let t=e.args[0],r=e.args[1];if(!Array.isArray(r))throw new Ul.AlgebraTranslatorError("IN/NOT IN second argument must be an array of values");return{type:"in",expression:this.translateExpression(t),list:r.map(i=>this.translateExpression(i)),negated:e.operator==="notin"}}};tp.ExpressionTranslator=vb});var dx=S(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.PatternTranslator=void 0;var ux=cb(),Nr=Da(),fx=Zh(),Eb=class{static{a(this,"PatternTranslator")}constructor(e){this.directionMappings=new Map,this.translateExpressionFn=e.translateExpression,this.translateSelectFn=e.translateSelect,this.translateBGPFn=e.translateBGP}setDirectionMappings(e){this.directionMappings=e}translateWhere(e){if(e.length===0)throw new Nr.AlgebraTranslatorError("Empty WHERE clause");let t=e.filter(o=>o.type==="filter"),r=e.filter(o=>o.type==="bind"),i=e.filter(o=>o.type!=="filter"&&o.type!=="bind"),s;if(i.length===0)s={type:"bgp",triples:[]};else if(i.length===1)if(i[0].type==="optional"){let o=i[0].expression;s={type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(i[0].patterns),expression:o?this.translateExpressionFn(o):void 0}}else s=this.translatePattern(i[0]);else{if(i[0].type==="optional"){let o=i[0].expression;s={type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(i[0].patterns),expression:o?this.translateExpressionFn(o):void 0}}else s=this.translatePattern(i[0]);for(let o=1;o<i.length;o++){let l=i[o];if(this.isLateralPattern(l)){let c=this.extractLateralSubquery(l),u=this.removeLateralMarker(c),f=this.translateSelectFn(u);s={type:"lateraljoin",left:s,right:f}}else if(l.type==="optional"){let c=l.expression;s={type:"leftjoin",left:s,right:this.translateWhere(l.patterns),expression:c?this.translateExpressionFn(c):void 0}}else{let c=this.translatePattern(l);s={type:"join",left:s,right:c}}}}for(let o of r)s=this.translateBind(o,s);for(let o of t)s={type:"filter",expression:this.translateExpressionFn(o.expression),input:s};return s}translatePattern(e){if(!e||!e.type)throw new Nr.AlgebraTranslatorError("Invalid pattern: missing type");switch(e.type){case"bgp":return this.translateBGPFn(e);case"filter":return this.translateFilter(e);case"optional":return this.translateOptional(e);case"union":return this.translateUnion(e);case"minus":return this.translateMinus(e);case"values":return this.translateValues(e);case"group":return this.translateWhere(e.patterns);case"query":return this.translateSubquery(e);case"service":return this.translateService(e);case"graph":return this.translateGraph(e);default:throw new Nr.AlgebraTranslatorError(`Unsupported pattern type: ${e.type}`)}}translateFilter(e){if(!e.expression)throw new Nr.AlgebraTranslatorError("Filter pattern must have expression");let t={type:"bgp",triples:[]};return{type:"filter",expression:this.translateExpressionFn(e.expression),input:t}}translateOptional(e){if(!e.patterns||e.patterns.length===0)throw new Nr.AlgebraTranslatorError("OPTIONAL pattern must have patterns");let t=e.expression;return{type:"leftjoin",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns),expression:t?this.translateExpressionFn(t):void 0}}translateUnion(e){if(!e.patterns||e.patterns.length<2)throw new Nr.AlgebraTranslatorError("UNION pattern must have at least 2 patterns");let t=a(i=>i.type==="graph"?this.translateGraph(i):i.type==="service"?this.translateService(i):"patterns"in i&&i.patterns&&Array.isArray(i.patterns)?this.translateWhere(i.patterns):this.translateWhere([i]),"translateBranch"),r={type:"union",left:t(e.patterns[0]),right:t(e.patterns[1])};for(let i=2;i<e.patterns.length;i++)r={type:"union",left:r,right:t(e.patterns[i])};return r}translateMinus(e){if(!e.patterns||e.patterns.length===0)throw new Nr.AlgebraTranslatorError("MINUS pattern must have patterns");return{type:"minus",left:{type:"bgp",triples:[]},right:this.translateWhere(e.patterns)}}translateValues(e){if(!e.values||!Array.isArray(e.values))throw new Nr.AlgebraTranslatorError("VALUES pattern must have values array");let t=new Set;for(let i of e.values)for(let s of Object.keys(i)){let o=s.startsWith("?")?s.slice(1):s;t.add(o)}let r=e.values.map(i=>this.translateValuesBinding(i));return{type:"values",variables:Array.from(t),bindings:r}}translateValuesBinding(e){let t={};for(let[r,i]of Object.entries(e)){let s=r.startsWith("?")?r.slice(1):r,o=i;if(o)if(o.termType==="NamedNode")t[s]={type:"iri",value:o.value};else if(o.termType==="Literal"){let l=o,c={type:"literal",value:l.value,datatype:l.datatype?.value,language:l.language||void 0};if(l.language){let u=this.directionMappings.get(l.language.toLowerCase());u&&(c.direction=u)}t[s]=c}else throw new Nr.AlgebraTranslatorError(`Unsupported VALUES term type: ${o.termType}`)}return t}translateBind(e,t){if(!e.variable||!e.expression)throw new Nr.AlgebraTranslatorError("BIND pattern must have variable and expression");return{type:"extend",variable:e.variable.value,expression:this.translateExpressionFn(e.expression),input:t}}translateSubquery(e){if(e.queryType!=="SELECT")throw new Nr.AlgebraTranslatorError(`Only SELECT subqueries are supported, got: ${String(e.queryType)}`);let t=this.removeLateralMarker(e);return{type:"subquery",query:this.translateSelectFn(t)}}translateService(e){if(!e.name||e.name.termType!=="NamedNode")throw new Nr.AlgebraTranslatorError("SERVICE pattern must have a NamedNode endpoint");if(!e.patterns||!Array.isArray(e.patterns))throw new Nr.AlgebraTranslatorError("SERVICE pattern must have patterns array");return{type:"service",endpoint:e.name.value,pattern:this.translateWhere(e.patterns),silent:e.silent||!1}}translateGraph(e){if(!e.name)throw new Nr.AlgebraTranslatorError("GRAPH pattern must have a name (IRI or variable)");if(!e.patterns||!Array.isArray(e.patterns))throw new Nr.AlgebraTranslatorError("GRAPH pattern must have patterns array");let t;if(e.name.termType==="NamedNode")t={type:"iri",value:e.name.value};else if(e.name.termType==="Variable")t={type:"variable",value:e.name.value};else throw new Nr.AlgebraTranslatorError(`GRAPH pattern name must be NamedNode or Variable, got: ${e.name.termType}`);return{type:"graph",name:t,pattern:this.translateWhere(e.patterns)}}isLateralPattern(e){if(e.type==="query"&&this.isLateralSubquery(e))return!0;if(e.type==="group"&&e.patterns?.length===1){let t=e.patterns[0];if(t.type==="query"&&this.isLateralSubquery(t))return!0}return!1}extractLateralSubquery(e){if(e.type==="query")return e;if(e.type==="group"&&e.patterns?.length===1){let t=e.patterns[0];if(t.type==="query")return t}throw new Nr.AlgebraTranslatorError("Invalid lateral pattern structure")}isLateralSubquery(e){return!("queryType"in e)||e.queryType!=="SELECT"||!("variables"in e)||!e.variables?!1:e.variables.some(i=>(0,fx.isVariableTerm)(i)&&i.value===ux.LateralTransformer.LATERAL_MARKER)}removeLateralMarker(e){if(!("variables"in e)||!e.variables)return e;let t=e,r=t.variables;return{...t,variables:r.filter(i=>!((0,fx.isVariableTerm)(i)&&i.value===ux.LateralTransformer.LATERAL_MARKER))}}};rp.PatternTranslator=Eb});var px=S(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});np.AggregateTranslator=void 0;var hx=Da(),V9=Zh(),Tb=class{static{a(this,"AggregateTranslator")}constructor(e){this.aggregateCounter=0,this.translateExpressionFn=e.translateExpression}resetCounter(){this.aggregateCounter=0}extractAggregatesWithMapping(e,t){if(!e)return[];let r=[];for(let i of e)(0,V9.isVariableExpression)(i)&&("type"in i.expression&&i.expression.type==="aggregate"?(r.push({variable:i.variable.value,expression:this.translateAggregateExpression(i.expression)}),t.set(i.expression,i.variable.value)):this.collectNestedAggregates(i.expression,r,t));return r}extractGroupVariables(e){return e?e.filter(t=>t.expression&&"termType"in t.expression&&t.expression.termType==="Variable").map(t=>t.expression.value):[]}extractHavingExpressions(e,t,r){if(!e||e.length===0)return[];for(let i of e)this.collectNestedAggregates(i,t,r);return e.map(i=>this.transformExpressionWithAggregateVars(i,r))}transformExpressionWithAggregateVars(e,t){let r=t.get(e);if(r!==void 0)return{type:"variable",name:r};if("type"in e&&e.type==="operation"&&"args"in e){let i=e,s=i.args.filter(u=>!Array.isArray(u)&&!("patterns"in u)).map(u=>this.transformExpressionWithAggregateVars(u,t)),o=["=","!=","<",">","<=",">="],l=["&&","||","!"],c=["+","-","*","/"];return o.includes(i.operator)?{type:"comparison",operator:i.operator,left:s[0],right:s[1]}:l.includes(i.operator)?{type:"logical",operator:i.operator,operands:s}:c.includes(i.operator)?{type:"arithmetic",operator:i.operator,left:s[0],right:s[1]}:{type:"function",function:i.operator,args:s}}return this.translateExpressionFn(e)}translateOrderComparator(e){return{expression:this.translateExpressionFn(e.expression),descending:e.descending||!1}}translateAggregateExpression(e){let t=e.aggregation,r=a(()=>{if(e.expression&&!("termType"in e.expression&&e.expression.termType==="Wildcard"))return this.translateExpressionFn(e.expression)},"translateInnerExpr");if(typeof t=="string"){let s=t.toLowerCase();return["count","sum","avg","min","max","group_concat","sample"].includes(s)?{type:"aggregate",aggregation:s,expression:r(),distinct:e.distinct||!1,separator:e.separator}:{type:"aggregate",aggregation:{type:"custom",iri:t},expression:r(),distinct:e.distinct||!1,separator:e.separator}}let i=t;if(i&&typeof i=="object"){let s,o=i;if(o.termType==="NamedNode"&&typeof o.value=="string")s=o.value;else if("value"in o)s=String(o.value);else throw new hx.AlgebraTranslatorError(`Invalid custom aggregate: expected IRI but got ${JSON.stringify(i)}`);return{type:"aggregate",aggregation:{type:"custom",iri:s},expression:r(),distinct:e.distinct||!1,separator:e.separator}}throw new hx.AlgebraTranslatorError(`Unknown aggregate format: ${JSON.stringify(t)}`)}collectNestedAggregates(e,t,r){if(e){if("type"in e&&e.type==="aggregate"){let i=`__agg${this.aggregateCounter++}`;t.push({variable:i,expression:this.translateAggregateExpression(e)}),r.set(e,i)}else if("type"in e&&e.type==="operation"&&"args"in e){let i=e;for(let s of i.args)!Array.isArray(s)&&"type"in s&&!("patterns"in s)?this.collectNestedAggregates(s,t,r):"termType"in s&&this.collectNestedAggregates(s,t,r)}}}};np.AggregateTranslator=Tb});var Vl=S(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.AlgebraTranslator=Lo.ExoQLAlgebraTranslator=Lo.AlgebraTranslatorError=void 0;var ip=Da(),sp=Zh(),B9=lx(),G9=cx(),q9=dx(),W9=px(),z9=Da();Object.defineProperty(Lo,"AlgebraTranslatorError",{enumerable:!0,get:a(function(){return z9.AlgebraTranslatorError},"get")});var op=class{static{a(this,"ExoQLAlgebraTranslator")}constructor(){this.tripleTranslator=new B9.TripleTranslator,this.expressionTranslator=new G9.ExpressionTranslator({translateWhere:a(e=>this.patternTranslator.translateWhere(e),"translateWhere"),translateBGP:a(e=>this.tripleTranslator.translateBGP(e),"translateBGP"),translatePattern:a(e=>this.patternTranslator.translatePattern(e),"translatePattern")}),this.patternTranslator=new q9.PatternTranslator({translateExpression:a(e=>this.expressionTranslator.translateExpression(e),"translateExpression"),translateSelect:a(e=>this.translateSelect(e),"translateSelect"),translateBGP:a(e=>this.tripleTranslator.translateBGP(e),"translateBGP")}),this.aggregateTranslator=new W9.AggregateTranslator({translateExpression:a(e=>this.expressionTranslator.translateExpression(e),"translateExpression")})}setDirectionMappings(e){this.tripleTranslator.setDirectionMappings(e),this.patternTranslator.setDirectionMappings(e)}translate(e){if(e.type!=="query")throw new ip.AlgebraTranslatorError("Only query operations are supported (not updates)");if(e.queryType==="SELECT")return this.translateSelect(e);if(e.queryType==="CONSTRUCT")return this.translateConstruct(e);if(e.queryType==="ASK")return this.translateAsk(e);if(e.queryType==="DESCRIBE")return this.translateDescribe(e);throw new ip.AlgebraTranslatorError(`Query type ${String(e.queryType)} not yet supported`)}translateSelect(e){if(!e.where||e.where.length===0)throw new ip.AlgebraTranslatorError("SELECT query must have WHERE clause");let t=this.patternTranslator.translateWhere(e.where);this.aggregateTranslator.resetCounter();let r=new Map,i=Array.isArray(e.variables)?e.variables.filter(c=>!("termType"in c&&c.termType==="Wildcard")):[],s=this.aggregateTranslator.extractAggregatesWithMapping(i,r),o=this.aggregateTranslator.extractGroupVariables(e.group),l=this.aggregateTranslator.extractHavingExpressions(e.having,s,r);if((s.length>0||o.length>0||l.length>0)&&(t={type:"group",variables:o,aggregates:s,having:l.length>0?l:void 0,input:t}),i.length>0){for(let u of i)if((0,sp.isVariableExpression)(u)){if("type"in u.expression&&u.expression.type==="aggregate")continue;let f=this.aggregateTranslator.transformExpressionWithAggregateVars(u.expression,r);t={type:"extend",variable:u.variable.value,expression:f,input:t}}let c=i.filter(u=>(0,sp.isVariableTerm)(u)||(0,sp.isVariableExpression)(u)).map(u=>(0,sp.isVariableTerm)(u)?u.value:u.variable.value);c.length>0&&(t={type:"project",variables:c,input:t})}return e.distinct&&(t={type:"distinct",input:t}),e.reduced&&(t={type:"reduced",input:t}),e.order&&e.order.length>0&&(t={type:"orderby",comparators:e.order.map(c=>this.aggregateTranslator.translateOrderComparator(c)),input:t}),(e.limit!==void 0||e.offset!==void 0)&&(t={type:"slice",limit:e.limit,offset:e.offset,input:t}),t}translateConstruct(e){let t=this.tripleTranslator.translateConstructTemplate(e.template??[]);if(!e.where||e.where.length===0)throw new ip.AlgebraTranslatorError("CONSTRUCT query must have WHERE clause");let r=this.patternTranslator.translateWhere(e.where),i=e;return(i.limit!==void 0||i.offset!==void 0)&&(r={type:"slice",limit:i.limit,offset:i.offset,input:r}),{type:"construct",template:t,where:r}}translateAsk(e){return{type:"ask",where:e.where&&e.where.length>0?this.patternTranslator.translateWhere(e.where):{type:"bgp",triples:[]}}}translateDescribe(e){let t=[];if(e.variables&&Array.isArray(e.variables)){let s=e.variables;for(let o of s)o.termType==="Wildcard"||o.value==="*"||(o.termType==="Variable"?t.push({type:"variable",value:o.value}):o.termType==="NamedNode"&&t.push({type:"iri",value:o.value}))}let r;e.where&&e.where.length>0&&(r=this.patternTranslator.translateWhere(e.where));let i=e.describeOptions;return{type:"describe",resources:t,where:r,depth:i?.depth,symmetric:i?.symmetric}}};Lo.ExoQLAlgebraTranslator=op;Lo.AlgebraTranslator=op});var ss=S(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.SolutionMapping=void 0;var mx=$e(),gx=Ae(),yx=$t(),Ib=class n{static{a(this,"SolutionMapping")}constructor(e){this.bindings=e?new Map(e):new Map}get(e){return this.bindings.get(e)}set(e,t){this.bindings.set(e,t)}has(e){return this.bindings.has(e)}variables(){return Array.from(this.bindings.keys())}getBindings(){return new Map(this.bindings)}isCompatibleWith(e){for(let[t,r]of this.bindings.entries()){let i=e.get(t);if(i!==void 0&&!this.areEqual(r,i))return!1}return!0}merge(e){if(!this.isCompatibleWith(e))return null;let t=new n(this.bindings);for(let[r,i]of e.getBindings().entries())t.set(r,i);return t}clone(){return new n(this.bindings)}areEqual(e,t){return e instanceof mx.Literal&&t instanceof mx.Literal?e.equals(t):e instanceof gx.IRI&&t instanceof gx.IRI?e.value===t.value:e instanceof yx.BlankNode&&t instanceof yx.BlankNode?e.id===t.id:!1}toJSON(){let e={};for(let[t,r]of this.bindings.entries())e[t]=r.toString();return e}size(){return this.bindings.size}};ap.SolutionMapping=Ib});var bx=S(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.PropertyPathExecutor=Gl.PropertyPathExecutorError=void 0;var H9=ss(),lp=Ae(),_x=$t(),Q9=$e(),Bl=class extends Error{static{a(this,"PropertyPathExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="PropertyPathExecutorError"}};Gl.PropertyPathExecutorError=Bl;var xb=class n{static{a(this,"PropertyPathExecutor")}constructor(e){this.tripleStore=e,this.MAX_DEPTH=100}async*execute(e,t,r){if(this.isLiteralElement(e)||this.isLiteralElement(r)){let o=this.isLiteralElement(e)?"subject":"object",l=this.isLiteralElement(e)?e:r,c="value"in l?String(l.value):"<unknown>",u=c.length>80?`${c.slice(0,77)}...`:c,f=this.describePath(t),d={position:o,value:u,path:f,hint:"Wikilink could not be resolved to IRI (likely label-form wikilink with no matching basename/alias). Check whether the target file exists in the queried vault, add an alias, or load the target vault via --also. See issue #3282."};if(console.error(`[PropertyPathExecutor] literal-safety guard fired: literal in ${o} position \u2014 yielding 0 solutions. value="${u}" path=${f}`,d),n.isStrictModeEnabled())throw new Bl(`Literal subject in property path: "${u}" (path=${f}). Set EXOCORTEX_SPARQL_STRICT=0 or omit --strict to fall back to warn-and-empty behaviour.`);return}let i=await this.resolveElement(e),s=this.isVariable(r)?null:await this.resolveElement(r);for(let o of i){let l=await this.evaluatePath(o,t,s);for(let c of l){let u=new H9.SolutionMapping;this.isVariable(e)&&u.set(e.value,o),this.isVariable(r)&&u.set(r.value,c),yield u}}}async*executeWithBindings(e,t){if(!this.isPropertyPath(e.predicate))throw new Bl("Predicate is not a property path");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.object,t);for await(let s of this.execute(r,e.predicate,i)){let o=t.merge(s);o!==null&&(yield o)}}async evaluatePath(e,t,r){switch(t.pathType){case"/":return this.evaluateSequencePath(e,t.items,r);case"|":return this.evaluateAlternativePath(e,t.items,r);case"^":return this.evaluateInversePath(e,t.items[0],r);case"+":return this.evaluateOneOrMorePath(e,t.items[0],r);case"*":return this.evaluateZeroOrMorePath(e,t.items[0],r);case"?":return this.evaluateZeroOrOnePath(e,t.items[0],r)}}async evaluateSequencePath(e,t,r){let i=new Set([e]);for(let s=0;s<t.length;s++){let o=t[s],l=s===t.length-1,c=new Set;for(let u of i){let f=await this.evaluatePathItem(u,o,l?r:null);for(let d of f)c.add(d)}if(i=c,i.size===0)break}return i}async evaluateAlternativePath(e,t,r){let i=new Set;for(let s of t){let o=await this.evaluatePathItem(e,s,r);for(let l of o)i.add(l)}return i}async evaluateInversePath(e,t,r){if(t.type==="iri"){let i=new lp.IRI(t.value),s=await this.tripleStore.match(void 0,i,e),o=new Set;for(let l of s)(r===null||this.nodeInSet(l.subject,r))&&o.add(l.subject);return o}else return this.evaluatePath(e,this.invertPath(t),r)}async evaluateOneOrMorePath(e,t,r){let i=new Set,s=new Set,o=[{node:e,depth:0}];for(;o.length>0;){let l=o.shift();if(!l)break;let{node:c,depth:u}=l;if(u>=this.MAX_DEPTH)continue;let f=await this.evaluatePathItem(c,t,null);for(let d of f){let h=this.nodeToKey(d);(r===null||this.nodeInSet(d,r))&&s.add(d),i.has(h)||(i.add(h),o.push({node:d,depth:u+1}))}}return s}async evaluateZeroOrMorePath(e,t,r){let i=await this.evaluateOneOrMorePath(e,t,r);return(r===null||this.nodeInSet(e,r))&&i.add(e),i}async evaluateZeroOrOnePath(e,t,r){let i=new Set;(r===null||this.nodeInSet(e,r))&&i.add(e);let s=await this.evaluatePathItem(e,t,r);for(let o of s)i.add(o);return i}async evaluatePathItem(e,t,r){if(t.type==="iri"){let i=new lp.IRI(t.value),s=await this.tripleStore.match(e,i,void 0),o=new Set;for(let l of s)(r===null||this.nodeInSet(l.object,r))&&o.add(l.object);return o}else return this.evaluatePath(e,t,r)}invertPath(e){switch(e.pathType){case"^":return e.items[0];case"/":return{type:"path",pathType:"/",items:[...e.items].reverse().map(t=>t.type==="iri"?{type:"path",pathType:"^",items:[t]}:this.invertPath(t))};case"|":return{type:"path",pathType:"|",items:e.items.map(t=>t.type==="iri"?{type:"path",pathType:"^",items:[t]}:this.invertPath(t))};case"+":case"*":case"?":{let t=e.items[0].type==="iri"?{type:"path",pathType:"^",items:[e.items[0]]}:this.invertPath(e.items[0]);return{type:"path",pathType:e.pathType,items:[t]}}}}async resolveElement(e){if(this.isVariable(e)){let r=new Set,i=await this.tripleStore.match(void 0,void 0,void 0);for(let s of i)r.add(s.subject),r.add(s.object);return r}let t=new Set;switch(e.type){case"iri":t.add(new lp.IRI(e.value));break;case"blank":t.add(new _x.BlankNode(e.value));break;default:throw new Bl(`Unsupported element type in subject/object position: ${e.type}`)}return t}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r){if(r instanceof lp.IRI)return{type:"iri",value:r.value};if(r instanceof _x.BlankNode)return{type:"blank",value:r.id};if(r instanceof Q9.Literal)return{type:"literal",value:r.value,datatype:r.datatype?.value,language:r.language,direction:r.direction}}}return e}isVariable(e){return e.type==="variable"}isLiteralElement(e){return e.type==="literal"}isPropertyPath(e){return e.type==="path"}nodeToKey(e){return e.toString()}nodeInSet(e,t){let r=this.nodeToKey(e);for(let i of t)if(this.nodeToKey(i)===r)return!0;return!1}describePath(e){try{let t=e.items,r=a(s=>{if(s&&typeof s=="object"&&"type"in s){let o=s;if(o.type==="iri")return`<${String(o.value)}>`;if(o.type==="path")return this.describePath(o)}return"?"},"renderItem");if(!Array.isArray(t)||t.length===0)return"(?)";if(t.length===1){let s=r(t[0]);return e.pathType==="^"?`(^${s})`:e.pathType==="+"||e.pathType==="*"||e.pathType==="?"?`(${s}${e.pathType})`:`(${s})`}return`(${t.map(r).join(` ${e.pathType} `)})`}catch{return"<unprintable-path>"}}static isStrictModeEnabled(){let e=process.env?.EXOCORTEX_SPARQL_STRICT;if(!e)return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"}};Gl.PropertyPathExecutor=xb});var Cb=S(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});ql.BGPExecutor=ql.BGPExecutorError=void 0;var cp=ss(),No=Ae(),Ab=$e(),up=$t(),fp=Ou(),Sx=bx(),kr=class extends Error{static{a(this,"BGPExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="BGPExecutorError"}};ql.BGPExecutorError=kr;var Rb=class{static{a(this,"BGPExecutor")}constructor(e){this.tripleStore=e,this.propertyPathExecutor=new Sx.PropertyPathExecutor(e)}async*execute(e){if(e.triples.length===0){yield new cp.SolutionMapping;return}let t=this.matchTriplePattern(e.triples[0]);for(let r=1;r<e.triples.length;r++)t=this.joinWithPattern(t,e.triples[r]);for await(let r of t)yield r}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*executeInGraph(e,t){if(e.triples.length===0){yield new cp.SolutionMapping;return}let r=this.matchTriplePatternInGraph(e.triples[0],t);for(let i=1;i<e.triples.length;i++)r=this.joinWithPatternInGraph(r,e.triples[i],t);for await(let i of r)yield i}async*matchTriplePatternInGraph(e,t){if(this.isPropertyPath(e.predicate))throw new kr("Property paths within named graphs are not yet supported");let r=e.predicate;if(this.isLiteral(e.subject)||this.isLiteral(r)){this.warnLiteralGuard("matchTriplePatternInGraph",this.isLiteral(e.subject)?"subject":"predicate",this.isLiteral(e.subject)?e.subject:r);return}let i=this.isVariable(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),s=this.isVariable(r)?void 0:this.toRDFTermAsPredicate(r),o=this.isVariable(e.object)?void 0:this.toRDFTerm(e.object);if(!this.tripleStore.matchInGraph)throw new kr("Triple store does not support named graph operations");let l=await this.tripleStore.matchInGraph(i,s,o,t);for(let c of l){let u=new cp.SolutionMapping;this.isVariable(e.subject)&&u.set(e.subject.value,c.subject),this.isVariable(r)&&u.set(r.value,c.predicate),this.isVariable(e.object)&&u.set(e.object.value,c.object),yield u}}async*joinWithPatternInGraph(e,t,r){let i=[];for await(let s of e)i.push(s);for(let s of i){let o=this.instantiatePattern(t,s);for await(let l of this.matchTriplePatternInGraph(o,r)){let c=s.merge(l);c!==null&&(yield c)}}}async*matchTriplePattern(e){if(this.isPropertyPath(e.predicate)){if(this.isLiteral(e.subject)||this.isLiteral(e.object)){this.warnLiteralGuard("matchTriplePattern.propertyPath",this.isLiteral(e.subject)?"subject":"object",this.isLiteral(e.subject)?e.subject:e.object);return}yield*this.propertyPathExecutor.execute(e.subject,e.predicate,e.object);return}let t=e.predicate;if(this.isLiteral(e.subject)||this.isLiteral(t)){this.warnLiteralGuard("matchTriplePattern",this.isLiteral(e.subject)?"subject":"predicate",this.isLiteral(e.subject)?e.subject:t);return}let r=this.isVariable(e.subject)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)?void 0:this.toRDFTermAsSubject(e.subject),i=this.isVariable(t)?void 0:this.toRDFTermAsPredicate(t),s=this.isVariable(e.object)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object)?void 0:this.toRDFTerm(e.object),o=await this.tripleStore.match(r,i,s);for(let l of o){let c=new cp.SolutionMapping;if(this.isVariable(e.subject))c.set(e.subject.value,l.subject);else if(this.isQuotedTriple(e.subject)){let u=this.matchQuotedTriplePattern(e.subject,l.subject);if(u===null)continue;for(let[f,d]of u.entries())c.set(f,d)}if(this.isVariable(t)&&c.set(t.value,l.predicate),this.isVariable(e.object))c.set(e.object.value,l.object);else if(this.isQuotedTriple(e.object)){let u=this.matchQuotedTriplePattern(e.object,l.object);if(u===null)continue;for(let[f,d]of u.entries())c.set(f,d)}yield c}}hasVariablesInQuotedTriple(e){return!!(this.isVariable(e.subject)||e.predicate.type==="variable"||this.isVariable(e.object)||this.isQuotedTriple(e.subject)&&this.hasVariablesInQuotedTriple(e.subject)||this.isQuotedTriple(e.object)&&this.hasVariablesInQuotedTriple(e.object))}matchQuotedTriplePattern(e,t){if(!(t instanceof fp.QuotedTriple))return null;let r=new Map;if(this.isVariable(e.subject))r.set(e.subject.value,t.subject);else if(this.isQuotedTriple(e.subject)){let i=this.matchQuotedTriplePattern(e.subject,t.subject);if(i===null)return null;for(let[s,o]of i)r.set(s,o)}else if(!this.elementsMatch(e.subject,t.subject))return null;if(e.predicate.type==="variable")r.set(e.predicate.value,t.predicate);else if(e.predicate.value!==t.predicate.value)return null;if(this.isVariable(e.object))r.set(e.object.value,t.object);else if(this.isQuotedTriple(e.object)){let i=this.matchQuotedTriplePattern(e.object,t.object);if(i===null)return null;for(let[s,o]of i)r.set(s,o)}else if(!this.elementsMatch(e.object,t.object))return null;return r}elementsMatch(e,t){switch(e.type){case"iri":return t instanceof No.IRI&&e.value===t.value;case"literal":return!(!(t instanceof Ab.Literal)||e.value!==t.value||e.datatype!==t.datatype?.value||e.language!==t.language||e.direction!==t.direction);case"blank":return t instanceof up.BlankNode&&e.value===t.id;case"quoted":return t instanceof fp.QuotedTriple?this.toRDFQuotedTriple(e).equals(t):!1;default:return!1}}isPropertyPath(e){return e.type==="path"}async*joinWithPattern(e,t){let r=[];for await(let i of e)r.push(i);for(let i of r){let s=this.instantiatePattern(t,i);for await(let o of this.matchTriplePattern(s)){let l=i.merge(o);l!==null&&(yield l)}}}instantiatePattern(e,t){let r=this.isPropertyPath(e.predicate)?e.predicate:this.instantiateElement(e.predicate,t);return{subject:this.instantiateElement(e.subject,t),predicate:r,object:this.instantiateElement(e.object,t)}}instantiateElement(e,t){if(this.isVariable(e)){let r=t.get(e.value);if(r)return this.toAlgebraElement(r)}return this.isQuotedTriple(e)?this.instantiateQuotedTriple(e,t):e}instantiateQuotedTriple(e,t){let r=this.instantiateElement(e.subject,t),i=e.predicate.type==="variable"?this.instantiatePredicateVariable(e.predicate,t):e.predicate,s=this.instantiateElement(e.object,t);return{type:"quoted",subject:r,predicate:i,object:s}}instantiatePredicateVariable(e,t){let r=t.get(e.value);return r&&r instanceof No.IRI?{type:"iri",value:r.value}:e}isVariable(e){return e.type==="variable"}isQuotedTriple(e){return e.type==="quoted"}isLiteral(e){return e.type==="literal"}warnLiteralGuard(e,t,r){let i="value"in r?String(r.value):"<unknown>",s=i.length>80?`${i.slice(0,77)}...`:i,o={executor:"BGPExecutor",context:e,position:t,value:s,hint:"Wikilink could not be resolved to IRI (likely label-form wikilink with no matching basename/alias). Check whether the target file exists in the queried vault, add an alias, or load the target vault via --also. See issue #3282."};if(console.error(`[BGPExecutor] literal-safety guard fired in ${e}: literal in ${t} position \u2014 yielding 0 solutions. value="${s}"`,o),Sx.PropertyPathExecutor.isStrictModeEnabled())throw new kr(`Literal in ${t} position (${e}): "${s}". Set EXOCORTEX_SPARQL_STRICT=0 or omit --strict to fall back to warn-and-empty behaviour.`)}toRDFTermAsSubject(e){switch(e.type){case"iri":return new No.IRI(e.value);case"blank":return new up.BlankNode(e.value);case"literal":throw new kr("Literals cannot appear in subject position");case"variable":throw new kr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new kr(`Unknown element type: ${String(e)}`)}}toRDFQuotedTriple(e){let t=this.toRDFTermAsSubject(e.subject),r=e.predicate.type==="iri"?new No.IRI(e.predicate.value):(()=>{throw new kr("Quoted triple predicate must be IRI")})(),i=this.toRDFTerm(e.object);return new fp.QuotedTriple(t,r,i)}toRDFTermAsPredicate(e){switch(e.type){case"iri":return new No.IRI(e.value);case"literal":throw new kr("Literals cannot appear in predicate position");case"blank":throw new kr("Blank nodes cannot appear in predicate position");case"variable":throw new kr(`Cannot convert variable to RDF term: ${e.value}`);default:throw new kr(`Unknown element type: ${String(e)}`)}}toRDFTerm(e){switch(e.type){case"iri":return new No.IRI(e.value);case"literal":return new Ab.Literal(e.value,e.datatype?new No.IRI(e.datatype):void 0,e.language,e.direction);case"blank":return new up.BlankNode(e.value);case"variable":throw new kr(`Cannot convert variable to RDF term: ${e.value}`);case"quoted":return this.toRDFQuotedTriple(e);default:throw new kr(`Unknown element type: ${String(e)}`)}}toAlgebraElement(e){if(e instanceof No.IRI)return{type:"iri",value:e.value};if(e instanceof Ab.Literal)return{type:"literal",value:e.value,datatype:e.datatype?.value,language:e.language,direction:e.direction};if(e instanceof up.BlankNode)return{type:"blank",value:e.id};if(e instanceof fp.QuotedTriple)return this.toAlgebraQuotedTriple(e);throw new kr(`Unknown RDF term type: ${String(e)}`)}toAlgebraQuotedTriple(e){return{type:"quoted",subject:this.toAlgebraElement(e.subject),predicate:{type:"iri",value:e.predicate.value},object:this.toAlgebraElement(e.object)}}};ql.BGPExecutor=Rb});var wx=S(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});dp.StringFunctions=void 0;var Wl=Ae(),ko=$e(),Pb=$t(),Ku=class n{static{a(this,"StringFunctions")}static str(e){if(e===void 0)throw new Error("STR: argument is undefined");return e instanceof Wl.IRI||e instanceof ko.Literal?e.value:e instanceof Pb.BlankNode?e.id:String(e)}static lang(e){if(e===void 0)throw new Error("LANG: argument is undefined");return e instanceof ko.Literal&&e.language?e.language:""}static langdir(e){if(e===void 0)throw new Error("LANGDIR: argument is undefined");return!(e instanceof ko.Literal)||!e.language?"":e.direction?`${e.language}--${e.direction}`:e.language}static langMatches(e,t){let[r,i]=n.parseDirectionalLangTag(e),[s,o]=n.parseDirectionalLangTag(t),l=r.toLowerCase(),c=s.toLowerCase();return c==="*"?l!=="":l===""?c==="":o&&i!==o?!1:l===c?!0:l.startsWith(c+"-")}static parseDirectionalLangTag(e){let t=e.indexOf("--");if(t===-1)return[e,void 0];let r=e.substring(0,t),i=e.substring(t+2).toLowerCase();return[r,i]}static regex(e,t,r){try{let i=r?r.includes("u")?r:r+"u":"u";return new RegExp(t,i).test(e)}catch(i){throw new Error(`REGEX: invalid pattern '${t}': ${i.message}`)}}static contains(e,t){return e.includes(t)}static strStarts(e,t){return e.startsWith(t)}static strEnds(e,t){return e.endsWith(t)}static strlen(e){return e.length}static ucase(e){return e.toUpperCase()}static lcase(e){return e.toLowerCase()}static substr(e,t,r){let i=t-1;if(i<0){if(r!==void 0){let s=r+i;return s<=0?"":e.substring(0,s)}return e}return r!==void 0?e.substring(i,i+r):e.substring(i)}static strBefore(e,t){if(t==="")return"";let r=e.indexOf(t);return r===-1?"":e.substring(0,r)}static strAfter(e,t){if(t==="")return e;let r=e.indexOf(t);return r===-1?"":e.substring(r+t.length)}static concat(...e){return e.join("")}static replace(e,t,r,i){try{let s=i||"g",o=s.includes("u")?s:s+"u",l=new RegExp(t,o);return e.replace(l,r)}catch(s){throw new Error(`REPLACE: invalid pattern '${t}': ${s.message}`)}}static encodeForUri(e){return encodeURIComponent(e)}static normalize(e,t){if(e===void 0)throw new Error("NORMALIZE: string argument is undefined");let r;if(e instanceof ko.Literal)r=e.value;else if(e instanceof Wl.IRI)r=e.value;else if(e instanceof Pb.BlankNode)r=e.id;else if(typeof e=="string")r=e;else throw new Error("NORMALIZE: first argument must be a string or literal");let i="NFC";if(t!==void 0)if(t instanceof ko.Literal)i=t.value.toUpperCase();else if(typeof t=="string")i=t.toUpperCase();else if(t instanceof Wl.IRI)i=t.value.toUpperCase();else throw new Error("NORMALIZE: second argument must be a string literal");if(!n.VALID_NORMALIZATION_FORMS.includes(i))throw new Error(`NORMALIZE: invalid normalization form '${i}'. Valid forms are: NFC, NFD, NFKC, NFKD`);let s=r.normalize(i);return new ko.Literal(s,new Wl.IRI("http://www.w3.org/2001/XMLSchema#string"))}static fold(e){if(e===void 0)throw new Error("FOLD: string argument is undefined");let t;if(e instanceof ko.Literal)t=e.value;else if(e instanceof Wl.IRI)t=e.value;else if(e instanceof Pb.BlankNode)t=e.id;else if(typeof e=="string")t=e;else throw new Error("FOLD: argument must be a string or literal");let r=n.unicodeCaseFold(t);return new ko.Literal(r,new Wl.IRI("http://www.w3.org/2001/XMLSchema#string"))}static unicodeCaseFold(e){let t="";for(let r of e){let i=n.CASE_FOLDING_MAP.get(r);i!==void 0?t+=i:t+=r.toLowerCase()}return t}};dp.StringFunctions=Ku;Ku.VALID_NORMALIZATION_FORMS=["NFC","NFD","NFKC","NFKD"];Ku.CASE_FOLDING_MAP=new Map([["\xDF","ss"],["\u1E9E","ss"],["\u03A3","\u03C3"],["\u03C2","\u03C3"],["\u0130","i\u0307"],["I","i"],["\u0587","\u0565\u0582"],["\uFB00","ff"],["\uFB01","fi"],["\uFB02","fl"],["\uFB03","ffi"],["\uFB04","ffl"],["\uFB05","st"],["\uFB06","st"],["\u0390","\u03B9\u0308\u0301"],["\u03B0","\u03C5\u0308\u0301"],["\u017F","s"],["\u1E9B","\u1E61"],["\u212A","k"],["\u212B","\xE5"]])});var vx=S(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.MathFunctions=void 0;var Ob=class{static{a(this,"MathFunctions")}static msToMinutes(e){return Math.round(e/(1e3*60))}static msToHours(e){return Math.round(e/(1e3*60*60)*100)/100}static msToSeconds(e){return Math.round(e/1e3)}static abs(e){return Math.abs(e)}static round(e){return Math.round(e)}static ceil(e){return Math.ceil(e)}static floor(e){return Math.floor(e)}static rand(){return Math.random()}};hp.MathFunctions=Ob});var Ju=S(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});pp.DateTimeParsing=void 0;var Y9=Ae(),X9=$e(),Fb=class n{static{a(this,"DateTimeParsing")}static parseDate(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`PARSEDATE: invalid date string '${e}'`);return t.getTime()}static parseDayTimeDuration(e){if(!e)throw new Error("parseDayTimeDuration: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDayTimeDuration: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=r.indexOf("T"),o="",l="";if(s===-1?o=r:(o=r.substring(0,s),l=r.substring(s+1)),o){let c=o.match(/^(\d+(?:\.\d+)?)D$/);if(c){let u=parseFloat(c[1]);i+=u*24*60*60*1e3}else if(o!=="")throw new Error(`parseDayTimeDuration: invalid day component: '${o}' in '${e}'`)}if(l){let c=l,u=c.match(/^(\d+(?:\.\d+)?)H/);if(u){let h=parseFloat(u[1]);i+=h*60*60*1e3,c=c.substring(u[0].length)}let f=c.match(/^(\d+(?:\.\d+)?)M/);if(f){let h=parseFloat(f[1]);i+=h*60*1e3,c=c.substring(f[0].length)}let d=c.match(/^(\d+(?:\.\d+)?)S$/);if(d){let h=parseFloat(d[1]);i+=h*1e3,c=c.substring(d[0].length)}if(c!=="")throw new Error(`parseDayTimeDuration: invalid time component: '${c}' in '${e}'`)}return t?-i:i}static formatDayTimeDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/(1440*60*1e3));r=r%(1440*60*1e3);let s=Math.floor(r/(3600*1e3));r=r%(3600*1e3);let o=Math.floor(r/(60*1e3));r=r%(60*1e3);let l=r/1e3,c=t?"-P":"P";return i>0&&(c+=`${i}D`),(s>0||o>0||l>0||i===0)&&(c+="T",s>0&&(c+=`${s}H`),o>0&&(c+=`${o}M`),(l>0||s===0&&o===0)&&(Number.isInteger(l)?c+=`${l}S`:c+=`${parseFloat(l.toFixed(3))}S`)),c}static xsdDayTimeDuration(e){return n.parseDayTimeDuration(e),new X9.Literal(e,new Y9.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static parseXSDDate(e){let t=/^(-?\d{4})-(\d{2})-(\d{2})(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r){let u=new Date(e);return isNaN(u.getTime())?null:new Date(Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate()))}let i=parseInt(r[1],10),s=parseInt(r[2],10)-1,o=parseInt(r[3],10),l=r[4],c=new Date(Date.UTC(i,s,o));if(l&&l!=="Z"){let u=l.match(/([+-])(\d{2}):(\d{2})/);if(u){let f=u[1]==="+"?1:-1,d=parseInt(u[2],10),h=parseInt(u[3],10),p=f*(d*60+h)*60*1e3;c=new Date(c.getTime()-p)}}return c}static parseXSDTime(e){let t=/^(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})?$/,r=e.match(t);if(!r)return null;let i=parseInt(r[1],10),s=parseInt(r[2],10),o=parseInt(r[3],10),l=r[4],c=r[5];if(i<0||i>24||s<0||s>59||o<0||o>59||i===24&&(s!==0||o!==0))return null;let u=0;if(l){let d=l.padEnd(3,"0").slice(0,3);u=parseInt(d,10)}let f=i*60*60*1e3+s*60*1e3+o*1e3+u;if(i===24&&(f=1440*60*1e3),c&&c!=="Z"){let d=c.match(/([+-])(\d{2}):(\d{2})/);if(d){let h=d[1]==="+"?1:-1,p=parseInt(d[2],10),g=parseInt(d[3],10),_=h*(p*60+g)*60*1e3;f-=_}}return f}static formatDateDuration(e){if(e===0)return"P0D";let t=e<0,r=Math.abs(e);return t?`-P${r}D`:`P${r}D`}static parseYearMonthDuration(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDuration: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),o=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDuration: invalid format (no duration components): '${e}'`);let l=s*12+o;return i?-l:l}static formatYearMonthDuration(e){let t=e<0,r=Math.abs(e),i=Math.floor(r/12),s=r%12,o=t?"-P":"P";return i>0&&(o+=`${i}Y`),(s>0||i===0)&&(o+=`${s}M`),o}static parseYearMonthDurationComponents(e){let t=/^(-)?P(?:(\d+)Y)?(?:(\d+)M)?$/,r=e.match(t);if(!r)throw new Error(`parseYearMonthDurationComponents: invalid format: '${e}'`);let i=r[1]==="-",s=parseInt(r[2]||"0",10),o=parseInt(r[3]||"0",10);if(!r[2]&&!r[3])throw new Error(`parseYearMonthDurationComponents: invalid format (no duration components): '${e}'`);return{years:s,months:o,negative:i}}static parseDurationComponents(e){if(!e)throw new Error("parseDurationComponents: duration string is empty");let t=!1,r=e.trim();if(r.startsWith("-")&&(t=!0,r=r.substring(1)),!r.startsWith("P"))throw new Error(`parseDurationComponents: invalid format, must start with 'P': '${e}'`);r=r.substring(1);let i=0,s=0,o=0,l=0,c=r.indexOf("T"),u="",f="";if(c===-1?u=r:(u=r.substring(0,c),f=r.substring(c+1)),u){let d=u.match(/^(\d+(?:\.\d+)?)D$/);if(d)i=parseFloat(d[1]);else if(u!=="")throw new Error(`parseDurationComponents: invalid day component: '${u}' in '${e}'`)}if(f){let d=f,h=d.match(/^(\d+(?:\.\d+)?)H/);h&&(s=parseFloat(h[1]),d=d.substring(h[0].length));let p=d.match(/^(\d+(?:\.\d+)?)M/);p&&(o=parseFloat(p[1]),d=d.substring(p[0].length));let g=d.match(/^(\d+(?:\.\d+)?)S$/);if(g&&(l=parseFloat(g[1]),d=d.substring(g[0].length)),d!=="")throw new Error(`parseDurationComponents: invalid time component: '${d}' in '${e}'`)}return{negative:t,days:i,hours:s,minutes:o,seconds:l}}};pp.DateTimeParsing=Fb});var Ex=S(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.DateTimeArithmetic=void 0;var fn=Ae(),Fe=$e(),rt=Ju(),Db=class{static{a(this,"DateTimeArithmetic")}static dateTimeDiff(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r),o=new Date(i);if(isNaN(s.getTime()))throw new Error(`dateTimeDiff: invalid first dateTime: '${r}'`);if(isNaN(o.getTime()))throw new Error(`dateTimeDiff: invalid second dateTime: '${i}'`);let l=s.getTime()-o.getTime(),c=rt.DateTimeParsing.formatDayTimeDuration(l);return new Fe.Literal(c,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static dateTimeAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAdd: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()+o,c=new Date(l);return new Fe.Literal(c.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtract: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()-o,c=new Date(l);return new Fe.Literal(c.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateAdd: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()+o,c=new Date(l),u=c.getUTCFullYear(),f=String(c.getUTCMonth()+1).padStart(2,"0"),d=String(c.getUTCDate()).padStart(2,"0"),h=`${u}-${f}-${d}`;return new Fe.Literal(h,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateSubtract: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseDayTimeDuration(i),l=s.getTime()-o,c=new Date(l),u=c.getUTCFullYear(),f=String(c.getUTCMonth()+1).padStart(2,"0"),d=String(c.getUTCDate()).padStart(2,"0"),h=`${u}-${f}-${d}`;return new Fe.Literal(h,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateTimeAddYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeAddYearMonth: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()+o),s.getUTCDate()!==l&&s.setUTCDate(0),new Fe.Literal(s.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateTimeSubtractYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=new Date(r);if(isNaN(s.getTime()))throw new Error(`dateTimeSubtractYearMonth: invalid dateTime: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();return s.setUTCMonth(s.getUTCMonth()-o),s.getUTCDate()!==l&&s.setUTCDate(0),new Fe.Literal(s.toISOString(),new fn.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static dateAddYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateAddYearMonth: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()+o),s.getUTCDate()!==l&&s.setUTCDate(0);let c=s.getUTCFullYear(),u=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),d=`${c}-${u}-${f}`;return new Fe.Literal(d,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static dateSubtractYearMonth(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseXSDDate(r);if(s===null)throw new Error(`dateSubtractYearMonth: invalid date: '${r}'`);let o=rt.DateTimeParsing.parseYearMonthDuration(i),l=s.getUTCDate();s.setUTCMonth(s.getUTCMonth()-o),s.getUTCDate()!==l&&s.setUTCDate(0);let c=s.getUTCFullYear(),u=String(s.getUTCMonth()+1).padStart(2,"0"),f=String(s.getUTCDate()).padStart(2,"0"),d=`${c}-${u}-${f}`;return new Fe.Literal(d,new fn.IRI("http://www.w3.org/2001/XMLSchema#date"))}static durationAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseDayTimeDuration(r),o=rt.DateTimeParsing.parseDayTimeDuration(i),l=rt.DateTimeParsing.formatDayTimeDuration(s+o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseDayTimeDuration(r),o=rt.DateTimeParsing.parseDayTimeDuration(i),l=rt.DateTimeParsing.formatDayTimeDuration(s-o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationMultiply(e,t){let r=e instanceof Fe.Literal?e.value:e,i=rt.DateTimeParsing.parseDayTimeDuration(r),s=rt.DateTimeParsing.formatDayTimeDuration(i*t);return new Fe.Literal(s,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static durationDivide(e,t){if(t===0)throw new Error("durationDivide: division by zero");let r=e instanceof Fe.Literal?e.value:e,i=rt.DateTimeParsing.parseDayTimeDuration(r),s=rt.DateTimeParsing.formatDayTimeDuration(i/t);return new Fe.Literal(s,new fn.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static yearMonthDurationAdd(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseYearMonthDuration(r),o=rt.DateTimeParsing.parseYearMonthDuration(i),l=rt.DateTimeParsing.formatYearMonthDuration(s+o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static yearMonthDurationSubtract(e,t){let r=e instanceof Fe.Literal?e.value:e,i=t instanceof Fe.Literal?t.value:t,s=rt.DateTimeParsing.parseYearMonthDuration(r),o=rt.DateTimeParsing.parseYearMonthDuration(i),l=rt.DateTimeParsing.formatYearMonthDuration(s-o);return new Fe.Literal(l,new fn.IRI("http://www.w3.org/2001/XMLSchema#yearMonthDuration"))}static durationToDays(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/(1440*60*1e3)}static durationToHours(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/(3600*1e3)}static durationToMinutes(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/(60*1e3)}static durationToSeconds(e){let t=e instanceof Fe.Literal?e.value:e;return rt.DateTimeParsing.parseDayTimeDuration(t)/1e3}};mp.DateTimeArithmetic=Db});var Tx=S(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});gp.DateTimeAccessors=void 0;var Zu=Ae(),Ut=$e(),At=Ju(),Lb=class{static{a(this,"DateTimeAccessors")}static year(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`YEAR: invalid date string '${e}'`);return t.getFullYear()}static month(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MONTH: invalid date string '${e}'`);return t.getMonth()+1}static day(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`DAY: invalid date string '${e}'`);return t.getDate()}static hours(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`HOURS: invalid date string '${e}'`);return t.getHours()}static minutes(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`MINUTES: invalid date string '${e}'`);return t.getMinutes()}static seconds(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`SECONDS: invalid date string '${e}'`);return t.getSeconds()+t.getMilliseconds()/1e3}static durationDays(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t),i=Math.floor(r.days);return r.negative?-i:i}static durationHours(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t),i=Math.floor(r.hours);return r.negative?-i:i}static durationMinutes(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t),i=Math.floor(r.minutes);return r.negative?-i:i}static durationSeconds(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseDurationComponents(t);return r.negative?-r.seconds:r.seconds}static durationYears(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseYearMonthDurationComponents(t);return r.negative?-r.years:r.years}static durationMonths(e){let t=e instanceof Ut.Literal?e.value:e,r=At.DateTimeParsing.parseYearMonthDurationComponents(t);return r.negative?-r.months:r.months}static timezone(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TIMEZONE: invalid date string '${e}'`);let r;if(e.endsWith("Z"))r="PT0S";else{let i=e.match(/([+-]\d{2}):?(\d{2})$/);if(i){let s=parseInt(i[1],10),o=parseInt(i[2],10),l=s>=0?"":"-",c=Math.abs(s);o===0?r=`${l}PT${c}H`:r=`${l}PT${c}H${o}M`}else{let s=-t.getTimezoneOffset(),o=Math.floor(Math.abs(s)/60),l=Math.abs(s)%60,c=s>=0?"":"-";l===0?r=`${c}PT${o}H`:r=`${c}PT${o}H${l}M`}}return new Ut.Literal(r,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static tz(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`TZ: invalid date string '${e}'`);if(e.endsWith("Z"))return"Z";let r=e.match(/([+-]\d{2}:\d{2})$/);if(r)return r[1];let i=e.match(/([+-])(\d{2})(\d{2})$/);return i?`${i[1]}${i[2]}:${i[3]}`:""}static adjust(e,t){let r=e instanceof Ut.Literal?e.value:e,i=new Date(r);if(isNaN(i.getTime()))throw new Error(`ADJUST: invalid dateTime: '${r}'`);if(t==null){let H=i.getUTCFullYear(),ne=String(i.getUTCMonth()+1).padStart(2,"0"),de=String(i.getUTCDate()).padStart(2,"0"),N=String(i.getUTCHours()).padStart(2,"0"),Y=String(i.getUTCMinutes()).padStart(2,"0"),se=String(i.getUTCSeconds()).padStart(2,"0"),V=i.getUTCMilliseconds(),X=`${H}-${ne}-${de}T${N}:${Y}:${se}`;return V>0&&(X+=`.${String(V).padStart(3,"0")}`),new Ut.Literal(X,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}let s=t instanceof Ut.Literal?t.value:t,o=At.DateTimeParsing.parseDayTimeDuration(s),l=840*60*1e3;if(Math.abs(o)>l)throw new Error(`ADJUST: timezone offset out of range: '${s}'`);let c=i.getTime(),u=new Date(c+o),f=u.getUTCFullYear(),d=String(u.getUTCMonth()+1).padStart(2,"0"),h=String(u.getUTCDate()).padStart(2,"0"),p=String(u.getUTCHours()).padStart(2,"0"),g=String(u.getUTCMinutes()).padStart(2,"0"),_=String(u.getUTCSeconds()).padStart(2,"0"),v=u.getUTCMilliseconds(),w=o>=0?"+":"-",E=Math.floor(Math.abs(o)/(3600*1e3)),I=Math.floor(Math.abs(o)%(3600*1e3)/(60*1e3)),O=`${w}${String(E).padStart(2,"0")}:${String(I).padStart(2,"0")}`,C=`${f}-${d}-${h}T${p}:${g}:${_}`;return v>0&&(C+=`.${String(v).padStart(3,"0")}`),C+=O,new Ut.Literal(C,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static now(){return new Date().toISOString()}static dateBefore(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t);return r<i}static dateAfter(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t);return r>i}static dateInRange(e,t,r){let i=At.DateTimeParsing.parseDate(e),s=At.DateTimeParsing.parseDate(t),o=At.DateTimeParsing.parseDate(r);return i>=s&&i<=o}static compareDurations(e,t,r){let i=e instanceof Ut.Literal?e.value:e,s=t instanceof Ut.Literal?t.value:t,o=At.DateTimeParsing.parseDayTimeDuration(i),l=At.DateTimeParsing.parseDayTimeDuration(s);switch(r){case"=":return o===l;case"!=":return o!==l;case"<":return o<l;case">":return o>l;case"<=":return o<=l;case">=":return o>=l;default:throw new Error(`compareDurations: unknown operator: ${r}`)}}static dateDiffMinutes(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60))}static dateDiffHours(e,t){let r=At.DateTimeParsing.parseDate(e),i=At.DateTimeParsing.parseDate(t),s=Math.abs(i-r);return Math.round(s/(1e3*60*60)*100)/100}static timeDiff(e,t){let r=e instanceof Ut.Literal?e.value:e,i=t instanceof Ut.Literal?t.value:t,s=At.DateTimeParsing.parseXSDTime(r),o=At.DateTimeParsing.parseXSDTime(i);if(s===null)throw new Error(`timeDiff: invalid first time: '${r}'`);if(o===null)throw new Error(`timeDiff: invalid second time: '${i}'`);let l=s-o,c=At.DateTimeParsing.formatDayTimeDuration(l);return new Ut.Literal(c,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}static isDayTimeDuration(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static isDate(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}static isYearMonthDuration(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}static isTime(e){return e instanceof Ut.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}static dateDiff(e,t){let r=e instanceof Ut.Literal?e.value:e,i=t instanceof Ut.Literal?t.value:t,s=At.DateTimeParsing.parseXSDDate(r),o=At.DateTimeParsing.parseXSDDate(i);if(s===null)throw new Error(`dateDiff: invalid first date: '${r}'`);if(o===null)throw new Error(`dateDiff: invalid second date: '${i}'`);let l=s.getTime()-o.getTime(),c=Math.round(l/(1440*60*1e3)),u=At.DateTimeParsing.formatDateDuration(c);return new Ut.Literal(u,new Zu.IRI("http://www.w3.org/2001/XMLSchema#dayTimeDuration"))}};gp.DateTimeAccessors=Lb});var _p=S(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});yp.DateTimeFunctions=void 0;var zl=Ju(),ur=Ex(),_t=Tx(),Nb=class{static{a(this,"DateTimeFunctions")}static parseDate(e){return zl.DateTimeParsing.parseDate(e)}static parseDayTimeDuration(e){return zl.DateTimeParsing.parseDayTimeDuration(e)}static formatDayTimeDuration(e){return zl.DateTimeParsing.formatDayTimeDuration(e)}static xsdDayTimeDuration(e){return zl.DateTimeParsing.xsdDayTimeDuration(e)}static parseYearMonthDuration(e){return zl.DateTimeParsing.parseYearMonthDuration(e)}static formatYearMonthDuration(e){return zl.DateTimeParsing.formatYearMonthDuration(e)}static year(e){return _t.DateTimeAccessors.year(e)}static month(e){return _t.DateTimeAccessors.month(e)}static day(e){return _t.DateTimeAccessors.day(e)}static hours(e){return _t.DateTimeAccessors.hours(e)}static minutes(e){return _t.DateTimeAccessors.minutes(e)}static seconds(e){return _t.DateTimeAccessors.seconds(e)}static durationDays(e){return _t.DateTimeAccessors.durationDays(e)}static durationHours(e){return _t.DateTimeAccessors.durationHours(e)}static durationMinutes(e){return _t.DateTimeAccessors.durationMinutes(e)}static durationSeconds(e){return _t.DateTimeAccessors.durationSeconds(e)}static durationYears(e){return _t.DateTimeAccessors.durationYears(e)}static durationMonths(e){return _t.DateTimeAccessors.durationMonths(e)}static timezone(e){return _t.DateTimeAccessors.timezone(e)}static tz(e){return _t.DateTimeAccessors.tz(e)}static adjust(e,t){return _t.DateTimeAccessors.adjust(e,t)}static now(){return _t.DateTimeAccessors.now()}static dateBefore(e,t){return _t.DateTimeAccessors.dateBefore(e,t)}static dateAfter(e,t){return _t.DateTimeAccessors.dateAfter(e,t)}static dateInRange(e,t,r){return _t.DateTimeAccessors.dateInRange(e,t,r)}static compareDurations(e,t,r){return _t.DateTimeAccessors.compareDurations(e,t,r)}static dateDiffMinutes(e,t){return _t.DateTimeAccessors.dateDiffMinutes(e,t)}static dateDiffHours(e,t){return _t.DateTimeAccessors.dateDiffHours(e,t)}static timeDiff(e,t){return _t.DateTimeAccessors.timeDiff(e,t)}static dateDiff(e,t){return _t.DateTimeAccessors.dateDiff(e,t)}static isDayTimeDuration(e){return _t.DateTimeAccessors.isDayTimeDuration(e)}static isDate(e){return _t.DateTimeAccessors.isDate(e)}static isYearMonthDuration(e){return _t.DateTimeAccessors.isYearMonthDuration(e)}static isTime(e){return _t.DateTimeAccessors.isTime(e)}static dateTimeDiff(e,t){return ur.DateTimeArithmetic.dateTimeDiff(e,t)}static dateTimeAdd(e,t){return ur.DateTimeArithmetic.dateTimeAdd(e,t)}static dateTimeSubtract(e,t){return ur.DateTimeArithmetic.dateTimeSubtract(e,t)}static dateAdd(e,t){return ur.DateTimeArithmetic.dateAdd(e,t)}static dateSubtract(e,t){return ur.DateTimeArithmetic.dateSubtract(e,t)}static dateTimeAddYearMonth(e,t){return ur.DateTimeArithmetic.dateTimeAddYearMonth(e,t)}static dateTimeSubtractYearMonth(e,t){return ur.DateTimeArithmetic.dateTimeSubtractYearMonth(e,t)}static dateAddYearMonth(e,t){return ur.DateTimeArithmetic.dateAddYearMonth(e,t)}static dateSubtractYearMonth(e,t){return ur.DateTimeArithmetic.dateSubtractYearMonth(e,t)}static durationAdd(e,t){return ur.DateTimeArithmetic.durationAdd(e,t)}static durationSubtract(e,t){return ur.DateTimeArithmetic.durationSubtract(e,t)}static durationMultiply(e,t){return ur.DateTimeArithmetic.durationMultiply(e,t)}static durationDivide(e,t){return ur.DateTimeArithmetic.durationDivide(e,t)}static yearMonthDurationAdd(e,t){return ur.DateTimeArithmetic.yearMonthDurationAdd(e,t)}static yearMonthDurationSubtract(e,t){return ur.DateTimeArithmetic.yearMonthDurationSubtract(e,t)}static durationToDays(e){return ur.DateTimeArithmetic.durationToDays(e)}static durationToHours(e){return ur.DateTimeArithmetic.durationToHours(e)}static durationToMinutes(e){return ur.DateTimeArithmetic.durationToMinutes(e)}static durationToSeconds(e){return ur.DateTimeArithmetic.durationToSeconds(e)}};yp.DateTimeFunctions=Nb});var Ix=S(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});Sp.LogicalFunctions=void 0;var K9=Ae(),Hl=$e(),J9=$t(),bp=_p(),kb=class n{static{a(this,"LogicalFunctions")}static compare(e,t,r){if(n.isDayTimeDurationValue(e)&&n.isDayTimeDurationValue(t))return bp.DateTimeFunctions.compareDurations(e instanceof Hl.Literal?e:String(e),t instanceof Hl.Literal?t:String(t),r);if(n.isDayTimeDurationValue(e)&&typeof t=="string"&&/^-?P/.test(t))return bp.DateTimeFunctions.compareDurations(e instanceof Hl.Literal?e:String(e),t,r);if(typeof e=="string"&&/^-?P/.test(e)&&n.isDayTimeDurationValue(t))return bp.DateTimeFunctions.compareDurations(e,t instanceof Hl.Literal?t:String(t),r);let i=n.toComparableValue(e),s=n.toComparableValue(t);switch(r){case"=":return i===s;case"!=":return i!==s;case"<":return i<s;case">":return i>s;case"<=":return i<=s;case">=":return i>=s;default:throw new Error(`Unknown comparison operator: ${r}`)}}static isDayTimeDurationValue(e){return e instanceof Hl.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}static toComparableValue(e){if(typeof e=="string"||typeof e=="number")return e;if(e instanceof Hl.Literal){let t=e.datatype?.value;if(t?.includes("#integer")||t?.includes("#decimal")||t?.includes("#double")){let r=parseFloat(e.value);if(!isNaN(r))return r}if(t==="http://www.w3.org/2001/XMLSchema#dayTimeDuration")try{return bp.DateTimeFunctions.parseDayTimeDuration(e.value)}catch{return e.value}return e.value}return e instanceof K9.IRI?e.value:e instanceof J9.BlankNode?e.id:String(e)}static logicalAnd(e){return e.every(t=>t===!0)}static logicalOr(e){return e.some(t=>t===!0)}static logicalNot(e){return!e}static coalesce(e){for(let t of e)if(t!=null)return t}static if(e,t,r){return e?t:r}};Sp.LogicalFunctions=kb});var xx=S(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});wp.RDFTermFunctions=void 0;var Mr=Ae(),Et=$e(),_i=$t(),Ql=Ou(),Mb=mi(),jb=class n{static{a(this,"RDFTermFunctions")}static datatype(e){if(e===void 0)throw new Error("DATATYPE: argument is undefined");if(e instanceof Et.Literal)return e.datatype?e.datatype:e.language?new Mr.IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"):new Mr.IRI("http://www.w3.org/2001/XMLSchema#string");throw new Error("DATATYPE: argument must be a literal")}static bound(e){return e!==void 0}static isIRI(e){return e===void 0?!1:e instanceof Mr.IRI}static isBlank(e){return e===void 0?!1:e instanceof _i.BlankNode}static isLiteral(e){return e===void 0?!1:e instanceof Et.Literal}static isTriple(e){return e===void 0?!1:e instanceof Ql.QuotedTriple}static hasLangdir(e){return e===void 0||!(e instanceof Et.Literal)?!1:!!e.language&&!!e.direction}static isNumeric(e){if(e===void 0||!(e instanceof Et.Literal))return!1;let t=e.datatype?.value;return t?["http://www.w3.org/2001/XMLSchema#integer","http://www.w3.org/2001/XMLSchema#decimal","http://www.w3.org/2001/XMLSchema#float","http://www.w3.org/2001/XMLSchema#double","http://www.w3.org/2001/XMLSchema#nonPositiveInteger","http://www.w3.org/2001/XMLSchema#negativeInteger","http://www.w3.org/2001/XMLSchema#long","http://www.w3.org/2001/XMLSchema#int","http://www.w3.org/2001/XMLSchema#short","http://www.w3.org/2001/XMLSchema#byte","http://www.w3.org/2001/XMLSchema#nonNegativeInteger","http://www.w3.org/2001/XMLSchema#unsignedLong","http://www.w3.org/2001/XMLSchema#unsignedInt","http://www.w3.org/2001/XMLSchema#unsignedShort","http://www.w3.org/2001/XMLSchema#unsignedByte","http://www.w3.org/2001/XMLSchema#positiveInteger"].includes(t):!1}static xsdDateTime(e){let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`xsd:dateTime: invalid date string '${e}'`);return new Et.Literal(t.toISOString(),new Mr.IRI("http://www.w3.org/2001/XMLSchema#dateTime"))}static xsdInteger(e){let t=parseInt(e,10);if(isNaN(t))throw new Error(`xsd:integer: cannot convert '${e}' to integer`);return new Et.Literal(String(t),new Mr.IRI("http://www.w3.org/2001/XMLSchema#integer"))}static xsdDecimal(e){let t=parseFloat(e);if(isNaN(t))throw new Error(`xsd:decimal: cannot convert '${e}' to decimal`);return new Et.Literal(String(t),new Mr.IRI("http://www.w3.org/2001/XMLSchema#decimal"))}static sameTerm(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0||e.constructor!==t.constructor)return!1;if(e instanceof Mr.IRI&&t instanceof Mr.IRI)return e.value===t.value;if(e instanceof _i.BlankNode&&t instanceof _i.BlankNode)return e.id===t.id;if(e instanceof Et.Literal&&t instanceof Et.Literal){if(e.value!==t.value||e.language!==t.language)return!1;let r=e.datatype?.value,i=t.datatype?.value;return r===i}return!1}static iri(e){if(e===void 0)throw new Error("IRI: argument is undefined");if(e instanceof Mr.IRI)return e;if(e instanceof Et.Literal)return new Mr.IRI(e.value);throw e instanceof _i.BlankNode?new Error("IRI: cannot convert blank node to IRI"):new Error("IRI: unsupported term type")}static uri(e){return n.iri(e)}static bnode(e){if(e===void 0){let t=`b${(0,Mb.v4)().replace(/-/g,"").substring(0,12)}`;return new _i.BlankNode(t)}if(e instanceof Et.Literal)return new _i.BlankNode(e.value);if(e instanceof _i.BlankNode)return e;throw new Error("BNODE: argument must be a string literal or omitted")}static strdt(e,t){if(e===void 0)throw new Error("STRDT: lexical form is undefined");if(t===void 0)throw new Error("STRDT: datatype IRI is undefined");let r;if(e instanceof Et.Literal){if(e.language)throw new Error("STRDT: lexical form must not have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRDT: lexical form must be a string literal");let i;if(t instanceof Mr.IRI)i=t;else if(t instanceof Et.Literal)i=new Mr.IRI(t.value);else throw new Error("STRDT: datatype must be an IRI");return new Et.Literal(r,i)}static strlang(e,t){if(e===void 0)throw new Error("STRLANG: lexical form is undefined");if(t===void 0)throw new Error("STRLANG: language tag is undefined");let r;if(e instanceof Et.Literal){if(e.language)throw new Error("STRLANG: lexical form must not already have a language tag");r=e.value}else if(typeof e=="string")r=e;else throw new Error("STRLANG: lexical form must be a string literal");let i;if(t instanceof Et.Literal)i=t.value;else if(typeof t=="string")i=t;else throw new Error("STRLANG: language tag must be a string literal");if(i==="")throw new Error("STRLANG: language tag cannot be empty");return new Et.Literal(r,void 0,i)}static strlangdir(e,t,r){if(e===void 0)throw new Error("STRLANGDIR: lexical form is undefined");if(t===void 0)throw new Error("STRLANGDIR: language tag is undefined");if(r===void 0)throw new Error("STRLANGDIR: direction is undefined");let i;if(e instanceof Et.Literal){if(e.language)throw new Error("STRLANGDIR: lexical form must not already have a language tag");i=e.value}else if(typeof e=="string")i=e;else throw new Error("STRLANGDIR: lexical form must be a string literal");let s;if(t instanceof Et.Literal)s=t.value;else if(typeof t=="string")s=t;else throw new Error("STRLANGDIR: language tag must be a string literal");if(s==="")throw new Error("STRLANGDIR: language tag cannot be empty");let o;if(r instanceof Et.Literal)o=r.value.toLowerCase();else throw new Error("STRLANGDIR: direction must be a string literal");if(o!=="ltr"&&o!=="rtl")throw new Error(`STRLANGDIR: invalid direction '${o}'. Must be 'ltr' or 'rtl'`);return new Et.Literal(i,void 0,s,o)}static uuid(){let e=(0,Mb.v4)();return new Mr.IRI(`urn:uuid:${e}`)}static struuid(){let e=(0,Mb.v4)();return new Et.Literal(e)}static triple(e,t,r){if(e===void 0)throw new Error("TRIPLE: subject is undefined");if(t===void 0)throw new Error("TRIPLE: predicate is undefined");if(r===void 0)throw new Error("TRIPLE: object is undefined");if(e instanceof Et.Literal)throw new Error("TRIPLE: subject must be IRI, BlankNode, or QuotedTriple, got Literal");if(!(t instanceof Mr.IRI)){let l=t instanceof Et.Literal?"Literal":t instanceof _i.BlankNode?"BlankNode":t instanceof Ql.QuotedTriple?"QuotedTriple":typeof t;throw new Error(`TRIPLE: predicate must be IRI, got ${l}`)}let i=e,s=t,o=r;return new Ql.QuotedTriple(i,s,o)}static subject(e){if(e===void 0)throw new Error("SUBJECT: argument is undefined");if(!(e instanceof Ql.QuotedTriple)){let t=e instanceof Mr.IRI?"IRI":e instanceof Et.Literal?"Literal":e instanceof _i.BlankNode?"BlankNode":typeof e;throw new Error(`SUBJECT: argument must be QuotedTriple, got ${t}`)}return e.subject}static predicate(e){if(e===void 0)throw new Error("PREDICATE: argument is undefined");if(!(e instanceof Ql.QuotedTriple)){let t=e instanceof Mr.IRI?"IRI":e instanceof Et.Literal?"Literal":e instanceof _i.BlankNode?"BlankNode":typeof e;throw new Error(`PREDICATE: argument must be QuotedTriple, got ${t}`)}return e.predicate}static object(e){if(e===void 0)throw new Error("OBJECT: argument is undefined");if(!(e instanceof Ql.QuotedTriple)){let t=e instanceof Mr.IRI?"IRI":e instanceof Et.Literal?"Literal":e instanceof _i.BlankNode?"BlankNode":typeof e;throw new Error(`OBJECT: argument must be QuotedTriple, got ${t}`)}return e.object}};wp.RDFTermFunctions=jb});var Ax=S(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});vp.HashFunctions=void 0;var $b=class{static{a(this,"HashFunctions")}static md5(e){return require("crypto").createHash("md5").update(e).digest("hex")}static sha1(e){return require("crypto").createHash("sha1").update(e).digest("hex")}static sha256(e){return require("crypto").createHash("sha256").update(e).digest("hex")}static sha384(e){return require("crypto").createHash("sha384").update(e).digest("hex")}static sha512(e){return require("crypto").createHash("sha512").update(e).digest("hex")}};vp.HashFunctions=$b});var Tp=S(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});Ep.BuiltInFunctions=void 0;var fr=wx(),Mo=vx(),he=_p(),Yl=Ix(),Ot=xx(),ef=Ax(),Ub=class{static{a(this,"BuiltInFunctions")}static str(...e){return fr.StringFunctions.str(...e)}static lang(...e){return fr.StringFunctions.lang(...e)}static langdir(...e){return fr.StringFunctions.langdir(...e)}static langMatches(...e){return fr.StringFunctions.langMatches(...e)}static regex(...e){return fr.StringFunctions.regex(...e)}static contains(...e){return fr.StringFunctions.contains(...e)}static strStarts(...e){return fr.StringFunctions.strStarts(...e)}static strEnds(...e){return fr.StringFunctions.strEnds(...e)}static strlen(...e){return fr.StringFunctions.strlen(...e)}static ucase(...e){return fr.StringFunctions.ucase(...e)}static lcase(...e){return fr.StringFunctions.lcase(...e)}static substr(...e){return fr.StringFunctions.substr(...e)}static strBefore(...e){return fr.StringFunctions.strBefore(...e)}static strAfter(...e){return fr.StringFunctions.strAfter(...e)}static concat(...e){return fr.StringFunctions.concat(...e)}static replace(...e){return fr.StringFunctions.replace(...e)}static encodeForUri(...e){return fr.StringFunctions.encodeForUri(...e)}static normalize(...e){return fr.StringFunctions.normalize(...e)}static fold(...e){return fr.StringFunctions.fold(...e)}static abs(...e){return Mo.MathFunctions.abs(...e)}static round(...e){return Mo.MathFunctions.round(...e)}static ceil(...e){return Mo.MathFunctions.ceil(...e)}static floor(...e){return Mo.MathFunctions.floor(...e)}static rand(){return Mo.MathFunctions.rand()}static msToMinutes(...e){return Mo.MathFunctions.msToMinutes(...e)}static msToHours(...e){return Mo.MathFunctions.msToHours(...e)}static msToSeconds(...e){return Mo.MathFunctions.msToSeconds(...e)}static parseDate(...e){return he.DateTimeFunctions.parseDate(...e)}static dateBefore(...e){return he.DateTimeFunctions.dateBefore(...e)}static dateAfter(...e){return he.DateTimeFunctions.dateAfter(...e)}static dateInRange(...e){return he.DateTimeFunctions.dateInRange(...e)}static dateDiffMinutes(...e){return he.DateTimeFunctions.dateDiffMinutes(...e)}static dateDiffHours(...e){return he.DateTimeFunctions.dateDiffHours(...e)}static year(...e){return he.DateTimeFunctions.year(...e)}static month(...e){return he.DateTimeFunctions.month(...e)}static day(...e){return he.DateTimeFunctions.day(...e)}static hours(...e){return he.DateTimeFunctions.hours(...e)}static minutes(...e){return he.DateTimeFunctions.minutes(...e)}static seconds(...e){return he.DateTimeFunctions.seconds(...e)}static timezone(...e){return he.DateTimeFunctions.timezone(...e)}static tz(...e){return he.DateTimeFunctions.tz(...e)}static now(){return he.DateTimeFunctions.now()}static parseDayTimeDuration(...e){return he.DateTimeFunctions.parseDayTimeDuration(...e)}static formatDayTimeDuration(...e){return he.DateTimeFunctions.formatDayTimeDuration(...e)}static xsdDayTimeDuration(...e){return he.DateTimeFunctions.xsdDayTimeDuration(...e)}static compareDurations(...e){return he.DateTimeFunctions.compareDurations(...e)}static isDayTimeDuration(...e){return he.DateTimeFunctions.isDayTimeDuration(...e)}static isDate(...e){return he.DateTimeFunctions.isDate(...e)}static dateDiff(...e){return he.DateTimeFunctions.dateDiff(...e)}static dateTimeDiff(...e){return he.DateTimeFunctions.dateTimeDiff(...e)}static dateTimeAdd(...e){return he.DateTimeFunctions.dateTimeAdd(...e)}static dateTimeSubtract(...e){return he.DateTimeFunctions.dateTimeSubtract(...e)}static dateAdd(...e){return he.DateTimeFunctions.dateAdd(...e)}static dateSubtract(...e){return he.DateTimeFunctions.dateSubtract(...e)}static parseYearMonthDuration(...e){return he.DateTimeFunctions.parseYearMonthDuration(...e)}static isYearMonthDuration(...e){return he.DateTimeFunctions.isYearMonthDuration(...e)}static dateTimeAddYearMonth(...e){return he.DateTimeFunctions.dateTimeAddYearMonth(...e)}static dateTimeSubtractYearMonth(...e){return he.DateTimeFunctions.dateTimeSubtractYearMonth(...e)}static dateAddYearMonth(...e){return he.DateTimeFunctions.dateAddYearMonth(...e)}static dateSubtractYearMonth(...e){return he.DateTimeFunctions.dateSubtractYearMonth(...e)}static durationAdd(...e){return he.DateTimeFunctions.durationAdd(...e)}static durationSubtract(...e){return he.DateTimeFunctions.durationSubtract(...e)}static durationMultiply(...e){return he.DateTimeFunctions.durationMultiply(...e)}static durationDivide(...e){return he.DateTimeFunctions.durationDivide(...e)}static formatYearMonthDuration(...e){return he.DateTimeFunctions.formatYearMonthDuration(...e)}static yearMonthDurationAdd(...e){return he.DateTimeFunctions.yearMonthDurationAdd(...e)}static yearMonthDurationSubtract(...e){return he.DateTimeFunctions.yearMonthDurationSubtract(...e)}static durationYears(...e){return he.DateTimeFunctions.durationYears(...e)}static durationMonths(...e){return he.DateTimeFunctions.durationMonths(...e)}static durationToDays(...e){return he.DateTimeFunctions.durationToDays(...e)}static durationToHours(...e){return he.DateTimeFunctions.durationToHours(...e)}static durationToMinutes(...e){return he.DateTimeFunctions.durationToMinutes(...e)}static durationToSeconds(...e){return he.DateTimeFunctions.durationToSeconds(...e)}static durationDays(...e){return he.DateTimeFunctions.durationDays(...e)}static durationHours(...e){return he.DateTimeFunctions.durationHours(...e)}static durationMinutes(...e){return he.DateTimeFunctions.durationMinutes(...e)}static durationSeconds(...e){return he.DateTimeFunctions.durationSeconds(...e)}static adjust(...e){return he.DateTimeFunctions.adjust(...e)}static isTime(...e){return he.DateTimeFunctions.isTime(...e)}static timeDiff(...e){return he.DateTimeFunctions.timeDiff(...e)}static compare(...e){return Yl.LogicalFunctions.compare(...e)}static logicalAnd(...e){return Yl.LogicalFunctions.logicalAnd(...e)}static logicalOr(...e){return Yl.LogicalFunctions.logicalOr(...e)}static logicalNot(...e){return Yl.LogicalFunctions.logicalNot(...e)}static coalesce(...e){return Yl.LogicalFunctions.coalesce(...e)}static if(...e){return Yl.LogicalFunctions.if(...e)}static datatype(...e){return Ot.RDFTermFunctions.datatype(...e)}static bound(...e){return Ot.RDFTermFunctions.bound(...e)}static isIRI(...e){return Ot.RDFTermFunctions.isIRI(...e)}static isBlank(...e){return Ot.RDFTermFunctions.isBlank(...e)}static isLiteral(...e){return Ot.RDFTermFunctions.isLiteral(...e)}static isTriple(...e){return Ot.RDFTermFunctions.isTriple(...e)}static isNumeric(...e){return Ot.RDFTermFunctions.isNumeric(...e)}static hasLangdir(...e){return Ot.RDFTermFunctions.hasLangdir(...e)}static sameTerm(...e){return Ot.RDFTermFunctions.sameTerm(...e)}static iri(...e){return Ot.RDFTermFunctions.iri(...e)}static uri(...e){return Ot.RDFTermFunctions.uri(...e)}static bnode(...e){return Ot.RDFTermFunctions.bnode(...e)}static strdt(...e){return Ot.RDFTermFunctions.strdt(...e)}static strlang(...e){return Ot.RDFTermFunctions.strlang(...e)}static strlangdir(...e){return Ot.RDFTermFunctions.strlangdir(...e)}static uuid(){return Ot.RDFTermFunctions.uuid()}static struuid(){return Ot.RDFTermFunctions.struuid()}static xsdDateTime(...e){return Ot.RDFTermFunctions.xsdDateTime(...e)}static xsdInteger(...e){return Ot.RDFTermFunctions.xsdInteger(...e)}static xsdDecimal(...e){return Ot.RDFTermFunctions.xsdDecimal(...e)}static triple(...e){return Ot.RDFTermFunctions.triple(...e)}static subject(...e){return Ot.RDFTermFunctions.subject(...e)}static predicate(...e){return Ot.RDFTermFunctions.predicate(...e)}static object(...e){return Ot.RDFTermFunctions.object(...e)}static md5(...e){return ef.HashFunctions.md5(...e)}static sha1(...e){return ef.HashFunctions.sha1(...e)}static sha256(...e){return ef.HashFunctions.sha256(...e)}static sha384(...e){return ef.HashFunctions.sha384(...e)}static sha512(...e){return ef.HashFunctions.sha512(...e)}};Ep.BuiltInFunctions=Ub});var tf=S(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});os.ExoQLBudgetExceededError=os.ExoQLCycleError=os.ExoQLEvalDisabledError=os.ExoQLForbiddenKeywordError=void 0;var Vb=class extends Error{static{a(this,"ExoQLForbiddenKeywordError")}constructor(e,t){super(t??`ExoQLForbiddenKeywordError: keyword "${e}" is not permitted by the exoql__Query AST allowlist`),this.name="ExoQLForbiddenKeywordError",this.keyword=e}};os.ExoQLForbiddenKeywordError=Vb;var Bb=class extends Error{static{a(this,"ExoQLEvalDisabledError")}constructor(e){super(e??"ExoQLEvalDisabledError: exoql.eval.enabled is false (default). Flip the feature flag to opt in."),this.name="ExoQLEvalDisabledError"}};os.ExoQLEvalDisabledError=Bb;var Gb=class extends Error{static{a(this,"ExoQLCycleError")}constructor(e,t){super(t??`ExoQLCycleError: cycle detected in nested exo:eval invocations: ${e.join(" \u2192 ")}`),this.name="ExoQLCycleError",this.path=e}};os.ExoQLCycleError=Gb;var qb=class extends Error{static{a(this,"ExoQLBudgetExceededError")}constructor(e,t,r,i){super(i??`ExoQLBudgetExceededError: ${e} budget exceeded (limit=${t}, observed=${r})`),this.name="ExoQLBudgetExceededError",this.budget=e,this.limit=t,this.observed=r}};os.ExoQLBudgetExceededError=qb});var kx=S(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.functionHandlers=void 0;var M=Tp();j.functionHandlers=new Map;j.functionHandlers.set("str",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.str(t)});j.functionHandlers.set("lang",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.lang(t)});j.functionHandlers.set("langmatches",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.langMatches(t,r)});j.functionHandlers.set("contains",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.contains(t,r)});j.functionHandlers.set("strstarts",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strStarts(t,r)});j.functionHandlers.set("strends",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strEnds(t,r)});j.functionHandlers.set("strlen",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.strlen(t)});j.functionHandlers.set("ucase",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.ucase(t)});j.functionHandlers.set("lcase",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.lcase(t)});j.functionHandlers.set("substr",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=Number(e.evaluateExpression(n[1],e.solution));if(n[2]){let i=Number(e.evaluateExpression(n[2],e.solution));return M.BuiltInFunctions.substr(t,r,i)}return M.BuiltInFunctions.substr(t,r)});j.functionHandlers.set("strbefore",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strBefore(t,r)});j.functionHandlers.set("strafter",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.strAfter(t,r)});j.functionHandlers.set("concat",(n,e)=>{let t=n.map(r=>e.getStringValue(e.evaluateExpression(r,e.solution)));return M.BuiltInFunctions.concat(...t)});j.functionHandlers.set("replace",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=e.getStringValue(e.evaluateExpression(n[2],e.solution)),s=n[3]?e.getStringValue(e.evaluateExpression(n[3],e.solution)):void 0;return M.BuiltInFunctions.replace(t,r,i,s)});j.functionHandlers.set("regex",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=n[2]?e.getStringValue(e.evaluateExpression(n[2],e.solution)):void 0;return M.BuiltInFunctions.regex(t,r,i)});j.functionHandlers.set("encode_for_uri",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.encodeForUri(t)});j.functionHandlers.set("datatype",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.datatype(t).value});j.functionHandlers.set("bound",(n,e)=>{let t=n[0];if(t.type==="variable"&&t.name){let r=e.solution.get(t.name);return M.BuiltInFunctions.bound(r)}return!0});var Rx=a((n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isIRI(t)},"isIriHandler");j.functionHandlers.set("isiri",Rx);j.functionHandlers.set("isuri",Rx);j.functionHandlers.set("isblank",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isBlank(t)});j.functionHandlers.set("isliteral",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isLiteral(t)});j.functionHandlers.set("isnumeric",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isNumeric(t)});j.functionHandlers.set("haslangdir",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.hasLangdir(t)});j.functionHandlers.set("istriple",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.isTriple(t)});j.functionHandlers.set("sameterm",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution),r=e.getTermFromExpression(n[1],e.solution);return M.BuiltInFunctions.sameTerm(t,r)});j.functionHandlers.set("abs",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.abs(t)});j.functionHandlers.set("round",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.round(t)});j.functionHandlers.set("ceil",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.ceil(t)});j.functionHandlers.set("floor",(n,e)=>{let t=Number(e.getStringValue(e.evaluateExpression(n[0],e.solution)));return M.BuiltInFunctions.floor(t)});j.functionHandlers.set("rand",()=>M.BuiltInFunctions.rand());j.functionHandlers.set("parsedate",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.parseDate(t)});j.functionHandlers.set("datebefore",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateBefore(t,r)});j.functionHandlers.set("dateafter",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateAfter(t,r)});j.functionHandlers.set("dateinrange",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=e.getStringValue(e.evaluateExpression(n[2],e.solution));return M.BuiltInFunctions.dateInRange(t,r,i)});j.functionHandlers.set("datediffminutes",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateDiffMinutes(t,r)});j.functionHandlers.set("datediffhours",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution));return M.BuiltInFunctions.dateDiffHours(t,r)});var Xl=a((n,e,t)=>(r,i)=>{let s=i.evaluateExpression(r[0],i.solution);return e&&i.isYearMonthDurationValue(s)?e(s):t&&i.isDayTimeDurationValue(s)?t(s):n(i.getStringValue(s))},"createDateTimeAccessor"),Cx=Xl(M.BuiltInFunctions.year.bind(M.BuiltInFunctions),M.BuiltInFunctions.durationYears.bind(M.BuiltInFunctions),null);j.functionHandlers.set("year",Cx);j.functionHandlers.set("years",Cx);var Px=Xl(M.BuiltInFunctions.month.bind(M.BuiltInFunctions),M.BuiltInFunctions.durationMonths.bind(M.BuiltInFunctions),null);j.functionHandlers.set("month",Px);j.functionHandlers.set("months",Px);var Ox=Xl(M.BuiltInFunctions.day.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationDays.bind(M.BuiltInFunctions));j.functionHandlers.set("day",Ox);j.functionHandlers.set("days",Ox);j.functionHandlers.set("hours",Xl(M.BuiltInFunctions.hours.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationHours.bind(M.BuiltInFunctions)));j.functionHandlers.set("minutes",Xl(M.BuiltInFunctions.minutes.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationMinutes.bind(M.BuiltInFunctions)));j.functionHandlers.set("seconds",Xl(M.BuiltInFunctions.seconds.bind(M.BuiltInFunctions),null,M.BuiltInFunctions.durationSeconds.bind(M.BuiltInFunctions)));j.functionHandlers.set("timezone",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.timezone(t)});j.functionHandlers.set("tz",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.tz(t)});j.functionHandlers.set("adjust",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=n.length>1?e.evaluateExpression(n[1],e.solution):void 0;return M.BuiltInFunctions.adjust(t,r)});j.functionHandlers.set("now",()=>M.BuiltInFunctions.now());var Fx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdDateTime(e.getStringValue(t))},"dateTimeHandler");j.functionHandlers.set("datetime",Fx);j.functionHandlers.set("xsd:datetime",Fx);var Dx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdInteger(e.getStringValue(t))},"integerHandler");j.functionHandlers.set("integer",Dx);j.functionHandlers.set("xsd:integer",Dx);var Lx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdDecimal(e.getStringValue(t))},"decimalHandler");j.functionHandlers.set("decimal",Lx);j.functionHandlers.set("xsd:decimal",Lx);var Nx=a((n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.xsdDayTimeDuration(e.getStringValue(t))},"dayTimeDurationHandler");j.functionHandlers.set("daytimeduration",Nx);j.functionHandlers.set("xsd:daytimeduration",Nx);j.functionHandlers.set("durationtodays",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToDays(t)});j.functionHandlers.set("durationtohours",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToHours(t)});j.functionHandlers.set("durationtominutes",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToMinutes(t)});j.functionHandlers.set("durationtoseconds",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationToSeconds(t)});j.functionHandlers.set("durationdays",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationDays(t)});j.functionHandlers.set("durationhours",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationHours(t)});j.functionHandlers.set("durationminutes",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationMinutes(t)});j.functionHandlers.set("durationseconds",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationSeconds(t)});j.functionHandlers.set("durationyears",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationYears(t)});j.functionHandlers.set("durationmonths",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution);return M.BuiltInFunctions.durationMonths(t)});j.functionHandlers.set("datetimediff",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=e.evaluateExpression(n[1],e.solution);return M.BuiltInFunctions.dateTimeDiff(t,r)});j.functionHandlers.set("datetimeadd",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=e.evaluateExpression(n[1],e.solution);return M.BuiltInFunctions.dateTimeAdd(t,r)});j.functionHandlers.set("datetimesubtract",(n,e)=>{let t=e.evaluateExpression(n[0],e.solution),r=e.evaluateExpression(n[1],e.solution);return M.BuiltInFunctions.dateTimeSubtract(t,r)});j.functionHandlers.set("mstominutes",(n,e)=>{let t=Number(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.msToMinutes(t)});j.functionHandlers.set("mstohours",(n,e)=>{let t=Number(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.msToHours(t)});j.functionHandlers.set("mstoseconds",(n,e)=>{let t=Number(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.msToSeconds(t)});j.functionHandlers.set("md5",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.md5(t)});j.functionHandlers.set("sha1",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha1(t)});j.functionHandlers.set("sha256",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha256(t)});j.functionHandlers.set("sha384",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha384(t)});j.functionHandlers.set("sha512",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution));return M.BuiltInFunctions.sha512(t)});j.functionHandlers.set("subject",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.subject(t)});j.functionHandlers.set("predicate",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.predicate(t)});j.functionHandlers.set("object",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution);return M.BuiltInFunctions.object(t)});j.functionHandlers.set("triple",(n,e)=>{let t=e.getTermFromExpression(n[0],e.solution),r=e.getTermFromExpression(n[1],e.solution),i=e.getTermFromExpression(n[2],e.solution);return M.BuiltInFunctions.triple(t,r,i)});j.functionHandlers.set("days_between",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t),s=new Date(r);return Math.floor((s.getTime()-i.getTime())/(1440*60*1e3))});j.functionHandlers.set("minutes_between",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t),s=new Date(r);return Math.floor((s.getTime()-i.getTime())/(60*1e3))});j.functionHandlers.set("hours_between",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t);return(new Date(r).getTime()-i.getTime())/(3600*1e3)});j.functionHandlers.set("age_days",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=new Date(t);return Math.floor((new Date().getTime()-r.getTime())/(1440*60*1e3))});j.functionHandlers.set("week_number",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=new Date(t),i=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()));i.setUTCDate(i.getUTCDate()+4-(i.getUTCDay()||7));let s=new Date(Date.UTC(i.getUTCFullYear(),0,1));return Math.ceil(((i.getTime()-s.getTime())/(1440*60*1e3)+1)/7)});j.functionHandlers.set("format_date",(n,e)=>{let t=e.getStringValue(e.evaluateExpression(n[0],e.solution)),r=e.getStringValue(e.evaluateExpression(n[1],e.solution)),i=new Date(t);return r.replace("YYYY",String(i.getFullYear())).replace("MM",String(i.getMonth()+1).padStart(2,"0")).replace("DD",String(i.getDate()).padStart(2,"0")).replace("HH",String(i.getHours()).padStart(2,"0")).replace("mm",String(i.getMinutes()).padStart(2,"0")).replace("ss",String(i.getSeconds()).padStart(2,"0"))});j.functionHandlers.set("exo:eval",()=>{let{ExoQLEvalDisabledError:n}=tf();throw new n})});var Ip=S(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.FilterExecutor=Kl.FilterExecutorError=void 0;var bt=Tp(),Z9=kx(),Wb=Ae(),as=$e(),br=class extends Error{static{a(this,"FilterExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="FilterExecutorError"}};Kl.FilterExecutorError=br;var zb=class{static{a(this,"FilterExecutor")}constructor(){this.existsEvaluator=null,this.tripleStore=null,this.uuidCache=new Map}setExistsEvaluator(e){this.existsEvaluator=e}setTripleStore(e){this.tripleStore=e,this.uuidCache.clear()}async*execute(e,t){let r=this.expressionContainsExists(e.expression);for await(let i of t)try{let s;r?s=await this.evaluateExpressionAsync(e.expression,i):s=this.evaluateExpression(e.expression,i),s===!0&&(yield i)}catch{continue}}expressionContainsExists(e){if(!e||typeof e!="object")return!1;if(e.type==="exists")return!0;if(e.type==="logical")return e.operands.some(t=>this.expressionContainsExists(t));if(e.type==="comparison"){let t=e;return this.expressionContainsExists(t.left)||this.expressionContainsExists(t.right)}if(e.type==="arithmetic"){let t=e;return this.expressionContainsExists(t.left)||this.expressionContainsExists(t.right)}if(e.type==="in"){let t=e;return this.expressionContainsExists(t.expression)||t.list.some(r=>this.expressionContainsExists(r))}if(e.type==="function"||e.type==="functionCall"){let t=e;return Array.isArray(t.args)?t.args.some(r=>this.expressionContainsExists(r)):!1}return!1}async executeAll(e,t){let r=[];async function*i(){for(let s of t)yield s}a(i,"generator");for await(let s of this.execute(e,i()))r.push(s);return r}evaluateExpression(e,t){let r=e;if("termType"in e)switch(r.termType){case"Variable":return t.get(r.value);case"Literal":{let i=r.value,s=r.datatype,o=typeof s=="string"?s:s?.value;return o&&i.length>0&&this.shouldPreserveDatatype(o)?new as.Literal(i,new Wb.IRI(o)):i}case"NamedNode":return r.value;default:throw new br(`Unsupported termType: ${String(r.termType)}`)}switch(e.type){case"comparison":return this.evaluateComparison(e,t);case"logical":return this.evaluateLogical(e,t);case"arithmetic":return this.evaluateArithmetic(e,t);case"function":case"functionCall":return this.evaluateFunction(e,t);case"variable":return t.get(e.name);case"literal":{let i=e;return i.datatype&&i.value.length>0&&this.shouldPreserveDatatype(i.datatype)?new as.Literal(i.value,new Wb.IRI(i.datatype)):i.value}case"in":return this.evaluateIn(e,t);case"exists":throw new br("EXISTS expressions require async evaluation. Use evaluateExpressionAsync instead.");default:throw new br(`Unsupported expression type: ${e.type}`)}}async evaluateExpressionAsync(e,t){if(!this.expressionContainsExists(e))return this.evaluateExpression(e,t);if(e.type==="exists")return this.evaluateExists(e,t);if(e.type==="logical")return this.evaluateLogicalAsync(e,t);if(e.type==="comparison"){let r=e,i=await this.evaluateExpressionAsync(r.left,t),s=await this.evaluateExpressionAsync(r.right,t);return bt.BuiltInFunctions.compare(i,s,r.operator)}return e.type==="in"?this.evaluateInAsync(e,t):e.type==="function"||e.type==="functionCall"?this.evaluateFunctionAsync(e,t):this.evaluateExpression(e,t)}async evaluateExists(e,t){if(!this.existsEvaluator)throw new br("EXISTS evaluator not set. Call setExistsEvaluator before evaluating EXISTS expressions.");let r=await this.existsEvaluator(e.pattern,t);return e.negated?!r:r}async evaluateLogicalAsync(e,t){if(e.operator==="!"){let i=await this.evaluateExpressionAsync(e.operands[0],t);return bt.BuiltInFunctions.logicalNot(i)}let r=[];for(let i of e.operands){let s=await this.evaluateExpressionAsync(i,t);r.push(s)}if(e.operator==="&&")return bt.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return bt.BuiltInFunctions.logicalOr(r);throw new br(`Unknown logical operator: ${String(e.operator)}`)}async evaluateInAsync(e,t){let r=await this.evaluateExpressionAsync(e.expression,t),i=!1;for(let s of e.list){let o=await this.evaluateExpressionAsync(s,t);if(bt.BuiltInFunctions.compare(r,o,"=")){i=!0;break}}return e.negated?!i:i}async evaluateFunctionAsync(e,t){let r=e,i=this.extractFunctionName(r.function),s=r.args??[];if(i==="if"){if(s.length!==3)throw new br("IF requires exactly 3 arguments");let c=await this.evaluateExpressionAsync(s[0],t);return this.toBoolean(c)?this.evaluateExpressionAsync(s[1],t):this.evaluateExpressionAsync(s[2],t)}if(i==="coalesce"){for(let c of s)try{let u=await this.evaluateExpressionAsync(c,t);if(u!=null)return u}catch{continue}return}let o=[];for(let c of s){let u=await this.evaluateExpressionAsync(c,t);o.push(this.wrapAsLiteralExpression(u))}let l={...r,args:o};return this.evaluateFunction(l,t)}wrapAsLiteralExpression(e){return e==null?{type:"literal",value:""}:typeof e=="object"&&"termType"in e?e:e instanceof Wb.IRI||e instanceof as.Literal?{type:"literal",value:e.value}:typeof e=="number"||typeof e=="boolean"||typeof e=="string"?{type:"literal",value:e}:{type:"literal",value:String(e)}}evaluateComparison(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);return bt.BuiltInFunctions.compare(r,i,e.operator)}evaluateLogical(e,t){if(e.operator==="!"){let i=this.evaluateExpression(e.operands[0],t);return bt.BuiltInFunctions.logicalNot(i)}let r=e.operands.map(i=>this.evaluateExpression(i,t));if(e.operator==="&&")return bt.BuiltInFunctions.logicalAnd(r);if(e.operator==="||")return bt.BuiltInFunctions.logicalOr(r);throw new br(`Unknown logical operator: ${String(e.operator)}`)}evaluateIn(e,t){let r=this.evaluateExpression(e.expression,t),i=e.list.some(s=>{let o=this.evaluateExpression(s,t);return bt.BuiltInFunctions.compare(r,o,"=")});return e.negated?!i:i}evaluateArithmetic(e,t){let r=this.evaluateExpression(e.left,t),i=this.evaluateExpression(e.right,t);if(e.operator==="-"&&this.isDateValue(r)&&this.isDateValue(i))return bt.BuiltInFunctions.dateDiff(r,i);if(e.operator==="-"&&this.isTimeValue(r)&&this.isTimeValue(i))return bt.BuiltInFunctions.timeDiff(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDateTimeValue(i))return bt.BuiltInFunctions.dateTimeDiff(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateAdd(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateSubtract(r,i);if(e.operator==="+"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateAddYearMonth(r,i);if(e.operator==="-"&&this.isDateValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateTimeAdd(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.dateTimeSubtract(r,i);if(e.operator==="+"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateTimeAddYearMonth(r,i);if(e.operator==="-"&&this.isDateTimeValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.dateTimeSubtractYearMonth(r,i);if(e.operator==="+"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.durationAdd(r,i);if(e.operator==="-"&&this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i))return bt.BuiltInFunctions.durationSubtract(r,i);if(e.operator==="*"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let l=this.toNumericValue(i);return bt.BuiltInFunctions.durationMultiply(r,l)}if(e.operator==="*"&&!this.isDayTimeDurationValue(r)&&this.isDayTimeDurationValue(i)){let l=this.toNumericValue(r);return bt.BuiltInFunctions.durationMultiply(i,l)}if(e.operator==="/"&&this.isDayTimeDurationValue(r)&&!this.isDayTimeDurationValue(i)){let l=this.toNumericValue(i);if(l===0)throw new br("Division by zero");return bt.BuiltInFunctions.durationDivide(r,l)}if(e.operator==="+"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.yearMonthDurationAdd(r,i);if(e.operator==="-"&&this.isYearMonthDurationValue(r)&&this.isYearMonthDurationValue(i))return bt.BuiltInFunctions.yearMonthDurationSubtract(r,i);let s=this.toNumericValue(r),o=this.toNumericValue(i);switch(e.operator){case"+":return s+o;case"-":return s-o;case"*":return s*o;case"/":if(o===0)throw new br("Division by zero");return s/o;default:throw new br(`Unknown arithmetic operator: ${String(e.operator)}`)}}shouldPreserveDatatype(e){return e==="http://www.w3.org/2001/XMLSchema#dateTime"||e==="http://www.w3.org/2001/XMLSchema#date"||e==="http://www.w3.org/2001/XMLSchema#time"||e==="http://www.w3.org/2001/XMLSchema#dayTimeDuration"||e==="http://www.w3.org/2001/XMLSchema#yearMonthDuration"||e==="http://www.w3.org/2001/XMLSchema#duration"}isDayTimeDurationValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#dayTimeDuration":!1}isYearMonthDurationValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#yearMonthDuration":!1}toNumericValue(e){if(typeof e=="number")return e;if(e instanceof as.Literal){let t=e.datatype?.value||"";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let i=parseFloat(e.value);if(!isNaN(i))return i}let r=parseFloat(e.value);if(!isNaN(r))return r}if(typeof e=="string"){let t=parseFloat(e);if(!isNaN(t))return t}if(e&&typeof e=="object"&&"value"in e){let t=parseFloat(String(e.value));if(!isNaN(t))return t}throw new br(`Cannot convert to number: ${e}`)}isDateTimeValue(e){if(e instanceof as.Literal){let t=e.datatype?.value||"";return t.includes("#dateTime")||t.includes("#date")?!0:/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e.value)}return typeof e=="string"?/^\d{4}-\d{2}-\d{2}(T|\s)/.test(e):!1}isDateValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#date":!1}isTimeValue(e){return e instanceof as.Literal?(e.datatype?.value||"")==="http://www.w3.org/2001/XMLSchema#time":!1}evaluateFunction(e,t){let r=e,i=this.extractFunctionName(r.function),s=this.evaluateSpecialFunction(i,r.args,t);if(s!==void 0)return s.value;let o=Z9.functionHandlers.get(i);if(!o)throw new br(`Unknown function: ${i}`);let l={evaluateExpression:a((c,u)=>this.evaluateExpression(c,u),"evaluateExpression"),getTermFromExpression:a((c,u)=>this.getTermFromExpression(c,u),"getTermFromExpression"),getStringValue:a(c=>this.getStringValue(c),"getStringValue"),solution:t,isYearMonthDurationValue:a(c=>this.isYearMonthDurationValue(c),"isYearMonthDurationValue"),isDayTimeDurationValue:a(c=>this.isDayTimeDurationValue(c),"isDayTimeDurationValue")};return o(r.args,l)}extractFunctionName(e){if(typeof e=="string")return e.toLowerCase();if(e&&typeof e=="object"&&"value"in e){let t=e.value;return((t.includes("#")?t.split("#").pop():t.split("/").pop())||t).toLowerCase()}throw new br(`Unknown function format: ${String(e)}`)}evaluateSpecialFunction(e,t,r){switch(e){case"coalesce":for(let i of t)try{let s=this.evaluateExpression(i,r);if(s!=null)return{value:s}}catch{continue}return{value:void 0};case"if":{if(!t||t.length!==3)throw new br("IF requires exactly 3 arguments");let i=this.evaluateExpression(t[0],r);return{value:this.toBoolean(i)?this.evaluateExpression(t[1],r):this.evaluateExpression(t[2],r)}}case"byuuid":return{value:this.evaluateByUUID({type:"function",function:"byuuid",args:t},r)};default:return}}getTermFromExpression(e,t){let r=e;if(r.type==="variable"&&r.name)return t.get(r.name)}getStringValue(e){return e==null?"":typeof e=="object"&&"value"in e?String(e.value):String(e)}toBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="number")return!isNaN(e)&&e!==0;if(typeof e=="string")return e.length>0;if(e instanceof as.Literal){let t=e.datatype?.value||"";if(t.includes("#boolean"))return e.value==="true"||e.value==="1";if(t.includes("#integer")||t.includes("#decimal")||t.includes("#double")||t.includes("#float")){let r=parseFloat(e.value);return!isNaN(r)&&r!==0}return e.value.length>0}return!!e}evaluateByUUID(e,t){if(!e.args||e.args.length!==1)throw new br("exo:byUUID requires exactly 1 argument (UUID string)");let r=this.evaluateExpression(e.args[0],t),i=this.getStringValue(r);if(!i)return;let s=i.toLowerCase();if(this.uuidCache.has(s))return this.uuidCache.get(s)??void 0;if(!this.tripleStore){this.uuidCache.set(s,null);return}if(this.tripleStore.findSubjectsByUUIDSync){let o=this.tripleStore.findSubjectsByUUIDSync(s);if(o.length===0){this.uuidCache.set(s,null);return}let l=o[0];return this.uuidCache.set(s,l),l}this.uuidCache.set(s,null)}cacheUUIDResult(e,t){let r=e.toLowerCase();this.uuidCache.set(r,t)}getCachedUUID(e){let t=e.toLowerCase();if(this.uuidCache.has(t))return this.uuidCache.get(t)}};Kl.FilterExecutor=zb});var Qb=S(xp=>{"use strict";Object.defineProperty(xp,"__esModule",{value:!0});xp.OptionalExecutor=void 0;var Hb=class{static{a(this,"OptionalExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);yield*this.hashJoin(r,i)}async executeAll(e,t){let r=[];for(let i of this.hashJoin(e,t))r.push(i);return r}*hashJoin(e,t){if(e.length===0)return;if(t.length===0){yield*e;return}let r=new Set;for(let c of e)for(let u of c.variables())r.add(u);let i=new Set;for(let c of t)for(let u of c.variables())i.add(u);let s=[];for(let c of r)i.has(c)&&s.push(c);if(s.sort(),s.length===0){yield*this.nestedLoopJoin(e,t);return}let o="\0",l=new Map;for(let c of t){let u=this.computeHashKey(c,s,o),f=l.get(u);f||(f=[],l.set(u,f)),f.push(c)}for(let c of e){let u=this.computeHashKey(c,s,o),f=l.get(u),d=!1;if(f)for(let h of f){let p=c.merge(h);p!==null&&(yield p,d=!0)}d||(yield c)}}computeHashKey(e,t,r){let i=[];for(let s of t){let o=e.get(s);i.push(o!==void 0?o.toString():"UNBOUND")}return i.join(r)}*nestedLoopJoin(e,t){for(let r of e){let i=!1;for(let s of t){let o=r.merge(s);o!==null&&(yield o,i=!0)}i||(yield r)}}};xp.OptionalExecutor=Hb});var Xb=S(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});Ap.UnionExecutor=void 0;var Yb=class{static{a(this,"UnionExecutor")}async*execute(e,t){let r=new Set;for await(let i of e){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}for await(let i of t){let s=this.getSolutionKey(i);r.has(s)||(r.add(s),yield i)}}async executeAll(e,t){let r=[];async function*i(){for(let o of e)yield o}a(i,"generateLeft");async function*s(){for(let o of t)yield o}a(s,"generateRight");for await(let o of this.execute(i(),s()))r.push(o);return r}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}};Ap.UnionExecutor=Yb});var Mx=S(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});Rp.MinusExecutor=void 0;var Kb=class{static{a(this,"MinusExecutor")}async*execute(e,t){let r=[];for await(let s of e)r.push(s);let i=[];for await(let s of t)i.push(s);for(let s of r){let o=!1;for(let l of i)if(this.areCompatible(s,l)){o=!0;break}o||(yield s)}}async executeAll(e,t){let r=[];async function*i(){for(let o of e)yield o}a(i,"generateLeft");async function*s(){for(let o of t)yield o}a(s,"generateRight");for await(let o of this.execute(i(),s()))r.push(o);return r}areCompatible(e,t){let r=e.variables(),i=new Set(t.variables()),s=r.filter(o=>i.has(o));if(s.length===0)return!1;for(let o of s){let l=e.get(o),c=t.get(o);if(l===void 0||c===void 0||l.toString()!==c.toString())return!1}return!0}};Rp.MinusExecutor=Kb});var $x=S(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.ValuesExecutor=Jl.ValuesExecutorError=void 0;var e5=ss(),jx=Ae(),t5=$e(),Cp=class extends Error{static{a(this,"ValuesExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ValuesExecutorError"}};Jl.ValuesExecutorError=Cp;var Jb=class{static{a(this,"ValuesExecutor")}async*execute(e){if(e.bindings.length!==0)for(let t of e.bindings)yield this.createSolutionMapping(t)}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}createSolutionMapping(e){let t=new e5.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.toRDFTerm(i);t.set(r,s)}return t}toRDFTerm(e){if(e.type==="iri")return new jx.IRI(e.value);if(e.type==="literal")return new t5.Literal(e.value,e.datatype?new jx.IRI(e.datatype):void 0,e.language,e.direction);throw new Cp(`Unknown term type: ${e.type}`)}};Jl.ValuesExecutor=Jb});var Zb=S(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.CustomAggregateRegistry=ec.CustomAggregateError=void 0;var Zl=class extends Error{static{a(this,"CustomAggregateError")}constructor(e,t){super(e),this.iri=t,this.name="CustomAggregateError"}};ec.CustomAggregateError=Zl;var Pp=class n{static{a(this,"CustomAggregateRegistry")}constructor(){this.aggregates=new Map}static getInstance(){return n.instance||(n.instance=new n),n.instance}static resetInstance(){n.instance&&n.instance.clear(),n.instance=null}register(e,t){if(!e||typeof e!="string")throw new Zl("Aggregate IRI must be a non-empty string");if(!t||typeof t.init!="function"||typeof t.step!="function"||typeof t.finalize!="function")throw new Zl("Aggregate must implement init(), step(), and finalize() methods",e);if(this.aggregates.has(e))throw new Zl(`Aggregate with IRI "${e}" is already registered`,e);this.aggregates.set(e,t)}unregister(e){return this.aggregates.delete(e)}get(e){return this.aggregates.get(e)}has(e){return this.aggregates.has(e)}getRegisteredIris(){return Array.from(this.aggregates.keys())}clear(){this.aggregates.clear()}get size(){return this.aggregates.size}};ec.CustomAggregateRegistry=Pp;Pp.instance=null});var e1=S(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.BUILT_IN_AGGREGATES=nt.modeAggregate=nt.stddevAggregate=nt.varianceAggregate=nt.medianAggregate=nt.EXO_AGGREGATE_NS=void 0;nt.getNumericValue=Op;nt.createDecimalLiteral=bi;nt.createDoubleLiteral=i5;nt.createPercentileAggregate=La;var Na=$e(),tc=Ae(),r5=new tc.IRI("http://www.w3.org/2001/XMLSchema#decimal"),n5=new tc.IRI("http://www.w3.org/2001/XMLSchema#double");nt.EXO_AGGREGATE_NS="https://exocortex.my/ontology/agg#";function Op(n){return n==null?NaN:typeof n=="number"?n:typeof n=="string"?parseFloat(n):n instanceof Na.Literal?parseFloat(n.value):n instanceof tc.IRI?NaN:typeof n=="boolean"?n?1:0:NaN}a(Op,"getNumericValue");function bi(n){return new Na.Literal(String(n),r5)}a(bi,"createDecimalLiteral");function i5(n){return new Na.Literal(String(n),n5)}a(i5,"createDoubleLiteral");nt.medianAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Op(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return bi(0);let r=[...t].sort((o,l)=>o-l),i=Math.floor(r.length/2),s=r.length%2!==0?r[i]:(r[i-1]+r[i])/2;return bi(s)}};nt.varianceAggregate={init(){return{values:[]}},step(n,e){let t=n,r=Op(e);isNaN(r)||t.values.push(r)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return bi(0);let r=t.reduce((s,o)=>s+o,0)/t.length,i=t.reduce((s,o)=>s+Math.pow(o-r,2),0)/t.length;return bi(i)}};nt.stddevAggregate={init(){return{values:[]}},step(n,e){nt.varianceAggregate.step(n,e)},finalize(n){let e=n,{values:t}=e;if(t.length===0)return bi(0);let r=t.reduce((s,o)=>s+o,0)/t.length,i=t.reduce((s,o)=>s+Math.pow(o-r,2),0)/t.length;return bi(Math.sqrt(i))}};nt.modeAggregate={init(){return{counts:new Map,values:new Map}},step(n,e){if(e==null)return;let t=n,r=String(e instanceof Na.Literal||e instanceof tc.IRI?e.value:e),i=t.counts.get(r)||0;t.counts.set(r,i+1),t.values.set(r,e)},finalize(n){let e=n;if(e.counts.size===0)return new Na.Literal(" ",new tc.IRI("http://www.w3.org/2001/XMLSchema#string"));let t="",r=0;for(let[o,l]of e.counts)l>r&&(r=l,t=o);let i=e.values.get(t);if(i instanceof Na.Literal)return i;let s=parseFloat(t);return isNaN(s)?new Na.Literal(t,new tc.IRI("http://www.w3.org/2001/XMLSchema#string")):bi(s)}};function La(n){let e=Math.max(0,Math.min(100,n))/100;return{init(){return{values:[],percentile:e}},step(t,r){let i=t,s=Op(r);isNaN(s)||i.values.push(s)},finalize(t){let r=t,{values:i}=r;if(i.length===0)return bi(0);let s=[...i].sort((d,h)=>d-h),o=r.percentile*(s.length-1),l=Math.floor(o),c=Math.ceil(o);if(l===c)return bi(s[l]);let u=o-l,f=s[l]*(1-u)+s[c]*u;return bi(f)}}}a(La,"createPercentileAggregate");nt.BUILT_IN_AGGREGATES={[`${nt.EXO_AGGREGATE_NS}median`]:nt.medianAggregate,[`${nt.EXO_AGGREGATE_NS}variance`]:nt.varianceAggregate,[`${nt.EXO_AGGREGATE_NS}stddev`]:nt.stddevAggregate,[`${nt.EXO_AGGREGATE_NS}mode`]:nt.modeAggregate,[`${nt.EXO_AGGREGATE_NS}percentile25`]:La(25),[`${nt.EXO_AGGREGATE_NS}percentile50`]:La(50),[`${nt.EXO_AGGREGATE_NS}percentile75`]:La(75),[`${nt.EXO_AGGREGATE_NS}percentile90`]:La(90),[`${nt.EXO_AGGREGATE_NS}percentile95`]:La(95),[`${nt.EXO_AGGREGATE_NS}percentile99`]:La(99)}});var Bx=S(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.AggregateExecutor=rc.AggregateExecutorError=void 0;var dr=$e(),r1=Ae(),s5=Ip(),o5=Zb(),a5=e1(),Ux=new r1.IRI("http://www.w3.org/2001/XMLSchema#integer"),ka=new r1.IRI("http://www.w3.org/2001/XMLSchema#decimal"),ls=new r1.IRI("http://www.w3.org/2001/XMLSchema#string");function Vx(n){return typeof n=="object"&&n.type==="custom"}a(Vx,"isCustomAggregation");var rf=class extends Error{static{a(this,"AggregateExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="AggregateExecutorError"}};rc.AggregateExecutorError=rf;var t1=class{static{a(this,"AggregateExecutor")}constructor(){this.filterExecutor=new s5.FilterExecutor}execute(e,t){let r=this.groupSolutions(t,e.variables),i=[];for(let[s,o]of r.entries()){let l=new Map;for(let f of e.variables)if(o.length>0){let d=o[0].get(f);d&&l.set(f,d)}for(let f of e.aggregates){let d=this.computeAggregate(f.expression,o);l.set(f.variable,d)}let{SolutionMapping:c}=ss(),u=new c;for(let[f,d]of l.entries())u.set(f,d);i.push(u)}if(i.length===0&&e.aggregates.length>0){let s=this.createEmptyAggregateResult(e);s&&i.push(s)}return i}groupSolutions(e,t){let r=new Map;if(t.length===0)return r.set("",e),r;for(let i of e){let s=this.computeGroupKey(i,t),o=r.get(s);o?o.push(i):r.set(s,[i])}return r}computeGroupKey(e,t){return t.map(r=>{let i=e.get(r);return i?this.termToString(i):""}).join("|")}termToString(e){if(e&&typeof e=="object"){if("value"in e)return String(e.value);if("id"in e)return String(e.id)}return String(e)}computeAggregate(e,t){if(Vx(e.aggregation))return this.computeCustomAggregate(e,t);let r=this.extractValues(e,t),i=e.aggregation;switch(i){case"count":{let s=this.computeCount(r,e.distinct);return new dr.Literal(String(s),Ux)}case"sum":{let s=this.computeSum(r);return new dr.Literal(String(s),ka)}case"avg":{let s=this.computeAvg(r);return new dr.Literal(String(s),ka)}case"min":{let s=this.computeMin(r);return s===void 0?new dr.Literal("",ls):typeof s=="number"?new dr.Literal(String(s),ka):new dr.Literal(String(s),ls)}case"max":{let s=this.computeMax(r);return s===void 0?new dr.Literal("",ls):typeof s=="number"?new dr.Literal(String(s),ka):new dr.Literal(String(s),ls)}case"group_concat":{let s=this.computeGroupConcat(r,e.separator||" ",e.distinct);return new dr.Literal(s||" ",ls)}case"sample":{let s=this.computeSample(r,e.distinct);return s===void 0?new dr.Literal(" ",ls):typeof s=="number"?new dr.Literal(String(s),ka):new dr.Literal(String(s),ls)}default:{let s=i;throw new rf(`Unknown aggregation function: ${s}`)}}}computeCustomAggregate(e,t){let i=e.aggregation.iri,o=o5.CustomAggregateRegistry.getInstance().get(i);if(o||(o=a5.BUILT_IN_AGGREGATES[i]),!o)throw new rf(`Unknown custom aggregate function: ${i}. Register it with CustomAggregateRegistry.getInstance().register() or use a built-in aggregate.`);let l=o.init();for(let c of t){let u=null;if(e.expression){let f=this.evaluateExpression(e.expression,c);f!==void 0&&(u=f)}else u=1;o.step(l,u)}return o.finalize(l)}extractValues(e,t){if(!e.expression)return t.map(()=>1);let r=[];for(let i of t){let s=this.evaluateExpression(e.expression,i);s!=null&&r.push(s)}return r}evaluateExpression(e,t){if(e.type==="variable"){let r=t.get(e.name);return r==null?void 0:typeof r=="number"||typeof r=="string"||typeof r=="boolean"?r:typeof r=="object"&&"value"in r?r.value:r}if(e.type==="literal")return e.value;try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}computeCount(e,t){return t?new Set(e.map(r=>String(r))).size:e.length}computeSum(e){return e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r)).reduce((r,i)=>r+i,0)}computeAvg(e){let t=e.map(r=>parseFloat(String(r))).filter(r=>!isNaN(r));return t.length===0?0:t.reduce((r,i)=>r+i,0)/t.length}computeMin(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.min(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s<i?s:i,r[0])}computeMax(e){if(e.length===0)return;let t=e.map(i=>parseFloat(String(i))).filter(i=>!isNaN(i));if(t.length>0)return Math.max(...t);let r=e.map(i=>String(i));return r.reduce((i,s)=>s>i?s:i,r[0])}computeGroupConcat(e,t,r){let i=e.map(s=>String(s));return r&&(i=[...new Set(i)]),i.join(t)}computeSample(e,t){if(e.length===0)return;if(t){let s=[...new Set(e.map(c=>String(c)))];if(s.length===0)return;let o=s[0],l=parseFloat(o);return isNaN(l)?o:l}let r=e[0];if(typeof r=="number")return r;let i=parseFloat(String(r));return isNaN(i)?String(r):i}createEmptyAggregateResult(e){let{SolutionMapping:t}=ss(),r=new t;for(let i of e.aggregates){let s=i.expression.aggregation;if(Vx(s)){r.set(i.variable,new dr.Literal("0",ka));continue}switch(s){case"count":r.set(i.variable,new dr.Literal("0",Ux));break;case"sum":case"avg":r.set(i.variable,new dr.Literal("0",ka));break;case"group_concat":r.set(i.variable,new dr.Literal(" ",ls));break;case"min":case"max":case"sample":r.set(i.variable,new dr.Literal("",ls));break;default:r.set(i.variable,new dr.Literal("",ls))}}return r}};rc.AggregateExecutor=t1});var o1=S(Fp=>{"use strict";Object.defineProperty(Fp,"__esModule",{value:!0});Fp.ConstructExecutor=void 0;var l5=Bn(),Ma=Ae(),n1=$e(),i1=$t(),c5=Ou(),s1=class{static{a(this,"ConstructExecutor")}async execute(e,t){let r=[],i=new Set;for(let s of t)for(let o of e)try{let l=this.instantiateTriple(o,s),c=`${l.subject.toString()}|${l.predicate.toString()}|${l.object.toString()}`;i.has(c)||(i.add(c),r.push(l))}catch{continue}return r}instantiateTriple(e,t){if(this.isPropertyPath(e.predicate))throw new Error("Property paths are not supported in CONSTRUCT templates");let r=this.instantiateElement(e.subject,t),i=this.instantiateElement(e.predicate,t),s=this.instantiateElement(e.object,t);return new l5.Triple(r,i,s)}isPropertyPath(e){return e.type==="path"}instantiateElement(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable: ${e.value}`);return r}if(e.type==="iri")return new Ma.IRI(e.value);if(e.type==="literal")return new n1.Literal(e.value,e.datatype?new Ma.IRI(e.datatype):void 0,e.language);if(e.type==="blank")return new i1.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Unknown element type: ${e.type}`)}instantiateQuotedTriple(e,t){let r=this.instantiateQuotedSubject(e.subject,t),i=this.instantiateQuotedPredicate(e.predicate,t),s=this.instantiateQuotedObject(e.object,t);return new c5.QuotedTriple(r,i,s)}instantiateQuotedSubject(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple subject: ${e.value}`);if(r instanceof n1.Literal)throw new Error("Literals cannot appear in quoted triple subject position");return r}if(e.type==="iri")return new Ma.IRI(e.value);if(e.type==="blank")return new i1.BlankNode(e.value);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);throw new Error(`Invalid element type for quoted triple subject: ${e.type}`)}instantiateQuotedPredicate(e,t){if(e.type==="variable"){let r=t.get(e.value);if(!r)throw new Error(`Unbound variable in quoted triple predicate: ${e.value}`);if(!(r instanceof Ma.IRI))throw new Error("Quoted triple predicate must be an IRI");return r}return new Ma.IRI(e.value)}instantiateQuotedObject(e,t){if(e.type==="variable"){let i=t.get(e.value);if(!i)throw new Error(`Unbound variable in quoted triple object: ${e.value}`);return i}if(e.type==="iri")return new Ma.IRI(e.value);if(e.type==="blank")return new i1.BlankNode(e.value);if(e.type==="literal")return new n1.Literal(e.value,e.datatype?new Ma.IRI(e.datatype):void 0,e.language);if(e.type==="quoted")return this.instantiateQuotedTriple(e,t);let r=e;throw new Error(`Invalid element type for quoted triple object: ${r.type}`)}};Fp.ConstructExecutor=s1});var qx=S(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.ServiceExecutor=nc.ServiceExecutorError=void 0;var u5=ss(),Gx=Ae(),f5=$e(),d5=$t(),ja=class extends Error{static{a(this,"ServiceExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="ServiceExecutorError"}};nc.ServiceExecutorError=ja;var a1=class{static{a(this,"ServiceExecutor")}constructor(e={}){this.timeout=e.timeout??3e4,this.httpClient=e.httpClient??((t,r)=>fetch(t,r)),this.maxRetries=e.maxRetries??2,this.retryDelay=e.retryDelay??1e3}async*execute(e,t){try{let r=t(e.pattern),i=await this.executeRemoteQuery(e.endpoint,r);for(let s of i)yield s}catch(r){if(e.silent)return;throw r}}async executeRemoteQuery(e,t){let r;for(let i=0;i<=this.maxRetries;i++)try{let s=new AbortController,o=setTimeout(()=>s.abort(),this.timeout);try{let l=await this.httpClient(e,{method:"POST",headers:{"Content-Type":"application/sparql-query",Accept:"application/sparql-results+json"},body:t,signal:s.signal});if(!l.ok)throw new ja(`Remote SPARQL endpoint returned ${l.status}: ${l.statusText}`);let c=await l.json();return this.parseJsonResults(c)}finally{clearTimeout(o)}}catch(s){if(r=s instanceof Error?s:new Error(String(s)),this.isRetryableError(r)&&i<this.maxRetries){await this.delay(this.retryDelay);continue}throw new ja(`Failed to query remote SPARQL endpoint ${e}: ${r.message}`,r)}throw new ja(`Failed to query remote SPARQL endpoint ${e} after ${this.maxRetries+1} attempts`,r)}parseJsonResults(e){return!e.results||!Array.isArray(e.results.bindings)?[]:e.results.bindings.map(t=>this.parseBinding(t))}parseBinding(e){let t=new u5.SolutionMapping;for(let[r,i]of Object.entries(e)){let s=this.parseRDFTerm(i);t.set(r,s)}return t}parseRDFTerm(e){switch(e.type){case"uri":return new Gx.IRI(e.value);case"literal":{let t=e.datatype?new Gx.IRI(e.datatype):void 0;return new f5.Literal(e.value,t,e["xml:lang"])}case"bnode":return new d5.BlankNode(e.value);default:throw new ja(`Unknown RDF term type: ${e.type}`)}}isRetryableError(e){let t=e.message.toLowerCase();return!!(e.name==="AbortError"||t.includes("network")||t.includes("econnreset")||t.includes("econnrefused")||t.includes("etimedout")||t.includes("returned 5"))}delay(e){return new Promise(t=>setTimeout(t,e))}};nc.ServiceExecutor=a1});var zx=S(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.GraphExecutor=ic.GraphExecutorError=void 0;var Wx=Ae(),Dp=class extends Error{static{a(this,"GraphExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="GraphExecutorError"}};ic.GraphExecutorError=Dp;var l1=class{static{a(this,"GraphExecutor")}constructor(e){this.tripleStore=e}async*execute(e,t,r){let i=e.name;if(i.type==="iri")yield*this.executeWithGraph(e.pattern,i,t);else if(i.type==="variable")yield*this.executeWithGraphVariable(e,i,t,r);else throw new Dp(`Invalid graph name type: ${i.type}`)}async*executeWithGraph(e,t,r){let i=new Wx.IRI(t.value);this.tripleStore.hasGraph&&!await this.tripleStore.hasGraph(i)||(yield*r(e,i))}async*executeWithGraphVariable(e,t,r,i){if(i){let o=i.get(t.value);if(o&&o instanceof Wx.IRI){yield*this.executeWithGraph(e.pattern,{type:"iri",value:o.value},r);return}}if(!this.tripleStore.getNamedGraphs)return;let s=await this.tripleStore.getNamedGraphs();for(let o of s)for await(let l of r(e.pattern,o)){let c=l.clone();c.set(t.value,o),yield c}}};ic.GraphExecutor=l1});var Hx=S(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.SPARQLGenerator=oc.SPARQLGeneratorError=void 0;var sc=class extends Error{static{a(this,"SPARQLGeneratorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="SPARQLGeneratorError"}};oc.SPARQLGeneratorError=sc;var c1=class{static{a(this,"SPARQLGenerator")}collectVariables(e){let t=new Set;return this.collectVariablesFromOperation(e,t),t}generateSelect(e){let t=this.collectVariables(e),r=t.size>0?Array.from(t).map(s=>`?${s}`).join(" "):"*",i=this.generateWhereClause(e);return`SELECT ${r} WHERE {
49
49
  ${i}
50
50
  }`}generateWhereClause(e,t=2){let r=" ".repeat(t);switch(e.type){case"bgp":return this.generateBGP(e,t);case"filter":return`${this.generateWhereClause(e.input,t)}
51
51
  ${r}FILTER(${this.generateExpression(e.expression)})`;case"join":return`${this.generateWhereClause(e.left,t)}
@@ -67,7 +67,7 @@ ${r}}`}default:throw new sc(`Unsupported operation type for SPARQL generation: $
67
67
  `)}generateTriple(e){let t=this.generateElement(e.subject),r=this.generatePredicate(e.predicate),i=this.generateElement(e.object);return`${t} ${r} ${i}`}generatePredicate(e){return"pathType"in e?this.generatePropertyPath(e):this.generateElement(e)}generatePropertyPath(e){let t=e.items.map(r=>"pathType"in r?`(${this.generatePropertyPath(r)})`:`<${r.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}generateElement(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":{let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}case"blank":return`_:${e.value}`;default:throw new sc(`Unknown element type: ${e.type}`)}}generateValues(e,t){let r=" ".repeat(t);if(e.variables.length===0||e.bindings.length===0)return"";if(e.variables.length===1){let o=e.variables[0],l=e.bindings.map(c=>{let u=c[o];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ");return`${r}VALUES ?${o} { ${l} }`}let i=e.variables.map(o=>`?${o}`).join(" "),s=e.bindings.map(o=>`(${e.variables.map(c=>{let u=o[c];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ")})`);return`${r}VALUES (${i}) {
68
68
  ${s.map(o=>`${r} ${o}`).join(`
69
69
  `)}
70
- ${r}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(r=>this.generateExpression(r)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),r=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${r})`:`${t} IN (${r})`}default:throw new sc(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let r of e.triples)this.collectVariablesFromTriple(r,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let r of e.variables)t.add(r);break;case"project":for(let r of e.variables)t.add(r);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let r of e.variables)t.add(r);for(let r of e.aggregates)t.add(r.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let r of e.operands)this.collectVariablesFromExpression(r,t);break;case"function":case"functionCall":for(let r of e.args)this.collectVariablesFromExpression(r,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let r of e.list)this.collectVariablesFromExpression(r,t);break}}};oc.SPARQLGenerator=c1});var lc=S(On=>{"use strict";var h5=On&&On.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),p5=On&&On.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),Qx=On&&On.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&h5(t,e,r[i]);return p5(t,e),t}})();Object.defineProperty(On,"__esModule",{value:!0});On.QueryExecutor=On.ExoQLQueryExecutor=On.QueryExecutorError=void 0;var m5=Cb(),g5=Ip(),y5=Qb(),_5=Xb(),b5=Mx(),S5=$x(),w5=Bx(),v5=o1(),E5=qx(),T5=zx(),I5=Hx(),x5=Ae(),A5=$e(),R5=_p(),jr="http://www.w3.org/2001/XMLSchema#",C5=new Set([`${jr}integer`,`${jr}decimal`,`${jr}float`,`${jr}double`,`${jr}nonPositiveInteger`,`${jr}negativeInteger`,`${jr}long`,`${jr}int`,`${jr}short`,`${jr}byte`,`${jr}nonNegativeInteger`,`${jr}unsignedLong`,`${jr}unsignedInt`,`${jr}unsignedShort`,`${jr}unsignedByte`,`${jr}positiveInteger`]),ac=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};On.QueryExecutorError=ac;var Lp=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){this.tripleStore=e,this.bgpExecutor=new m5.BGPExecutor(e),this.filterExecutor=new g5.FilterExecutor,this.optionalExecutor=new y5.OptionalExecutor,this.unionExecutor=new _5.UnionExecutor,this.minusExecutor=new b5.MinusExecutor,this.valuesExecutor=new S5.ValuesExecutor,this.aggregateExecutor=new w5.AggregateExecutor,this.constructExecutor=new v5.ConstructExecutor,this.serviceExecutor=new E5.ServiceExecutor(t.serviceConfig),this.graphExecutor=new T5.GraphExecutor(e),this.sparqlGenerator=new I5.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(r,i)=>this.evaluateExistsPattern(r,i)),this.filterExecutor.setTripleStore(e)}async evaluateExistsPattern(e,t){for await(let r of this.execute(e))if(t.merge(r)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new ac(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let r=new Set;for(let o of t)for(let l of o.variables())r.add(l);let i=this.collectOperationVariables(e.right);if([...r].some(o=>i.has(o)))for(let o of t){let l=this.substituteVariables(e.right,o);for await(let c of this.execute(l)){let u=o.merge(c);u!==null&&(yield u)}}else{let o=[];for await(let l of this.execute(e.right))o.push(l);for(let l of t)for(let c of o){let u=l.merge(c);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>Qx(ss())),r=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(r.has(o)){let l=i.get(o);l!==void 0&&s.set(o,l)}yield s}}async*executeOrderBy(e){let t=[];for await(let r of this.execute(e.input))t.push(r);t.sort((r,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,r),l=this.getExpressionValue(s.expression,i),c=0;if(o===void 0&&l===void 0?c=0:o===void 0?c=1:l===void 0?c=-1:typeof o=="number"&&typeof l=="number"?c=o-l:c=String(o).localeCompare(String(l)),s.descending&&(c=-c),c!==0)return c}return 0});for(let r of t)yield r}async*executeSlice(e){let t=0,r=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=r){if(i!==void 0&&t-r>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeReduced(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let r=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of r)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of r)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let r of this.execute(e.input)){let i=r.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,r):this.evaluateExtendExpression(e.expression,r);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let r of this.execute(e.left))t.push(r);for(let r of t){let i=this.substituteVariables(e.right,r);for await(let s of this.execute(i)){let o=r.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let r=JSON.parse(JSON.stringify(e));return this.substituteInOperation(r,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let r=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(r.input&&(r.input=this.substituteInOperation(r.input,t)),r.left&&(r.left=this.substituteInOperation(r.left,t)),r.right&&(r.right=this.substituteInOperation(r.right,t)),r.pattern&&(r.pattern=this.substituteInOperation(r.pattern,t)),r.query&&(r.query=this.substituteInOperation(r.query,t)),r.where&&(r.where=this.substituteInOperation(r.where,t)),r.expression&&this.substituteInExpression(r.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let r of e.operands)this.substituteInExpression(r,t);if(e.args)for(let r of e.args)this.substituteInExpression(r,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let r of e.list)this.substituteInExpression(r,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let r=t.get(e.value);if(r!=null){let i=r;if(r instanceof x5.IRI||i.termType==="NamedNode")return{type:"iri",value:r.value};if(i.termType==="Literal"||typeof i.value=="string")return{type:"literal",value:i.value,datatype:i.datatype?.value??i._datatype?.value,language:i.language??i._language}}}return e}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(r,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{r.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(r,i):yield*this.execute(r)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:r}=await Promise.resolve().then(()=>Qx(ss()));yield new r;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let r=t.get(e.name);if(!r)return;if(r instanceof A5.Literal){let i=r.datatype?.value;if(i===`${jr}dayTimeDuration`)try{return R5.DateTimeFunctions.parseDayTimeDuration(r.value)}catch{return r.value}if(i&&C5.has(i)){let s=parseFloat(r.value);if(!Number.isNaN(s))return s}return r.value}return r.value??r.id??String(r)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="bgp"&&r.triples)for(let i of r.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(r.type==="values"&&r.variables)for(let i of r.variables)t.add(i);r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.type==="extend"&&r.variable&&t.add(r.variable),r.input&&this.collectVarsFromOperation(r.input,t),r.left&&this.collectVarsFromOperation(r.left,t),r.right&&this.collectVarsFromOperation(r.right,t),r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.query&&this.collectVarsFromOperation(r.query,t),r.where&&this.collectVarsFromOperation(r.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let r=e;r.type==="variable"&&t.add(r.value),r.type==="quoted"&&(this.collectVarsFromElement(r.subject,t),this.collectVarsFromElement(r.predicate,t),this.collectVarsFromElement(r.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="variable"&&r.name&&t.add(r.name),r.type==="exists"&&r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.left&&this.collectVarsFromExpressionTree(r.left,t),r.right&&this.collectVarsFromExpressionTree(r.right,t),r.operands)for(let i of r.operands)this.collectVarsFromExpressionTree(i,t);if(r.args)for(let i of r.args)this.collectVarsFromExpressionTree(i,t);if(r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.list)for(let i of r.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new ac("executeConstruct requires a CONSTRUCT operation");let t=await this.executeAll(e.where);return this.constructExecutor.execute(e.template,t)}isAskQuery(e){return e.type==="ask"}async executeAsk(e){if(e.type!=="ask")throw new ac("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};On.ExoQLQueryExecutor=Lp;On.QueryExecutor=Lp});var rA=S(zs=>{"use strict";var P5=zs&&zs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},O5=zs&&zs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},u1;Object.defineProperty(zs,"__esModule",{value:!0});zs.CommandResolver=void 0;var F5=Oe(),D5=Cl(),rr=Ae(),Ht=$e(),L=er(),Yx=Io(),Xx=Cu(),cc=x0(),Np=GI(),L5=$l(),N5=Vl(),k5=lc(),kp=10,Kx="08cec529-90eb-4d43-88de-ceecccea12b0",M5=L.Namespace.EXOCMD.term("SubstitutionToken").value,Jx=new Set(["today","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","labelAsArray","groundingTargetClass"]);function j5(n,e){return`__SUBSTITUTE__${n}__${e}__`}a(j5,"buildSubstitutionMarker");function $5(n,e,t){let r=Buffer.from(t,"utf-8").toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${n}__${e}__${r}__`}a($5,"buildParameterisedMarker");var Zx="3f28af98-c031-4718-8ba2-44ad0b012c52",U5=L.Namespace.EXOCMD.term("TokenInvocation").value,eA="29e2c8f8-2d27-4e58-b467-2e85d46f8122",tA="universal-default-template",V5=new Set(["today","todayStart","nowTimestamp","nowDate","nowYear","nowMonth"]),f1=u1=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null,(0,Np.clearUniversalDefault)()}constructor(e,t=D5.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,r){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${r??""}`,o=this.multiCache.get(s);if(o)return o;let l=new Set,c=[];for(let u of t){let f=await this.resolveForAsset(e,u,r);for(let d of f)l.has(d.binding.id)||(l.add(d.binding.id),c.push(d))}return c.sort((u,f)=>{let d=this.getBindingPriority(u.binding),h=this.getBindingPriority(f.binding);return d!==h?d-h:(u.binding.order??100)-(f.binding.order??100)}),this.multiCache.set(s,c),c}async resolveForAsset(e,t,r){let i=`${e}:${t}:${r??""}`,s=this.cache.get(i);if(s)return s;let o=await this.findBindings(t,r,e),l=[];for(let c of o){let u=await this.loadCommand(c.commandRef,{targetClass:c.targetClass});if(!u)continue;let f=c.precondition?{...u,precondition:c.precondition}:u;l.push({command:f,binding:c})}return l.sort((c,u)=>{let f=this.getBindingPriority(c.binding),d=this.getBindingPriority(u.binding);return f!==d?f-d:(c.binding.order??100)-(u.binding.order??100)}),this.cache.set(i,l),l}async loadCommand(e,t){let r=await this.findSubjectByUID(e);if(!r||(await this.tripleStore.match(r,L.Namespace.RDF.term("type"),L.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(r,L.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_labelTemplate")),l=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_icon")),c=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_openInSameTab")),h=d!==null&&String(d).trim().toLowerCase()==="true",p=await this.loadLinkedPrecondition(r),g=await this.loadLinkedGrounding(r,0,t);return g?{id:e,name:s,labelTemplate:o??void 0,icon:l??void 0,precondition:p??void 0,grounding:g,confirmMessage:c??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:h||void 0}:null}async findBindings(e,t,r){let i=await this.tripleStore.match(void 0,L.Namespace.RDF.term("type"),L.Namespace.EXOCMD.term("CommandBinding")),s=[];for(let o of i){let l=o.subject,c=await this.loadBindingDefinition(l);c&&this.bindingMatches(c,e,t,r)&&s.push(c)}return s}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,L.Namespace.RDF.term("type"),L.Namespace.EXOCMD.term("Command")),t=[],r=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let l=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_uid"));if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let c=await this.loadCommand(l);if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command ${l} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Command_cliName")),d=u??f??l;if(r.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${l}`);continue}r.add(d),t.push({command:c,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorCache.clear()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let r=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let l=await this.evaluateSelectSnippet(o,t);r=r.replace(s,l)}return r}extractPlaceholders(e){let t=[],r=0;for(;r<e.length;)if(e[r]==="{"){let i=1,s=r+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(r,s),l=e.slice(r+1,s-1);t.push({full:o,body:l})}r=s}else r++;return t}async evaluateSelectSnippet(e,t){try{let r=e.replace(/\$target/g,`<${t}>`),s=new L5.ExoQLParser().parse(r),l=new N5.ExoQLAlgebraTranslator().translate(s),u=await new k5.ExoQLQueryExecutor(this.tripleStore).executeAll(l);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let h=f.get(d[0]);return h?h instanceof Ht.Literal||h instanceof rr.IRI?h.value:String(h):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,L.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,L.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,L.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),l=await this.getLinkedValue(e,L.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!l)return null;let c=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,h=await this.loadLinkedPreconditionFromProperty(e,L.Namespace.EXOCMD.term("CommandBinding_precondition")),p=await this.loadLinkedStyle(e,t);return{id:t,label:r,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:l??void 0,position:c??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:h??void 0,style:p??void 0}}async loadLinkedStyle(e,t){let r=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(r.length>0){let s=r[0].object,o=null;if(s instanceof rr.IRI)o=s;else if(s instanceof Ht.Literal){let l=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(l)}if(o){let l=await this.loadStyleAsset(o);if(l)return l}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_variant"));if(i!==null){let s=this.coerceVariant(i,t);if(s!==void 0)return{id:`inline:${t}`,label:"",variant:s,inline:!0}}return null}async loadStyleAsset(e){let t=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),l=this.coerceBoolean(o),c=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=c!==null?this.coerceLabelClass(c,t):void 0,f=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),h=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),p=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_source")),g=p!==null?this.coerceStyleSource(p,t):void 0;return{id:t,label:r,variant:s,showIcon:l,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:h??void 0,source:g,inline:!1}}coerceVariant(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(cc.COMMAND_VARIANT_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${r}" not in whitelist [${cc.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(cc.LABEL_CLASS_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${r}" not in whitelist [${cc.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(cc.STYLE_SOURCE_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle source "${r}" not in whitelist [${cc.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,r,i){return!!(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i)||e.targetPrototype&&r&&this.matchesReference(e.targetPrototype,r)||e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let r=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(r===i)return!0;let s=this.extractPathBasename(i);if(s&&s===r)return!0;let o=this.extractPathBasename(r);if(o&&o===i)return!0;let l=this.extractAlias(t);if(l&&r===l)return!0;let c=this.extractAlias(e);return!!(c&&c===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(r+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,L.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object,s=null;if(i instanceof rr.IRI)s=i;else if(i instanceof Ht.Literal){let h=this.normalizeWikilink(i.value);s=await this.findSubjectByUID(h)}if(!s)return null;let o=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_uid")),l=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_label"))??"",c=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Precondition_sparqlAsk")),u=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Precondition_hostFunction")),f=await this.tripleStore.match(s,L.Namespace.EXOCMD.term("Precondition_query"),void 0),d;if(f.length>0){let h=f[0].object;if(h instanceof rr.IRI){let p=await this.getLiteralValue(h,L.Namespace.EXO.term("Asset_uid"));p&&(d=p)}else h instanceof Ht.Literal&&(d=this.normalizeWikilink(h.value))}return!o||!c&&!u&&!d?null:{id:o,label:l,...c&&{sparqlAsk:c},...u&&{hostFunction:u},...d&&{query:d}}}async loadLinkedGrounding(e,t,r){if(t>=kp)return null;let i=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!r?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let l=await this.resolveGroundingRef(o.object);if(!l)continue;let c=await this.getObsidianName(l,L.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(c&&this.matchesReference(c,r.targetClass))return this.loadGroundingDefinition(l,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${r.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof rr.IRI)return e;if(e instanceof Ht.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadGroundingByUid(e){let t=await this.findSubjectByUID(e);return t?this.loadGroundingDefinition(t,0):null}async loadGroundingDefinition(e,t){if(t>=kp)return null;let r=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_uid"));if(!r)return null;let i=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let U=await this.resolveLabelByUID(o);if(!U)return this.logger.warn(`Grounding ${r}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=U}if(s===Yx.GroundingType.SERVICE_CALL){let U=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_serviceId"));U&&(o=U)}let l=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetValueRef")),c=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let U=await this.resolveLabelByUID(u);if(!U)return this.logger.warn(`Grounding ${r}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=U}else u&&(f=u);let d=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),h=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_appendExpression")),p=await this.getObsidianWikilinkValue(e,L.Namespace.EXOCMD.term("Grounding_isDefinedBy")),g=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),_=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetClass"));if(_&&!this.looksLikeUUID(_)){let U=await this.findUidByLabel(_);U&&(_=U)}let v=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetPrototype")),w=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_targetFolder")),E=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_linkBackProperty")),I=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_inputSchema")),A=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_incrementBy")),D=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_shiftDelta")),K;if(A!=null&&A!==""){let U=Number.parseInt(String(A),10);Number.isFinite(U)&&(K=U)}let oe=await this.resolvePropertyDefaults(e,r),me=await this.resolveInheritanceRules(e,r),N=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_propertyDefaults"));N!==null&&N!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(r)&&(this.logger.warn(`Grounding ${r}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(r));let Q;s===Yx.GroundingType.COMPOSITE&&(Q=await this.loadCompositeSteps(e,t+1));let ie;if(I)try{let U=JSON.parse(I);U?.properties&&(ie=Object.entries(U.properties).map(([B,tt])=>{let at=tt.type,H=at==="string"?"text":at,De=tt.defaultValue!==void 0?tt.defaultValue:tt.default,Be={name:B,type:H,label:tt.title??B,required:Array.isArray(U.required)&&U.required.includes(B)};return De!=null&&(Be.defaultValue=String(De)),Be}))}catch{}let V=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),Y=V!==null&&String(V).trim().toLowerCase()==="true",re=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_labelTemplate")),G=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_direction")),ne;if(G!=null){let U=String(G).trim().toLowerCase();U==="forward"||U==="rollback"?ne=U:U!==""&&this.logger.warn(`Grounding ${r}: exocmd__Grounding_direction value '${G}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let q={id:r,label:i,type:s,targetProperty:o??void 0,targetValueRef:l??void 0,targetValueLiteral:c??void 0,targetValueSubstitution:f??void 0,serviceCallPayload:d??void 0,appendExpression:h??void 0,sparqlUpdate:g??void 0,steps:Q,targetClass:_??void 0,targetPrototype:v??void 0,targetFolder:w??void 0,linkBackProperty:E??void 0,incrementBy:K,shiftDelta:D??void 0,propertyDefault:oe.length>0?oe:void 0,inheritanceRule:me.length>0?me:void 0,isDefinedBy:p??void 0,prefillLabelWithDate:Y||void 0,labelTemplate:re??void 0,direction:ne};return ie&&(q.inputSchema=ie),q}async loadCompositeSteps(e,t){if(t>=kp)return[];let r=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of r){let o=null;if(s.object instanceof rr.IRI)o=s.object;else if(s.object instanceof Ht.Literal){let c=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(c)}if(!o)continue;let l=await this.loadGroundingDefinition(o,t);l&&i.push(l)}return i}async resolvePropertyDefaults(e,t){let r=await this.resolvePropertyDefaultsForSubject(e,t,L.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,Np.mergePropertyDefaults)(i.propertyDefaults,r):r}async resolvePropertyDefaultsForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[];for(let o of i){let l=await this.resolveRefTripleObject(o.object);if(!l)continue;let c=await this.getObsidianName(l,L.Namespace.EXOCMD.term("PropertyDefault_property"));if(!c){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(c)?await this.resolveLabelByUID(c):c;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${c}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(l,L.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.logger.warn(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await(0,Np.loadUniversalDefault)();if(e)return this._universalCacheValue=e,e;let t=await this.findUniversalSingleton();if(!t)return this._universalCacheValue=null,null;let r=await this.resolvePropertyDefaultsForSubject(t,tA,L.Namespace.EXOCMD.term("Template_propertyDefault")),i=await this.resolveInheritanceRulesForSubject(t,tA,L.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:r,inheritanceRules:i},this._universalCacheValue}async findUniversalSingleton(){let e=L.Namespace.EXOCMD.term("UniversalDefaultTemplate").value,t=await this.tripleStore.match(void 0,L.Namespace.EXO.term("Instance_class"),void 0),r=[];for(let i of t){let s=!1;if(i.object instanceof rr.IRI)s=i.object.value===e||i.object.value.includes(eA);else if(i.object instanceof Ht.Literal){let o=this.unwrapWikilink(i.object.value);s=o==="exocmd__UniversalDefaultTemplate"||o===eA}s&&i.subject instanceof rr.IRI&&r.push(i.subject)}return r.length===0?null:(r.length===1||(r.sort((i,s)=>i.value.localeCompare(s.value)),this.logger.warn(`Multiple UniversalDefaultTemplate singletons found (${r.length}); selecting deterministically by lexicographic UID order: ${r[0].value}`)),r[0])}async resolveInheritanceRules(e,t){let r=await this.resolveInheritanceRulesForSubject(e,t,L.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,Np.mergeInheritanceRules)(i.inheritanceRules,r):r}async resolveInheritanceRulesForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[],o=t;for(let l of i){let c=await this.resolveRefTripleObject(l.object);if(!c)continue;let u=await this.resolveLabelRef(c,L.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(c,L.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(c,L.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),h;if(d.length>0){let E=await this.resolveLabelRef(c,L.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!E){this.logger.warn(`Grounding ${o}: InheritanceRule has exocmd__InheritanceRule_targetClassCondition triple but ref is unresolvable \u2014 entire rule skipped (would otherwise apply unconditionally, broadening scope).`);continue}h=E}let p=await this.tripleStore.match(c,L.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),g=[],_=!1;for(let E of p){let I=null;if(E.object instanceof rr.IRI?I=this.iriToObsidianName(E.object.value)??E.object.value:E.object instanceof Ht.Literal&&(I=this.unwrapWikilink(E.object.value)),!I){_=!0;continue}let A=this.looksLikeUUID(I)?await this.resolveLabelByUID(I):I;if(!A){_=!0;continue}g.push(A)}if(_){this.logger.warn(`Grounding ${o}: InheritanceRule has unresolvable exocmd__InheritanceRule_targetClassExclusion entry \u2014 entire rule skipped (would otherwise expand scope by silently dropping the excluded class).`);continue}let v=await this.getLiteralValue(c,L.Namespace.EXOCMD.term("InheritanceRule_priority")),w=50;if(v!==null&&v!==""){let E=Number.parseInt(String(v),10);Number.isFinite(E)&&(w=E)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:h,targetClassExclusion:g,priority:w})}return s}async resolveRefTripleObject(e){if(e instanceof rr.IRI)return e;if(e instanceof Ht.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let r=await this.getObsidianName(e,t);return r?this.looksLikeUUID(r)?this.resolveLabelByUID(r):r:null}async resolvePropertyDefaultValue(e,t,r){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);return i?await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,r):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,r,void 0):`"[[${e}]]"`:`"[[${e}]]"`}async dispatchSubstitutionToken(e,t,r,i,s){let o=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let l=o.trim();return Jx.has(l)?s!==void 0?$5(l,t,s):V5.has(l)?u1.parseTimeResolve(l):j5(l,t):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${l}' \u2014 falling back to wikilink form. Known ids: ${Array.from(Jx).join(", ")}.`),`"[[${t}]]"`)}static parseTimeResolve(e){let t=new Date,r=a(i=>i<10?`0${i}`:String(i),"pad");switch(e){case"today":return t.toISOString().slice(0,10);case"todayStart":return new Date(new Date().setHours(0,0,0,0)).toISOString();case"nowTimestamp":return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}`;case"nowDate":return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}`;case"nowYear":return String(t.getFullYear());case"nowMonth":return r(t.getMonth()+1);default:return""}}async resolveTokenInvocation(e,t,r,i){let s=await this.getObsidianName(e,L.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let l=await this.findSubjectByUID(s);return l?this.dispatchSubstitutionToken(l,s,r,i,o):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,L.Namespace.EXO.term("Instance_class"),void 0);for(let r of t)if(r.object instanceof rr.IRI){if(r.object.value===U5||r.object.value.includes(Zx))return!0}else if(r.object instanceof Ht.Literal){let i=this.unwrapWikilink(r.object.value);if(i==="exocmd__TokenInvocation"||i===Zx)return!0}return!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,L.Namespace.EXO.term("Instance_class"),void 0);for(let r of t)if(r.object instanceof rr.IRI){if(r.object.value===M5||r.object.value.includes(Kx))return!0}else if(r.object instanceof Ht.Literal){let i=this.unwrapWikilink(r.object.value);if(i==="exocmd__SubstitutionToken"||i===Kx)return!0}return!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let r=t[0].object;if(r instanceof rr.IRI)return(0,Xx.resolveGroundingTypeFromIRI)(r.value);if(r instanceof Ht.Literal){let i=r.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,Xx.resolveGroundingTypeFromIRI)(`obsidian://vault/${s[1].toLowerCase()}.md`):(this.logger.warn(`[exocmd-grounding-type-literal-form] legacy literal-string form '${i}' for exocmd__Grounding_type on <${e.value}>. Migrate to wikilink form per RFC 9d20c91f Phase 3.`),null)}return null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let r=await this.tripleStore.findSubjectsByUUID(e);if(r.length>0)return r[0]}let t=await this.tripleStore.match(void 0,L.Namespace.EXO.term("Asset_uid"),void 0);for(let r of t)if(r.object instanceof Ht.Literal&&r.object.value===e)return r.subject;return null}async getLiteralValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Ht.Literal||i instanceof rr.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);return t?this.getLiteralValue(t,L.Namespace.EXO.term("Asset_label")):null}async getClassAncestors(e){let t=this._ancestorCache.get(e);if(t)return t;let r=new Set,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),l=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_uid"));l&&o.add(l);let c=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_label"));c&&o.add(c);let u=[{fileIRI:s,depth:0}];for(;u.length>0;){let d=u.shift();if(!d)break;let{fileIRI:h,depth:p}=d;if(p>=kp||i.has(h.value))continue;i.add(h.value);let g=await this.tripleStore.match(h,L.Namespace.EXO.term("Class_superClass"),void 0);for(let _ of g){let v=_.object;if(!(v instanceof rr.IRI))continue;let w=v.value.startsWith("obsidian://vault/"),E=this.iriToObsidianName(v.value);E&&!o.has(E)&&!r.has(E)&&r.add(E);let I=null;if(w?I=v:E&&(I=await this.resolveClassFileIRI(E)),!I)continue;let A=await this.getLiteralValue(I,L.Namespace.EXO.term("Asset_uid"));A&&!o.has(A)&&!r.has(A)&&r.add(A),i.has(I.value)||u.push({fileIRI:I,depth:p+1})}}let f=Array.from(r);return this._ancestorCache.set(e,f),f}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){let t=await this.tripleStore.match(void 0,L.Namespace.EXO.term("Asset_label"),void 0);for(let r of t)if(r.object instanceof Ht.Literal&&r.object.value===e&&r.subject instanceof rr.IRI){let i=await this.tripleStore.match(r.subject,L.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Ht.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof rr.IRI){let s=await this.tripleStore.match(i,L.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Ht.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Ht.Literal?this.normalizeWikilink(i.value):null}async getLinkedValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Ht.Literal?this.normalizeWikilink(i.value):i instanceof rr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Ht.Literal?this.unwrapWikilink(i.value):i instanceof rr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let r=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(r)return r[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof Ht.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof rr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let r=t[1],i=await this.findSubjectByUID(r);if(!i)return e;let s=await this.getLiteralValue(i,L.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${r}]]`,`[[${r}|${s}]]`):e}iriToObsidianName(e){let t=e.match(/^https:\/\/exocortex\.my\/ontology\/([a-z][a-zA-Z0-9]*)#([^#]+)$/);if(t){let[,i,s]=t;return`${i}__${s}`}let r=e.match(/\/([^/]+)\.md$/);return r?r[1]:null}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(0,r):t}};zs.CommandResolver=f1;zs.CommandResolver=f1=u1=P5([(0,F5.injectable)(),O5("design:paramtypes",[Object,Object])],f1)});var h1=S(d1=>{"use strict";Object.defineProperty(d1,"__esModule",{value:!0});d1.validateExoQLAllowlist=B5;var Mp=tf();function B5(n){if(!n||typeof n!="object")return;let e=n;if(e.type==="update"){let t=n.updates??[];for(let r of t)if(r?.type==="load")throw new Mp.ExoQLForbiddenKeywordError("LOAD");throw new Mp.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,r=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||r)throw new Mp.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)jp(t);if(Array.isArray(e.template))for(let t of e.template)jp(t)}}a(B5,"validateExoQLAllowlist");function jp(n){if(!n||typeof n!="object")return;if(n.type==="service")throw new Mp.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(n.patterns))for(let t of n.patterns)jp(t);let e=n.where;if(Array.isArray(e))for(let t of e)jp(t)}a(jp,"walkPatternForBannedKeywords")});var p1=S($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});$p.DEFAULT_EVAL_CONFIG=void 0;$p.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var g1=S(m1=>{"use strict";Object.defineProperty(m1,"__esModule",{value:!0});m1.evaluateWithExoEval=Y5;var G5=$l(),q5=Vl(),W5=lc(),z5=h1(),H5=p1(),Q5=tf();async function Y5(n,e={}){if(typeof n!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let r=new G5.ExoQLParser().parse(n);if((0,z5.validateExoQLAllowlist)(r),!{...H5.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new Q5.ExoQLEvalDisabledError;let s="queryType"in r&&typeof r.queryType=="string"?r.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let l=new q5.ExoQLAlgebraTranslator().translate(r),c=new W5.ExoQLQueryExecutor(e.store);return c.isAskQuery(l)?{kind:"ask",result:await c.executeAsk(l)}:c.isConstructQuery(l)?{kind:"construct",triples:await c.executeConstruct(l)}:{kind:"select",rows:await c.executeAll(l)}}a(Y5,"evaluateWithExoEval")});var nf=S(Up=>{"use strict";Object.defineProperty(Up,"__esModule",{value:!0});Up.liveClock=X5;Up.frozenClock=K5;function X5(){return{now:a(()=>new Date,"now")}}a(X5,"liveClock");function K5(n){let e=new Date(n);return{now:a(()=>new Date(e.getTime()),"now")}}a(K5,"frozenClock")});var iA=S(Hs=>{"use strict";var J5=Hs&&Hs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Z5=Hs&&Hs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},sf;Object.defineProperty(Hs,"__esModule",{value:!0});Hs.PreconditionEvaluator=void 0;var e6=Oe(),t6=$l(),r6=Vl(),nA=lc(),n6=g1(),i6=nf(),of=sf=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,r){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=r?.clock??(0,i6.liveClock)()}async evaluate(e,t,r){return e?e.sparqlAsk?this.evaluateSparqlAsk(e.sparqlAsk,t):e.query?this.evaluateQueryRef(e.query,t):e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,r):!0:!0}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let r=await this.queryBodyResolver.resolveSparql(e);if(!r)return!1;let i=this.substituteVariables(r,t),s=await(0,n6.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,r){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,r):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,sf.SENTINEL_IRI),i=new t6.ExoQLParser().parse(t),o=new r6.ExoQLAlgebraTranslator().translate(i);return new nA.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,r){let i=this.hostFunctions.get(e);if(!i)return!0;let s=r?{...r,targetIRI:t}:{targetIRI:t};return i(s)}async evaluateSparqlAsk(e,t){try{let r=this.askCache.get(e);if(r===void 0){let o=this.compileAsk(e);if(!o)return!1;r=o,this.askCache.set(e,r)}let i=JSON.parse(JSON.stringify(r).replaceAll(sf.SENTINEL_IRI,t));return await new nA.ExoQLQueryExecutor(this.tripleStore).executeAsk(i)}catch{return!1}}substituteVariables(e,t){let r=this.clock.now(),i=r.toISOString(),s=i.slice(0,10),o=new Date(r.getTime()+sf.ALMATY_OFFSET_MS),l=o.getUTCFullYear(),c=o.getUTCMonth(),u=o.getUTCDate(),f=o.getUTCDay(),h=new Date(Date.UTC(l,c,u-1)).toISOString().slice(0,10),p=(f+6)%7,g=new Date(Date.UTC(l,c,u-p)),_=g.toISOString().slice(0,10),w=new Date(g.getTime()-10080*60*1e3).toISOString().slice(0,10),E=`${l}-${String(c+1).padStart(2,"0")}-01`,I=c===0?11:c-1,D=`${c===0?l-1:l}-${String(I+1).padStart(2,"0")}-01`,K=`${l}-01-01`;return e.replace(/\$target/g,`<${t}>`).replace(/\$now/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday/g,`"${h}"^^xsd:date`).replace(/\$thisWeekStart/g,`"${_}"^^xsd:date`).replace(/\$lastWeekStart/g,`"${w}"^^xsd:date`).replace(/\$thisMonthStart/g,`"${E}"^^xsd:date`).replace(/\$lastMonthStart/g,`"${D}"^^xsd:date`).replace(/\$thisYearStart/g,`"${K}"^^xsd:date`).replace(/\$today/g,`"${s}"^^xsd:date`)}};Hs.PreconditionEvaluator=of;of.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";of.ALMATY_OFFSET_MS=300*60*1e3;Hs.PreconditionEvaluator=of=sf=J5([(0,e6.injectable)(),Z5("design:paramtypes",[Object,Object,Object])],of)});var sA=S(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.hasUidFilename=Qs.hasNonUidFilename=void 0;Qs.registerDefaultHostFunctions=a6;var s6=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");Qs.hasNonUidFilename=s6;var o6=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");Qs.hasUidFilename=o6;function a6(n){n.registerHostFunction("hasNonUidFilename",Qs.hasNonUidFilename),n.registerHostFunction("hasUidFilename",Qs.hasUidFilename)}a(a6,"registerDefaultHostFunctions")});var Bp=S(Vp=>{"use strict";Object.defineProperty(Vp,"__esModule",{value:!0});Vp.liveUidGenerator=l6;Vp.seededUidGenerator=u6;var y1=mi();function l6(){return{next:a(()=>(0,y1.v4)(),"next")}}a(l6,"liveUidGenerator");var c6="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function u6(n){let e=0,t=(0,y1.v5)(n,c6);return{next:a(()=>{let r=`${n}#${e}`;return e+=1,(0,y1.v5)(r,t)},"next")}}a(u6,"seededUidGenerator")});var af=S(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.registerOrderSpecLoader=f6;uc.clearOrderSpecLoader=d6;uc.loadDefaultSpec=h6;uc.orderProperties=p6;var Gp=null,jo,qp=!1;function f6(n){Gp=n,jo=void 0,qp=!1}a(f6,"registerOrderSpecLoader");function d6(){Gp=null,jo=void 0,qp=!1}a(d6,"clearOrderSpecLoader");function h6(){if(jo!==void 0)return jo;if(!Gp)return jo=null,null;try{jo=Gp()}catch(n){qp||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",n),qp=!0),jo=null}return jo}a(h6,"loadDefaultSpec");function p6(n,e){if(!e||e.head.length===0&&e.tail.length===0)return n;let t=Object.keys(n),r=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),l=t.filter(u=>!r.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&l.sort((u,f)=>u.localeCompare(f));let c={};for(let u of s)c[u]=n[u];for(let u of l)c[u]=n[u];for(let u of o)c[u]=n[u];return c}a(p6,"orderProperties")});var cs=S(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});Wp.FrontmatterService=void 0;var oA=af(),lf=class n{static{a(this,"FrontmatterService")}parse(e){let t=e.match(n.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let r={},i=t.content.split(/\r?\n/),s=null,o=null,l=a(()=>{s!==null&&o!==null&&(r[s]=o),s=null,o=null},"flushArray");for(let c of i){let u=/^ {2}- (.*)$/.exec(c);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}l();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(c);if(!f)continue;let d=f[1].trim(),h=f[2].trim();h===""?(s=d,o=[]):r[d]=h}return l(),r}updateProperty(e,t,r){t=n.normalizeIRI(t),typeof r=="string"&&(r=n.normalizeIRIValue(r));let i=this.parse(e),s=this.serializeValue(t,r);if(!i.exists)return`---
70
+ ${r}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(r=>this.generateExpression(r)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),r=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${r})`:`${t} IN (${r})`}default:throw new sc(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let r of e.triples)this.collectVariablesFromTriple(r,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let r of e.variables)t.add(r);break;case"project":for(let r of e.variables)t.add(r);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let r of e.variables)t.add(r);for(let r of e.aggregates)t.add(r.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let r of e.operands)this.collectVariablesFromExpression(r,t);break;case"function":case"functionCall":for(let r of e.args)this.collectVariablesFromExpression(r,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let r of e.list)this.collectVariablesFromExpression(r,t);break}}};oc.SPARQLGenerator=c1});var lc=S(On=>{"use strict";var h5=On&&On.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),p5=On&&On.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),Qx=On&&On.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&h5(t,e,r[i]);return p5(t,e),t}})();Object.defineProperty(On,"__esModule",{value:!0});On.QueryExecutor=On.ExoQLQueryExecutor=On.QueryExecutorError=void 0;var m5=Cb(),g5=Ip(),y5=Qb(),_5=Xb(),b5=Mx(),S5=$x(),w5=Bx(),v5=o1(),E5=qx(),T5=zx(),I5=Hx(),x5=Ae(),A5=$e(),R5=_p(),jr="http://www.w3.org/2001/XMLSchema#",C5=new Set([`${jr}integer`,`${jr}decimal`,`${jr}float`,`${jr}double`,`${jr}nonPositiveInteger`,`${jr}negativeInteger`,`${jr}long`,`${jr}int`,`${jr}short`,`${jr}byte`,`${jr}nonNegativeInteger`,`${jr}unsignedLong`,`${jr}unsignedInt`,`${jr}unsignedShort`,`${jr}unsignedByte`,`${jr}positiveInteger`]),ac=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};On.QueryExecutorError=ac;var Lp=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){this.tripleStore=e,this.bgpExecutor=new m5.BGPExecutor(e),this.filterExecutor=new g5.FilterExecutor,this.optionalExecutor=new y5.OptionalExecutor,this.unionExecutor=new _5.UnionExecutor,this.minusExecutor=new b5.MinusExecutor,this.valuesExecutor=new S5.ValuesExecutor,this.aggregateExecutor=new w5.AggregateExecutor,this.constructExecutor=new v5.ConstructExecutor,this.serviceExecutor=new E5.ServiceExecutor(t.serviceConfig),this.graphExecutor=new T5.GraphExecutor(e),this.sparqlGenerator=new I5.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(r,i)=>this.evaluateExistsPattern(r,i)),this.filterExecutor.setTripleStore(e)}async evaluateExistsPattern(e,t){for await(let r of this.execute(e))if(t.merge(r)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new ac(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let r=new Set;for(let o of t)for(let l of o.variables())r.add(l);let i=this.collectOperationVariables(e.right);if([...r].some(o=>i.has(o)))for(let o of t){let l=this.substituteVariables(e.right,o);for await(let c of this.execute(l)){let u=o.merge(c);u!==null&&(yield u)}}else{let o=[];for await(let l of this.execute(e.right))o.push(l);for(let l of t)for(let c of o){let u=l.merge(c);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>Qx(ss())),r=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(r.has(o)){let l=i.get(o);l!==void 0&&s.set(o,l)}yield s}}async*executeOrderBy(e){let t=[];for await(let r of this.execute(e.input))t.push(r);t.sort((r,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,r),l=this.getExpressionValue(s.expression,i),c=0;if(o===void 0&&l===void 0?c=0:o===void 0?c=1:l===void 0?c=-1:typeof o=="number"&&typeof l=="number"?c=o-l:c=String(o).localeCompare(String(l)),s.descending&&(c=-c),c!==0)return c}return 0});for(let r of t)yield r}async*executeSlice(e){let t=0,r=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=r){if(i!==void 0&&t-r>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeReduced(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let r=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of r)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of r)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let r of this.execute(e.input)){let i=r.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,r):this.evaluateExtendExpression(e.expression,r);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let r of this.execute(e.left))t.push(r);for(let r of t){let i=this.substituteVariables(e.right,r);for await(let s of this.execute(i)){let o=r.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let r=JSON.parse(JSON.stringify(e));return this.substituteInOperation(r,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let r=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(r.input&&(r.input=this.substituteInOperation(r.input,t)),r.left&&(r.left=this.substituteInOperation(r.left,t)),r.right&&(r.right=this.substituteInOperation(r.right,t)),r.pattern&&(r.pattern=this.substituteInOperation(r.pattern,t)),r.query&&(r.query=this.substituteInOperation(r.query,t)),r.where&&(r.where=this.substituteInOperation(r.where,t)),r.expression&&this.substituteInExpression(r.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let r of e.operands)this.substituteInExpression(r,t);if(e.args)for(let r of e.args)this.substituteInExpression(r,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let r of e.list)this.substituteInExpression(r,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let r=t.get(e.value);if(r!=null){let i=r;if(r instanceof x5.IRI||i.termType==="NamedNode")return{type:"iri",value:r.value};if(i.termType==="Literal"||typeof i.value=="string")return{type:"literal",value:i.value,datatype:i.datatype?.value??i._datatype?.value,language:i.language??i._language}}}return e}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(r,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{r.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(r,i):yield*this.execute(r)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:r}=await Promise.resolve().then(()=>Qx(ss()));yield new r;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let r=t.get(e.name);if(!r)return;if(r instanceof A5.Literal){let i=r.datatype?.value;if(i===`${jr}dayTimeDuration`)try{return R5.DateTimeFunctions.parseDayTimeDuration(r.value)}catch{return r.value}if(i&&C5.has(i)){let s=parseFloat(r.value);if(!Number.isNaN(s))return s}return r.value}return r.value??r.id??String(r)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="bgp"&&r.triples)for(let i of r.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(r.type==="values"&&r.variables)for(let i of r.variables)t.add(i);r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.type==="extend"&&r.variable&&t.add(r.variable),r.input&&this.collectVarsFromOperation(r.input,t),r.left&&this.collectVarsFromOperation(r.left,t),r.right&&this.collectVarsFromOperation(r.right,t),r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.query&&this.collectVarsFromOperation(r.query,t),r.where&&this.collectVarsFromOperation(r.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let r=e;r.type==="variable"&&t.add(r.value),r.type==="quoted"&&(this.collectVarsFromElement(r.subject,t),this.collectVarsFromElement(r.predicate,t),this.collectVarsFromElement(r.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="variable"&&r.name&&t.add(r.name),r.type==="exists"&&r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.left&&this.collectVarsFromExpressionTree(r.left,t),r.right&&this.collectVarsFromExpressionTree(r.right,t),r.operands)for(let i of r.operands)this.collectVarsFromExpressionTree(i,t);if(r.args)for(let i of r.args)this.collectVarsFromExpressionTree(i,t);if(r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.list)for(let i of r.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new ac("executeConstruct requires a CONSTRUCT operation");let t=await this.executeAll(e.where);return this.constructExecutor.execute(e.template,t)}isAskQuery(e){return e.type==="ask"}async executeAsk(e){if(e.type!=="ask")throw new ac("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};On.ExoQLQueryExecutor=Lp;On.QueryExecutor=Lp});var rA=S(zs=>{"use strict";var P5=zs&&zs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},O5=zs&&zs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},u1;Object.defineProperty(zs,"__esModule",{value:!0});zs.CommandResolver=void 0;var F5=Oe(),D5=Cl(),rr=Ae(),Ht=$e(),L=er(),Yx=Io(),Xx=Cu(),cc=x0(),Np=GI(),L5=$l(),N5=Vl(),k5=lc(),kp=10,Kx="08cec529-90eb-4d43-88de-ceecccea12b0",M5=L.Namespace.EXOCMD.term("SubstitutionToken").value,Jx=new Set(["today","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","labelAsArray","groundingTargetClass"]);function j5(n,e){return`__SUBSTITUTE__${n}__${e}__`}a(j5,"buildSubstitutionMarker");function $5(n,e,t){let r=Buffer.from(t,"utf-8").toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${n}__${e}__${r}__`}a($5,"buildParameterisedMarker");var Zx="3f28af98-c031-4718-8ba2-44ad0b012c52",U5=L.Namespace.EXOCMD.term("TokenInvocation").value,eA="29e2c8f8-2d27-4e58-b467-2e85d46f8122",tA="universal-default-template",V5=new Set(["today","todayStart","nowTimestamp","nowDate","nowYear","nowMonth"]),f1=u1=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null,(0,Np.clearUniversalDefault)()}constructor(e,t=D5.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,r){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${r??""}`,o=this.multiCache.get(s);if(o)return o;let l=new Set,c=[];for(let u of t){let f=await this.resolveForAsset(e,u,r);for(let d of f)l.has(d.binding.id)||(l.add(d.binding.id),c.push(d))}return c.sort((u,f)=>{let d=this.getBindingPriority(u.binding),h=this.getBindingPriority(f.binding);return d!==h?d-h:(u.binding.order??100)-(f.binding.order??100)}),this.multiCache.set(s,c),c}async resolveForAsset(e,t,r){let i=`${e}:${t}:${r??""}`,s=this.cache.get(i);if(s)return s;let o=await this.findBindings(t,r,e),l=[];for(let c of o){let u=await this.loadCommand(c.commandRef,{targetClass:c.targetClass});if(!u)continue;let f=c.precondition?{...u,precondition:c.precondition}:u;l.push({command:f,binding:c})}return l.sort((c,u)=>{let f=this.getBindingPriority(c.binding),d=this.getBindingPriority(u.binding);return f!==d?f-d:(c.binding.order??100)-(u.binding.order??100)}),this.cache.set(i,l),l}async loadCommand(e,t){let r=await this.findSubjectByUID(e);if(!r||(await this.tripleStore.match(r,L.Namespace.RDF.term("type"),L.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(r,L.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_labelTemplate")),l=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_icon")),c=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(r,L.Namespace.EXOCMD.term("Command_openInSameTab")),h=d!==null&&String(d).trim().toLowerCase()==="true",p=await this.loadLinkedPrecondition(r),g=await this.loadLinkedGrounding(r,0,t);return g?{id:e,name:s,labelTemplate:o??void 0,icon:l??void 0,precondition:p??void 0,grounding:g,confirmMessage:c??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:h||void 0}:null}async findBindings(e,t,r){let i=await this.tripleStore.match(void 0,L.Namespace.RDF.term("type"),L.Namespace.EXOCMD.term("CommandBinding")),s=[];for(let o of i){let l=o.subject,c=await this.loadBindingDefinition(l);c&&this.bindingMatches(c,e,t,r)&&s.push(c)}return s}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,L.Namespace.RDF.term("type"),L.Namespace.EXOCMD.term("Command")),t=[],r=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let l=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_uid"));if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let c=await this.loadCommand(l);if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command ${l} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Command_cliName")),d=u??f??l;if(r.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${l}`);continue}r.add(d),t.push({command:c,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorCache.clear()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let r=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let l=await this.evaluateSelectSnippet(o,t);r=r.replace(s,l)}return r}extractPlaceholders(e){let t=[],r=0;for(;r<e.length;)if(e[r]==="{"){let i=1,s=r+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(r,s),l=e.slice(r+1,s-1);t.push({full:o,body:l})}r=s}else r++;return t}async evaluateSelectSnippet(e,t){try{let r=e.replace(/\$target/g,`<${t}>`),s=new L5.ExoQLParser().parse(r),l=new N5.ExoQLAlgebraTranslator().translate(s),u=await new k5.ExoQLQueryExecutor(this.tripleStore).executeAll(l);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let h=f.get(d[0]);return h?h instanceof Ht.Literal||h instanceof rr.IRI?h.value:String(h):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,L.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,L.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,L.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),l=await this.getLinkedValue(e,L.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!l)return null;let c=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,h=await this.loadLinkedPreconditionFromProperty(e,L.Namespace.EXOCMD.term("CommandBinding_precondition")),p=await this.loadLinkedStyle(e,t);return{id:t,label:r,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:l??void 0,position:c??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:h??void 0,style:p??void 0}}async loadLinkedStyle(e,t){let r=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(r.length>0){let s=r[0].object,o=null;if(s instanceof rr.IRI)o=s;else if(s instanceof Ht.Literal){let l=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(l)}if(o){let l=await this.loadStyleAsset(o);if(l)return l}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBinding_variant"));if(i!==null){let s=this.coerceVariant(i,t);if(s!==void 0)return{id:`inline:${t}`,label:"",variant:s,inline:!0}}return null}async loadStyleAsset(e){let t=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),l=this.coerceBoolean(o),c=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=c!==null?this.coerceLabelClass(c,t):void 0,f=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),h=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),p=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("CommandBindingStyle_source")),g=p!==null?this.coerceStyleSource(p,t):void 0;return{id:t,label:r,variant:s,showIcon:l,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:h??void 0,source:g,inline:!1}}coerceVariant(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(cc.COMMAND_VARIANT_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${r}" not in whitelist [${cc.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(cc.LABEL_CLASS_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${r}" not in whitelist [${cc.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(cc.STYLE_SOURCE_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle source "${r}" not in whitelist [${cc.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,r,i){return!!(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i)||e.targetPrototype&&r&&this.matchesReference(e.targetPrototype,r)||e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let r=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(r===i)return!0;let s=this.extractPathBasename(i);if(s&&s===r)return!0;let o=this.extractPathBasename(r);if(o&&o===i)return!0;let l=this.extractAlias(t);if(l&&r===l)return!0;let c=this.extractAlias(e);return!!(c&&c===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(r+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,L.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object,s=null;if(i instanceof rr.IRI)s=i;else if(i instanceof Ht.Literal){let h=this.normalizeWikilink(i.value);s=await this.findSubjectByUID(h)}if(!s)return null;let o=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_uid")),l=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_label"))??"",c=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Precondition_sparqlAsk")),u=await this.getLiteralValue(s,L.Namespace.EXOCMD.term("Precondition_hostFunction")),f=await this.tripleStore.match(s,L.Namespace.EXOCMD.term("Precondition_query"),void 0),d;if(f.length>0){let h=f[0].object;if(h instanceof rr.IRI){let p=await this.getLiteralValue(h,L.Namespace.EXO.term("Asset_uid"));p&&(d=p)}else h instanceof Ht.Literal&&(d=this.normalizeWikilink(h.value))}return!o||!c&&!u&&!d?null:{id:o,label:l,...c&&{sparqlAsk:c},...u&&{hostFunction:u},...d&&{query:d}}}async loadLinkedGrounding(e,t,r){if(t>=kp)return null;let i=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!r?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let l=await this.resolveGroundingRef(o.object);if(!l)continue;let c=await this.getObsidianName(l,L.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(c&&this.matchesReference(c,r.targetClass))return this.loadGroundingDefinition(l,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${r.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof rr.IRI)return e;if(e instanceof Ht.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadGroundingByUid(e){let t=await this.findSubjectByUID(e);return t?this.loadGroundingDefinition(t,0):null}async loadGroundingDefinition(e,t){if(t>=kp)return null;let r=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_uid"));if(!r)return null;let i=await this.getLiteralValue(e,L.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let U=await this.resolveLabelByUID(o);if(!U)return this.logger.warn(`Grounding ${r}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=U}if(s===Yx.GroundingType.SERVICE_CALL){let U=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_serviceId"));U&&(o=U)}let l=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetValueRef")),c=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let U=await this.resolveLabelByUID(u);if(!U)return this.logger.warn(`Grounding ${r}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=U}else u&&(f=u);let d=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),h=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_appendExpression")),p=await this.getObsidianWikilinkValue(e,L.Namespace.EXOCMD.term("Grounding_isDefinedBy")),g=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),_=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetClass"));if(_&&!this.looksLikeUUID(_)){let U=await this.findUidByLabel(_);U&&(_=U)}let v=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_targetPrototype")),w=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_targetFolder")),E=await this.getObsidianName(e,L.Namespace.EXOCMD.term("Grounding_linkBackProperty")),I=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_inputSchema")),O=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_incrementBy")),C=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_shiftDelta")),H;if(O!=null&&O!==""){let U=Number.parseInt(String(O),10);Number.isFinite(U)&&(H=U)}let ne=await this.resolvePropertyDefaults(e,r),de=await this.resolveInheritanceRules(e,r),N=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_propertyDefaults"));N!==null&&N!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(r)&&(this.logger.warn(`Grounding ${r}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(r));let Y;s===Yx.GroundingType.COMPOSITE&&(Y=await this.loadCompositeSteps(e,t+1));let se;if(I)try{let U=JSON.parse(I);U?.properties&&(se=Object.entries(U.properties).map(([B,tt])=>{let at=tt.type,Q=at==="string"?"text":at,De=tt.defaultValue!==void 0?tt.defaultValue:tt.default,Be={name:B,type:Q,label:tt.title??B,required:Array.isArray(U.required)&&U.required.includes(B)};return De!=null&&(Be.defaultValue=String(De)),Be}))}catch{}let V=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),X=V!==null&&String(V).trim().toLowerCase()==="true",re=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_labelTemplate")),G=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("Grounding_direction")),ie;if(G!=null){let U=String(G).trim().toLowerCase();U==="forward"||U==="rollback"?ie=U:U!==""&&this.logger.warn(`Grounding ${r}: exocmd__Grounding_direction value '${G}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let q={id:r,label:i,type:s,targetProperty:o??void 0,targetValueRef:l??void 0,targetValueLiteral:c??void 0,targetValueSubstitution:f??void 0,serviceCallPayload:d??void 0,appendExpression:h??void 0,sparqlUpdate:g??void 0,steps:Y,targetClass:_??void 0,targetPrototype:v??void 0,targetFolder:w??void 0,linkBackProperty:E??void 0,incrementBy:H,shiftDelta:C??void 0,propertyDefault:ne.length>0?ne:void 0,inheritanceRule:de.length>0?de:void 0,isDefinedBy:p??void 0,prefillLabelWithDate:X||void 0,labelTemplate:re??void 0,direction:ie};return se&&(q.inputSchema=se),q}async loadCompositeSteps(e,t){if(t>=kp)return[];let r=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of r){let o=null;if(s.object instanceof rr.IRI)o=s.object;else if(s.object instanceof Ht.Literal){let c=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(c)}if(!o)continue;let l=await this.loadGroundingDefinition(o,t);l&&i.push(l)}return i}async resolvePropertyDefaults(e,t){let r=await this.resolvePropertyDefaultsForSubject(e,t,L.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,Np.mergePropertyDefaults)(i.propertyDefaults,r):r}async resolvePropertyDefaultsForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[];for(let o of i){let l=await this.resolveRefTripleObject(o.object);if(!l)continue;let c=await this.getObsidianName(l,L.Namespace.EXOCMD.term("PropertyDefault_property"));if(!c){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(c)?await this.resolveLabelByUID(c):c;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${c}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(l,L.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.logger.warn(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await(0,Np.loadUniversalDefault)();if(e)return this._universalCacheValue=e,e;let t=await this.findUniversalSingleton();if(!t)return this._universalCacheValue=null,null;let r=await this.resolvePropertyDefaultsForSubject(t,tA,L.Namespace.EXOCMD.term("Template_propertyDefault")),i=await this.resolveInheritanceRulesForSubject(t,tA,L.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:r,inheritanceRules:i},this._universalCacheValue}async findUniversalSingleton(){let e=L.Namespace.EXOCMD.term("UniversalDefaultTemplate").value,t=await this.tripleStore.match(void 0,L.Namespace.EXO.term("Instance_class"),void 0),r=[];for(let i of t){let s=!1;if(i.object instanceof rr.IRI)s=i.object.value===e||i.object.value.includes(eA);else if(i.object instanceof Ht.Literal){let o=this.unwrapWikilink(i.object.value);s=o==="exocmd__UniversalDefaultTemplate"||o===eA}s&&i.subject instanceof rr.IRI&&r.push(i.subject)}return r.length===0?null:(r.length===1||(r.sort((i,s)=>i.value.localeCompare(s.value)),this.logger.warn(`Multiple UniversalDefaultTemplate singletons found (${r.length}); selecting deterministically by lexicographic UID order: ${r[0].value}`)),r[0])}async resolveInheritanceRules(e,t){let r=await this.resolveInheritanceRulesForSubject(e,t,L.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,Np.mergeInheritanceRules)(i.inheritanceRules,r):r}async resolveInheritanceRulesForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[],o=t;for(let l of i){let c=await this.resolveRefTripleObject(l.object);if(!c)continue;let u=await this.resolveLabelRef(c,L.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(c,L.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(c,L.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),h;if(d.length>0){let E=await this.resolveLabelRef(c,L.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!E){this.logger.warn(`Grounding ${o}: InheritanceRule has exocmd__InheritanceRule_targetClassCondition triple but ref is unresolvable \u2014 entire rule skipped (would otherwise apply unconditionally, broadening scope).`);continue}h=E}let p=await this.tripleStore.match(c,L.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),g=[],_=!1;for(let E of p){let I=null;if(E.object instanceof rr.IRI?I=this.iriToObsidianName(E.object.value)??E.object.value:E.object instanceof Ht.Literal&&(I=this.unwrapWikilink(E.object.value)),!I){_=!0;continue}let O=this.looksLikeUUID(I)?await this.resolveLabelByUID(I):I;if(!O){_=!0;continue}g.push(O)}if(_){this.logger.warn(`Grounding ${o}: InheritanceRule has unresolvable exocmd__InheritanceRule_targetClassExclusion entry \u2014 entire rule skipped (would otherwise expand scope by silently dropping the excluded class).`);continue}let v=await this.getLiteralValue(c,L.Namespace.EXOCMD.term("InheritanceRule_priority")),w=50;if(v!==null&&v!==""){let E=Number.parseInt(String(v),10);Number.isFinite(E)&&(w=E)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:h,targetClassExclusion:g,priority:w})}return s}async resolveRefTripleObject(e){if(e instanceof rr.IRI)return e;if(e instanceof Ht.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let r=await this.getObsidianName(e,t);return r?this.looksLikeUUID(r)?this.resolveLabelByUID(r):r:null}async resolvePropertyDefaultValue(e,t,r){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);return i?await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,r):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,r,void 0):`"[[${e}]]"`:`"[[${e}]]"`}async dispatchSubstitutionToken(e,t,r,i,s){let o=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let l=o.trim();return Jx.has(l)?s!==void 0?$5(l,t,s):V5.has(l)?u1.parseTimeResolve(l):j5(l,t):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${l}' \u2014 falling back to wikilink form. Known ids: ${Array.from(Jx).join(", ")}.`),`"[[${t}]]"`)}static parseTimeResolve(e){let t=new Date,r=a(i=>i<10?`0${i}`:String(i),"pad");switch(e){case"today":return t.toISOString().slice(0,10);case"todayStart":return new Date(new Date().setHours(0,0,0,0)).toISOString();case"nowTimestamp":return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}`;case"nowDate":return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}`;case"nowYear":return String(t.getFullYear());case"nowMonth":return r(t.getMonth()+1);default:return""}}async resolveTokenInvocation(e,t,r,i){let s=await this.getObsidianName(e,L.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,L.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let l=await this.findSubjectByUID(s);return l?this.dispatchSubstitutionToken(l,s,r,i,o):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,L.Namespace.EXO.term("Instance_class"),void 0);for(let r of t)if(r.object instanceof rr.IRI){if(r.object.value===U5||r.object.value.includes(Zx))return!0}else if(r.object instanceof Ht.Literal){let i=this.unwrapWikilink(r.object.value);if(i==="exocmd__TokenInvocation"||i===Zx)return!0}return!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,L.Namespace.EXO.term("Instance_class"),void 0);for(let r of t)if(r.object instanceof rr.IRI){if(r.object.value===M5||r.object.value.includes(Kx))return!0}else if(r.object instanceof Ht.Literal){let i=this.unwrapWikilink(r.object.value);if(i==="exocmd__SubstitutionToken"||i===Kx)return!0}return!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,L.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let r=t[0].object;if(r instanceof rr.IRI)return(0,Xx.resolveGroundingTypeFromIRI)(r.value);if(r instanceof Ht.Literal){let i=r.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,Xx.resolveGroundingTypeFromIRI)(`obsidian://vault/${s[1].toLowerCase()}.md`):(this.logger.warn(`[exocmd-grounding-type-literal-form] legacy literal-string form '${i}' for exocmd__Grounding_type on <${e.value}>. Migrate to wikilink form per RFC 9d20c91f Phase 3.`),null)}return null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let r=await this.tripleStore.findSubjectsByUUID(e);if(r.length>0)return r[0]}let t=await this.tripleStore.match(void 0,L.Namespace.EXO.term("Asset_uid"),void 0);for(let r of t)if(r.object instanceof Ht.Literal&&r.object.value===e)return r.subject;return null}async getLiteralValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Ht.Literal||i instanceof rr.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);return t?this.getLiteralValue(t,L.Namespace.EXO.term("Asset_label")):null}async getClassAncestors(e){let t=this._ancestorCache.get(e);if(t)return t;let r=new Set,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),l=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_uid"));l&&o.add(l);let c=await this.getLiteralValue(s,L.Namespace.EXO.term("Asset_label"));c&&o.add(c);let u=[{fileIRI:s,depth:0}];for(;u.length>0;){let d=u.shift();if(!d)break;let{fileIRI:h,depth:p}=d;if(p>=kp||i.has(h.value))continue;i.add(h.value);let g=await this.tripleStore.match(h,L.Namespace.EXO.term("Class_superClass"),void 0);for(let _ of g){let v=_.object;if(!(v instanceof rr.IRI))continue;let w=v.value.startsWith("obsidian://vault/"),E=this.iriToObsidianName(v.value);E&&!o.has(E)&&!r.has(E)&&r.add(E);let I=null;if(w?I=v:E&&(I=await this.resolveClassFileIRI(E)),!I)continue;let O=await this.getLiteralValue(I,L.Namespace.EXO.term("Asset_uid"));O&&!o.has(O)&&!r.has(O)&&r.add(O),i.has(I.value)||u.push({fileIRI:I,depth:p+1})}}let f=Array.from(r);return this._ancestorCache.set(e,f),f}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){let t=await this.tripleStore.match(void 0,L.Namespace.EXO.term("Asset_label"),void 0);for(let r of t)if(r.object instanceof Ht.Literal&&r.object.value===e&&r.subject instanceof rr.IRI){let i=await this.tripleStore.match(r.subject,L.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Ht.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof rr.IRI){let s=await this.tripleStore.match(i,L.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Ht.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Ht.Literal?this.normalizeWikilink(i.value):null}async getLinkedValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Ht.Literal?this.normalizeWikilink(i.value):i instanceof rr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Ht.Literal?this.unwrapWikilink(i.value):i instanceof rr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let r=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(r)return r[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof Ht.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof rr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let r=t[1],i=await this.findSubjectByUID(r);if(!i)return e;let s=await this.getLiteralValue(i,L.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${r}]]`,`[[${r}|${s}]]`):e}iriToObsidianName(e){let t=e.match(/^https:\/\/exocortex\.my\/ontology\/([a-z][a-zA-Z0-9]*)#([^#]+)$/);if(t){let[,i,s]=t;return`${i}__${s}`}let r=e.match(/\/([^/]+)\.md$/);return r?r[1]:null}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(0,r):t}};zs.CommandResolver=f1;zs.CommandResolver=f1=u1=P5([(0,F5.injectable)(),O5("design:paramtypes",[Object,Object])],f1)});var h1=S(d1=>{"use strict";Object.defineProperty(d1,"__esModule",{value:!0});d1.validateExoQLAllowlist=B5;var Mp=tf();function B5(n){if(!n||typeof n!="object")return;let e=n;if(e.type==="update"){let t=n.updates??[];for(let r of t)if(r?.type==="load")throw new Mp.ExoQLForbiddenKeywordError("LOAD");throw new Mp.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,r=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||r)throw new Mp.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)jp(t);if(Array.isArray(e.template))for(let t of e.template)jp(t)}}a(B5,"validateExoQLAllowlist");function jp(n){if(!n||typeof n!="object")return;if(n.type==="service")throw new Mp.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(n.patterns))for(let t of n.patterns)jp(t);let e=n.where;if(Array.isArray(e))for(let t of e)jp(t)}a(jp,"walkPatternForBannedKeywords")});var p1=S($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});$p.DEFAULT_EVAL_CONFIG=void 0;$p.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var g1=S(m1=>{"use strict";Object.defineProperty(m1,"__esModule",{value:!0});m1.evaluateWithExoEval=Y5;var G5=$l(),q5=Vl(),W5=lc(),z5=h1(),H5=p1(),Q5=tf();async function Y5(n,e={}){if(typeof n!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let r=new G5.ExoQLParser().parse(n);if((0,z5.validateExoQLAllowlist)(r),!{...H5.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new Q5.ExoQLEvalDisabledError;let s="queryType"in r&&typeof r.queryType=="string"?r.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let l=new q5.ExoQLAlgebraTranslator().translate(r),c=new W5.ExoQLQueryExecutor(e.store);return c.isAskQuery(l)?{kind:"ask",result:await c.executeAsk(l)}:c.isConstructQuery(l)?{kind:"construct",triples:await c.executeConstruct(l)}:{kind:"select",rows:await c.executeAll(l)}}a(Y5,"evaluateWithExoEval")});var nf=S(Up=>{"use strict";Object.defineProperty(Up,"__esModule",{value:!0});Up.liveClock=X5;Up.frozenClock=K5;function X5(){return{now:a(()=>new Date,"now")}}a(X5,"liveClock");function K5(n){let e=new Date(n);return{now:a(()=>new Date(e.getTime()),"now")}}a(K5,"frozenClock")});var iA=S(Hs=>{"use strict";var J5=Hs&&Hs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Z5=Hs&&Hs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},sf;Object.defineProperty(Hs,"__esModule",{value:!0});Hs.PreconditionEvaluator=void 0;var e6=Oe(),t6=$l(),r6=Vl(),nA=lc(),n6=g1(),i6=nf(),of=sf=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,r){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=r?.clock??(0,i6.liveClock)()}async evaluate(e,t,r){return e?e.sparqlAsk?this.evaluateSparqlAsk(e.sparqlAsk,t):e.query?this.evaluateQueryRef(e.query,t):e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,r):!0:!0}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let r=await this.queryBodyResolver.resolveSparql(e);if(!r)return!1;let i=this.substituteVariables(r,t),s=await(0,n6.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,r){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,r):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,sf.SENTINEL_IRI),i=new t6.ExoQLParser().parse(t),o=new r6.ExoQLAlgebraTranslator().translate(i);return new nA.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,r){let i=this.hostFunctions.get(e);if(!i)return!0;let s=r?{...r,targetIRI:t}:{targetIRI:t};return i(s)}async evaluateSparqlAsk(e,t){try{let r=this.askCache.get(e);if(r===void 0){let o=this.compileAsk(e);if(!o)return!1;r=o,this.askCache.set(e,r)}let i=JSON.parse(JSON.stringify(r).replaceAll(sf.SENTINEL_IRI,t));return await new nA.ExoQLQueryExecutor(this.tripleStore).executeAsk(i)}catch{return!1}}substituteVariables(e,t){let r=this.clock.now(),i=r.toISOString(),s=i.slice(0,10),o=new Date(r.getTime()+sf.ALMATY_OFFSET_MS),l=o.getUTCFullYear(),c=o.getUTCMonth(),u=o.getUTCDate(),f=o.getUTCDay(),h=new Date(Date.UTC(l,c,u-1)).toISOString().slice(0,10),p=(f+6)%7,g=new Date(Date.UTC(l,c,u-p)),_=g.toISOString().slice(0,10),w=new Date(g.getTime()-10080*60*1e3).toISOString().slice(0,10),E=`${l}-${String(c+1).padStart(2,"0")}-01`,I=c===0?11:c-1,C=`${c===0?l-1:l}-${String(I+1).padStart(2,"0")}-01`,H=`${l}-01-01`;return e.replace(/\$target/g,`<${t}>`).replace(/\$now/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday/g,`"${h}"^^xsd:date`).replace(/\$thisWeekStart/g,`"${_}"^^xsd:date`).replace(/\$lastWeekStart/g,`"${w}"^^xsd:date`).replace(/\$thisMonthStart/g,`"${E}"^^xsd:date`).replace(/\$lastMonthStart/g,`"${C}"^^xsd:date`).replace(/\$thisYearStart/g,`"${H}"^^xsd:date`).replace(/\$today/g,`"${s}"^^xsd:date`)}};Hs.PreconditionEvaluator=of;of.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";of.ALMATY_OFFSET_MS=300*60*1e3;Hs.PreconditionEvaluator=of=sf=J5([(0,e6.injectable)(),Z5("design:paramtypes",[Object,Object,Object])],of)});var sA=S(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.hasUidFilename=Qs.hasNonUidFilename=void 0;Qs.registerDefaultHostFunctions=a6;var s6=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");Qs.hasNonUidFilename=s6;var o6=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");Qs.hasUidFilename=o6;function a6(n){n.registerHostFunction("hasNonUidFilename",Qs.hasNonUidFilename),n.registerHostFunction("hasUidFilename",Qs.hasUidFilename)}a(a6,"registerDefaultHostFunctions")});var Bp=S(Vp=>{"use strict";Object.defineProperty(Vp,"__esModule",{value:!0});Vp.liveUidGenerator=l6;Vp.seededUidGenerator=u6;var y1=mi();function l6(){return{next:a(()=>(0,y1.v4)(),"next")}}a(l6,"liveUidGenerator");var c6="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function u6(n){let e=0,t=(0,y1.v5)(n,c6);return{next:a(()=>{let r=`${n}#${e}`;return e+=1,(0,y1.v5)(r,t)},"next")}}a(u6,"seededUidGenerator")});var af=S(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.registerOrderSpecLoader=f6;uc.clearOrderSpecLoader=d6;uc.loadDefaultSpec=h6;uc.orderProperties=p6;var Gp=null,jo,qp=!1;function f6(n){Gp=n,jo=void 0,qp=!1}a(f6,"registerOrderSpecLoader");function d6(){Gp=null,jo=void 0,qp=!1}a(d6,"clearOrderSpecLoader");function h6(){if(jo!==void 0)return jo;if(!Gp)return jo=null,null;try{jo=Gp()}catch(n){qp||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",n),qp=!0),jo=null}return jo}a(h6,"loadDefaultSpec");function p6(n,e){if(!e||e.head.length===0&&e.tail.length===0)return n;let t=Object.keys(n),r=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),l=t.filter(u=>!r.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&l.sort((u,f)=>u.localeCompare(f));let c={};for(let u of s)c[u]=n[u];for(let u of l)c[u]=n[u];for(let u of o)c[u]=n[u];return c}a(p6,"orderProperties")});var cs=S(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});Wp.FrontmatterService=void 0;var oA=af(),lf=class n{static{a(this,"FrontmatterService")}parse(e){let t=e.match(n.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let r={},i=t.content.split(/\r?\n/),s=null,o=null,l=a(()=>{s!==null&&o!==null&&(r[s]=o),s=null,o=null},"flushArray");for(let c of i){let u=/^ {2}- (.*)$/.exec(c);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}l();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(c);if(!f)continue;let d=f[1].trim(),h=f[2].trim();h===""?(s=d,o=[]):r[d]=h}return l(),r}updateProperty(e,t,r){t=n.normalizeIRI(t),typeof r=="string"&&(r=n.normalizeIRIValue(r));let i=this.parse(e),s=this.serializeValue(t,r);if(!i.exists)return`---
71
71
  ${s}
72
72
  ---
73
73
  ${e}`;let o=i.content;if(this.hasProperty(o,t)){let l=new RegExp(`${this.escapeRegex(t)}:.*(?:
@@ -88,7 +88,7 @@ ${Object.entries(r).map(([l,c])=>this.serializeValue(l,c)).join(`
88
88
  ${r}`}return`${e}: ${String(t)}`}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};Wp.FrontmatterService=lf;lf.FRONTMATTER_REGEX=/^---\n([\s\S]*?)\n---/;lf.IRI_PREFIX_MAP={"https://exocortex.my/ontology/ems#":"ems__","https://exocortex.my/ontology/exo#":"exo__","https://exocortex.my/ontology/exocmd#":"exocmd__","https://exocortex.my/ontology/ims#":"ims__","https://exocortex.my/ontology/ztlk#":"ztlk__","https://exocortex.my/ontology/ptms#":"ptms__","https://exocortex.my/ontology/lit#":"lit__","https://exocortex.my/ontology/inbox#":"inbox__","https://exocortex.my/ontology/pmbok#":"pmbok__"}});var Fn=S(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});zp.DateFormatter=void 0;var _1=class n{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}-${r}-${i}T${s}:${o}:${l}`}static toDateWikilink(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${r}-${i}]]"`}static getTodayWikilink(){return n.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${i}`}static parseWikilink(e){let r=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return r?r[1]:null}static addDays(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),n.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[r,i,s]=t,o=new Date(r,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return n.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return n.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};zp.DateFormatter=_1});var $o=S(Hp=>{"use strict";Object.defineProperty(Hp,"__esModule",{value:!0});Hp.LoggingService=void 0;var cf=class{static{a(this,"LoggingService")}static setVerbose(e){this.isVerbose=e}static setDevelopmentMode(e){this.isDevelopment=e}static checkIsDevelopment(){return this.isDevelopment!==void 0?this.isDevelopment:typeof process<"u"?(this.isDevelopment=!1,this.isDevelopment):(this.isDevelopment=!1,this.isDevelopment)}static debug(e,t){this.isVerbose&&console.debug(`[Exocortex] ${e}`,t??"")}static info(e,t){console.log(`[Exocortex] ${e}`,t??"")}static warn(e,t){console.warn(`[Exocortex] ${e}`,t??"")}static error(e,t,r){let i=this.checkIsDevelopment(),s=r?` [${r}]`:"";if(i){let o=t?.stack?`
89
89
  Stack trace:
90
90
  ${t.stack}`:"";console.error(`[Exocortex ERROR]${s} ${e}${o}`,t??"")}else{let o=t?.message?`
91
- Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${o}`)}}};Hp.LoggingService=cf;cf.isVerbose=!1;cf.isDevelopment=void 0});var aA=S($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.registerResolver=dn;$a.getResolver=m6;$a.getRegisteredResolverIds=g6;$a.clearResolvers=y6;$a.installDefaultResolvers=_6;var Qp=new Map;function dn(n,e){Qp.set(n,e)}a(dn,"registerResolver");function m6(n){return Qp.get(n)}a(m6,"getResolver");function g6(){return Array.from(Qp.keys())}a(g6,"getRegisteredResolverIds");function y6(){Qp.clear()}a(y6,"clearResolvers");function Uo(n){return n<10?`0${n}`:String(n)}a(Uo,"pad2");function _6(){dn("today",()=>new Date().toISOString().slice(0,10)),dn("todayStart",()=>new Date(new Date().setHours(0,0,0,0)).toISOString()),dn("target",n=>n.targetIRI?`"[[${n.targetIRI}]]"`:""),dn("targetFolder",n=>{if(!n.targetFilePath)return"";let e=n.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),dn("randomUUIDv4",()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();throw new Error("randomUUIDv4 resolver requires crypto.randomUUID() \u2014 runtime is missing Node crypto / Web Crypto API.")}),dn("nowTimestamp",()=>{let n=new Date;return`${n.getFullYear()}-${Uo(n.getMonth()+1)}-${Uo(n.getDate())}T${Uo(n.getHours())}:${Uo(n.getMinutes())}:${Uo(n.getSeconds())}`}),dn("nowDate",()=>{let n=new Date;return`${n.getFullYear()}-${Uo(n.getMonth()+1)}-${Uo(n.getDate())}`}),dn("nowYear",()=>String(new Date().getFullYear())),dn("nowMonth",()=>Uo(new Date().getMonth()+1)),dn("userInputLabel",n=>{let e=n.userInput?.label;return typeof e=="string"?e:""}),dn("userInput",(n,e)=>{if(!e)return null;let t=n.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),dn("targetProperty",(n,e)=>{if(!e||!n.targetFm)return null;let t=n.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),dn("labelAsArray",n=>{let e=n.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),dn("groundingTargetClass",n=>n.groundingTargetClassUid?`"[[${n.groundingTargetClassUid}]]"`:null)}a(_6,"installDefaultResolvers")});var fA=S(Sr=>{"use strict";var b6=Sr&&Sr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},S6=Sr&&Sr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},Ys;Object.defineProperty(Sr,"__esModule",{value:!0});Sr.GroundingExecutor=Sr.ServiceRegistry=Sr.CLASS_UID_TO_LABEL=Sr.STATUS_UID_BY_ENUM=void 0;var w6=Oe(),v6=nf(),E6=Bp(),ni=Io(),Yp=Il(),Ua=xl(),T6=Ae(),I6=cs(),b1=Fn(),lA=Ju(),fc=$o();Sr.STATUS_UID_BY_ENUM={[Ua.EffortStatus.DRAFT]:"c42245d0-01de-4c35-bfcf-d910445ea28e",[Ua.EffortStatus.BACKLOG]:"753a44d5-846c-4b82-9196-4fd9a4d48777",[Ua.EffortStatus.ANALYSIS]:"cde3525c-57ea-4efc-b477-2e7e7ccd3a1e",[Ua.EffortStatus.TODO]:"6a0e933a-6653-46f4-95ae-ed7508177c73",[Ua.EffortStatus.DOING]:"027e78f4-6e16-4b36-b8fb-5510507d5745",[Ua.EffortStatus.DONE]:"7b9b3116-7c3c-438c-9618-94fe301320a6",[Ua.EffortStatus.TRASHED]:"5d14f18d-db2b-4847-9ac1-144cb93b2541"};var x6=Object.freeze(Object.fromEntries(Object.entries(Sr.STATUS_UID_BY_ENUM).map(([n,e])=>[e,n])));Sr.CLASS_UID_TO_LABEL=Object.freeze({"1b20a8f0-d745-4e93-91db-4531b3df120e":Yp.AssetClass.TASK,"7db5eeff-718a-49b0-8d2b-39b084a356e3":Yp.AssetClass.PROJECT,"1b0a5e34-dd7f-4ead-b43a-6c7c5a5ecaca":Yp.AssetClass.MEETING});var S1=aA();(0,S1.installDefaultResolvers)();function A6(n){if(n){if(n==="1b20a8f0-d745-4e93-91db-4531b3df120e")return"ems__Task";if(n==="7db5eeff-718a-49b0-8d2b-39b084a356e3")return"ems__Project";if(n==="ems__Task"||n==="ems__Project")return n}}a(A6,"resolveClassFlipTarget");var cA=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,R6=/^__SUBSTITUTE__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__$/,C6=/^__SUBSTITUTE_P__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__([A-Za-z0-9_-]*)__$/,Xp=class{static{a(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};Sr.ServiceRegistry=Xp;var uA=20,Kp=Ys=class{static{a(this,"GroundingExecutor")}constructor(e,t,r,i,s){this.frontmatterService=new I6.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=r,this.classLabelToUid=i,this.workflowResolver=s?.workflowResolver,this.groundingLoader=s?.groundingLoader,this.clock=s?.clock??(0,v6.liveClock)(),this.uidGen=s?.uidGenerator??(0,E6.liveUidGenerator)()}async execute(e,t,r,i){try{switch(e.type){case ni.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,r,i);case ni.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,r);case ni.GroundingType.COMPOSITE:return await this.executeComposite(e,t,r,i,0);case ni.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,r,i);case ni.GroundingType.CREATE_INSTANCE:return await this.executeCreateInstance(e,t,r,i);case ni.GroundingType.PROPERTY_APPEND:return await this.executePropertyAppend(e,t,r,i);case ni.GroundingType.PROPERTY_INCREMENT:return await this.executePropertyIncrement(e,r);case ni.GroundingType.PROPERTY_SHIFT:return await this.executePropertyShift(e,r);case ni.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};case ni.GroundingType.WORKFLOW_TRANSITION:return await this.executeWorkflowTransition(e,t,r,i);default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async executePropertySet(e,t,r,i){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};let s;if([e.targetValueRef!==void 0,e.targetValueLiteral!==void 0,e.targetValueSubstitution!==void 0].filter(Boolean).length>1)return{success:!1,error:"property_set: more than one of targetValueRef/targetValueLiteral/targetValueSubstitution set (cardinality 0..1 each, mutually exclusive)"};if(e.targetValueRef!==void 0)s=`"[[${e.targetValueRef}]]"`;else if(e.targetValueLiteral!==void 0)s=e.targetValueLiteral;else if(e.targetValueSubstitution!==void 0)s=e.targetValueSubstitution;else return{success:!1,error:"property_set requires one of targetValueRef/targetValueLiteral/targetValueSubstitution"};if(/\$(input|value)\b/.test(s)&&(i===void 0||i.value===void 0||i.value===null))return{success:!1,error:"property_set: substituted value contains $input/$value placeholder but no userInput.value provided"};let c=this.substituteVariables(s,t,i),u=await this.fileReader.readFile(r),f=this.frontmatterService.updateProperty(u,e.targetProperty,c);return await this.fileWriter.updateFile(r,f),{success:!0}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let r=await this.fileReader.readFile(t),i=this.frontmatterService.removeProperty(r,e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,r,i,s){if(s>=uA)return{success:!1,error:`Composite grounding exceeded maximum depth of ${uA}`};let o=e.steps??[];if(o.length===0)return{success:!0};let l;try{l=await this.fileReader.readFile(r)}catch{}let c=[];try{for(let u=0;u<o.length;u++){let f=o[u],d=await this.executeStep(f,t,r,i,s+1);if(!d.success)return await this.rollback(l,r,c),{success:!1,error:`Composite step ${u} failed: ${d.error}`};c.push(u)}return{success:!0}}catch(u){return await this.rollback(l,r,c),{success:!1,error:`Composite execution failed: ${u instanceof Error?u.message:String(u)}`}}}async executeServiceCall(e,t,r,i){let s=e.targetProperty;if(!s)return{success:!1,error:"service_call requires targetProperty as serviceId"};if(s==="convertToTask")return await this.executeConvertToTask(r);if(s==="updateProperty"){let c=A6(e.targetValueRef);if(c==="ems__Task")return await this.executeConvertToTask(r);if(c==="ems__Project")return await this.executeConvertToProject(r)}let o=this.serviceRegistry.get(s);if(!o)return{success:!1,error:`Service not found: "${s}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`};let l=i;if(e.isDefinedBy&&(l={isDefinedBy:e.isDefinedBy,...l??{}}),e.serviceCallPayload)try{let c=this.substituteVariables(e.serviceCallPayload,t,i),u=JSON.parse(c);typeof u=="object"&&u!==null&&(l={...u,...l??{}})}catch{}return await o.execute(t,l),{success:!0}}async executeConvertToTask(e){let t=await this.fileReader.readFile(e),r=await this.resolveClassRefToUid("ems__Task"),i=this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${r}]]"]`);return await this.fileWriter.updateFile(e,i),{success:!0}}async executeConvertToProject(e){let t=await this.fileReader.readFile(e),r=await this.resolveClassRefToUid("ems__Project"),i=this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${r}]]"]`);return await this.fileWriter.updateFile(e,i),{success:!0}}async executeCreateInstance(e,t,r,i){if(!e.targetFolder)return{success:!1,error:"create_instance requires targetFolder"};let s={},o=null;if((e.inheritanceRule&&e.inheritanceRule.length>0||e.propertyDefault&&e.propertyDefault.some(g=>typeof g.value=="string"&&g.value.includes("__SUBSTITUTE"))||e.labelTemplate!==void 0&&/\$target\./.test(e.labelTemplate))&&t&&r){let g;try{g=await this.fileReader.readFile(r)}catch(_){return{success:!1,error:`create_instance: failed to read $target file "${r}": ${_ instanceof Error?_.message:String(_)}`}}o=this.frontmatterService.parseObject(g)??null}let c;e.targetClass&&(c=await this.resolveClassRefToUid(e.targetClass));let u={userInput:i,targetIRI:t,targetFilePath:r,targetFm:o??void 0,groundingTargetClassUid:c};if(e.propertyDefault&&e.propertyDefault.length>0&&this.applyPropertyDefaultStep(s,e.propertyDefault,u),this.applyMissingScalarPrimitives(s,i,c,e,t,o,r),i)for(let[g,_]of Object.entries(i))g!=="label"&&_!=null&&(s[g]=_);if(e.inheritanceRule&&e.inheritanceRule.length>0&&o&&await this.applyInheritanceRuleStep(s,e.inheritanceRule,o),this.applyMissingBacklinkTopUp(s,e,t,r),t&&e.linkBackProperty&&s[e.linkBackProperty]===void 0){let g=Ys.extractBacklinkTarget(t,r);s[e.linkBackProperty]=`"[[${g}]]"`}let f=s.exo__Asset_uid,d=this.frontmatterService.createFrontmatter("",s),h=this.substituteVariables(e.targetFolder,t,i,void 0,r),p=h?`${h}/${f}.md`:`${f}.md`;return await this.fileWriter.createFile(p,d),{success:!0,openPath:p}}async resolveClassRefToUid(e){if(cA.test(e)||!this.classLabelToUid)return e;try{let t=await this.classLabelToUid(e);return t&&t.length>0?t:e}catch{return e}}applyPropertyDefaultStep(e,t,r){for(let{propertyName:i,value:s}of t){if(e[i]!==void 0)continue;let o=this.resolveSubstitutionMarker(s,r);if(o!=null){if(Array.isArray(o)){if(o.length===0)continue;e[i]=o;continue}if(i==="exo__Instance_class"&&typeof o=="string"){e[i]=[o];continue}e[i]=o}}}applyMissingScalarPrimitives(e,t,r,i,s,o,l){let c=[];e.exo__Asset_uid===void 0&&(e.exo__Asset_uid=this.uidGen.next(),c.push("exo__Asset_uid")),e.exo__Asset_createdAt===void 0&&(e.exo__Asset_createdAt=b1.DateFormatter.toLocalTimestamp(this.clock.now()),c.push("exo__Asset_createdAt"));let u=typeof e.exo__Asset_label=="string"&&e.exo__Asset_label.trim().length===0;if(e.exo__Asset_label===void 0||u){let f=t?.label;if(f===void 0&&i?.labelTemplate)try{let h=this.substituteVariables(i.labelTemplate,s??"",t,o??void 0,l);h.trim().length>0&&(f=h)}catch(h){fc.LoggingService.error(`[GroundingExecutor] labelTemplate substitution failed: ${h instanceof Error?h.message:String(h)}. Falling back to "Untitled".`)}let d=f??"Untitled";e.exo__Asset_label=d,d!=="Untitled"&&e.aliases===void 0&&(e.aliases=[d]),c.push("exo__Asset_label")}e.exo__Instance_class===void 0&&r&&(e.exo__Instance_class=[`"[[${r}]]"`],c.push("exo__Instance_class")),c.length>0&&fc.LoggingService.error(`[GroundingExecutor] Universal Default Template did not cover essential scalar primitives: ${c.join(", ")}. Filled from legacy TS fallback. Vault may be in an unhealthy state \u2014 verify UniversalDefaultTemplate singleton is present and complete.`)}applyMissingBacklinkTopUp(e,t,r,i){if(!r||t.linkBackProperty||e.exo__Asset_prototype!==void 0||e.ems__Effort_parent!==void 0)return;let s=Ys.extractBacklinkTarget(r,i);e.exo__Asset_prototype=`"[[${s}]]"`,fc.LoggingService.error("[GroundingExecutor] No backlink rule fired (Universal IRs absent or no class match). Falling back to legacy exo__Asset_prototype default. Bug #5 may surface if target is not a prototype-instance.")}resolveSubstitutionMarker(e,t){let r=e.match(C6);if(r){let l=r[1],c=r[2],u=Ys.decodeBase64UrlSafe(c),f=(0,S1.getResolver)(l);return f?f(t,u):(fc.LoggingService.warn(`[GroundingExecutor] Parameterised marker references unknown resolver '${l}' \u2014 value left as marker.`),e)}let i=e.match(R6);if(!i)return e;let s=i[1];if(s==="target"){let l=t.targetIRI??"",c=t.targetFilePath??"";return`"[[${Ys.extractBacklinkTarget(l,c)}]]"`}if(s==="targetFolder"){let l=t.targetFilePath??"";if(!l)return"";let c=l.replace(/^\/+/,""),u=c.lastIndexOf("/");return u>=0?c.slice(0,u):""}let o=(0,S1.getResolver)(s);return o?o(t):(fc.LoggingService.warn(`[GroundingExecutor] Marker references unknown resolver '${s}' \u2014 value left as marker.`),e)}static decodeBase64UrlSafe(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4);return Buffer.from(t+r,"base64").toString("utf-8")}async applyInheritanceRuleStep(e,t,r){let i=this.extractTargetClassNames(r),s=[];for(let o of t)!await this.inheritanceConditionMatches(o.targetClassCondition,i)||await this.inheritanceExclusionMatches(o.targetClassExclusion,i)||s.push(o);s.sort((o,l)=>l.priority-o.priority);for(let o of s){if(e[o.targetPropertyName]!==void 0)continue;let l=r[o.sourcePropertyName];l!=null&&(e[o.targetPropertyName]=this.formatInheritedValue(l))}}async inheritanceConditionMatches(e,t){return e?this.classMatchesAny(e,t):!0}async inheritanceExclusionMatches(e,t){for(let r of e)if(await this.classMatchesAny(r,t))return!0;return!1}async classMatchesAny(e,t){if(t.includes(e))return!0;if(!this.classLabelToUid)return!1;try{let r=await this.classLabelToUid(e);if(r&&r.length>0&&t.includes(r))return!0}catch{}return!1}extractTargetClassNames(e){let t=e.exo__Instance_class;if(t==null)return[];let r=Array.isArray(t)?t:[t],i=[];for(let s of r){let o=this.extractWikilinkInner(String(s));o&&i.push(o)}return i}extractWikilinkInner(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/);return t?t[1].trim():e.replace(/^["']|["']$/g,"").trim()}formatInheritedValue(e){return Array.isArray(e)?e.map(t=>this.formatInheritedScalar(String(t))):this.formatInheritedScalar(String(e))}formatInheritedScalar(e){return/^"?\[\[.+\]\]"?$/.test(e)?this.reformatWikilink(e):cA.test(e)?`"[[${e}]]"`:e}reformatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:e}async executeStep(e,t,r,i,s){return e.type===ni.GroundingType.COMPOSITE?this.executeComposite(e,t,r,i,s):this.execute(e,t,r,i)}async rollback(e,t,r){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(i){fc.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,i instanceof Error?i:new Error(String(i)))}}substituteVariables(e,t,r,i,s){let o=this.clock.now(),l=o.toISOString(),c=b1.DateFormatter.toLocalTimestamp(o),u=l.slice(0,10),f=`${u}T00:00:00`,d=`${c.slice(0,10)}-${c.slice(11,13)}-${c.slice(14,16)}`,h=e.replace(/\$target\.([A-Za-z_][\w]*)/g,(p,g)=>{if(!i)throw new Error(`$target.${g} substitution requires target frontmatter context; none was supplied (asset IRI: ${t})`);let _=i[g];if(_==null)throw new Error(`$target.${g} is undefined on asset ${t}`);if(Array.isArray(_))throw new Error(`$target.${g} resolved to an array on asset ${t}; only scalar properties are supported for substitution`);return String(_).replace(/^["'](.*)["']$/,"$1")});if(/\$targetFolder\b/.test(h)){if(!s)throw new Error("$targetFolder substitution requires targetFilePath context; none was supplied (asset IRI: "+t+")");let p=s.replace(/^\/+/,""),g=p.lastIndexOf("/"),_=g>=0?p.slice(0,g):"";h=h.replace(/\$targetFolder\b/g,_)}if(h=h.replace(/\$target/g,t).replace(/\$nowCompact\b/g,d).replace(/\$nowLocal/g,c).replace(/\$now/g,l).replace(/\$todayStart\b/g,f).replace(/\$today/g,u),r?.value!==void 0&&r.value!==null){let p=String(r.value);h=h.replace(/\$input\b/g,p).replace(/\$value\b/g,p)}return h}async executePropertyAppend(e,t,r,i){if(!e.targetProperty)return{success:!1,error:"property_append requires targetProperty"};if(e.appendExpression===void 0)return{success:!1,error:"property_append requires appendExpression"};let s=await this.fileReader.readFile(r),o=this.frontmatterService.parseObject(s)??{},l=this.substituteVariables(e.appendExpression,t,i,o),c=o[e.targetProperty],u=Array.isArray(c)?c:c!==void 0?[String(c)]:[],f=a(g=>g.replace(/^["'](.*)["']$/,"$1"),"stripQuotes"),d=new Set(u.map(f)),h;if(d.has(f(l)))h=u;else{let g=`"${f(l)}"`;h=[...u,g]}let p=this.frontmatterService.updateProperty(s,e.targetProperty,h);return await this.fileWriter.updateFile(r,p),{success:!0}}async executePropertyIncrement(e,t){if(!e.targetProperty)return{success:!1,error:"property_increment requires targetProperty"};let r=e.incrementBy??1;if(!Number.isFinite(r)||!Number.isInteger(r))return{success:!1,error:`property_increment: incrementBy must be an integer (got ${String(e.incrementBy)})`};let i=await this.fileReader.readFile(t),o=(this.frontmatterService.parseObject(i)??{})[e.targetProperty],l;if(o==null||o==="")l=0;else{if(Array.isArray(o))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" is an array, expected integer`};{let f=String(o).replace(/^["'](.*)["']$/,"$1").trim();if(!/^-?\d+$/.test(f))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" current value "${String(o)}" is not a valid integer`};l=Number.parseInt(f,10)}}let c=l+r,u=this.frontmatterService.updateProperty(i,e.targetProperty,c);return await this.fileWriter.updateFile(t,u),{success:!0}}async executePropertyShift(e,t){if(!e.targetProperty)return{success:!1,error:"property_shift requires targetProperty"};if(!e.shiftDelta)return{success:!1,error:"property_shift requires shiftDelta (ISO-8601 duration literal)"};let r=await this.fileReader.readFile(t),s=(this.frontmatterService.parseObject(r)??{})[e.targetProperty];if(s==null||s==="")return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is not set on target asset`};if(Array.isArray(s))return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is an array, expected single datetime`};let o=String(s).replace(/^["'](.*)["']$/,"$1").trim(),l=new Date(o);if(Number.isNaN(l.getTime()))return{success:!1,error:`property_shift: current value "${o}" is not a valid datetime`};let c;try{c=Ys.applyIsoDuration(l,e.shiftDelta)}catch(d){return{success:!1,error:`property_shift: invalid shiftDelta "${e.shiftDelta}": ${d instanceof Error?d.message:String(d)}`}}let u=b1.DateFormatter.toLocalTimestamp(c),f=this.frontmatterService.updateProperty(r,e.targetProperty,u);return await this.fileWriter.updateFile(t,f),{success:!0}}async executeWorkflowTransition(e,t,r,i){if(!this.workflowResolver)return{success:!1,error:"workflow_transition requires WorkflowResolver injection (options.workflowResolver). Wire the plugin/CLI before using this grounding type."};let s=await this.fileReader.readFile(r),o=this.frontmatterService.parseObject(s)??{},l=this.resolveAssetClassFromFrontmatter(o);if(!l)return{success:!1,error:"workflow_transition: target asset has no recognised ems__* class in exo__Instance_class (cannot resolve workflow)."};let c=this.resolveStatusFromFrontmatter(o);if(!c)return{success:!1,error:"workflow_transition: target asset has no parseable ems__Effort_status value (need wikilink to an ems__EffortStatus* asset)."};let u;try{u=new T6.IRI(t)}catch(I){return{success:!1,error:`workflow_transition: invalid targetIRI "${t}" \u2014 ${I instanceof Error?I.message:String(I)}`}}let f=await this.workflowResolver.resolveForAsset(u,l),d=e.direction??"forward",h=d==="rollback",p=f.transitions.find(I=>I.from===c&&I.isRollback===h);if(!p)return{success:!1,error:`workflow_transition: no ${d} transition from "${c}" defined in workflow "${f.name}" (target class: ${l}).`};let g=Sr.STATUS_UID_BY_ENUM[p.to];if(!g)return{success:!1,error:`workflow_transition: no UID mapping for destination status "${p.to}" (transition target unreachable).`};let _={id:`${e.id}.statusMutation`,label:`workflow_transition: ${p.from} \u2192 ${p.to}`,type:ni.GroundingType.PROPERTY_SET,targetProperty:"ems__Effort_status",targetValueRef:g},v=await this.executePropertySet(_,t,r,i);if(!v.success)return{success:!1,error:`workflow_transition: status mutation failed \u2014 ${v.error}`};let w=p.postActions??[],E=this.groundingLoader;if(w.length>0&&E===void 0)return{success:!1,error:"workflow_transition: transition has postActions but no GroundingLoader injected (options.groundingLoader). Wire commandResolver.loadGroundingByUid in plugin/CLI."};for(let I of w){if(E===void 0)break;let A=await E(I);if(!A)return{success:!1,error:`workflow_transition: postAction grounding UID "${I}" could not be loaded (asset missing or invalid Grounding shape).`};let D=await this.execute(A,t,r,i);if(!D.success)return{success:!1,error:`workflow_transition: postAction "${A.label}" (UID ${I}) failed \u2014 ${D.error}`}}return{success:!0}}resolveAssetClassFromFrontmatter(e){let t=e.exo__Instance_class;if(t==null)return null;let r=Array.isArray(t)?t:[t],i=new Set(Object.values(Yp.AssetClass));for(let s of r){if(typeof s!="string")continue;let o=s.replace(/^\s*"?\[\[/,"").replace(/\]\]"?\s*$/,""),c=(o.includes("|")?o.split("|")[1]:o).trim();if(i.has(c))return c;let u=o.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);if(u){let f=Sr.CLASS_UID_TO_LABEL[u[1].toLowerCase()];if(f&&i.has(f))return f}}return null}resolveStatusFromFrontmatter(e){let t=e.ems__Effort_status;if(t==null)return null;if(Array.isArray(t)){if(t.length!==1)return null;t=t[0]}let i=String(t).trim().replace(/^["']/,"").replace(/["']$/,"").replace(/^\[\[/,"").replace(/\]\]$/,"");if(/^ems__EffortStatus[A-Za-z]+$/.test(i))return i;if(i.includes("|")){let o=i.split("|")[1].trim();if(/^ems__EffortStatus[A-Za-z]+$/.test(o))return o}let s=i.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);if(s){let o=x6[s[1].toLowerCase()];if(o)return o}return null}static applyIsoDuration(e,t){let r=t.trim();if(/^-?P(\d+Y)(\d+M)?$|^-?P\d+M$/.test(r)){let o=lA.DateTimeParsing.parseYearMonthDuration(r),l=new Date(e.getTime());return l.setMonth(l.getMonth()+o),l}let s=lA.DateTimeParsing.parseDayTimeDuration(r);return new Date(e.getTime()+s)}static extractBacklinkTarget(e,t){let r=Ys.resolveTargetPath(e,t),i=r.split("/").pop()??r;return Ys.UUID_BASENAME_RE.test(i)?i:r}static resolveTargetPath(e,t){if(t)return t.replace(/\.md$/i,"").replace(/^\/+/,"");if(e){let r=e.match(/^obsidian:\/\/vault\/(.+?)(?:\.md)?(?:\?|#|$)/i);if(r&&r[1])try{return decodeURIComponent(r[1])}catch{return r[1]}}return e}};Sr.GroundingExecutor=Kp;Kp.UUID_BASENAME_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Sr.GroundingExecutor=Kp=Ys=b6([(0,w6.injectable)(),S6("design:paramtypes",[Object,Object,Xp,Function,Object])],Kp)});var dA=S(w1=>{"use strict";Object.defineProperty(w1,"__esModule",{value:!0});w1.createVaultFrontmatterClassLabelResolver=P6;function P6(n){return async e=>{if(!e)return null;let t=await n.findFilesByMetadata({exo__Asset_label:e});if(t.length>0){let s=(await n.getFileMetadata(t[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}let r=await n.findFilesByMetadata({aliases:e});if(r.length>0){let s=(await n.getFileMetadata(r[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}return null}}a(P6,"createVaultFrontmatterClassLabelResolver")});var hA=S(Xs=>{"use strict";var O6=Xs&&Xs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},F6=Xs&&Xs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},v1;Object.defineProperty(Xs,"__esModule",{value:!0});Xs.CommandExecutionFlow=void 0;var D6=Oe(),L6=Io(),N6=Ae(),k6=$e(),M6=er(),j6=Fn(),E1=v1=class{static{a(this,"CommandExecutionFlow")}constructor(e,t,r,i,s,o){this.groundingExecutor=e,this.notificationService=t,this.logger=r,this.prompts=i,this.tripleStore=s,this.fileOpener=o}async run(e,t){let{command:r}=e;if(r.confirmMessage&&!await this.prompts.confirm(r.confirmMessage))return;let i=t.injectedUserInput,s=v1.extractInputSchema(e);if(s!==null&&s.length>0){let c=await this.applyLabelDatePrefill(s,r.grounding,t.targetIRI),u=await this.prompts.promptInputSchema(c);if(u===null)return;i={...t.injectedUserInput??{},...u}}let o=await this.groundingExecutor.execute(r.grounding,t.targetIRI??"",t.filePath??"",i),l=t.filePath??"<no-file>";if(o.success){if(r.successMessage&&this.notificationService.success(r.successMessage),await new Promise(c=>setTimeout(c,100)),t.onComplete&&await t.onComplete(),o.openPath&&this.fileOpener)try{await this.fileOpener.open(o.openPath,{sameTab:r.openInSameTab})}catch(c){this.logger.info(`[CommandExecutionFlow] Failed to open created file "${o.openPath}": ${c instanceof Error?c.message:String(c)}`)}this.logger.info(`[CommandExecutionFlow] Executed "${r.name}" on ${l}`)}else this.notificationService.error(`Command failed: ${o.error??"unknown error"}`),this.logger.info(`[CommandExecutionFlow] Failed "${r.name}": ${o.error}`)}static extractInputSchema(e){let r=e.command.grounding.inputSchema;return!r||!Array.isArray(r)?null:r}async applyLabelDatePrefill(e,t,r){if(t.type!==L6.GroundingType.CREATE_INSTANCE||!t.prefillLabelWithDate||!r||!this.tripleStore)return e;let i=await this.resolveAssetLabel(r);if(!i)return e;let s=j6.DateFormatter.toDateString(new Date),o=`${i} ${s}`;return e.map(l=>{if(typeof l!="object"||l===null)return l;let c=l;if(c.name!=="label")return l;let u=c.defaultValue;return typeof u=="string"&&u.length>0?l:{...c,defaultValue:o}})}async resolveAssetLabel(e){if(!this.tripleStore)return;let t=new N6.IRI(e),r=await this.tripleStore.match(t,M6.Namespace.EXO.term("Asset_label"),void 0);if(r.length===0)return;let i=r[0].object;if(i instanceof k6.Literal)return i.value.length>0?i.value:void 0}};Xs.CommandExecutionFlow=E1;Xs.CommandExecutionFlow=E1=v1=O6([(0,D6.injectable)(),F6("design:paramtypes",[Function,Object,Object,Object,Object,Object])],E1)});var uf=S(Ks=>{"use strict";var $6=Ks&&Ks.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},U6=Ks&&Ks.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Ks,"__esModule",{value:!0});Ks.WorkflowEngine=void 0;var V6=Oe(),T1=class{static{a(this,"WorkflowEngine")}constructor(e){this.definition=e}getAvailableTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&!t.isRollback)}getRollbackTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&t.isRollback)}getAllTransitions(e){return this.definition.transitions.filter(t=>t.from===e)}canTransition(e,t){return this.definition.transitions.some(r=>r.from===e&&r.to===t)}getPreviousStatus(e){return this.definition.transitions.find(r=>r.from===e&&r.isRollback)?.to??null}getNextStates(e){return this.getAvailableTransitions(e).map(t=>t.to)}isTerminalState(e){return this.definition.terminalStates.includes(e)}isInitialState(e){return this.definition.initialState===e}getTimestampsForStatus(e){return this.definition.states.find(r=>r.status===e)?.timestampOnEnter??[]}getTransition(e,t){return this.definition.transitions.find(r=>r.from===e&&r.to===t)}getOrderedStates(){return this.definition.states.map(e=>e.status)}getDefinition(){return this.definition}validate(){let e=[],t=new Set(this.definition.states.map(i=>i.status));this.definition.states.length===0&&e.push("Workflow must have at least one state"),t.has(this.definition.initialState)||e.push(`Initial state "${this.definition.initialState}" is not in the states list`);for(let i of this.definition.terminalStates)t.has(i)||e.push(`Terminal state "${i}" is not in the states list`);for(let i of this.definition.transitions)t.has(i.from)||e.push(`Transition "${i.label}" references unknown source state "${i.from}"`),t.has(i.to)||e.push(`Transition "${i.label}" references unknown target state "${i.to}"`);for(let i of this.definition.states){if(this.definition.terminalStates.includes(i.status))continue;this.definition.transitions.filter(o=>o.from===i.status&&!o.isRollback).length===0&&e.push(`State "${i.status}" has no outgoing forward transitions (dead end)`)}let r=new Set;for(let i of this.definition.transitions){let s=`${i.from}\u2192${i.to}`;r.has(s)&&e.push(`Duplicate transition: ${s}`),r.add(s)}return{valid:e.length===0,errors:e}}};Ks.WorkflowEngine=T1;Ks.WorkflowEngine=T1=$6([(0,V6.injectable)(),U6("design:paramtypes",[Object])],T1)});var pA=S(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.EFFORT_WORKFLOW_PROPERTY=us.WorkflowTransitionProperty=us.WorkflowStateProperty=us.WorkflowProperty=void 0;us.WorkflowProperty={TARGET_CLASS:"ems__Workflow_targetClass",INITIAL_STATE:"ems__Workflow_initialState",TERMINAL_STATES:"ems__Workflow_terminalStates",IS_DEFAULT:"ems__Workflow_isDefault"};us.WorkflowStateProperty={WORKFLOW:"ems__WorkflowState_workflow",STATUS:"ems__WorkflowState_status",ORDER:"ems__WorkflowState_order",OPTIONAL:"ems__WorkflowState_optional",TIMESTAMP_ON_ENTER:"ems__WorkflowState_timestampOnEnter",BADGE_COLOR:"ems__WorkflowState_badgeColor"};us.WorkflowTransitionProperty={WORKFLOW:"ems__WorkflowTransition_workflow",FROM:"ems__WorkflowTransition_from",TO:"ems__WorkflowTransition_to",LABEL:"ems__WorkflowTransition_label",ICON:"ems__WorkflowTransition_icon",IS_ROLLBACK:"ems__WorkflowTransition_isRollback"};us.EFFORT_WORKFLOW_PROPERTY="ems__Effort_workflow"});var Js=S(Jp=>{"use strict";Object.defineProperty(Jp,"__esModule",{value:!0});Jp.MetadataHelpers=void 0;var mA=af(),I1=class{static{a(this,"MetadataHelpers")}static findAllReferencingProperties(e,t){let r=[];for(let[i,s]of Object.entries(e))this.containsReference(s,t)&&r.push(i);return r}static findReferencingProperty(e,t){for(let[r,i]of Object.entries(e))if(this.containsReference(i,t))return r}static containsReference(e,t){if(!e)return!1;let r=t.replace(/\.md$/,"");if(typeof e=="string"){let i=/\[\[([^[\]]+)\]\]/g,s;for(;(s=i.exec(e))!==null;){let l=s[1].split("|")[0].trim();if(l===r||l.endsWith(`/${r}`))return!0}return!1}return Array.isArray(e)?e.some(i=>this.containsReference(i,t)):!1}static isAssetArchived(e){let t=e?.exo__Asset_isArchived;if(t!=null){if(t===!0||t===1)return!0;if(typeof t=="string"){let i=t.toLowerCase().trim();if(i==="true"||i==="yes"||i==="1")return!0}if(typeof t=="boolean")return t}let r=e?.archived;if(r==null)return!1;if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0;if(typeof r=="string"){let i=r.toLowerCase().trim();return i==="true"||i==="yes"||i==="1"}return!1}static getPropertyValue(e,t){return t==="Name"||t==="title"?e.title:t==="created"?e.created:t==="modified"?e.modified:t==="path"?e.path:e.metadata?.[t]}static ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}static buildFileContent(e,t){let r=(0,mA.orderProperties)(e,(0,mA.loadDefaultSpec)()),i=Object.entries(r).map(([l,c])=>{if(Array.isArray(c)){let u=c.map(f=>` - ${String(f)}`).join(`
91
+ Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${o}`)}}};Hp.LoggingService=cf;cf.isVerbose=!1;cf.isDevelopment=void 0});var aA=S($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.registerResolver=dn;$a.getResolver=m6;$a.getRegisteredResolverIds=g6;$a.clearResolvers=y6;$a.installDefaultResolvers=_6;var Qp=new Map;function dn(n,e){Qp.set(n,e)}a(dn,"registerResolver");function m6(n){return Qp.get(n)}a(m6,"getResolver");function g6(){return Array.from(Qp.keys())}a(g6,"getRegisteredResolverIds");function y6(){Qp.clear()}a(y6,"clearResolvers");function Uo(n){return n<10?`0${n}`:String(n)}a(Uo,"pad2");function _6(){dn("today",()=>new Date().toISOString().slice(0,10)),dn("todayStart",()=>new Date(new Date().setHours(0,0,0,0)).toISOString()),dn("target",n=>n.targetIRI?`"[[${n.targetIRI}]]"`:""),dn("targetFolder",n=>{if(!n.targetFilePath)return"";let e=n.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),dn("randomUUIDv4",()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();throw new Error("randomUUIDv4 resolver requires crypto.randomUUID() \u2014 runtime is missing Node crypto / Web Crypto API.")}),dn("nowTimestamp",()=>{let n=new Date;return`${n.getFullYear()}-${Uo(n.getMonth()+1)}-${Uo(n.getDate())}T${Uo(n.getHours())}:${Uo(n.getMinutes())}:${Uo(n.getSeconds())}`}),dn("nowDate",()=>{let n=new Date;return`${n.getFullYear()}-${Uo(n.getMonth()+1)}-${Uo(n.getDate())}`}),dn("nowYear",()=>String(new Date().getFullYear())),dn("nowMonth",()=>Uo(new Date().getMonth()+1)),dn("userInputLabel",n=>{let e=n.userInput?.label;return typeof e=="string"?e:""}),dn("userInput",(n,e)=>{if(!e)return null;let t=n.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),dn("targetProperty",(n,e)=>{if(!e||!n.targetFm)return null;let t=n.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),dn("labelAsArray",n=>{let e=n.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),dn("groundingTargetClass",n=>n.groundingTargetClassUid?`"[[${n.groundingTargetClassUid}]]"`:null)}a(_6,"installDefaultResolvers")});var fA=S(Sr=>{"use strict";var b6=Sr&&Sr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},S6=Sr&&Sr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},Ys;Object.defineProperty(Sr,"__esModule",{value:!0});Sr.GroundingExecutor=Sr.ServiceRegistry=Sr.CLASS_UID_TO_LABEL=Sr.STATUS_UID_BY_ENUM=void 0;var w6=Oe(),v6=nf(),E6=Bp(),ni=Io(),Yp=Il(),Ua=xl(),T6=Ae(),I6=cs(),b1=Fn(),lA=Ju(),fc=$o();Sr.STATUS_UID_BY_ENUM={[Ua.EffortStatus.DRAFT]:"c42245d0-01de-4c35-bfcf-d910445ea28e",[Ua.EffortStatus.BACKLOG]:"753a44d5-846c-4b82-9196-4fd9a4d48777",[Ua.EffortStatus.ANALYSIS]:"cde3525c-57ea-4efc-b477-2e7e7ccd3a1e",[Ua.EffortStatus.TODO]:"6a0e933a-6653-46f4-95ae-ed7508177c73",[Ua.EffortStatus.DOING]:"027e78f4-6e16-4b36-b8fb-5510507d5745",[Ua.EffortStatus.DONE]:"7b9b3116-7c3c-438c-9618-94fe301320a6",[Ua.EffortStatus.TRASHED]:"5d14f18d-db2b-4847-9ac1-144cb93b2541"};var x6=Object.freeze(Object.fromEntries(Object.entries(Sr.STATUS_UID_BY_ENUM).map(([n,e])=>[e,n])));Sr.CLASS_UID_TO_LABEL=Object.freeze({"1b20a8f0-d745-4e93-91db-4531b3df120e":Yp.AssetClass.TASK,"7db5eeff-718a-49b0-8d2b-39b084a356e3":Yp.AssetClass.PROJECT,"1b0a5e34-dd7f-4ead-b43a-6c7c5a5ecaca":Yp.AssetClass.MEETING});var S1=aA();(0,S1.installDefaultResolvers)();function A6(n){if(n){if(n==="1b20a8f0-d745-4e93-91db-4531b3df120e")return"ems__Task";if(n==="7db5eeff-718a-49b0-8d2b-39b084a356e3")return"ems__Project";if(n==="ems__Task"||n==="ems__Project")return n}}a(A6,"resolveClassFlipTarget");var cA=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,R6=/^__SUBSTITUTE__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__$/,C6=/^__SUBSTITUTE_P__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__([A-Za-z0-9_-]*)__$/,Xp=class{static{a(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};Sr.ServiceRegistry=Xp;var uA=20,Kp=Ys=class{static{a(this,"GroundingExecutor")}constructor(e,t,r,i,s){this.frontmatterService=new I6.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=r,this.classLabelToUid=i,this.workflowResolver=s?.workflowResolver,this.groundingLoader=s?.groundingLoader,this.clock=s?.clock??(0,v6.liveClock)(),this.uidGen=s?.uidGenerator??(0,E6.liveUidGenerator)()}async execute(e,t,r,i){try{switch(e.type){case ni.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,r,i);case ni.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,r);case ni.GroundingType.COMPOSITE:return await this.executeComposite(e,t,r,i,0);case ni.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,r,i);case ni.GroundingType.CREATE_INSTANCE:return await this.executeCreateInstance(e,t,r,i);case ni.GroundingType.PROPERTY_APPEND:return await this.executePropertyAppend(e,t,r,i);case ni.GroundingType.PROPERTY_INCREMENT:return await this.executePropertyIncrement(e,r);case ni.GroundingType.PROPERTY_SHIFT:return await this.executePropertyShift(e,r);case ni.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};case ni.GroundingType.WORKFLOW_TRANSITION:return await this.executeWorkflowTransition(e,t,r,i);default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async executePropertySet(e,t,r,i){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};let s;if([e.targetValueRef!==void 0,e.targetValueLiteral!==void 0,e.targetValueSubstitution!==void 0].filter(Boolean).length>1)return{success:!1,error:"property_set: more than one of targetValueRef/targetValueLiteral/targetValueSubstitution set (cardinality 0..1 each, mutually exclusive)"};if(e.targetValueRef!==void 0)s=`"[[${e.targetValueRef}]]"`;else if(e.targetValueLiteral!==void 0)s=e.targetValueLiteral;else if(e.targetValueSubstitution!==void 0)s=e.targetValueSubstitution;else return{success:!1,error:"property_set requires one of targetValueRef/targetValueLiteral/targetValueSubstitution"};if(/\$(input|value)\b/.test(s)&&(i===void 0||i.value===void 0||i.value===null))return{success:!1,error:"property_set: substituted value contains $input/$value placeholder but no userInput.value provided"};let c=this.substituteVariables(s,t,i),u=await this.fileReader.readFile(r),f=this.frontmatterService.updateProperty(u,e.targetProperty,c);return await this.fileWriter.updateFile(r,f),{success:!0}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let r=await this.fileReader.readFile(t),i=this.frontmatterService.removeProperty(r,e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,r,i,s){if(s>=uA)return{success:!1,error:`Composite grounding exceeded maximum depth of ${uA}`};let o=e.steps??[];if(o.length===0)return{success:!0};let l;try{l=await this.fileReader.readFile(r)}catch{}let c=[];try{for(let u=0;u<o.length;u++){let f=o[u],d=await this.executeStep(f,t,r,i,s+1);if(!d.success)return await this.rollback(l,r,c),{success:!1,error:`Composite step ${u} failed: ${d.error}`};c.push(u)}return{success:!0}}catch(u){return await this.rollback(l,r,c),{success:!1,error:`Composite execution failed: ${u instanceof Error?u.message:String(u)}`}}}async executeServiceCall(e,t,r,i){let s=e.targetProperty;if(!s)return{success:!1,error:"service_call requires targetProperty as serviceId"};if(s==="convertToTask")return await this.executeConvertToTask(r);if(s==="updateProperty"){let c=A6(e.targetValueRef);if(c==="ems__Task")return await this.executeConvertToTask(r);if(c==="ems__Project")return await this.executeConvertToProject(r)}let o=this.serviceRegistry.get(s);if(!o)return{success:!1,error:`Service not found: "${s}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`};let l=i;if(e.isDefinedBy&&(l={isDefinedBy:e.isDefinedBy,...l??{}}),e.serviceCallPayload)try{let c=this.substituteVariables(e.serviceCallPayload,t,i),u=JSON.parse(c);typeof u=="object"&&u!==null&&(l={...u,...l??{}})}catch{}return await o.execute(t,l),{success:!0}}async executeConvertToTask(e){let t=await this.fileReader.readFile(e),r=await this.resolveClassRefToUid("ems__Task"),i=this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${r}]]"]`);return await this.fileWriter.updateFile(e,i),{success:!0}}async executeConvertToProject(e){let t=await this.fileReader.readFile(e),r=await this.resolveClassRefToUid("ems__Project"),i=this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${r}]]"]`);return await this.fileWriter.updateFile(e,i),{success:!0}}async executeCreateInstance(e,t,r,i){if(!e.targetFolder)return{success:!1,error:"create_instance requires targetFolder"};let s={},o=null;if((e.inheritanceRule&&e.inheritanceRule.length>0||e.propertyDefault&&e.propertyDefault.some(g=>typeof g.value=="string"&&g.value.includes("__SUBSTITUTE"))||e.labelTemplate!==void 0&&/\$target\./.test(e.labelTemplate))&&t&&r){let g;try{g=await this.fileReader.readFile(r)}catch(_){return{success:!1,error:`create_instance: failed to read $target file "${r}": ${_ instanceof Error?_.message:String(_)}`}}o=this.frontmatterService.parseObject(g)??null}let c;e.targetClass&&(c=await this.resolveClassRefToUid(e.targetClass));let u={userInput:i,targetIRI:t,targetFilePath:r,targetFm:o??void 0,groundingTargetClassUid:c};if(e.propertyDefault&&e.propertyDefault.length>0&&this.applyPropertyDefaultStep(s,e.propertyDefault,u),this.applyMissingScalarPrimitives(s,i,c,e,t,o,r),i)for(let[g,_]of Object.entries(i))g!=="label"&&_!=null&&(s[g]=_);if(e.inheritanceRule&&e.inheritanceRule.length>0&&o&&await this.applyInheritanceRuleStep(s,e.inheritanceRule,o),this.applyMissingBacklinkTopUp(s,e,t,r),t&&e.linkBackProperty&&s[e.linkBackProperty]===void 0){let g=Ys.extractBacklinkTarget(t,r);s[e.linkBackProperty]=`"[[${g}]]"`}let f=s.exo__Asset_uid,d=this.frontmatterService.createFrontmatter("",s),h=this.substituteVariables(e.targetFolder,t,i,void 0,r),p=h?`${h}/${f}.md`:`${f}.md`;return await this.fileWriter.createFile(p,d),{success:!0,openPath:p}}async resolveClassRefToUid(e){if(cA.test(e)||!this.classLabelToUid)return e;try{let t=await this.classLabelToUid(e);return t&&t.length>0?t:e}catch{return e}}applyPropertyDefaultStep(e,t,r){for(let{propertyName:i,value:s}of t){if(e[i]!==void 0)continue;let o=this.resolveSubstitutionMarker(s,r);if(o!=null){if(Array.isArray(o)){if(o.length===0)continue;e[i]=o;continue}if(i==="exo__Instance_class"&&typeof o=="string"){e[i]=[o];continue}e[i]=o}}}applyMissingScalarPrimitives(e,t,r,i,s,o,l){let c=[];e.exo__Asset_uid===void 0&&(e.exo__Asset_uid=this.uidGen.next(),c.push("exo__Asset_uid")),e.exo__Asset_createdAt===void 0&&(e.exo__Asset_createdAt=b1.DateFormatter.toLocalTimestamp(this.clock.now()),c.push("exo__Asset_createdAt"));let u=typeof e.exo__Asset_label=="string"&&e.exo__Asset_label.trim().length===0;if(e.exo__Asset_label===void 0||u){let f=t?.label;if(f===void 0&&i?.labelTemplate)try{let h=this.substituteVariables(i.labelTemplate,s??"",t,o??void 0,l);h.trim().length>0&&(f=h)}catch(h){fc.LoggingService.error(`[GroundingExecutor] labelTemplate substitution failed: ${h instanceof Error?h.message:String(h)}. Falling back to "Untitled".`)}let d=f??"Untitled";e.exo__Asset_label=d,d!=="Untitled"&&e.aliases===void 0&&(e.aliases=[d]),c.push("exo__Asset_label")}e.exo__Instance_class===void 0&&r&&(e.exo__Instance_class=[`"[[${r}]]"`],c.push("exo__Instance_class")),c.length>0&&fc.LoggingService.error(`[GroundingExecutor] Universal Default Template did not cover essential scalar primitives: ${c.join(", ")}. Filled from legacy TS fallback. Vault may be in an unhealthy state \u2014 verify UniversalDefaultTemplate singleton is present and complete.`)}applyMissingBacklinkTopUp(e,t,r,i){if(!r||t.linkBackProperty||e.exo__Asset_prototype!==void 0||e.ems__Effort_parent!==void 0)return;let s=Ys.extractBacklinkTarget(r,i);e.exo__Asset_prototype=`"[[${s}]]"`,fc.LoggingService.error("[GroundingExecutor] No backlink rule fired (Universal IRs absent or no class match). Falling back to legacy exo__Asset_prototype default. Bug #5 may surface if target is not a prototype-instance.")}resolveSubstitutionMarker(e,t){let r=e.match(C6);if(r){let l=r[1],c=r[2],u=Ys.decodeBase64UrlSafe(c),f=(0,S1.getResolver)(l);return f?f(t,u):(fc.LoggingService.warn(`[GroundingExecutor] Parameterised marker references unknown resolver '${l}' \u2014 value left as marker.`),e)}let i=e.match(R6);if(!i)return e;let s=i[1];if(s==="target"){let l=t.targetIRI??"",c=t.targetFilePath??"";return`"[[${Ys.extractBacklinkTarget(l,c)}]]"`}if(s==="targetFolder"){let l=t.targetFilePath??"";if(!l)return"";let c=l.replace(/^\/+/,""),u=c.lastIndexOf("/");return u>=0?c.slice(0,u):""}let o=(0,S1.getResolver)(s);return o?o(t):(fc.LoggingService.warn(`[GroundingExecutor] Marker references unknown resolver '${s}' \u2014 value left as marker.`),e)}static decodeBase64UrlSafe(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t.length%4===0?"":"=".repeat(4-t.length%4);return Buffer.from(t+r,"base64").toString("utf-8")}async applyInheritanceRuleStep(e,t,r){let i=this.extractTargetClassNames(r),s=[];for(let o of t)!await this.inheritanceConditionMatches(o.targetClassCondition,i)||await this.inheritanceExclusionMatches(o.targetClassExclusion,i)||s.push(o);s.sort((o,l)=>l.priority-o.priority);for(let o of s){if(e[o.targetPropertyName]!==void 0)continue;let l=r[o.sourcePropertyName];l!=null&&(e[o.targetPropertyName]=this.formatInheritedValue(l))}}async inheritanceConditionMatches(e,t){return e?this.classMatchesAny(e,t):!0}async inheritanceExclusionMatches(e,t){for(let r of e)if(await this.classMatchesAny(r,t))return!0;return!1}async classMatchesAny(e,t){if(t.includes(e))return!0;if(!this.classLabelToUid)return!1;try{let r=await this.classLabelToUid(e);if(r&&r.length>0&&t.includes(r))return!0}catch{}return!1}extractTargetClassNames(e){let t=e.exo__Instance_class;if(t==null)return[];let r=Array.isArray(t)?t:[t],i=[];for(let s of r){let o=this.extractWikilinkInner(String(s));o&&i.push(o)}return i}extractWikilinkInner(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/);return t?t[1].trim():e.replace(/^["']|["']$/g,"").trim()}formatInheritedValue(e){return Array.isArray(e)?e.map(t=>this.formatInheritedScalar(String(t))):this.formatInheritedScalar(String(e))}formatInheritedScalar(e){return/^"?\[\[.+\]\]"?$/.test(e)?this.reformatWikilink(e):cA.test(e)?`"[[${e}]]"`:e}reformatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:e}async executeStep(e,t,r,i,s){return e.type===ni.GroundingType.COMPOSITE?this.executeComposite(e,t,r,i,s):this.execute(e,t,r,i)}async rollback(e,t,r){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(i){fc.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,i instanceof Error?i:new Error(String(i)))}}substituteVariables(e,t,r,i,s){let o=this.clock.now(),l=o.toISOString(),c=b1.DateFormatter.toLocalTimestamp(o),u=l.slice(0,10),f=`${u}T00:00:00`,d=`${c.slice(0,10)}-${c.slice(11,13)}-${c.slice(14,16)}`,h=e.replace(/\$target\.([A-Za-z_][\w]*)/g,(p,g)=>{if(!i)throw new Error(`$target.${g} substitution requires target frontmatter context; none was supplied (asset IRI: ${t})`);let _=i[g];if(_==null)throw new Error(`$target.${g} is undefined on asset ${t}`);if(Array.isArray(_))throw new Error(`$target.${g} resolved to an array on asset ${t}; only scalar properties are supported for substitution`);return String(_).replace(/^["'](.*)["']$/,"$1")});if(/\$targetFolder\b/.test(h)){if(!s)throw new Error("$targetFolder substitution requires targetFilePath context; none was supplied (asset IRI: "+t+")");let p=s.replace(/^\/+/,""),g=p.lastIndexOf("/"),_=g>=0?p.slice(0,g):"";h=h.replace(/\$targetFolder\b/g,_)}if(h=h.replace(/\$target/g,t).replace(/\$nowCompact\b/g,d).replace(/\$nowLocal/g,c).replace(/\$now/g,l).replace(/\$todayStart\b/g,f).replace(/\$today/g,u),r?.value!==void 0&&r.value!==null){let p=String(r.value);h=h.replace(/\$input\b/g,p).replace(/\$value\b/g,p)}return h}async executePropertyAppend(e,t,r,i){if(!e.targetProperty)return{success:!1,error:"property_append requires targetProperty"};if(e.appendExpression===void 0)return{success:!1,error:"property_append requires appendExpression"};let s=await this.fileReader.readFile(r),o=this.frontmatterService.parseObject(s)??{},l=this.substituteVariables(e.appendExpression,t,i,o),c=o[e.targetProperty],u=Array.isArray(c)?c:c!==void 0?[String(c)]:[],f=a(g=>g.replace(/^["'](.*)["']$/,"$1"),"stripQuotes"),d=new Set(u.map(f)),h;if(d.has(f(l)))h=u;else{let g=`"${f(l)}"`;h=[...u,g]}let p=this.frontmatterService.updateProperty(s,e.targetProperty,h);return await this.fileWriter.updateFile(r,p),{success:!0}}async executePropertyIncrement(e,t){if(!e.targetProperty)return{success:!1,error:"property_increment requires targetProperty"};let r=e.incrementBy??1;if(!Number.isFinite(r)||!Number.isInteger(r))return{success:!1,error:`property_increment: incrementBy must be an integer (got ${String(e.incrementBy)})`};let i=await this.fileReader.readFile(t),o=(this.frontmatterService.parseObject(i)??{})[e.targetProperty],l;if(o==null||o==="")l=0;else{if(Array.isArray(o))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" is an array, expected integer`};{let f=String(o).replace(/^["'](.*)["']$/,"$1").trim();if(!/^-?\d+$/.test(f))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" current value "${String(o)}" is not a valid integer`};l=Number.parseInt(f,10)}}let c=l+r,u=this.frontmatterService.updateProperty(i,e.targetProperty,c);return await this.fileWriter.updateFile(t,u),{success:!0}}async executePropertyShift(e,t){if(!e.targetProperty)return{success:!1,error:"property_shift requires targetProperty"};if(!e.shiftDelta)return{success:!1,error:"property_shift requires shiftDelta (ISO-8601 duration literal)"};let r=await this.fileReader.readFile(t),s=(this.frontmatterService.parseObject(r)??{})[e.targetProperty];if(s==null||s==="")return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is not set on target asset`};if(Array.isArray(s))return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is an array, expected single datetime`};let o=String(s).replace(/^["'](.*)["']$/,"$1").trim(),l=new Date(o);if(Number.isNaN(l.getTime()))return{success:!1,error:`property_shift: current value "${o}" is not a valid datetime`};let c;try{c=Ys.applyIsoDuration(l,e.shiftDelta)}catch(d){return{success:!1,error:`property_shift: invalid shiftDelta "${e.shiftDelta}": ${d instanceof Error?d.message:String(d)}`}}let u=b1.DateFormatter.toLocalTimestamp(c),f=this.frontmatterService.updateProperty(r,e.targetProperty,u);return await this.fileWriter.updateFile(t,f),{success:!0}}async executeWorkflowTransition(e,t,r,i){if(!this.workflowResolver)return{success:!1,error:"workflow_transition requires WorkflowResolver injection (options.workflowResolver). Wire the plugin/CLI before using this grounding type."};let s=await this.fileReader.readFile(r),o=this.frontmatterService.parseObject(s)??{},l=this.resolveAssetClassFromFrontmatter(o);if(!l)return{success:!1,error:"workflow_transition: target asset has no recognised ems__* class in exo__Instance_class (cannot resolve workflow)."};let c=this.resolveStatusFromFrontmatter(o);if(!c)return{success:!1,error:"workflow_transition: target asset has no parseable ems__Effort_status value (need wikilink to an ems__EffortStatus* asset)."};let u;try{u=new T6.IRI(t)}catch(I){return{success:!1,error:`workflow_transition: invalid targetIRI "${t}" \u2014 ${I instanceof Error?I.message:String(I)}`}}let f=await this.workflowResolver.resolveForAsset(u,l),d=e.direction??"forward",h=d==="rollback",p=f.transitions.find(I=>I.from===c&&I.isRollback===h);if(!p)return{success:!1,error:`workflow_transition: no ${d} transition from "${c}" defined in workflow "${f.name}" (target class: ${l}).`};let g=Sr.STATUS_UID_BY_ENUM[p.to];if(!g)return{success:!1,error:`workflow_transition: no UID mapping for destination status "${p.to}" (transition target unreachable).`};let _={id:`${e.id}.statusMutation`,label:`workflow_transition: ${p.from} \u2192 ${p.to}`,type:ni.GroundingType.PROPERTY_SET,targetProperty:"ems__Effort_status",targetValueRef:g},v=await this.executePropertySet(_,t,r,i);if(!v.success)return{success:!1,error:`workflow_transition: status mutation failed \u2014 ${v.error}`};let w=p.postActions??[],E=this.groundingLoader;if(w.length>0&&E===void 0)return{success:!1,error:"workflow_transition: transition has postActions but no GroundingLoader injected (options.groundingLoader). Wire commandResolver.loadGroundingByUid in plugin/CLI."};for(let I of w){if(E===void 0)break;let O=await E(I);if(!O)return{success:!1,error:`workflow_transition: postAction grounding UID "${I}" could not be loaded (asset missing or invalid Grounding shape).`};let C=await this.execute(O,t,r,i);if(!C.success)return{success:!1,error:`workflow_transition: postAction "${O.label}" (UID ${I}) failed \u2014 ${C.error}`}}return{success:!0}}resolveAssetClassFromFrontmatter(e){let t=e.exo__Instance_class;if(t==null)return null;let r=Array.isArray(t)?t:[t],i=new Set(Object.values(Yp.AssetClass));for(let s of r){if(typeof s!="string")continue;let o=s.replace(/^\s*"?\[\[/,"").replace(/\]\]"?\s*$/,""),c=(o.includes("|")?o.split("|")[1]:o).trim();if(i.has(c))return c;let u=o.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);if(u){let f=Sr.CLASS_UID_TO_LABEL[u[1].toLowerCase()];if(f&&i.has(f))return f}}return null}resolveStatusFromFrontmatter(e){let t=e.ems__Effort_status;if(t==null)return null;if(Array.isArray(t)){if(t.length!==1)return null;t=t[0]}let i=String(t).trim().replace(/^["']/,"").replace(/["']$/,"").replace(/^\[\[/,"").replace(/\]\]$/,"");if(/^ems__EffortStatus[A-Za-z]+$/.test(i))return i;if(i.includes("|")){let o=i.split("|")[1].trim();if(/^ems__EffortStatus[A-Za-z]+$/.test(o))return o}let s=i.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);if(s){let o=x6[s[1].toLowerCase()];if(o)return o}return null}static applyIsoDuration(e,t){let r=t.trim();if(/^-?P(\d+Y)(\d+M)?$|^-?P\d+M$/.test(r)){let o=lA.DateTimeParsing.parseYearMonthDuration(r),l=new Date(e.getTime());return l.setMonth(l.getMonth()+o),l}let s=lA.DateTimeParsing.parseDayTimeDuration(r);return new Date(e.getTime()+s)}static extractBacklinkTarget(e,t){let r=Ys.resolveTargetPath(e,t),i=r.split("/").pop()??r;return Ys.UUID_BASENAME_RE.test(i)?i:r}static resolveTargetPath(e,t){if(t)return t.replace(/\.md$/i,"").replace(/^\/+/,"");if(e){let r=e.match(/^obsidian:\/\/vault\/(.+?)(?:\.md)?(?:\?|#|$)/i);if(r&&r[1])try{return decodeURIComponent(r[1])}catch{return r[1]}}return e}};Sr.GroundingExecutor=Kp;Kp.UUID_BASENAME_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Sr.GroundingExecutor=Kp=Ys=b6([(0,w6.injectable)(),S6("design:paramtypes",[Object,Object,Xp,Function,Object])],Kp)});var dA=S(w1=>{"use strict";Object.defineProperty(w1,"__esModule",{value:!0});w1.createVaultFrontmatterClassLabelResolver=P6;function P6(n){return async e=>{if(!e)return null;let t=await n.findFilesByMetadata({exo__Asset_label:e});if(t.length>0){let s=(await n.getFileMetadata(t[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}let r=await n.findFilesByMetadata({aliases:e});if(r.length>0){let s=(await n.getFileMetadata(r[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}return null}}a(P6,"createVaultFrontmatterClassLabelResolver")});var hA=S(Xs=>{"use strict";var O6=Xs&&Xs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},F6=Xs&&Xs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},v1;Object.defineProperty(Xs,"__esModule",{value:!0});Xs.CommandExecutionFlow=void 0;var D6=Oe(),L6=Io(),N6=Ae(),k6=$e(),M6=er(),j6=Fn(),E1=v1=class{static{a(this,"CommandExecutionFlow")}constructor(e,t,r,i,s,o){this.groundingExecutor=e,this.notificationService=t,this.logger=r,this.prompts=i,this.tripleStore=s,this.fileOpener=o}async run(e,t){let{command:r}=e;if(r.confirmMessage&&!await this.prompts.confirm(r.confirmMessage))return;let i=t.injectedUserInput,s=v1.extractInputSchema(e);if(s!==null&&s.length>0){let c=await this.applyLabelDatePrefill(s,r.grounding,t.targetIRI),u=await this.prompts.promptInputSchema(c);if(u===null)return;i={...t.injectedUserInput??{},...u}}let o=await this.groundingExecutor.execute(r.grounding,t.targetIRI??"",t.filePath??"",i),l=t.filePath??"<no-file>";if(o.success){if(r.successMessage&&this.notificationService.success(r.successMessage),await new Promise(c=>setTimeout(c,100)),t.onComplete&&await t.onComplete(),o.openPath&&this.fileOpener)try{await this.fileOpener.open(o.openPath,{sameTab:r.openInSameTab})}catch(c){this.logger.info(`[CommandExecutionFlow] Failed to open created file "${o.openPath}": ${c instanceof Error?c.message:String(c)}`)}this.logger.info(`[CommandExecutionFlow] Executed "${r.name}" on ${l}`)}else this.notificationService.error(`Command failed: ${o.error??"unknown error"}`),this.logger.info(`[CommandExecutionFlow] Failed "${r.name}": ${o.error}`)}static extractInputSchema(e){let r=e.command.grounding.inputSchema;return!r||!Array.isArray(r)?null:r}async applyLabelDatePrefill(e,t,r){if(t.type!==L6.GroundingType.CREATE_INSTANCE||!t.prefillLabelWithDate||!r||!this.tripleStore)return e;let i=await this.resolveAssetLabel(r);if(!i)return e;let s=j6.DateFormatter.toDateString(new Date),o=`${i} ${s}`;return e.map(l=>{if(typeof l!="object"||l===null)return l;let c=l;if(c.name!=="label")return l;let u=c.defaultValue;return typeof u=="string"&&u.length>0?l:{...c,defaultValue:o}})}async resolveAssetLabel(e){if(!this.tripleStore)return;let t=new N6.IRI(e),r=await this.tripleStore.match(t,M6.Namespace.EXO.term("Asset_label"),void 0);if(r.length===0)return;let i=r[0].object;if(i instanceof k6.Literal)return i.value.length>0?i.value:void 0}};Xs.CommandExecutionFlow=E1;Xs.CommandExecutionFlow=E1=v1=O6([(0,D6.injectable)(),F6("design:paramtypes",[Function,Object,Object,Object,Object,Object])],E1)});var uf=S(Ks=>{"use strict";var $6=Ks&&Ks.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},U6=Ks&&Ks.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Ks,"__esModule",{value:!0});Ks.WorkflowEngine=void 0;var V6=Oe(),T1=class{static{a(this,"WorkflowEngine")}constructor(e){this.definition=e}getAvailableTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&!t.isRollback)}getRollbackTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&t.isRollback)}getAllTransitions(e){return this.definition.transitions.filter(t=>t.from===e)}canTransition(e,t){return this.definition.transitions.some(r=>r.from===e&&r.to===t)}getPreviousStatus(e){return this.definition.transitions.find(r=>r.from===e&&r.isRollback)?.to??null}getNextStates(e){return this.getAvailableTransitions(e).map(t=>t.to)}isTerminalState(e){return this.definition.terminalStates.includes(e)}isInitialState(e){return this.definition.initialState===e}getTimestampsForStatus(e){return this.definition.states.find(r=>r.status===e)?.timestampOnEnter??[]}getTransition(e,t){return this.definition.transitions.find(r=>r.from===e&&r.to===t)}getOrderedStates(){return this.definition.states.map(e=>e.status)}getDefinition(){return this.definition}validate(){let e=[],t=new Set(this.definition.states.map(i=>i.status));this.definition.states.length===0&&e.push("Workflow must have at least one state"),t.has(this.definition.initialState)||e.push(`Initial state "${this.definition.initialState}" is not in the states list`);for(let i of this.definition.terminalStates)t.has(i)||e.push(`Terminal state "${i}" is not in the states list`);for(let i of this.definition.transitions)t.has(i.from)||e.push(`Transition "${i.label}" references unknown source state "${i.from}"`),t.has(i.to)||e.push(`Transition "${i.label}" references unknown target state "${i.to}"`);for(let i of this.definition.states){if(this.definition.terminalStates.includes(i.status))continue;this.definition.transitions.filter(o=>o.from===i.status&&!o.isRollback).length===0&&e.push(`State "${i.status}" has no outgoing forward transitions (dead end)`)}let r=new Set;for(let i of this.definition.transitions){let s=`${i.from}\u2192${i.to}`;r.has(s)&&e.push(`Duplicate transition: ${s}`),r.add(s)}return{valid:e.length===0,errors:e}}};Ks.WorkflowEngine=T1;Ks.WorkflowEngine=T1=$6([(0,V6.injectable)(),U6("design:paramtypes",[Object])],T1)});var pA=S(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.EFFORT_WORKFLOW_PROPERTY=us.WorkflowTransitionProperty=us.WorkflowStateProperty=us.WorkflowProperty=void 0;us.WorkflowProperty={TARGET_CLASS:"ems__Workflow_targetClass",INITIAL_STATE:"ems__Workflow_initialState",TERMINAL_STATES:"ems__Workflow_terminalStates",IS_DEFAULT:"ems__Workflow_isDefault"};us.WorkflowStateProperty={WORKFLOW:"ems__WorkflowState_workflow",STATUS:"ems__WorkflowState_status",ORDER:"ems__WorkflowState_order",OPTIONAL:"ems__WorkflowState_optional",TIMESTAMP_ON_ENTER:"ems__WorkflowState_timestampOnEnter",BADGE_COLOR:"ems__WorkflowState_badgeColor"};us.WorkflowTransitionProperty={WORKFLOW:"ems__WorkflowTransition_workflow",FROM:"ems__WorkflowTransition_from",TO:"ems__WorkflowTransition_to",LABEL:"ems__WorkflowTransition_label",ICON:"ems__WorkflowTransition_icon",IS_ROLLBACK:"ems__WorkflowTransition_isRollback"};us.EFFORT_WORKFLOW_PROPERTY="ems__Effort_workflow"});var Js=S(Jp=>{"use strict";Object.defineProperty(Jp,"__esModule",{value:!0});Jp.MetadataHelpers=void 0;var mA=af(),I1=class{static{a(this,"MetadataHelpers")}static findAllReferencingProperties(e,t){let r=[];for(let[i,s]of Object.entries(e))this.containsReference(s,t)&&r.push(i);return r}static findReferencingProperty(e,t){for(let[r,i]of Object.entries(e))if(this.containsReference(i,t))return r}static containsReference(e,t){if(!e)return!1;let r=t.replace(/\.md$/,"");if(typeof e=="string"){let i=/\[\[([^[\]]+)\]\]/g,s;for(;(s=i.exec(e))!==null;){let l=s[1].split("|")[0].trim();if(l===r||l.endsWith(`/${r}`))return!0}return!1}return Array.isArray(e)?e.some(i=>this.containsReference(i,t)):!1}static isAssetArchived(e){let t=e?.exo__Asset_isArchived;if(t!=null){if(t===!0||t===1)return!0;if(typeof t=="string"){let i=t.toLowerCase().trim();if(i==="true"||i==="yes"||i==="1")return!0}if(typeof t=="boolean")return t}let r=e?.archived;if(r==null)return!1;if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0;if(typeof r=="string"){let i=r.toLowerCase().trim();return i==="true"||i==="yes"||i==="1"}return!1}static getPropertyValue(e,t){return t==="Name"||t==="title"?e.title:t==="created"?e.created:t==="modified"?e.modified:t==="path"?e.path:e.metadata?.[t]}static ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}static buildFileContent(e,t){let r=(0,mA.orderProperties)(e,(0,mA.loadDefaultSpec)()),i=Object.entries(r).map(([l,c])=>{if(Array.isArray(c)){let u=c.map(f=>` - ${String(f)}`).join(`
92
92
  `);return`${l}:
93
93
  ${u}`}return`${l}: ${String(c)}`}).join(`
94
94
  `),s=t;if(s===void 0){let l=r.exo__Asset_label;typeof l=="string"&&l.trim()!==""&&(s=`# ${l}`)}let o=s?`
@@ -97,7 +97,7 @@ ${s}
97
97
  `;return`---
98
98
  ${i}
99
99
  ---
100
- ${o}`}};Jp.MetadataHelpers=I1});var yA=S(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.TASK_DEFAULT_WORKFLOW=Va.PROJECT_DEFAULT_WORKFLOW=void 0;Va.buildWorkflowAssetContent=B6;var gA=mi(),ff=Il(),Re=xl(),zr=pA(),x1=Js();Va.PROJECT_DEFAULT_WORKFLOW={id:"a1b2c3d4-1111-4000-a000-000000000001",name:"Project Default Workflow",targetClass:ff.AssetClass.PROJECT,initialState:Re.EffortStatus.DRAFT,terminalStates:[Re.EffortStatus.DONE,Re.EffortStatus.TRASHED],isDefault:!0,states:[{status:Re.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.ANALYSIS,order:3,optional:!0,timestampOnEnter:[]},{status:Re.EffortStatus.TODO,order:4,optional:!0,timestampOnEnter:[]},{status:Re.EffortStatus.DOING,order:5,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:Re.EffortStatus.DONE,order:6,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:Re.EffortStatus.TRASHED,order:7,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:Re.EffortStatus.DRAFT,to:Re.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.ANALYSIS,label:"\u2192 Analysis",isRollback:!1},{from:Re.EffortStatus.ANALYSIS,to:Re.EffortStatus.TODO,label:"\u2192 ToDo",isRollback:!1},{from:Re.EffortStatus.TODO,to:Re.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:Re.EffortStatus.ANALYSIS,to:Re.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:Re.EffortStatus.TODO,to:Re.EffortStatus.ANALYSIS,label:"\u2190 Analysis",isRollback:!0},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.TODO,label:"\u2190 ToDo",isRollback:!0},{from:Re.EffortStatus.DONE,to:Re.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};Va.TASK_DEFAULT_WORKFLOW={id:"a1b2c3d4-2222-4000-a000-000000000002",name:"Task Default Workflow",targetClass:ff.AssetClass.TASK,initialState:Re.EffortStatus.DRAFT,terminalStates:[Re.EffortStatus.DONE,Re.EffortStatus.TRASHED],isDefault:!0,states:[{status:Re.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.DOING,order:3,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:Re.EffortStatus.DONE,order:4,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:Re.EffortStatus.TRASHED,order:5,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:Re.EffortStatus.DRAFT,to:Re.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:Re.EffortStatus.DONE,to:Re.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};function B6(n){let e=new Date().toISOString(),t=[],r=n.id,i={exo__Asset_uid:r,exo__Asset_label:`"${n.name}"`,exo__Asset_createdAt:e,exo__Instance_class:ff.AssetClass.WORKFLOW,[zr.WorkflowProperty.TARGET_CLASS]:`"[[${n.targetClass}]]"`,[zr.WorkflowProperty.INITIAL_STATE]:`"[[${n.initialState}]]"`,[zr.WorkflowProperty.TERMINAL_STATES]:n.terminalStates.map(s=>`"[[${s}]]"`),[zr.WorkflowProperty.IS_DEFAULT]:n.isDefault};t.push({filename:`${r}.md`,content:x1.MetadataHelpers.buildFileContent(i)});for(let s of n.states){let o=(0,gA.v4)(),l={exo__Asset_uid:o,exo__Asset_label:`"${n.name} - ${s.status}"`,exo__Asset_createdAt:e,exo__Instance_class:ff.AssetClass.WORKFLOW_STATE,[zr.WorkflowStateProperty.WORKFLOW]:`"[[${r}]]"`,[zr.WorkflowStateProperty.STATUS]:`"[[${s.status}]]"`,[zr.WorkflowStateProperty.ORDER]:s.order,[zr.WorkflowStateProperty.OPTIONAL]:s.optional};s.timestampOnEnter.length>0&&(l[zr.WorkflowStateProperty.TIMESTAMP_ON_ENTER]=s.timestampOnEnter),s.badgeColor&&(l[zr.WorkflowStateProperty.BADGE_COLOR]=`"${s.badgeColor}"`),t.push({filename:`${o}.md`,content:x1.MetadataHelpers.buildFileContent(l)})}for(let s of n.transitions){let o=(0,gA.v4)(),l={exo__Asset_uid:o,exo__Asset_label:`"${n.name} - ${s.label}"`,exo__Asset_createdAt:e,exo__Instance_class:ff.AssetClass.WORKFLOW_TRANSITION,[zr.WorkflowTransitionProperty.WORKFLOW]:`"[[${r}]]"`,[zr.WorkflowTransitionProperty.FROM]:`"[[${s.from}]]"`,[zr.WorkflowTransitionProperty.TO]:`"[[${s.to}]]"`,[zr.WorkflowTransitionProperty.LABEL]:`"${s.label}"`,[zr.WorkflowTransitionProperty.IS_ROLLBACK]:s.isRollback};s.icon&&(l[zr.WorkflowTransitionProperty.ICON]=`"${s.icon}"`),t.push({filename:`${o}.md`,content:x1.MetadataHelpers.buildFileContent(l)})}return t}a(B6,"buildWorkflowAssetContent")});var R1=S(Zs=>{"use strict";var G6=Zs&&Zs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},q6=Zs&&Zs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.WorkflowResolver=void 0;var W6=Oe(),dc=Ae(),Hr=$e(),St=er(),Ba=Il(),Zp=xl(),_A=yA(),A1=class{static{a(this,"WorkflowResolver")}constructor(e){this.tripleStore=e,this.cache=new Map}async resolveForClass(e){let t=`class:${e}`,r=this.cache.get(t);if(r)return r;let s=await this.findDefaultWorkflow(e)??this.getHardcodedFallback(e);return this.cache.set(t,s),s}async resolveForAsset(e,t){let r=await this.tripleStore.match(e,St.Namespace.EMS.term("Effort_workflow"),void 0);if(r.length>0){let i=r[0].object;if(i instanceof dc.IRI){let s=await this.loadWorkflowBySubject(i);if(s)return s}}return this.resolveForClass(t)}invalidateCache(){this.cache.clear()}async findDefaultWorkflow(e){let t=await this.tripleStore.match(void 0,St.Namespace.RDF.term("type"),St.Namespace.EMS.term("Workflow"));for(let r of t){let i=r.subject;if(!(!(await this.tripleStore.match(i,St.Namespace.EMS.term("Workflow_targetClass"),void 0)).some(u=>{let f=u.object;return f instanceof dc.IRI?f.value.endsWith(e.replace(/^ems__/,"")):f instanceof Hr.Literal?this.normalizeWikilink(f.value)===e:!1})||!(await this.tripleStore.match(i,St.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(u=>{let f=u.object instanceof Hr.Literal?u.object.value:"";return f==="true"||f==="1"})))return this.loadWorkflowBySubject(i)}return null}async loadWorkflowBySubject(e){let t=await this.tripleStore.match(e,St.Namespace.EXO.term("Asset_label"),void 0),r=t.length>0&&t[0].object instanceof Hr.Literal?t[0].object.value:"Unknown Workflow",i=await this.tripleStore.match(e,St.Namespace.EXO.term("Asset_uid"),void 0),s=i.length>0&&i[0].object instanceof Hr.Literal?i[0].object.value:e.value,o=await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_targetClass"),void 0),l=this.resolveAssetClass(o),c=await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_initialState"),void 0),u=this.resolveEffortStatus(c)??Zp.EffortStatus.DRAFT,f=await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_terminalStates"),void 0),d=this.resolveEffortStatuses(f),p=(await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(v=>{let w=v.object instanceof Hr.Literal?v.object.value:"";return w==="true"||w==="1"}),g=await this.loadStates(e),_=await this.loadTransitions(e);return g.length===0&&_.length===0?null:{id:s,name:r,targetClass:l,states:g,transitions:_,initialState:u,terminalStates:d.length>0?d:[Zp.EffortStatus.DONE,Zp.EffortStatus.TRASHED],isDefault:p}}async loadStates(e){let t=await this.tripleStore.match(void 0,St.Namespace.RDF.term("type"),St.Namespace.EMS.term("WorkflowState")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_workflow"),void 0)).some(E=>this.isSameSubject(E.object,e)))continue;let c=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_status"),void 0),u=this.resolveEffortStatus(c);if(!u)continue;let f=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_order"),void 0),d=f.length>0&&f[0].object instanceof Hr.Literal&&parseInt(f[0].object.value,10)||0,p=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_optional"),void 0)).some(E=>{let I=E.object instanceof Hr.Literal?E.object.value:"";return I==="true"||I==="1"}),_=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_timestampOnEnter"),void 0)).map(E=>E.object instanceof Hr.Literal?E.object.value:"").filter(E=>E.length>0),v=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_badgeColor"),void 0),w=v.length>0&&v[0].object instanceof Hr.Literal?v[0].object.value:void 0;r.push({status:u,order:d,optional:p,timestampOnEnter:_,badgeColor:w})}return r.sort((i,s)=>i.order-s.order)}async loadTransitions(e){let t=await this.tripleStore.match(void 0,St.Namespace.RDF.term("type"),St.Namespace.EMS.term("WorkflowTransition")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_workflow"),void 0)).some(A=>this.isSameSubject(A.object,e)))continue;let c=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_from"),void 0),u=this.resolveEffortStatus(c),f=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_to"),void 0),d=this.resolveEffortStatus(f);if(!u||!d)continue;let h=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_label"),void 0),p=h.length>0&&h[0].object instanceof Hr.Literal?h[0].object.value:`${u} \u2192 ${d}`,g=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_icon"),void 0),_=g.length>0&&g[0].object instanceof Hr.Literal?g[0].object.value:void 0,w=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_isRollback"),void 0)).some(A=>{let D=A.object instanceof Hr.Literal?A.object.value:"";return D==="true"||D==="1"}),I=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_postActions"),void 0)).map(A=>this.extractUid(A.object)).filter(A=>A!==null);r.push({from:u,to:d,label:p,icon:_,isRollback:w,postActions:I.length>0?I:void 0})}return r}extractUid(e){let t=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i,r=e instanceof dc.IRI||e instanceof Hr.Literal?e.value:null;if(r===null)return null;let i=r.match(t);return i?i[1].toLowerCase():null}normalizeWikilink(e){return e.replace(/["'[\]]/g,"").trim()}resolveAssetClass(e){if(e.length===0)return Ba.AssetClass.TASK;let t=e[0].object;if(t instanceof dc.IRI){let i=`ems__${t.value.split("#").pop()??""}`;return Object.values(Ba.AssetClass).includes(i)?i:Ba.AssetClass.TASK}if(t instanceof Hr.Literal){let r=this.normalizeWikilink(t.value);return Object.values(Ba.AssetClass).includes(r)?r:Ba.AssetClass.TASK}return Ba.AssetClass.TASK}resolveEffortStatus(e){if(e.length===0)return null;let t=e[0].object,r;if(t instanceof dc.IRI)r=`ems__${t.value.split("#").pop()??""}`;else if(t instanceof Hr.Literal)r=this.normalizeWikilink(t.value);else return null;return Object.values(Zp.EffortStatus).includes(r)?r:null}resolveEffortStatuses(e){return e.map(t=>this.resolveEffortStatus([t])).filter(t=>t!==null)}isSameSubject(e,t){if(e instanceof dc.IRI)return e.value===t.value;if(e instanceof Hr.Literal){let r=this.normalizeWikilink(e.value);return t.value.includes(r)}return!1}getHardcodedFallback(e){return e===Ba.AssetClass.PROJECT?{..._A.PROJECT_DEFAULT_WORKFLOW}:{..._A.TASK_DEFAULT_WORKFLOW}}};Zs.WorkflowResolver=A1;Zs.WorkflowResolver=A1=G6([(0,W6.injectable)(),q6("design:paramtypes",[Object])],A1)});var F1=S(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.TransactionError=Vo.TripleNotFoundError=Vo.TripleAlreadyExistsError=void 0;var C1=class extends Error{static{a(this,"TripleAlreadyExistsError")}constructor(e){super(`Triple already exists: ${e.toString()}`),this.name="TripleAlreadyExistsError"}};Vo.TripleAlreadyExistsError=C1;var P1=class extends Error{static{a(this,"TripleNotFoundError")}constructor(e){super(`Triple not found: ${e.toString()}`),this.name="TripleNotFoundError"}};Vo.TripleNotFoundError=P1;var O1=class extends Error{static{a(this,"TransactionError")}constructor(e){super(e),this.name="TransactionError"}};Vo.TransactionError=O1});var tm=S(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});em.LRUCache=void 0;var D1=class{static{a(this,"LRUCache")}constructor(e){this.maxSize=e,this.cache=new Map}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};em.LRUCache=D1});var k1=S(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});nm.InMemoryTripleStore=void 0;var Bo=F1(),rm=Ae(),z6=$t(),H6=$e(),Q6=er(),Y6=tm(),X6=Q6.Namespace.XSD.term("string").value,K6=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,hc="__default__",L1=class n{static{a(this,"InMemoryTripleStore")}constructor(){this.triples=new Map,this.spo=new Map,this.sop=new Map,this.pso=new Map,this.pos=new Map,this.osp=new Map,this.ops=new Map,this.queryCache=new Y6.LRUCache(1e3),this.uuidIndex=new Map,this.namedGraphs=new Map}async add(e){let t=this.getTripleKey(e);if(this.triples.has(t))return;this.triples.set(t,e);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);this.addToIndex(this.spo,r,i,s),this.addToIndex(this.sop,r,s,i),this.addToIndex(this.pso,i,r,s),this.addToIndex(this.pos,i,s,r),this.addToIndex(this.osp,s,r,i),this.addToIndex(this.ops,s,i,r),this.addToUUIDIndex(e.subject),this.queryCache.clear()}async remove(e){let t=this.getTripleKey(e);if(!this.triples.has(t))return!1;this.triples.delete(t);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);return this.removeFromIndex(this.spo,r,i,s),this.removeFromIndex(this.sop,r,s,i),this.removeFromIndex(this.pso,i,r,s),this.removeFromIndex(this.pos,i,s,r),this.removeFromIndex(this.osp,s,r,i),this.removeFromIndex(this.ops,s,i,r),this.queryCache.clear(),!0}async has(e){let t=this.getTripleKey(e);return this.triples.has(t)}async match(e,t,r){let i=this.getMatchCacheKey(e,t,r),s=this.queryCache.get(i);if(s!==void 0)return s;let o;return!e&&!t&&!r?o=Array.from(this.triples.values()):e&&t&&r?o=this.matchSPO(e,t,r):e&&t?o=this.matchSP(e,t):e&&r?o=this.matchSO(e,r):t&&r?o=this.matchPO(t,r):e?o=this.matchS(e):t?o=this.matchP(t):r?o=this.matchO(r):o=[],this.queryCache.set(i,o),o}async addAll(e){for(let t of e)await this.add(t)}async removeAll(e){let t=0;for(let r of e)await this.remove(r)&&t++;return t}async clear(){this.triples.clear(),this.spo.clear(),this.sop.clear(),this.pso.clear(),this.pos.clear(),this.osp.clear(),this.ops.clear(),this.uuidIndex.clear(),this.queryCache.clear()}async count(){return this.triples.size}async subjects(){let e=new Set;for(let t of this.triples.values())e.add(t.subject);return Array.from(e)}async predicates(){let e=new Set;for(let t of this.triples.values())e.add(t.predicate);return Array.from(e)}async objects(){let e=new Set;for(let t of this.triples.values())e.add(t.object);return Array.from(e)}async beginTransaction(){return new N1(this)}async findSubjectsByUUID(e){return this.findSubjectsByUUIDSync(e)}findSubjectsByUUIDSync(e){let t=e.toLowerCase(),r=this.uuidIndex.get(t);if(!r||r.size===0)return[];let i=[];for(let s of r)this.spo.has(`i:${s}`)&&i.push(new rm.IRI(s));return i}addToUUIDIndex(e){if(!(e instanceof rm.IRI))return;let t=e.value,r=t.match(K6);if(r)for(let i of r){let s=i.toLowerCase();this.uuidIndex.has(s)||this.uuidIndex.set(s,new Set),this.uuidIndex.get(s).add(t)}}matchSPO(e,t,r){let i=this.getNodeKey(e),s=this.getNodeKey(t),o=this.getNodeKey(r),l=this.spo.get(i);if(!l)return[];let c=l.get(s);if(!c)return[];if(c.has(o)){let u=this.buildTripleKey(i,s,o),f=this.triples.get(u);return f?[f]:[]}return[]}matchSP(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.spo.get(r);if(!s)return[];let o=s.get(i);return o?this.getTriplesByKeys(Array.from(o).map(l=>this.buildTripleKey(r,i,l))):[]}matchSO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.sop.get(r);if(!s)return[];let o=s.get(i);return o?this.getTriplesByKeys(Array.from(o).map(l=>this.buildTripleKey(r,l,i))):[]}matchPO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.pos.get(r);if(!s)return[];let o=s.get(i);return o?this.getTriplesByKeys(Array.from(o).map(l=>this.buildTripleKey(l,r,i))):[]}matchS(e){let t=this.getNodeKey(e),r=this.spo.get(t);if(!r)return[];let i=[];for(let[s,o]of r.entries())for(let l of o)i.push(this.buildTripleKey(t,s,l));return this.getTriplesByKeys(i)}matchP(e){let t=this.getNodeKey(e),r=this.pso.get(t);if(!r)return[];let i=[];for(let[s,o]of r.entries())for(let l of o)i.push(this.buildTripleKey(s,t,l));return this.getTriplesByKeys(i)}matchO(e){let t=this.getNodeKey(e),r=this.osp.get(t);if(!r)return[];let i=[];for(let[s,o]of r.entries())for(let l of o)i.push(this.buildTripleKey(s,l,t));return this.getTriplesByKeys(i)}getTriplesByKeys(e){let t=[];for(let r of e){let i=this.triples.get(r);i&&t.push(i)}return t}addToIndex(e,t,r,i){e.has(t)||e.set(t,new Map);let s=e.get(t);s.has(r)||s.set(r,new Set),s.get(r).add(i)}removeFromIndex(e,t,r,i){let s=e.get(t);if(!s)return;let o=s.get(r);o&&(o.delete(i),o.size===0&&s.delete(r),s.size===0&&e.delete(t))}getTripleKey(e){let t=this.getNodeKey(e.subject),r=this.getNodeKey(e.predicate),i=this.getNodeKey(e.object);return this.buildTripleKey(t,r,i)}buildTripleKey(e,t,r){return`${e}|${t}|${r}`}getNodeKey(e){if(e instanceof rm.IRI)return`i:${e.value}`;if(e instanceof z6.BlankNode)return`b:${e.id}`;if(e instanceof H6.Literal){let t=`l:${e.value}`;return e.datatype&&e.datatype.value!==X6?t+=`^^${e.datatype.value}`:e.language&&(t+=`@${e.language}`),t}return""}getMatchCacheKey(e,t,r){let i=e?this.getNodeKey(e):"?",s=t?this.getNodeKey(t):"?",o=r?this.getNodeKey(r):"?";return`${i}|${s}|${o}`}getGraphKey(e){return e?e.value:hc}getOrCreateGraphStore(e){let t=this.getGraphKey(e);return t===hc?this:(this.namedGraphs.has(t)||this.namedGraphs.set(t,new n),this.namedGraphs.get(t))}async addToGraph(e,t){await this.getOrCreateGraphStore(t).add(e)}async removeFromGraph(e,t){let r=this.getGraphKey(t);if(r===hc)return this.remove(e);let i=this.namedGraphs.get(r);return i?i.remove(e):!1}async matchInGraph(e,t,r,i){let s=this.getGraphKey(i);if(s===hc)return this.match(e,t,r);let o=this.namedGraphs.get(s);return o?o.match(e,t,r):[]}async getNamedGraphs(){return Array.from(this.namedGraphs.keys()).map(e=>new rm.IRI(e))}async hasGraph(e){let t=this.namedGraphs.get(e.value);return t?await t.count()>0:!1}async clearGraph(e){let t=this.getGraphKey(e);if(t===hc){await this.clear();return}let r=this.namedGraphs.get(t);r&&(await r.clear(),this.namedGraphs.delete(t))}async countInGraph(e){let t=this.getGraphKey(e);if(t===hc)return this.count();let r=this.namedGraphs.get(t);return r?r.count():0}};nm.InMemoryTripleStore=L1;var N1=class{static{a(this,"InMemoryTransaction")}constructor(e){this.store=e,this.operations=[],this.committed=!1,this.rolledBack=!1}async add(e){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");this.operations.push({type:"add",triple:e})}async remove(e){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");return this.operations.push({type:"remove",triple:e}),!0}async commit(){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");for(let e of this.operations)e.type==="add"?await this.store.add(e.triple):await this.store.remove(e.triple);this.committed=!0,this.operations=[]}async rollback(){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");this.operations=[],this.rolledBack=!0}}});var sm=S(eo=>{"use strict";var J6=eo&&eo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Z6=eo&&eo.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(eo,"__esModule",{value:!0});eo.EffortStatusWorkflow=void 0;var e7=Oe(),im=Ao(),t7=uf(),r7=R1(),n7=k1(),M1=class{static{a(this,"EffortStatusWorkflow")}constructor(){this.resolver=new r7.WorkflowResolver(new n7.InMemoryTripleStore)}setResolver(e){this.resolver=e}getPreviousStatus(e,t){let r=this.normalizeStatus(e),i=this.resolveDefinition(t),s=new t7.WorkflowEngine(i);if(s.isInitialState(r))return null;let o=s.getPreviousStatus(r);if(o!==null)return this.wrapStatus(o)}normalizeStatus(e){return e.replace(/["'[\]]/g,"").trim()}wrapStatus(e){return`"[[${e}]]"`}resolveDefinition(e){return this.hasInstanceClass(e,im.AssetClass.TASK)||this.hasInstanceClass(e,im.AssetClass.MEETING)?this.resolver.getHardcodedFallback(im.AssetClass.TASK):this.resolver.getHardcodedFallback(im.AssetClass.PROJECT)}hasInstanceClass(e,t){return e?(Array.isArray(e)?e:[e]).some(i=>i.replace(/["'[\]]/g,"").trim()===t):!1}};eo.EffortStatusWorkflow=M1;eo.EffortStatusWorkflow=M1=J6([(0,e7.injectable)(),Z6("design:paramtypes",[])],M1)});var Ft=S(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0});om.DI_TOKENS=void 0;om.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),AreaCreationService:Symbol.for("AreaCreationService"),ClassCreationService:Symbol.for("ClassCreationService"),ConceptCreationService:Symbol.for("ConceptCreationService"),SupervisionCreationService:Symbol.for("SupervisionCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),DynamicFrontmatterGenerator:Symbol.for("DynamicFrontmatterGenerator"),AlgorithmExtractor:Symbol.for("AlgorithmExtractor"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),LabelToAliasService:Symbol.for("LabelToAliasService"),RenameToUidService:Symbol.for("RenameToUidService"),PlanningService:Symbol.for("PlanningService"),EffortVotingService:Symbol.for("EffortVotingService"),SessionEventService:Symbol.for("SessionEventService"),CriticalityZoneService:Symbol.for("CriticalityZoneService"),AssetConversionService:Symbol.for("AssetConversionService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),URIConstructionService:Symbol.for("URIConstructionService"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var am=S(Si=>{"use strict";var i7=Si&&Si.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},s7=Si&&Si.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},o7=Si&&Si.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Si,"__esModule",{value:!0});Si.StatusTimestampService=void 0;var bA=Oe(),a7=cs(),pc=Fn(),l7=Ft(),j1=class{static{a(this,"StatusTimestampService")}constructor(e){this.vault=e,this.frontmatterService=new a7.FrontmatterService}async addStartTimestamp(e){let t=await this.vault.read(e),r=pc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_startTimestamp",r);await this.vault.modify(e,i)}async addEndTimestamp(e,t){let r=await this.vault.read(e),i=t||new Date,s=pc.DateFormatter.toLocalTimestamp(i),o=this.frontmatterService.updateProperty(r,"ems__Effort_endTimestamp",s);await this.vault.modify(e,o)}async addResolutionTimestamp(e){let t=await this.vault.read(e),r=pc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_resolutionTimestamp",r);await this.vault.modify(e,i)}async addReviewTimestamp(e){let t=await this.vault.read(e),r=pc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_lastReviewTimestamp",r);await this.vault.modify(e,i)}async addEndAndResolutionTimestamps(e,t){let r=await this.vault.read(e),i=t||new Date,s=pc.DateFormatter.toLocalTimestamp(i),o=this.frontmatterService.updateProperty(r,"ems__Effort_endTimestamp",s);o=this.frontmatterService.updateProperty(o,"ems__Effort_resolutionTimestamp",s),await this.vault.modify(e,o)}async removeStartTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_startTimestamp");await this.vault.modify(e,r)}async removeEndTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_endTimestamp");await this.vault.modify(e,r)}async removeResolutionTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_resolutionTimestamp");await this.vault.modify(e,r)}async removeEndAndResolutionTimestamps(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_endTimestamp");r=this.frontmatterService.removeProperty(r,"ems__Effort_resolutionTimestamp"),await this.vault.modify(e,r)}async shiftPlannedEndTimestamp(e,t){let r=await this.vault.read(e),i=this.frontmatterService.parse(r);if(!i.exists)return;let s=this.frontmatterService.getPropertyValue(i.content,"ems__Effort_plannedEndTimestamp");if(!s)return;let o=new Date(s.replace(/["']/g,""));if(isNaN(o.getTime()))return;let l=new Date(o.getTime()+t),c=pc.DateFormatter.toLocalTimestamp(l),u=this.frontmatterService.updateProperty(r,"ems__Effort_plannedEndTimestamp",c);await this.vault.modify(e,u)}};Si.StatusTimestampService=j1;Si.StatusTimestampService=j1=i7([(0,bA.injectable)(),o7(0,(0,bA.inject)(l7.DI_TOKENS.IVaultAdapter)),s7("design:paramtypes",[Object])],j1)});var U1=S(wi=>{"use strict";var c7=wi&&wi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},u7=wi&&wi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},f7=wi&&wi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(wi,"__esModule",{value:!0});wi.TaskStatusService=void 0;var SA=Oe(),d7=cs(),h7=Fn(),p7=sm(),m7=am(),g7=Ft(),$1=class{static{a(this,"TaskStatusService")}constructor(e,t,r){this.vault=e,this.timestampService=r,this.frontmatterService=new d7.FrontmatterService}async syncEffortEndTimestamp(e,t){await this.timestampService.addEndAndResolutionTimestamps(e,t)}async shiftPlannedEndTimestamp(e,t){await this.timestampService.shiftPlannedEndTimestamp(e,t)}async planForEvening(e){let t=await this.vault.read(e),r=new Date;r.setHours(19,0,0,0);let i=h7.DateFormatter.toLocalTimestamp(r),s=this.frontmatterService.updateProperty(t,"ems__Effort_plannedStartTimestamp",i);await this.vault.modify(e,s)}};wi.TaskStatusService=$1;wi.TaskStatusService=$1=c7([(0,SA.injectable)(),f7(0,(0,SA.inject)(g7.DI_TOKENS.IVaultAdapter)),u7("design:paramtypes",[Object,p7.EffortStatusWorkflow,m7.StatusTimestampService])],$1)});var B1=S(lm=>{"use strict";Object.defineProperty(lm,"__esModule",{value:!0});lm.MetadataExtractor=void 0;var y7=Js(),V1=class{static{a(this,"MetadataExtractor")}constructor(e){this.vault=e}extractMetadata(e){return e?this.vault.getFrontmatter(e)||{}:{}}extractInstanceClass(e){return e.exo__Instance_class||null}extractStatus(e){return e.ems__Effort_status||null}extractIsArchived(e){return y7.MetadataHelpers.isAssetArchived(e)}static extractIsDefinedBy(e){let t=e.exo__Asset_isDefinedBy||'""';return Array.isArray(t)&&(t=t[0]||'""'),String(t)}extractExpectedFolder(e){let t=e.exo__Asset_isDefinedBy;if(!t)return null;let r=Array.isArray(t)?t[0]:t;if(!r||typeof r!="string")return null;let i=r.replace(/["'[\]]/g,"").trim();if(!i)return null;let s=i.split("/");return s.pop(),s.join("/")}extractCommandVisibilityContext(e){let t=this.extractMetadata(e),r=this.extractInstanceClass(t),i=this.extractStatus(t),s=this.extractIsArchived(t),o=e.parent?.path||"",l=this.extractExpectedFolder(t);return{instanceClass:r,currentStatus:i,metadata:t,isArchived:s,currentFolder:o,expectedFolder:l}}extractCache(e){return e?this.vault.getFrontmatter(e):null}};lm.MetadataExtractor=V1});var q1=S(vi=>{"use strict";var _7=vi&&vi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},b7=vi&&vi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},S7=vi&&vi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(vi,"__esModule",{value:!0});vi.AreaCreationService=void 0;var wA=Oe(),vA=mi(),w7=Ao(),v7=Fn(),E7=B1(),EA=Js(),T7=Ft(),G1=class{static{a(this,"AreaCreationService")}constructor(e){this.vault=e}async createChildArea(e,t,r){let i=(0,vA.v4)(),s=`${i}.md`,o=this.generateChildAreaFrontmatter(t,e.basename,r,i),l=EA.MetadataHelpers.buildFileContent(o),c=e.parent?.path||"",u=c?`${c}/${s}`:s;return await this.vault.create(u,l)}generateChildAreaFrontmatter(e,t,r,i){let s=new Date,o=v7.DateFormatter.toLocalTimestamp(s),l=E7.MetadataExtractor.extractIsDefinedBy(e),c={};if(c.exo__Asset_isDefinedBy=EA.MetadataHelpers.ensureQuoted(l),c.exo__Asset_uid=i||(0,vA.v4)(),c.exo__Asset_createdAt=o,c.exo__Instance_class=[`"[[${w7.AssetClass.AREA}]]"`],c.ems__Area_parent=`"[[${t}]]"`,r&&r.trim()!==""){let u=r.trim();c.exo__Asset_label=u,c.aliases=[u]}return c}};vi.AreaCreationService=G1;vi.AreaCreationService=G1=_7([(0,wA.injectable)(),S7(0,(0,wA.inject)(T7.DI_TOKENS.IVaultAdapter)),b7("design:paramtypes",[Object])],G1)});var z1=S(Ei=>{"use strict";var I7=Ei&&Ei.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},x7=Ei&&Ei.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},A7=Ei&&Ei.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ei,"__esModule",{value:!0});Ei.AreaHierarchyBuilder=void 0;var TA=Oe(),IA=Ao(),R7=Ft(),cm=Us(),W1=class{static{a(this,"AreaHierarchyBuilder")}constructor(e){this.vault=e}buildHierarchy(e,t){let r=this.vault.getAbstractFileByPath(e);if(!this.isFile(r))return null;let i=this.vault.getFrontmatter(r)||{};if(this.extractInstanceClass(i)!==IA.AssetClass.AREA)return null;let o=this.collectAllAreasFromVault(),l=new Set;return this.buildTree(e,o,l,0)}isFile(e){return!!e&&typeof e=="object"&&"basename"in e&&"path"in e}extractInstanceClass(e){let t=e.exo__Instance_class||"";return Array.isArray(t)?cm.WikiLinkHelpers.normalize(String(t[0]||"")):cm.WikiLinkHelpers.normalize(String(t))}collectAllAreasFromVault(){let e=new Map,t=new Map,r=this.vault.getAllFiles();for(let i of r){let s=this.vault.getFrontmatter(i)||{};if(this.extractInstanceClass(s)===IA.AssetClass.AREA){let l=this.extractParentPath(s);e.set(i.path,{path:i.path,title:i.basename,label:s.exo__Asset_label||void 0,isArchived:this.isArchived(s),depth:0,parentPath:l||void 0}),t.set(i.basename,i.path)}}for(let[,i]of e.entries())i.parentPath&&t.has(i.parentPath)&&(i.parentPath=t.get(i.parentPath));return e}extractParentPath(e){let t=e.ems__Area_parent;if(!t)return null;if(Array.isArray(t)){let r=t[0]||"";return cm.WikiLinkHelpers.normalize(String(r))}return cm.WikiLinkHelpers.normalize(String(t))}isArchived(e){let t=e.exo__Asset_archived;if(t===!0||t==="true")return!0;if(Array.isArray(t)&&t.length>0){let r=t[0];return r===!0||r==="true"}return!1}buildTree(e,t,r,i){if(r.has(e))return null;r.add(e);let s=t.get(e);if(!s)return null;let o=[];for(let[l,c]of t.entries())if(c.parentPath===e){let u=this.buildTree(l,t,r,i+1);u&&o.push(u)}return o.sort((l,c)=>{let u=l.label||l.title,f=c.label||c.title;return u.localeCompare(f)}),{path:s.path,title:s.title,label:s.label,isArchived:s.isArchived,depth:i,parentPath:s.parentPath,children:o}}};Ei.AreaHierarchyBuilder=W1;Ei.AreaHierarchyBuilder=W1=I7([(0,TA.injectable)(),A7(0,(0,TA.inject)(R7.DI_TOKENS.IVaultAdapter)),x7("design:paramtypes",[Object])],W1)});var Q1=S(Ti=>{"use strict";var C7=Ti&&Ti.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},P7=Ti&&Ti.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},O7=Ti&&Ti.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ti,"__esModule",{value:!0});Ti.ClassCreationService=void 0;var xA=Oe(),F7=mi(),D7=Fn(),L7=Js(),N7=Ft(),H1=class{static{a(this,"ClassCreationService")}constructor(e){this.vault=e}async createSubclass(e,t,r){let i=(0,F7.v4)(),s=this.generateFileName(t),o=s.endsWith(".md")?s:`${s}.md`,l=this.generateClassFrontmatter(e.basename,t,i,r),c=L7.MetadataHelpers.buildFileContent(l),u="classes",f=`${u}/${o}`;return this.vault.getAbstractFileByPath(u)||await this.vault.createFolder(u),await this.vault.create(f,c)}generateFileName(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-");for(;t.startsWith("-");)t=t.slice(1);for(;t.endsWith("-");)t=t.slice(0,-1);return t}generateClassFrontmatter(e,t,r,i){let s=new Date,o=D7.DateFormatter.toLocalTimestamp(s),l={};l.exo__Asset_uid=r,l.exo__Asset_label=t,l.exo__Asset_createdAt=o,l.exo__Instance_class=['"[[exo__Class]]"'],l.exo__Class_superClass=`"[[${e}]]"`;let c=i.exo__Asset_isDefinedBy||'"[[Ontology/EXO]]"';return l.exo__Asset_isDefinedBy=c,l.aliases=[t],l}};Ti.ClassCreationService=H1;Ti.ClassCreationService=H1=C7([(0,xA.injectable)(),O7(0,(0,xA.inject)(N7.DI_TOKENS.IVaultAdapter)),P7("design:paramtypes",[Object])],H1)});var X1=S(Ii=>{"use strict";var k7=Ii&&Ii.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},M7=Ii&&Ii.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},j7=Ii&&Ii.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ii,"__esModule",{value:!0});Ii.ConceptCreationService=void 0;var AA=Oe(),$7=mi(),U7=Fn(),V7=Js(),B7=Ao(),G7=Ft(),Y1=class{static{a(this,"ConceptCreationService")}constructor(e){this.vault=e}async createNarrowerConcept(e,t,r,i){let s=(0,$7.v4)(),o=t.endsWith(".md")?t:`${t}.md`,l=this.generateConceptFrontmatter(e.basename,r,i,s),c=V7.MetadataHelpers.buildFileContent(l),u="concepts",f=`${u}/${o}`;return this.vault.getAbstractFileByPath(u)||await this.vault.createFolder(u),await this.vault.create(f,c)}generateConceptFrontmatter(e,t,r,i){let s=new Date,o=U7.DateFormatter.toLocalTimestamp(s),l={};return l.exo__Asset_isDefinedBy='"[[!concepts]]"',l.exo__Asset_uid=i,l.exo__Asset_createdAt=o,l.exo__Instance_class=[`"[[${B7.AssetClass.CONCEPT}]]"`],l.ims__Concept_broader=`"[[${e}]]"`,l.ims__Concept_definition=t,r.length>0&&(l.aliases=r),l}};Ii.ConceptCreationService=Y1;Ii.ConceptCreationService=Y1=k7([(0,AA.injectable)(),j7(0,(0,AA.inject)(G7.DI_TOKENS.IVaultAdapter)),M7("design:paramtypes",[Object])],Y1)});var RA=S(ro=>{"use strict";var q7=ro&&ro.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},W7=ro&&ro.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(ro,"__esModule",{value:!0});ro.InstantiationRuleResolver=void 0;var z7=Oe(),K1=Ae(),mc=$e(),to=er(),J1=class{static{a(this,"InstantiationRuleResolver")}constructor(e){this.tripleStore=e,this.cache=new Map}async getRule(e){let t=this.cache.get(e);if(t!==void 0)return t;let r=await this.findRuleForClass(e);return this.cache.set(e,r),r}invalidateCache(){this.cache.clear()}async findRuleForClass(e){let t=await this.tripleStore.match(void 0,to.Namespace.RDF.term("type"),to.Namespace.EXO.term("InstantiationRule"));for(let r of t){let i=r.subject;if((await this.tripleStore.match(i,to.Namespace.EXO.term("rule_targetClass"),void 0)).some(l=>this.matchesTargetClass(l.object,e)))return this.loadRule(i)}return null}async loadRule(e){let t=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_prototypeUID"),void 0),r=t.length>0&&t[0].object instanceof mc.Literal?t[0].object.value:null,i=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_defaultFolder"),void 0),s=i.length>0&&i[0].object instanceof mc.Literal?i[0].object.value:null,o=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_propertySetRules"),void 0),l=[];for(let c of o){let u=c.object;if(!(u instanceof K1.IRI))continue;let f=await this.loadPropertySetRule(u);f&&l.push(f)}return{prototypeUID:r,defaultFolder:s,propertySetRules:l}}async loadPropertySetRule(e){let t=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_property"),void 0);if(t.length===0)return null;let r=t[0].object,i=r instanceof K1.IRI?this.extractLocalName(r):r instanceof mc.Literal?this.normalizeWikilink(r.value):null;if(!i)return null;let s=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_value"),void 0),o=s.length>0&&s[0].object instanceof mc.Literal?s[0].object.value:"",l=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_valueType"),void 0),c=l.length>0&&l[0].object instanceof mc.Literal?l[0].object.value:"literal";return{property:i,value:o,valueType:c}}matchesTargetClass(e,t){return e instanceof K1.IRI?this.extractLocalName(e)===t:e instanceof mc.Literal?this.normalizeWikilink(e.value)===t:!1}extractLocalName(e){let t=e.value,r=t.lastIndexOf("#");if(r>=0){let s=t.substring(r+1);return t.includes("/ems#")?`ems__${s}`:t.includes("/exo#")?`exo__${s}`:t.includes("/ims#")?`ims__${s}`:s}let i=t.lastIndexOf("/");return i>=0?t.substring(i+1):t}normalizeWikilink(e){return e.replace(/["'[\]]/g,"").trim()}};ro.InstantiationRuleResolver=J1;ro.InstantiationRuleResolver=J1=q7([(0,z7.injectable)(),W7("design:paramtypes",[Object])],J1)});var CA=S(no=>{"use strict";var H7=no&&no.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Q7=no&&no.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(no,"__esModule",{value:!0});no.VisibilityGenerator=void 0;var Y7=Oe(),X7=uf(),Z1=class{static{a(this,"VisibilityGenerator")}constructor(e){this.engine=e}getVisibleCommands(e){return this.engine.getAllTransitions(e).map(t=>this.toCommand(t))}getForwardCommands(e){return this.engine.getAvailableTransitions(e).map(t=>this.toCommand(t))}getRollbackCommands(e){return this.engine.getRollbackTransitions(e).map(t=>this.toCommand(t))}toCommand(e){let t=e.from.replace("ems__EffortStatus","").toLowerCase(),r=e.to.replace("ems__EffortStatus","").toLowerCase();return{commandId:`workflow-${t}-to-${r}`,label:e.label,icon:e.icon,targetStatus:e.to,isRollback:e.isRollback}}};no.VisibilityGenerator=Z1;no.VisibilityGenerator=Z1=H7([(0,Y7.injectable)(),Q7("design:paramtypes",[X7.WorkflowEngine])],Z1)});var PA=S(io=>{"use strict";var K7=io&&io.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},J7=io&&io.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(io,"__esModule",{value:!0});io.WorkflowCommandAdapter=void 0;var Z7=Oe(),eS=Io(),e8=uf(),tS=class{static{a(this,"WorkflowCommandAdapter")}constructor(e){this.workflow=e,this.engine=new e8.WorkflowEngine(e)}adaptTransitions(e){return this.engine.getAllTransitions(e).map(r=>this.transitionToCommand(r))}adaptForwardTransitions(e){return this.engine.getAvailableTransitions(e).map(r=>this.transitionToCommand(r))}adaptRollbackTransitions(e){return this.engine.getRollbackTransitions(e).map(r=>this.transitionToCommand(r))}getEngine(){return this.engine}getWorkflow(){return this.workflow}transitionToCommand(e){let t=this.generateCommandId(e),r=this.buildPrecondition(e),i=this.buildGrounding(e),s=e.isRollback?"rollback":"workflow";return{id:t,name:e.label,icon:e.icon,precondition:r,grounding:i,category:s,confirmMessage:e.isRollback?`Rollback to ${this.shortStatus(e.to)}?`:void 0,successMessage:`Status changed to ${this.shortStatus(e.to)}`}}generateCommandId(e){let t=this.shortStatus(e.from),r=this.shortStatus(e.to);return`workflow-${t}-to-${r}`}buildPrecondition(e){return{id:`precond-${this.generateCommandId(e)}`,label:`Asset status is ${this.shortStatus(e.from)}`,sparqlAsk:`ASK { $target ems:Effort_status "${e.from}" }`}}buildGrounding(e){let t=[];t.push({id:`gnd-status-${this.shortStatus(e.to)}`,label:`Set status to ${this.shortStatus(e.to)}`,type:eS.GroundingType.PROPERTY_SET,targetProperty:"ems__Effort_status",targetValueRef:e.to});let r=this.engine.getTimestampsForStatus(e.to);for(let i of r)t.push({id:`gnd-ts-${i}`,label:`Set ${i}`,type:eS.GroundingType.PROPERTY_SET,targetProperty:i,targetValueSubstitution:"$now"});return t.length===1?t[0]:{id:`gnd-composite-${this.generateCommandId(e)}`,label:`Transition to ${this.shortStatus(e.to)}`,type:eS.GroundingType.COMPOSITE,steps:t}}shortStatus(e){return e.replace("ems__EffortStatus","").toLowerCase()}};io.WorkflowCommandAdapter=tS;io.WorkflowCommandAdapter=tS=K7([(0,Z7.injectable)(),J7("design:paramtypes",[Object])],tS)});var nS=S(xi=>{"use strict";var t8=xi&&xi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},r8=xi&&xi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},n8=xi&&xi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(xi,"__esModule",{value:!0});xi.EffortVotingService=void 0;var OA=Oe(),i8=Ft(),rS=class{static{a(this,"EffortVotingService")}constructor(e){this.vault=e}async incrementEffortVotes(e){let t=await this.vault.read(e),i=this.extractVoteCount(t)+1,s=this.updateFrontmatterWithVotes(t,i);return await this.vault.modify(e,s),i}extractVoteCount(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/,r=e.match(t);if(!r)return 0;let s=r[1].match(/ems__Effort_votes:\s*(\d+)/);return s&&s[1]?parseInt(s[1],10):0}updateFrontmatterWithVotes(e,t){let r=/^---\r?\n([\s\S]*?)\r?\n---/,i=e.match(r),s=e.includes(`\r
100
+ ${o}`}};Jp.MetadataHelpers=I1});var yA=S(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.TASK_DEFAULT_WORKFLOW=Va.PROJECT_DEFAULT_WORKFLOW=void 0;Va.buildWorkflowAssetContent=B6;var gA=mi(),ff=Il(),Re=xl(),zr=pA(),x1=Js();Va.PROJECT_DEFAULT_WORKFLOW={id:"a1b2c3d4-1111-4000-a000-000000000001",name:"Project Default Workflow",targetClass:ff.AssetClass.PROJECT,initialState:Re.EffortStatus.DRAFT,terminalStates:[Re.EffortStatus.DONE,Re.EffortStatus.TRASHED],isDefault:!0,states:[{status:Re.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.ANALYSIS,order:3,optional:!0,timestampOnEnter:[]},{status:Re.EffortStatus.TODO,order:4,optional:!0,timestampOnEnter:[]},{status:Re.EffortStatus.DOING,order:5,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:Re.EffortStatus.DONE,order:6,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:Re.EffortStatus.TRASHED,order:7,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:Re.EffortStatus.DRAFT,to:Re.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.ANALYSIS,label:"\u2192 Analysis",isRollback:!1},{from:Re.EffortStatus.ANALYSIS,to:Re.EffortStatus.TODO,label:"\u2192 ToDo",isRollback:!1},{from:Re.EffortStatus.TODO,to:Re.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:Re.EffortStatus.ANALYSIS,to:Re.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:Re.EffortStatus.TODO,to:Re.EffortStatus.ANALYSIS,label:"\u2190 Analysis",isRollback:!0},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.TODO,label:"\u2190 ToDo",isRollback:!0},{from:Re.EffortStatus.DONE,to:Re.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};Va.TASK_DEFAULT_WORKFLOW={id:"a1b2c3d4-2222-4000-a000-000000000002",name:"Task Default Workflow",targetClass:ff.AssetClass.TASK,initialState:Re.EffortStatus.DRAFT,terminalStates:[Re.EffortStatus.DONE,Re.EffortStatus.TRASHED],isDefault:!0,states:[{status:Re.EffortStatus.DRAFT,order:1,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.BACKLOG,order:2,optional:!1,timestampOnEnter:[]},{status:Re.EffortStatus.DOING,order:3,optional:!1,timestampOnEnter:["ems__Effort_startTimestamp"]},{status:Re.EffortStatus.DONE,order:4,optional:!1,timestampOnEnter:["ems__Effort_endTimestamp","ems__Effort_resolutionTimestamp"]},{status:Re.EffortStatus.TRASHED,order:5,optional:!1,timestampOnEnter:["ems__Effort_resolutionTimestamp"]}],transitions:[{from:Re.EffortStatus.DRAFT,to:Re.EffortStatus.BACKLOG,label:"\u2192 Backlog",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.DOING,label:"\u25B6 Start",isRollback:!1},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.DONE,label:"\u2713 Done",isRollback:!1},{from:Re.EffortStatus.BACKLOG,to:Re.EffortStatus.DRAFT,label:"\u2190 Draft",isRollback:!0},{from:Re.EffortStatus.DOING,to:Re.EffortStatus.BACKLOG,label:"\u2190 Backlog",isRollback:!0},{from:Re.EffortStatus.DONE,to:Re.EffortStatus.DOING,label:"\u2190 Doing",isRollback:!0}]};function B6(n){let e=new Date().toISOString(),t=[],r=n.id,i={exo__Asset_uid:r,exo__Asset_label:`"${n.name}"`,exo__Asset_createdAt:e,exo__Instance_class:ff.AssetClass.WORKFLOW,[zr.WorkflowProperty.TARGET_CLASS]:`"[[${n.targetClass}]]"`,[zr.WorkflowProperty.INITIAL_STATE]:`"[[${n.initialState}]]"`,[zr.WorkflowProperty.TERMINAL_STATES]:n.terminalStates.map(s=>`"[[${s}]]"`),[zr.WorkflowProperty.IS_DEFAULT]:n.isDefault};t.push({filename:`${r}.md`,content:x1.MetadataHelpers.buildFileContent(i)});for(let s of n.states){let o=(0,gA.v4)(),l={exo__Asset_uid:o,exo__Asset_label:`"${n.name} - ${s.status}"`,exo__Asset_createdAt:e,exo__Instance_class:ff.AssetClass.WORKFLOW_STATE,[zr.WorkflowStateProperty.WORKFLOW]:`"[[${r}]]"`,[zr.WorkflowStateProperty.STATUS]:`"[[${s.status}]]"`,[zr.WorkflowStateProperty.ORDER]:s.order,[zr.WorkflowStateProperty.OPTIONAL]:s.optional};s.timestampOnEnter.length>0&&(l[zr.WorkflowStateProperty.TIMESTAMP_ON_ENTER]=s.timestampOnEnter),s.badgeColor&&(l[zr.WorkflowStateProperty.BADGE_COLOR]=`"${s.badgeColor}"`),t.push({filename:`${o}.md`,content:x1.MetadataHelpers.buildFileContent(l)})}for(let s of n.transitions){let o=(0,gA.v4)(),l={exo__Asset_uid:o,exo__Asset_label:`"${n.name} - ${s.label}"`,exo__Asset_createdAt:e,exo__Instance_class:ff.AssetClass.WORKFLOW_TRANSITION,[zr.WorkflowTransitionProperty.WORKFLOW]:`"[[${r}]]"`,[zr.WorkflowTransitionProperty.FROM]:`"[[${s.from}]]"`,[zr.WorkflowTransitionProperty.TO]:`"[[${s.to}]]"`,[zr.WorkflowTransitionProperty.LABEL]:`"${s.label}"`,[zr.WorkflowTransitionProperty.IS_ROLLBACK]:s.isRollback};s.icon&&(l[zr.WorkflowTransitionProperty.ICON]=`"${s.icon}"`),t.push({filename:`${o}.md`,content:x1.MetadataHelpers.buildFileContent(l)})}return t}a(B6,"buildWorkflowAssetContent")});var R1=S(Zs=>{"use strict";var G6=Zs&&Zs.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},q6=Zs&&Zs.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.WorkflowResolver=void 0;var W6=Oe(),dc=Ae(),Hr=$e(),St=er(),Ba=Il(),Zp=xl(),_A=yA(),A1=class{static{a(this,"WorkflowResolver")}constructor(e){this.tripleStore=e,this.cache=new Map}async resolveForClass(e){let t=`class:${e}`,r=this.cache.get(t);if(r)return r;let s=await this.findDefaultWorkflow(e)??this.getHardcodedFallback(e);return this.cache.set(t,s),s}async resolveForAsset(e,t){let r=await this.tripleStore.match(e,St.Namespace.EMS.term("Effort_workflow"),void 0);if(r.length>0){let i=r[0].object;if(i instanceof dc.IRI){let s=await this.loadWorkflowBySubject(i);if(s)return s}}return this.resolveForClass(t)}invalidateCache(){this.cache.clear()}async findDefaultWorkflow(e){let t=await this.tripleStore.match(void 0,St.Namespace.RDF.term("type"),St.Namespace.EMS.term("Workflow"));for(let r of t){let i=r.subject;if(!(!(await this.tripleStore.match(i,St.Namespace.EMS.term("Workflow_targetClass"),void 0)).some(u=>{let f=u.object;return f instanceof dc.IRI?f.value.endsWith(e.replace(/^ems__/,"")):f instanceof Hr.Literal?this.normalizeWikilink(f.value)===e:!1})||!(await this.tripleStore.match(i,St.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(u=>{let f=u.object instanceof Hr.Literal?u.object.value:"";return f==="true"||f==="1"})))return this.loadWorkflowBySubject(i)}return null}async loadWorkflowBySubject(e){let t=await this.tripleStore.match(e,St.Namespace.EXO.term("Asset_label"),void 0),r=t.length>0&&t[0].object instanceof Hr.Literal?t[0].object.value:"Unknown Workflow",i=await this.tripleStore.match(e,St.Namespace.EXO.term("Asset_uid"),void 0),s=i.length>0&&i[0].object instanceof Hr.Literal?i[0].object.value:e.value,o=await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_targetClass"),void 0),l=this.resolveAssetClass(o),c=await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_initialState"),void 0),u=this.resolveEffortStatus(c)??Zp.EffortStatus.DRAFT,f=await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_terminalStates"),void 0),d=this.resolveEffortStatuses(f),p=(await this.tripleStore.match(e,St.Namespace.EMS.term("Workflow_isDefault"),void 0)).some(v=>{let w=v.object instanceof Hr.Literal?v.object.value:"";return w==="true"||w==="1"}),g=await this.loadStates(e),_=await this.loadTransitions(e);return g.length===0&&_.length===0?null:{id:s,name:r,targetClass:l,states:g,transitions:_,initialState:u,terminalStates:d.length>0?d:[Zp.EffortStatus.DONE,Zp.EffortStatus.TRASHED],isDefault:p}}async loadStates(e){let t=await this.tripleStore.match(void 0,St.Namespace.RDF.term("type"),St.Namespace.EMS.term("WorkflowState")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_workflow"),void 0)).some(E=>this.isSameSubject(E.object,e)))continue;let c=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_status"),void 0),u=this.resolveEffortStatus(c);if(!u)continue;let f=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_order"),void 0),d=f.length>0&&f[0].object instanceof Hr.Literal&&parseInt(f[0].object.value,10)||0,p=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_optional"),void 0)).some(E=>{let I=E.object instanceof Hr.Literal?E.object.value:"";return I==="true"||I==="1"}),_=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_timestampOnEnter"),void 0)).map(E=>E.object instanceof Hr.Literal?E.object.value:"").filter(E=>E.length>0),v=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowState_badgeColor"),void 0),w=v.length>0&&v[0].object instanceof Hr.Literal?v[0].object.value:void 0;r.push({status:u,order:d,optional:p,timestampOnEnter:_,badgeColor:w})}return r.sort((i,s)=>i.order-s.order)}async loadTransitions(e){let t=await this.tripleStore.match(void 0,St.Namespace.RDF.term("type"),St.Namespace.EMS.term("WorkflowTransition")),r=[];for(let i of t){let s=i.subject;if(!(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_workflow"),void 0)).some(O=>this.isSameSubject(O.object,e)))continue;let c=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_from"),void 0),u=this.resolveEffortStatus(c),f=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_to"),void 0),d=this.resolveEffortStatus(f);if(!u||!d)continue;let h=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_label"),void 0),p=h.length>0&&h[0].object instanceof Hr.Literal?h[0].object.value:`${u} \u2192 ${d}`,g=await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_icon"),void 0),_=g.length>0&&g[0].object instanceof Hr.Literal?g[0].object.value:void 0,w=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_isRollback"),void 0)).some(O=>{let C=O.object instanceof Hr.Literal?O.object.value:"";return C==="true"||C==="1"}),I=(await this.tripleStore.match(s,St.Namespace.EMS.term("WorkflowTransition_postActions"),void 0)).map(O=>this.extractUid(O.object)).filter(O=>O!==null);r.push({from:u,to:d,label:p,icon:_,isRollback:w,postActions:I.length>0?I:void 0})}return r}extractUid(e){let t=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i,r=e instanceof dc.IRI||e instanceof Hr.Literal?e.value:null;if(r===null)return null;let i=r.match(t);return i?i[1].toLowerCase():null}normalizeWikilink(e){return e.replace(/["'[\]]/g,"").trim()}resolveAssetClass(e){if(e.length===0)return Ba.AssetClass.TASK;let t=e[0].object;if(t instanceof dc.IRI){let i=`ems__${t.value.split("#").pop()??""}`;return Object.values(Ba.AssetClass).includes(i)?i:Ba.AssetClass.TASK}if(t instanceof Hr.Literal){let r=this.normalizeWikilink(t.value);return Object.values(Ba.AssetClass).includes(r)?r:Ba.AssetClass.TASK}return Ba.AssetClass.TASK}resolveEffortStatus(e){if(e.length===0)return null;let t=e[0].object,r;if(t instanceof dc.IRI)r=`ems__${t.value.split("#").pop()??""}`;else if(t instanceof Hr.Literal)r=this.normalizeWikilink(t.value);else return null;return Object.values(Zp.EffortStatus).includes(r)?r:null}resolveEffortStatuses(e){return e.map(t=>this.resolveEffortStatus([t])).filter(t=>t!==null)}isSameSubject(e,t){if(e instanceof dc.IRI)return e.value===t.value;if(e instanceof Hr.Literal){let r=this.normalizeWikilink(e.value);return t.value.includes(r)}return!1}getHardcodedFallback(e){return e===Ba.AssetClass.PROJECT?{..._A.PROJECT_DEFAULT_WORKFLOW}:{..._A.TASK_DEFAULT_WORKFLOW}}};Zs.WorkflowResolver=A1;Zs.WorkflowResolver=A1=G6([(0,W6.injectable)(),q6("design:paramtypes",[Object])],A1)});var F1=S(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.TransactionError=Vo.TripleNotFoundError=Vo.TripleAlreadyExistsError=void 0;var C1=class extends Error{static{a(this,"TripleAlreadyExistsError")}constructor(e){super(`Triple already exists: ${e.toString()}`),this.name="TripleAlreadyExistsError"}};Vo.TripleAlreadyExistsError=C1;var P1=class extends Error{static{a(this,"TripleNotFoundError")}constructor(e){super(`Triple not found: ${e.toString()}`),this.name="TripleNotFoundError"}};Vo.TripleNotFoundError=P1;var O1=class extends Error{static{a(this,"TransactionError")}constructor(e){super(e),this.name="TransactionError"}};Vo.TransactionError=O1});var tm=S(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});em.LRUCache=void 0;var D1=class{static{a(this,"LRUCache")}constructor(e){this.maxSize=e,this.cache=new Map}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};em.LRUCache=D1});var k1=S(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});nm.InMemoryTripleStore=void 0;var Bo=F1(),rm=Ae(),z6=$t(),H6=$e(),Q6=er(),Y6=tm(),X6=Q6.Namespace.XSD.term("string").value,K6=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,hc="__default__",L1=class n{static{a(this,"InMemoryTripleStore")}constructor(){this.triples=new Map,this.spo=new Map,this.sop=new Map,this.pso=new Map,this.pos=new Map,this.osp=new Map,this.ops=new Map,this.queryCache=new Y6.LRUCache(1e3),this.uuidIndex=new Map,this.namedGraphs=new Map}async add(e){let t=this.getTripleKey(e);if(this.triples.has(t))return;this.triples.set(t,e);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);this.addToIndex(this.spo,r,i,s),this.addToIndex(this.sop,r,s,i),this.addToIndex(this.pso,i,r,s),this.addToIndex(this.pos,i,s,r),this.addToIndex(this.osp,s,r,i),this.addToIndex(this.ops,s,i,r),this.addToUUIDIndex(e.subject),this.queryCache.clear()}async remove(e){let t=this.getTripleKey(e);if(!this.triples.has(t))return!1;this.triples.delete(t);let r=this.getNodeKey(e.subject),i=this.getNodeKey(e.predicate),s=this.getNodeKey(e.object);return this.removeFromIndex(this.spo,r,i,s),this.removeFromIndex(this.sop,r,s,i),this.removeFromIndex(this.pso,i,r,s),this.removeFromIndex(this.pos,i,s,r),this.removeFromIndex(this.osp,s,r,i),this.removeFromIndex(this.ops,s,i,r),this.queryCache.clear(),!0}async has(e){let t=this.getTripleKey(e);return this.triples.has(t)}async match(e,t,r){let i=this.getMatchCacheKey(e,t,r),s=this.queryCache.get(i);if(s!==void 0)return s;let o;return!e&&!t&&!r?o=Array.from(this.triples.values()):e&&t&&r?o=this.matchSPO(e,t,r):e&&t?o=this.matchSP(e,t):e&&r?o=this.matchSO(e,r):t&&r?o=this.matchPO(t,r):e?o=this.matchS(e):t?o=this.matchP(t):r?o=this.matchO(r):o=[],this.queryCache.set(i,o),o}async addAll(e){for(let t of e)await this.add(t)}async removeAll(e){let t=0;for(let r of e)await this.remove(r)&&t++;return t}async clear(){this.triples.clear(),this.spo.clear(),this.sop.clear(),this.pso.clear(),this.pos.clear(),this.osp.clear(),this.ops.clear(),this.uuidIndex.clear(),this.queryCache.clear()}async count(){return this.triples.size}async subjects(){let e=new Set;for(let t of this.triples.values())e.add(t.subject);return Array.from(e)}async predicates(){let e=new Set;for(let t of this.triples.values())e.add(t.predicate);return Array.from(e)}async objects(){let e=new Set;for(let t of this.triples.values())e.add(t.object);return Array.from(e)}async beginTransaction(){return new N1(this)}async findSubjectsByUUID(e){return this.findSubjectsByUUIDSync(e)}findSubjectsByUUIDSync(e){let t=e.toLowerCase(),r=this.uuidIndex.get(t);if(!r||r.size===0)return[];let i=[];for(let s of r)this.spo.has(`i:${s}`)&&i.push(new rm.IRI(s));return i}addToUUIDIndex(e){if(!(e instanceof rm.IRI))return;let t=e.value,r=t.match(K6);if(r)for(let i of r){let s=i.toLowerCase();this.uuidIndex.has(s)||this.uuidIndex.set(s,new Set),this.uuidIndex.get(s).add(t)}}matchSPO(e,t,r){let i=this.getNodeKey(e),s=this.getNodeKey(t),o=this.getNodeKey(r),l=this.spo.get(i);if(!l)return[];let c=l.get(s);if(!c)return[];if(c.has(o)){let u=this.buildTripleKey(i,s,o),f=this.triples.get(u);return f?[f]:[]}return[]}matchSP(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.spo.get(r);if(!s)return[];let o=s.get(i);return o?this.getTriplesByKeys(Array.from(o).map(l=>this.buildTripleKey(r,i,l))):[]}matchSO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.sop.get(r);if(!s)return[];let o=s.get(i);return o?this.getTriplesByKeys(Array.from(o).map(l=>this.buildTripleKey(r,l,i))):[]}matchPO(e,t){let r=this.getNodeKey(e),i=this.getNodeKey(t),s=this.pos.get(r);if(!s)return[];let o=s.get(i);return o?this.getTriplesByKeys(Array.from(o).map(l=>this.buildTripleKey(l,r,i))):[]}matchS(e){let t=this.getNodeKey(e),r=this.spo.get(t);if(!r)return[];let i=[];for(let[s,o]of r.entries())for(let l of o)i.push(this.buildTripleKey(t,s,l));return this.getTriplesByKeys(i)}matchP(e){let t=this.getNodeKey(e),r=this.pso.get(t);if(!r)return[];let i=[];for(let[s,o]of r.entries())for(let l of o)i.push(this.buildTripleKey(s,t,l));return this.getTriplesByKeys(i)}matchO(e){let t=this.getNodeKey(e),r=this.osp.get(t);if(!r)return[];let i=[];for(let[s,o]of r.entries())for(let l of o)i.push(this.buildTripleKey(s,l,t));return this.getTriplesByKeys(i)}getTriplesByKeys(e){let t=[];for(let r of e){let i=this.triples.get(r);i&&t.push(i)}return t}addToIndex(e,t,r,i){e.has(t)||e.set(t,new Map);let s=e.get(t);s.has(r)||s.set(r,new Set),s.get(r).add(i)}removeFromIndex(e,t,r,i){let s=e.get(t);if(!s)return;let o=s.get(r);o&&(o.delete(i),o.size===0&&s.delete(r),s.size===0&&e.delete(t))}getTripleKey(e){let t=this.getNodeKey(e.subject),r=this.getNodeKey(e.predicate),i=this.getNodeKey(e.object);return this.buildTripleKey(t,r,i)}buildTripleKey(e,t,r){return`${e}|${t}|${r}`}getNodeKey(e){if(e instanceof rm.IRI)return`i:${e.value}`;if(e instanceof z6.BlankNode)return`b:${e.id}`;if(e instanceof H6.Literal){let t=`l:${e.value}`;return e.datatype&&e.datatype.value!==X6?t+=`^^${e.datatype.value}`:e.language&&(t+=`@${e.language}`),t}return""}getMatchCacheKey(e,t,r){let i=e?this.getNodeKey(e):"?",s=t?this.getNodeKey(t):"?",o=r?this.getNodeKey(r):"?";return`${i}|${s}|${o}`}getGraphKey(e){return e?e.value:hc}getOrCreateGraphStore(e){let t=this.getGraphKey(e);return t===hc?this:(this.namedGraphs.has(t)||this.namedGraphs.set(t,new n),this.namedGraphs.get(t))}async addToGraph(e,t){await this.getOrCreateGraphStore(t).add(e)}async removeFromGraph(e,t){let r=this.getGraphKey(t);if(r===hc)return this.remove(e);let i=this.namedGraphs.get(r);return i?i.remove(e):!1}async matchInGraph(e,t,r,i){let s=this.getGraphKey(i);if(s===hc)return this.match(e,t,r);let o=this.namedGraphs.get(s);return o?o.match(e,t,r):[]}async getNamedGraphs(){return Array.from(this.namedGraphs.keys()).map(e=>new rm.IRI(e))}async hasGraph(e){let t=this.namedGraphs.get(e.value);return t?await t.count()>0:!1}async clearGraph(e){let t=this.getGraphKey(e);if(t===hc){await this.clear();return}let r=this.namedGraphs.get(t);r&&(await r.clear(),this.namedGraphs.delete(t))}async countInGraph(e){let t=this.getGraphKey(e);if(t===hc)return this.count();let r=this.namedGraphs.get(t);return r?r.count():0}};nm.InMemoryTripleStore=L1;var N1=class{static{a(this,"InMemoryTransaction")}constructor(e){this.store=e,this.operations=[],this.committed=!1,this.rolledBack=!1}async add(e){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");this.operations.push({type:"add",triple:e})}async remove(e){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");return this.operations.push({type:"remove",triple:e}),!0}async commit(){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");for(let e of this.operations)e.type==="add"?await this.store.add(e.triple):await this.store.remove(e.triple);this.committed=!0,this.operations=[]}async rollback(){if(this.committed)throw new Bo.TransactionError("Transaction already committed");if(this.rolledBack)throw new Bo.TransactionError("Transaction already rolled back");this.operations=[],this.rolledBack=!0}}});var sm=S(eo=>{"use strict";var J6=eo&&eo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Z6=eo&&eo.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(eo,"__esModule",{value:!0});eo.EffortStatusWorkflow=void 0;var e7=Oe(),im=Ao(),t7=uf(),r7=R1(),n7=k1(),M1=class{static{a(this,"EffortStatusWorkflow")}constructor(){this.resolver=new r7.WorkflowResolver(new n7.InMemoryTripleStore)}setResolver(e){this.resolver=e}getPreviousStatus(e,t){let r=this.normalizeStatus(e),i=this.resolveDefinition(t),s=new t7.WorkflowEngine(i);if(s.isInitialState(r))return null;let o=s.getPreviousStatus(r);if(o!==null)return this.wrapStatus(o)}normalizeStatus(e){return e.replace(/["'[\]]/g,"").trim()}wrapStatus(e){return`"[[${e}]]"`}resolveDefinition(e){return this.hasInstanceClass(e,im.AssetClass.TASK)||this.hasInstanceClass(e,im.AssetClass.MEETING)?this.resolver.getHardcodedFallback(im.AssetClass.TASK):this.resolver.getHardcodedFallback(im.AssetClass.PROJECT)}hasInstanceClass(e,t){return e?(Array.isArray(e)?e:[e]).some(i=>i.replace(/["'[\]]/g,"").trim()===t):!1}};eo.EffortStatusWorkflow=M1;eo.EffortStatusWorkflow=M1=J6([(0,e7.injectable)(),Z6("design:paramtypes",[])],M1)});var Ft=S(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0});om.DI_TOKENS=void 0;om.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),AreaCreationService:Symbol.for("AreaCreationService"),ClassCreationService:Symbol.for("ClassCreationService"),ConceptCreationService:Symbol.for("ConceptCreationService"),SupervisionCreationService:Symbol.for("SupervisionCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),DynamicFrontmatterGenerator:Symbol.for("DynamicFrontmatterGenerator"),AlgorithmExtractor:Symbol.for("AlgorithmExtractor"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),LabelToAliasService:Symbol.for("LabelToAliasService"),RenameToUidService:Symbol.for("RenameToUidService"),PlanningService:Symbol.for("PlanningService"),EffortVotingService:Symbol.for("EffortVotingService"),SessionEventService:Symbol.for("SessionEventService"),CriticalityZoneService:Symbol.for("CriticalityZoneService"),AssetConversionService:Symbol.for("AssetConversionService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),URIConstructionService:Symbol.for("URIConstructionService"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var am=S(Si=>{"use strict";var i7=Si&&Si.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},s7=Si&&Si.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},o7=Si&&Si.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Si,"__esModule",{value:!0});Si.StatusTimestampService=void 0;var bA=Oe(),a7=cs(),pc=Fn(),l7=Ft(),j1=class{static{a(this,"StatusTimestampService")}constructor(e){this.vault=e,this.frontmatterService=new a7.FrontmatterService}async addStartTimestamp(e){let t=await this.vault.read(e),r=pc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_startTimestamp",r);await this.vault.modify(e,i)}async addEndTimestamp(e,t){let r=await this.vault.read(e),i=t||new Date,s=pc.DateFormatter.toLocalTimestamp(i),o=this.frontmatterService.updateProperty(r,"ems__Effort_endTimestamp",s);await this.vault.modify(e,o)}async addResolutionTimestamp(e){let t=await this.vault.read(e),r=pc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_resolutionTimestamp",r);await this.vault.modify(e,i)}async addReviewTimestamp(e){let t=await this.vault.read(e),r=pc.DateFormatter.toLocalTimestamp(new Date),i=this.frontmatterService.updateProperty(t,"ems__Effort_lastReviewTimestamp",r);await this.vault.modify(e,i)}async addEndAndResolutionTimestamps(e,t){let r=await this.vault.read(e),i=t||new Date,s=pc.DateFormatter.toLocalTimestamp(i),o=this.frontmatterService.updateProperty(r,"ems__Effort_endTimestamp",s);o=this.frontmatterService.updateProperty(o,"ems__Effort_resolutionTimestamp",s),await this.vault.modify(e,o)}async removeStartTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_startTimestamp");await this.vault.modify(e,r)}async removeEndTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_endTimestamp");await this.vault.modify(e,r)}async removeResolutionTimestamp(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_resolutionTimestamp");await this.vault.modify(e,r)}async removeEndAndResolutionTimestamps(e){let t=await this.vault.read(e),r=this.frontmatterService.removeProperty(t,"ems__Effort_endTimestamp");r=this.frontmatterService.removeProperty(r,"ems__Effort_resolutionTimestamp"),await this.vault.modify(e,r)}async shiftPlannedEndTimestamp(e,t){let r=await this.vault.read(e),i=this.frontmatterService.parse(r);if(!i.exists)return;let s=this.frontmatterService.getPropertyValue(i.content,"ems__Effort_plannedEndTimestamp");if(!s)return;let o=new Date(s.replace(/["']/g,""));if(isNaN(o.getTime()))return;let l=new Date(o.getTime()+t),c=pc.DateFormatter.toLocalTimestamp(l),u=this.frontmatterService.updateProperty(r,"ems__Effort_plannedEndTimestamp",c);await this.vault.modify(e,u)}};Si.StatusTimestampService=j1;Si.StatusTimestampService=j1=i7([(0,bA.injectable)(),o7(0,(0,bA.inject)(l7.DI_TOKENS.IVaultAdapter)),s7("design:paramtypes",[Object])],j1)});var U1=S(wi=>{"use strict";var c7=wi&&wi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},u7=wi&&wi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},f7=wi&&wi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(wi,"__esModule",{value:!0});wi.TaskStatusService=void 0;var SA=Oe(),d7=cs(),h7=Fn(),p7=sm(),m7=am(),g7=Ft(),$1=class{static{a(this,"TaskStatusService")}constructor(e,t,r){this.vault=e,this.timestampService=r,this.frontmatterService=new d7.FrontmatterService}async syncEffortEndTimestamp(e,t){await this.timestampService.addEndAndResolutionTimestamps(e,t)}async shiftPlannedEndTimestamp(e,t){await this.timestampService.shiftPlannedEndTimestamp(e,t)}async planForEvening(e){let t=await this.vault.read(e),r=new Date;r.setHours(19,0,0,0);let i=h7.DateFormatter.toLocalTimestamp(r),s=this.frontmatterService.updateProperty(t,"ems__Effort_plannedStartTimestamp",i);await this.vault.modify(e,s)}};wi.TaskStatusService=$1;wi.TaskStatusService=$1=c7([(0,SA.injectable)(),f7(0,(0,SA.inject)(g7.DI_TOKENS.IVaultAdapter)),u7("design:paramtypes",[Object,p7.EffortStatusWorkflow,m7.StatusTimestampService])],$1)});var B1=S(lm=>{"use strict";Object.defineProperty(lm,"__esModule",{value:!0});lm.MetadataExtractor=void 0;var y7=Js(),V1=class{static{a(this,"MetadataExtractor")}constructor(e){this.vault=e}extractMetadata(e){return e?this.vault.getFrontmatter(e)||{}:{}}extractInstanceClass(e){return e.exo__Instance_class||null}extractStatus(e){return e.ems__Effort_status||null}extractIsArchived(e){return y7.MetadataHelpers.isAssetArchived(e)}static extractIsDefinedBy(e){let t=e.exo__Asset_isDefinedBy||'""';return Array.isArray(t)&&(t=t[0]||'""'),String(t)}extractExpectedFolder(e){let t=e.exo__Asset_isDefinedBy;if(!t)return null;let r=Array.isArray(t)?t[0]:t;if(!r||typeof r!="string")return null;let i=r.replace(/["'[\]]/g,"").trim();if(!i)return null;let s=i.split("/");return s.pop(),s.join("/")}extractCommandVisibilityContext(e){let t=this.extractMetadata(e),r=this.extractInstanceClass(t),i=this.extractStatus(t),s=this.extractIsArchived(t),o=e.parent?.path||"",l=this.extractExpectedFolder(t);return{instanceClass:r,currentStatus:i,metadata:t,isArchived:s,currentFolder:o,expectedFolder:l}}extractCache(e){return e?this.vault.getFrontmatter(e):null}};lm.MetadataExtractor=V1});var q1=S(vi=>{"use strict";var _7=vi&&vi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},b7=vi&&vi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},S7=vi&&vi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(vi,"__esModule",{value:!0});vi.AreaCreationService=void 0;var wA=Oe(),vA=mi(),w7=Ao(),v7=Fn(),E7=B1(),EA=Js(),T7=Ft(),G1=class{static{a(this,"AreaCreationService")}constructor(e){this.vault=e}async createChildArea(e,t,r){let i=(0,vA.v4)(),s=`${i}.md`,o=this.generateChildAreaFrontmatter(t,e.basename,r,i),l=EA.MetadataHelpers.buildFileContent(o),c=e.parent?.path||"",u=c?`${c}/${s}`:s;return await this.vault.create(u,l)}generateChildAreaFrontmatter(e,t,r,i){let s=new Date,o=v7.DateFormatter.toLocalTimestamp(s),l=E7.MetadataExtractor.extractIsDefinedBy(e),c={};if(c.exo__Asset_isDefinedBy=EA.MetadataHelpers.ensureQuoted(l),c.exo__Asset_uid=i||(0,vA.v4)(),c.exo__Asset_createdAt=o,c.exo__Instance_class=[`"[[${w7.AssetClass.AREA}]]"`],c.ems__Area_parent=`"[[${t}]]"`,r&&r.trim()!==""){let u=r.trim();c.exo__Asset_label=u,c.aliases=[u]}return c}};vi.AreaCreationService=G1;vi.AreaCreationService=G1=_7([(0,wA.injectable)(),S7(0,(0,wA.inject)(T7.DI_TOKENS.IVaultAdapter)),b7("design:paramtypes",[Object])],G1)});var z1=S(Ei=>{"use strict";var I7=Ei&&Ei.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},x7=Ei&&Ei.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},A7=Ei&&Ei.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ei,"__esModule",{value:!0});Ei.AreaHierarchyBuilder=void 0;var TA=Oe(),IA=Ao(),R7=Ft(),cm=Us(),W1=class{static{a(this,"AreaHierarchyBuilder")}constructor(e){this.vault=e}buildHierarchy(e,t){let r=this.vault.getAbstractFileByPath(e);if(!this.isFile(r))return null;let i=this.vault.getFrontmatter(r)||{};if(this.extractInstanceClass(i)!==IA.AssetClass.AREA)return null;let o=this.collectAllAreasFromVault(),l=new Set;return this.buildTree(e,o,l,0)}isFile(e){return!!e&&typeof e=="object"&&"basename"in e&&"path"in e}extractInstanceClass(e){let t=e.exo__Instance_class||"";return Array.isArray(t)?cm.WikiLinkHelpers.normalize(String(t[0]||"")):cm.WikiLinkHelpers.normalize(String(t))}collectAllAreasFromVault(){let e=new Map,t=new Map,r=this.vault.getAllFiles();for(let i of r){let s=this.vault.getFrontmatter(i)||{};if(this.extractInstanceClass(s)===IA.AssetClass.AREA){let l=this.extractParentPath(s);e.set(i.path,{path:i.path,title:i.basename,label:s.exo__Asset_label||void 0,isArchived:this.isArchived(s),depth:0,parentPath:l||void 0}),t.set(i.basename,i.path)}}for(let[,i]of e.entries())i.parentPath&&t.has(i.parentPath)&&(i.parentPath=t.get(i.parentPath));return e}extractParentPath(e){let t=e.ems__Area_parent;if(!t)return null;if(Array.isArray(t)){let r=t[0]||"";return cm.WikiLinkHelpers.normalize(String(r))}return cm.WikiLinkHelpers.normalize(String(t))}isArchived(e){let t=e.exo__Asset_archived;if(t===!0||t==="true")return!0;if(Array.isArray(t)&&t.length>0){let r=t[0];return r===!0||r==="true"}return!1}buildTree(e,t,r,i){if(r.has(e))return null;r.add(e);let s=t.get(e);if(!s)return null;let o=[];for(let[l,c]of t.entries())if(c.parentPath===e){let u=this.buildTree(l,t,r,i+1);u&&o.push(u)}return o.sort((l,c)=>{let u=l.label||l.title,f=c.label||c.title;return u.localeCompare(f)}),{path:s.path,title:s.title,label:s.label,isArchived:s.isArchived,depth:i,parentPath:s.parentPath,children:o}}};Ei.AreaHierarchyBuilder=W1;Ei.AreaHierarchyBuilder=W1=I7([(0,TA.injectable)(),A7(0,(0,TA.inject)(R7.DI_TOKENS.IVaultAdapter)),x7("design:paramtypes",[Object])],W1)});var Q1=S(Ti=>{"use strict";var C7=Ti&&Ti.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},P7=Ti&&Ti.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},O7=Ti&&Ti.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ti,"__esModule",{value:!0});Ti.ClassCreationService=void 0;var xA=Oe(),F7=mi(),D7=Fn(),L7=Js(),N7=Ft(),H1=class{static{a(this,"ClassCreationService")}constructor(e){this.vault=e}async createSubclass(e,t,r){let i=(0,F7.v4)(),s=this.generateFileName(t),o=s.endsWith(".md")?s:`${s}.md`,l=this.generateClassFrontmatter(e.basename,t,i,r),c=L7.MetadataHelpers.buildFileContent(l),u="classes",f=`${u}/${o}`;return this.vault.getAbstractFileByPath(u)||await this.vault.createFolder(u),await this.vault.create(f,c)}generateFileName(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-");for(;t.startsWith("-");)t=t.slice(1);for(;t.endsWith("-");)t=t.slice(0,-1);return t}generateClassFrontmatter(e,t,r,i){let s=new Date,o=D7.DateFormatter.toLocalTimestamp(s),l={};l.exo__Asset_uid=r,l.exo__Asset_label=t,l.exo__Asset_createdAt=o,l.exo__Instance_class=['"[[exo__Class]]"'],l.exo__Class_superClass=`"[[${e}]]"`;let c=i.exo__Asset_isDefinedBy||'"[[Ontology/EXO]]"';return l.exo__Asset_isDefinedBy=c,l.aliases=[t],l}};Ti.ClassCreationService=H1;Ti.ClassCreationService=H1=C7([(0,xA.injectable)(),O7(0,(0,xA.inject)(N7.DI_TOKENS.IVaultAdapter)),P7("design:paramtypes",[Object])],H1)});var X1=S(Ii=>{"use strict";var k7=Ii&&Ii.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},M7=Ii&&Ii.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},j7=Ii&&Ii.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ii,"__esModule",{value:!0});Ii.ConceptCreationService=void 0;var AA=Oe(),$7=mi(),U7=Fn(),V7=Js(),B7=Ao(),G7=Ft(),Y1=class{static{a(this,"ConceptCreationService")}constructor(e){this.vault=e}async createNarrowerConcept(e,t,r,i){let s=(0,$7.v4)(),o=t.endsWith(".md")?t:`${t}.md`,l=this.generateConceptFrontmatter(e.basename,r,i,s),c=V7.MetadataHelpers.buildFileContent(l),u="concepts",f=`${u}/${o}`;return this.vault.getAbstractFileByPath(u)||await this.vault.createFolder(u),await this.vault.create(f,c)}generateConceptFrontmatter(e,t,r,i){let s=new Date,o=U7.DateFormatter.toLocalTimestamp(s),l={};return l.exo__Asset_isDefinedBy='"[[!concepts]]"',l.exo__Asset_uid=i,l.exo__Asset_createdAt=o,l.exo__Instance_class=[`"[[${B7.AssetClass.CONCEPT}]]"`],l.ims__Concept_broader=`"[[${e}]]"`,l.ims__Concept_definition=t,r.length>0&&(l.aliases=r),l}};Ii.ConceptCreationService=Y1;Ii.ConceptCreationService=Y1=k7([(0,AA.injectable)(),j7(0,(0,AA.inject)(G7.DI_TOKENS.IVaultAdapter)),M7("design:paramtypes",[Object])],Y1)});var RA=S(ro=>{"use strict";var q7=ro&&ro.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},W7=ro&&ro.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(ro,"__esModule",{value:!0});ro.InstantiationRuleResolver=void 0;var z7=Oe(),K1=Ae(),mc=$e(),to=er(),J1=class{static{a(this,"InstantiationRuleResolver")}constructor(e){this.tripleStore=e,this.cache=new Map}async getRule(e){let t=this.cache.get(e);if(t!==void 0)return t;let r=await this.findRuleForClass(e);return this.cache.set(e,r),r}invalidateCache(){this.cache.clear()}async findRuleForClass(e){let t=await this.tripleStore.match(void 0,to.Namespace.RDF.term("type"),to.Namespace.EXO.term("InstantiationRule"));for(let r of t){let i=r.subject;if((await this.tripleStore.match(i,to.Namespace.EXO.term("rule_targetClass"),void 0)).some(l=>this.matchesTargetClass(l.object,e)))return this.loadRule(i)}return null}async loadRule(e){let t=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_prototypeUID"),void 0),r=t.length>0&&t[0].object instanceof mc.Literal?t[0].object.value:null,i=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_defaultFolder"),void 0),s=i.length>0&&i[0].object instanceof mc.Literal?i[0].object.value:null,o=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_propertySetRules"),void 0),l=[];for(let c of o){let u=c.object;if(!(u instanceof K1.IRI))continue;let f=await this.loadPropertySetRule(u);f&&l.push(f)}return{prototypeUID:r,defaultFolder:s,propertySetRules:l}}async loadPropertySetRule(e){let t=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_property"),void 0);if(t.length===0)return null;let r=t[0].object,i=r instanceof K1.IRI?this.extractLocalName(r):r instanceof mc.Literal?this.normalizeWikilink(r.value):null;if(!i)return null;let s=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_value"),void 0),o=s.length>0&&s[0].object instanceof mc.Literal?s[0].object.value:"",l=await this.tripleStore.match(e,to.Namespace.EXO.term("rule_valueType"),void 0),c=l.length>0&&l[0].object instanceof mc.Literal?l[0].object.value:"literal";return{property:i,value:o,valueType:c}}matchesTargetClass(e,t){return e instanceof K1.IRI?this.extractLocalName(e)===t:e instanceof mc.Literal?this.normalizeWikilink(e.value)===t:!1}extractLocalName(e){let t=e.value,r=t.lastIndexOf("#");if(r>=0){let s=t.substring(r+1);return t.includes("/ems#")?`ems__${s}`:t.includes("/exo#")?`exo__${s}`:t.includes("/ims#")?`ims__${s}`:s}let i=t.lastIndexOf("/");return i>=0?t.substring(i+1):t}normalizeWikilink(e){return e.replace(/["'[\]]/g,"").trim()}};ro.InstantiationRuleResolver=J1;ro.InstantiationRuleResolver=J1=q7([(0,z7.injectable)(),W7("design:paramtypes",[Object])],J1)});var CA=S(no=>{"use strict";var H7=no&&no.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Q7=no&&no.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(no,"__esModule",{value:!0});no.VisibilityGenerator=void 0;var Y7=Oe(),X7=uf(),Z1=class{static{a(this,"VisibilityGenerator")}constructor(e){this.engine=e}getVisibleCommands(e){return this.engine.getAllTransitions(e).map(t=>this.toCommand(t))}getForwardCommands(e){return this.engine.getAvailableTransitions(e).map(t=>this.toCommand(t))}getRollbackCommands(e){return this.engine.getRollbackTransitions(e).map(t=>this.toCommand(t))}toCommand(e){let t=e.from.replace("ems__EffortStatus","").toLowerCase(),r=e.to.replace("ems__EffortStatus","").toLowerCase();return{commandId:`workflow-${t}-to-${r}`,label:e.label,icon:e.icon,targetStatus:e.to,isRollback:e.isRollback}}};no.VisibilityGenerator=Z1;no.VisibilityGenerator=Z1=H7([(0,Y7.injectable)(),Q7("design:paramtypes",[X7.WorkflowEngine])],Z1)});var PA=S(io=>{"use strict";var K7=io&&io.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},J7=io&&io.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(io,"__esModule",{value:!0});io.WorkflowCommandAdapter=void 0;var Z7=Oe(),eS=Io(),e8=uf(),tS=class{static{a(this,"WorkflowCommandAdapter")}constructor(e){this.workflow=e,this.engine=new e8.WorkflowEngine(e)}adaptTransitions(e){return this.engine.getAllTransitions(e).map(r=>this.transitionToCommand(r))}adaptForwardTransitions(e){return this.engine.getAvailableTransitions(e).map(r=>this.transitionToCommand(r))}adaptRollbackTransitions(e){return this.engine.getRollbackTransitions(e).map(r=>this.transitionToCommand(r))}getEngine(){return this.engine}getWorkflow(){return this.workflow}transitionToCommand(e){let t=this.generateCommandId(e),r=this.buildPrecondition(e),i=this.buildGrounding(e),s=e.isRollback?"rollback":"workflow";return{id:t,name:e.label,icon:e.icon,precondition:r,grounding:i,category:s,confirmMessage:e.isRollback?`Rollback to ${this.shortStatus(e.to)}?`:void 0,successMessage:`Status changed to ${this.shortStatus(e.to)}`}}generateCommandId(e){let t=this.shortStatus(e.from),r=this.shortStatus(e.to);return`workflow-${t}-to-${r}`}buildPrecondition(e){return{id:`precond-${this.generateCommandId(e)}`,label:`Asset status is ${this.shortStatus(e.from)}`,sparqlAsk:`ASK { $target ems:Effort_status "${e.from}" }`}}buildGrounding(e){let t=[];t.push({id:`gnd-status-${this.shortStatus(e.to)}`,label:`Set status to ${this.shortStatus(e.to)}`,type:eS.GroundingType.PROPERTY_SET,targetProperty:"ems__Effort_status",targetValueRef:e.to});let r=this.engine.getTimestampsForStatus(e.to);for(let i of r)t.push({id:`gnd-ts-${i}`,label:`Set ${i}`,type:eS.GroundingType.PROPERTY_SET,targetProperty:i,targetValueSubstitution:"$now"});return t.length===1?t[0]:{id:`gnd-composite-${this.generateCommandId(e)}`,label:`Transition to ${this.shortStatus(e.to)}`,type:eS.GroundingType.COMPOSITE,steps:t}}shortStatus(e){return e.replace("ems__EffortStatus","").toLowerCase()}};io.WorkflowCommandAdapter=tS;io.WorkflowCommandAdapter=tS=K7([(0,Z7.injectable)(),J7("design:paramtypes",[Object])],tS)});var nS=S(xi=>{"use strict";var t8=xi&&xi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},r8=xi&&xi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},n8=xi&&xi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(xi,"__esModule",{value:!0});xi.EffortVotingService=void 0;var OA=Oe(),i8=Ft(),rS=class{static{a(this,"EffortVotingService")}constructor(e){this.vault=e}async incrementEffortVotes(e){let t=await this.vault.read(e),i=this.extractVoteCount(t)+1,s=this.updateFrontmatterWithVotes(t,i);return await this.vault.modify(e,s),i}extractVoteCount(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/,r=e.match(t);if(!r)return 0;let s=r[1].match(/ems__Effort_votes:\s*(\d+)/);return s&&s[1]?parseInt(s[1],10):0}updateFrontmatterWithVotes(e,t){let r=/^---\r?\n([\s\S]*?)\r?\n---/,i=e.match(r),s=e.includes(`\r
101
101
  `)?`\r
102
102
  `:`
103
103
  `;if(!i)return`---${s}ems__Effort_votes: ${t}${s}---${s}${e}`;let l=i[1];return l.includes("ems__Effort_votes:")?l=l.replace(/ems__Effort_votes:.*$/m,`ems__Effort_votes: ${t}`):l+=`${s}ems__Effort_votes: ${t}`,e.replace(r,`---${s}${l}${s}---`)}};xi.EffortVotingService=rS;xi.EffortVotingService=rS=t8([(0,OA.injectable)(),n8(0,(0,OA.inject)(i8.DI_TOKENS.IVaultAdapter)),r8("design:paramtypes",[Object])],rS)});var sS=S(iS=>{"use strict";Object.defineProperty(iS,"__esModule",{value:!0});iS.extractAssetReference=s8;function s8(n){if(typeof n!="string")return null;let e=n.trim().replace(/^["']|["']$/g,"");e=e.replace(/^\[\[|\]\]$/g,"");let t=e.indexOf("|");return t!==-1&&(e=e.slice(0,t).trim()),e||null}a(s8,"extractAssetReference")});var aS=S(Ai=>{"use strict";var o8=Ai&&Ai.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},a8=Ai&&Ai.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},l8=Ai&&Ai.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ai,"__esModule",{value:!0});Ai.FolderRepairService=void 0;var FA=Oe(),c8=Ft(),u8=sS(),oS=class{static{a(this,"FolderRepairService")}constructor(e){this.vault=e}async getExpectedFolder(e,t){return this.getExpectedFolderSync(e,t)}getExpectedFolderSync(e,t){let r=t?.exo__Asset_isDefinedBy;if(!r)return null;let i=(0,u8.extractAssetReference)(r);if(!i)return null;let s=this.vault.getFirstLinkpathDest(i,e.path);return s?this.getFileFolder(s):null}async repairFolder(e,t){let r=`${t}/${e.name}`;if(this.vault.getAbstractFileByPath(r))throw new Error(`Cannot move file: ${r} already exists`);await this.ensureFolderExists(t),await this.vault.rename(e,r)}getFileFolder(e){return e.parent?.path||""}async ensureFolderExists(e){if(!e)return;let t=this.vault.getAbstractFileByPath(e);if(!(t&&"children"in t))try{await this.vault.createFolder(e)}catch(r){if(r instanceof Error&&r.message.includes("Folder already exists"))return;throw r}}};Ai.FolderRepairService=oS;Ai.FolderRepairService=oS=o8([(0,FA.injectable)(),l8(0,(0,FA.inject)(c8.DI_TOKENS.IVaultAdapter)),a8("design:paramtypes",[Object])],oS)});var cS=S(Ri=>{"use strict";var f8=Ri&&Ri.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},d8=Ri&&Ri.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},h8=Ri&&Ri.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ri,"__esModule",{value:!0});Ri.LabelToAliasService=void 0;var DA=Oe(),p8=Ft(),lS=class{static{a(this,"LabelToAliasService")}constructor(e){this.vault=e}async copyLabelToAliases(e){let t=await this.vault.read(e),r=this.extractLabel(t);if(!r)throw new Error("No exo__Asset_label found in file");let i=this.addLabelToAliases(t,r);await this.vault.modify(e,i)}extractLabel(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/,r=e.match(t);if(!r)return null;let s=r[1].match(/exo__Asset_label:\s*["']?([^"'\r\n]+)["']?/);return s&&s[1]?s[1].trim():null}addLabelToAliases(e,t){let r=/^---\r?\n([\s\S]*?)\r?\n---/,i=e.match(r),s=e.includes(`\r
@@ -209,7 +209,7 @@ ${s}`}return`${r}: ${i}`}).join(`
209
209
  `,o=await this.sparqlService.query(s);return this.buildEnumValues(o)}buildEnumValues(e){let t=[],r=new Set;for(let i of e){let s=this.getBindingValue(i,"instance");if(!s||r.has(s))continue;r.add(s);let o=this.getBindingValue(i,"label")??s,c=`[[${this.fromFullIRI(s)}]]`;t.push({value:c,label:o})}return t}buildRankProperty(e){let t=e.match(/^([a-z]+)__(.+)$/);if(!t)return null;let[,r,i]=t;return`${r}__${i}_rank`}normalizeClassName(e){return e.replace(/\[\[|\]\]/g,"").trim()}getBindingValue(e,t){let r=e.get(t);if(r!=null)return String(r)}toFullIRI(e){if(e.startsWith("http://")||e.startsWith("https://"))return e;let t=e.match(/^([a-z]+)__(.+)$/);if(t){let[,r,i]=t;return`https://exocortex.my/ontology/${r}#${i}`}return e}fromFullIRI(e){let t=e.match(/https:\/\/exocortex\.my\/ontology\/([a-z]+)#(.+)$/);if(t){let[,r,i]=t;return`${r}__${i}`}return e}};ao.EnumValueResolver=xS;ao.EnumValueResolver=xS=q8([(0,z8.injectable)(),W8("design:paramtypes",[Object,Object])],xS)});var RS=S(Di=>{"use strict";var H8=Di&&Di.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Q8=Di&&Di.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},Y8=Di&&Di.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Di,"__esModule",{value:!0});Di.AssetConversionService=void 0;var WA=Oe(),zA=Ao(),X8=cs(),um=$o(),K8=Ft(),AS=class{static{a(this,"AssetConversionService")}constructor(e){this.vault=e,this.frontmatterService=new X8.FrontmatterService}async convertTaskToProject(e){try{let t=await this.vault.read(e),r=this.removeInstanceClassProperty(t);return r=this.frontmatterService.updateProperty(r,"exo__Instance_class",`["[[${zA.AssetClass.PROJECT}]]"]`),await this.vault.modify(e,r),um.LoggingService.info(`Converted Task to Project: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Task to Project: ${e.path}`;throw um.LoggingService.error(r,t instanceof Error?t:void 0),new Error(r)}}async convertProjectToTask(e){try{let t=await this.vault.read(e),r=this.removeInstanceClassProperty(t);return r=this.frontmatterService.updateProperty(r,"exo__Instance_class",`["[[${zA.AssetClass.TASK}]]"]`),await this.vault.modify(e,r),um.LoggingService.info(`Converted Project to Task: ${e.basename} (${e.path})`),e}catch(t){let r=`Failed to convert Project to Task: ${e.path}`;throw um.LoggingService.error(r,t instanceof Error?t:void 0),new Error(r)}}removeInstanceClassProperty(e){let t=this.frontmatterService.parse(e);if(!t.exists)return e;let r=/^exo__Instance_class:.*$(\n -.*$)*/gm,i=t.content.replace(r,"").replace(/\n\n+/g,`
210
210
  `).trim();return e.replace(/^---\n[\s\S]*?\n---/,`---
211
211
  ${i}
212
- ---`)}};Di.AssetConversionService=AS;Di.AssetConversionService=AS=H8([(0,WA.injectable)(),Y8(0,(0,WA.inject)(K8.DI_TOKENS.IVaultAdapter)),Q8("design:paramtypes",[Object])],AS)});var OS=S(Li=>{"use strict";var J8=Li&&Li.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Z8=Li&&Li.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},HA=Li&&Li.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Li,"__esModule",{value:!0});Li.SessionEventService=void 0;var CS=Oe(),e$=mi(),QA=Ao(),t$=Fn(),r$=Js(),YA=Ft(),PS=class{static{a(this,"SessionEventService")}constructor(e,t){this.vault=e,this.vaultSettings=t,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,QA.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,QA.AssetClass.SESSION_END_EVENT)}getSessionEventFolder(){if(this.folderPathCache!==null)return this.folderPathCache;let e=this.vault.getDefaultNewFileParent();return this.folderPathCache=e?.path||"",this.folderPathCache}async createSessionEvent(e,t){let r=(0,e$.v4)(),i=t$.DateFormatter.toLocalTimestamp(new Date),s={exo__Asset_uid:r,exo__Asset_createdAt:i,exo__Asset_isDefinedBy:this.vaultSettings.getOwnerIdentity(),exo__Instance_class:[`"[[${t}]]"`],ems__SessionEvent_timestamp:i,ems__Session_area:`"[[${e}]]"`},o=r$.MetadataHelpers.buildFileContent(s),l=this.getSessionEventFolder();l&&!await this.vault.exists(l)&&await this.vault.createFolder(l);let c=l?`${l}/${r}.md`:`${r}.md`;return await this.vault.create(c,o)}};Li.SessionEventService=PS;Li.SessionEventService=PS=J8([(0,CS.injectable)(),HA(0,(0,CS.inject)(YA.DI_TOKENS.IVaultAdapter)),HA(1,(0,CS.inject)(YA.DI_TOKENS.IVaultSettings)),Z8("design:paramtypes",[Object,Object])],PS)});var LS=S(Ni=>{"use strict";var n$=Ni&&Ni.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},i$=Ni&&Ni.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},XA=Ni&&Ni.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ni,"__esModule",{value:!0});Ni.URIConstructionService=void 0;var FS=Oe(),KA=Ft(),s$=Cl(),DS=class{static{a(this,"URIConstructionService")}constructor(e,t=s$.NullLogger){this.fileSystem=e,this.logger=t,this.defaultOntologyURL="https://exocortex.my/default/",this.strictValidation=!0}configure(e){e?.defaultOntologyURL&&(this.defaultOntologyURL=e.defaultOntologyURL),e?.strictValidation!==void 0&&(this.strictValidation=e.strictValidation)}async constructAssetURI(e){let t=this.extractUID(e);if(!t){if(this.strictValidation)throw new Error(`Asset missing exo__Asset_uid: ${e.path}`);return this.logger.warn(`Asset ${e.path} missing UID, using filename fallback`),this.constructFallbackURI(e)}let r=await this.resolveOntologyURL(e);if(!this.validateOntologyURL(r))throw new Error(`Invalid ontology URL: ${r}`);return`${r.endsWith("/")?r:`${r}/`}${t}`}validateOntologyURL(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}async resolveOntologyURL(e){let t=e.frontmatter?.exo__Asset_isDefinedBy;if(!t||typeof t!="string")return this.defaultOntologyURL;let r=this.extractWikiLink(t),i=r,s=await this.fileSystem.fileExists(r);return!s&&!r.endsWith(".md")&&(i=`${r}.md`,s=await this.fileSystem.fileExists(i)),s?(await this.fileSystem.getFileMetadata(i))?.exo__Ontology_url||this.defaultOntologyURL:(this.logger.warn(`Ontology file not found: ${r}, using default`),this.defaultOntologyURL)}extractUID(e){let t=e.frontmatter?.exo__Asset_uid;return typeof t=="string"?t:null}extractWikiLink(e){return e.replace(/^\[\[|\]\]$/g,"")}constructFallbackURI(e){let t=e.path.split("/").pop()?.replace(".md","")||"unknown";return`${this.defaultOntologyURL}${t}`}};Ni.URIConstructionService=DS;Ni.URIConstructionService=DS=n$([(0,FS.injectable)(),XA(0,(0,FS.inject)(KA.DI_TOKENS.IFileSystemAdapter)),XA(1,(0,FS.inject)(KA.DI_TOKENS.ILogger)),i$("design:paramtypes",[Object,Object])],DS)});var kS=S(ki=>{"use strict";var o$=ki&&ki.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},a$=ki&&ki.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},l$=ki&&ki.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ki,"__esModule",{value:!0});ki.GenericAssetCreationService=void 0;var JA=Oe(),hf=Fn(),c$=Js(),u$=Us(),f$=Ft(),fs=yh(),d$=nf(),h$=Bp(),NS=class{static{a(this,"GenericAssetCreationService")}constructor(e){this.vault=e,this.clock=(0,d$.liveClock)(),this.uidGen=(0,h$.liveUidGenerator)()}withDeterminism(e){return e.clock&&(this.clock=e.clock),e.uidGenerator&&(this.uidGen=e.uidGenerator),this}async createAsset(e,t){let r=this.uidGen.next(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),o=c$.MetadataHelpers.buildFileContent(s),l=e.folderPath||this.getDefaultFolderPath(e);this.vault.getAbstractFileByPath(l)||await this.vault.createFolder(l);let u=l?`${l}/${i}`:i;return await this.vault.create(u,o)}generateFrontmatter(e,t,r){let i=this.clock.now(),s={},o=new Map;for(let l of t)o.set(l.name,l.fieldType);if(s.exo__Asset_uid=r,s.exo__Asset_createdAt=hf.DateFormatter.toLocalTimestamp(i),s.exo__Instance_class=[this.formatWikilink(e.className)],e.label&&e.label.trim()!==""){let l=e.label.trim();s.exo__Asset_label=l,s.aliases=[l]}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(s,e),e.propertyValues)for(let[l,c]of Object.entries(e.propertyValues)){if(l==="exo__Asset_uid"||l==="exo__Asset_createdAt"||l==="exo__Instance_class"||l==="exo__Asset_label"||l==="aliases"||c==null)continue;let u=o.get(l);s[l]=this.formatValue(c,u)}return s}inheritParentContext(e,t){let r=t.parentMetadata||{},i=t.parentFile?.basename;if(t.className==="ems__Task"||t.className.startsWith("ems__Task")){let s=r.exo__Instance_class,l=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[l]=i?this.formatWikilink(i):null}if(t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=r.exo__Instance_class,l=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[l]=i?this.formatWikilink(i):null}if(r.exo__Asset_isDefinedBy){let s=r.exo__Asset_isDefinedBy;e.exo__Asset_isDefinedBy=typeof s=="string"?this.formatWikilink(s):s}}isAreaClass(e,t){if(!e)return!1;let r=Array.isArray(e)?e:[e],i=a(()=>null,"noopResolver");return r.some(s=>{let o=u$.WikiLinkHelpers.resolveSymbolic(String(s),t??i);return o.includes("Area")||o.includes("ems__Area")})}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events",ims__Concept:"concepts"};if(t[e.className])return t[e.className];for(let[r,i]of Object.entries(t))if(e.className.startsWith(r))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case fs.PropertyFieldType.Text:return String(e);case fs.PropertyFieldType.Wikilink:case fs.PropertyFieldType.Reference:case fs.PropertyFieldType.StatusSelect:case fs.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case fs.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case fs.PropertyFieldType.Boolean:return this.formatBoolean(e);case fs.PropertyFieldType.Date:case fs.PropertyFieldType.DateTime:case fs.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?hf.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return hf.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:hf.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return hf.DateFormatter.toLocalTimestamp(t)}return String(e)}};ki.GenericAssetCreationService=NS;ki.GenericAssetCreationService=NS=o$([(0,JA.injectable)(),l$(0,(0,JA.inject)(f$.DI_TOKENS.IVaultAdapter)),a$("design:paramtypes",[Object])],NS)});var e3=S(Mi=>{"use strict";var p$=Mi&&Mi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},m$=Mi&&Mi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},g$=Mi&&Mi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Mi,"__esModule",{value:!0});Mi.ArchiveAssetService=void 0;var ZA=Oe(),y$=Ft(),_$=cs(),MS=class{static{a(this,"ArchiveAssetService")}constructor(e){this.vault=e,this.frontmatterService=new _$.FrontmatterService}async archiveAsset(e){let t=await this.vault.read(e),r=this.frontmatterService.updateProperty(t,"archived","true");r=this.frontmatterService.removeProperty(r,"aliases"),r!==t&&await this.vault.modify(e,r)}};Mi.ArchiveAssetService=MS;Mi.ArchiveAssetService=MS=p$([(0,ZA.injectable)(),g$(0,(0,ZA.inject)(y$.DI_TOKENS.IVaultAdapter)),m$("design:paramtypes",[Object])],MS)});var r3=S(ji=>{"use strict";var b$=ji&&ji.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},S$=ji&&ji.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},w$=ji&&ji.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ji,"__esModule",{value:!0});ji.FixMissingLabelService=void 0;var t3=Oe(),v$=Ft(),E$=cs(),jS=class{static{a(this,"FixMissingLabelService")}constructor(e){this.vault=e,this.frontmatterService=new E$.FrontmatterService}async fixMissingLabel(e){let t=await this.vault.read(e);if(this.hasNonEmptyLabel(t))return;let r=this.frontmatterService.updateProperty(t,"exo__Asset_label",e.basename);r!==t&&await this.vault.modify(e,r)}hasNonEmptyLabel(e){let t=this.frontmatterService.parse(e);if(!t.exists)return!1;let r=t.content.match(/^exo__Asset_label:\s*(.*)$/m);if(!r)return!1;let i=r[1].trim();return!(i===""||i==='""'||i==="''")}};ji.FixMissingLabelService=jS;ji.FixMissingLabelService=jS=b$([(0,t3.injectable)(),w$(0,(0,t3.inject)(v$.DI_TOKENS.IVaultAdapter)),S$("design:paramtypes",[Object])],jS)});var n3=S(lo=>{"use strict";var T$=lo&&lo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},I$=lo&&lo.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(lo,"__esModule",{value:!0});lo.GraphQueryService=void 0;var x$=Oe(),pf=Ae(),A$=$e(),Go=er(),R$=R0(),ds={INSTANCE_CLASS:Go.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Go.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Go.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:Go.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Go.Namespace.EMS.term("Effort_parent"),REFERENCES:Go.Namespace.EXO.term("references"),REFERENCED_BY:Go.Namespace.EXO.term("referencedBy"),RDF_TYPE:Go.Namespace.RDF.term("type")},$S=class{static{a(this,"GraphQueryService")}constructor(e,t={},r){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=r,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),r=await this.loadNodes(e),i=await this.loadEdges(r,e),s=this.computeStats(r,i),o=Date.now()-t;return o>100&&r.length>0&&this.logger?.debug(`GraphQueryService: loaded ${r.length} nodes in ${o}ms (${(o/r.length).toFixed(2)}ms/node)`),{nodes:r,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),r=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:r}),s=i.length>t,o=s?i.slice(0,t):i,l=await this.loadEdges(o,e);return{nodes:o,edges:l,hasMore:s,totalCount:void 0,cursor:s?String(r+t):void 0}}async loadConnectedNodes(e,t={}){let r=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,o=[{id:e,currentDepth:0}],l=[];for(;o.length>0&&l.length<i;){let u=o.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let h=await this.getNodeById(f,t);if(h&&(l.push(h),d<r)){let p=await this.getConnectedNodeIds(f);for(let g of p)s.has(g)||o.push({id:g,currentDepth:d+1})}}let c=await this.loadEdges(l,t);return{nodes:l,edges:c,hasMore:o.length>0,totalCount:s.size+o.length}}async getNodeById(e,t={}){let r=this.getCachedNode(e);if(r)return{...r};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let o=this.triplesToNode(e,s,t);return o&&this.cacheNode(o),o}subscribe(e){return this.subscribers.add(e),{unsubscribe:a(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(r){this.logger?.error("GraphQueryService: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,r=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,ds.INSTANCE_CLASS,void 0),o=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);o=s.filter(g=>{let _=this.getObjectValue(g.object);return _&&p.has(_)})}let l=new Set;for(let p of o)l.add(this.subjectToId(p.subject));let f=Array.from(l).slice(i,i+r).map(p=>this.getNodeById(p,e));return(await Promise.all(f)).filter(p=>!(!p||!t&&p.isArchived))}async loadEdges(e,t){let r=new Set(e.map(o=>o.id)),i=[],s=new Set;for(let o of e){let l=this.idToIRI(o.id),c=await this.tripleStore.match(l,void 0,void 0);for(let u of c){let f=this.tripleToEdge(o.id,u,r);f&&f.id&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),r=[],i=await this.tripleStore.match(t,void 0,void 0);for(let o of i){let l=this.objectToId(o.object);l&&r.push(l)}let s=await this.tripleStore.match(void 0,void 0,t);for(let o of s)r.push(this.subjectToId(o.subject));return[...new Set(r)]}triplesToNode(e,t,r){let i={},s,o,l,c,u=!1;for(let h of t){let p=h.predicate.value,g=this.getObjectValue(h.object);if(p===ds.INSTANCE_CLASS.value)s=g;else if(p===ds.ASSET_LABEL.value)o=g;else if(p===ds.ASSET_PROTOTYPE.value)l=this.objectToId(h.object)??g;else if(p===ds.EFFORT_PARENT.value)c=this.objectToId(h.object)??g;else if(p===ds.ASSET_IS_ARCHIVED.value)u=g==="true"||g==="1";else{let _=this.predicateToPropertyName(p);_&&(i[_]=g)}}if(u&&!(r.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=o??this.pathToTitle(f);return{id:e,path:f,title:d,label:d,assetClass:s,isArchived:u,uri:e.startsWith("http")?e:void 0,prototype:l,parent:c,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,r){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!r.has(s)||s===e)return null;let o=this.predicateToEdgeType(i);if(!o)return null;let l=(0,R$.createEdgeId)(e,s,o,i),c=this.predicateToLabel(i);return{id:l,source:e,target:s,type:o,predicate:i,label:c}}predicateToEdgeType(e){return e===ds.EFFORT_PARENT.value?"hierarchy":e===ds.ASSET_PROTOTYPE.value?"prototype":e===ds.REFERENCES.value?"forward-link":e===ds.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),r=e.lastIndexOf("/"),i=Math.max(t,r);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let r={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let l of e){let c=l.assetClass??"unknown";r[c]=(r[c]??0)+1}for(let l of t)i[l.type]=(i[l.type]??0)+1;let s=new Map,o=new Map;for(let l of t)o.set(l.source,(o.get(l.source)??0)+1),s.set(l.target,(s.get(l.target)??0)+1);for(let l of e)l.inDegree=s.get(l.id)??0,l.outDegree=o.get(l.id)??0,l.weight=l.inDegree+l.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:r,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new pf.IRI(e):new pf.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof pf.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof pf.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof A$.Literal||e instanceof pf.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};lo.GraphQueryService=$S;lo.GraphQueryService=$S=T$([(0,x$.injectable)(),I$("design:paramtypes",[Object,Object,Object])],$S)});var s3=S(co=>{"use strict";var C$=co&&co.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},P$=co&&co.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(co,"__esModule",{value:!0});co.TypeRegistry=void 0;var O$=Oe(),hs=Ae(),i3=$t(),F$=$e(),D$=$o(),mt=C0(),US=class{static{a(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:mt.DEFAULT_NODE_STYLE,defaultEdgeStyle:mt.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let r=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:r,typeUri:e.uri,definition:e})}registerEdgeType(e){let r=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:r,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),r=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||r)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let r=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;let{uri:l,currentDepth:c}=o;if(i.has(l)||(i.add(l),c>=t))continue;let u=this.typeHierarchy.get(l)??[];for(let f of u)i.has(f)||(r.push(f),s.push({uri:f,currentDepth:c+1}))}return r}getChildTypes(e){let t=[];for(let[r,i]of this.typeHierarchy)i.includes(e)&&t.push(r);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],r="unknown",i="custom";if(e.assetClass){let l=this.normalizeTypeUri(e.assetClass);t.push(l),r=l,i="exo:Instance_class"}let s=e.properties?.[mt.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),r==="unknown"&&(r=s,i="rdf:type"));for(let l of[...t]){let c=this.getParentTypes(l);for(let u of c)t.includes(u)||t.push(u)}let o=this.resolveNodeStyle(t);return{primaryType:r,types:t,resolvedStyle:o,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,r=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:r}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:r}=this.config.styleResolution,i={...r},s=[];for(let o of e){let l=this.nodeTypes.get(o);l&&s.push(l)}if(s.sort((o,l)=>o.priority-l.priority),t)for(let o of s)i=(0,mt.mergeNodeStyles)(i,o.style);else if(s.length>0){let o=s[s.length-1];i=(0,mt.mergeNodeStyles)(i,o.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,r={...t},i=this.edgeTypes.get(e);return i&&(r=(0,mt.mergeEdgeStyles)(r,i.style)),r}filterNodes(e,t){return e.filter(r=>{let i=this.resolveNodeType(r);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(r=>{let i=r.predicate??r.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,r={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:o=0,maxGroups:l=20,customGroupFn:c}=r,u=new Map;for(let h of e){let p=this.resolveNodeType(h),g;if(c?g=c(p.types):s&&p.types.length>o?g=p.types[o]??p.primaryType:i?g=p.primaryType:g="all",!u.has(g)){let w=this.nodeTypes.get(g)?.label??(0,mt.extractLocalName)(g);u.set(g,{nodeIds:new Set,label:w})}let _=u.get(g);_&&_.nodeIds.add(h.id)}let f=Array.from(u.entries()).map(([h,p])=>({id:h,label:p.label,nodeIds:Array.from(p.nodeIds)}));if(f.length>l){f.sort((g,_)=>_.nodeIds.length-g.nodeIds.length);let h=f.slice(0,l-1),p=f.slice(l-1).flatMap(g=>g.nodeIds);h.push({id:"other",label:"Other",nodeIds:p}),f=h}let d=new Map;for(let h of f)for(let p of h.nodeIds)d.set(p,h.id);return f.map((h,p)=>{let g=new Set(h.nodeIds),_=[],v=[];for(let I of t){let A=g.has(I.source),D=g.has(I.target);A&&D?I.id&&_.push(I.id):(A||D)&&I.id&&v.push(I.id)}let E=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:h.id,label:h.label,nodeIds:h.nodeIds,internalEdgeIds:_,externalEdgeIds:v,color:E,stats:{nodeCount:h.nodeIds.length,internalEdgeCount:_.length,externalEdgeCount:v.length}}})}validateTypes(e,t){let r=[],i=[];for(let s of e){let o=this.resolveNodeType(s);if(o.primaryType!=="unknown"){let l=this.nodeTypes.get(o.primaryType);!l&&o.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${o.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),l?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${o.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let o=s.predicate??s.type,l=this.edgeTypes.get(o);if(l?.domain&&l.domain.length>0){let c=e.find(u=>u.id===s.source);if(c){let u=this.resolveNodeType(c);l.domain.some(d=>u.types.includes(d))||r.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:l.domain,actual:u.types})}}if(l?.range&&l.range.length>0){let c=e.find(u=>u.id===s.target);if(c){let u=this.resolveNodeType(c);l.range.some(d=>u.types.includes(d))||r.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:l.range,actual:u.types})}}}return{valid:r.length===0,errors:r,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new hs.IRI(mt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let r of e){let i=this.getObjectValue(r.object);if(i&&(0,mt.isClassType)(i)){let s=this.getSubjectValue(r.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new hs.IRI(mt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let r of t){let i=this.getSubjectValue(r.subject),s=this.getObjectValue(r.object);if(i&&s){let o=this.typeHierarchy.get(i)??[];if(!o.includes(s)){o.push(s),this.typeHierarchy.set(i,o);let l=this.nodeTypes.get(i);l&&(l.parentTypes=o)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(mt.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,mt.extractLocalName)(e),source:"custom",style:(0,mt.mergeNodeStyles)(mt.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(mt.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,mt.extractLocalName)(e),source:"custom",style:(0,mt.mergeEdgeStyles)(mt.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new hs.IRI(e),new hs.IRI(mt.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new hs.IRI(e),new hs.IRI(mt.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,mt.extractLocalName)(e):(0,mt.extractLocalName)(e),s=r.length>0?this.getObjectValue(r[0].object):void 0,o="rdfs:Class",l=await this.tripleStore.match(new hs.IRI(e),new hs.IRI(mt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of l)if(this.getObjectValue(f.object)===mt.RDF_TYPE_PREDICATES.OWL_CLASS){o="owl:Class";break}let c=mt.BUILT_IN_NODE_STYLES[e]??mt.BUILT_IN_NODE_STYLES[(0,mt.extractLocalName)(e)],u={uri:e,label:i,description:s,source:o,style:(0,mt.mergeNodeStyles)(mt.DEFAULT_NODE_STYLE,c??{}),priority:1};this.registerNodeType(u)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof hs.IRI)return e.value;if(e instanceof i3.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof F$.Literal||e instanceof hs.IRI)return e.value;if(e instanceof i3.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let r of this.typeHierarchy.values())for(let i of r)e.add(i);let t=[];for(let r of this.nodeTypes.keys()){let i=this.typeHierarchy.get(r);(!i||i.length===0)&&e.has(r)&&t.push(r)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(r){D$.LoggingService.error("TypeRegistry: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}}};co.TypeRegistry=US;co.TypeRegistry=US=C$([(0,O$.injectable)(),P$("design:paramtypes",[Object,Object])],US)});var VS=S($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.SPARQL_TEMPLATES=$.KNOWN_CLASSES=$.KNOWN_PROTOTYPES=$.EFFORT_STATUSES=$.ASSET_CLASSES=$.PREDICATES=$.SPARQL_PREFIXES=void 0;$.findClassByTerm=L$;$.getTemplateByName=N$;$.findMatchingTemplates=k$;$.fillTemplate=M$;$.validateParameters=j$;$.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
212
+ ---`)}};Di.AssetConversionService=AS;Di.AssetConversionService=AS=H8([(0,WA.injectable)(),Y8(0,(0,WA.inject)(K8.DI_TOKENS.IVaultAdapter)),Q8("design:paramtypes",[Object])],AS)});var OS=S(Li=>{"use strict";var J8=Li&&Li.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Z8=Li&&Li.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},HA=Li&&Li.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Li,"__esModule",{value:!0});Li.SessionEventService=void 0;var CS=Oe(),e$=mi(),QA=Ao(),t$=Fn(),r$=Js(),YA=Ft(),PS=class{static{a(this,"SessionEventService")}constructor(e,t){this.vault=e,this.vaultSettings=t,this.folderPathCache=null}async createSessionStartEvent(e){return this.createSessionEvent(e,QA.AssetClass.SESSION_START_EVENT)}async createSessionEndEvent(e){return this.createSessionEvent(e,QA.AssetClass.SESSION_END_EVENT)}getSessionEventFolder(){if(this.folderPathCache!==null)return this.folderPathCache;let e=this.vault.getDefaultNewFileParent();return this.folderPathCache=e?.path||"",this.folderPathCache}async createSessionEvent(e,t){let r=(0,e$.v4)(),i=t$.DateFormatter.toLocalTimestamp(new Date),s={exo__Asset_uid:r,exo__Asset_createdAt:i,exo__Asset_isDefinedBy:this.vaultSettings.getOwnerIdentity(),exo__Instance_class:[`"[[${t}]]"`],ems__SessionEvent_timestamp:i,ems__Session_area:`"[[${e}]]"`},o=r$.MetadataHelpers.buildFileContent(s),l=this.getSessionEventFolder();l&&!await this.vault.exists(l)&&await this.vault.createFolder(l);let c=l?`${l}/${r}.md`:`${r}.md`;return await this.vault.create(c,o)}};Li.SessionEventService=PS;Li.SessionEventService=PS=J8([(0,CS.injectable)(),HA(0,(0,CS.inject)(YA.DI_TOKENS.IVaultAdapter)),HA(1,(0,CS.inject)(YA.DI_TOKENS.IVaultSettings)),Z8("design:paramtypes",[Object,Object])],PS)});var LS=S(Ni=>{"use strict";var n$=Ni&&Ni.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},i$=Ni&&Ni.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},XA=Ni&&Ni.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ni,"__esModule",{value:!0});Ni.URIConstructionService=void 0;var FS=Oe(),KA=Ft(),s$=Cl(),DS=class{static{a(this,"URIConstructionService")}constructor(e,t=s$.NullLogger){this.fileSystem=e,this.logger=t,this.defaultOntologyURL="https://exocortex.my/default/",this.strictValidation=!0}configure(e){e?.defaultOntologyURL&&(this.defaultOntologyURL=e.defaultOntologyURL),e?.strictValidation!==void 0&&(this.strictValidation=e.strictValidation)}async constructAssetURI(e){let t=this.extractUID(e);if(!t){if(this.strictValidation)throw new Error(`Asset missing exo__Asset_uid: ${e.path}`);return this.logger.warn(`Asset ${e.path} missing UID, using filename fallback`),this.constructFallbackURI(e)}let r=await this.resolveOntologyURL(e);if(!this.validateOntologyURL(r))throw new Error(`Invalid ontology URL: ${r}`);return`${r.endsWith("/")?r:`${r}/`}${t}`}validateOntologyURL(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}async resolveOntologyURL(e){let t=e.frontmatter?.exo__Asset_isDefinedBy;if(!t||typeof t!="string")return this.defaultOntologyURL;let r=this.extractWikiLink(t),i=r,s=await this.fileSystem.fileExists(r);return!s&&!r.endsWith(".md")&&(i=`${r}.md`,s=await this.fileSystem.fileExists(i)),s?(await this.fileSystem.getFileMetadata(i))?.exo__Ontology_url||this.defaultOntologyURL:(this.logger.warn(`Ontology file not found: ${r}, using default`),this.defaultOntologyURL)}extractUID(e){let t=e.frontmatter?.exo__Asset_uid;return typeof t=="string"?t:null}extractWikiLink(e){return e.replace(/^\[\[|\]\]$/g,"")}constructFallbackURI(e){let t=e.path.split("/").pop()?.replace(".md","")||"unknown";return`${this.defaultOntologyURL}${t}`}};Ni.URIConstructionService=DS;Ni.URIConstructionService=DS=n$([(0,FS.injectable)(),XA(0,(0,FS.inject)(KA.DI_TOKENS.IFileSystemAdapter)),XA(1,(0,FS.inject)(KA.DI_TOKENS.ILogger)),i$("design:paramtypes",[Object,Object])],DS)});var kS=S(ki=>{"use strict";var o$=ki&&ki.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},a$=ki&&ki.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},l$=ki&&ki.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ki,"__esModule",{value:!0});ki.GenericAssetCreationService=void 0;var JA=Oe(),hf=Fn(),c$=Js(),u$=Us(),f$=Ft(),fs=yh(),d$=nf(),h$=Bp(),NS=class{static{a(this,"GenericAssetCreationService")}constructor(e){this.vault=e,this.clock=(0,d$.liveClock)(),this.uidGen=(0,h$.liveUidGenerator)()}withDeterminism(e){return e.clock&&(this.clock=e.clock),e.uidGenerator&&(this.uidGen=e.uidGenerator),this}async createAsset(e,t){let r=this.uidGen.next(),i=`${r}.md`,s=this.generateFrontmatter(e,t||[],r),o=c$.MetadataHelpers.buildFileContent(s),l=e.folderPath||this.getDefaultFolderPath(e);this.vault.getAbstractFileByPath(l)||await this.vault.createFolder(l);let u=l?`${l}/${i}`:i;return await this.vault.create(u,o)}generateFrontmatter(e,t,r){let i=this.clock.now(),s={},o=new Map;for(let l of t)o.set(l.name,l.fieldType);if(s.exo__Asset_uid=r,s.exo__Asset_createdAt=hf.DateFormatter.toLocalTimestamp(i),s.exo__Instance_class=[this.formatWikilink(e.className)],e.label&&e.label.trim()!==""){let l=e.label.trim();s.exo__Asset_label=l,s.aliases=[l]}if(e.parentFile&&e.parentMetadata&&this.inheritParentContext(s,e),e.propertyValues)for(let[l,c]of Object.entries(e.propertyValues)){if(l==="exo__Asset_uid"||l==="exo__Asset_createdAt"||l==="exo__Instance_class"||l==="exo__Asset_label"||l==="aliases"||c==null)continue;let u=o.get(l);s[l]=this.formatValue(c,u)}return s}inheritParentContext(e,t){let r=t.parentMetadata||{},i=t.parentFile?.basename;if(t.className==="ems__Task"||t.className.startsWith("ems__Task")){let s=r.exo__Instance_class,l=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[l]=i?this.formatWikilink(i):null}if(t.className==="ems__Project"||t.className.startsWith("ems__Project")){let s=r.exo__Instance_class,l=this.isAreaClass(s,t.classResolver)?"ems__Effort_area":"ems__Effort_parent";e[l]=i?this.formatWikilink(i):null}if(r.exo__Asset_isDefinedBy){let s=r.exo__Asset_isDefinedBy;e.exo__Asset_isDefinedBy=typeof s=="string"?this.formatWikilink(s):s}}isAreaClass(e,t){if(!e)return!1;let r=Array.isArray(e)?e:[e],i=a(()=>null,"noopResolver");return r.some(s=>{let o=u$.WikiLinkHelpers.resolveSymbolic(String(s),t??i);return o.includes("Area")||o.includes("ems__Area")})}getDefaultFolderPath(e){if(e.parentFile?.parent?.path)return e.parentFile.parent.path;let t={ems__Task:"tasks",ems__Project:"projects",ems__Area:"areas",ems__Meeting:"meetings",exo__Event:"events",ims__Concept:"concepts"};if(t[e.className])return t[e.className];for(let[r,i]of Object.entries(t))if(e.className.startsWith(r))return i;return"assets"}formatValue(e,t){if(e==null)return null;if(!t)return this.formatInferredValue(e);switch(t){case fs.PropertyFieldType.Text:return String(e);case fs.PropertyFieldType.Wikilink:case fs.PropertyFieldType.Reference:case fs.PropertyFieldType.StatusSelect:case fs.PropertyFieldType.SizeSelect:return this.formatWikilink(String(e));case fs.PropertyFieldType.Number:return typeof e=="number"?e:Number(e)||0;case fs.PropertyFieldType.Boolean:return this.formatBoolean(e);case fs.PropertyFieldType.Date:case fs.PropertyFieldType.DateTime:case fs.PropertyFieldType.Timestamp:return this.formatTimestamp(e);default:return String(e)}}formatInferredValue(e){return typeof e=="boolean"||typeof e=="number"?e:e instanceof Date?hf.DateFormatter.toLocalTimestamp(e):typeof e=="string"?e.startsWith("[[")||e.startsWith('"[[')?this.formatWikilink(e):e:String(e)}formatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:`"[[${e}]]"`}formatBoolean(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase().trim();return t==="true"||t==="yes"||t==="1"}return typeof e=="number"?e!==0:!!e}formatTimestamp(e){if(e instanceof Date)return hf.DateFormatter.toLocalTimestamp(e);if(typeof e=="string"){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e))return e;if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e.replace("Z","");let t=new Date(e);return isNaN(t.getTime())?e:hf.DateFormatter.toLocalTimestamp(t)}if(typeof e=="number"){let t=new Date(e);if(!isNaN(t.getTime()))return hf.DateFormatter.toLocalTimestamp(t)}return String(e)}};ki.GenericAssetCreationService=NS;ki.GenericAssetCreationService=NS=o$([(0,JA.injectable)(),l$(0,(0,JA.inject)(f$.DI_TOKENS.IVaultAdapter)),a$("design:paramtypes",[Object])],NS)});var e3=S(Mi=>{"use strict";var p$=Mi&&Mi.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},m$=Mi&&Mi.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},g$=Mi&&Mi.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Mi,"__esModule",{value:!0});Mi.ArchiveAssetService=void 0;var ZA=Oe(),y$=Ft(),_$=cs(),MS=class{static{a(this,"ArchiveAssetService")}constructor(e){this.vault=e,this.frontmatterService=new _$.FrontmatterService}async archiveAsset(e){let t=await this.vault.read(e),r=this.frontmatterService.updateProperty(t,"archived","true");r=this.frontmatterService.removeProperty(r,"aliases"),r!==t&&await this.vault.modify(e,r)}};Mi.ArchiveAssetService=MS;Mi.ArchiveAssetService=MS=p$([(0,ZA.injectable)(),g$(0,(0,ZA.inject)(y$.DI_TOKENS.IVaultAdapter)),m$("design:paramtypes",[Object])],MS)});var r3=S(ji=>{"use strict";var b$=ji&&ji.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},S$=ji&&ji.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},w$=ji&&ji.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(ji,"__esModule",{value:!0});ji.FixMissingLabelService=void 0;var t3=Oe(),v$=Ft(),E$=cs(),jS=class{static{a(this,"FixMissingLabelService")}constructor(e){this.vault=e,this.frontmatterService=new E$.FrontmatterService}async fixMissingLabel(e){let t=await this.vault.read(e);if(this.hasNonEmptyLabel(t))return;let r=this.frontmatterService.updateProperty(t,"exo__Asset_label",e.basename);r!==t&&await this.vault.modify(e,r)}hasNonEmptyLabel(e){let t=this.frontmatterService.parse(e);if(!t.exists)return!1;let r=t.content.match(/^exo__Asset_label:\s*(.*)$/m);if(!r)return!1;let i=r[1].trim();return!(i===""||i==='""'||i==="''")}};ji.FixMissingLabelService=jS;ji.FixMissingLabelService=jS=b$([(0,t3.injectable)(),w$(0,(0,t3.inject)(v$.DI_TOKENS.IVaultAdapter)),S$("design:paramtypes",[Object])],jS)});var n3=S(lo=>{"use strict";var T$=lo&&lo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},I$=lo&&lo.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(lo,"__esModule",{value:!0});lo.GraphQueryService=void 0;var x$=Oe(),pf=Ae(),A$=$e(),Go=er(),R$=R0(),ds={INSTANCE_CLASS:Go.Namespace.EXO.term("Instance_class"),ASSET_LABEL:Go.Namespace.EXO.term("Asset_label"),ASSET_PROTOTYPE:Go.Namespace.EXO.term("Asset_prototype"),ASSET_IS_ARCHIVED:Go.Namespace.EXO.term("Asset_isArchived"),EFFORT_PARENT:Go.Namespace.EMS.term("Effort_parent"),REFERENCES:Go.Namespace.EXO.term("references"),REFERENCED_BY:Go.Namespace.EXO.term("referencedBy"),RDF_TYPE:Go.Namespace.RDF.term("type")},$S=class{static{a(this,"GraphQueryService")}constructor(e,t={},r){this.subscribers=new Set,this.nodeCache=new Map,this.lastCacheUpdate=0,this.tripleStore=e,this.logger=r,this.config={defaultLimit:t.defaultLimit??100,maxLimit:t.maxLimit??1e4,defaultDepth:t.defaultDepth??2,maxDepth:t.maxDepth??10,includeArchivedByDefault:t.includeArchivedByDefault??!1,cacheTTL:t.cacheTTL??3e4}}async loadGraphData(e={}){let t=Date.now(),r=await this.loadNodes(e),i=await this.loadEdges(r,e),s=this.computeStats(r,i),o=Date.now()-t;return o>100&&r.length>0&&this.logger?.debug(`GraphQueryService: loaded ${r.length} nodes in ${o}ms (${(o/r.length).toFixed(2)}ms/node)`),{nodes:r,edges:i,stats:s,lastUpdated:Date.now(),version:1}}async loadNodesIncremental(e={}){let t=Math.min(e.limit??this.config.defaultLimit,this.config.maxLimit),r=e.offset??0,i=await this.loadNodes({...e,limit:t+1,offset:r}),s=i.length>t,o=s?i.slice(0,t):i,l=await this.loadEdges(o,e);return{nodes:o,edges:l,hasMore:s,totalCount:void 0,cursor:s?String(r+t):void 0}}async loadConnectedNodes(e,t={}){let r=Math.min(t.depth??this.config.defaultDepth,this.config.maxDepth),i=Math.min(t.limit??this.config.maxLimit,this.config.maxLimit),s=new Set,o=[{id:e,currentDepth:0}],l=[];for(;o.length>0&&l.length<i;){let u=o.shift();if(!u)break;let{id:f,currentDepth:d}=u;if(s.has(f))continue;s.add(f);let h=await this.getNodeById(f,t);if(h&&(l.push(h),d<r)){let p=await this.getConnectedNodeIds(f);for(let g of p)s.has(g)||o.push({id:g,currentDepth:d+1})}}let c=await this.loadEdges(l,t);return{nodes:l,edges:c,hasMore:o.length>0,totalCount:s.size+o.length}}async getNodeById(e,t={}){let r=this.getCachedNode(e);if(r)return{...r};let i=this.idToIRI(e),s=await this.tripleStore.match(i,void 0,void 0);if(s.length===0)return null;let o=this.triplesToNode(e,s,t);return o&&this.cacheNode(o),o}subscribe(e){return this.subscribers.add(e),{unsubscribe:a(()=>{this.subscribers.delete(e)},"unsubscribe")}}notifyChange(e){for(let t of this.subscribers)try{t(e)}catch(r){this.logger?.error("GraphQueryService: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}this.invalidateCache()}async getStats(){let e=await this.loadNodes({includeArchived:!0}),t=await this.loadEdges(e,{});return this.computeStats(e,t)}clearCache(){this.nodeCache.clear(),this.lastCacheUpdate=0}async loadNodes(e){let t=e.includeArchived??this.config.includeArchivedByDefault,r=e.limit??this.config.maxLimit,i=e.offset??0,s=await this.tripleStore.match(void 0,ds.INSTANCE_CLASS,void 0),o=s;if(e.classes&&e.classes.length>0){let p=new Set(e.classes);o=s.filter(g=>{let _=this.getObjectValue(g.object);return _&&p.has(_)})}let l=new Set;for(let p of o)l.add(this.subjectToId(p.subject));let f=Array.from(l).slice(i,i+r).map(p=>this.getNodeById(p,e));return(await Promise.all(f)).filter(p=>!(!p||!t&&p.isArchived))}async loadEdges(e,t){let r=new Set(e.map(o=>o.id)),i=[],s=new Set;for(let o of e){let l=this.idToIRI(o.id),c=await this.tripleStore.match(l,void 0,void 0);for(let u of c){let f=this.tripleToEdge(o.id,u,r);f&&f.id&&!s.has(f.id)&&(!t.edgeTypes||t.edgeTypes.includes(f.type))&&(s.add(f.id),i.push(f))}}return i}async getConnectedNodeIds(e){let t=this.idToIRI(e),r=[],i=await this.tripleStore.match(t,void 0,void 0);for(let o of i){let l=this.objectToId(o.object);l&&r.push(l)}let s=await this.tripleStore.match(void 0,void 0,t);for(let o of s)r.push(this.subjectToId(o.subject));return[...new Set(r)]}triplesToNode(e,t,r){let i={},s,o,l,c,u=!1;for(let h of t){let p=h.predicate.value,g=this.getObjectValue(h.object);if(p===ds.INSTANCE_CLASS.value)s=g;else if(p===ds.ASSET_LABEL.value)o=g;else if(p===ds.ASSET_PROTOTYPE.value)l=this.objectToId(h.object)??g;else if(p===ds.EFFORT_PARENT.value)c=this.objectToId(h.object)??g;else if(p===ds.ASSET_IS_ARCHIVED.value)u=g==="true"||g==="1";else{let _=this.predicateToPropertyName(p);_&&(i[_]=g)}}if(u&&!(r.includeArchived??this.config.includeArchivedByDefault))return null;let f=this.idToPath(e),d=o??this.pathToTitle(f);return{id:e,path:f,title:d,label:d,assetClass:s,isArchived:u,uri:e.startsWith("http")?e:void 0,prototype:l,parent:c,properties:Object.keys(i).length>0?i:void 0}}tripleToEdge(e,t,r){let i=t.predicate.value,s=this.objectToId(t.object);if(!s||!r.has(s)||s===e)return null;let o=this.predicateToEdgeType(i);if(!o)return null;let l=(0,R$.createEdgeId)(e,s,o,i),c=this.predicateToLabel(i);return{id:l,source:e,target:s,type:o,predicate:i,label:c}}predicateToEdgeType(e){return e===ds.EFFORT_PARENT.value?"hierarchy":e===ds.ASSET_PROTOTYPE.value?"prototype":e===ds.REFERENCES.value?"forward-link":e===ds.REFERENCED_BY.value?"backlink":e.includes("Asset_")||e.includes("Instance_")?null:"semantic"}predicateToLabel(e){let t=e.lastIndexOf("#"),r=e.lastIndexOf("/"),i=Math.max(t,r);return i>=0?e.substring(i+1):e}predicateToPropertyName(e){return this.predicateToLabel(e).replace(/_/g,"__").replace(/#/g,"_")}computeStats(e,t){let r={},i={backlink:0,"forward-link":0,hierarchy:0,prototype:0,semantic:0,reference:0};for(let l of e){let c=l.assetClass??"unknown";r[c]=(r[c]??0)+1}for(let l of t)i[l.type]=(i[l.type]??0)+1;let s=new Map,o=new Map;for(let l of t)o.set(l.source,(o.get(l.source)??0)+1),s.set(l.target,(s.get(l.target)??0)+1);for(let l of e)l.inDegree=s.get(l.id)??0,l.outDegree=o.get(l.id)??0,l.weight=l.inDegree+l.outDegree;return{nodeCount:e.length,edgeCount:t.length,nodesByClass:r,edgesByType:i,computedAt:Date.now()}}idToIRI(e){return e.startsWith("http://")||e.startsWith("https://")?new pf.IRI(e):new pf.IRI(`obsidian://vault/${encodeURIComponent(e)}`)}subjectToId(e){if(e instanceof pf.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return e.toString()}objectToId(e){if(e instanceof pf.IRI){let t=e.value;return t.startsWith("obsidian://vault/")?decodeURIComponent(t.replace("obsidian://vault/","")):t}return null}getObjectValue(e){if(e instanceof A$.Literal||e instanceof pf.IRI)return e.value}idToPath(e){if(e.startsWith("obsidian://vault/"))return decodeURIComponent(e.replace("obsidian://vault/",""));if(e.startsWith("http://")||e.startsWith("https://")){let t=e.match(/\/([^/]+\.md)$/);if(t)return t[1]}return e}pathToTitle(e){return(e.split("/").pop()??e).replace(/\.md$/,"")}getCachedNode(e){return Date.now()-this.lastCacheUpdate>this.config.cacheTTL?(this.clearCache(),null):this.nodeCache.get(e)??null}cacheNode(e){this.nodeCache.set(e.id,e),this.lastCacheUpdate===0&&(this.lastCacheUpdate=Date.now())}invalidateCache(){this.clearCache()}};lo.GraphQueryService=$S;lo.GraphQueryService=$S=T$([(0,x$.injectable)(),I$("design:paramtypes",[Object,Object,Object])],$S)});var s3=S(co=>{"use strict";var C$=co&&co.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},P$=co&&co.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(co,"__esModule",{value:!0});co.TypeRegistry=void 0;var O$=Oe(),hs=Ae(),i3=$t(),F$=$e(),D$=$o(),mt=C0(),US=class{static{a(this,"TypeRegistry")}constructor(e=null,t={}){this.nodeTypes=new Map,this.edgeTypes=new Map,this.typeHierarchy=new Map,this.subscribers=new Set,this.discoveryComplete=!1,this.tripleStore=e,this.config={autoDiscoverTypes:t.autoDiscoverTypes??!0,includeBuiltInStyles:t.includeBuiltInStyles??!0,styleResolution:t.styleResolution??{mergeStyles:!0,inheritParentStyles:!0,defaultNodeStyle:mt.DEFAULT_NODE_STYLE,defaultEdgeStyle:mt.DEFAULT_EDGE_STYLE},maxInheritanceDepth:t.maxInheritanceDepth??10},this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerNodeType(e){let r=this.nodeTypes.get(e.uri)?"type-updated":"type-added";this.nodeTypes.set(e.uri,e),e.parentTypes&&e.parentTypes.length>0&&this.typeHierarchy.set(e.uri,e.parentTypes),this.emit({type:r,typeUri:e.uri,definition:e})}registerEdgeType(e){let r=this.edgeTypes.get(e.uri)?"type-updated":"type-added";this.edgeTypes.set(e.uri,e),this.emit({type:r,typeUri:e.uri,definition:e})}unregisterType(e){let t=this.nodeTypes.delete(e),r=this.edgeTypes.delete(e);this.typeHierarchy.delete(e),(t||r)&&this.emit({type:"type-removed",typeUri:e})}getNodeType(e){return this.nodeTypes.get(e)}getEdgeType(e){return this.edgeTypes.get(e)}getAllNodeTypes(){return Array.from(this.nodeTypes.values())}getAllEdgeTypes(){return Array.from(this.edgeTypes.values())}getParentTypes(e,t=this.config.maxInheritanceDepth){let r=[],i=new Set,s=[{uri:e,currentDepth:0}];for(;s.length>0;){let o=s.shift();if(!o)break;let{uri:l,currentDepth:c}=o;if(i.has(l)||(i.add(l),c>=t))continue;let u=this.typeHierarchy.get(l)??[];for(let f of u)i.has(f)||(r.push(f),s.push({uri:f,currentDepth:c+1}))}return r}getChildTypes(e){let t=[];for(let[r,i]of this.typeHierarchy)i.includes(e)&&t.push(r);return t}isSubtypeOf(e,t){return e===t?!0:this.getParentTypes(e).includes(t)}resolveNodeType(e){let t=[],r="unknown",i="custom";if(e.assetClass){let l=this.normalizeTypeUri(e.assetClass);t.push(l),r=l,i="exo:Instance_class"}let s=e.properties?.[mt.RDF_TYPE_PREDICATES.RDF_TYPE];s&&!t.includes(s)&&(t.push(s),r==="unknown"&&(r=s,i="rdf:type"));for(let l of[...t]){let c=this.getParentTypes(l);for(let u of c)t.includes(u)||t.push(u)}let o=this.resolveNodeStyle(t);return{primaryType:r,types:t,resolvedStyle:o,source:i}}resolveEdgeType(e){let t=e.predicate??e.type,r=e.predicate?"rdf:type":"custom",i=this.resolveEdgeStyle(t);return{primaryType:t,resolvedStyle:i,source:r}}resolveNodeStyle(e){let{mergeStyles:t,defaultNodeStyle:r}=this.config.styleResolution,i={...r},s=[];for(let o of e){let l=this.nodeTypes.get(o);l&&s.push(l)}if(s.sort((o,l)=>o.priority-l.priority),t)for(let o of s)i=(0,mt.mergeNodeStyles)(i,o.style);else if(s.length>0){let o=s[s.length-1];i=(0,mt.mergeNodeStyles)(i,o.style)}return i}resolveEdgeStyle(e){let{defaultEdgeStyle:t}=this.config.styleResolution,r={...t},i=this.edgeTypes.get(e);return i&&(r=(0,mt.mergeEdgeStyles)(r,i.style)),r}filterNodes(e,t){return e.filter(r=>{let i=this.resolveNodeType(r);return!(t.includeNodeTypes&&t.includeNodeTypes.length>0&&!t.includeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||t.excludeNodeTypes&&t.excludeNodeTypes.length>0&&t.excludeNodeTypes.some(o=>i.types.includes(o)||t.includeInferred&&this.isSubtypeOf(i.primaryType,o))||!t.includeDeprecated&&this.nodeTypes.get(i.primaryType)?.deprecated)})}filterEdges(e,t){return e.filter(r=>{let i=r.predicate??r.type;return!(t.includeEdgeTypes&&t.includeEdgeTypes.length>0&&!t.includeEdgeTypes.includes(i)||t.excludeEdgeTypes&&t.excludeEdgeTypes.length>0&&t.excludeEdgeTypes.includes(i))})}groupNodesByType(e,t,r={}){let{groupByNodeType:i=!0,groupByParentType:s=!1,groupLevel:o=0,maxGroups:l=20,customGroupFn:c}=r,u=new Map;for(let h of e){let p=this.resolveNodeType(h),g;if(c?g=c(p.types):s&&p.types.length>o?g=p.types[o]??p.primaryType:i?g=p.primaryType:g="all",!u.has(g)){let w=this.nodeTypes.get(g)?.label??(0,mt.extractLocalName)(g);u.set(g,{nodeIds:new Set,label:w})}let _=u.get(g);_&&_.nodeIds.add(h.id)}let f=Array.from(u.entries()).map(([h,p])=>({id:h,label:p.label,nodeIds:Array.from(p.nodeIds)}));if(f.length>l){f.sort((g,_)=>_.nodeIds.length-g.nodeIds.length);let h=f.slice(0,l-1),p=f.slice(l-1).flatMap(g=>g.nodeIds);h.push({id:"other",label:"Other",nodeIds:p}),f=h}let d=new Map;for(let h of f)for(let p of h.nodeIds)d.set(p,h.id);return f.map((h,p)=>{let g=new Set(h.nodeIds),_=[],v=[];for(let I of t){let O=g.has(I.source),C=g.has(I.target);O&&C?I.id&&_.push(I.id):(O||C)&&I.id&&v.push(I.id)}let E=`hsl(${p*137.5%360}, 70%, 50%)`;return{id:h.id,label:h.label,nodeIds:h.nodeIds,internalEdgeIds:_,externalEdgeIds:v,color:E,stats:{nodeCount:h.nodeIds.length,internalEdgeCount:_.length,externalEdgeCount:v.length}}})}validateTypes(e,t){let r=[],i=[];for(let s of e){let o=this.resolveNodeType(s);if(o.primaryType!=="unknown"){let l=this.nodeTypes.get(o.primaryType);!l&&o.source!=="inferred"&&i.push({code:"UNREGISTERED_NODE_TYPE",message:`Node type "${o.primaryType}" is not registered`,elementId:s.id,suggestion:"Register the type with registerNodeType()"}),l?.deprecated&&i.push({code:"DEPRECATED_NODE_TYPE",message:`Node uses deprecated type "${o.primaryType}"`,elementId:s.id,suggestion:"Migrate to a non-deprecated type"})}else i.push({code:"MISSING_NODE_TYPE",message:"Node has no type information",elementId:s.id,suggestion:"Add exo:Instance_class or rdf:type to the node"})}for(let s of t){let o=s.predicate??s.type,l=this.edgeTypes.get(o);if(l?.domain&&l.domain.length>0){let c=e.find(u=>u.id===s.source);if(c){let u=this.resolveNodeType(c);l.domain.some(d=>u.types.includes(d))||r.push({code:"DOMAIN_VIOLATION",message:"Edge source does not match expected domain",elementId:s.id,expected:l.domain,actual:u.types})}}if(l?.range&&l.range.length>0){let c=e.find(u=>u.id===s.target);if(c){let u=this.resolveNodeType(c);l.range.some(d=>u.types.includes(d))||r.push({code:"RANGE_VIOLATION",message:"Edge target does not match expected range",elementId:s.id,expected:l.range,actual:u.types})}}}return{valid:r.length===0,errors:r,warnings:i}}async discoverTypes(){if(!this.tripleStore||this.discoveryComplete)return;let e=await this.tripleStore.match(void 0,new hs.IRI(mt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let r of e){let i=this.getObjectValue(r.object);if(i&&(0,mt.isClassType)(i)){let s=this.getSubjectValue(r.subject);s&&await this.discoverNodeType(s)}}let t=await this.tripleStore.match(void 0,new hs.IRI(mt.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF),void 0);for(let r of t){let i=this.getSubjectValue(r.subject),s=this.getObjectValue(r.object);if(i&&s){let o=this.typeHierarchy.get(i)??[];if(!o.includes(s)){o.push(s),this.typeHierarchy.set(i,o);let l=this.nodeTypes.get(i);l&&(l.parentTypes=o)}}}this.discoveryComplete=!0,this.emit({type:"hierarchy-updated",rootTypes:this.getRootTypes()})}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}clear(){this.nodeTypes.clear(),this.edgeTypes.clear(),this.typeHierarchy.clear(),this.discoveryComplete=!1,this.config.includeBuiltInStyles&&this.registerBuiltInTypes()}registerBuiltInTypes(){for(let[e,t]of Object.entries(mt.BUILT_IN_NODE_STYLES))this.nodeTypes.set(e,{uri:e,label:(0,mt.extractLocalName)(e),source:"custom",style:(0,mt.mergeNodeStyles)(mt.DEFAULT_NODE_STYLE,t),priority:1});for(let[e,t]of Object.entries(mt.BUILT_IN_EDGE_STYLES))this.edgeTypes.set(e,{uri:e,label:(0,mt.extractLocalName)(e),source:"custom",style:(0,mt.mergeEdgeStyles)(mt.DEFAULT_EDGE_STYLE,t),priority:1})}async discoverNodeType(e){if(this.nodeTypes.has(e)||!this.tripleStore)return;let t=await this.tripleStore.match(new hs.IRI(e),new hs.IRI(mt.RDF_TYPE_PREDICATES.RDFS_LABEL),void 0),r=await this.tripleStore.match(new hs.IRI(e),new hs.IRI(mt.RDF_TYPE_PREDICATES.RDFS_COMMENT),void 0),i=t.length>0?this.getObjectValue(t[0].object)??(0,mt.extractLocalName)(e):(0,mt.extractLocalName)(e),s=r.length>0?this.getObjectValue(r[0].object):void 0,o="rdfs:Class",l=await this.tripleStore.match(new hs.IRI(e),new hs.IRI(mt.RDF_TYPE_PREDICATES.RDF_TYPE),void 0);for(let f of l)if(this.getObjectValue(f.object)===mt.RDF_TYPE_PREDICATES.OWL_CLASS){o="owl:Class";break}let c=mt.BUILT_IN_NODE_STYLES[e]??mt.BUILT_IN_NODE_STYLES[(0,mt.extractLocalName)(e)],u={uri:e,label:i,description:s,source:o,style:(0,mt.mergeNodeStyles)(mt.DEFAULT_NODE_STYLE,c??{}),priority:1};this.registerNodeType(u)}normalizeTypeUri(e){let t=e.match(/^\[\[(.+?)\]\]$/);return t?t[1]:e}getSubjectValue(e){if(e instanceof hs.IRI)return e.value;if(e instanceof i3.BlankNode)return`_:${e.id}`;if(typeof e=="object"&&e!==null&&"termType"in e)return e.toString()}getObjectValue(e){if(e instanceof F$.Literal||e instanceof hs.IRI)return e.value;if(e instanceof i3.BlankNode)return`_:${e.id}`}getRootTypes(){let e=new Set;for(let r of this.typeHierarchy.values())for(let i of r)e.add(i);let t=[];for(let r of this.nodeTypes.keys()){let i=this.typeHierarchy.get(r);(!i||i.length===0)&&e.has(r)&&t.push(r)}return t}emit(e){for(let t of this.subscribers)try{t(e)}catch(r){D$.LoggingService.error("TypeRegistry: error in subscriber callback",r instanceof Error?r:new Error(String(r)))}}};co.TypeRegistry=US;co.TypeRegistry=US=C$([(0,O$.injectable)(),P$("design:paramtypes",[Object,Object])],US)});var VS=S($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.SPARQL_TEMPLATES=$.KNOWN_CLASSES=$.KNOWN_PROTOTYPES=$.EFFORT_STATUSES=$.ASSET_CLASSES=$.PREDICATES=$.SPARQL_PREFIXES=void 0;$.findClassByTerm=L$;$.getTemplateByName=N$;$.findMatchingTemplates=k$;$.fillTemplate=M$;$.validateParameters=j$;$.SPARQL_PREFIXES=`PREFIX exo: <https://exocortex.my/ontology/exo#>
213
213
  PREFIX ems: <https://exocortex.my/ontology/ems#>
214
214
  PREFIX ims: <https://exocortex.my/ontology/ims#>
215
215
  PREFIX gtd: <https://exocortex.my/ontology/gtd#>
@@ -375,7 +375,7 @@ LIMIT ${this.config.defaultLimit}`,s="\u041D\u0435 \u0443\u0434\u0430\u043B\u043
375
375
  `,i=this.composePrefixes(t),s=this.serializePrefixes(i,r),o=this.nTriplesSerializer.serialize(e,{newline:r}).trimEnd();return s?o?`${s}${r}${r}${o}${r}`:`${s}${r}`:o?`${o}${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?{...Y$,...e.prefixes??{}}:{...e.prefixes??{}}}serializeTriplesOnly(e,t){return this.nTriplesSerializer.serializeChunk(e,t).trimEnd()}};pm.TurtleSerializer=QS});var h3=S(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});mm.JSONLDSerializer=void 0;var f3=Ae(),d3=$t(),X$=$e(),yc=er(),K$={rdf:yc.Namespace.RDF.iri.value,rdfs:yc.Namespace.RDFS.iri.value,owl:yc.Namespace.OWL.iri.value,xsd:yc.Namespace.XSD.iri.value,exo:yc.Namespace.EXO.iri.value,ems:yc.Namespace.EMS.iri.value},YS=class{static{a(this,"JSONLDSerializer")}toDocument(e,t={}){let r={...K$,...t.context??{}},i=new Map;for(let s of e){let o=this.subjectToId(s.subject),l=this.compactIri(s.predicate.value,r),c=this.objectToJSONLD(s.object,r),u=i.get(o)??{"@id":o},f=u[l];f===void 0?u[l]=c:Array.isArray(f)?f.push(c):u[l]=[f,c],i.set(o,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 f3.IRI?e.value:e instanceof d3.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 f3.IRI)return{"@id":e.value};if(e instanceof d3.BlankNode)return{"@id":`_:${e.id}`};if(e instanceof X$.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}};mm.JSONLDSerializer=YS});var JS=S(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});gm.NTriplesParser=void 0;var J$=Bn(),p3=Ae(),XS=$e(),Z$=$t(),_c=er(),eU={rdf:_c.Namespace.RDF.iri.value,rdfs:_c.Namespace.RDFS.iri.value,owl:_c.Namespace.OWL.iri.value,xsd:_c.Namespace.XSD.iri.value,exo:_c.Namespace.EXO.iri.value,ems:_c.Namespace.EMS.iri.value},KS=class{static{a(this,"NTriplesParser")}parse(e,t={}){let r={prefixes:{...eU,...t.prefixes??{}},strict:t.strict??!1},i=[];return e.split(/\r?\n/).forEach((o,l)=>{let c=o.trim();!c||c.startsWith("#")||i.push(this.parseLine(c,l+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(),o=this.parseSubject(s,t,r);s=o.rest.trim();let l=this.parsePredicate(s,t,r);s=l.rest.trim();let c=this.parseObject(s,t,r);if(s=c.rest.trim(),s.length>0)throw new Error(`Unexpected tokens after object at line ${t}`);return new J$.Triple(o.node,l.node,c.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,o,l]=i,c=r.prefixes[s];if(!c)throw new Error(`Unknown prefix "${s}" at line ${t}`);return{node:new p3.IRI(`${c}${o}`),rest:(l??"").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),o=new p3.IRI(s),l=e.slice(i+1).trimStart();return{node:o,rest:l}}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 Z$.BlankNode(i),rest:(s??"").trimStart()}}consumeLiteral(e,t,r){let{value:i,rest:s}=this.consumeQuotedString(e,t),o=s.trimStart();if(o.startsWith("^^")){o=o.slice(2).trimStart();let l=o.startsWith("<")?this.consumeIRI(o,t,r):this.consumePrefixedName(o,t,r);return{node:new XS.Literal(i,l.node),rest:l.rest}}if(o.startsWith("@")){let l=o.match(/^@([a-zA-Z-]+)(?:\s+(.*))?$/);if(!l)throw new Error(`Invalid language tag at line ${t}`);let[,c,u]=l;return{node:new XS.Literal(i,void 0,c),rest:(u??"").trimStart()}}return{node:new XS.Literal(i),rest:o}}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 o=e[i+1];switch(o){case"t":r+=" ",i+=1;break;case"b":r+="\b",i+=1;break;case"n":r+=`
376
376
  `,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 l=e.slice(i+2,i+6);if(l.length!==4||!/^[0-9a-fA-F]{4}$/.test(l))throw new Error(`Invalid \\u escape at line ${t}`);r+=String.fromCharCode(parseInt(l,16)),i+=5;break}case"U":{let l=e.slice(i+2,i+10);if(l.length!==8||!/^[0-9a-fA-F]{8}$/.test(l))throw new Error(`Invalid \\U escape at line ${t}`);r+=String.fromCodePoint(parseInt(l,16)),i+=9;break}default:throw new Error(`Unknown escape sequence \\${o} at line ${t}`)}continue}if(s==='"'){let o=e.slice(i+1);return{value:r,rest:o}}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 o=e[s];if(o===t){i++;continue}if(o===r&&(i--,i===0))return s}return-1}};gm.NTriplesParser=KS});var m3=S(ym=>{"use strict";Object.defineProperty(ym,"__esModule",{value:!0});ym.TurtleParser=void 0;var bc=er(),tU=JS(),rU={rdf:bc.Namespace.RDF.iri.value,rdfs:bc.Namespace.RDFS.iri.value,owl:bc.Namespace.OWL.iri.value,xsd:bc.Namespace.XSD.iri.value,exo:bc.Namespace.EXO.iri.value,ems:bc.Namespace.EMS.iri.value},nU=/^@prefix\s+([a-zA-Z_][\w-]*):\s*<([^>]+)>\s*\.$/,ZS=class{static{a(this,"TurtleParser")}constructor(){this.nTriplesParser=new tU.NTriplesParser}parse(e,t={}){let r={...rU,...t.prefixes??{}},i=this.collectStatements(e),s=[];return i.forEach(({statement:o,lineNumber:l})=>{if(this.isPrefixStatement(o)){let u=o.match(nU);if(!u)throw new Error(`Invalid prefix declaration at line ${l}`);let[,f,d]=u;r[f]=d;return}if(o.includes(";")||o.includes(","))throw new Error(`Complex Turtle statements with ';' or ',' are not supported (line ${l})`);let c=this.normalizeShortcuts(o);s.push(this.nTriplesParser.parseLine(c,l,{prefixes:r,strict:!1}))}),s}collectStatements(e){let t=e.split(/\r?\n/),r=[],i="",s=0;if(t.forEach((o,l)=>{let c=o.trim();!c||c.startsWith("#")||(i||(s=l+1),i=i?`${i} ${c}`:c,c.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}};ym.TurtleParser=ZS});var g3=S(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});_m.RDFSerializer=void 0;var Sc=Bn(),za=Ae(),Ha=$e(),ew=$t(),ps=er(),iU=u3(),sU=HS(),oU=h3(),aU=m3(),lU=JS(),cU=1024,uU=`
377
377
  `,fU={rdf:ps.Namespace.RDF.iri.value,rdfs:ps.Namespace.RDFS.iri.value,owl:ps.Namespace.OWL.iri.value,xsd:ps.Namespace.XSD.iri.value,exo:ps.Namespace.EXO.iri.value,ems:ps.Namespace.EMS.iri.value},tw=class{static{a(this,"RDFSerializer")}constructor(e){this.store=e,this.turtleSerializer=new iU.TurtleSerializer,this.nTriplesSerializer=new sU.NTriplesSerializer,this.jsonldSerializer=new oU.JSONLDSerializer,this.turtleParser=new aU.TurtleParser,this.nTriplesParser=new lU.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??uU,i=t.batchSize??cU,s=t.includeDefaultPrefixes,o=t.prefixes,l=this,c=!1,u=[],f=[],d=0,h=a(async()=>{if(!c){if(f=await l.store.match(),e==="json-ld"){let g=l.jsonldSerializer.toDocument(f,{context:o,pretty:!1});u.push(...l.buildJsonLdChunks(g))}else if(e==="turtle"){let g=l.turtleSerializer.serializePrefixes(l.composePrefixes(o,s),r);g&&u.push(`${g}${r}${r}`)}c=!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 g=f.slice(d,d+i);d+=g.length;let _="";if(e==="turtle"){let v=l.turtleSerializer.serializeTriplesOnly(g,r);v&&(_=`${v}${r}`)}else e==="n-triples"&&(_=l.nTriplesSerializer.serializeChunk(g,r));return _?{value:_,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?{...fU,...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),o={...i,...s},l=this.extractGraph(r),c=[];return l.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,o,f),h=Object.entries(u);for(let[p,g]of h){if(p==="@id"||p==="@context")continue;if(p==="@type"){this.collectTypeTriples(d,g,c,o);continue}let _=this.expandTerm(p,o),v=new za.IRI(_);this.collectTriplesForValue(d,v,g,c,o)}}),c}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 ew.BlankNode(i.slice(2));if(this.isAbsoluteIri(i))return new za.IRI(i);let s=this.expandTerm(i,t);return new za.IRI(s)}return new ew.BlankNode(`jsonld_${r}`)}collectTypeTriples(e,t,r,i){let s=ps.Namespace.RDF.term("type");(Array.isArray(t)?t:[t]).forEach(l=>{if(typeof l!="string")throw new Error("Invalid @type value in JSON-LD node");let c=this.expandTerm(l,i);r.push(new Sc.Triple(e,s,new za.IRI(c)))})}collectTriplesForValue(e,t,r,i,s){if(r!=null){if(Array.isArray(r)){r.forEach(o=>this.collectTriplesForValue(e,t,o,i,s));return}if(typeof r=="object"){let o=r;if(typeof o["@id"]=="string"){let l=this.parseIdNode(o["@id"],s);i.push(new Sc.Triple(e,t,l));return}if(o["@value"]!==void 0){let l=this.parseLiteralObject(o,s);i.push(new Sc.Triple(e,t,l));return}}if(typeof r=="string"){i.push(new Sc.Triple(e,t,new Ha.Literal(r)));return}if(typeof r=="number"){let o=Number.isInteger(r)?ps.Namespace.XSD.term("integer"):ps.Namespace.XSD.term("decimal");i.push(new Sc.Triple(e,t,new Ha.Literal(r.toString(),o)));return}if(typeof r=="boolean"){let o=ps.Namespace.XSD.term("boolean");i.push(new Sc.Triple(e,t,new Ha.Literal(r.toString(),o)));return}throw new Error("Unsupported JSON-LD value encountered")}}parseIdNode(e,t){if(e.startsWith("_:"))return new ew.BlankNode(e.slice(2));if(this.isAbsoluteIri(e))return new za.IRI(e);let r=this.expandTerm(e,t);return new za.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 Ha.Literal(r,void 0,e["@language"],i):new Ha.Literal(r,void 0,e["@language"])}if(typeof e["@type"]=="string"){let i=this.expandTerm(e["@type"],t);return new Ha.Literal(r,new za.IRI(i))}return new Ha.Literal(r)}expandTerm(e,t){if(this.isAbsoluteIri(e))return e;let r=e.indexOf(":");if(r>0){let s=e.slice(0,r),o=e.slice(r+1),l=t[s];if(!l)throw new Error(`Unknown prefix "${s}" in JSON-LD document`);return`${l}${o}`}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 o=JSON.stringify(i);s>0?t.push(`,${o}`):t.push(o)}),t.push(`]}
378
- `),t}};_m.RDFSerializer=tw});var rw=S(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.OBSIDIAN_VAULT_SCHEME=void 0;uo.vaultPathToIRI=dU;uo.iriToVaultPath=hU;uo.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function dU(n){let e=n.startsWith("./")?n.slice(2):n;return`${uo.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(dU,"vaultPathToIRI");function hU(n){if(!n.startsWith(uo.OBSIDIAN_VAULT_SCHEME))return null;let e=n.slice(uo.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(hU,"iriToVaultPath")});var iw=S(bm=>{"use strict";Object.defineProperty(bm,"__esModule",{value:!0});bm.RDFVocabularyMapper=void 0;var nr=Bn(),y3=Ae(),ee=er(),nw=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",ee.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",ee.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",ee.Namespace.RDFS.term("subClassOf")],["exo__Property_range",ee.Namespace.RDFS.term("range")],["exo__Property_domain",ee.Namespace.RDFS.term("domain")],["exo__Property_superProperty",ee.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new nr.Triple(ee.Namespace.EXO.term("Asset"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.RDFS.term("Resource"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Class"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.RDFS.term("Class"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.RDF.term("Property"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Task"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Project"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Area"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Workflow"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("WorkflowState"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("WorkflowTransition"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("Command"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("Precondition"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("Grounding"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("CommandBinding"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new nr.Triple(ee.Namespace.EXO.term("Instance_class"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDF.term("type"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Asset_isDefinedBy"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("isDefinedBy"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Class_superClass"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("subClassOf"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property_range"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("range"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property_domain"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("domain"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property_superProperty"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof y3.IRI)s=r;else{let o=r.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,l,c]=o;s=(l==="ems"?ee.Namespace.EMS:l==="exocmd"?ee.Namespace.EXOCMD:ee.Namespace.EXO).term(c)}else s=new y3.IRI(r)}return new nr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};bm.RDFVocabularyMapper=nw});var _3=S(wm=>{"use strict";Object.defineProperty(wm,"__esModule",{value:!0});wm.RDFSInferenceEngine=void 0;var pU=Bn(),Sm=Ae(),sw=class{static{a(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 o=this.computeAllAncestors(s),l=await e.count(),c=await e.match(void 0,i),u=[];for(let d of c)if(d.object instanceof Sm.IRI){let h=o.get(d.object.value);if(h)for(let p of h)u.push(new pU.Triple(d.subject,i,new Sm.IRI(p)))}return u.length>0&&await e.addAll(u),await e.count()-l}async buildDirectParentMap(e,t){let r=await e.match(void 0,t),i=new Map;for(let s of r)if(s.subject instanceof Sm.IRI&&s.object instanceof Sm.IRI){let o=s.subject.value,l=s.object.value;i.has(o)||i.set(o,new Set),i.get(o).add(l)}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=[],o=t.get(e);if(o)for(let l of o)s.push(l);for(;s.length>0;){let l=s.shift();if(i.has(l))continue;i.add(l),r.add(l);let c=t.get(l);if(c)for(let u of c)i.has(u)||s.push(u)}return r}};wm.RDFSInferenceEngine=sw});var lw=S(Qa=>{"use strict";var mU=Qa&&Qa.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Qa,"__esModule",{value:!0});Qa.NonInheritablePropertyRegistry=void 0;var gU=Oe(),b3=Ae(),S3=$e(),ow=er(),aw=class{static{a(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(l=>l.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 o=t.find(l=>l.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let l of s){let c=await e.match(l.subject,o,void 0);for(let u of c)if(u.object instanceof S3.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(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new S3.Literal("exo__NonInheritableProperty"));if(i.length>0&&i[0].subject instanceof b3.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let l of o)if(l.object instanceof b3.IRI&&l.object.value.includes("NonInheritableProperty"))return l.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?ow.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?ow.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?ow.Namespace.EXOCMD.term(e.substring(8)).value:null}};Qa.NonInheritablePropertyRegistry=aw;Qa.NonInheritablePropertyRegistry=aw=mU([(0,gU.injectable)()],aw)});var fw=S(Ya=>{"use strict";var yU=Ya&&Ya.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Ya,"__esModule",{value:!0});Ya.PropertyCardinalityRegistry=void 0;var _U=Oe(),w3=Ae(),v3=$e(),cw=er(),uw=class{static{a(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(l=>l.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 o=t.find(l=>l.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let l of s){let c=await e.match(l.subject,o,void 0);for(let u of c)if(u.object instanceof v3.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(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new v3.Literal("exo__PropertyCardinalityMultiple"));if(i.length>0&&i[0].subject instanceof w3.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let l of o)if(l.object instanceof w3.IRI&&l.object.value.includes("PropertyCardinalityMultiple"))return l.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?cw.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?cw.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?cw.Namespace.EXOCMD.term(e.substring(8)).value:null}};Ya.PropertyCardinalityRegistry=uw;Ya.PropertyCardinalityRegistry=uw=yU([(0,_U.injectable)()],uw)});var pw=S(wr=>{"use strict";var bU=wr&&wr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},SU=wr&&wr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(wr,"__esModule",{value:!0});wr.PrototypeChainMaterializer=wr.MAX_PROTOTYPE_DEPTH=wr.INFERRED_GRAPH=void 0;wr.inferredGraphForDepth=dw;var wU=Oe(),E3=Bn(),qo=Ae(),vU=lw(),EU=fw();wr.INFERRED_GRAPH=new qo.IRI("https://exocortex.my/ontology/exo#inferred");var TU="https://exocortex.my/ontology/exo#inferred/";function dw(n){return new qo.IRI(`${TU}${n}`)}a(dw,"inferredGraphForDepth");wr.MAX_PROTOTYPE_DEPTH=10;var hw=class{static{a(this,"PrototypeChainMaterializer")}constructor(e,t){this.registry=e,this.cardinalityRegistry=t??null}async materialize(e){let r=(await e.predicates()).find(l=>l.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 l of i)if(l.subject instanceof qo.IRI&&l.object instanceof qo.IRI){let c=l.subject.value,u=l.object.value;c!==u&&s.set(c,l.object)}if(s.size===0)return 0;let o=0;for(let[l]of s){let c=new qo.IRI(l),u=this.resolveChain(l,s);if(u.length===0)continue;let f=await e.match(c,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 g=p.object instanceof qo.IRI?p.object.value:String(p.object),_=h.get(p.predicate.value);_||(_=new Set,h.set(p.predicate.value,_)),_.add(g)}for(let p=0;p<u.length;p++){let g=u[p],_=p+1,v=new qo.IRI(g),w=await e.match(v,void 0,void 0),E=new Set;if(e.matchInGraph){let I=await e.matchInGraph(v,void 0,void 0,wr.INFERRED_GRAPH);for(let A of I)E.add(A.predicate.value)}for(let I of w){let A=I.predicate.value;if(this.registry.isNonInheritable(A)||E.has(A))continue;if(d.has(A)&&this.isMultiValued(A)){let K=I.object instanceof qo.IRI?I.object.value:String(I.object);if(h.get(A)?.has(K))continue;let me=h.get(A);me||(me=new Set,h.set(A,me)),me.add(K);let N=new E3.Triple(c,I.predicate,I.object);await e.add(N),e.addToGraph&&(await e.addToGraph(N,wr.INFERRED_GRAPH),await e.addToGraph(N,dw(_))),o++;continue}if(d.has(A))continue;let D=new E3.Triple(c,I.predicate,I.object);await e.add(D),e.addToGraph&&(await e.addToGraph(D,wr.INFERRED_GRAPH),await e.addToGraph(D,dw(_))),d.add(A),o++}}}return o}isMultiValued(e){return this.cardinalityRegistry?this.cardinalityRegistry.isMultiValued(e):!1}resolveChain(e,t){let r=[],i=new Set;i.add(e);let s=[],o=t.get(e);for(o&&s.push(o.value);s.length>0&&r.length<wr.MAX_PROTOTYPE_DEPTH;){let l=s.shift();if(l===void 0)break;if(i.has(l))continue;i.add(l),r.push(l);let c=t.get(l);c&&!i.has(c.value)&&s.push(c.value)}return r}};wr.PrototypeChainMaterializer=hw;wr.PrototypeChainMaterializer=hw=bU([(0,wU.injectable)(),SU("design:paramtypes",[vU.NonInheritablePropertyRegistry,EU.PropertyCardinalityRegistry])],hw)});var I3=S(Em=>{"use strict";Object.defineProperty(Em,"__esModule",{value:!0});Em.IRICanonicalizer=void 0;var T3=Ae(),IU=$e(),xU=$t(),AU=Bn(),mw=/^obsidian:\/\/vault\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i,vm=class n{static{a(this,"IRICanonicalizer")}static extractSynthAUid(e){let t=mw.exec(e);return t?t[1].toLowerCase():null}static canonicalize(e,t){if(t.size===0)return{triples:e,remapCount:0,uniqueRemapCount:0};let r=new Map,i=new Set,s=0;return{triples:e.map(l=>{let c=n.remapIfSynthA(l.subject,t,r,i),u=n.remapIfSynthA(l.object,t,r,i);return c===l.subject&&u===l.object?l:(s++,new AU.Triple(c,l.predicate,u))}),remapCount:s,uniqueRemapCount:i.size}}static remapIfSynthA(e,t,r,i){if(e instanceof IU.Literal||e instanceof xU.BlankNode||!(e instanceof T3.IRI))return e;let s=mw.exec(e.value);if(!s)return e;let o=s[1].toLowerCase(),l=t.get(o);if(!l||l===e.value)return e;i.add(o);let c=r.get(l);return c||(c=new T3.IRI(l),r.set(l,c)),c}};Em.IRICanonicalizer=vm;vm.SYNTH_A_IRI_PATTERN=mw});var x3=S(Wn=>{"use strict";var RU=Wn&&Wn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},CU=Wn&&Wn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Wn,"__esModule",{value:!0});Wn.LazyAssetGraphLoader=Wn.MAX_LAZY_DEPTH=void 0;var PU=Oe(),OU=Ae(),gw=er();Wn.MAX_LAZY_DEPTH=10;var yw=class{static{a(this,"LazyAssetGraphLoader")}constructor(e,t,r){this.converter=e,this.fileResolver=t,this.store=r,this.loadedIRIs=new Set,this.instanceClassPredicate=gw.Namespace.EXO.term("Instance_class"),this.superClassPredicate=gw.Namespace.EXO.term("Class_superClass"),this.prototypePredicate=gw.Namespace.EXO.term("Asset_prototype")}async ensureFileLoaded(e,t=0){if(t>=Wn.MAX_LAZY_DEPTH)return;let r=this.converter.notePathToIRI(e.path).value;if(!this.loadedIRIs.has(r)){this.loadedIRIs.add(r);try{let i=await this.converter.convertNote(e);if(!this.loadedIRIs.has(r)||(await this.store.addAll(i),!this.loadedIRIs.has(r)))return;await this.walkClassAndPrototypeRelations(i,t+1)}catch(i){throw this.loadedIRIs.delete(r),i}}}async ensureLoadedByIRI(e,t=0){if(t>=Wn.MAX_LAZY_DEPTH||this.loadedIRIs.has(e.value))return;let r=this.fileResolver.resolveByIRI(e);r!==null&&await this.ensureFileLoaded(r,t)}isLoaded(e){return this.loadedIRIs.has(e.value)}forget(e){this.loadedIRIs.delete(e.value)}clearAll(){this.loadedIRIs.clear()}get loadedCount(){return this.loadedIRIs.size}clearForTests(){this.loadedIRIs.clear()}async walkClassAndPrototypeRelations(e,t){let r=[];for(let i of e){if(!(i.object instanceof OU.IRI))continue;let s=i.predicate.value;(s===this.instanceClassPredicate.value||s===this.superClassPredicate.value||s===this.prototypePredicate.value)&&r.push(i.object)}for(let i of r)await this.ensureLoadedByIRI(i,t)}};Wn.LazyAssetGraphLoader=yw;Wn.LazyAssetGraphLoader=yw=RU([(0,PU.injectable)(),CU("design:paramtypes",[Object,Object,Object])],yw)});var bw=S(hr=>{"use strict";var FU=hr&&hr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},DU=hr&&hr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(hr,"__esModule",{value:!0});hr.SourceAnnotator=hr.DEPTH_VARIABLE=hr.SOURCE_VARIABLE=void 0;var LU=Oe(),wc=$e(),NU=Ae(),Tm=pw();hr.SOURCE_VARIABLE="_source";hr.DEPTH_VARIABLE="_depth";var _w=class{static{a(this,"SourceAnnotator")}constructor(e){this.tripleStore=e}async annotate(e,t,r,i){if(!this.tripleStore.matchInGraph)return e.map(o=>{let l=o.clone();return l.set(hr.SOURCE_VARIABLE,new wc.Literal("own")),l});let s=[];for(let o of e){let l=o.get(t),c=o.get(r),u=o.get(i),f=o.clone();if(!l||!c||!u)f.set(hr.SOURCE_VARIABLE,new wc.Literal("own"));else{let d=await this.determineSource(l,c,u);f.set(hr.SOURCE_VARIABLE,new wc.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,Tm.INFERRED_GRAPH)).length>0?"inherited":"own"}async getInheritanceDepth(e,t,r){if(!this.tripleStore.matchInGraph)return 0;for(let i=1;i<=Tm.MAX_PROTOTYPE_DEPTH;i++){let s=(0,Tm.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 o=s.clone();return o.set(hr.SOURCE_VARIABLE,new wc.Literal("own")),o});let r=[],i=new Map;for(let s of e){let o=s.get(t),l=s.clone();if(!o||!(o instanceof NU.IRI))l.set(hr.SOURCE_VARIABLE,new wc.Literal("own"));else{let c=o.value;if(!i.has(c)){let f=await this.tripleStore.matchInGraph(o,void 0,void 0,Tm.INFERRED_GRAPH);i.set(c,f.length>0?"inherited":"own")}let u=i.get(c)??"own";l.set(hr.SOURCE_VARIABLE,new wc.Literal(u))}r.push(l)}return r}};hr.SourceAnnotator=_w;hr.SourceAnnotator=_w=FU([(0,LU.injectable)(),DU("design:paramtypes",[Object])],_w)});var Ew=S(Ln=>{"use strict";var kU=Ln&&Ln.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},MU=Ln&&Ln.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},A3=Ln&&Ln.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.NoteToRDFConverter=void 0;Ln.normaliseExcludedFolders=P3;Ln.isPathExcluded=O3;Ln.shouldSkipFileForEffectiveSet=F3;var Sw=Oe(),pr=Bn(),fo=Ae(),hn=$e(),R3=$t(),Qt=er(),C3=Ft(),jU=iw(),$U=Cl(),ww=rw(),Dn=u_(),UU=new Set(["archived","draft","pinned"]);function P3(n){return Array.isArray(n)?n.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(P3,"normaliseExcludedFolders");function O3(n,e){if(e.length===0)return!1;let t=n.replace(/\\/g,"/");for(let r of e)if(t.startsWith(r))return!0;return!1}a(O3,"isPathExcluded");var vw="assetspaces/";function F3(n,e,t){let r=n.replace(/\\/g,"/");if(!r.startsWith(vw))return!1;let i=r.slice(vw.length),s=i.indexOf("/");if(s<0)return!1;let o=`${vw}${i.slice(0,s)}`,l=t.get(o);return l===void 0?!1:!e.has(l)}a(F3,"shouldSkipFileForEffectiveSet");function VU(n){if(!n)return"";let e=n.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(VU,"normaliseSubjectIriPrefix");var vc=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=$U.NullLogger,r={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new jU.RDFVocabularyMapper,this.subjectIriPrefix=VU(r.subjectIriPrefix)}async convertNote(e){let t=this.vault.getFrontmatter(e);if(!t)return[];let r=this.notePathToIRI(e.path),i=Qt.Namespace.EXO.term("Asset_filename"),s=new pr.Triple(r,i,new hn.Literal(e.basename));if(Dn.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}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=UU.has(f)?`exo__Asset_${f}`:f;if(!this.isExocortexProperty(h))continue;let p=this.propertyKeyToIRI(h),g=Array.isArray(d)?d:[d];for(let _ of g)if(!(f==="exo__Asset_label"&&typeof _=="string"&&_.trim()===""))if(f==="exo__Instance_class"){let v=this.valueToClassURI(_);i.push(new pr.Triple(s,p,v))}else{let v=await this.valueToRDFObject(_,e,p);for(let w of v)if(i.push(new pr.Triple(s,p,w)),this.vocabularyMapper.hasMappingFor(f)&&w instanceof fo.IRI){let E=this.vocabularyMapper.generateMappedTriple(s,f,w);E&&i.push(E)}}if(f==="exo__Instance_class")for(let _ of g){let v=this.valueToClassURI(_);if(v instanceof fo.IRI){let w=Qt.Namespace.RDF.term("type");i.push(new pr.Triple(s,w,v))}}if(f==="exo__Asset_label"){let _=Qt.Namespace.RDFS.term("label");for(let v of g)typeof v=="string"&&v.length>0&&i.push(new pr.Triple(s,_,new hn.Literal(v)))}}let o="exo__Instance_class"in t||"exo__Asset_uid"in t,l=t.exo__Asset_label,c="exo__Asset_label"in t&&l!==null&&l!==void 0&&!(typeof l=="string"&&l.trim()==="")&&!(Array.isArray(l)&&l.length===0);if(o&&!c){let f=Qt.Namespace.RDFS.term("label"),d=Qt.Namespace.EXO.term("Asset_label"),h=new hn.Literal(e.basename);i.push(new pr.Triple(s,f,h)),i.push(new pr.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=Dn.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Dn.Exo003MetadataType.Namespace:break;case Dn.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Dn.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Dn.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Dn.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new fo.IRI(t.uri);return[new pr.Triple(r,Qt.Namespace.OWL.term("sameAs"),i),new pr.Triple(i,Qt.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 pr.Triple(r,Qt.Namespace.OWL.term("sameAs"),new R3.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Dn.Exo003Parser.toTriple(t,i);r.push(s);let o=this.notePathToIRI(e.path);r.push(new pr.Triple(o,Qt.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),o=this.createExo003ReferenceResolver(e),l=o(t.subject),c=o(t.predicate);if(l.type==="literal")throw new Error("Body subject cannot be a literal");if(c.type!=="iri")throw new Error("Body predicate must be an IRI");let u=l.type==="iri"?new fo.IRI(l.value):new R3.BlankNode(l.value),f=new fo.IRI(c.value),d=Dn.Exo003Parser.toLiteral(t,s.trim());r.push(new pr.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new pr.Triple(h,Qt.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 o=this.vault.getFrontmatter(s);if(o&&Dn.Exo003Parser.isExo003Format(o)){let l=Dn.Exo003Parser.parse(o);if(l.success&&l.metadata){let c=l.metadata;if(c.metadata===Dn.Exo003MetadataType.Anchor||c.metadata===Dn.Exo003MetadataType.Namespace)return{type:"iri",value:c.uri};if(c.metadata===Dn.Exo003MetadataType.BlankNode)return{type:"blank",value:c.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(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders,effectiveOntologies:e.effectiveOntologies,assetSpaceFolderToUid:e.assetSpaceFolderToUid})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1,o=P3(e.excludedFolders),l=e.effectiveOntologies,c=e.assetSpaceFolderToUid,u=null;l!==void 0&&(l.size===0?this.logger.warn("[NoteToRDFConverter] effectiveOntologies is empty \u2014 falling back to no-filter path to avoid plugin self-brick. Verify the active focus profile's _includes / _extends / _alwaysOnOverlay properties."):c===void 0?this.logger.warn("[NoteToRDFConverter] effectiveOntologies provided without assetSpaceFolderToUid map \u2014 falling back to no-filter. Caller must precompute the folder\u2192UID map (see AssetSpaceManager)."):u={effective:l,folderMap:c});let f=o.length===0?t:t.filter(d=>!O3(d.path,o));if(u!==null){let{effective:d,folderMap:h}=u;f=f.filter(p=>!F3(p.path,d,h))}for(let d of f)try{let h=this.vault.getFrontmatter(d),p=h?this.validateExocortexAsset(h,d.basename):null;if(p){if(s)throw new Error(`Invariant violation in "${d.path}": ${p.message}`);i.push({path:d.path,reason:`Invariant violation: ${p.message}`}),this.logger.warn(`Skipping file with invariant violation: ${d.path}`,{code:p.code,property:p.property,reason:p.message});continue}let g=await this.convertNote(d);r.push(...g)}catch(h){let p=h instanceof Error?h.message:String(h);if(s)throw new Error(`Invalid IRI for file "${d.path}": ${p}`);i.push({path:d.path,reason:`Invalid IRI: ${p}`}),this.logger.warn(`Skipping file with invalid IRI: ${d.path}`,{reason:p})}return{triples:r,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length}}}static inferLabelFromBasename(e){return Qt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=a(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 o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&r(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let l=e.exo__Instance_class,c=Array.isArray(l)?l:[l],u=null,f=!1;for(let d of c){if(typeof d!="string")continue;let h=this.removeQuotes(d),g=(this.extractWikilink(h)??h).trim();/^[a-z][a-zA-Z0-9]*__/.test(g)&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=(0,ww.vaultPathToIRI)(r.path);fo.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 fo.IRI((0,ww.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new fo.IRI((0,ww.vaultPathToIRI)(e))}isExocortexProperty(e){return Qt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Qt.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 o=this.valueToClassURI(s);o instanceof fo.IRI&&(this.pendingExtraTriples.push(new pr.Triple(e,Qt.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new pr.Triple(e,Qt.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e),s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let c=this.notePathToIRI(o.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")||r?.value.endsWith("#Grounding_type")||r?.value.endsWith("#PropertyDefault_value"))return[c];let p=this.expandClassValue(o.basename);if(p)return this.emitTypeTripleForEnumInstance(p,o),[p];let g=this.vault.getFrontmatter(o);if(g){let E=g.exo__Asset_label;if(typeof E=="string"){let I=this.expandClassValue(E);if(I)return this.emitTypeTripleForEnumInstance(I,o),[I]}}let _=r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype"),v=(process.env.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(E=>E.trim()).filter(Boolean),w=v.length>0&&v.some(E=>r?.value.endsWith(`#${E}`));return _||w?[c,d]:[c]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[c]}if(this.isClassReference(s)){let c=this.expandClassValue(s);if(c)return[c]}let l=s.includes("|")?s.split("|")[0]:s;return this.isUUID(l)?[this.synthesizeWikilinkTargetIRI(`${l}.md`)]:[new hn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new hn.Literal(i,Qt.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(),Qt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new hn.Literal(e.toISOString(),Qt.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 o=this.extractWikilinkAlias(t);if(o){let l=this.expandClassValue(o);if(l)return l}if(this.isUUID(i)){let l=this.vault.getFirstLinkpathDest(i,"");if(l){let c=this.expandClassValue(l.basename);if(c)return c;let u=this.vault.getFrontmatter(l);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return d}}return this.notePathToIRI(l.path)}}return new hn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Qt.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=Qt.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),o=this.extractBodyWikilinks(s),l=Qt.Namespace.EXO.term("Asset_bodyLink");for(let c of o){let u=this.vault.getFirstLinkpathDest(c,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new pr.Triple(t,l,f))}else if(this.isClassReference(c)){let f=this.expandClassValue(c);f?r.push(new pr.Triple(t,l,f)):r.push(new pr.Triple(t,l,new hn.Literal(c)))}else r.push(new pr.Triple(t,l,new hn.Literal(c)))}}catch{}return r}};Ln.NoteToRDFConverter=vc;vc.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};vc.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};vc.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Ln.NoteToRDFConverter=vc=kU([(0,Sw.injectable)(),A3(0,(0,Sw.inject)(C3.DI_TOKENS.IVaultAdapter)),A3(1,(0,Sw.inject)(C3.DI_TOKENS.ILogger)),MU("design:paramtypes",[Object,Object,Object])],vc)});var Iw=S(Im=>{"use strict";Object.defineProperty(Im,"__esModule",{value:!0});Im.FilterContainsOptimizer=void 0;var BU=Ae(),GU=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,Tw=class{static{a(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 l=s.args[0];l.type==="variable"&&(i=l.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let l=String(t.value).match(GU);if(l)return{variable:i,uuid:l[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 BU.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(o=>o.subject.type==="variable"&&o.subject.value===t?{...o,subject:{type:"iri",value:r}}:o);if(i.some((o,l)=>o.subject!==e.triples[l].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(o=>({[t.variable]:{type:"iri",value:o}}))},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)}};Im.FilterContainsOptimizer=Tw});var D3=S(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0});xm.AlgebraOptimizer=void 0;var qU=Iw(),xw=class{static{a(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new qU.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),o=r.every(c=>i.has(c)),l=r.every(c=>s.has(c));return o&&!l?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:l&&!o?{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)}};xm.AlgebraOptimizer=xw});var L3=S(Am=>{"use strict";Object.defineProperty(Am,"__esModule",{value:!0});Am.AlgebraSerializer=void 0;var Aw=class{static{a(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
378
+ `),t}};_m.RDFSerializer=tw});var rw=S(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.OBSIDIAN_VAULT_SCHEME=void 0;uo.vaultPathToIRI=dU;uo.iriToVaultPath=hU;uo.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function dU(n){let e=n.startsWith("./")?n.slice(2):n;return`${uo.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(dU,"vaultPathToIRI");function hU(n){if(!n.startsWith(uo.OBSIDIAN_VAULT_SCHEME))return null;let e=n.slice(uo.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(hU,"iriToVaultPath")});var iw=S(bm=>{"use strict";Object.defineProperty(bm,"__esModule",{value:!0});bm.RDFVocabularyMapper=void 0;var nr=Bn(),y3=Ae(),ee=er(),nw=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",ee.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",ee.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",ee.Namespace.RDFS.term("subClassOf")],["exo__Property_range",ee.Namespace.RDFS.term("range")],["exo__Property_domain",ee.Namespace.RDFS.term("domain")],["exo__Property_superProperty",ee.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new nr.Triple(ee.Namespace.EXO.term("Asset"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.RDFS.term("Resource"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Class"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.RDFS.term("Class"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.RDF.term("Property"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Task"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Project"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Area"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("Workflow"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("WorkflowState"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EMS.term("WorkflowTransition"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("Command"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("Precondition"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("Grounding"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e.push(new nr.Triple(ee.Namespace.EXOCMD.term("CommandBinding"),ee.Namespace.RDFS.term("subClassOf"),ee.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new nr.Triple(ee.Namespace.EXO.term("Instance_class"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDF.term("type"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Asset_isDefinedBy"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("isDefinedBy"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Class_superClass"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("subClassOf"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property_range"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("range"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property_domain"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("domain"))),e.push(new nr.Triple(ee.Namespace.EXO.term("Property_superProperty"),ee.Namespace.RDFS.term("subPropertyOf"),ee.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof y3.IRI)s=r;else{let o=r.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,l,c]=o;s=(l==="ems"?ee.Namespace.EMS:l==="exocmd"?ee.Namespace.EXOCMD:ee.Namespace.EXO).term(c)}else s=new y3.IRI(r)}return new nr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};bm.RDFVocabularyMapper=nw});var _3=S(wm=>{"use strict";Object.defineProperty(wm,"__esModule",{value:!0});wm.RDFSInferenceEngine=void 0;var pU=Bn(),Sm=Ae(),sw=class{static{a(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 o=this.computeAllAncestors(s),l=await e.count(),c=await e.match(void 0,i),u=[];for(let d of c)if(d.object instanceof Sm.IRI){let h=o.get(d.object.value);if(h)for(let p of h)u.push(new pU.Triple(d.subject,i,new Sm.IRI(p)))}return u.length>0&&await e.addAll(u),await e.count()-l}async buildDirectParentMap(e,t){let r=await e.match(void 0,t),i=new Map;for(let s of r)if(s.subject instanceof Sm.IRI&&s.object instanceof Sm.IRI){let o=s.subject.value,l=s.object.value;i.has(o)||i.set(o,new Set),i.get(o).add(l)}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=[],o=t.get(e);if(o)for(let l of o)s.push(l);for(;s.length>0;){let l=s.shift();if(i.has(l))continue;i.add(l),r.add(l);let c=t.get(l);if(c)for(let u of c)i.has(u)||s.push(u)}return r}};wm.RDFSInferenceEngine=sw});var lw=S(Qa=>{"use strict";var mU=Qa&&Qa.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Qa,"__esModule",{value:!0});Qa.NonInheritablePropertyRegistry=void 0;var gU=Oe(),b3=Ae(),S3=$e(),ow=er(),aw=class{static{a(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(l=>l.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 o=t.find(l=>l.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let l of s){let c=await e.match(l.subject,o,void 0);for(let u of c)if(u.object instanceof S3.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(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new S3.Literal("exo__NonInheritableProperty"));if(i.length>0&&i[0].subject instanceof b3.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let l of o)if(l.object instanceof b3.IRI&&l.object.value.includes("NonInheritableProperty"))return l.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?ow.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?ow.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?ow.Namespace.EXOCMD.term(e.substring(8)).value:null}};Qa.NonInheritablePropertyRegistry=aw;Qa.NonInheritablePropertyRegistry=aw=mU([(0,gU.injectable)()],aw)});var fw=S(Ya=>{"use strict";var yU=Ya&&Ya.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s};Object.defineProperty(Ya,"__esModule",{value:!0});Ya.PropertyCardinalityRegistry=void 0;var _U=Oe(),w3=Ae(),v3=$e(),cw=er(),uw=class{static{a(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(l=>l.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 o=t.find(l=>l.value.includes("Asset_label"));if(!o){this.initialized=!0;return}for(let l of s){let c=await e.match(l.subject,o,void 0);for(let u of c)if(u.object instanceof v3.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(o=>o.value.includes("Asset_label"));if(!r)return null;let i=await e.match(void 0,r,new v3.Literal("exo__PropertyCardinalityMultiple"));if(i.length>0&&i[0].subject instanceof w3.IRI)return i[0].subject;let s=t.find(o=>o.value.includes("Instance_class"));if(s){let o=await e.match(void 0,s,void 0);for(let l of o)if(l.object instanceof w3.IRI&&l.object.value.includes("PropertyCardinalityMultiple"))return l.object}return null}propertyKeyToIRI(e){return e.startsWith("exo__")?cw.Namespace.EXO.term(e.substring(5)).value:e.startsWith("ems__")?cw.Namespace.EMS.term(e.substring(5)).value:e.startsWith("exocmd__")?cw.Namespace.EXOCMD.term(e.substring(8)).value:null}};Ya.PropertyCardinalityRegistry=uw;Ya.PropertyCardinalityRegistry=uw=yU([(0,_U.injectable)()],uw)});var pw=S(wr=>{"use strict";var bU=wr&&wr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},SU=wr&&wr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(wr,"__esModule",{value:!0});wr.PrototypeChainMaterializer=wr.MAX_PROTOTYPE_DEPTH=wr.INFERRED_GRAPH=void 0;wr.inferredGraphForDepth=dw;var wU=Oe(),E3=Bn(),qo=Ae(),vU=lw(),EU=fw();wr.INFERRED_GRAPH=new qo.IRI("https://exocortex.my/ontology/exo#inferred");var TU="https://exocortex.my/ontology/exo#inferred/";function dw(n){return new qo.IRI(`${TU}${n}`)}a(dw,"inferredGraphForDepth");wr.MAX_PROTOTYPE_DEPTH=10;var hw=class{static{a(this,"PrototypeChainMaterializer")}constructor(e,t){this.registry=e,this.cardinalityRegistry=t??null}async materialize(e){let r=(await e.predicates()).find(l=>l.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 l of i)if(l.subject instanceof qo.IRI&&l.object instanceof qo.IRI){let c=l.subject.value,u=l.object.value;c!==u&&s.set(c,l.object)}if(s.size===0)return 0;let o=0;for(let[l]of s){let c=new qo.IRI(l),u=this.resolveChain(l,s);if(u.length===0)continue;let f=await e.match(c,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 g=p.object instanceof qo.IRI?p.object.value:String(p.object),_=h.get(p.predicate.value);_||(_=new Set,h.set(p.predicate.value,_)),_.add(g)}for(let p=0;p<u.length;p++){let g=u[p],_=p+1,v=new qo.IRI(g),w=await e.match(v,void 0,void 0),E=new Set;if(e.matchInGraph){let I=await e.matchInGraph(v,void 0,void 0,wr.INFERRED_GRAPH);for(let O of I)E.add(O.predicate.value)}for(let I of w){let O=I.predicate.value;if(this.registry.isNonInheritable(O)||E.has(O))continue;if(d.has(O)&&this.isMultiValued(O)){let H=I.object instanceof qo.IRI?I.object.value:String(I.object);if(h.get(O)?.has(H))continue;let de=h.get(O);de||(de=new Set,h.set(O,de)),de.add(H);let N=new E3.Triple(c,I.predicate,I.object);await e.add(N),e.addToGraph&&(await e.addToGraph(N,wr.INFERRED_GRAPH),await e.addToGraph(N,dw(_))),o++;continue}if(d.has(O))continue;let C=new E3.Triple(c,I.predicate,I.object);await e.add(C),e.addToGraph&&(await e.addToGraph(C,wr.INFERRED_GRAPH),await e.addToGraph(C,dw(_))),d.add(O),o++}}}return o}isMultiValued(e){return this.cardinalityRegistry?this.cardinalityRegistry.isMultiValued(e):!1}resolveChain(e,t){let r=[],i=new Set;i.add(e);let s=[],o=t.get(e);for(o&&s.push(o.value);s.length>0&&r.length<wr.MAX_PROTOTYPE_DEPTH;){let l=s.shift();if(l===void 0)break;if(i.has(l))continue;i.add(l),r.push(l);let c=t.get(l);c&&!i.has(c.value)&&s.push(c.value)}return r}};wr.PrototypeChainMaterializer=hw;wr.PrototypeChainMaterializer=hw=bU([(0,wU.injectable)(),SU("design:paramtypes",[vU.NonInheritablePropertyRegistry,EU.PropertyCardinalityRegistry])],hw)});var I3=S(Em=>{"use strict";Object.defineProperty(Em,"__esModule",{value:!0});Em.IRICanonicalizer=void 0;var T3=Ae(),IU=$e(),xU=$t(),AU=Bn(),mw=/^obsidian:\/\/vault\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i,vm=class n{static{a(this,"IRICanonicalizer")}static extractSynthAUid(e){let t=mw.exec(e);return t?t[1].toLowerCase():null}static canonicalize(e,t){if(t.size===0)return{triples:e,remapCount:0,uniqueRemapCount:0};let r=new Map,i=new Set,s=0;return{triples:e.map(l=>{let c=n.remapIfSynthA(l.subject,t,r,i),u=n.remapIfSynthA(l.object,t,r,i);return c===l.subject&&u===l.object?l:(s++,new AU.Triple(c,l.predicate,u))}),remapCount:s,uniqueRemapCount:i.size}}static remapIfSynthA(e,t,r,i){if(e instanceof IU.Literal||e instanceof xU.BlankNode||!(e instanceof T3.IRI))return e;let s=mw.exec(e.value);if(!s)return e;let o=s[1].toLowerCase(),l=t.get(o);if(!l||l===e.value)return e;i.add(o);let c=r.get(l);return c||(c=new T3.IRI(l),r.set(l,c)),c}};Em.IRICanonicalizer=vm;vm.SYNTH_A_IRI_PATTERN=mw});var x3=S(Wn=>{"use strict";var RU=Wn&&Wn.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},CU=Wn&&Wn.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Wn,"__esModule",{value:!0});Wn.LazyAssetGraphLoader=Wn.MAX_LAZY_DEPTH=void 0;var PU=Oe(),OU=Ae(),gw=er();Wn.MAX_LAZY_DEPTH=10;var yw=class{static{a(this,"LazyAssetGraphLoader")}constructor(e,t,r){this.converter=e,this.fileResolver=t,this.store=r,this.loadedIRIs=new Set,this.instanceClassPredicate=gw.Namespace.EXO.term("Instance_class"),this.superClassPredicate=gw.Namespace.EXO.term("Class_superClass"),this.prototypePredicate=gw.Namespace.EXO.term("Asset_prototype")}async ensureFileLoaded(e,t=0){if(t>=Wn.MAX_LAZY_DEPTH)return;let r=this.converter.notePathToIRI(e.path).value;if(!this.loadedIRIs.has(r)){this.loadedIRIs.add(r);try{let i=await this.converter.convertNote(e);if(!this.loadedIRIs.has(r)||(await this.store.addAll(i),!this.loadedIRIs.has(r)))return;await this.walkClassAndPrototypeRelations(i,t+1)}catch(i){throw this.loadedIRIs.delete(r),i}}}async ensureLoadedByIRI(e,t=0){if(t>=Wn.MAX_LAZY_DEPTH||this.loadedIRIs.has(e.value))return;let r=this.fileResolver.resolveByIRI(e);r!==null&&await this.ensureFileLoaded(r,t)}isLoaded(e){return this.loadedIRIs.has(e.value)}forget(e){this.loadedIRIs.delete(e.value)}clearAll(){this.loadedIRIs.clear()}get loadedCount(){return this.loadedIRIs.size}clearForTests(){this.loadedIRIs.clear()}async walkClassAndPrototypeRelations(e,t){let r=[];for(let i of e){if(!(i.object instanceof OU.IRI))continue;let s=i.predicate.value;(s===this.instanceClassPredicate.value||s===this.superClassPredicate.value||s===this.prototypePredicate.value)&&r.push(i.object)}for(let i of r)await this.ensureLoadedByIRI(i,t)}};Wn.LazyAssetGraphLoader=yw;Wn.LazyAssetGraphLoader=yw=RU([(0,PU.injectable)(),CU("design:paramtypes",[Object,Object,Object])],yw)});var bw=S(hr=>{"use strict";var FU=hr&&hr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},DU=hr&&hr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(hr,"__esModule",{value:!0});hr.SourceAnnotator=hr.DEPTH_VARIABLE=hr.SOURCE_VARIABLE=void 0;var LU=Oe(),wc=$e(),NU=Ae(),Tm=pw();hr.SOURCE_VARIABLE="_source";hr.DEPTH_VARIABLE="_depth";var _w=class{static{a(this,"SourceAnnotator")}constructor(e){this.tripleStore=e}async annotate(e,t,r,i){if(!this.tripleStore.matchInGraph)return e.map(o=>{let l=o.clone();return l.set(hr.SOURCE_VARIABLE,new wc.Literal("own")),l});let s=[];for(let o of e){let l=o.get(t),c=o.get(r),u=o.get(i),f=o.clone();if(!l||!c||!u)f.set(hr.SOURCE_VARIABLE,new wc.Literal("own"));else{let d=await this.determineSource(l,c,u);f.set(hr.SOURCE_VARIABLE,new wc.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,Tm.INFERRED_GRAPH)).length>0?"inherited":"own"}async getInheritanceDepth(e,t,r){if(!this.tripleStore.matchInGraph)return 0;for(let i=1;i<=Tm.MAX_PROTOTYPE_DEPTH;i++){let s=(0,Tm.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 o=s.clone();return o.set(hr.SOURCE_VARIABLE,new wc.Literal("own")),o});let r=[],i=new Map;for(let s of e){let o=s.get(t),l=s.clone();if(!o||!(o instanceof NU.IRI))l.set(hr.SOURCE_VARIABLE,new wc.Literal("own"));else{let c=o.value;if(!i.has(c)){let f=await this.tripleStore.matchInGraph(o,void 0,void 0,Tm.INFERRED_GRAPH);i.set(c,f.length>0?"inherited":"own")}let u=i.get(c)??"own";l.set(hr.SOURCE_VARIABLE,new wc.Literal(u))}r.push(l)}return r}};hr.SourceAnnotator=_w;hr.SourceAnnotator=_w=FU([(0,LU.injectable)(),DU("design:paramtypes",[Object])],_w)});var Ew=S(Ln=>{"use strict";var kU=Ln&&Ln.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},MU=Ln&&Ln.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},A3=Ln&&Ln.__param||function(n,e){return function(t,r){e(t,r,n)}};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.NoteToRDFConverter=void 0;Ln.normaliseExcludedFolders=P3;Ln.isPathExcluded=O3;Ln.shouldSkipFileForEffectiveSet=F3;var Sw=Oe(),pr=Bn(),fo=Ae(),hn=$e(),R3=$t(),Qt=er(),C3=Ft(),jU=iw(),$U=Cl(),ww=rw(),Dn=u_(),UU=new Set(["archived","draft","pinned"]);function P3(n){return Array.isArray(n)?n.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(P3,"normaliseExcludedFolders");function O3(n,e){if(e.length===0)return!1;let t=n.replace(/\\/g,"/");for(let r of e)if(t.startsWith(r))return!0;return!1}a(O3,"isPathExcluded");var vw="assetspaces/";function F3(n,e,t){let r=n.replace(/\\/g,"/");if(!r.startsWith(vw))return!1;let i=r.slice(vw.length),s=i.indexOf("/");if(s<0)return!1;let o=`${vw}${i.slice(0,s)}`,l=t.get(o);return l===void 0?!1:!e.has(l)}a(F3,"shouldSkipFileForEffectiveSet");function VU(n){if(!n)return"";let e=n.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(VU,"normaliseSubjectIriPrefix");var vc=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=$U.NullLogger,r={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new jU.RDFVocabularyMapper,this.subjectIriPrefix=VU(r.subjectIriPrefix)}async convertNote(e){let t=this.vault.getFrontmatter(e);if(!t)return[];let r=this.notePathToIRI(e.path),i=Qt.Namespace.EXO.term("Asset_filename"),s=new pr.Triple(r,i,new hn.Literal(e.basename));if(Dn.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}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=UU.has(f)?`exo__Asset_${f}`:f;if(!this.isExocortexProperty(h))continue;let p=this.propertyKeyToIRI(h),g=Array.isArray(d)?d:[d];for(let _ of g)if(!(f==="exo__Asset_label"&&typeof _=="string"&&_.trim()===""))if(f==="exo__Instance_class"){let v=this.valueToClassURI(_);i.push(new pr.Triple(s,p,v))}else{let v=await this.valueToRDFObject(_,e,p);for(let w of v)if(i.push(new pr.Triple(s,p,w)),this.vocabularyMapper.hasMappingFor(f)&&w instanceof fo.IRI){let E=this.vocabularyMapper.generateMappedTriple(s,f,w);E&&i.push(E)}}if(f==="exo__Instance_class")for(let _ of g){let v=this.valueToClassURI(_);if(v instanceof fo.IRI){let w=Qt.Namespace.RDF.term("type");i.push(new pr.Triple(s,w,v))}}if(f==="exo__Asset_label"){let _=Qt.Namespace.RDFS.term("label");for(let v of g)typeof v=="string"&&v.length>0&&i.push(new pr.Triple(s,_,new hn.Literal(v)))}}let o="exo__Instance_class"in t||"exo__Asset_uid"in t,l=t.exo__Asset_label,c="exo__Asset_label"in t&&l!==null&&l!==void 0&&!(typeof l=="string"&&l.trim()==="")&&!(Array.isArray(l)&&l.length===0);if(o&&!c){let f=Qt.Namespace.RDFS.term("label"),d=Qt.Namespace.EXO.term("Asset_label"),h=new hn.Literal(e.basename);i.push(new pr.Triple(s,f,h)),i.push(new pr.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=Dn.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case Dn.Exo003MetadataType.Namespace:break;case Dn.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Dn.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Dn.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Dn.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new fo.IRI(t.uri);return[new pr.Triple(r,Qt.Namespace.OWL.term("sameAs"),i),new pr.Triple(i,Qt.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 pr.Triple(r,Qt.Namespace.OWL.term("sameAs"),new R3.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=Dn.Exo003Parser.toTriple(t,i);r.push(s);let o=this.notePathToIRI(e.path);r.push(new pr.Triple(o,Qt.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),o=this.createExo003ReferenceResolver(e),l=o(t.subject),c=o(t.predicate);if(l.type==="literal")throw new Error("Body subject cannot be a literal");if(c.type!=="iri")throw new Error("Body predicate must be an IRI");let u=l.type==="iri"?new fo.IRI(l.value):new R3.BlankNode(l.value),f=new fo.IRI(c.value),d=Dn.Exo003Parser.toLiteral(t,s.trim());r.push(new pr.Triple(u,f,d));let h=this.notePathToIRI(e.path);r.push(new pr.Triple(h,Qt.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 o=this.vault.getFrontmatter(s);if(o&&Dn.Exo003Parser.isExo003Format(o)){let l=Dn.Exo003Parser.parse(o);if(l.success&&l.metadata){let c=l.metadata;if(c.metadata===Dn.Exo003MetadataType.Anchor||c.metadata===Dn.Exo003MetadataType.Namespace)return{type:"iri",value:c.uri};if(c.metadata===Dn.Exo003MetadataType.BlankNode)return{type:"blank",value:c.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(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders,effectiveOntologies:e.effectiveOntologies,assetSpaceFolderToUid:e.assetSpaceFolderToUid})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1,o=P3(e.excludedFolders),l=e.effectiveOntologies,c=e.assetSpaceFolderToUid,u=null;l!==void 0&&(l.size===0?this.logger.warn("[NoteToRDFConverter] effectiveOntologies is empty \u2014 falling back to no-filter path to avoid plugin self-brick. Verify the active focus profile's _includes / _extends / _alwaysOnOverlay properties."):c===void 0?this.logger.warn("[NoteToRDFConverter] effectiveOntologies provided without assetSpaceFolderToUid map \u2014 falling back to no-filter. Caller must precompute the folder\u2192UID map (see AssetSpaceManager)."):u={effective:l,folderMap:c});let f=o.length===0?t:t.filter(d=>!O3(d.path,o));if(u!==null){let{effective:d,folderMap:h}=u;f=f.filter(p=>!F3(p.path,d,h))}for(let d of f)try{let h=this.vault.getFrontmatter(d),p=h?this.validateExocortexAsset(h,d.basename):null;if(p){if(s)throw new Error(`Invariant violation in "${d.path}": ${p.message}`);i.push({path:d.path,reason:`Invariant violation: ${p.message}`}),this.logger.warn(`Skipping file with invariant violation: ${d.path}`,{code:p.code,property:p.property,reason:p.message});continue}let g=await this.convertNote(d);r.push(...g)}catch(h){let p=h instanceof Error?h.message:String(h);if(s)throw new Error(`Invalid IRI for file "${d.path}": ${p}`);i.push({path:d.path,reason:`Invalid IRI: ${p}`}),this.logger.warn(`Skipping file with invalid IRI: ${d.path}`,{reason:p})}return{triples:r,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length}}}static inferLabelFromBasename(e){return Qt.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=a(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 o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&r(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let l=e.exo__Instance_class,c=Array.isArray(l)?l:[l],u=null,f=!1;for(let d of c){if(typeof d!="string")continue;let h=this.removeQuotes(d),g=(this.extractWikilink(h)??h).trim();/^[a-z][a-zA-Z0-9]*__/.test(g)&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=(0,ww.vaultPathToIRI)(r.path);fo.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 fo.IRI((0,ww.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new fo.IRI((0,ww.vaultPathToIRI)(e))}isExocortexProperty(e){return Qt.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=Qt.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 o=this.valueToClassURI(s);o instanceof fo.IRI&&(this.pendingExtraTriples.push(new pr.Triple(e,Qt.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new pr.Triple(e,Qt.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e),s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let c=this.notePathToIRI(o.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")||r?.value.endsWith("#Grounding_type")||r?.value.endsWith("#PropertyDefault_value"))return[c];let p=this.expandClassValue(o.basename);if(p)return this.emitTypeTripleForEnumInstance(p,o),[p];let g=this.vault.getFrontmatter(o);if(g){let E=g.exo__Asset_label;if(typeof E=="string"){let I=this.expandClassValue(E);if(I)return this.emitTypeTripleForEnumInstance(I,o),[I]}}let _=r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype"),v=(process.env.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(E=>E.trim()).filter(Boolean),w=v.length>0&&v.some(E=>r?.value.endsWith(`#${E}`));return _||w?[c,d]:[c]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[c]}if(this.isClassReference(s)){let c=this.expandClassValue(s);if(c)return[c]}let l=s.includes("|")?s.split("|")[0]:s;return this.isUUID(l)?[this.synthesizeWikilinkTargetIRI(`${l}.md`)]:[new hn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new hn.Literal(i,Qt.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(),Qt.Namespace.XSD.term("decimal"))]:e instanceof Date?[new hn.Literal(e.toISOString(),Qt.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 o=this.extractWikilinkAlias(t);if(o){let l=this.expandClassValue(o);if(l)return l}if(this.isUUID(i)){let l=this.vault.getFirstLinkpathDest(i,"");if(l){let c=this.expandClassValue(l.basename);if(c)return c;let u=this.vault.getFrontmatter(l);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return d}}return this.notePathToIRI(l.path)}}return new hn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:Qt.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=Qt.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),o=this.extractBodyWikilinks(s),l=Qt.Namespace.EXO.term("Asset_bodyLink");for(let c of o){let u=this.vault.getFirstLinkpathDest(c,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new pr.Triple(t,l,f))}else if(this.isClassReference(c)){let f=this.expandClassValue(c);f?r.push(new pr.Triple(t,l,f)):r.push(new pr.Triple(t,l,new hn.Literal(c)))}else r.push(new pr.Triple(t,l,new hn.Literal(c)))}}catch{}return r}};Ln.NoteToRDFConverter=vc;vc.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};vc.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};vc.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Ln.NoteToRDFConverter=vc=kU([(0,Sw.injectable)(),A3(0,(0,Sw.inject)(C3.DI_TOKENS.IVaultAdapter)),A3(1,(0,Sw.inject)(C3.DI_TOKENS.ILogger)),MU("design:paramtypes",[Object,Object,Object])],vc)});var Iw=S(Im=>{"use strict";Object.defineProperty(Im,"__esModule",{value:!0});Im.FilterContainsOptimizer=void 0;var BU=Ae(),GU=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,Tw=class{static{a(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 l=s.args[0];l.type==="variable"&&(i=l.name)}}if(!i&&e.type==="variable"&&(i=e.name),!i)return null;if(t.type==="literal"){let l=String(t.value).match(GU);if(l)return{variable:i,uuid:l[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 BU.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(o=>o.subject.type==="variable"&&o.subject.value===t?{...o,subject:{type:"iri",value:r}}:o);if(i.some((o,l)=>o.subject!==e.triples[l].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(o=>({[t.variable]:{type:"iri",value:o}}))},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)}};Im.FilterContainsOptimizer=Tw});var D3=S(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0});xm.AlgebraOptimizer=void 0;var qU=Iw(),xw=class{static{a(this,"AlgebraOptimizer")}constructor(){this.stats=new Map,this.tripleStore=null,this.filterContainsOptimizer=new qU.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),o=r.every(c=>i.has(c)),l=r.every(c=>s.has(c));return o&&!l?{type:"join",left:{type:"filter",expression:e.expression,input:this.filterPushDown(t.left)},right:this.filterPushDown(t.right)}:l&&!o?{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)}};xm.AlgebraOptimizer=xw});var L3=S(Am=>{"use strict";Object.defineProperty(Am,"__esModule",{value:!0});Am.AlgebraSerializer=void 0;var Aw=class{static{a(this,"AlgebraSerializer")}toString(e,t=0){let r=" ".repeat(t);switch(e.type){case"bgp":return`${r}BGP [
379
379
  ${e.triples.map(u=>`${r} ${this.tripleToString(u)}`).join(`
380
380
  `)}
381
381
  ${r}]`;case"filter":return`${r}Filter(
@@ -452,18 +452,18 @@ To resolve:
452
452
  \u2022 Check service initialization parameters
453
453
  \u2022 Verify all required dependencies are available
454
454
  \u2022 Review service logs for detailed error information
455
- \u2022 Contact support if the issue persists`}};eg.ServiceError=ov});var bR=S(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.ServiceError=or.ResourceExhaustedError=or.NotFoundError=or.PermissionError=or.StateTransitionError=or.NetworkError=or.ValidationError=or.ApplicationError=or.ErrorCode=void 0;var PB=ms();Object.defineProperty(or,"ErrorCode",{enumerable:!0,get:a(function(){return PB.ErrorCode},"get")});var OB=gs();Object.defineProperty(or,"ApplicationError",{enumerable:!0,get:a(function(){return OB.ApplicationError},"get")});var FB=dR();Object.defineProperty(or,"ValidationError",{enumerable:!0,get:a(function(){return FB.ValidationError},"get")});var DB=hR();Object.defineProperty(or,"NetworkError",{enumerable:!0,get:a(function(){return DB.NetworkError},"get")});var LB=pR();Object.defineProperty(or,"StateTransitionError",{enumerable:!0,get:a(function(){return LB.StateTransitionError},"get")});var NB=mR();Object.defineProperty(or,"PermissionError",{enumerable:!0,get:a(function(){return NB.PermissionError},"get")});var kB=gR();Object.defineProperty(or,"NotFoundError",{enumerable:!0,get:a(function(){return kB.NotFoundError},"get")});var MB=yR();Object.defineProperty(or,"ResourceExhaustedError",{enumerable:!0,get:a(function(){return MB.ResourceExhaustedError},"get")});var jB=_R();Object.defineProperty(or,"ServiceError",{enumerable:!0,get:a(function(){return jB.ServiceError},"get")})});var lv=S(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});tg.ShapeRegistry=void 0;var av=class{static{a(this,"ShapeRegistry")}constructor(){this.shapes=new Map}get(e){return this.shapes.get(e)}register(e){this.shapes.set(e.propertyIRI,e)}getAll(){return Array.from(this.shapes.values())}get size(){return this.shapes.size}};tg.ShapeRegistry=av});var fv=S(ys=>{"use strict";var $B=ys&&ys.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),UB=ys&&ys.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),cv=ys&&ys.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&$B(t,e,r[i]);return UB(t,e),t}})();Object.defineProperty(ys,"__esModule",{value:!0});ys.ShapeLoader=void 0;var uv=lv(),Xa=Ae(),Ef=$e(),Xr=er(),rg="http://www.w3.org/ns/shacl#",VB="http://www.w3.org/2001/XMLSchema#",sfe=[["exo__",Xr.Namespace.EXO],["ems__",Xr.Namespace.EMS],["exocmd__",Xr.Namespace.EXOCMD],["ims__",Xr.Namespace.IMS],["ztlk__",Xr.Namespace.ZTLK],["ptms__",Xr.Namespace.PTMS],["lit__",Xr.Namespace.LIT],["inbox__",Xr.Namespace.INBOX],["pmbok__",Xr.Namespace.PMBOK]],Tf=class n{static{a(this,"ShapeLoader")}static async loadFromVaultFS(e){let{readdir:t,readFile:r}=await Promise.resolve().then(()=>cv(require("fs/promises"))),i=await Promise.resolve().then(()=>cv(require("path"))),s=new uv.ShapeRegistry;return await n.scanDir(e,s,{readdir:t,readFile:r,path:i}),s}static async loadFromRDFGraph(e){let t=new uv.ShapeRegistry,r=Xr.Namespace.EXO,i=Xr.Namespace.RDFS,s=Xr.Namespace.RDF,[o,l]=await Promise.all([e.match(void 0,s.term("type"),r.term("ObjectProperty")),e.match(void 0,s.term("type"),r.term("Property"))]),c=new Set;for(let u of[...o,...l])u.subject instanceof Xa.IRI&&c.add(u.subject.value);for(let u of c){let f;try{f=new Xa.IRI(u)}catch{continue}let[d,h,p,g,_,v,w,E,I]=await Promise.all([e.match(f,i.term("domain"),void 0),e.match(f,r.term("Property_domain"),void 0),e.match(f,i.term("range"),void 0),e.match(f,r.term("Property_range"),void 0),e.match(f,r.term("Property_cardinality"),void 0),e.match(f,r.term("Property_severity"),void 0),e.match(f,r.term("Asset_label"),void 0),e.match(f,i.term("label"),void 0),e.match(f,r.term("Property_minCount"),void 0)]),A=[...w,...E],D=[...d,...h],K=[...p,...g];if(D.length===0)continue;let oe=null;for(let q of A)if(q.object instanceof Ef.Literal&&(oe=n.labelToIRI(q.object.value),oe))break;if(!oe)continue;let me=await Promise.all(D.map(async q=>q.object instanceof Xa.IRI?await n.resolveClassIRI(q.object.value,e):null)),N=Array.from(new Set(me.filter(q=>q!==null))),Q=await Promise.all(K.map(async q=>{if(q.object instanceof Xa.IRI)return await n.resolveClassIRI(q.object.value,e);if(q.object instanceof Ef.Literal){let U=q.object.value;if(U.startsWith("http://")||U.startsWith("https://"))return U}return null})),ie=Array.from(new Set(Q.filter(q=>q!==null))),V=n.cardinalityFromIRI(_[0]?.object instanceof Xa.IRI?_[0].object.value:void 0),Y=n.severityFromValue(v[0]?.object instanceof Ef.Literal||v[0]?.object instanceof Xa.IRI?v[0].object.value:void 0),re=I[0]?.object,G=re instanceof Ef.Literal?parseInt(re.value,10):NaN,ne=isNaN(G)?void 0:G;t.register({propertyIRI:oe,domain:N,range:ie.length>0?ie:void 0,cardinality:V,severity:Y,minCount:ne})}return t}static async loadFromShapeJSON(e){let{readFile:t}=await Promise.resolve().then(()=>cv(require("fs/promises"))),r=await t(e,"utf-8"),i=JSON.parse(r),s=new uv.ShapeRegistry;for(let o of Object.values(i.shapes))s.register(o);return s}static async resolveClassIRI(e,t){if(e.startsWith("https://exocortex.my/ontology/")||e.startsWith("http://www.w3.org/"))return e;let r;try{r=new Xa.IRI(e)}catch{return null}let i=Xr.Namespace.RDFS,s=Xr.Namespace.EXO,[o,l]=await Promise.all([t.match(r,i.term("label"),void 0),t.match(r,s.term("Asset_label"),void 0)]);for(let c of[...o,...l])if(c.object instanceof Ef.Literal){let u=n.labelToIRI(c.object.value);if(u)return u}return e}static async scanDir(e,t,r){let i;try{i=await r.readdir(e,{withFileTypes:!0})}catch{return}for(let s of i){let o=r.path.join(e,s.name);if(s.isDirectory())await n.scanDir(o,t,r);else if(s.isFile()&&s.name.endsWith(".md"))try{await n.processFile(o,t,r.readFile,r.path)}catch{}}}static async processFile(e,t,r,i){let s;try{s=await r(e,"utf-8")}catch{return}let o=n.parseFrontmatter(s);if(!o)return;let l="38277bfa-d7f9-4a75-b856-b23276ab0db3",c="9a1cf31c-9d41-4ef3-9023-584a8d087d16";if(!n.asArray(o.exo__Instance_class).some(N=>{let Q=n.extractWikilinkRef(N);return Q==="exo__Property"||Q==="exo__ObjectProperty"||Q===l||Q===c||Q?.includes("|exo__Property")||Q?.includes("|exo__ObjectProperty")}))return;let d=null,h=o.exo__Asset_label;if(typeof h=="string"&&h.trim().length>0)d=h.trim();else if(i){let N=i.basename(e,".md");Xr.Namespace.fromPropertyKey(N)&&(d=N)}if(!d)return;let p=n.labelToIRI(d);if(!p)return;let g=o.exo__Property_domain,_=o.exo__Property_range,v=o.exo__Property_cardinality,w=o.exo__Property_severity,E=o.exo__Property_minCount,I=n.asArray(g).map(N=>n.wikilinkToIRI(N)).filter(N=>N!==null);if(I.length===0)return;let A=n.asArray(_).map(N=>n.wikilinkToIRI(N)).filter(N=>N!==null),D=n.cardinalityFromLabel(typeof v=="string"?v:void 0),K=n.severityFromValue(typeof w=="string"?w:void 0),oe=typeof E=="string"?parseInt(E,10):void 0,me=oe!==void 0&&!isNaN(oe)?oe:void 0;t.register({propertyIRI:p,domain:I,range:A.length>0?A:void 0,cardinality:D,severity:K,minCount:me})}static parseFrontmatter(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!t)return null;let r=t[1],i={},s=r.split(/\r?\n/),o=null,l=null;for(let c of s){let u=/^ {2}- (.*)$/.exec(c);if(u){o&&l&&l.push(u[1].trim());continue}o&&l&&(i[o]=l,o=null,l=null);let f=/^([^:]+):\s*(.*)$/.exec(c);if(!f)continue;let d=f[1].trim(),h=f[2].trim();h===""?(o=d,l=[]):i[d]=h}return o&&l&&(i[o]=l),i}static labelToIRI(e){let t=Xr.Namespace.fromPropertyKey(e);if(!t)return null;try{return t.namespace.term(t.localName).value}catch{return null}}static extractWikilinkRef(e){let t=e.replace(/^["']|["']$/g,""),r=/\[\[([^\]]+)\]\]/.exec(t);return r?r[1]:t}static wikilinkToIRI(e){let t=n.extractWikilinkRef(e);if(!t)return null;let r=t.split("|"),i=r.length>1?[r[1],r[0]]:[r[0]];for(let s of i){let o=n.labelToIRI(s.trim());if(o)return o}return t.startsWith("http")?t:t.startsWith("sh:")?rg+t.substring(3):t.startsWith("xsd:")?VB+t.substring(4):null}static asArray(e){return Array.isArray(e)?e.map(String):typeof e=="string"?[e]:[]}static cardinalityFromIRI(e){if(e){if(e.endsWith("PropertyCardinalitySingle"))return"Single";if(e.endsWith("PropertyCardinalityMultiple"))return"Multiple";if(e.includes(n.CARDINALITY_SINGLE_UID))return"Single";if(e.includes(n.CARDINALITY_MULTIPLE_UID))return"Multiple"}}static cardinalityFromLabel(e){if(!e)return;let t=n.extractWikilinkRef(e)??e,r=t.split("|").pop()??t;if(r.includes("Single"))return"Single";if(r.includes("Multiple"))return"Multiple";if(t.includes(n.CARDINALITY_SINGLE_UID))return"Single";if(t.includes(n.CARDINALITY_MULTIPLE_UID))return"Multiple"}static severityFromValue(e){return!e||e.includes("Violation")||e===rg+"Violation"?"sh:Violation":e.includes("Warning")||e===rg+"Warning"?"sh:Warning":e.includes("Info")||e===rg+"Info"?"sh:Info":"sh:Violation"}};ys.ShapeLoader=Tf;Tf.CARDINALITY_SINGLE_UID="c93c4b2f-b43d-4cc9-8dd0-31514d608da2";Tf.CARDINALITY_MULTIPLE_UID="59a37aa7-ffbe-4e0d-ba60-06ae370d880f"});var hv=S(If=>{"use strict";Object.defineProperty(If,"__esModule",{value:!0});If.ShapeRegistry=void 0;If.validate=QB;var dv=class{static{a(this,"ShapeRegistry")}constructor(e=[],t="https://exocortex.my/ontology/exo#Instance_class"){this.shapeMap=new Map(e.map(r=>[r.propertyIRI,r])),this.typePredicateIRI=t}getShape(e){return this.shapeMap.get(e)}getAllShapes(){return Array.from(this.shapeMap.values())}hasShape(e){return this.shapeMap.has(e)}};If.ShapeRegistry=dv;var BB="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",GB=["http://www.w3.org/2001/XMLSchema#","http://www.w3.org/1999/02/22-rdf-syntax-ns#","http://www.w3.org/2000/01/rdf-schema#","http://www.w3.org/2002/07/owl#","http://www.w3.org/2004/02/skos/core#","http://purl.org/dc/elements/1.1/","http://purl.org/dc/terms/","http://xmlns.com/foaf/0.1/","https://schema.org/","https://exocortex.my/ontology/xsd#","https://exocortex.my/ontology/rdf#","https://exocortex.my/ontology/rdfs#","https://exocortex.my/ontology/owl#","https://exocortex.my/ontology/skos#"];function qB(n){return GB.some(e=>n.startsWith(e))}a(qB,"isExternalOntologyIRI");var WB=["http://www.w3.org/2001/XMLSchema#","https://exocortex.my/ontology/xsd#"];function zB(n){return WB.some(e=>n.startsWith(e))}a(zB,"isXSDDatatypeIRI");var HB=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function SR(n){let e=HB.exec(n);return e?e[1].toLowerCase():null}a(SR,"extractUid");function QB(n,e,t,r){let i=new Map,s=new Map;for(let c of n){let{subject:u,predicate:f,object:d}=c;if(u.type!=="iri"||f.type!=="iri"||d.type!=="iri"&&d.type!=="literal")continue;let h=u.value,p=f.value,g=d;if(p===e.typePredicateIRI||p===BB){if(g.type==="iri"){let v=i.get(h)??[];v.push(g.value),i.set(h,v);let w=SR(h);if(w){let E=`uid:${w}`,I=i.get(E)??[];I.push(g.value),i.set(E,I)}}}else{let v=s.get(h);v||(v=new Map,s.set(h,v));let w=v.get(p)??[];w.push(g),v.set(p,w)}}let o=[],l=new Set([...i.keys(),...s.keys()]);for(let c of l){let u=i.get(c)??[],f=s.get(c)??new Map;for(let d of e.getAllShapes()){if(!(d.domain.length===0||d.domain.some(g=>u.some(_=>_===g||t.isSubClassOf(_,g)))))continue;let p=f.get(d.propertyIRI)??[];if(d.minCount!==void 0&&d.minCount>0&&p.length<d.minCount){o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:minCount violation: expected at least ${d.minCount} value(s) for <${d.propertyIRI}>`});continue}if(p.length!==0){if(d.cardinality==="Single"&&p.length>1){o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:maxCount violation: expected at most 1 value for <${d.propertyIRI}>, got ${p.length}`});continue}if(d.range&&d.range.length>0){for(let g of p)if(g.type==="iri"){if(qB(g.value))continue;let _=i.get(g.value)??[];if(_.length===0){let w=SR(g.value);w&&(_=i.get(`uid:${w}`)??[])}d.range.some(w=>_.some(E=>E===w||t.isSubClassOf(E,w)))||o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:class violation: <${g.value}> does not conform to expected class ${d.range.join(" | ")}`,actualValue:g.value,expectedRange:d.range.join(" | ")})}else if(g.type==="literal"){let _=d.range.filter(E=>zB(E));if(_.length===0)continue;let v=g.datatype??"http://www.w3.org/2001/XMLSchema#string";_.some(E=>E===v)||o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:datatype violation: literal "${g.value}" has datatype <${v}>, expected ${_.join(" | ")}`,actualValue:g.value,expectedRange:_.join(" | ")})}}}}}if(r?.closedWorldMode)for(let c of l){let u=s.get(c)??new Map;for(let f of u.keys())e.hasShape(f)||o.push({focusNode:c,propertyPath:f,severity:"sh:Warning",message:`Unknown property: <${f}> has no registered shape`})}return o.sort((c,u)=>{let f=c.focusNode.localeCompare(u.focusNode);return f!==0?f:c.propertyPath.localeCompare(u.propertyPath)}),{conforms:!o.some(c=>c.severity==="sh:Violation"),violations:o}}a(QB,"validate")});var wR=S(ng=>{"use strict";Object.defineProperty(ng,"__esModule",{value:!0});ng.ApplicationErrorHandler=void 0;var pv=gs(),YB=ms(),XB=$o(),mv=class{static{a(this,"ApplicationErrorHandler")}constructor(e={},t,r){this.logger=t,this.notifier=r,this.telemetryHooks=new Set,this.retryConfig={maxRetries:e.maxRetries??3,initialDelayMs:e.initialDelayMs??1e3,backoffMultiplier:e.backoffMultiplier??2,maxDelayMs:e.maxDelayMs??1e4}}handle(e,t){let r=this.ensureApplicationError(e,t);return this.notifier&&this.notifier.error(r.message),this.callTelemetryHooks("onError",r,t),this.formatError(r)}async executeWithRetry(e,t){let r,i=0;for(;i<=this.retryConfig.maxRetries;)try{return await e()}catch(s){if(r=this.ensureApplicationError(s,t),!r.retriable||i>=this.retryConfig.maxRetries)throw this.callTelemetryHooks("onError",r,t),i>=this.retryConfig.maxRetries&&r.retriable&&this.callTelemetryHooks("onRetryExhausted",r,i+1),r;let o=this.calculateDelay(i);this.callTelemetryHooks("onRetry",r,i+1,o),this.logger?.debug(`Retrying after ${o}ms (attempt ${i+1}/${this.retryConfig.maxRetries})`),await this.sleep(o),i++}throw r}registerTelemetryHook(e){this.telemetryHooks.add(e)}unregisterTelemetryHook(e){this.telemetryHooks.delete(e)}ensureApplicationError(e,t){if(e instanceof pv.ApplicationError){if(t){let i=e,s={...e.context,...t};return new class extends pv.ApplicationError{constructor(){super(...arguments),this.code=i.code,this.retriable=i.retriable,this.guidance=i.guidance}}(e.message,s)}return e}return new class extends pv.ApplicationError{static{a(this,"UnknownError")}constructor(s,o){super(s,{originalError:o.name,...t}),this.code=YB.ErrorCode.UNKNOWN_ERROR,this.retriable=!1,this.guidance="An unexpected error occurred"}}(e.message,e)}formatError(e){let t=[];return t.push(`\u274C ${e.name}: ${e.message}`),e.guidance&&t.push(`\u{1F4A1} ${e.guidance}`),e.context&&Object.keys(e.context).length>0&&t.push(`Context: ${JSON.stringify(e.context,null,2)}`),t.join(`
455
+ \u2022 Contact support if the issue persists`}};eg.ServiceError=ov});var bR=S(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.ServiceError=or.ResourceExhaustedError=or.NotFoundError=or.PermissionError=or.StateTransitionError=or.NetworkError=or.ValidationError=or.ApplicationError=or.ErrorCode=void 0;var PB=ms();Object.defineProperty(or,"ErrorCode",{enumerable:!0,get:a(function(){return PB.ErrorCode},"get")});var OB=gs();Object.defineProperty(or,"ApplicationError",{enumerable:!0,get:a(function(){return OB.ApplicationError},"get")});var FB=dR();Object.defineProperty(or,"ValidationError",{enumerable:!0,get:a(function(){return FB.ValidationError},"get")});var DB=hR();Object.defineProperty(or,"NetworkError",{enumerable:!0,get:a(function(){return DB.NetworkError},"get")});var LB=pR();Object.defineProperty(or,"StateTransitionError",{enumerable:!0,get:a(function(){return LB.StateTransitionError},"get")});var NB=mR();Object.defineProperty(or,"PermissionError",{enumerable:!0,get:a(function(){return NB.PermissionError},"get")});var kB=gR();Object.defineProperty(or,"NotFoundError",{enumerable:!0,get:a(function(){return kB.NotFoundError},"get")});var MB=yR();Object.defineProperty(or,"ResourceExhaustedError",{enumerable:!0,get:a(function(){return MB.ResourceExhaustedError},"get")});var jB=_R();Object.defineProperty(or,"ServiceError",{enumerable:!0,get:a(function(){return jB.ServiceError},"get")})});var lv=S(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});tg.ShapeRegistry=void 0;var av=class{static{a(this,"ShapeRegistry")}constructor(){this.shapes=new Map}get(e){return this.shapes.get(e)}register(e){this.shapes.set(e.propertyIRI,e)}getAll(){return Array.from(this.shapes.values())}get size(){return this.shapes.size}};tg.ShapeRegistry=av});var fv=S(ys=>{"use strict";var $B=ys&&ys.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),UB=ys&&ys.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),cv=ys&&ys.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&$B(t,e,r[i]);return UB(t,e),t}})();Object.defineProperty(ys,"__esModule",{value:!0});ys.ShapeLoader=void 0;var uv=lv(),Xa=Ae(),Ef=$e(),Xr=er(),rg="http://www.w3.org/ns/shacl#",VB="http://www.w3.org/2001/XMLSchema#",sfe=[["exo__",Xr.Namespace.EXO],["ems__",Xr.Namespace.EMS],["exocmd__",Xr.Namespace.EXOCMD],["ims__",Xr.Namespace.IMS],["ztlk__",Xr.Namespace.ZTLK],["ptms__",Xr.Namespace.PTMS],["lit__",Xr.Namespace.LIT],["inbox__",Xr.Namespace.INBOX],["pmbok__",Xr.Namespace.PMBOK]],Tf=class n{static{a(this,"ShapeLoader")}static async loadFromVaultFS(e){let{readdir:t,readFile:r}=await Promise.resolve().then(()=>cv(require("fs/promises"))),i=await Promise.resolve().then(()=>cv(require("path"))),s=new uv.ShapeRegistry;return await n.scanDir(e,s,{readdir:t,readFile:r,path:i}),s}static async loadFromRDFGraph(e){let t=new uv.ShapeRegistry,r=Xr.Namespace.EXO,i=Xr.Namespace.RDFS,s=Xr.Namespace.RDF,[o,l]=await Promise.all([e.match(void 0,s.term("type"),r.term("ObjectProperty")),e.match(void 0,s.term("type"),r.term("Property"))]),c=new Set;for(let u of[...o,...l])u.subject instanceof Xa.IRI&&c.add(u.subject.value);for(let u of c){let f;try{f=new Xa.IRI(u)}catch{continue}let[d,h,p,g,_,v,w,E,I]=await Promise.all([e.match(f,i.term("domain"),void 0),e.match(f,r.term("Property_domain"),void 0),e.match(f,i.term("range"),void 0),e.match(f,r.term("Property_range"),void 0),e.match(f,r.term("Property_cardinality"),void 0),e.match(f,r.term("Property_severity"),void 0),e.match(f,r.term("Asset_label"),void 0),e.match(f,i.term("label"),void 0),e.match(f,r.term("Property_minCount"),void 0)]),O=[...w,...E],C=[...d,...h],H=[...p,...g];if(C.length===0)continue;let ne=null;for(let q of O)if(q.object instanceof Ef.Literal&&(ne=n.labelToIRI(q.object.value),ne))break;if(!ne)continue;let de=await Promise.all(C.map(async q=>q.object instanceof Xa.IRI?await n.resolveClassIRI(q.object.value,e):null)),N=Array.from(new Set(de.filter(q=>q!==null))),Y=await Promise.all(H.map(async q=>{if(q.object instanceof Xa.IRI)return await n.resolveClassIRI(q.object.value,e);if(q.object instanceof Ef.Literal){let U=q.object.value;if(U.startsWith("http://")||U.startsWith("https://"))return U}return null})),se=Array.from(new Set(Y.filter(q=>q!==null))),V=n.cardinalityFromIRI(_[0]?.object instanceof Xa.IRI?_[0].object.value:void 0),X=n.severityFromValue(v[0]?.object instanceof Ef.Literal||v[0]?.object instanceof Xa.IRI?v[0].object.value:void 0),re=I[0]?.object,G=re instanceof Ef.Literal?parseInt(re.value,10):NaN,ie=isNaN(G)?void 0:G;t.register({propertyIRI:ne,domain:N,range:se.length>0?se:void 0,cardinality:V,severity:X,minCount:ie})}return t}static async loadFromShapeJSON(e){let{readFile:t}=await Promise.resolve().then(()=>cv(require("fs/promises"))),r=await t(e,"utf-8"),i=JSON.parse(r),s=new uv.ShapeRegistry;for(let o of Object.values(i.shapes))s.register(o);return s}static async resolveClassIRI(e,t){if(e.startsWith("https://exocortex.my/ontology/")||e.startsWith("http://www.w3.org/"))return e;let r;try{r=new Xa.IRI(e)}catch{return null}let i=Xr.Namespace.RDFS,s=Xr.Namespace.EXO,[o,l]=await Promise.all([t.match(r,i.term("label"),void 0),t.match(r,s.term("Asset_label"),void 0)]);for(let c of[...o,...l])if(c.object instanceof Ef.Literal){let u=n.labelToIRI(c.object.value);if(u)return u}return e}static async scanDir(e,t,r){let i;try{i=await r.readdir(e,{withFileTypes:!0})}catch{return}for(let s of i){let o=r.path.join(e,s.name);if(s.isDirectory())await n.scanDir(o,t,r);else if(s.isFile()&&s.name.endsWith(".md"))try{await n.processFile(o,t,r.readFile,r.path)}catch{}}}static async processFile(e,t,r,i){let s;try{s=await r(e,"utf-8")}catch{return}let o=n.parseFrontmatter(s);if(!o)return;let l="38277bfa-d7f9-4a75-b856-b23276ab0db3",c="9a1cf31c-9d41-4ef3-9023-584a8d087d16";if(!n.asArray(o.exo__Instance_class).some(N=>{let Y=n.extractWikilinkRef(N);return Y==="exo__Property"||Y==="exo__ObjectProperty"||Y===l||Y===c||Y?.includes("|exo__Property")||Y?.includes("|exo__ObjectProperty")}))return;let d=null,h=o.exo__Asset_label;if(typeof h=="string"&&h.trim().length>0)d=h.trim();else if(i){let N=i.basename(e,".md");Xr.Namespace.fromPropertyKey(N)&&(d=N)}if(!d)return;let p=n.labelToIRI(d);if(!p)return;let g=o.exo__Property_domain,_=o.exo__Property_range,v=o.exo__Property_cardinality,w=o.exo__Property_severity,E=o.exo__Property_minCount,I=n.asArray(g).map(N=>n.wikilinkToIRI(N)).filter(N=>N!==null);if(I.length===0)return;let O=n.asArray(_).map(N=>n.wikilinkToIRI(N)).filter(N=>N!==null),C=n.cardinalityFromLabel(typeof v=="string"?v:void 0),H=n.severityFromValue(typeof w=="string"?w:void 0),ne=typeof E=="string"?parseInt(E,10):void 0,de=ne!==void 0&&!isNaN(ne)?ne:void 0;t.register({propertyIRI:p,domain:I,range:O.length>0?O:void 0,cardinality:C,severity:H,minCount:de})}static parseFrontmatter(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!t)return null;let r=t[1],i={},s=r.split(/\r?\n/),o=null,l=null;for(let c of s){let u=/^ {2}- (.*)$/.exec(c);if(u){o&&l&&l.push(u[1].trim());continue}o&&l&&(i[o]=l,o=null,l=null);let f=/^([^:]+):\s*(.*)$/.exec(c);if(!f)continue;let d=f[1].trim(),h=f[2].trim();h===""?(o=d,l=[]):i[d]=h}return o&&l&&(i[o]=l),i}static labelToIRI(e){let t=Xr.Namespace.fromPropertyKey(e);if(!t)return null;try{return t.namespace.term(t.localName).value}catch{return null}}static extractWikilinkRef(e){let t=e.replace(/^["']|["']$/g,""),r=/\[\[([^\]]+)\]\]/.exec(t);return r?r[1]:t}static wikilinkToIRI(e){let t=n.extractWikilinkRef(e);if(!t)return null;let r=t.split("|"),i=r.length>1?[r[1],r[0]]:[r[0]];for(let s of i){let o=n.labelToIRI(s.trim());if(o)return o}return t.startsWith("http")?t:t.startsWith("sh:")?rg+t.substring(3):t.startsWith("xsd:")?VB+t.substring(4):null}static asArray(e){return Array.isArray(e)?e.map(String):typeof e=="string"?[e]:[]}static cardinalityFromIRI(e){if(e){if(e.endsWith("PropertyCardinalitySingle"))return"Single";if(e.endsWith("PropertyCardinalityMultiple"))return"Multiple";if(e.includes(n.CARDINALITY_SINGLE_UID))return"Single";if(e.includes(n.CARDINALITY_MULTIPLE_UID))return"Multiple"}}static cardinalityFromLabel(e){if(!e)return;let t=n.extractWikilinkRef(e)??e,r=t.split("|").pop()??t;if(r.includes("Single"))return"Single";if(r.includes("Multiple"))return"Multiple";if(t.includes(n.CARDINALITY_SINGLE_UID))return"Single";if(t.includes(n.CARDINALITY_MULTIPLE_UID))return"Multiple"}static severityFromValue(e){return!e||e.includes("Violation")||e===rg+"Violation"?"sh:Violation":e.includes("Warning")||e===rg+"Warning"?"sh:Warning":e.includes("Info")||e===rg+"Info"?"sh:Info":"sh:Violation"}};ys.ShapeLoader=Tf;Tf.CARDINALITY_SINGLE_UID="c93c4b2f-b43d-4cc9-8dd0-31514d608da2";Tf.CARDINALITY_MULTIPLE_UID="59a37aa7-ffbe-4e0d-ba60-06ae370d880f"});var hv=S(If=>{"use strict";Object.defineProperty(If,"__esModule",{value:!0});If.ShapeRegistry=void 0;If.validate=QB;var dv=class{static{a(this,"ShapeRegistry")}constructor(e=[],t="https://exocortex.my/ontology/exo#Instance_class"){this.shapeMap=new Map(e.map(r=>[r.propertyIRI,r])),this.typePredicateIRI=t}getShape(e){return this.shapeMap.get(e)}getAllShapes(){return Array.from(this.shapeMap.values())}hasShape(e){return this.shapeMap.has(e)}};If.ShapeRegistry=dv;var BB="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",GB=["http://www.w3.org/2001/XMLSchema#","http://www.w3.org/1999/02/22-rdf-syntax-ns#","http://www.w3.org/2000/01/rdf-schema#","http://www.w3.org/2002/07/owl#","http://www.w3.org/2004/02/skos/core#","http://purl.org/dc/elements/1.1/","http://purl.org/dc/terms/","http://xmlns.com/foaf/0.1/","https://schema.org/","https://exocortex.my/ontology/xsd#","https://exocortex.my/ontology/rdf#","https://exocortex.my/ontology/rdfs#","https://exocortex.my/ontology/owl#","https://exocortex.my/ontology/skos#"];function qB(n){return GB.some(e=>n.startsWith(e))}a(qB,"isExternalOntologyIRI");var WB=["http://www.w3.org/2001/XMLSchema#","https://exocortex.my/ontology/xsd#"];function zB(n){return WB.some(e=>n.startsWith(e))}a(zB,"isXSDDatatypeIRI");var HB=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function SR(n){let e=HB.exec(n);return e?e[1].toLowerCase():null}a(SR,"extractUid");function QB(n,e,t,r){let i=new Map,s=new Map;for(let c of n){let{subject:u,predicate:f,object:d}=c;if(u.type!=="iri"||f.type!=="iri"||d.type!=="iri"&&d.type!=="literal")continue;let h=u.value,p=f.value,g=d;if(p===e.typePredicateIRI||p===BB){if(g.type==="iri"){let v=i.get(h)??[];v.push(g.value),i.set(h,v);let w=SR(h);if(w){let E=`uid:${w}`,I=i.get(E)??[];I.push(g.value),i.set(E,I)}}}else{let v=s.get(h);v||(v=new Map,s.set(h,v));let w=v.get(p)??[];w.push(g),v.set(p,w)}}let o=[],l=new Set([...i.keys(),...s.keys()]);for(let c of l){let u=i.get(c)??[],f=s.get(c)??new Map;for(let d of e.getAllShapes()){if(!(d.domain.length===0||d.domain.some(g=>u.some(_=>_===g||t.isSubClassOf(_,g)))))continue;let p=f.get(d.propertyIRI)??[];if(d.minCount!==void 0&&d.minCount>0&&p.length<d.minCount){o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:minCount violation: expected at least ${d.minCount} value(s) for <${d.propertyIRI}>`});continue}if(p.length!==0){if(d.cardinality==="Single"&&p.length>1){o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:maxCount violation: expected at most 1 value for <${d.propertyIRI}>, got ${p.length}`});continue}if(d.range&&d.range.length>0){for(let g of p)if(g.type==="iri"){if(qB(g.value))continue;let _=i.get(g.value)??[];if(_.length===0){let w=SR(g.value);w&&(_=i.get(`uid:${w}`)??[])}d.range.some(w=>_.some(E=>E===w||t.isSubClassOf(E,w)))||o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:class violation: <${g.value}> does not conform to expected class ${d.range.join(" | ")}`,actualValue:g.value,expectedRange:d.range.join(" | ")})}else if(g.type==="literal"){let _=d.range.filter(E=>zB(E));if(_.length===0)continue;let v=g.datatype??"http://www.w3.org/2001/XMLSchema#string";_.some(E=>E===v)||o.push({focusNode:c,propertyPath:d.propertyIRI,severity:d.severity,message:d.message??`sh:datatype violation: literal "${g.value}" has datatype <${v}>, expected ${_.join(" | ")}`,actualValue:g.value,expectedRange:_.join(" | ")})}}}}}if(r?.closedWorldMode)for(let c of l){let u=s.get(c)??new Map;for(let f of u.keys())e.hasShape(f)||o.push({focusNode:c,propertyPath:f,severity:"sh:Warning",message:`Unknown property: <${f}> has no registered shape`})}return o.sort((c,u)=>{let f=c.focusNode.localeCompare(u.focusNode);return f!==0?f:c.propertyPath.localeCompare(u.propertyPath)}),{conforms:!o.some(c=>c.severity==="sh:Violation"),violations:o}}a(QB,"validate")});var wR=S(ng=>{"use strict";Object.defineProperty(ng,"__esModule",{value:!0});ng.ApplicationErrorHandler=void 0;var pv=gs(),YB=ms(),XB=$o(),mv=class{static{a(this,"ApplicationErrorHandler")}constructor(e={},t,r){this.logger=t,this.notifier=r,this.telemetryHooks=new Set,this.retryConfig={maxRetries:e.maxRetries??3,initialDelayMs:e.initialDelayMs??1e3,backoffMultiplier:e.backoffMultiplier??2,maxDelayMs:e.maxDelayMs??1e4}}handle(e,t){let r=this.ensureApplicationError(e,t);return this.notifier&&this.notifier.error(r.message),this.callTelemetryHooks("onError",r,t),this.formatError(r)}async executeWithRetry(e,t){let r,i=0;for(;i<=this.retryConfig.maxRetries;)try{return await e()}catch(s){if(r=this.ensureApplicationError(s,t),!r.retriable||i>=this.retryConfig.maxRetries)throw this.callTelemetryHooks("onError",r,t),i>=this.retryConfig.maxRetries&&r.retriable&&this.callTelemetryHooks("onRetryExhausted",r,i+1),r;let o=this.calculateDelay(i);this.callTelemetryHooks("onRetry",r,i+1,o),this.logger?.debug(`Retrying after ${o}ms (attempt ${i+1}/${this.retryConfig.maxRetries})`),await this.sleep(o),i++}throw r}registerTelemetryHook(e){this.telemetryHooks.add(e)}unregisterTelemetryHook(e){this.telemetryHooks.delete(e)}ensureApplicationError(e,t){if(e instanceof pv.ApplicationError){if(t){let i=e,s={...e.context,...t};return new class extends pv.ApplicationError{constructor(){super(...arguments),this.code=i.code,this.retriable=i.retriable,this.guidance=i.guidance}}(e.message,s)}return e}return new class extends pv.ApplicationError{static{a(this,"UnknownError")}constructor(s,o){super(s,{originalError:o.name,...t}),this.code=YB.ErrorCode.UNKNOWN_ERROR,this.retriable=!1,this.guidance="An unexpected error occurred"}}(e.message,e)}formatError(e){let t=[];return t.push(`\u274C ${e.name}: ${e.message}`),e.guidance&&t.push(`\u{1F4A1} ${e.guidance}`),e.context&&Object.keys(e.context).length>0&&t.push(`Context: ${JSON.stringify(e.context,null,2)}`),t.join(`
456
456
  `)}calculateDelay(e){let t=this.retryConfig.initialDelayMs*Math.pow(this.retryConfig.backoffMultiplier,e);return Math.min(t,this.retryConfig.maxDelayMs)}sleep(e){return new Promise(t=>setTimeout(t,e))}callTelemetryHooks(e,...t){for(let r of this.telemetryHooks)try{let i=r[e];i&&i.apply(r,t)}catch(i){XB.LoggingService.error("Error in telemetry hook",i instanceof Error?i:new Error(String(i)))}}};ng.ApplicationErrorHandler=mv});var vR=S(ig=>{"use strict";Object.defineProperty(ig,"__esModule",{value:!0});ig.ApplicationErrorHandler=void 0;var KB=wR();Object.defineProperty(ig,"ApplicationErrorHandler",{enumerable:!0,get:a(function(){return KB.ApplicationErrorHandler},"get")})});var yv=S(sg=>{"use strict";Object.defineProperty(sg,"__esModule",{value:!0});sg.ClassHierarchy=void 0;var JB="http://www.w3.org/2000/01/rdf-schema#subClassOf",gv=class{static{a(this,"ClassHierarchy")}constructor(e){this.adjacency=new Map;for(let t of e){if(t.predicate.type!=="iri"||t.predicate.value!==JB||t.subject.type!=="iri"||t.object.type!=="iri")continue;let r=t.subject.value,i=t.object.value,s=this.adjacency.get(r);s||(s=new Set,this.adjacency.set(r,s)),s.add(i)}}isSubClassOf(e,t){if(e===t)return!0;let r=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(s===void 0)break;if(r.has(s))continue;r.add(s);let o=this.adjacency.get(s);if(o)for(let l of o){if(l===t)return!0;r.has(l)||i.push(l)}}return!1}getAncestors(e){let t=new Set,r=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(s===void 0)break;if(r.has(s))continue;r.add(s);let o=this.adjacency.get(s);if(o)for(let l of o)t.add(l),r.has(l)||i.push(l)}return t}};sg.ClassHierarchy=gv});var TR=S(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.ValidatorDaemon=_s.IDLE_TIMEOUT_MS=_s.DEFAULT_SOCKET_PATH=void 0;var ER=hv(),ZB=fv(),eG=yv();_s.DEFAULT_SOCKET_PATH=typeof process<"u"&&process.env?`${process.env.HOME??process.env.USERPROFILE??"/tmp"}/.cache/exocortex/validator.sock`:"/tmp/.cache/exocortex/validator.sock";_s.IDLE_TIMEOUT_MS=300*1e3;var _v=class{static{a(this,"ValidatorDaemon")}constructor(e=_s.DEFAULT_SOCKET_PATH,t=_s.IDLE_TIMEOUT_MS){this.registryCache=new Map,this.server=null,this.idleTimer=null,this.socketPath=e,this.idleTimeoutMs=t}async start(){let e=require("net"),t=require("fs/promises"),r=require("path");await t.mkdir(r.dirname(this.socketPath),{recursive:!0});try{await t.unlink(this.socketPath)}catch{}this.server=e.createServer(o=>{this.handleConnection(o)});let i=this.server;await new Promise((o,l)=>{i.on("error",l),i.listen(this.socketPath,o)}),this.resetIdleTimer();let s=a(()=>{this.stop()},"handleSignal");process.once("SIGTERM",s),process.once("SIGINT",s)}async stop(){if(this.idleTimer!==null&&(clearTimeout(this.idleTimer),this.idleTimer=null),!this.server)return;let e=this.server;this.server=null,await new Promise(t=>{e.close(()=>t())})}resetIdleTimer(){this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{process.exit(0)},this.idleTimeoutMs)}handleConnection(e){let t="";e.setEncoding("utf-8"),e.on("data",r=>{t+=r;let i=t.split(`
457
457
  `);t=i.pop()??"";for(let s of i){let o=s.trim();o&&this.handleRequest(o,e)}}),e.on("error",()=>{e.destroy()})}async handleRequest(e,t){this.resetIdleTimer();let r;try{let i=JSON.parse(e),s=await this.getRegistry(i.registryPath),o=new eG.ClassHierarchy(i.subclassTriples??[]);r={report:(0,ER.validate)(i.triples,s,o,{closedWorldMode:i.closedWorldMode})}}catch(i){r={error:i instanceof Error?i.message:String(i)}}t.destroyed||t.write(JSON.stringify(r)+`
458
458
  `)}async getRegistry(e){let t=this.registryCache.get(e);if(t)return t;let r=await ZB.ShapeLoader.loadFromShapeJSON(e),i=new ER.ShapeRegistry(r.getAll());return this.registryCache.set(e,i),i}};_s.ValidatorDaemon=_v});var RR=S(og=>{"use strict";Object.defineProperty(og,"__esModule",{value:!0});og.parseTarball=AR;og.parseTarballGzip=oG;var tG={0:"file",1:"hardLink",2:"symbolicLink",3:"characterDevice",4:"blockDevice",5:"directory",6:"fifo",7:"contiguousFile",g:"globalExtendedHeader",x:"extendedHeader",D:"gnuDirectory",I:"gnuInodeMetadata",K:"gnuLongLinkName",L:"gnuLongFileName",N:"gnuOldLongFileName",M:"gnuMultiVolume",S:"gnuSparseFile",E:"gnuExtendedSparse"},rG=new Set(["extendedHeader","globalExtendedHeader","gnuLongFileName","gnuOldLongFileName","gnuLongLinkName"]),IR;function xR(){return IR??(IR=new TextDecoder)}a(xR,"getDecoder");function xf(n,e,t){let r=n.subarray(e,e+t),i=r.indexOf(0);return xR().decode(i===-1?r:r.subarray(0,i))}a(xf,"readString");function nG(n,e,t){let r="";for(let s=0;s<t;s++)r+=String.fromCodePoint(n[e+s]);let i=Number.parseInt(r,8);return Number.isNaN(i)?0:i}a(nG,"readNumber");function iG(n){let e=xR().decode(n),t={};for(let r of e.split(`
459
- `)){let i=r.indexOf("=");if(i===-1)continue;let s=r.slice(r.indexOf(" ")+1,i),o=r.slice(i+1);s&&(t[s]=o)}return t}a(iG,"parseExtendedHeaders");function sG(n){let e=n.replace(/\\/g,"/");e=e.replace(/^[a-zA-Z]:\//,""),e=e.replace(/^\/+/,"");let t=e.startsWith("./"),r=e.split("/"),i=[];for(let o of r)o===".."?i.pop():o!=="."&&o!==""&&i.push(o);let s=i.join("/");return t&&!s.startsWith("./")&&(s="./"+s),n.endsWith("/")&&!s.endsWith("/")&&(s+="/"),s}a(sG,"sanitizePath");function AR(n){let e=n.byteOffset===0&&n.byteLength===n.buffer.byteLength?n:n.slice(),t=[],r=0,i,s;for(;r+512<=e.byteLength;){let o=xf(e,r,100);if(o.length===0)break;let l=!1;if(i){let p=i.path??i.linkpath;p&&(o=p,l=!0)}let c=nG(e,r+124,12),u=512+512*Math.trunc(c/512)+(c%512?512:0),f=xf(e,r+156,1)||"0",d=tG[f]??f;if(d==="extendedHeader"||d==="globalExtendedHeader"){let p=iG(e.subarray(r+512,r+512+c));d==="extendedHeader"?i=p:(i=void 0,s={...s,...p}),r+=u;continue}if(rG.has(d)){i={path:xf(e,r+512,c)},r+=u;continue}if(!l&&xf(e,r+257,6).startsWith("ustar")){let g=xf(e,r+345,155);g.length>0&&(o=`${g}/${o}`)}o=sG(o);let h=c===0?void 0:e.subarray(r+512,r+512+c);t.push({name:o,type:d,size:c,data:h}),i=void 0,r+=u}return t}a(AR,"parseTarball");async function oG(n){let e=new Uint8Array(n instanceof Uint8Array?n:new Uint8Array(n)),t=new DecompressionStream("gzip"),r=t.writable.getWriter(),[,i]=await Promise.all([r.write(e).then(()=>r.close()),new Response(t.readable).arrayBuffer()]);return AR(new Uint8Array(i))}a(oG,"parseTarballGzip")});var It=S(m=>{"use strict";var aG=m&&m.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),oi=m&&m.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&aG(e,n,t)};Object.defineProperty(m,"__esModule",{value:!0});m.FolderRepairService=m.EffortVotingService=m.WorkflowCommandAdapter=m.VisibilityGenerator=m.InstantiationRuleResolver=m.WorkflowResolver=m.WorkflowEngine=m.EffortStatusWorkflow=m.ConceptCreationService=m.ClassCreationService=m.AreaHierarchyBuilder=m.AreaCreationService=m.TaskStatusService=m.CommandExecutionFlow=m.createVaultFrontmatterClassLabelResolver=m.ServiceRegistry=m.GroundingExecutor=m.registerDefaultHostFunctions=m.hasUidFilename=m.hasNonUidFilename=m.PreconditionEvaluator=m.CommandResolver=m.extractPropertyLabel=m.uriToPropertyName=m.propertyNameToUri=m.rangeToFieldType=m.PropertyFieldType=m.parseGroundingDefinitionFromFrontmatter=m.isCommandBindingFrontmatter=m.isGroundingFrontmatter=m.isPreconditionFrontmatter=m.isCommandFrontmatter=m.isStyleSource=m.isLabelClass=m.isCommandVariant=m.STYLE_SOURCE_VALUES=m.LABEL_CLASS_VALUES=m.COMMAND_VARIANT_VALUES=m.CommandBindingStyleProperty=m.CommandBindingProperty=m.GroundingProperty=m.PreconditionProperty=m.CommandProperty=m.resolveGroundingTypeFromWikilinkLiteral=m.resolveGroundingTypeFromIRI=m.GROUNDING_TYPE_IRI_TO_ENUM=m.GROUNDING_TYPE_UID_TO_ENUM=m.GROUNDING_TYPE_UIDS=m.GroundingType=m.EFFORT_STATUS_OPTIONS=void 0;m.NullLogger=m.RDFSerializer=m.FilenameValidator=m.EffortSortingHelpers=m.MetadataExtractor=m.MetadataHelpers=m.WikiLinkHelpers=m.DateFormatter=m.FrontmatterService=m.CriticalityZoneUUIDs=m.CriticalityZoneService=m.getTemplateByName=m.validateParameters=m.fillTemplate=m.findMatchingTemplates=m.findClassByTerm=m.KNOWN_CLASSES=m.KNOWN_PROTOTYPES=m.EFFORT_STATUSES=m.ASSET_CLASSES=m.PREDICATES=m.SPARQL_PREFIXES=m.SPARQL_TEMPLATES=m.DEFAULT_NL_TO_SPARQL_CONFIG=m.NLToSPARQLService=m.TypeRegistry=m.GraphQueryService=m.FixMissingLabelService=m.ArchiveAssetService=m.GenericAssetCreationService=m.URIConstructionService=m.SessionEventService=m.AssetConversionService=m.EnumValueResolver=m.ClassHierarchyResolver=m.PropertySchemaResolver=m.PlanningService=m.AlgorithmExtractor=m.orderProperties=m.loadDefaultSpec=m.clearOrderSpecLoader=m.registerOrderSpecLoader=m.DynamicFrontmatterGenerator=m.SupervisionCreationService=m.StatusTimestampService=m.RenameToUidService=m.PropertyCleanupService=m.LoggingService=m.LabelToAliasService=m.extractAssetReference=void 0;m.medianAggregate=m.EXO_AGGREGATE_NS=m.BUILT_IN_AGGREGATES=m.CustomAggregateError=m.CustomAggregateRegistry=m.AggregateFunctions=m.BuiltInFunctions=m.SolutionMapping=m.UpdateExecutorError=m.UpdateExecutor=m.QueryExecutor=m.ExoQLQueryExecutor=m.DescribeExecutor=m.ConstructExecutor=m.UnionExecutor=m.OptionalExecutor=m.FilterExecutor=m.BGPExecutor=m.AlgebraSerializer=m.AlgebraOptimizer=m.AlgebraTranslator=m.ExoQLAlgebraTranslator=m.DescribeOptionsTransformerError=m.DescribeOptionsTransformer=m.SPARQLParseError=m.SPARQLParser=m.ExoQLParser=m.shouldSkipFileForEffectiveSet=m.isPathExcluded=m.normaliseExcludedFolders=m.NoteToRDFConverter=m.SOURCE_VARIABLE=m.SourceAnnotator=m.MAX_LAZY_DEPTH=m.LazyAssetGraphLoader=m.IRICanonicalizer=m.INFERRED_GRAPH=m.PrototypeChainMaterializer=m.PropertyCardinalityRegistry=m.NonInheritablePropertyRegistry=m.RDFSInferenceEngine=m.RDFVocabularyMapper=m.DomainTriple=m.DomainBlankNode=m.DomainLiteral=m.DomainIRI=m.InMemoryTripleStore=m.OBSIDIAN_VAULT_SCHEME=m.iriToVaultPath=m.vaultPathToIRI=void 0;m.createRelationColumnSetFromFrontmatter=m.RELATION_COLUMN_SET_CLASS_UID=m.RELATION_COLUMN_SET_CLASS_IRI=m.ExoQLError=m.ExoQL=m.createStreamingSource=m.StreamingLoader=m.resetGlobalPool=m.getGlobalPool=m.MemoryPool=m.CompactGraphStore=m.StringTable=m.DEFAULT_COLORS=m.NODE_FLAGS=m.container=m.resetContainer=m.getContainer=m.createChildContainer=m.registerCoreServices=m.DI_TOKENS=m.DEFAULT_FLEETING_NOTE_CLASS_UID=m.DEFAULT_INBOX_FOLDER=m.DEFAULT_OWNER_IDENTITY=m.VaultSettings=m.seededUidGenerator=m.liveUidGenerator=m.frozenClock=m.liveClock=m.TransactionError=m.TripleNotFoundError=m.TripleAlreadyExistsError=m.FileAlreadyExistsError=m.FileNotFoundError=m.FilterContainsOptimizer=m.VaultPrefixTransformer=m.CaseWhenTransformerError=m.CaseWhenTransformer=m.ResultSerializer=m.createIncrementalIndexer=m.IncrementalIndexer=m.createSPARQLResultCache=m.SPARQLResultCache=m.QueryPlanCache=m.createDoubleLiteral=m.createDecimalLiteral=m.getNumericValue=m.createPercentileAggregate=m.modeAggregate=m.stddevAggregate=m.varianceAggregate=void 0;m.parseTarballGzip=m.parseTarball=m.TripleClassHierarchy=m.IDLE_TIMEOUT_MS=m.DEFAULT_SOCKET_PATH=m.ValidatorDaemon=m.ShaclShapeRegistry=m.shaclValidate=m.Namespace=m.ShapeRegistry=m.ShapeLoader=m.selectByPriority=m.LayoutSelector=m.isPropertiesBlock=m.isLayoutBlockFrontmatter=m.isBacklinksTableBlock=m.createLayoutBlockFromFrontmatter=m.PROPERTIES_BLOCK_CLASS_UID=m.PROPERTIES_BLOCK_CLASS_IRI=m.BACKLINKS_TABLE_BLOCK_CLASS_UID=m.BACKLINKS_TABLE_BLOCK_CLASS_IRI=m.isLayoutFrontmatter=m.isLayout=m.createLayoutFromFrontmatter=m.LAYOUT_CLASS_UID=m.LAYOUT_CLASS_IRI=m.RelationColumnSetResolver=m.normalizeRelationColumnSetRef=m.isRelationColumnSetFrontmatter=m.isRelationColumnSet=void 0;oi(Il(),m);oi(xl(),m);var lG=T0();Object.defineProperty(m,"EFFORT_STATUS_OPTIONS",{enumerable:!0,get:a(function(){return lG.EFFORT_STATUS_OPTIONS},"get")});var cG=Io();Object.defineProperty(m,"GroundingType",{enumerable:!0,get:a(function(){return cG.GroundingType},"get")});var Af=Cu();Object.defineProperty(m,"GROUNDING_TYPE_UIDS",{enumerable:!0,get:a(function(){return Af.GROUNDING_TYPE_UIDS},"get")});Object.defineProperty(m,"GROUNDING_TYPE_UID_TO_ENUM",{enumerable:!0,get:a(function(){return Af.GROUNDING_TYPE_UID_TO_ENUM},"get")});Object.defineProperty(m,"GROUNDING_TYPE_IRI_TO_ENUM",{enumerable:!0,get:a(function(){return Af.GROUNDING_TYPE_IRI_TO_ENUM},"get")});Object.defineProperty(m,"resolveGroundingTypeFromIRI",{enumerable:!0,get:a(function(){return Af.resolveGroundingTypeFromIRI},"get")});Object.defineProperty(m,"resolveGroundingTypeFromWikilinkLiteral",{enumerable:!0,get:a(function(){return Af.resolveGroundingTypeFromWikilinkLiteral},"get")});var Rf=I0();Object.defineProperty(m,"CommandProperty",{enumerable:!0,get:a(function(){return Rf.CommandProperty},"get")});Object.defineProperty(m,"PreconditionProperty",{enumerable:!0,get:a(function(){return Rf.PreconditionProperty},"get")});Object.defineProperty(m,"GroundingProperty",{enumerable:!0,get:a(function(){return Rf.GroundingProperty},"get")});Object.defineProperty(m,"CommandBindingProperty",{enumerable:!0,get:a(function(){return Rf.CommandBindingProperty},"get")});Object.defineProperty(m,"CommandBindingStyleProperty",{enumerable:!0,get:a(function(){return Rf.CommandBindingStyleProperty},"get")});var Pc=x0();Object.defineProperty(m,"COMMAND_VARIANT_VALUES",{enumerable:!0,get:a(function(){return Pc.COMMAND_VARIANT_VALUES},"get")});Object.defineProperty(m,"LABEL_CLASS_VALUES",{enumerable:!0,get:a(function(){return Pc.LABEL_CLASS_VALUES},"get")});Object.defineProperty(m,"STYLE_SOURCE_VALUES",{enumerable:!0,get:a(function(){return Pc.STYLE_SOURCE_VALUES},"get")});Object.defineProperty(m,"isCommandVariant",{enumerable:!0,get:a(function(){return Pc.isCommandVariant},"get")});Object.defineProperty(m,"isLabelClass",{enumerable:!0,get:a(function(){return Pc.isLabelClass},"get")});Object.defineProperty(m,"isStyleSource",{enumerable:!0,get:a(function(){return Pc.isStyleSource},"get")});var ag=PT();Object.defineProperty(m,"isCommandFrontmatter",{enumerable:!0,get:a(function(){return ag.isCommandFrontmatter},"get")});Object.defineProperty(m,"isPreconditionFrontmatter",{enumerable:!0,get:a(function(){return ag.isPreconditionFrontmatter},"get")});Object.defineProperty(m,"isGroundingFrontmatter",{enumerable:!0,get:a(function(){return ag.isGroundingFrontmatter},"get")});Object.defineProperty(m,"isCommandBindingFrontmatter",{enumerable:!0,get:a(function(){return ag.isCommandBindingFrontmatter},"get")});var uG=FT();Object.defineProperty(m,"parseGroundingDefinitionFromFrontmatter",{enumerable:!0,get:a(function(){return uG.parseGroundingDefinitionFromFrontmatter},"get")});oi(DT(),m);oi(LT(),m);oi(R0(),m);oi(C0(),m);oi(kT(),m);oi($T(),m);oi(u_(),m);oi(_I(),m);var CR=yh();Object.defineProperty(m,"PropertyFieldType",{enumerable:!0,get:a(function(){return CR.PropertyFieldType},"get")});Object.defineProperty(m,"rangeToFieldType",{enumerable:!0,get:a(function(){return CR.rangeToFieldType},"get")});var bv=h_();Object.defineProperty(m,"propertyNameToUri",{enumerable:!0,get:a(function(){return bv.propertyNameToUri},"get")});Object.defineProperty(m,"uriToPropertyName",{enumerable:!0,get:a(function(){return bv.uriToPropertyName},"get")});Object.defineProperty(m,"extractPropertyLabel",{enumerable:!0,get:a(function(){return bv.extractPropertyLabel},"get")});var fG=rA();Object.defineProperty(m,"CommandResolver",{enumerable:!0,get:a(function(){return fG.CommandResolver},"get")});var dG=iA();Object.defineProperty(m,"PreconditionEvaluator",{enumerable:!0,get:a(function(){return dG.PreconditionEvaluator},"get")});var Sv=sA();Object.defineProperty(m,"hasNonUidFilename",{enumerable:!0,get:a(function(){return Sv.hasNonUidFilename},"get")});Object.defineProperty(m,"hasUidFilename",{enumerable:!0,get:a(function(){return Sv.hasUidFilename},"get")});Object.defineProperty(m,"registerDefaultHostFunctions",{enumerable:!0,get:a(function(){return Sv.registerDefaultHostFunctions},"get")});var PR=fA();Object.defineProperty(m,"GroundingExecutor",{enumerable:!0,get:a(function(){return PR.GroundingExecutor},"get")});Object.defineProperty(m,"ServiceRegistry",{enumerable:!0,get:a(function(){return PR.ServiceRegistry},"get")});var hG=dA();Object.defineProperty(m,"createVaultFrontmatterClassLabelResolver",{enumerable:!0,get:a(function(){return hG.createVaultFrontmatterClassLabelResolver},"get")});var pG=hA();Object.defineProperty(m,"CommandExecutionFlow",{enumerable:!0,get:a(function(){return pG.CommandExecutionFlow},"get")});var mG=U1();Object.defineProperty(m,"TaskStatusService",{enumerable:!0,get:a(function(){return mG.TaskStatusService},"get")});var gG=q1();Object.defineProperty(m,"AreaCreationService",{enumerable:!0,get:a(function(){return gG.AreaCreationService},"get")});var yG=z1();Object.defineProperty(m,"AreaHierarchyBuilder",{enumerable:!0,get:a(function(){return yG.AreaHierarchyBuilder},"get")});var _G=Q1();Object.defineProperty(m,"ClassCreationService",{enumerable:!0,get:a(function(){return _G.ClassCreationService},"get")});var bG=X1();Object.defineProperty(m,"ConceptCreationService",{enumerable:!0,get:a(function(){return bG.ConceptCreationService},"get")});var SG=sm();Object.defineProperty(m,"EffortStatusWorkflow",{enumerable:!0,get:a(function(){return SG.EffortStatusWorkflow},"get")});var wG=uf();Object.defineProperty(m,"WorkflowEngine",{enumerable:!0,get:a(function(){return wG.WorkflowEngine},"get")});var vG=R1();Object.defineProperty(m,"WorkflowResolver",{enumerable:!0,get:a(function(){return vG.WorkflowResolver},"get")});var EG=RA();Object.defineProperty(m,"InstantiationRuleResolver",{enumerable:!0,get:a(function(){return EG.InstantiationRuleResolver},"get")});var TG=CA();Object.defineProperty(m,"VisibilityGenerator",{enumerable:!0,get:a(function(){return TG.VisibilityGenerator},"get")});var IG=PA();Object.defineProperty(m,"WorkflowCommandAdapter",{enumerable:!0,get:a(function(){return IG.WorkflowCommandAdapter},"get")});var xG=nS();Object.defineProperty(m,"EffortVotingService",{enumerable:!0,get:a(function(){return xG.EffortVotingService},"get")});var AG=aS();Object.defineProperty(m,"FolderRepairService",{enumerable:!0,get:a(function(){return AG.FolderRepairService},"get")});var RG=sS();Object.defineProperty(m,"extractAssetReference",{enumerable:!0,get:a(function(){return RG.extractAssetReference},"get")});var CG=cS();Object.defineProperty(m,"LabelToAliasService",{enumerable:!0,get:a(function(){return CG.LabelToAliasService},"get")});var PG=$o();Object.defineProperty(m,"LoggingService",{enumerable:!0,get:a(function(){return PG.LoggingService},"get")});var OG=dS();Object.defineProperty(m,"PropertyCleanupService",{enumerable:!0,get:a(function(){return OG.PropertyCleanupService},"get")});var FG=pS();Object.defineProperty(m,"RenameToUidService",{enumerable:!0,get:a(function(){return FG.RenameToUidService},"get")});var DG=am();Object.defineProperty(m,"StatusTimestampService",{enumerable:!0,get:a(function(){return DG.StatusTimestampService},"get")});var LG=yS();Object.defineProperty(m,"SupervisionCreationService",{enumerable:!0,get:a(function(){return LG.SupervisionCreationService},"get")});var NG=bS();Object.defineProperty(m,"DynamicFrontmatterGenerator",{enumerable:!0,get:a(function(){return NG.DynamicFrontmatterGenerator},"get")});var lg=af();Object.defineProperty(m,"registerOrderSpecLoader",{enumerable:!0,get:a(function(){return lg.registerOrderSpecLoader},"get")});Object.defineProperty(m,"clearOrderSpecLoader",{enumerable:!0,get:a(function(){return lg.clearOrderSpecLoader},"get")});Object.defineProperty(m,"loadDefaultSpec",{enumerable:!0,get:a(function(){return lg.loadDefaultSpec},"get")});Object.defineProperty(m,"orderProperties",{enumerable:!0,get:a(function(){return lg.orderProperties},"get")});var kG=wS();Object.defineProperty(m,"AlgorithmExtractor",{enumerable:!0,get:a(function(){return kG.AlgorithmExtractor},"get")});var MG=ES();Object.defineProperty(m,"PlanningService",{enumerable:!0,get:a(function(){return MG.PlanningService},"get")});var jG=BA();Object.defineProperty(m,"PropertySchemaResolver",{enumerable:!0,get:a(function(){return jG.PropertySchemaResolver},"get")});var $G=GA();Object.defineProperty(m,"ClassHierarchyResolver",{enumerable:!0,get:a(function(){return $G.ClassHierarchyResolver},"get")});var UG=qA();Object.defineProperty(m,"EnumValueResolver",{enumerable:!0,get:a(function(){return UG.EnumValueResolver},"get")});var VG=RS();Object.defineProperty(m,"AssetConversionService",{enumerable:!0,get:a(function(){return VG.AssetConversionService},"get")});var BG=OS();Object.defineProperty(m,"SessionEventService",{enumerable:!0,get:a(function(){return BG.SessionEventService},"get")});var GG=LS();Object.defineProperty(m,"URIConstructionService",{enumerable:!0,get:a(function(){return GG.URIConstructionService},"get")});var qG=kS();Object.defineProperty(m,"GenericAssetCreationService",{enumerable:!0,get:a(function(){return qG.GenericAssetCreationService},"get")});var WG=e3();Object.defineProperty(m,"ArchiveAssetService",{enumerable:!0,get:a(function(){return WG.ArchiveAssetService},"get")});var zG=r3();Object.defineProperty(m,"FixMissingLabelService",{enumerable:!0,get:a(function(){return zG.FixMissingLabelService},"get")});var HG=n3();Object.defineProperty(m,"GraphQueryService",{enumerable:!0,get:a(function(){return HG.GraphQueryService},"get")});var QG=s3();Object.defineProperty(m,"TypeRegistry",{enumerable:!0,get:a(function(){return QG.TypeRegistry},"get")});var OR=o3();Object.defineProperty(m,"NLToSPARQLService",{enumerable:!0,get:a(function(){return OR.NLToSPARQLService},"get")});Object.defineProperty(m,"DEFAULT_NL_TO_SPARQL_CONFIG",{enumerable:!0,get:a(function(){return OR.DEFAULT_NL_TO_SPARQL_CONFIG},"get")});var ai=VS();Object.defineProperty(m,"SPARQL_TEMPLATES",{enumerable:!0,get:a(function(){return ai.SPARQL_TEMPLATES},"get")});Object.defineProperty(m,"SPARQL_PREFIXES",{enumerable:!0,get:a(function(){return ai.SPARQL_PREFIXES},"get")});Object.defineProperty(m,"PREDICATES",{enumerable:!0,get:a(function(){return ai.PREDICATES},"get")});Object.defineProperty(m,"ASSET_CLASSES",{enumerable:!0,get:a(function(){return ai.ASSET_CLASSES},"get")});Object.defineProperty(m,"EFFORT_STATUSES",{enumerable:!0,get:a(function(){return ai.EFFORT_STATUSES},"get")});Object.defineProperty(m,"KNOWN_PROTOTYPES",{enumerable:!0,get:a(function(){return ai.KNOWN_PROTOTYPES},"get")});Object.defineProperty(m,"KNOWN_CLASSES",{enumerable:!0,get:a(function(){return ai.KNOWN_CLASSES},"get")});Object.defineProperty(m,"findClassByTerm",{enumerable:!0,get:a(function(){return ai.findClassByTerm},"get")});Object.defineProperty(m,"findMatchingTemplates",{enumerable:!0,get:a(function(){return ai.findMatchingTemplates},"get")});Object.defineProperty(m,"fillTemplate",{enumerable:!0,get:a(function(){return ai.fillTemplate},"get")});Object.defineProperty(m,"validateParameters",{enumerable:!0,get:a(function(){return ai.validateParameters},"get")});Object.defineProperty(m,"getTemplateByName",{enumerable:!0,get:a(function(){return ai.getTemplateByName},"get")});var FR=qS();Object.defineProperty(m,"CriticalityZoneService",{enumerable:!0,get:a(function(){return FR.CriticalityZoneService},"get")});Object.defineProperty(m,"CriticalityZoneUUIDs",{enumerable:!0,get:a(function(){return FR.CriticalityZoneUUIDs},"get")});var YG=cs();Object.defineProperty(m,"FrontmatterService",{enumerable:!0,get:a(function(){return YG.FrontmatterService},"get")});var XG=Fn();Object.defineProperty(m,"DateFormatter",{enumerable:!0,get:a(function(){return XG.DateFormatter},"get")});var KG=Us();Object.defineProperty(m,"WikiLinkHelpers",{enumerable:!0,get:a(function(){return KG.WikiLinkHelpers},"get")});var JG=Js();Object.defineProperty(m,"MetadataHelpers",{enumerable:!0,get:a(function(){return JG.MetadataHelpers},"get")});var ZG=B1();Object.defineProperty(m,"MetadataExtractor",{enumerable:!0,get:a(function(){return ZG.MetadataExtractor},"get")});var eq=l3();Object.defineProperty(m,"EffortSortingHelpers",{enumerable:!0,get:a(function(){return eq.EffortSortingHelpers},"get")});var tq=c3();Object.defineProperty(m,"FilenameValidator",{enumerable:!0,get:a(function(){return tq.FilenameValidator},"get")});var rq=g3();Object.defineProperty(m,"RDFSerializer",{enumerable:!0,get:a(function(){return rq.RDFSerializer},"get")});var nq=Cl();Object.defineProperty(m,"NullLogger",{enumerable:!0,get:a(function(){return nq.NullLogger},"get")});var wv=rw();Object.defineProperty(m,"vaultPathToIRI",{enumerable:!0,get:a(function(){return wv.vaultPathToIRI},"get")});Object.defineProperty(m,"iriToVaultPath",{enumerable:!0,get:a(function(){return wv.iriToVaultPath},"get")});Object.defineProperty(m,"OBSIDIAN_VAULT_SCHEME",{enumerable:!0,get:a(function(){return wv.OBSIDIAN_VAULT_SCHEME},"get")});var iq=k1();Object.defineProperty(m,"InMemoryTripleStore",{enumerable:!0,get:a(function(){return iq.InMemoryTripleStore},"get")});var sq=Ae();Object.defineProperty(m,"DomainIRI",{enumerable:!0,get:a(function(){return sq.IRI},"get")});var oq=$e();Object.defineProperty(m,"DomainLiteral",{enumerable:!0,get:a(function(){return oq.Literal},"get")});var aq=$t();Object.defineProperty(m,"DomainBlankNode",{enumerable:!0,get:a(function(){return aq.BlankNode},"get")});var lq=Bn();Object.defineProperty(m,"DomainTriple",{enumerable:!0,get:a(function(){return lq.Triple},"get")});var cq=iw();Object.defineProperty(m,"RDFVocabularyMapper",{enumerable:!0,get:a(function(){return cq.RDFVocabularyMapper},"get")});var uq=_3();Object.defineProperty(m,"RDFSInferenceEngine",{enumerable:!0,get:a(function(){return uq.RDFSInferenceEngine},"get")});var fq=lw();Object.defineProperty(m,"NonInheritablePropertyRegistry",{enumerable:!0,get:a(function(){return fq.NonInheritablePropertyRegistry},"get")});var dq=fw();Object.defineProperty(m,"PropertyCardinalityRegistry",{enumerable:!0,get:a(function(){return dq.PropertyCardinalityRegistry},"get")});var DR=pw();Object.defineProperty(m,"PrototypeChainMaterializer",{enumerable:!0,get:a(function(){return DR.PrototypeChainMaterializer},"get")});Object.defineProperty(m,"INFERRED_GRAPH",{enumerable:!0,get:a(function(){return DR.INFERRED_GRAPH},"get")});var hq=I3();Object.defineProperty(m,"IRICanonicalizer",{enumerable:!0,get:a(function(){return hq.IRICanonicalizer},"get")});var LR=x3();Object.defineProperty(m,"LazyAssetGraphLoader",{enumerable:!0,get:a(function(){return LR.LazyAssetGraphLoader},"get")});Object.defineProperty(m,"MAX_LAZY_DEPTH",{enumerable:!0,get:a(function(){return LR.MAX_LAZY_DEPTH},"get")});var NR=bw();Object.defineProperty(m,"SourceAnnotator",{enumerable:!0,get:a(function(){return NR.SourceAnnotator},"get")});Object.defineProperty(m,"SOURCE_VARIABLE",{enumerable:!0,get:a(function(){return NR.SOURCE_VARIABLE},"get")});var cg=Ew();Object.defineProperty(m,"NoteToRDFConverter",{enumerable:!0,get:a(function(){return cg.NoteToRDFConverter},"get")});Object.defineProperty(m,"normaliseExcludedFolders",{enumerable:!0,get:a(function(){return cg.normaliseExcludedFolders},"get")});Object.defineProperty(m,"isPathExcluded",{enumerable:!0,get:a(function(){return cg.isPathExcluded},"get")});Object.defineProperty(m,"shouldSkipFileForEffectiveSet",{enumerable:!0,get:a(function(){return cg.shouldSkipFileForEffectiveSet},"get")});var vv=$l();Object.defineProperty(m,"ExoQLParser",{enumerable:!0,get:a(function(){return vv.ExoQLParser},"get")});Object.defineProperty(m,"SPARQLParser",{enumerable:!0,get:a(function(){return vv.SPARQLParser},"get")});Object.defineProperty(m,"SPARQLParseError",{enumerable:!0,get:a(function(){return vv.SPARQLParseError},"get")});var kR=fb();Object.defineProperty(m,"DescribeOptionsTransformer",{enumerable:!0,get:a(function(){return kR.DescribeOptionsTransformer},"get")});Object.defineProperty(m,"DescribeOptionsTransformerError",{enumerable:!0,get:a(function(){return kR.DescribeOptionsTransformerError},"get")});var MR=Vl();Object.defineProperty(m,"ExoQLAlgebraTranslator",{enumerable:!0,get:a(function(){return MR.ExoQLAlgebraTranslator},"get")});Object.defineProperty(m,"AlgebraTranslator",{enumerable:!0,get:a(function(){return MR.AlgebraTranslator},"get")});var pq=D3();Object.defineProperty(m,"AlgebraOptimizer",{enumerable:!0,get:a(function(){return pq.AlgebraOptimizer},"get")});var mq=L3();Object.defineProperty(m,"AlgebraSerializer",{enumerable:!0,get:a(function(){return mq.AlgebraSerializer},"get")});var gq=Cb();Object.defineProperty(m,"BGPExecutor",{enumerable:!0,get:a(function(){return gq.BGPExecutor},"get")});var yq=Ip();Object.defineProperty(m,"FilterExecutor",{enumerable:!0,get:a(function(){return yq.FilterExecutor},"get")});var _q=Qb();Object.defineProperty(m,"OptionalExecutor",{enumerable:!0,get:a(function(){return _q.OptionalExecutor},"get")});var bq=Xb();Object.defineProperty(m,"UnionExecutor",{enumerable:!0,get:a(function(){return bq.UnionExecutor},"get")});var Sq=o1();Object.defineProperty(m,"ConstructExecutor",{enumerable:!0,get:a(function(){return Sq.ConstructExecutor},"get")});var wq=k3();Object.defineProperty(m,"DescribeExecutor",{enumerable:!0,get:a(function(){return wq.DescribeExecutor},"get")});var jR=lc();Object.defineProperty(m,"ExoQLQueryExecutor",{enumerable:!0,get:a(function(){return jR.ExoQLQueryExecutor},"get")});Object.defineProperty(m,"QueryExecutor",{enumerable:!0,get:a(function(){return jR.QueryExecutor},"get")});var $R=j3();Object.defineProperty(m,"UpdateExecutor",{enumerable:!0,get:a(function(){return $R.UpdateExecutor},"get")});Object.defineProperty(m,"UpdateExecutorError",{enumerable:!0,get:a(function(){return $R.UpdateExecutorError},"get")});var vq=ss();Object.defineProperty(m,"SolutionMapping",{enumerable:!0,get:a(function(){return vq.SolutionMapping},"get")});var Eq=Tp();Object.defineProperty(m,"BuiltInFunctions",{enumerable:!0,get:a(function(){return Eq.BuiltInFunctions},"get")});var Tq=U3();Object.defineProperty(m,"AggregateFunctions",{enumerable:!0,get:a(function(){return Tq.AggregateFunctions},"get")});var UR=Zb();Object.defineProperty(m,"CustomAggregateRegistry",{enumerable:!0,get:a(function(){return UR.CustomAggregateRegistry},"get")});Object.defineProperty(m,"CustomAggregateError",{enumerable:!0,get:a(function(){return UR.CustomAggregateError},"get")});var bs=e1();Object.defineProperty(m,"BUILT_IN_AGGREGATES",{enumerable:!0,get:a(function(){return bs.BUILT_IN_AGGREGATES},"get")});Object.defineProperty(m,"EXO_AGGREGATE_NS",{enumerable:!0,get:a(function(){return bs.EXO_AGGREGATE_NS},"get")});Object.defineProperty(m,"medianAggregate",{enumerable:!0,get:a(function(){return bs.medianAggregate},"get")});Object.defineProperty(m,"varianceAggregate",{enumerable:!0,get:a(function(){return bs.varianceAggregate},"get")});Object.defineProperty(m,"stddevAggregate",{enumerable:!0,get:a(function(){return bs.stddevAggregate},"get")});Object.defineProperty(m,"modeAggregate",{enumerable:!0,get:a(function(){return bs.modeAggregate},"get")});Object.defineProperty(m,"createPercentileAggregate",{enumerable:!0,get:a(function(){return bs.createPercentileAggregate},"get")});Object.defineProperty(m,"getNumericValue",{enumerable:!0,get:a(function(){return bs.getNumericValue},"get")});Object.defineProperty(m,"createDecimalLiteral",{enumerable:!0,get:a(function(){return bs.createDecimalLiteral},"get")});Object.defineProperty(m,"createDoubleLiteral",{enumerable:!0,get:a(function(){return bs.createDoubleLiteral},"get")});var Iq=V3();Object.defineProperty(m,"QueryPlanCache",{enumerable:!0,get:a(function(){return Iq.QueryPlanCache},"get")});var VR=B3();Object.defineProperty(m,"SPARQLResultCache",{enumerable:!0,get:a(function(){return VR.SPARQLResultCache},"get")});Object.defineProperty(m,"createSPARQLResultCache",{enumerable:!0,get:a(function(){return VR.createSPARQLResultCache},"get")});var BR=G3();Object.defineProperty(m,"IncrementalIndexer",{enumerable:!0,get:a(function(){return BR.IncrementalIndexer},"get")});Object.defineProperty(m,"createIncrementalIndexer",{enumerable:!0,get:a(function(){return BR.createIncrementalIndexer},"get")});var xq=q3();Object.defineProperty(m,"ResultSerializer",{enumerable:!0,get:a(function(){return xq.ResultSerializer},"get")});var GR=lb();Object.defineProperty(m,"CaseWhenTransformer",{enumerable:!0,get:a(function(){return GR.CaseWhenTransformer},"get")});Object.defineProperty(m,"CaseWhenTransformerError",{enumerable:!0,get:a(function(){return GR.CaseWhenTransformerError},"get")});var Aq=mb();Object.defineProperty(m,"VaultPrefixTransformer",{enumerable:!0,get:a(function(){return Aq.VaultPrefixTransformer},"get")});var Rq=Iw();Object.defineProperty(m,"FilterContainsOptimizer",{enumerable:!0,get:a(function(){return Rq.FilterContainsOptimizer},"get")});var qR=W3();Object.defineProperty(m,"FileNotFoundError",{enumerable:!0,get:a(function(){return qR.FileNotFoundError},"get")});Object.defineProperty(m,"FileAlreadyExistsError",{enumerable:!0,get:a(function(){return qR.FileAlreadyExistsError},"get")});var Ev=F1();Object.defineProperty(m,"TripleAlreadyExistsError",{enumerable:!0,get:a(function(){return Ev.TripleAlreadyExistsError},"get")});Object.defineProperty(m,"TripleNotFoundError",{enumerable:!0,get:a(function(){return Ev.TripleNotFoundError},"get")});Object.defineProperty(m,"TransactionError",{enumerable:!0,get:a(function(){return Ev.TransactionError},"get")});var WR=nf();Object.defineProperty(m,"liveClock",{enumerable:!0,get:a(function(){return WR.liveClock},"get")});Object.defineProperty(m,"frozenClock",{enumerable:!0,get:a(function(){return WR.frozenClock},"get")});var zR=Bp();Object.defineProperty(m,"liveUidGenerator",{enumerable:!0,get:a(function(){return zR.liveUidGenerator},"get")});Object.defineProperty(m,"seededUidGenerator",{enumerable:!0,get:a(function(){return zR.seededUidGenerator},"get")});var ug=jw();Object.defineProperty(m,"VaultSettings",{enumerable:!0,get:a(function(){return ug.VaultSettings},"get")});Object.defineProperty(m,"DEFAULT_OWNER_IDENTITY",{enumerable:!0,get:a(function(){return ug.DEFAULT_OWNER_IDENTITY},"get")});Object.defineProperty(m,"DEFAULT_INBOX_FOLDER",{enumerable:!0,get:a(function(){return ug.DEFAULT_INBOX_FOLDER},"get")});Object.defineProperty(m,"DEFAULT_FLEETING_NOTE_CLASS_UID",{enumerable:!0,get:a(function(){return ug.DEFAULT_FLEETING_NOTE_CLASS_UID},"get")});var Cq=Ft();Object.defineProperty(m,"DI_TOKENS",{enumerable:!0,get:a(function(){return Cq.DI_TOKENS},"get")});var Cf=z3();Object.defineProperty(m,"registerCoreServices",{enumerable:!0,get:a(function(){return Cf.registerCoreServices},"get")});Object.defineProperty(m,"createChildContainer",{enumerable:!0,get:a(function(){return Cf.createChildContainer},"get")});Object.defineProperty(m,"getContainer",{enumerable:!0,get:a(function(){return Cf.getContainer},"get")});Object.defineProperty(m,"resetContainer",{enumerable:!0,get:a(function(){return Cf.resetContainer},"get")});Object.defineProperty(m,"container",{enumerable:!0,get:a(function(){return Cf.container},"get")});var ho=J3();Object.defineProperty(m,"NODE_FLAGS",{enumerable:!0,get:a(function(){return ho.NODE_FLAGS},"get")});Object.defineProperty(m,"DEFAULT_COLORS",{enumerable:!0,get:a(function(){return ho.DEFAULT_COLORS},"get")});Object.defineProperty(m,"StringTable",{enumerable:!0,get:a(function(){return ho.StringTable},"get")});Object.defineProperty(m,"CompactGraphStore",{enumerable:!0,get:a(function(){return ho.CompactGraphStore},"get")});Object.defineProperty(m,"MemoryPool",{enumerable:!0,get:a(function(){return ho.MemoryPool},"get")});Object.defineProperty(m,"getGlobalPool",{enumerable:!0,get:a(function(){return ho.getGlobalPool},"get")});Object.defineProperty(m,"resetGlobalPool",{enumerable:!0,get:a(function(){return ho.resetGlobalPool},"get")});Object.defineProperty(m,"StreamingLoader",{enumerable:!0,get:a(function(){return ho.StreamingLoader},"get")});Object.defineProperty(m,"createStreamingSource",{enumerable:!0,get:a(function(){return ho.createStreamingSource},"get")});var HR=Z3();Object.defineProperty(m,"ExoQL",{enumerable:!0,get:a(function(){return HR.ExoQL},"get")});Object.defineProperty(m,"ExoQLError",{enumerable:!0,get:a(function(){return HR.ExoQLError},"get")});var Oc=Gm();Object.defineProperty(m,"RELATION_COLUMN_SET_CLASS_IRI",{enumerable:!0,get:a(function(){return Oc.RELATION_COLUMN_SET_CLASS_IRI},"get")});Object.defineProperty(m,"RELATION_COLUMN_SET_CLASS_UID",{enumerable:!0,get:a(function(){return Oc.RELATION_COLUMN_SET_CLASS_UID},"get")});Object.defineProperty(m,"createRelationColumnSetFromFrontmatter",{enumerable:!0,get:a(function(){return Oc.createRelationColumnSetFromFrontmatter},"get")});Object.defineProperty(m,"isRelationColumnSet",{enumerable:!0,get:a(function(){return Oc.isRelationColumnSet},"get")});Object.defineProperty(m,"isRelationColumnSetFrontmatter",{enumerable:!0,get:a(function(){return Oc.isRelationColumnSetFrontmatter},"get")});Object.defineProperty(m,"normalizeRelationColumnSetRef",{enumerable:!0,get:a(function(){return Oc.normalizeRef},"get")});var Pq=lR();Object.defineProperty(m,"RelationColumnSetResolver",{enumerable:!0,get:a(function(){return Pq.RelationColumnSetResolver},"get")});var Pf=Gm();Object.defineProperty(m,"LAYOUT_CLASS_IRI",{enumerable:!0,get:a(function(){return Pf.LAYOUT_CLASS_IRI},"get")});Object.defineProperty(m,"LAYOUT_CLASS_UID",{enumerable:!0,get:a(function(){return Pf.LAYOUT_CLASS_UID},"get")});Object.defineProperty(m,"createLayoutFromFrontmatter",{enumerable:!0,get:a(function(){return Pf.createLayoutFromFrontmatter},"get")});Object.defineProperty(m,"isLayout",{enumerable:!0,get:a(function(){return Pf.isLayout},"get")});Object.defineProperty(m,"isLayoutFrontmatter",{enumerable:!0,get:a(function(){return Pf.isLayoutFrontmatter},"get")});var Ho=Gm();Object.defineProperty(m,"BACKLINKS_TABLE_BLOCK_CLASS_IRI",{enumerable:!0,get:a(function(){return Ho.BACKLINKS_TABLE_BLOCK_CLASS_IRI},"get")});Object.defineProperty(m,"BACKLINKS_TABLE_BLOCK_CLASS_UID",{enumerable:!0,get:a(function(){return Ho.BACKLINKS_TABLE_BLOCK_CLASS_UID},"get")});Object.defineProperty(m,"PROPERTIES_BLOCK_CLASS_IRI",{enumerable:!0,get:a(function(){return Ho.PROPERTIES_BLOCK_CLASS_IRI},"get")});Object.defineProperty(m,"PROPERTIES_BLOCK_CLASS_UID",{enumerable:!0,get:a(function(){return Ho.PROPERTIES_BLOCK_CLASS_UID},"get")});Object.defineProperty(m,"createLayoutBlockFromFrontmatter",{enumerable:!0,get:a(function(){return Ho.createLayoutBlockFromFrontmatter},"get")});Object.defineProperty(m,"isBacklinksTableBlock",{enumerable:!0,get:a(function(){return Ho.isBacklinksTableBlock},"get")});Object.defineProperty(m,"isLayoutBlockFrontmatter",{enumerable:!0,get:a(function(){return Ho.isLayoutBlockFrontmatter},"get")});Object.defineProperty(m,"isPropertiesBlock",{enumerable:!0,get:a(function(){return Ho.isPropertiesBlock},"get")});var QR=uR();Object.defineProperty(m,"LayoutSelector",{enumerable:!0,get:a(function(){return QR.LayoutSelector},"get")});Object.defineProperty(m,"selectByPriority",{enumerable:!0,get:a(function(){return QR.selectByPriority},"get")});oi(bR(),m);var Oq=fv();Object.defineProperty(m,"ShapeLoader",{enumerable:!0,get:a(function(){return Oq.ShapeLoader},"get")});var Fq=lv();Object.defineProperty(m,"ShapeRegistry",{enumerable:!0,get:a(function(){return Fq.ShapeRegistry},"get")});var Dq=er();Object.defineProperty(m,"Namespace",{enumerable:!0,get:a(function(){return Dq.Namespace},"get")});var YR=hv();Object.defineProperty(m,"shaclValidate",{enumerable:!0,get:a(function(){return YR.validate},"get")});Object.defineProperty(m,"ShaclShapeRegistry",{enumerable:!0,get:a(function(){return YR.ShapeRegistry},"get")});oi(vR(),m);var Tv=TR();Object.defineProperty(m,"ValidatorDaemon",{enumerable:!0,get:a(function(){return Tv.ValidatorDaemon},"get")});Object.defineProperty(m,"DEFAULT_SOCKET_PATH",{enumerable:!0,get:a(function(){return Tv.DEFAULT_SOCKET_PATH},"get")});Object.defineProperty(m,"IDLE_TIMEOUT_MS",{enumerable:!0,get:a(function(){return Tv.IDLE_TIMEOUT_MS},"get")});var Lq=yv();Object.defineProperty(m,"TripleClassHierarchy",{enumerable:!0,get:a(function(){return Lq.ClassHierarchy},"get")});var XR=RR();Object.defineProperty(m,"parseTarball",{enumerable:!0,get:a(function(){return XR.parseTarball},"get")});Object.defineProperty(m,"parseTarballGzip",{enumerable:!0,get:a(function(){return XR.parseTarballGzip},"get")})});var Er=S(Iv=>{"use strict";Iv.fromCallback=function(n){return Object.defineProperty(function(...e){if(typeof e[e.length-1]=="function")n.apply(this,e);else return new Promise((t,r)=>{e.push((i,s)=>i!=null?r(i):t(s)),n.apply(this,e)})},"name",{value:n.name})};Iv.fromPromise=function(n){return Object.defineProperty(function(...e){let t=e[e.length-1];if(typeof t!="function")return n.apply(this,e);e.pop(),n.apply(this,e).then(r=>t(null,r),t)},"name",{value:n.name})}});var JR=S((Ife,KR)=>{var Qo=require("constants"),Nq=process.cwd,fg=null,kq=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return fg||(fg=Nq.call(process)),fg};try{process.cwd()}catch{}typeof process.chdir=="function"&&(xv=process.chdir,process.chdir=function(n){fg=null,xv.call(process,n)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,xv));var xv;KR.exports=Mq;function Mq(n){Qo.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(n),n.lutimes||t(n),n.chown=s(n.chown),n.fchown=s(n.fchown),n.lchown=s(n.lchown),n.chmod=r(n.chmod),n.fchmod=r(n.fchmod),n.lchmod=r(n.lchmod),n.chownSync=o(n.chownSync),n.fchownSync=o(n.fchownSync),n.lchownSync=o(n.lchownSync),n.chmodSync=i(n.chmodSync),n.fchmodSync=i(n.fchmodSync),n.lchmodSync=i(n.lchmodSync),n.stat=l(n.stat),n.fstat=l(n.fstat),n.lstat=l(n.lstat),n.statSync=c(n.statSync),n.fstatSync=c(n.fstatSync),n.lstatSync=c(n.lstatSync),n.chmod&&!n.lchmod&&(n.lchmod=function(f,d,h){h&&process.nextTick(h)},n.lchmodSync=function(){}),n.chown&&!n.lchown&&(n.lchown=function(f,d,h,p){p&&process.nextTick(p)},n.lchownSync=function(){}),kq==="win32"&&(n.rename=typeof n.rename!="function"?n.rename:(function(f){function d(h,p,g){var _=Date.now(),v=0;f(h,p,a(function w(E){if(E&&(E.code==="EACCES"||E.code==="EPERM"||E.code==="EBUSY")&&Date.now()-_<6e4){setTimeout(function(){n.stat(p,function(I,A){I&&I.code==="ENOENT"?f(h,p,w):g(E)})},v),v<100&&(v+=10);return}g&&g(E)},"CB"))}return a(d,"rename"),Object.setPrototypeOf&&Object.setPrototypeOf(d,f),d})(n.rename)),n.read=typeof n.read!="function"?n.read:(function(f){function d(h,p,g,_,v,w){var E;if(w&&typeof w=="function"){var I=0;E=a(function(A,D,K){if(A&&A.code==="EAGAIN"&&I<10)return I++,f.call(n,h,p,g,_,v,E);w.apply(this,arguments)},"callback")}return f.call(n,h,p,g,_,v,E)}return a(d,"read"),Object.setPrototypeOf&&Object.setPrototypeOf(d,f),d})(n.read),n.readSync=typeof n.readSync!="function"?n.readSync:(function(f){return function(d,h,p,g,_){for(var v=0;;)try{return f.call(n,d,h,p,g,_)}catch(w){if(w.code==="EAGAIN"&&v<10){v++;continue}throw w}}})(n.readSync);function e(f){f.lchmod=function(d,h,p){f.open(d,Qo.O_WRONLY|Qo.O_SYMLINK,h,function(g,_){if(g){p&&p(g);return}f.fchmod(_,h,function(v){f.close(_,function(w){p&&p(v||w)})})})},f.lchmodSync=function(d,h){var p=f.openSync(d,Qo.O_WRONLY|Qo.O_SYMLINK,h),g=!0,_;try{_=f.fchmodSync(p,h),g=!1}finally{if(g)try{f.closeSync(p)}catch{}else f.closeSync(p)}return _}}a(e,"patchLchmod");function t(f){Qo.hasOwnProperty("O_SYMLINK")&&f.futimes?(f.lutimes=function(d,h,p,g){f.open(d,Qo.O_SYMLINK,function(_,v){if(_){g&&g(_);return}f.futimes(v,h,p,function(w){f.close(v,function(E){g&&g(w||E)})})})},f.lutimesSync=function(d,h,p){var g=f.openSync(d,Qo.O_SYMLINK),_,v=!0;try{_=f.futimesSync(g,h,p),v=!1}finally{if(v)try{f.closeSync(g)}catch{}else f.closeSync(g)}return _}):f.futimes&&(f.lutimes=function(d,h,p,g){g&&process.nextTick(g)},f.lutimesSync=function(){})}a(t,"patchLutimes");function r(f){return f&&function(d,h,p){return f.call(n,d,h,function(g){u(g)&&(g=null),p&&p.apply(this,arguments)})}}a(r,"chmodFix");function i(f){return f&&function(d,h){try{return f.call(n,d,h)}catch(p){if(!u(p))throw p}}}a(i,"chmodFixSync");function s(f){return f&&function(d,h,p,g){return f.call(n,d,h,p,function(_){u(_)&&(_=null),g&&g.apply(this,arguments)})}}a(s,"chownFix");function o(f){return f&&function(d,h,p){try{return f.call(n,d,h,p)}catch(g){if(!u(g))throw g}}}a(o,"chownFixSync");function l(f){return f&&function(d,h,p){typeof h=="function"&&(p=h,h=null);function g(_,v){v&&(v.uid<0&&(v.uid+=4294967296),v.gid<0&&(v.gid+=4294967296)),p&&p.apply(this,arguments)}return a(g,"callback"),h?f.call(n,d,h,g):f.call(n,d,g)}}a(l,"statFix");function c(f){return f&&function(d,h){var p=h?f.call(n,d,h):f.call(n,d);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}a(c,"statFixSync");function u(f){if(!f||f.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(f.code==="EINVAL"||f.code==="EPERM"))}a(u,"chownErOk")}a(Mq,"patch")});var tC=S((Afe,eC)=>{var ZR=require("stream").Stream;eC.exports=jq;function jq(n){return{ReadStream:e,WriteStream:t};function e(r,i){if(!(this instanceof e))return new e(r,i);ZR.call(this);var s=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var o=Object.keys(i),l=0,c=o.length;l<c;l++){var u=o[l];this[u]=i[u]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){s._read()});return}n.open(this.path,this.flags,this.mode,function(f,d){if(f){s.emit("error",f),s.readable=!1;return}s.fd=d,s.emit("open",d),s._read()})}function t(r,i){if(!(this instanceof t))return new t(r,i);ZR.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var s=Object.keys(i),o=0,l=s.length;o<l;o++){var c=s[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=n.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}a(jq,"legacy")});var nC=S((Cfe,rC)=>{"use strict";rC.exports=Uq;var $q=Object.getPrototypeOf||function(n){return n.__proto__};function Uq(n){if(n===null||typeof n!="object")return n;if(n instanceof Object)var e={__proto__:$q(n)};else var e=Object.create(null);return Object.getOwnPropertyNames(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}a(Uq,"clone")});var Dc=S((Ofe,Cv)=>{var Vt=require("fs"),Vq=JR(),Bq=tC(),Gq=nC(),dg=require("util"),$r,pg;typeof Symbol=="function"&&typeof Symbol.for=="function"?($r=Symbol.for("graceful-fs.queue"),pg=Symbol.for("graceful-fs.previous")):($r="___graceful-fs.queue",pg="___graceful-fs.previous");function qq(){}a(qq,"noop");function oC(n,e){Object.defineProperty(n,$r,{get:a(function(){return e},"get")})}a(oC,"publishQueue");var Ka=qq;dg.debuglog?Ka=dg.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ka=a(function(){var n=dg.format.apply(dg,arguments);n="GFS4: "+n.split(/\n/).join(`
460
- GFS4: `),console.error(n)},"debug"));Vt[$r]||(iC=global[$r]||[],oC(Vt,iC),Vt.close=(function(n){function e(t,r){return n.call(Vt,t,function(i){i||sC(),typeof r=="function"&&r.apply(this,arguments)})}return a(e,"close"),Object.defineProperty(e,pg,{value:n}),e})(Vt.close),Vt.closeSync=(function(n){function e(t){n.apply(Vt,arguments),sC()}return a(e,"closeSync"),Object.defineProperty(e,pg,{value:n}),e})(Vt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Ka(Vt[$r]),require("assert").equal(Vt[$r].length,0)}));var iC;global[$r]||oC(global,Vt[$r]);Cv.exports=Av(Gq(Vt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Vt.__patched&&(Cv.exports=Av(Vt),Vt.__patched=!0);function Av(n){Vq(n),n.gracefulify=Av,n.createReadStream=D,n.createWriteStream=K;var e=n.readFile;n.readFile=t;function t(N,Q,ie){return typeof Q=="function"&&(ie=Q,Q=null),V(N,Q,ie);function V(Y,re,G,ne){return e(Y,re,function(q){q&&(q.code==="EMFILE"||q.code==="ENFILE")?Fc([V,[Y,re,G],q,ne||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}a(V,"go$readFile")}a(t,"readFile");var r=n.writeFile;n.writeFile=i;function i(N,Q,ie,V){return typeof ie=="function"&&(V=ie,ie=null),Y(N,Q,ie,V);function Y(re,G,ne,q,U){return r(re,G,ne,function(B){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([Y,[re,G,ne,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(Y,"go$writeFile")}a(i,"writeFile");var s=n.appendFile;s&&(n.appendFile=o);function o(N,Q,ie,V){return typeof ie=="function"&&(V=ie,ie=null),Y(N,Q,ie,V);function Y(re,G,ne,q,U){return s(re,G,ne,function(B){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([Y,[re,G,ne,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(Y,"go$appendFile")}a(o,"appendFile");var l=n.copyFile;l&&(n.copyFile=c);function c(N,Q,ie,V){return typeof ie=="function"&&(V=ie,ie=0),Y(N,Q,ie,V);function Y(re,G,ne,q,U){return l(re,G,ne,function(B){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([Y,[re,G,ne,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(Y,"go$copyFile")}a(c,"copyFile");var u=n.readdir;n.readdir=d;var f=/^v[0-5]\./;function d(N,Q,ie){typeof Q=="function"&&(ie=Q,Q=null);var V=f.test(process.version)?a(function(G,ne,q,U){return u(G,Y(G,ne,q,U))},"go$readdir"):a(function(G,ne,q,U){return u(G,ne,Y(G,ne,q,U))},"go$readdir");return V(N,Q,ie);function Y(re,G,ne,q){return function(U,B){U&&(U.code==="EMFILE"||U.code==="ENFILE")?Fc([V,[re,G,ne],U,q||Date.now(),Date.now()]):(B&&B.sort&&B.sort(),typeof ne=="function"&&ne.call(this,U,B))}}}if(a(d,"readdir"),process.version.substr(0,4)==="v0.8"){var h=Bq(n);w=h.ReadStream,I=h.WriteStream}var p=n.ReadStream;p&&(w.prototype=Object.create(p.prototype),w.prototype.open=E);var g=n.WriteStream;g&&(I.prototype=Object.create(g.prototype),I.prototype.open=A),Object.defineProperty(n,"ReadStream",{get:a(function(){return w},"get"),set:a(function(N){w=N},"set"),enumerable:!0,configurable:!0}),Object.defineProperty(n,"WriteStream",{get:a(function(){return I},"get"),set:a(function(N){I=N},"set"),enumerable:!0,configurable:!0});var _=w;Object.defineProperty(n,"FileReadStream",{get:a(function(){return _},"get"),set:a(function(N){_=N},"set"),enumerable:!0,configurable:!0});var v=I;Object.defineProperty(n,"FileWriteStream",{get:a(function(){return v},"get"),set:a(function(N){v=N},"set"),enumerable:!0,configurable:!0});function w(N,Q){return this instanceof w?(p.apply(this,arguments),this):w.apply(Object.create(w.prototype),arguments)}a(w,"ReadStream");function E(){var N=this;me(N.path,N.flags,N.mode,function(Q,ie){Q?(N.autoClose&&N.destroy(),N.emit("error",Q)):(N.fd=ie,N.emit("open",ie),N.read())})}a(E,"ReadStream$open");function I(N,Q){return this instanceof I?(g.apply(this,arguments),this):I.apply(Object.create(I.prototype),arguments)}a(I,"WriteStream");function A(){var N=this;me(N.path,N.flags,N.mode,function(Q,ie){Q?(N.destroy(),N.emit("error",Q)):(N.fd=ie,N.emit("open",ie))})}a(A,"WriteStream$open");function D(N,Q){return new n.ReadStream(N,Q)}a(D,"createReadStream");function K(N,Q){return new n.WriteStream(N,Q)}a(K,"createWriteStream");var oe=n.open;n.open=me;function me(N,Q,ie,V){return typeof ie=="function"&&(V=ie,ie=null),Y(N,Q,ie,V);function Y(re,G,ne,q,U){return oe(re,G,ne,function(B,tt){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([Y,[re,G,ne,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(Y,"go$open")}return a(me,"open"),n}a(Av,"patch");function Fc(n){Ka("ENQUEUE",n[0].name,n[1]),Vt[$r].push(n),Rv()}a(Fc,"enqueue");var hg;function sC(){for(var n=Date.now(),e=0;e<Vt[$r].length;++e)Vt[$r][e].length>2&&(Vt[$r][e][3]=n,Vt[$r][e][4]=n);Rv()}a(sC,"resetQueue");function Rv(){if(clearTimeout(hg),hg=void 0,Vt[$r].length!==0){var n=Vt[$r].shift(),e=n[0],t=n[1],r=n[2],i=n[3],s=n[4];if(i===void 0)Ka("RETRY",e.name,t),e.apply(null,t);else if(Date.now()-i>=6e4){Ka("TIMEOUT",e.name,t);var o=t.pop();typeof o=="function"&&o.call(null,r)}else{var l=Date.now()-s,c=Math.max(s-i,1),u=Math.min(c*1.2,100);l>=u?(Ka("RETRY",e.name,t),e.apply(null,t.concat([i]))):Vt[$r].push(n)}hg===void 0&&(hg=setTimeout(Rv,0))}}a(Rv,"retry")});var mn=S(po=>{"use strict";var aC=Er().fromCallback,pn=Dc(),Wq=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(n=>typeof pn[n]=="function");Object.assign(po,pn);Wq.forEach(n=>{po[n]=aC(pn[n])});po.exists=function(n,e){return typeof e=="function"?pn.exists(n,e):new Promise(t=>pn.exists(n,t))};po.read=function(n,e,t,r,i,s){return typeof s=="function"?pn.read(n,e,t,r,i,s):new Promise((o,l)=>{pn.read(n,e,t,r,i,(c,u,f)=>{if(c)return l(c);o({bytesRead:u,buffer:f})})})};po.write=function(n,e,...t){return typeof t[t.length-1]=="function"?pn.write(n,e,...t):new Promise((r,i)=>{pn.write(n,e,...t,(s,o,l)=>{if(s)return i(s);r({bytesWritten:o,buffer:l})})})};po.readv=function(n,e,...t){return typeof t[t.length-1]=="function"?pn.readv(n,e,...t):new Promise((r,i)=>{pn.readv(n,e,...t,(s,o,l)=>{if(s)return i(s);r({bytesRead:o,buffers:l})})})};po.writev=function(n,e,...t){return typeof t[t.length-1]=="function"?pn.writev(n,e,...t):new Promise((r,i)=>{pn.writev(n,e,...t,(s,o,l)=>{if(s)return i(s);r({bytesWritten:o,buffers:l})})})};typeof pn.realpath.native=="function"?po.realpath.native=aC(pn.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var cC=S((Lfe,lC)=>{"use strict";var zq=require("path");lC.exports.checkPath=a(function(e){if(process.platform==="win32"&&/[<>:"|?*]/.test(e.replace(zq.parse(e).root,""))){let r=new Error(`Path contains invalid characters: ${e}`);throw r.code="EINVAL",r}},"checkPath")});var hC=S((kfe,Pv)=>{"use strict";var uC=mn(),{checkPath:fC}=cC(),dC=a(n=>{let e={mode:511};return typeof n=="number"?n:{...e,...n}.mode},"getMode");Pv.exports.makeDir=async(n,e)=>(fC(n),uC.mkdir(n,{mode:dC(e),recursive:!0}));Pv.exports.makeDirSync=(n,e)=>(fC(n),uC.mkdirSync(n,{mode:dC(e),recursive:!0}))});var Ui=S((jfe,pC)=>{"use strict";var Hq=Er().fromPromise,{makeDir:Qq,makeDirSync:Ov}=hC(),Fv=Hq(Qq);pC.exports={mkdirs:Fv,mkdirsSync:Ov,mkdirp:Fv,mkdirpSync:Ov,ensureDir:Fv,ensureDirSync:Ov}});var Yo=S(($fe,gC)=>{"use strict";var Yq=Er().fromPromise,mC=mn();function Xq(n){return mC.access(n).then(()=>!0).catch(()=>!1)}a(Xq,"pathExists");gC.exports={pathExists:Yq(Xq),pathExistsSync:mC.existsSync}});var Dv=S((Vfe,yC)=>{"use strict";var Lc=mn(),Kq=Er().fromPromise;async function Jq(n,e,t){let r=await Lc.open(n,"r+"),i=null;try{await Lc.futimes(r,e,t)}finally{try{await Lc.close(r)}catch(s){i=s}}if(i)throw i}a(Jq,"utimesMillis");function Zq(n,e,t){let r=Lc.openSync(n,"r+");return Lc.futimesSync(r,e,t),Lc.closeSync(r)}a(Zq,"utimesMillisSync");yC.exports={utimesMillis:Kq(Jq),utimesMillisSync:Zq}});var Ja=S((Gfe,wC)=>{"use strict";var Nc=mn(),Tr=require("path"),_C=Er().fromPromise;function eW(n,e,t){let r=t.dereference?i=>Nc.stat(i,{bigint:!0}):i=>Nc.lstat(i,{bigint:!0});return Promise.all([r(n),r(e).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,s])=>({srcStat:i,destStat:s}))}a(eW,"getStats");function tW(n,e,t){let r,i=t.dereference?o=>Nc.statSync(o,{bigint:!0}):o=>Nc.lstatSync(o,{bigint:!0}),s=i(n);try{r=i(e)}catch(o){if(o.code==="ENOENT")return{srcStat:s,destStat:null};throw o}return{srcStat:s,destStat:r}}a(tW,"getStatsSync");async function rW(n,e,t,r){let{srcStat:i,destStat:s}=await eW(n,e,r);if(s){if(Of(i,s)){let o=Tr.basename(n),l=Tr.basename(e);if(t==="move"&&o!==l&&o.toLowerCase()===l.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&Lv(n,e))throw new Error(mg(n,e,t));return{srcStat:i,destStat:s}}a(rW,"checkPaths");function nW(n,e,t,r){let{srcStat:i,destStat:s}=tW(n,e,r);if(s){if(Of(i,s)){let o=Tr.basename(n),l=Tr.basename(e);if(t==="move"&&o!==l&&o.toLowerCase()===l.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&Lv(n,e))throw new Error(mg(n,e,t));return{srcStat:i,destStat:s}}a(nW,"checkPathsSync");async function bC(n,e,t,r){let i=Tr.resolve(Tr.dirname(n)),s=Tr.resolve(Tr.dirname(t));if(s===i||s===Tr.parse(s).root)return;let o;try{o=await Nc.stat(s,{bigint:!0})}catch(l){if(l.code==="ENOENT")return;throw l}if(Of(e,o))throw new Error(mg(n,t,r));return bC(n,e,s,r)}a(bC,"checkParentPaths");function SC(n,e,t,r){let i=Tr.resolve(Tr.dirname(n)),s=Tr.resolve(Tr.dirname(t));if(s===i||s===Tr.parse(s).root)return;let o;try{o=Nc.statSync(s,{bigint:!0})}catch(l){if(l.code==="ENOENT")return;throw l}if(Of(e,o))throw new Error(mg(n,t,r));return SC(n,e,s,r)}a(SC,"checkParentPathsSync");function Of(n,e){return e.ino!==void 0&&e.dev!==void 0&&e.ino===n.ino&&e.dev===n.dev}a(Of,"areIdentical");function Lv(n,e){let t=Tr.resolve(n).split(Tr.sep).filter(i=>i),r=Tr.resolve(e).split(Tr.sep).filter(i=>i);return t.every((i,s)=>r[s]===i)}a(Lv,"isSrcSubdir");function mg(n,e,t){return`Cannot ${t} '${n}' to a subdirectory of itself, '${e}'.`}a(mg,"errMsg");wC.exports={checkPaths:_C(rW),checkPathsSync:nW,checkParentPaths:_C(bC),checkParentPathsSync:SC,isSrcSubdir:Lv,areIdentical:Of}});var EC=S((Wfe,vC)=>{"use strict";async function iW(n,e){let t=[];for await(let r of n)t.push(e(r).then(()=>null,i=>i??new Error("unknown error")));await Promise.all(t.map(r=>r.then(i=>{if(i!==null)throw i})))}a(iW,"asyncIteratorConcurrentProcess");vC.exports={asyncIteratorConcurrentProcess:iW}});var RC=S((Hfe,AC)=>{"use strict";var Kr=mn(),Ff=require("path"),{mkdirs:sW}=Ui(),{pathExists:oW}=Yo(),{utimesMillis:aW}=Dv(),Df=Ja(),{asyncIteratorConcurrentProcess:lW}=EC();async function cW(n,e,t={}){typeof t=="function"&&(t={filter:t}),t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
459
+ `)){let i=r.indexOf("=");if(i===-1)continue;let s=r.slice(r.indexOf(" ")+1,i),o=r.slice(i+1);s&&(t[s]=o)}return t}a(iG,"parseExtendedHeaders");function sG(n){let e=n.replace(/\\/g,"/");e=e.replace(/^[a-zA-Z]:\//,""),e=e.replace(/^\/+/,"");let t=e.startsWith("./"),r=e.split("/"),i=[];for(let o of r)o===".."?i.pop():o!=="."&&o!==""&&i.push(o);let s=i.join("/");return t&&!s.startsWith("./")&&(s="./"+s),n.endsWith("/")&&!s.endsWith("/")&&(s+="/"),s}a(sG,"sanitizePath");function AR(n){let e=n.byteOffset===0&&n.byteLength===n.buffer.byteLength?n:n.slice(),t=[],r=0,i,s;for(;r+512<=e.byteLength;){let o=xf(e,r,100);if(o.length===0)break;let l=!1;if(i){let p=i.path??i.linkpath;p&&(o=p,l=!0)}let c=nG(e,r+124,12),u=512+512*Math.trunc(c/512)+(c%512?512:0),f=xf(e,r+156,1)||"0",d=tG[f]??f;if(d==="extendedHeader"||d==="globalExtendedHeader"){let p=iG(e.subarray(r+512,r+512+c));d==="extendedHeader"?i=p:(i=void 0,s={...s,...p}),r+=u;continue}if(rG.has(d)){i={path:xf(e,r+512,c)},r+=u;continue}if(!l&&xf(e,r+257,6).startsWith("ustar")){let g=xf(e,r+345,155);g.length>0&&(o=`${g}/${o}`)}o=sG(o);let h=c===0?void 0:e.subarray(r+512,r+512+c);t.push({name:o,type:d,size:c,data:h}),i=void 0,r+=u}return t}a(AR,"parseTarball");async function oG(n){let e=new Uint8Array(n instanceof Uint8Array?n:new Uint8Array(n)),t=new DecompressionStream("gzip"),r=t.writable.getWriter(),[,i]=await Promise.all([r.write(e).then(()=>r.close()),new Response(t.readable).arrayBuffer()]);return AR(new Uint8Array(i))}a(oG,"parseTarballGzip")});var It=S(m=>{"use strict";var aG=m&&m.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),oi=m&&m.__exportStar||function(n,e){for(var t in n)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&aG(e,n,t)};Object.defineProperty(m,"__esModule",{value:!0});m.FolderRepairService=m.EffortVotingService=m.WorkflowCommandAdapter=m.VisibilityGenerator=m.InstantiationRuleResolver=m.WorkflowResolver=m.WorkflowEngine=m.EffortStatusWorkflow=m.ConceptCreationService=m.ClassCreationService=m.AreaHierarchyBuilder=m.AreaCreationService=m.TaskStatusService=m.CommandExecutionFlow=m.createVaultFrontmatterClassLabelResolver=m.ServiceRegistry=m.GroundingExecutor=m.registerDefaultHostFunctions=m.hasUidFilename=m.hasNonUidFilename=m.PreconditionEvaluator=m.CommandResolver=m.extractPropertyLabel=m.uriToPropertyName=m.propertyNameToUri=m.rangeToFieldType=m.PropertyFieldType=m.parseGroundingDefinitionFromFrontmatter=m.isCommandBindingFrontmatter=m.isGroundingFrontmatter=m.isPreconditionFrontmatter=m.isCommandFrontmatter=m.isStyleSource=m.isLabelClass=m.isCommandVariant=m.STYLE_SOURCE_VALUES=m.LABEL_CLASS_VALUES=m.COMMAND_VARIANT_VALUES=m.CommandBindingStyleProperty=m.CommandBindingProperty=m.GroundingProperty=m.PreconditionProperty=m.CommandProperty=m.resolveGroundingTypeFromWikilinkLiteral=m.resolveGroundingTypeFromIRI=m.GROUNDING_TYPE_IRI_TO_ENUM=m.GROUNDING_TYPE_UID_TO_ENUM=m.GROUNDING_TYPE_UIDS=m.GroundingType=m.EFFORT_STATUS_OPTIONS=void 0;m.NullLogger=m.RDFSerializer=m.FilenameValidator=m.EffortSortingHelpers=m.MetadataExtractor=m.MetadataHelpers=m.WikiLinkHelpers=m.DateFormatter=m.FrontmatterService=m.CriticalityZoneUUIDs=m.CriticalityZoneService=m.getTemplateByName=m.validateParameters=m.fillTemplate=m.findMatchingTemplates=m.findClassByTerm=m.KNOWN_CLASSES=m.KNOWN_PROTOTYPES=m.EFFORT_STATUSES=m.ASSET_CLASSES=m.PREDICATES=m.SPARQL_PREFIXES=m.SPARQL_TEMPLATES=m.DEFAULT_NL_TO_SPARQL_CONFIG=m.NLToSPARQLService=m.TypeRegistry=m.GraphQueryService=m.FixMissingLabelService=m.ArchiveAssetService=m.GenericAssetCreationService=m.URIConstructionService=m.SessionEventService=m.AssetConversionService=m.EnumValueResolver=m.ClassHierarchyResolver=m.PropertySchemaResolver=m.PlanningService=m.AlgorithmExtractor=m.orderProperties=m.loadDefaultSpec=m.clearOrderSpecLoader=m.registerOrderSpecLoader=m.DynamicFrontmatterGenerator=m.SupervisionCreationService=m.StatusTimestampService=m.RenameToUidService=m.PropertyCleanupService=m.LoggingService=m.LabelToAliasService=m.extractAssetReference=void 0;m.medianAggregate=m.EXO_AGGREGATE_NS=m.BUILT_IN_AGGREGATES=m.CustomAggregateError=m.CustomAggregateRegistry=m.AggregateFunctions=m.BuiltInFunctions=m.SolutionMapping=m.UpdateExecutorError=m.UpdateExecutor=m.QueryExecutor=m.ExoQLQueryExecutor=m.DescribeExecutor=m.ConstructExecutor=m.UnionExecutor=m.OptionalExecutor=m.FilterExecutor=m.BGPExecutor=m.AlgebraSerializer=m.AlgebraOptimizer=m.AlgebraTranslator=m.ExoQLAlgebraTranslator=m.DescribeOptionsTransformerError=m.DescribeOptionsTransformer=m.SPARQLParseError=m.SPARQLParser=m.ExoQLParser=m.shouldSkipFileForEffectiveSet=m.isPathExcluded=m.normaliseExcludedFolders=m.NoteToRDFConverter=m.SOURCE_VARIABLE=m.SourceAnnotator=m.MAX_LAZY_DEPTH=m.LazyAssetGraphLoader=m.IRICanonicalizer=m.INFERRED_GRAPH=m.PrototypeChainMaterializer=m.PropertyCardinalityRegistry=m.NonInheritablePropertyRegistry=m.RDFSInferenceEngine=m.RDFVocabularyMapper=m.DomainTriple=m.DomainBlankNode=m.DomainLiteral=m.DomainIRI=m.InMemoryTripleStore=m.OBSIDIAN_VAULT_SCHEME=m.iriToVaultPath=m.vaultPathToIRI=void 0;m.createRelationColumnSetFromFrontmatter=m.RELATION_COLUMN_SET_CLASS_UID=m.RELATION_COLUMN_SET_CLASS_IRI=m.ExoQLError=m.ExoQL=m.createStreamingSource=m.StreamingLoader=m.resetGlobalPool=m.getGlobalPool=m.MemoryPool=m.CompactGraphStore=m.StringTable=m.DEFAULT_COLORS=m.NODE_FLAGS=m.container=m.resetContainer=m.getContainer=m.createChildContainer=m.registerCoreServices=m.DI_TOKENS=m.DEFAULT_FLEETING_NOTE_CLASS_UID=m.DEFAULT_INBOX_FOLDER=m.DEFAULT_OWNER_IDENTITY=m.VaultSettings=m.seededUidGenerator=m.liveUidGenerator=m.frozenClock=m.liveClock=m.TransactionError=m.TripleNotFoundError=m.TripleAlreadyExistsError=m.FileAlreadyExistsError=m.FileNotFoundError=m.FilterContainsOptimizer=m.VaultPrefixTransformer=m.CaseWhenTransformerError=m.CaseWhenTransformer=m.ResultSerializer=m.createIncrementalIndexer=m.IncrementalIndexer=m.createSPARQLResultCache=m.SPARQLResultCache=m.QueryPlanCache=m.createDoubleLiteral=m.createDecimalLiteral=m.getNumericValue=m.createPercentileAggregate=m.modeAggregate=m.stddevAggregate=m.varianceAggregate=void 0;m.parseTarballGzip=m.parseTarball=m.TripleClassHierarchy=m.IDLE_TIMEOUT_MS=m.DEFAULT_SOCKET_PATH=m.ValidatorDaemon=m.ShaclShapeRegistry=m.shaclValidate=m.Namespace=m.ShapeRegistry=m.ShapeLoader=m.selectByPriority=m.LayoutSelector=m.isPropertiesBlock=m.isLayoutBlockFrontmatter=m.isBacklinksTableBlock=m.createLayoutBlockFromFrontmatter=m.PROPERTIES_BLOCK_CLASS_UID=m.PROPERTIES_BLOCK_CLASS_IRI=m.BACKLINKS_TABLE_BLOCK_CLASS_UID=m.BACKLINKS_TABLE_BLOCK_CLASS_IRI=m.isLayoutFrontmatter=m.isLayout=m.createLayoutFromFrontmatter=m.LAYOUT_CLASS_UID=m.LAYOUT_CLASS_IRI=m.RelationColumnSetResolver=m.normalizeRelationColumnSetRef=m.isRelationColumnSetFrontmatter=m.isRelationColumnSet=void 0;oi(Il(),m);oi(xl(),m);var lG=T0();Object.defineProperty(m,"EFFORT_STATUS_OPTIONS",{enumerable:!0,get:a(function(){return lG.EFFORT_STATUS_OPTIONS},"get")});var cG=Io();Object.defineProperty(m,"GroundingType",{enumerable:!0,get:a(function(){return cG.GroundingType},"get")});var Af=Cu();Object.defineProperty(m,"GROUNDING_TYPE_UIDS",{enumerable:!0,get:a(function(){return Af.GROUNDING_TYPE_UIDS},"get")});Object.defineProperty(m,"GROUNDING_TYPE_UID_TO_ENUM",{enumerable:!0,get:a(function(){return Af.GROUNDING_TYPE_UID_TO_ENUM},"get")});Object.defineProperty(m,"GROUNDING_TYPE_IRI_TO_ENUM",{enumerable:!0,get:a(function(){return Af.GROUNDING_TYPE_IRI_TO_ENUM},"get")});Object.defineProperty(m,"resolveGroundingTypeFromIRI",{enumerable:!0,get:a(function(){return Af.resolveGroundingTypeFromIRI},"get")});Object.defineProperty(m,"resolveGroundingTypeFromWikilinkLiteral",{enumerable:!0,get:a(function(){return Af.resolveGroundingTypeFromWikilinkLiteral},"get")});var Rf=I0();Object.defineProperty(m,"CommandProperty",{enumerable:!0,get:a(function(){return Rf.CommandProperty},"get")});Object.defineProperty(m,"PreconditionProperty",{enumerable:!0,get:a(function(){return Rf.PreconditionProperty},"get")});Object.defineProperty(m,"GroundingProperty",{enumerable:!0,get:a(function(){return Rf.GroundingProperty},"get")});Object.defineProperty(m,"CommandBindingProperty",{enumerable:!0,get:a(function(){return Rf.CommandBindingProperty},"get")});Object.defineProperty(m,"CommandBindingStyleProperty",{enumerable:!0,get:a(function(){return Rf.CommandBindingStyleProperty},"get")});var Pc=x0();Object.defineProperty(m,"COMMAND_VARIANT_VALUES",{enumerable:!0,get:a(function(){return Pc.COMMAND_VARIANT_VALUES},"get")});Object.defineProperty(m,"LABEL_CLASS_VALUES",{enumerable:!0,get:a(function(){return Pc.LABEL_CLASS_VALUES},"get")});Object.defineProperty(m,"STYLE_SOURCE_VALUES",{enumerable:!0,get:a(function(){return Pc.STYLE_SOURCE_VALUES},"get")});Object.defineProperty(m,"isCommandVariant",{enumerable:!0,get:a(function(){return Pc.isCommandVariant},"get")});Object.defineProperty(m,"isLabelClass",{enumerable:!0,get:a(function(){return Pc.isLabelClass},"get")});Object.defineProperty(m,"isStyleSource",{enumerable:!0,get:a(function(){return Pc.isStyleSource},"get")});var ag=PT();Object.defineProperty(m,"isCommandFrontmatter",{enumerable:!0,get:a(function(){return ag.isCommandFrontmatter},"get")});Object.defineProperty(m,"isPreconditionFrontmatter",{enumerable:!0,get:a(function(){return ag.isPreconditionFrontmatter},"get")});Object.defineProperty(m,"isGroundingFrontmatter",{enumerable:!0,get:a(function(){return ag.isGroundingFrontmatter},"get")});Object.defineProperty(m,"isCommandBindingFrontmatter",{enumerable:!0,get:a(function(){return ag.isCommandBindingFrontmatter},"get")});var uG=FT();Object.defineProperty(m,"parseGroundingDefinitionFromFrontmatter",{enumerable:!0,get:a(function(){return uG.parseGroundingDefinitionFromFrontmatter},"get")});oi(DT(),m);oi(LT(),m);oi(R0(),m);oi(C0(),m);oi(kT(),m);oi($T(),m);oi(u_(),m);oi(_I(),m);var CR=yh();Object.defineProperty(m,"PropertyFieldType",{enumerable:!0,get:a(function(){return CR.PropertyFieldType},"get")});Object.defineProperty(m,"rangeToFieldType",{enumerable:!0,get:a(function(){return CR.rangeToFieldType},"get")});var bv=h_();Object.defineProperty(m,"propertyNameToUri",{enumerable:!0,get:a(function(){return bv.propertyNameToUri},"get")});Object.defineProperty(m,"uriToPropertyName",{enumerable:!0,get:a(function(){return bv.uriToPropertyName},"get")});Object.defineProperty(m,"extractPropertyLabel",{enumerable:!0,get:a(function(){return bv.extractPropertyLabel},"get")});var fG=rA();Object.defineProperty(m,"CommandResolver",{enumerable:!0,get:a(function(){return fG.CommandResolver},"get")});var dG=iA();Object.defineProperty(m,"PreconditionEvaluator",{enumerable:!0,get:a(function(){return dG.PreconditionEvaluator},"get")});var Sv=sA();Object.defineProperty(m,"hasNonUidFilename",{enumerable:!0,get:a(function(){return Sv.hasNonUidFilename},"get")});Object.defineProperty(m,"hasUidFilename",{enumerable:!0,get:a(function(){return Sv.hasUidFilename},"get")});Object.defineProperty(m,"registerDefaultHostFunctions",{enumerable:!0,get:a(function(){return Sv.registerDefaultHostFunctions},"get")});var PR=fA();Object.defineProperty(m,"GroundingExecutor",{enumerable:!0,get:a(function(){return PR.GroundingExecutor},"get")});Object.defineProperty(m,"ServiceRegistry",{enumerable:!0,get:a(function(){return PR.ServiceRegistry},"get")});var hG=dA();Object.defineProperty(m,"createVaultFrontmatterClassLabelResolver",{enumerable:!0,get:a(function(){return hG.createVaultFrontmatterClassLabelResolver},"get")});var pG=hA();Object.defineProperty(m,"CommandExecutionFlow",{enumerable:!0,get:a(function(){return pG.CommandExecutionFlow},"get")});var mG=U1();Object.defineProperty(m,"TaskStatusService",{enumerable:!0,get:a(function(){return mG.TaskStatusService},"get")});var gG=q1();Object.defineProperty(m,"AreaCreationService",{enumerable:!0,get:a(function(){return gG.AreaCreationService},"get")});var yG=z1();Object.defineProperty(m,"AreaHierarchyBuilder",{enumerable:!0,get:a(function(){return yG.AreaHierarchyBuilder},"get")});var _G=Q1();Object.defineProperty(m,"ClassCreationService",{enumerable:!0,get:a(function(){return _G.ClassCreationService},"get")});var bG=X1();Object.defineProperty(m,"ConceptCreationService",{enumerable:!0,get:a(function(){return bG.ConceptCreationService},"get")});var SG=sm();Object.defineProperty(m,"EffortStatusWorkflow",{enumerable:!0,get:a(function(){return SG.EffortStatusWorkflow},"get")});var wG=uf();Object.defineProperty(m,"WorkflowEngine",{enumerable:!0,get:a(function(){return wG.WorkflowEngine},"get")});var vG=R1();Object.defineProperty(m,"WorkflowResolver",{enumerable:!0,get:a(function(){return vG.WorkflowResolver},"get")});var EG=RA();Object.defineProperty(m,"InstantiationRuleResolver",{enumerable:!0,get:a(function(){return EG.InstantiationRuleResolver},"get")});var TG=CA();Object.defineProperty(m,"VisibilityGenerator",{enumerable:!0,get:a(function(){return TG.VisibilityGenerator},"get")});var IG=PA();Object.defineProperty(m,"WorkflowCommandAdapter",{enumerable:!0,get:a(function(){return IG.WorkflowCommandAdapter},"get")});var xG=nS();Object.defineProperty(m,"EffortVotingService",{enumerable:!0,get:a(function(){return xG.EffortVotingService},"get")});var AG=aS();Object.defineProperty(m,"FolderRepairService",{enumerable:!0,get:a(function(){return AG.FolderRepairService},"get")});var RG=sS();Object.defineProperty(m,"extractAssetReference",{enumerable:!0,get:a(function(){return RG.extractAssetReference},"get")});var CG=cS();Object.defineProperty(m,"LabelToAliasService",{enumerable:!0,get:a(function(){return CG.LabelToAliasService},"get")});var PG=$o();Object.defineProperty(m,"LoggingService",{enumerable:!0,get:a(function(){return PG.LoggingService},"get")});var OG=dS();Object.defineProperty(m,"PropertyCleanupService",{enumerable:!0,get:a(function(){return OG.PropertyCleanupService},"get")});var FG=pS();Object.defineProperty(m,"RenameToUidService",{enumerable:!0,get:a(function(){return FG.RenameToUidService},"get")});var DG=am();Object.defineProperty(m,"StatusTimestampService",{enumerable:!0,get:a(function(){return DG.StatusTimestampService},"get")});var LG=yS();Object.defineProperty(m,"SupervisionCreationService",{enumerable:!0,get:a(function(){return LG.SupervisionCreationService},"get")});var NG=bS();Object.defineProperty(m,"DynamicFrontmatterGenerator",{enumerable:!0,get:a(function(){return NG.DynamicFrontmatterGenerator},"get")});var lg=af();Object.defineProperty(m,"registerOrderSpecLoader",{enumerable:!0,get:a(function(){return lg.registerOrderSpecLoader},"get")});Object.defineProperty(m,"clearOrderSpecLoader",{enumerable:!0,get:a(function(){return lg.clearOrderSpecLoader},"get")});Object.defineProperty(m,"loadDefaultSpec",{enumerable:!0,get:a(function(){return lg.loadDefaultSpec},"get")});Object.defineProperty(m,"orderProperties",{enumerable:!0,get:a(function(){return lg.orderProperties},"get")});var kG=wS();Object.defineProperty(m,"AlgorithmExtractor",{enumerable:!0,get:a(function(){return kG.AlgorithmExtractor},"get")});var MG=ES();Object.defineProperty(m,"PlanningService",{enumerable:!0,get:a(function(){return MG.PlanningService},"get")});var jG=BA();Object.defineProperty(m,"PropertySchemaResolver",{enumerable:!0,get:a(function(){return jG.PropertySchemaResolver},"get")});var $G=GA();Object.defineProperty(m,"ClassHierarchyResolver",{enumerable:!0,get:a(function(){return $G.ClassHierarchyResolver},"get")});var UG=qA();Object.defineProperty(m,"EnumValueResolver",{enumerable:!0,get:a(function(){return UG.EnumValueResolver},"get")});var VG=RS();Object.defineProperty(m,"AssetConversionService",{enumerable:!0,get:a(function(){return VG.AssetConversionService},"get")});var BG=OS();Object.defineProperty(m,"SessionEventService",{enumerable:!0,get:a(function(){return BG.SessionEventService},"get")});var GG=LS();Object.defineProperty(m,"URIConstructionService",{enumerable:!0,get:a(function(){return GG.URIConstructionService},"get")});var qG=kS();Object.defineProperty(m,"GenericAssetCreationService",{enumerable:!0,get:a(function(){return qG.GenericAssetCreationService},"get")});var WG=e3();Object.defineProperty(m,"ArchiveAssetService",{enumerable:!0,get:a(function(){return WG.ArchiveAssetService},"get")});var zG=r3();Object.defineProperty(m,"FixMissingLabelService",{enumerable:!0,get:a(function(){return zG.FixMissingLabelService},"get")});var HG=n3();Object.defineProperty(m,"GraphQueryService",{enumerable:!0,get:a(function(){return HG.GraphQueryService},"get")});var QG=s3();Object.defineProperty(m,"TypeRegistry",{enumerable:!0,get:a(function(){return QG.TypeRegistry},"get")});var OR=o3();Object.defineProperty(m,"NLToSPARQLService",{enumerable:!0,get:a(function(){return OR.NLToSPARQLService},"get")});Object.defineProperty(m,"DEFAULT_NL_TO_SPARQL_CONFIG",{enumerable:!0,get:a(function(){return OR.DEFAULT_NL_TO_SPARQL_CONFIG},"get")});var ai=VS();Object.defineProperty(m,"SPARQL_TEMPLATES",{enumerable:!0,get:a(function(){return ai.SPARQL_TEMPLATES},"get")});Object.defineProperty(m,"SPARQL_PREFIXES",{enumerable:!0,get:a(function(){return ai.SPARQL_PREFIXES},"get")});Object.defineProperty(m,"PREDICATES",{enumerable:!0,get:a(function(){return ai.PREDICATES},"get")});Object.defineProperty(m,"ASSET_CLASSES",{enumerable:!0,get:a(function(){return ai.ASSET_CLASSES},"get")});Object.defineProperty(m,"EFFORT_STATUSES",{enumerable:!0,get:a(function(){return ai.EFFORT_STATUSES},"get")});Object.defineProperty(m,"KNOWN_PROTOTYPES",{enumerable:!0,get:a(function(){return ai.KNOWN_PROTOTYPES},"get")});Object.defineProperty(m,"KNOWN_CLASSES",{enumerable:!0,get:a(function(){return ai.KNOWN_CLASSES},"get")});Object.defineProperty(m,"findClassByTerm",{enumerable:!0,get:a(function(){return ai.findClassByTerm},"get")});Object.defineProperty(m,"findMatchingTemplates",{enumerable:!0,get:a(function(){return ai.findMatchingTemplates},"get")});Object.defineProperty(m,"fillTemplate",{enumerable:!0,get:a(function(){return ai.fillTemplate},"get")});Object.defineProperty(m,"validateParameters",{enumerable:!0,get:a(function(){return ai.validateParameters},"get")});Object.defineProperty(m,"getTemplateByName",{enumerable:!0,get:a(function(){return ai.getTemplateByName},"get")});var FR=qS();Object.defineProperty(m,"CriticalityZoneService",{enumerable:!0,get:a(function(){return FR.CriticalityZoneService},"get")});Object.defineProperty(m,"CriticalityZoneUUIDs",{enumerable:!0,get:a(function(){return FR.CriticalityZoneUUIDs},"get")});var YG=cs();Object.defineProperty(m,"FrontmatterService",{enumerable:!0,get:a(function(){return YG.FrontmatterService},"get")});var XG=Fn();Object.defineProperty(m,"DateFormatter",{enumerable:!0,get:a(function(){return XG.DateFormatter},"get")});var KG=Us();Object.defineProperty(m,"WikiLinkHelpers",{enumerable:!0,get:a(function(){return KG.WikiLinkHelpers},"get")});var JG=Js();Object.defineProperty(m,"MetadataHelpers",{enumerable:!0,get:a(function(){return JG.MetadataHelpers},"get")});var ZG=B1();Object.defineProperty(m,"MetadataExtractor",{enumerable:!0,get:a(function(){return ZG.MetadataExtractor},"get")});var eq=l3();Object.defineProperty(m,"EffortSortingHelpers",{enumerable:!0,get:a(function(){return eq.EffortSortingHelpers},"get")});var tq=c3();Object.defineProperty(m,"FilenameValidator",{enumerable:!0,get:a(function(){return tq.FilenameValidator},"get")});var rq=g3();Object.defineProperty(m,"RDFSerializer",{enumerable:!0,get:a(function(){return rq.RDFSerializer},"get")});var nq=Cl();Object.defineProperty(m,"NullLogger",{enumerable:!0,get:a(function(){return nq.NullLogger},"get")});var wv=rw();Object.defineProperty(m,"vaultPathToIRI",{enumerable:!0,get:a(function(){return wv.vaultPathToIRI},"get")});Object.defineProperty(m,"iriToVaultPath",{enumerable:!0,get:a(function(){return wv.iriToVaultPath},"get")});Object.defineProperty(m,"OBSIDIAN_VAULT_SCHEME",{enumerable:!0,get:a(function(){return wv.OBSIDIAN_VAULT_SCHEME},"get")});var iq=k1();Object.defineProperty(m,"InMemoryTripleStore",{enumerable:!0,get:a(function(){return iq.InMemoryTripleStore},"get")});var sq=Ae();Object.defineProperty(m,"DomainIRI",{enumerable:!0,get:a(function(){return sq.IRI},"get")});var oq=$e();Object.defineProperty(m,"DomainLiteral",{enumerable:!0,get:a(function(){return oq.Literal},"get")});var aq=$t();Object.defineProperty(m,"DomainBlankNode",{enumerable:!0,get:a(function(){return aq.BlankNode},"get")});var lq=Bn();Object.defineProperty(m,"DomainTriple",{enumerable:!0,get:a(function(){return lq.Triple},"get")});var cq=iw();Object.defineProperty(m,"RDFVocabularyMapper",{enumerable:!0,get:a(function(){return cq.RDFVocabularyMapper},"get")});var uq=_3();Object.defineProperty(m,"RDFSInferenceEngine",{enumerable:!0,get:a(function(){return uq.RDFSInferenceEngine},"get")});var fq=lw();Object.defineProperty(m,"NonInheritablePropertyRegistry",{enumerable:!0,get:a(function(){return fq.NonInheritablePropertyRegistry},"get")});var dq=fw();Object.defineProperty(m,"PropertyCardinalityRegistry",{enumerable:!0,get:a(function(){return dq.PropertyCardinalityRegistry},"get")});var DR=pw();Object.defineProperty(m,"PrototypeChainMaterializer",{enumerable:!0,get:a(function(){return DR.PrototypeChainMaterializer},"get")});Object.defineProperty(m,"INFERRED_GRAPH",{enumerable:!0,get:a(function(){return DR.INFERRED_GRAPH},"get")});var hq=I3();Object.defineProperty(m,"IRICanonicalizer",{enumerable:!0,get:a(function(){return hq.IRICanonicalizer},"get")});var LR=x3();Object.defineProperty(m,"LazyAssetGraphLoader",{enumerable:!0,get:a(function(){return LR.LazyAssetGraphLoader},"get")});Object.defineProperty(m,"MAX_LAZY_DEPTH",{enumerable:!0,get:a(function(){return LR.MAX_LAZY_DEPTH},"get")});var NR=bw();Object.defineProperty(m,"SourceAnnotator",{enumerable:!0,get:a(function(){return NR.SourceAnnotator},"get")});Object.defineProperty(m,"SOURCE_VARIABLE",{enumerable:!0,get:a(function(){return NR.SOURCE_VARIABLE},"get")});var cg=Ew();Object.defineProperty(m,"NoteToRDFConverter",{enumerable:!0,get:a(function(){return cg.NoteToRDFConverter},"get")});Object.defineProperty(m,"normaliseExcludedFolders",{enumerable:!0,get:a(function(){return cg.normaliseExcludedFolders},"get")});Object.defineProperty(m,"isPathExcluded",{enumerable:!0,get:a(function(){return cg.isPathExcluded},"get")});Object.defineProperty(m,"shouldSkipFileForEffectiveSet",{enumerable:!0,get:a(function(){return cg.shouldSkipFileForEffectiveSet},"get")});var vv=$l();Object.defineProperty(m,"ExoQLParser",{enumerable:!0,get:a(function(){return vv.ExoQLParser},"get")});Object.defineProperty(m,"SPARQLParser",{enumerable:!0,get:a(function(){return vv.SPARQLParser},"get")});Object.defineProperty(m,"SPARQLParseError",{enumerable:!0,get:a(function(){return vv.SPARQLParseError},"get")});var kR=fb();Object.defineProperty(m,"DescribeOptionsTransformer",{enumerable:!0,get:a(function(){return kR.DescribeOptionsTransformer},"get")});Object.defineProperty(m,"DescribeOptionsTransformerError",{enumerable:!0,get:a(function(){return kR.DescribeOptionsTransformerError},"get")});var MR=Vl();Object.defineProperty(m,"ExoQLAlgebraTranslator",{enumerable:!0,get:a(function(){return MR.ExoQLAlgebraTranslator},"get")});Object.defineProperty(m,"AlgebraTranslator",{enumerable:!0,get:a(function(){return MR.AlgebraTranslator},"get")});var pq=D3();Object.defineProperty(m,"AlgebraOptimizer",{enumerable:!0,get:a(function(){return pq.AlgebraOptimizer},"get")});var mq=L3();Object.defineProperty(m,"AlgebraSerializer",{enumerable:!0,get:a(function(){return mq.AlgebraSerializer},"get")});var gq=Cb();Object.defineProperty(m,"BGPExecutor",{enumerable:!0,get:a(function(){return gq.BGPExecutor},"get")});var yq=Ip();Object.defineProperty(m,"FilterExecutor",{enumerable:!0,get:a(function(){return yq.FilterExecutor},"get")});var _q=Qb();Object.defineProperty(m,"OptionalExecutor",{enumerable:!0,get:a(function(){return _q.OptionalExecutor},"get")});var bq=Xb();Object.defineProperty(m,"UnionExecutor",{enumerable:!0,get:a(function(){return bq.UnionExecutor},"get")});var Sq=o1();Object.defineProperty(m,"ConstructExecutor",{enumerable:!0,get:a(function(){return Sq.ConstructExecutor},"get")});var wq=k3();Object.defineProperty(m,"DescribeExecutor",{enumerable:!0,get:a(function(){return wq.DescribeExecutor},"get")});var jR=lc();Object.defineProperty(m,"ExoQLQueryExecutor",{enumerable:!0,get:a(function(){return jR.ExoQLQueryExecutor},"get")});Object.defineProperty(m,"QueryExecutor",{enumerable:!0,get:a(function(){return jR.QueryExecutor},"get")});var $R=j3();Object.defineProperty(m,"UpdateExecutor",{enumerable:!0,get:a(function(){return $R.UpdateExecutor},"get")});Object.defineProperty(m,"UpdateExecutorError",{enumerable:!0,get:a(function(){return $R.UpdateExecutorError},"get")});var vq=ss();Object.defineProperty(m,"SolutionMapping",{enumerable:!0,get:a(function(){return vq.SolutionMapping},"get")});var Eq=Tp();Object.defineProperty(m,"BuiltInFunctions",{enumerable:!0,get:a(function(){return Eq.BuiltInFunctions},"get")});var Tq=U3();Object.defineProperty(m,"AggregateFunctions",{enumerable:!0,get:a(function(){return Tq.AggregateFunctions},"get")});var UR=Zb();Object.defineProperty(m,"CustomAggregateRegistry",{enumerable:!0,get:a(function(){return UR.CustomAggregateRegistry},"get")});Object.defineProperty(m,"CustomAggregateError",{enumerable:!0,get:a(function(){return UR.CustomAggregateError},"get")});var bs=e1();Object.defineProperty(m,"BUILT_IN_AGGREGATES",{enumerable:!0,get:a(function(){return bs.BUILT_IN_AGGREGATES},"get")});Object.defineProperty(m,"EXO_AGGREGATE_NS",{enumerable:!0,get:a(function(){return bs.EXO_AGGREGATE_NS},"get")});Object.defineProperty(m,"medianAggregate",{enumerable:!0,get:a(function(){return bs.medianAggregate},"get")});Object.defineProperty(m,"varianceAggregate",{enumerable:!0,get:a(function(){return bs.varianceAggregate},"get")});Object.defineProperty(m,"stddevAggregate",{enumerable:!0,get:a(function(){return bs.stddevAggregate},"get")});Object.defineProperty(m,"modeAggregate",{enumerable:!0,get:a(function(){return bs.modeAggregate},"get")});Object.defineProperty(m,"createPercentileAggregate",{enumerable:!0,get:a(function(){return bs.createPercentileAggregate},"get")});Object.defineProperty(m,"getNumericValue",{enumerable:!0,get:a(function(){return bs.getNumericValue},"get")});Object.defineProperty(m,"createDecimalLiteral",{enumerable:!0,get:a(function(){return bs.createDecimalLiteral},"get")});Object.defineProperty(m,"createDoubleLiteral",{enumerable:!0,get:a(function(){return bs.createDoubleLiteral},"get")});var Iq=V3();Object.defineProperty(m,"QueryPlanCache",{enumerable:!0,get:a(function(){return Iq.QueryPlanCache},"get")});var VR=B3();Object.defineProperty(m,"SPARQLResultCache",{enumerable:!0,get:a(function(){return VR.SPARQLResultCache},"get")});Object.defineProperty(m,"createSPARQLResultCache",{enumerable:!0,get:a(function(){return VR.createSPARQLResultCache},"get")});var BR=G3();Object.defineProperty(m,"IncrementalIndexer",{enumerable:!0,get:a(function(){return BR.IncrementalIndexer},"get")});Object.defineProperty(m,"createIncrementalIndexer",{enumerable:!0,get:a(function(){return BR.createIncrementalIndexer},"get")});var xq=q3();Object.defineProperty(m,"ResultSerializer",{enumerable:!0,get:a(function(){return xq.ResultSerializer},"get")});var GR=lb();Object.defineProperty(m,"CaseWhenTransformer",{enumerable:!0,get:a(function(){return GR.CaseWhenTransformer},"get")});Object.defineProperty(m,"CaseWhenTransformerError",{enumerable:!0,get:a(function(){return GR.CaseWhenTransformerError},"get")});var Aq=mb();Object.defineProperty(m,"VaultPrefixTransformer",{enumerable:!0,get:a(function(){return Aq.VaultPrefixTransformer},"get")});var Rq=Iw();Object.defineProperty(m,"FilterContainsOptimizer",{enumerable:!0,get:a(function(){return Rq.FilterContainsOptimizer},"get")});var qR=W3();Object.defineProperty(m,"FileNotFoundError",{enumerable:!0,get:a(function(){return qR.FileNotFoundError},"get")});Object.defineProperty(m,"FileAlreadyExistsError",{enumerable:!0,get:a(function(){return qR.FileAlreadyExistsError},"get")});var Ev=F1();Object.defineProperty(m,"TripleAlreadyExistsError",{enumerable:!0,get:a(function(){return Ev.TripleAlreadyExistsError},"get")});Object.defineProperty(m,"TripleNotFoundError",{enumerable:!0,get:a(function(){return Ev.TripleNotFoundError},"get")});Object.defineProperty(m,"TransactionError",{enumerable:!0,get:a(function(){return Ev.TransactionError},"get")});var WR=nf();Object.defineProperty(m,"liveClock",{enumerable:!0,get:a(function(){return WR.liveClock},"get")});Object.defineProperty(m,"frozenClock",{enumerable:!0,get:a(function(){return WR.frozenClock},"get")});var zR=Bp();Object.defineProperty(m,"liveUidGenerator",{enumerable:!0,get:a(function(){return zR.liveUidGenerator},"get")});Object.defineProperty(m,"seededUidGenerator",{enumerable:!0,get:a(function(){return zR.seededUidGenerator},"get")});var ug=jw();Object.defineProperty(m,"VaultSettings",{enumerable:!0,get:a(function(){return ug.VaultSettings},"get")});Object.defineProperty(m,"DEFAULT_OWNER_IDENTITY",{enumerable:!0,get:a(function(){return ug.DEFAULT_OWNER_IDENTITY},"get")});Object.defineProperty(m,"DEFAULT_INBOX_FOLDER",{enumerable:!0,get:a(function(){return ug.DEFAULT_INBOX_FOLDER},"get")});Object.defineProperty(m,"DEFAULT_FLEETING_NOTE_CLASS_UID",{enumerable:!0,get:a(function(){return ug.DEFAULT_FLEETING_NOTE_CLASS_UID},"get")});var Cq=Ft();Object.defineProperty(m,"DI_TOKENS",{enumerable:!0,get:a(function(){return Cq.DI_TOKENS},"get")});var Cf=z3();Object.defineProperty(m,"registerCoreServices",{enumerable:!0,get:a(function(){return Cf.registerCoreServices},"get")});Object.defineProperty(m,"createChildContainer",{enumerable:!0,get:a(function(){return Cf.createChildContainer},"get")});Object.defineProperty(m,"getContainer",{enumerable:!0,get:a(function(){return Cf.getContainer},"get")});Object.defineProperty(m,"resetContainer",{enumerable:!0,get:a(function(){return Cf.resetContainer},"get")});Object.defineProperty(m,"container",{enumerable:!0,get:a(function(){return Cf.container},"get")});var ho=J3();Object.defineProperty(m,"NODE_FLAGS",{enumerable:!0,get:a(function(){return ho.NODE_FLAGS},"get")});Object.defineProperty(m,"DEFAULT_COLORS",{enumerable:!0,get:a(function(){return ho.DEFAULT_COLORS},"get")});Object.defineProperty(m,"StringTable",{enumerable:!0,get:a(function(){return ho.StringTable},"get")});Object.defineProperty(m,"CompactGraphStore",{enumerable:!0,get:a(function(){return ho.CompactGraphStore},"get")});Object.defineProperty(m,"MemoryPool",{enumerable:!0,get:a(function(){return ho.MemoryPool},"get")});Object.defineProperty(m,"getGlobalPool",{enumerable:!0,get:a(function(){return ho.getGlobalPool},"get")});Object.defineProperty(m,"resetGlobalPool",{enumerable:!0,get:a(function(){return ho.resetGlobalPool},"get")});Object.defineProperty(m,"StreamingLoader",{enumerable:!0,get:a(function(){return ho.StreamingLoader},"get")});Object.defineProperty(m,"createStreamingSource",{enumerable:!0,get:a(function(){return ho.createStreamingSource},"get")});var HR=Z3();Object.defineProperty(m,"ExoQL",{enumerable:!0,get:a(function(){return HR.ExoQL},"get")});Object.defineProperty(m,"ExoQLError",{enumerable:!0,get:a(function(){return HR.ExoQLError},"get")});var Oc=Gm();Object.defineProperty(m,"RELATION_COLUMN_SET_CLASS_IRI",{enumerable:!0,get:a(function(){return Oc.RELATION_COLUMN_SET_CLASS_IRI},"get")});Object.defineProperty(m,"RELATION_COLUMN_SET_CLASS_UID",{enumerable:!0,get:a(function(){return Oc.RELATION_COLUMN_SET_CLASS_UID},"get")});Object.defineProperty(m,"createRelationColumnSetFromFrontmatter",{enumerable:!0,get:a(function(){return Oc.createRelationColumnSetFromFrontmatter},"get")});Object.defineProperty(m,"isRelationColumnSet",{enumerable:!0,get:a(function(){return Oc.isRelationColumnSet},"get")});Object.defineProperty(m,"isRelationColumnSetFrontmatter",{enumerable:!0,get:a(function(){return Oc.isRelationColumnSetFrontmatter},"get")});Object.defineProperty(m,"normalizeRelationColumnSetRef",{enumerable:!0,get:a(function(){return Oc.normalizeRef},"get")});var Pq=lR();Object.defineProperty(m,"RelationColumnSetResolver",{enumerable:!0,get:a(function(){return Pq.RelationColumnSetResolver},"get")});var Pf=Gm();Object.defineProperty(m,"LAYOUT_CLASS_IRI",{enumerable:!0,get:a(function(){return Pf.LAYOUT_CLASS_IRI},"get")});Object.defineProperty(m,"LAYOUT_CLASS_UID",{enumerable:!0,get:a(function(){return Pf.LAYOUT_CLASS_UID},"get")});Object.defineProperty(m,"createLayoutFromFrontmatter",{enumerable:!0,get:a(function(){return Pf.createLayoutFromFrontmatter},"get")});Object.defineProperty(m,"isLayout",{enumerable:!0,get:a(function(){return Pf.isLayout},"get")});Object.defineProperty(m,"isLayoutFrontmatter",{enumerable:!0,get:a(function(){return Pf.isLayoutFrontmatter},"get")});var Ho=Gm();Object.defineProperty(m,"BACKLINKS_TABLE_BLOCK_CLASS_IRI",{enumerable:!0,get:a(function(){return Ho.BACKLINKS_TABLE_BLOCK_CLASS_IRI},"get")});Object.defineProperty(m,"BACKLINKS_TABLE_BLOCK_CLASS_UID",{enumerable:!0,get:a(function(){return Ho.BACKLINKS_TABLE_BLOCK_CLASS_UID},"get")});Object.defineProperty(m,"PROPERTIES_BLOCK_CLASS_IRI",{enumerable:!0,get:a(function(){return Ho.PROPERTIES_BLOCK_CLASS_IRI},"get")});Object.defineProperty(m,"PROPERTIES_BLOCK_CLASS_UID",{enumerable:!0,get:a(function(){return Ho.PROPERTIES_BLOCK_CLASS_UID},"get")});Object.defineProperty(m,"createLayoutBlockFromFrontmatter",{enumerable:!0,get:a(function(){return Ho.createLayoutBlockFromFrontmatter},"get")});Object.defineProperty(m,"isBacklinksTableBlock",{enumerable:!0,get:a(function(){return Ho.isBacklinksTableBlock},"get")});Object.defineProperty(m,"isLayoutBlockFrontmatter",{enumerable:!0,get:a(function(){return Ho.isLayoutBlockFrontmatter},"get")});Object.defineProperty(m,"isPropertiesBlock",{enumerable:!0,get:a(function(){return Ho.isPropertiesBlock},"get")});var QR=uR();Object.defineProperty(m,"LayoutSelector",{enumerable:!0,get:a(function(){return QR.LayoutSelector},"get")});Object.defineProperty(m,"selectByPriority",{enumerable:!0,get:a(function(){return QR.selectByPriority},"get")});oi(bR(),m);var Oq=fv();Object.defineProperty(m,"ShapeLoader",{enumerable:!0,get:a(function(){return Oq.ShapeLoader},"get")});var Fq=lv();Object.defineProperty(m,"ShapeRegistry",{enumerable:!0,get:a(function(){return Fq.ShapeRegistry},"get")});var Dq=er();Object.defineProperty(m,"Namespace",{enumerable:!0,get:a(function(){return Dq.Namespace},"get")});var YR=hv();Object.defineProperty(m,"shaclValidate",{enumerable:!0,get:a(function(){return YR.validate},"get")});Object.defineProperty(m,"ShaclShapeRegistry",{enumerable:!0,get:a(function(){return YR.ShapeRegistry},"get")});oi(vR(),m);var Tv=TR();Object.defineProperty(m,"ValidatorDaemon",{enumerable:!0,get:a(function(){return Tv.ValidatorDaemon},"get")});Object.defineProperty(m,"DEFAULT_SOCKET_PATH",{enumerable:!0,get:a(function(){return Tv.DEFAULT_SOCKET_PATH},"get")});Object.defineProperty(m,"IDLE_TIMEOUT_MS",{enumerable:!0,get:a(function(){return Tv.IDLE_TIMEOUT_MS},"get")});var Lq=yv();Object.defineProperty(m,"TripleClassHierarchy",{enumerable:!0,get:a(function(){return Lq.ClassHierarchy},"get")});var XR=RR();Object.defineProperty(m,"parseTarball",{enumerable:!0,get:a(function(){return XR.parseTarball},"get")});Object.defineProperty(m,"parseTarballGzip",{enumerable:!0,get:a(function(){return XR.parseTarballGzip},"get")})});var Er=S(Iv=>{"use strict";Iv.fromCallback=function(n){return Object.defineProperty(function(...e){if(typeof e[e.length-1]=="function")n.apply(this,e);else return new Promise((t,r)=>{e.push((i,s)=>i!=null?r(i):t(s)),n.apply(this,e)})},"name",{value:n.name})};Iv.fromPromise=function(n){return Object.defineProperty(function(...e){let t=e[e.length-1];if(typeof t!="function")return n.apply(this,e);e.pop(),n.apply(this,e).then(r=>t(null,r),t)},"name",{value:n.name})}});var JR=S((Ife,KR)=>{var Qo=require("constants"),Nq=process.cwd,fg=null,kq=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return fg||(fg=Nq.call(process)),fg};try{process.cwd()}catch{}typeof process.chdir=="function"&&(xv=process.chdir,process.chdir=function(n){fg=null,xv.call(process,n)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,xv));var xv;KR.exports=Mq;function Mq(n){Qo.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(n),n.lutimes||t(n),n.chown=s(n.chown),n.fchown=s(n.fchown),n.lchown=s(n.lchown),n.chmod=r(n.chmod),n.fchmod=r(n.fchmod),n.lchmod=r(n.lchmod),n.chownSync=o(n.chownSync),n.fchownSync=o(n.fchownSync),n.lchownSync=o(n.lchownSync),n.chmodSync=i(n.chmodSync),n.fchmodSync=i(n.fchmodSync),n.lchmodSync=i(n.lchmodSync),n.stat=l(n.stat),n.fstat=l(n.fstat),n.lstat=l(n.lstat),n.statSync=c(n.statSync),n.fstatSync=c(n.fstatSync),n.lstatSync=c(n.lstatSync),n.chmod&&!n.lchmod&&(n.lchmod=function(f,d,h){h&&process.nextTick(h)},n.lchmodSync=function(){}),n.chown&&!n.lchown&&(n.lchown=function(f,d,h,p){p&&process.nextTick(p)},n.lchownSync=function(){}),kq==="win32"&&(n.rename=typeof n.rename!="function"?n.rename:(function(f){function d(h,p,g){var _=Date.now(),v=0;f(h,p,a(function w(E){if(E&&(E.code==="EACCES"||E.code==="EPERM"||E.code==="EBUSY")&&Date.now()-_<6e4){setTimeout(function(){n.stat(p,function(I,O){I&&I.code==="ENOENT"?f(h,p,w):g(E)})},v),v<100&&(v+=10);return}g&&g(E)},"CB"))}return a(d,"rename"),Object.setPrototypeOf&&Object.setPrototypeOf(d,f),d})(n.rename)),n.read=typeof n.read!="function"?n.read:(function(f){function d(h,p,g,_,v,w){var E;if(w&&typeof w=="function"){var I=0;E=a(function(O,C,H){if(O&&O.code==="EAGAIN"&&I<10)return I++,f.call(n,h,p,g,_,v,E);w.apply(this,arguments)},"callback")}return f.call(n,h,p,g,_,v,E)}return a(d,"read"),Object.setPrototypeOf&&Object.setPrototypeOf(d,f),d})(n.read),n.readSync=typeof n.readSync!="function"?n.readSync:(function(f){return function(d,h,p,g,_){for(var v=0;;)try{return f.call(n,d,h,p,g,_)}catch(w){if(w.code==="EAGAIN"&&v<10){v++;continue}throw w}}})(n.readSync);function e(f){f.lchmod=function(d,h,p){f.open(d,Qo.O_WRONLY|Qo.O_SYMLINK,h,function(g,_){if(g){p&&p(g);return}f.fchmod(_,h,function(v){f.close(_,function(w){p&&p(v||w)})})})},f.lchmodSync=function(d,h){var p=f.openSync(d,Qo.O_WRONLY|Qo.O_SYMLINK,h),g=!0,_;try{_=f.fchmodSync(p,h),g=!1}finally{if(g)try{f.closeSync(p)}catch{}else f.closeSync(p)}return _}}a(e,"patchLchmod");function t(f){Qo.hasOwnProperty("O_SYMLINK")&&f.futimes?(f.lutimes=function(d,h,p,g){f.open(d,Qo.O_SYMLINK,function(_,v){if(_){g&&g(_);return}f.futimes(v,h,p,function(w){f.close(v,function(E){g&&g(w||E)})})})},f.lutimesSync=function(d,h,p){var g=f.openSync(d,Qo.O_SYMLINK),_,v=!0;try{_=f.futimesSync(g,h,p),v=!1}finally{if(v)try{f.closeSync(g)}catch{}else f.closeSync(g)}return _}):f.futimes&&(f.lutimes=function(d,h,p,g){g&&process.nextTick(g)},f.lutimesSync=function(){})}a(t,"patchLutimes");function r(f){return f&&function(d,h,p){return f.call(n,d,h,function(g){u(g)&&(g=null),p&&p.apply(this,arguments)})}}a(r,"chmodFix");function i(f){return f&&function(d,h){try{return f.call(n,d,h)}catch(p){if(!u(p))throw p}}}a(i,"chmodFixSync");function s(f){return f&&function(d,h,p,g){return f.call(n,d,h,p,function(_){u(_)&&(_=null),g&&g.apply(this,arguments)})}}a(s,"chownFix");function o(f){return f&&function(d,h,p){try{return f.call(n,d,h,p)}catch(g){if(!u(g))throw g}}}a(o,"chownFixSync");function l(f){return f&&function(d,h,p){typeof h=="function"&&(p=h,h=null);function g(_,v){v&&(v.uid<0&&(v.uid+=4294967296),v.gid<0&&(v.gid+=4294967296)),p&&p.apply(this,arguments)}return a(g,"callback"),h?f.call(n,d,h,g):f.call(n,d,g)}}a(l,"statFix");function c(f){return f&&function(d,h){var p=h?f.call(n,d,h):f.call(n,d);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}a(c,"statFixSync");function u(f){if(!f||f.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(f.code==="EINVAL"||f.code==="EPERM"))}a(u,"chownErOk")}a(Mq,"patch")});var tC=S((Afe,eC)=>{var ZR=require("stream").Stream;eC.exports=jq;function jq(n){return{ReadStream:e,WriteStream:t};function e(r,i){if(!(this instanceof e))return new e(r,i);ZR.call(this);var s=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var o=Object.keys(i),l=0,c=o.length;l<c;l++){var u=o[l];this[u]=i[u]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){s._read()});return}n.open(this.path,this.flags,this.mode,function(f,d){if(f){s.emit("error",f),s.readable=!1;return}s.fd=d,s.emit("open",d),s._read()})}function t(r,i){if(!(this instanceof t))return new t(r,i);ZR.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var s=Object.keys(i),o=0,l=s.length;o<l;o++){var c=s[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=n.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}a(jq,"legacy")});var nC=S((Cfe,rC)=>{"use strict";rC.exports=Uq;var $q=Object.getPrototypeOf||function(n){return n.__proto__};function Uq(n){if(n===null||typeof n!="object")return n;if(n instanceof Object)var e={__proto__:$q(n)};else var e=Object.create(null);return Object.getOwnPropertyNames(n).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}a(Uq,"clone")});var Dc=S((Ofe,Cv)=>{var Vt=require("fs"),Vq=JR(),Bq=tC(),Gq=nC(),dg=require("util"),$r,pg;typeof Symbol=="function"&&typeof Symbol.for=="function"?($r=Symbol.for("graceful-fs.queue"),pg=Symbol.for("graceful-fs.previous")):($r="___graceful-fs.queue",pg="___graceful-fs.previous");function qq(){}a(qq,"noop");function oC(n,e){Object.defineProperty(n,$r,{get:a(function(){return e},"get")})}a(oC,"publishQueue");var Ka=qq;dg.debuglog?Ka=dg.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ka=a(function(){var n=dg.format.apply(dg,arguments);n="GFS4: "+n.split(/\n/).join(`
460
+ GFS4: `),console.error(n)},"debug"));Vt[$r]||(iC=global[$r]||[],oC(Vt,iC),Vt.close=(function(n){function e(t,r){return n.call(Vt,t,function(i){i||sC(),typeof r=="function"&&r.apply(this,arguments)})}return a(e,"close"),Object.defineProperty(e,pg,{value:n}),e})(Vt.close),Vt.closeSync=(function(n){function e(t){n.apply(Vt,arguments),sC()}return a(e,"closeSync"),Object.defineProperty(e,pg,{value:n}),e})(Vt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Ka(Vt[$r]),require("assert").equal(Vt[$r].length,0)}));var iC;global[$r]||oC(global,Vt[$r]);Cv.exports=Av(Gq(Vt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Vt.__patched&&(Cv.exports=Av(Vt),Vt.__patched=!0);function Av(n){Vq(n),n.gracefulify=Av,n.createReadStream=C,n.createWriteStream=H;var e=n.readFile;n.readFile=t;function t(N,Y,se){return typeof Y=="function"&&(se=Y,Y=null),V(N,Y,se);function V(X,re,G,ie){return e(X,re,function(q){q&&(q.code==="EMFILE"||q.code==="ENFILE")?Fc([V,[X,re,G],q,ie||Date.now(),Date.now()]):typeof G=="function"&&G.apply(this,arguments)})}a(V,"go$readFile")}a(t,"readFile");var r=n.writeFile;n.writeFile=i;function i(N,Y,se,V){return typeof se=="function"&&(V=se,se=null),X(N,Y,se,V);function X(re,G,ie,q,U){return r(re,G,ie,function(B){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([X,[re,G,ie,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(X,"go$writeFile")}a(i,"writeFile");var s=n.appendFile;s&&(n.appendFile=o);function o(N,Y,se,V){return typeof se=="function"&&(V=se,se=null),X(N,Y,se,V);function X(re,G,ie,q,U){return s(re,G,ie,function(B){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([X,[re,G,ie,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(X,"go$appendFile")}a(o,"appendFile");var l=n.copyFile;l&&(n.copyFile=c);function c(N,Y,se,V){return typeof se=="function"&&(V=se,se=0),X(N,Y,se,V);function X(re,G,ie,q,U){return l(re,G,ie,function(B){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([X,[re,G,ie,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(X,"go$copyFile")}a(c,"copyFile");var u=n.readdir;n.readdir=d;var f=/^v[0-5]\./;function d(N,Y,se){typeof Y=="function"&&(se=Y,Y=null);var V=f.test(process.version)?a(function(G,ie,q,U){return u(G,X(G,ie,q,U))},"go$readdir"):a(function(G,ie,q,U){return u(G,ie,X(G,ie,q,U))},"go$readdir");return V(N,Y,se);function X(re,G,ie,q){return function(U,B){U&&(U.code==="EMFILE"||U.code==="ENFILE")?Fc([V,[re,G,ie],U,q||Date.now(),Date.now()]):(B&&B.sort&&B.sort(),typeof ie=="function"&&ie.call(this,U,B))}}}if(a(d,"readdir"),process.version.substr(0,4)==="v0.8"){var h=Bq(n);w=h.ReadStream,I=h.WriteStream}var p=n.ReadStream;p&&(w.prototype=Object.create(p.prototype),w.prototype.open=E);var g=n.WriteStream;g&&(I.prototype=Object.create(g.prototype),I.prototype.open=O),Object.defineProperty(n,"ReadStream",{get:a(function(){return w},"get"),set:a(function(N){w=N},"set"),enumerable:!0,configurable:!0}),Object.defineProperty(n,"WriteStream",{get:a(function(){return I},"get"),set:a(function(N){I=N},"set"),enumerable:!0,configurable:!0});var _=w;Object.defineProperty(n,"FileReadStream",{get:a(function(){return _},"get"),set:a(function(N){_=N},"set"),enumerable:!0,configurable:!0});var v=I;Object.defineProperty(n,"FileWriteStream",{get:a(function(){return v},"get"),set:a(function(N){v=N},"set"),enumerable:!0,configurable:!0});function w(N,Y){return this instanceof w?(p.apply(this,arguments),this):w.apply(Object.create(w.prototype),arguments)}a(w,"ReadStream");function E(){var N=this;de(N.path,N.flags,N.mode,function(Y,se){Y?(N.autoClose&&N.destroy(),N.emit("error",Y)):(N.fd=se,N.emit("open",se),N.read())})}a(E,"ReadStream$open");function I(N,Y){return this instanceof I?(g.apply(this,arguments),this):I.apply(Object.create(I.prototype),arguments)}a(I,"WriteStream");function O(){var N=this;de(N.path,N.flags,N.mode,function(Y,se){Y?(N.destroy(),N.emit("error",Y)):(N.fd=se,N.emit("open",se))})}a(O,"WriteStream$open");function C(N,Y){return new n.ReadStream(N,Y)}a(C,"createReadStream");function H(N,Y){return new n.WriteStream(N,Y)}a(H,"createWriteStream");var ne=n.open;n.open=de;function de(N,Y,se,V){return typeof se=="function"&&(V=se,se=null),X(N,Y,se,V);function X(re,G,ie,q,U){return ne(re,G,ie,function(B,tt){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Fc([X,[re,G,ie,q],B,U||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}a(X,"go$open")}return a(de,"open"),n}a(Av,"patch");function Fc(n){Ka("ENQUEUE",n[0].name,n[1]),Vt[$r].push(n),Rv()}a(Fc,"enqueue");var hg;function sC(){for(var n=Date.now(),e=0;e<Vt[$r].length;++e)Vt[$r][e].length>2&&(Vt[$r][e][3]=n,Vt[$r][e][4]=n);Rv()}a(sC,"resetQueue");function Rv(){if(clearTimeout(hg),hg=void 0,Vt[$r].length!==0){var n=Vt[$r].shift(),e=n[0],t=n[1],r=n[2],i=n[3],s=n[4];if(i===void 0)Ka("RETRY",e.name,t),e.apply(null,t);else if(Date.now()-i>=6e4){Ka("TIMEOUT",e.name,t);var o=t.pop();typeof o=="function"&&o.call(null,r)}else{var l=Date.now()-s,c=Math.max(s-i,1),u=Math.min(c*1.2,100);l>=u?(Ka("RETRY",e.name,t),e.apply(null,t.concat([i]))):Vt[$r].push(n)}hg===void 0&&(hg=setTimeout(Rv,0))}}a(Rv,"retry")});var mn=S(po=>{"use strict";var aC=Er().fromCallback,pn=Dc(),Wq=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(n=>typeof pn[n]=="function");Object.assign(po,pn);Wq.forEach(n=>{po[n]=aC(pn[n])});po.exists=function(n,e){return typeof e=="function"?pn.exists(n,e):new Promise(t=>pn.exists(n,t))};po.read=function(n,e,t,r,i,s){return typeof s=="function"?pn.read(n,e,t,r,i,s):new Promise((o,l)=>{pn.read(n,e,t,r,i,(c,u,f)=>{if(c)return l(c);o({bytesRead:u,buffer:f})})})};po.write=function(n,e,...t){return typeof t[t.length-1]=="function"?pn.write(n,e,...t):new Promise((r,i)=>{pn.write(n,e,...t,(s,o,l)=>{if(s)return i(s);r({bytesWritten:o,buffer:l})})})};po.readv=function(n,e,...t){return typeof t[t.length-1]=="function"?pn.readv(n,e,...t):new Promise((r,i)=>{pn.readv(n,e,...t,(s,o,l)=>{if(s)return i(s);r({bytesRead:o,buffers:l})})})};po.writev=function(n,e,...t){return typeof t[t.length-1]=="function"?pn.writev(n,e,...t):new Promise((r,i)=>{pn.writev(n,e,...t,(s,o,l)=>{if(s)return i(s);r({bytesWritten:o,buffers:l})})})};typeof pn.realpath.native=="function"?po.realpath.native=aC(pn.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var cC=S((Lfe,lC)=>{"use strict";var zq=require("path");lC.exports.checkPath=a(function(e){if(process.platform==="win32"&&/[<>:"|?*]/.test(e.replace(zq.parse(e).root,""))){let r=new Error(`Path contains invalid characters: ${e}`);throw r.code="EINVAL",r}},"checkPath")});var hC=S((kfe,Pv)=>{"use strict";var uC=mn(),{checkPath:fC}=cC(),dC=a(n=>{let e={mode:511};return typeof n=="number"?n:{...e,...n}.mode},"getMode");Pv.exports.makeDir=async(n,e)=>(fC(n),uC.mkdir(n,{mode:dC(e),recursive:!0}));Pv.exports.makeDirSync=(n,e)=>(fC(n),uC.mkdirSync(n,{mode:dC(e),recursive:!0}))});var Ui=S((jfe,pC)=>{"use strict";var Hq=Er().fromPromise,{makeDir:Qq,makeDirSync:Ov}=hC(),Fv=Hq(Qq);pC.exports={mkdirs:Fv,mkdirsSync:Ov,mkdirp:Fv,mkdirpSync:Ov,ensureDir:Fv,ensureDirSync:Ov}});var Yo=S(($fe,gC)=>{"use strict";var Yq=Er().fromPromise,mC=mn();function Xq(n){return mC.access(n).then(()=>!0).catch(()=>!1)}a(Xq,"pathExists");gC.exports={pathExists:Yq(Xq),pathExistsSync:mC.existsSync}});var Dv=S((Vfe,yC)=>{"use strict";var Lc=mn(),Kq=Er().fromPromise;async function Jq(n,e,t){let r=await Lc.open(n,"r+"),i=null;try{await Lc.futimes(r,e,t)}finally{try{await Lc.close(r)}catch(s){i=s}}if(i)throw i}a(Jq,"utimesMillis");function Zq(n,e,t){let r=Lc.openSync(n,"r+");return Lc.futimesSync(r,e,t),Lc.closeSync(r)}a(Zq,"utimesMillisSync");yC.exports={utimesMillis:Kq(Jq),utimesMillisSync:Zq}});var Ja=S((Gfe,wC)=>{"use strict";var Nc=mn(),Tr=require("path"),_C=Er().fromPromise;function eW(n,e,t){let r=t.dereference?i=>Nc.stat(i,{bigint:!0}):i=>Nc.lstat(i,{bigint:!0});return Promise.all([r(n),r(e).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,s])=>({srcStat:i,destStat:s}))}a(eW,"getStats");function tW(n,e,t){let r,i=t.dereference?o=>Nc.statSync(o,{bigint:!0}):o=>Nc.lstatSync(o,{bigint:!0}),s=i(n);try{r=i(e)}catch(o){if(o.code==="ENOENT")return{srcStat:s,destStat:null};throw o}return{srcStat:s,destStat:r}}a(tW,"getStatsSync");async function rW(n,e,t,r){let{srcStat:i,destStat:s}=await eW(n,e,r);if(s){if(Of(i,s)){let o=Tr.basename(n),l=Tr.basename(e);if(t==="move"&&o!==l&&o.toLowerCase()===l.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&Lv(n,e))throw new Error(mg(n,e,t));return{srcStat:i,destStat:s}}a(rW,"checkPaths");function nW(n,e,t,r){let{srcStat:i,destStat:s}=tW(n,e,r);if(s){if(Of(i,s)){let o=Tr.basename(n),l=Tr.basename(e);if(t==="move"&&o!==l&&o.toLowerCase()===l.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${n}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${n}'.`)}if(i.isDirectory()&&Lv(n,e))throw new Error(mg(n,e,t));return{srcStat:i,destStat:s}}a(nW,"checkPathsSync");async function bC(n,e,t,r){let i=Tr.resolve(Tr.dirname(n)),s=Tr.resolve(Tr.dirname(t));if(s===i||s===Tr.parse(s).root)return;let o;try{o=await Nc.stat(s,{bigint:!0})}catch(l){if(l.code==="ENOENT")return;throw l}if(Of(e,o))throw new Error(mg(n,t,r));return bC(n,e,s,r)}a(bC,"checkParentPaths");function SC(n,e,t,r){let i=Tr.resolve(Tr.dirname(n)),s=Tr.resolve(Tr.dirname(t));if(s===i||s===Tr.parse(s).root)return;let o;try{o=Nc.statSync(s,{bigint:!0})}catch(l){if(l.code==="ENOENT")return;throw l}if(Of(e,o))throw new Error(mg(n,t,r));return SC(n,e,s,r)}a(SC,"checkParentPathsSync");function Of(n,e){return e.ino!==void 0&&e.dev!==void 0&&e.ino===n.ino&&e.dev===n.dev}a(Of,"areIdentical");function Lv(n,e){let t=Tr.resolve(n).split(Tr.sep).filter(i=>i),r=Tr.resolve(e).split(Tr.sep).filter(i=>i);return t.every((i,s)=>r[s]===i)}a(Lv,"isSrcSubdir");function mg(n,e,t){return`Cannot ${t} '${n}' to a subdirectory of itself, '${e}'.`}a(mg,"errMsg");wC.exports={checkPaths:_C(rW),checkPathsSync:nW,checkParentPaths:_C(bC),checkParentPathsSync:SC,isSrcSubdir:Lv,areIdentical:Of}});var EC=S((Wfe,vC)=>{"use strict";async function iW(n,e){let t=[];for await(let r of n)t.push(e(r).then(()=>null,i=>i??new Error("unknown error")));await Promise.all(t.map(r=>r.then(i=>{if(i!==null)throw i})))}a(iW,"asyncIteratorConcurrentProcess");vC.exports={asyncIteratorConcurrentProcess:iW}});var RC=S((Hfe,AC)=>{"use strict";var Kr=mn(),Ff=require("path"),{mkdirs:sW}=Ui(),{pathExists:oW}=Yo(),{utimesMillis:aW}=Dv(),Df=Ja(),{asyncIteratorConcurrentProcess:lW}=EC();async function cW(n,e,t={}){typeof t=="function"&&(t={filter:t}),t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
461
461
 
462
462
  see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:r,destStat:i}=await Df.checkPaths(n,e,"copy",t);if(await Df.checkParentPaths(n,r,e,"copy"),!await IC(n,e,t))return;let o=Ff.dirname(e);await oW(o)||await sW(o),await xC(i,n,e,t)}a(cW,"copy");async function IC(n,e,t){return t.filter?t.filter(n,e):!0}a(IC,"runFilter");async function xC(n,e,t,r){let s=await(r.dereference?Kr.stat:Kr.lstat)(e);if(s.isDirectory())return hW(s,n,e,t,r);if(s.isFile()||s.isCharacterDevice()||s.isBlockDevice())return uW(s,n,e,t,r);if(s.isSymbolicLink())return pW(n,e,t,r);throw s.isSocket()?new Error(`Cannot copy a socket file: ${e}`):s.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}a(xC,"getStatsAndPerformCopy");async function uW(n,e,t,r,i){if(!e)return TC(n,t,r,i);if(i.overwrite)return await Kr.unlink(r),TC(n,t,r,i);if(i.errorOnExist)throw new Error(`'${r}' already exists`)}a(uW,"onFile");async function TC(n,e,t,r){if(await Kr.copyFile(e,t),r.preserveTimestamps){fW(n.mode)&&await dW(t,n.mode);let i=await Kr.stat(e);await aW(t,i.atime,i.mtime)}return Kr.chmod(t,n.mode)}a(TC,"copyFile");function fW(n){return(n&128)===0}a(fW,"fileIsNotWritable");function dW(n,e){return Kr.chmod(n,e|128)}a(dW,"makeFileWritable");async function hW(n,e,t,r,i){e||await Kr.mkdir(r),await lW(await Kr.opendir(t),async s=>{let o=Ff.join(t,s.name),l=Ff.join(r,s.name);if(await IC(o,l,i)){let{destStat:u}=await Df.checkPaths(o,l,"copy",i);await xC(u,o,l,i)}}),e||await Kr.chmod(r,n.mode)}a(hW,"onDir");async function pW(n,e,t,r){let i=await Kr.readlink(e);if(r.dereference&&(i=Ff.resolve(process.cwd(),i)),!n)return Kr.symlink(i,t);let s=null;try{s=await Kr.readlink(t)}catch(o){if(o.code==="EINVAL"||o.code==="UNKNOWN")return Kr.symlink(i,t);throw o}if(r.dereference&&(s=Ff.resolve(process.cwd(),s)),Df.isSrcSubdir(i,s))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${s}'.`);if(Df.isSrcSubdir(s,i))throw new Error(`Cannot overwrite '${s}' with '${i}'.`);return await Kr.unlink(t),Kr.symlink(i,t)}a(pW,"onLink");AC.exports=cW});var DC=S((Yfe,FC)=>{"use strict";var gn=Dc(),Lf=require("path"),mW=Ui().mkdirsSync,gW=Dv().utimesMillisSync,Nf=Ja();function yW(n,e,t){typeof t=="function"&&(t={filter:t}),t=t||{},t.clobber="clobber"in t?!!t.clobber:!0,t.overwrite="overwrite"in t?!!t.overwrite:t.clobber,t.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
463
463
 
464
464
  see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");let{srcStat:r,destStat:i}=Nf.checkPathsSync(n,e,"copy",t);if(Nf.checkParentPathsSync(n,r,e,"copy"),t.filter&&!t.filter(n,e))return;let s=Lf.dirname(e);return gn.existsSync(s)||mW(s),CC(i,n,e,t)}a(yW,"copySync");function CC(n,e,t,r){let s=(r.dereference?gn.statSync:gn.lstatSync)(e);if(s.isDirectory())return TW(s,n,e,t,r);if(s.isFile()||s.isCharacterDevice()||s.isBlockDevice())return _W(s,n,e,t,r);if(s.isSymbolicLink())return AW(n,e,t,r);throw s.isSocket()?new Error(`Cannot copy a socket file: ${e}`):s.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}a(CC,"getStats");function _W(n,e,t,r,i){return e?bW(n,t,r,i):PC(n,t,r,i)}a(_W,"onFile");function bW(n,e,t,r){if(r.overwrite)return gn.unlinkSync(t),PC(n,e,t,r);if(r.errorOnExist)throw new Error(`'${t}' already exists`)}a(bW,"mayCopyFile");function PC(n,e,t,r){return gn.copyFileSync(e,t),r.preserveTimestamps&&SW(n.mode,e,t),Nv(t,n.mode)}a(PC,"copyFile");function SW(n,e,t){return wW(n)&&vW(t,n),EW(e,t)}a(SW,"handleTimestamps");function wW(n){return(n&128)===0}a(wW,"fileIsNotWritable");function vW(n,e){return Nv(n,e|128)}a(vW,"makeFileWritable");function Nv(n,e){return gn.chmodSync(n,e)}a(Nv,"setDestMode");function EW(n,e){let t=gn.statSync(n);return gW(e,t.atime,t.mtime)}a(EW,"setDestTimestamps");function TW(n,e,t,r,i){return e?OC(t,r,i):IW(n.mode,t,r,i)}a(TW,"onDir");function IW(n,e,t,r){return gn.mkdirSync(t),OC(e,t,r),Nv(t,n)}a(IW,"mkDirAndCopy");function OC(n,e,t){let r=gn.opendirSync(n);try{let i;for(;(i=r.readSync())!==null;)xW(i.name,n,e,t)}finally{r.closeSync()}}a(OC,"copyDir");function xW(n,e,t,r){let i=Lf.join(e,n),s=Lf.join(t,n);if(r.filter&&!r.filter(i,s))return;let{destStat:o}=Nf.checkPathsSync(i,s,"copy",r);return CC(o,i,s,r)}a(xW,"copyDirItem");function AW(n,e,t,r){let i=gn.readlinkSync(e);if(r.dereference&&(i=Lf.resolve(process.cwd(),i)),n){let s;try{s=gn.readlinkSync(t)}catch(o){if(o.code==="EINVAL"||o.code==="UNKNOWN")return gn.symlinkSync(i,t);throw o}if(r.dereference&&(s=Lf.resolve(process.cwd(),s)),Nf.isSrcSubdir(i,s))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${s}'.`);if(Nf.isSrcSubdir(s,i))throw new Error(`Cannot overwrite '${s}' with '${i}'.`);return RW(i,t)}else return gn.symlinkSync(i,t)}a(AW,"onLink");function RW(n,e){return gn.unlinkSync(e),gn.symlinkSync(n,e)}a(RW,"copyLink");FC.exports=yW});var gg=S((Kfe,LC)=>{"use strict";var CW=Er().fromPromise;LC.exports={copy:CW(RC()),copySync:DC()}});var kf=S((Jfe,kC)=>{"use strict";var NC=Dc(),PW=Er().fromCallback;function OW(n,e){NC.rm(n,{recursive:!0,force:!0},e)}a(OW,"remove");function FW(n){NC.rmSync(n,{recursive:!0,force:!0})}a(FW,"removeSync");kC.exports={remove:PW(OW),removeSync:FW}});var qC=S((ede,GC)=>{"use strict";var DW=Er().fromPromise,$C=mn(),UC=require("path"),VC=Ui(),BC=kf(),MC=DW(a(async function(e){let t;try{t=await $C.readdir(e)}catch{return VC.mkdirs(e)}return Promise.all(t.map(r=>BC.remove(UC.join(e,r))))},"emptyDir"));function jC(n){let e;try{e=$C.readdirSync(n)}catch{return VC.mkdirsSync(n)}e.forEach(t=>{t=UC.join(n,t),BC.removeSync(t)})}a(jC,"emptyDirSync");GC.exports={emptyDirSync:jC,emptydirSync:jC,emptyDir:MC,emptydir:MC}});var QC=S((rde,HC)=>{"use strict";var LW=Er().fromPromise,WC=require("path"),mo=mn(),zC=Ui();async function NW(n){let e;try{e=await mo.stat(n)}catch{}if(e&&e.isFile())return;let t=WC.dirname(n),r=null;try{r=await mo.stat(t)}catch(i){if(i.code==="ENOENT"){await zC.mkdirs(t),await mo.writeFile(n,"");return}else throw i}r.isDirectory()?await mo.writeFile(n,""):await mo.readdir(t)}a(NW,"createFile");function kW(n){let e;try{e=mo.statSync(n)}catch{}if(e&&e.isFile())return;let t=WC.dirname(n);try{mo.statSync(t).isDirectory()||mo.readdirSync(t)}catch(r){if(r&&r.code==="ENOENT")zC.mkdirsSync(t);else throw r}mo.writeFileSync(n,"")}a(kW,"createFileSync");HC.exports={createFile:LW(NW),createFileSync:kW}});var ZC=S((ide,JC)=>{"use strict";var MW=Er().fromPromise,YC=require("path"),Xo=mn(),XC=Ui(),{pathExists:jW}=Yo(),{areIdentical:KC}=Ja();async function $W(n,e){let t;try{t=await Xo.lstat(e)}catch{}let r;try{r=await Xo.lstat(n)}catch(o){throw o.message=o.message.replace("lstat","ensureLink"),o}if(t&&KC(r,t))return;let i=YC.dirname(e);await jW(i)||await XC.mkdirs(i),await Xo.link(n,e)}a($W,"createLink");function UW(n,e){let t;try{t=Xo.lstatSync(e)}catch{}try{let s=Xo.lstatSync(n);if(t&&KC(s,t))return}catch(s){throw s.message=s.message.replace("lstat","ensureLink"),s}let r=YC.dirname(e);return Xo.existsSync(r)||XC.mkdirsSync(r),Xo.linkSync(n,e)}a(UW,"createLinkSync");JC.exports={createLink:MW($W),createLinkSync:UW}});var tP=S((ode,eP)=>{"use strict";var Ko=require("path"),Mf=mn(),{pathExists:VW}=Yo(),BW=Er().fromPromise;async function GW(n,e){if(Ko.isAbsolute(n)){try{await Mf.lstat(n)}catch(s){throw s.message=s.message.replace("lstat","ensureSymlink"),s}return{toCwd:n,toDst:n}}let t=Ko.dirname(e),r=Ko.join(t,n);if(await VW(r))return{toCwd:r,toDst:n};try{await Mf.lstat(n)}catch(s){throw s.message=s.message.replace("lstat","ensureSymlink"),s}return{toCwd:n,toDst:Ko.relative(t,n)}}a(GW,"symlinkPaths");function qW(n,e){if(Ko.isAbsolute(n)){if(!Mf.existsSync(n))throw new Error("absolute srcpath does not exist");return{toCwd:n,toDst:n}}let t=Ko.dirname(e),r=Ko.join(t,n);if(Mf.existsSync(r))return{toCwd:r,toDst:n};if(!Mf.existsSync(n))throw new Error("relative srcpath does not exist");return{toCwd:n,toDst:Ko.relative(t,n)}}a(qW,"symlinkPathsSync");eP.exports={symlinkPaths:BW(GW),symlinkPathsSync:qW}});var iP=S((lde,nP)=>{"use strict";var rP=mn(),WW=Er().fromPromise;async function zW(n,e){if(e)return e;let t;try{t=await rP.lstat(n)}catch{return"file"}return t&&t.isDirectory()?"dir":"file"}a(zW,"symlinkType");function HW(n,e){if(e)return e;let t;try{t=rP.lstatSync(n)}catch{return"file"}return t&&t.isDirectory()?"dir":"file"}a(HW,"symlinkTypeSync");nP.exports={symlinkType:WW(zW),symlinkTypeSync:HW}});var lP=S((ude,aP)=>{"use strict";var QW=Er().fromPromise,sP=require("path"),Ss=mn(),{mkdirs:YW,mkdirsSync:XW}=Ui(),{symlinkPaths:KW,symlinkPathsSync:JW}=tP(),{symlinkType:ZW,symlinkTypeSync:ez}=iP(),{pathExists:tz}=Yo(),{areIdentical:oP}=Ja();async function rz(n,e,t){let r;try{r=await Ss.lstat(e)}catch{}if(r&&r.isSymbolicLink()){let[l,c]=await Promise.all([Ss.stat(n),Ss.stat(e)]);if(oP(l,c))return}let i=await KW(n,e);n=i.toDst;let s=await ZW(i.toCwd,t),o=sP.dirname(e);return await tz(o)||await YW(o),Ss.symlink(n,e,s)}a(rz,"createSymlink");function nz(n,e,t){let r;try{r=Ss.lstatSync(e)}catch{}if(r&&r.isSymbolicLink()){let l=Ss.statSync(n),c=Ss.statSync(e);if(oP(l,c))return}let i=JW(n,e);n=i.toDst,t=ez(i.toCwd,t);let s=sP.dirname(e);return Ss.existsSync(s)||XW(s),Ss.symlinkSync(n,e,t)}a(nz,"createSymlinkSync");aP.exports={createSymlink:QW(rz),createSymlinkSync:nz}});var gP=S((dde,mP)=>{"use strict";var{createFile:cP,createFileSync:uP}=QC(),{createLink:fP,createLinkSync:dP}=ZC(),{createSymlink:hP,createSymlinkSync:pP}=lP();mP.exports={createFile:cP,createFileSync:uP,ensureFile:cP,ensureFileSync:uP,createLink:fP,createLinkSync:dP,ensureLink:fP,ensureLinkSync:dP,createSymlink:hP,createSymlinkSync:pP,ensureSymlink:hP,ensureSymlinkSync:pP}});var yg=S((hde,yP)=>{function iz(n,{EOL:e=`
465
- `,finalEOL:t=!0,replacer:r=null,spaces:i}={}){let s=t?e:"";return JSON.stringify(n,r,i).replace(/\n/g,e)+s}a(iz,"stringify");function sz(n){return Buffer.isBuffer(n)&&(n=n.toString("utf8")),n.replace(/^\uFEFF/,"")}a(sz,"stripBom");yP.exports={stringify:iz,stripBom:sz}});var wP=S((mde,SP)=>{var kc;try{kc=Dc()}catch{kc=require("fs")}var _g=Er(),{stringify:_P,stripBom:bP}=yg();async function oz(n,e={}){typeof e=="string"&&(e={encoding:e});let t=e.fs||kc,r="throws"in e?e.throws:!0,i=await _g.fromCallback(t.readFile)(n,e);i=bP(i);let s;try{s=JSON.parse(i,e?e.reviver:null)}catch(o){if(r)throw o.message=`${n}: ${o.message}`,o;return null}return s}a(oz,"_readFile");var az=_g.fromPromise(oz);function lz(n,e={}){typeof e=="string"&&(e={encoding:e});let t=e.fs||kc,r="throws"in e?e.throws:!0;try{let i=t.readFileSync(n,e);return i=bP(i),JSON.parse(i,e.reviver)}catch(i){if(r)throw i.message=`${n}: ${i.message}`,i;return null}}a(lz,"readFileSync");async function cz(n,e,t={}){let r=t.fs||kc,i=_P(e,t);await _g.fromCallback(r.writeFile)(n,i,t)}a(cz,"_writeFile");var uz=_g.fromPromise(cz);function fz(n,e,t={}){let r=t.fs||kc,i=_P(e,t);return r.writeFileSync(n,i,t)}a(fz,"writeFileSync");SP.exports={readFile:az,readFileSync:lz,writeFile:uz,writeFileSync:fz}});var EP=S((yde,vP)=>{"use strict";var bg=wP();vP.exports={readJson:bg.readFile,readJsonSync:bg.readFileSync,writeJson:bg.writeFile,writeJsonSync:bg.writeFileSync}});var Sg=S((_de,xP)=>{"use strict";var dz=Er().fromPromise,kv=mn(),TP=require("path"),IP=Ui(),hz=Yo().pathExists;async function pz(n,e,t="utf-8"){let r=TP.dirname(n);return await hz(r)||await IP.mkdirs(r),kv.writeFile(n,e,t)}a(pz,"outputFile");function mz(n,...e){let t=TP.dirname(n);kv.existsSync(t)||IP.mkdirsSync(t),kv.writeFileSync(n,...e)}a(mz,"outputFileSync");xP.exports={outputFile:dz(pz),outputFileSync:mz}});var RP=S((Sde,AP)=>{"use strict";var{stringify:gz}=yg(),{outputFile:yz}=Sg();async function _z(n,e,t={}){let r=gz(e,t);await yz(n,r,t)}a(_z,"outputJson");AP.exports=_z});var PP=S((vde,CP)=>{"use strict";var{stringify:bz}=yg(),{outputFileSync:Sz}=Sg();function wz(n,e,t){let r=bz(e,t);Sz(n,r,t)}a(wz,"outputJsonSync");CP.exports=wz});var FP=S((Tde,OP)=>{"use strict";var vz=Er().fromPromise,yn=EP();yn.outputJson=vz(RP());yn.outputJsonSync=PP();yn.outputJSON=yn.outputJson;yn.outputJSONSync=yn.outputJsonSync;yn.writeJSON=yn.writeJson;yn.writeJSONSync=yn.writeJsonSync;yn.readJSON=yn.readJson;yn.readJSONSync=yn.readJsonSync;OP.exports=yn});var MP=S((Ide,kP)=>{"use strict";var Ez=mn(),DP=require("path"),{copy:Tz}=gg(),{remove:NP}=kf(),{mkdirp:Iz}=Ui(),{pathExists:xz}=Yo(),LP=Ja();async function Az(n,e,t={}){let r=t.overwrite||t.clobber||!1,{srcStat:i,isChangingCase:s=!1}=await LP.checkPaths(n,e,"move",t);await LP.checkParentPaths(n,i,e,"move");let o=DP.dirname(e);return DP.parse(o).root!==o&&await Iz(o),Rz(n,e,r,s)}a(Az,"move");async function Rz(n,e,t,r){if(!r){if(t)await NP(e);else if(await xz(e))throw new Error("dest already exists.")}try{await Ez.rename(n,e)}catch(i){if(i.code!=="EXDEV")throw i;await Cz(n,e,t)}}a(Rz,"doRename");async function Cz(n,e,t){return await Tz(n,e,{overwrite:t,errorOnExist:!0,preserveTimestamps:!0}),NP(n)}a(Cz,"moveAcrossDevice");kP.exports=Az});var BP=S((Ade,VP)=>{"use strict";var $P=Dc(),jv=require("path"),Pz=gg().copySync,UP=kf().removeSync,Oz=Ui().mkdirpSync,jP=Ja();function Fz(n,e,t){t=t||{};let r=t.overwrite||t.clobber||!1,{srcStat:i,isChangingCase:s=!1}=jP.checkPathsSync(n,e,"move",t);return jP.checkParentPathsSync(n,i,e,"move"),Dz(e)||Oz(jv.dirname(e)),Lz(n,e,r,s)}a(Fz,"moveSync");function Dz(n){let e=jv.dirname(n);return jv.parse(e).root===e}a(Dz,"isParentRoot");function Lz(n,e,t,r){if(r)return Mv(n,e,t);if(t)return UP(e),Mv(n,e,t);if($P.existsSync(e))throw new Error("dest already exists.");return Mv(n,e,t)}a(Lz,"doRename");function Mv(n,e,t){try{$P.renameSync(n,e)}catch(r){if(r.code!=="EXDEV")throw r;return Nz(n,e,t)}}a(Mv,"rename");function Nz(n,e,t){return Pz(n,e,{overwrite:t,errorOnExist:!0,preserveTimestamps:!0}),UP(n)}a(Nz,"moveAcrossDevice");VP.exports=Fz});var qP=S((Cde,GP)=>{"use strict";var kz=Er().fromPromise;GP.exports={move:kz(MP()),moveSync:BP()}});var Jo=S((Pde,WP)=>{"use strict";WP.exports={...mn(),...gg(),...qC(),...gP(),...FP(),...Ui(),...qP(),...Sg(),...Yo(),...kf()}});var ZO=S((Dde,JO)=>{"use strict";JO.exports=XO;function XO(n,e,t){n instanceof RegExp&&(n=YO(n,t)),e instanceof RegExp&&(e=YO(e,t));var r=KO(n,e,t);return r&&{start:r[0],end:r[1],pre:t.slice(0,r[0]),body:t.slice(r[0]+n.length,r[1]),post:t.slice(r[1]+e.length)}}a(XO,"balanced");function YO(n,e){var t=e.match(n);return t?t[0]:null}a(YO,"maybeMatch");XO.range=KO;function KO(n,e,t){var r,i,s,o,l,c=t.indexOf(n),u=t.indexOf(e,c+1),f=c;if(c>=0&&u>0){if(n===e)return[c,u];for(r=[],s=t.length;f>=0&&!l;)f==c?(r.push(f),c=t.indexOf(n,f+1)):r.length==1?l=[r.pop(),u]:(i=r.pop(),i<s&&(s=i,o=u),u=t.indexOf(e,f+1)),f=c<u&&c>=0?c:u;r.length&&(l=[s,o])}return l}a(KO,"range")});var aF=S((Nde,oF)=>{var eF=ZO();oF.exports=iY;var tF="\0SLASH"+Math.random()+"\0",rF="\0OPEN"+Math.random()+"\0",eE="\0CLOSE"+Math.random()+"\0",nF="\0COMMA"+Math.random()+"\0",iF="\0PERIOD"+Math.random()+"\0";function Zv(n){return parseInt(n,10)==n?parseInt(n,10):n.charCodeAt(0)}a(Zv,"numeric");function rY(n){return n.split("\\\\").join(tF).split("\\{").join(rF).split("\\}").join(eE).split("\\,").join(nF).split("\\.").join(iF)}a(rY,"escapeBraces");function nY(n){return n.split(tF).join("\\").split(rF).join("{").split(eE).join("}").split(nF).join(",").split(iF).join(".")}a(nY,"unescapeBraces");function sF(n){if(!n)return[""];var e=[],t=eF("{","}",n);if(!t)return n.split(",");var r=t.pre,i=t.body,s=t.post,o=r.split(",");o[o.length-1]+="{"+i+"}";var l=sF(s);return s.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),e.push.apply(e,o),e}a(sF,"parseCommaParts");function iY(n){return n?(n.substr(0,2)==="{}"&&(n="\\{\\}"+n.substr(2)),Gf(rY(n),!0).map(nY)):[]}a(iY,"expandTop");function sY(n){return"{"+n+"}"}a(sY,"embrace");function oY(n){return/^-?0\d/.test(n)}a(oY,"isPadded");function aY(n,e){return n<=e}a(aY,"lte");function lY(n,e){return n>=e}a(lY,"gte");function Gf(n,e){var t=[],r=eF("{","}",n);if(!r)return[n];var i=r.pre,s=r.post.length?Gf(r.post,!1):[""];if(/\$$/.test(r.pre))for(var o=0;o<s.length;o++){var l=i+"{"+r.body+"}"+s[o];t.push(l)}else{var c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),f=c||u,d=r.body.indexOf(",")>=0;if(!f&&!d)return r.post.match(/,(?!,).*\}/)?(n=r.pre+"{"+r.body+eE+r.post,Gf(n)):[n];var h;if(f)h=r.body.split(/\.\./);else if(h=sF(r.body),h.length===1&&(h=Gf(h[0],!1).map(sY),h.length===1))return s.map(function(Q){return r.pre+h[0]+Q});var p;if(f){var g=Zv(h[0]),_=Zv(h[1]),v=Math.max(h[0].length,h[1].length),w=h.length==3?Math.max(Math.abs(Zv(h[2])),1):1,E=aY,I=_<g;I&&(w*=-1,E=lY);var A=h.some(oY);p=[];for(var D=g;E(D,_);D+=w){var K;if(u)K=String.fromCharCode(D),K==="\\"&&(K="");else if(K=String(D),A){var oe=v-K.length;if(oe>0){var me=new Array(oe+1).join("0");D<0?K="-"+me+K.slice(1):K=me+K}}p.push(K)}}else{p=[];for(var N=0;N<h.length;N++)p.push.apply(p,Gf(h[N],!1))}for(var N=0;N<p.length;N++)for(var o=0;o<s.length;o++){var l=i+p[N]+s[o];(!e||f||l)&&t.push(l)}}return t}a(Gf,"expand")});var dN=S(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.createPathBasedTargetResolver=Yi;Gr.createCreateRelatedTaskService=UZ;Gr.createCreateRelatedProjectService=VZ;Gr.createCreateAssetService=BZ;Gr.createArchiveAssetService=GZ;Gr.createCleanPropertiesService=qZ;Gr.createFixMissingLabelService=WZ;Gr.createRenameToUidService=zZ;Gr.createRepairFolderService=HZ;Gr.createPlanForEveningService=QZ;Gr.createUpdatePropertyService=YZ;Gr.createRemovePropertyService=XZ;Gr.createSetStatusService=KZ;Gr.createDuplicateAssetService=JZ;Gr.rewriteFrontmatterScalars=fN;var Ly=It();function Yi(n){return{resolveFile(e){let t=(0,Ly.iriToVaultPath)(e)??e,r=t.endsWith(".md")?t:`${t}.md`,i=n.getAbstractFileByPath(r);if(!i||!("basename"in i))throw new Error(`Cannot resolve target file for IRI: ${e}`);return i}}}a(Yi,"createPathBasedTargetResolver");var S2=a(()=>null,"NULL_CLASS_RESOLVER");function Dy(n){return n.startsWith('"[[')&&n.endsWith(']]"')?n:n.startsWith("[[")&&n.endsWith("]]")?`"${n}"`:`"[[${n}]]"`}a(Dy,"toQuotedWikilink");function UZ(n,e,t=Yi(n),r,i=S2){return{async execute(s,o){let l=o?.label;if(!l)throw new Error("createRelatedTask requires userInput.label");let c=t.resolveFile(s),u=n.getFrontmatter(c)??{},f=c.parent?.path||"",d={ems__Effort_status:'"[[c42245d0-01de-4c35-bfcf-d910445ea28e]]"'},h=o?.parentProperty;h&&c.basename&&(d[h]=`"[[${c.basename}]]"`);let p=await e.createAsset({className:"ems__Task",label:l,folderPath:f,propertyValues:d,parentFile:c,parentMetadata:u,classResolver:i});r&&await r(p)}}}a(UZ,"createCreateRelatedTaskService");function VZ(n,e,t=Yi(n),r,i=S2){return{async execute(s,o){let l=o?.label;if(!l)throw new Error("createRelatedProject requires userInput.label");let c=t.resolveFile(s),u=n.getFrontmatter(c)??{},f=c.parent?.path||"",d={ems__Effort_status:'"[[c42245d0-01de-4c35-bfcf-d910445ea28e]]"'},h=o?.parentProperty;h&&c.basename&&(d[h]=`"[[${c.basename}]]"`);let p=await e.createAsset({className:"ems__Project",label:l,folderPath:f,propertyValues:d,parentFile:c,parentMetadata:u,classResolver:i});r&&await r(p)}}}a(VZ,"createCreateRelatedProjectService");function BZ(n,e,t=S2,r=Yi(n)){return{async execute(i,s){let o=s?.prototypeUID??s?.prototype,l=s?.label,c=s?.folder,u=s?.ownerIdentity,f=s?.isDefinedBy;if(!o)throw new Error("createAsset requires userInput.prototypeUID");if(!l)throw new Error("createAsset requires userInput.label");let d,h;if(i)try{let D=r.resolveFile(i);d=D.path,h=n.getFrontmatter(D)??void 0}catch{}if(!c&&d){let D=d.lastIndexOf("/");c=D>=0?d.substring(0,D):""}if(c===void 0)throw new Error("createAsset requires userInput.folder");let p=o.endsWith("Prototype")?o.slice(0,-9):o,g=crypto.randomUUID(),_=Ly.DateFormatter.toISOTimestamp(new Date),v=`${g}.md`,w=c?`${c}/${v}`:v,E=["---",`exo__Asset_uid: ${g}`,`exo__Asset_createdAt: ${_}`,`exo__Asset_label: ${l}`,`exo__Asset_prototype: "[[${o}]]"`,"exo__Instance_class:",` - "[[${p}]]"`],I=!1;if(f&&(E.push(`exo__Asset_isDefinedBy: ${Dy(f)}`),I=!0),h){let D=h.exo__Instance_class,oe=(Array.isArray(D)?D:D!=null?[D]:[]).some(N=>Ly.WikiLinkHelpers.resolveSymbolic(String(N),t).includes("Area")),me=d?d.substring(d.lastIndexOf("/")+1).replace(/\.md$/,""):void 0;if(me){let N=oe?"ems__Effort_area":"ems__Effort_parent";E.push(`${N}: "[[${me}]]"`)}!oe&&h.ems__Effort_area&&E.push(`ems__Effort_area: ${Dy(String(h.ems__Effort_area))}`),E.push('ems__Effort_status: "[[753a44d5-846c-4b82-9196-4fd9a4d48777]]"'),!I&&h.exo__Asset_isDefinedBy&&(E.push(`exo__Asset_isDefinedBy: ${Dy(String(h.exo__Asset_isDefinedBy))}`),I=!0)}!I&&u&&E.push(`exo__Asset_isDefinedBy: ${Dy(u)}`),E.push("---","");let A=E.join(`
466
- `);await e.createFile(w,A)}}}a(BZ,"createCreateAssetService");function GZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.archiveAsset(i)}}}a(GZ,"createArchiveAssetService");function qZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.cleanEmptyProperties(i)}}}a(qZ,"createCleanPropertiesService");function WZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.fixMissingLabel(i)}}}a(WZ,"createFixMissingLabelService");function zZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r),s=n.getFrontmatter(i)??{};await e.renameToUid(i,s)}}}a(zZ,"createRenameToUidService");function HZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r),s=n.getFrontmatter(i)??{},o=await e.getExpectedFolder(i,s);if(o===null)throw new Error("repairFolder: cannot determine expected folder (missing exo__Asset_isDefinedBy or referenced asset not found)");(i.parent?.path??"")!==o&&await e.repairFolder(i,o)}}}a(HZ,"createRepairFolderService");function QZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.planForEvening(i)}}}a(QZ,"createPlanForEveningService");function YZ(n,e,t){return{async execute(r,i){let s=i?.property,o=i?.value;if(!s)throw new Error("updateProperty requires userInput.property");if(o===void 0)throw new Error("updateProperty requires userInput.value");let l=await t.resolveTargetPath(r),c=await n.readFile(l),u=e.updateProperty(c,s,o);await n.updateFile(l,u)}}}a(YZ,"createUpdatePropertyService");function XZ(n,e,t){return{async execute(r,i){let s=i?.property;if(!s)throw new Error("removeProperty requires userInput.property");let o=await t.resolveTargetPath(r),l=await n.readFile(o),c=e.removeProperty(l,s);await n.updateFile(o,c)}}}a(XZ,"createRemovePropertyService");function KZ(n,e,t){return{async execute(r,i){let s=i?.statusUID;if(!s)throw new Error("setStatus requires userInput.statusUID");let o=await t.resolveTargetPath(r),l=await n.readFile(o),c=e.updateProperty(l,"ems__Effort_status",`"[[${s}]]"`);await n.updateFile(o,c)}}}a(KZ,"createSetStatusService");function JZ(n,e=Yi(n),t){return{async execute(r){if(!r)throw new Error("duplicateAsset requires an active target \u2014 open an Exocortex asset before invoking");let i=e.resolveFile(r),s=await n.read(i),o=crypto.randomUUID(),l=Ly.DateFormatter.toLocalTimestamp(new Date),c=fN(s,{exo__Asset_uid:o,exo__Asset_createdAt:l}),u=i.parent?.path??"",f=u?`${u}/${o}.md`:`${o}.md`,d=await n.create(f,c);t&&await t(d)}}}a(JZ,"createDuplicateAssetService");function fN(n,e){let t=n.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!t)throw new Error("duplicateAsset: source file has no YAML frontmatter block");let r=t[1],i=new Map(Object.entries(e)),s=r.split(`
465
+ `,finalEOL:t=!0,replacer:r=null,spaces:i}={}){let s=t?e:"";return JSON.stringify(n,r,i).replace(/\n/g,e)+s}a(iz,"stringify");function sz(n){return Buffer.isBuffer(n)&&(n=n.toString("utf8")),n.replace(/^\uFEFF/,"")}a(sz,"stripBom");yP.exports={stringify:iz,stripBom:sz}});var wP=S((mde,SP)=>{var kc;try{kc=Dc()}catch{kc=require("fs")}var _g=Er(),{stringify:_P,stripBom:bP}=yg();async function oz(n,e={}){typeof e=="string"&&(e={encoding:e});let t=e.fs||kc,r="throws"in e?e.throws:!0,i=await _g.fromCallback(t.readFile)(n,e);i=bP(i);let s;try{s=JSON.parse(i,e?e.reviver:null)}catch(o){if(r)throw o.message=`${n}: ${o.message}`,o;return null}return s}a(oz,"_readFile");var az=_g.fromPromise(oz);function lz(n,e={}){typeof e=="string"&&(e={encoding:e});let t=e.fs||kc,r="throws"in e?e.throws:!0;try{let i=t.readFileSync(n,e);return i=bP(i),JSON.parse(i,e.reviver)}catch(i){if(r)throw i.message=`${n}: ${i.message}`,i;return null}}a(lz,"readFileSync");async function cz(n,e,t={}){let r=t.fs||kc,i=_P(e,t);await _g.fromCallback(r.writeFile)(n,i,t)}a(cz,"_writeFile");var uz=_g.fromPromise(cz);function fz(n,e,t={}){let r=t.fs||kc,i=_P(e,t);return r.writeFileSync(n,i,t)}a(fz,"writeFileSync");SP.exports={readFile:az,readFileSync:lz,writeFile:uz,writeFileSync:fz}});var EP=S((yde,vP)=>{"use strict";var bg=wP();vP.exports={readJson:bg.readFile,readJsonSync:bg.readFileSync,writeJson:bg.writeFile,writeJsonSync:bg.writeFileSync}});var Sg=S((_de,xP)=>{"use strict";var dz=Er().fromPromise,kv=mn(),TP=require("path"),IP=Ui(),hz=Yo().pathExists;async function pz(n,e,t="utf-8"){let r=TP.dirname(n);return await hz(r)||await IP.mkdirs(r),kv.writeFile(n,e,t)}a(pz,"outputFile");function mz(n,...e){let t=TP.dirname(n);kv.existsSync(t)||IP.mkdirsSync(t),kv.writeFileSync(n,...e)}a(mz,"outputFileSync");xP.exports={outputFile:dz(pz),outputFileSync:mz}});var RP=S((Sde,AP)=>{"use strict";var{stringify:gz}=yg(),{outputFile:yz}=Sg();async function _z(n,e,t={}){let r=gz(e,t);await yz(n,r,t)}a(_z,"outputJson");AP.exports=_z});var PP=S((vde,CP)=>{"use strict";var{stringify:bz}=yg(),{outputFileSync:Sz}=Sg();function wz(n,e,t){let r=bz(e,t);Sz(n,r,t)}a(wz,"outputJsonSync");CP.exports=wz});var FP=S((Tde,OP)=>{"use strict";var vz=Er().fromPromise,yn=EP();yn.outputJson=vz(RP());yn.outputJsonSync=PP();yn.outputJSON=yn.outputJson;yn.outputJSONSync=yn.outputJsonSync;yn.writeJSON=yn.writeJson;yn.writeJSONSync=yn.writeJsonSync;yn.readJSON=yn.readJson;yn.readJSONSync=yn.readJsonSync;OP.exports=yn});var MP=S((Ide,kP)=>{"use strict";var Ez=mn(),DP=require("path"),{copy:Tz}=gg(),{remove:NP}=kf(),{mkdirp:Iz}=Ui(),{pathExists:xz}=Yo(),LP=Ja();async function Az(n,e,t={}){let r=t.overwrite||t.clobber||!1,{srcStat:i,isChangingCase:s=!1}=await LP.checkPaths(n,e,"move",t);await LP.checkParentPaths(n,i,e,"move");let o=DP.dirname(e);return DP.parse(o).root!==o&&await Iz(o),Rz(n,e,r,s)}a(Az,"move");async function Rz(n,e,t,r){if(!r){if(t)await NP(e);else if(await xz(e))throw new Error("dest already exists.")}try{await Ez.rename(n,e)}catch(i){if(i.code!=="EXDEV")throw i;await Cz(n,e,t)}}a(Rz,"doRename");async function Cz(n,e,t){return await Tz(n,e,{overwrite:t,errorOnExist:!0,preserveTimestamps:!0}),NP(n)}a(Cz,"moveAcrossDevice");kP.exports=Az});var BP=S((Ade,VP)=>{"use strict";var $P=Dc(),jv=require("path"),Pz=gg().copySync,UP=kf().removeSync,Oz=Ui().mkdirpSync,jP=Ja();function Fz(n,e,t){t=t||{};let r=t.overwrite||t.clobber||!1,{srcStat:i,isChangingCase:s=!1}=jP.checkPathsSync(n,e,"move",t);return jP.checkParentPathsSync(n,i,e,"move"),Dz(e)||Oz(jv.dirname(e)),Lz(n,e,r,s)}a(Fz,"moveSync");function Dz(n){let e=jv.dirname(n);return jv.parse(e).root===e}a(Dz,"isParentRoot");function Lz(n,e,t,r){if(r)return Mv(n,e,t);if(t)return UP(e),Mv(n,e,t);if($P.existsSync(e))throw new Error("dest already exists.");return Mv(n,e,t)}a(Lz,"doRename");function Mv(n,e,t){try{$P.renameSync(n,e)}catch(r){if(r.code!=="EXDEV")throw r;return Nz(n,e,t)}}a(Mv,"rename");function Nz(n,e,t){return Pz(n,e,{overwrite:t,errorOnExist:!0,preserveTimestamps:!0}),UP(n)}a(Nz,"moveAcrossDevice");VP.exports=Fz});var qP=S((Cde,GP)=>{"use strict";var kz=Er().fromPromise;GP.exports={move:kz(MP()),moveSync:BP()}});var Jo=S((Pde,WP)=>{"use strict";WP.exports={...mn(),...gg(),...qC(),...gP(),...FP(),...Ui(),...qP(),...Sg(),...Yo(),...kf()}});var ZO=S((Dde,JO)=>{"use strict";JO.exports=XO;function XO(n,e,t){n instanceof RegExp&&(n=YO(n,t)),e instanceof RegExp&&(e=YO(e,t));var r=KO(n,e,t);return r&&{start:r[0],end:r[1],pre:t.slice(0,r[0]),body:t.slice(r[0]+n.length,r[1]),post:t.slice(r[1]+e.length)}}a(XO,"balanced");function YO(n,e){var t=e.match(n);return t?t[0]:null}a(YO,"maybeMatch");XO.range=KO;function KO(n,e,t){var r,i,s,o,l,c=t.indexOf(n),u=t.indexOf(e,c+1),f=c;if(c>=0&&u>0){if(n===e)return[c,u];for(r=[],s=t.length;f>=0&&!l;)f==c?(r.push(f),c=t.indexOf(n,f+1)):r.length==1?l=[r.pop(),u]:(i=r.pop(),i<s&&(s=i,o=u),u=t.indexOf(e,f+1)),f=c<u&&c>=0?c:u;r.length&&(l=[s,o])}return l}a(KO,"range")});var aF=S((Nde,oF)=>{var eF=ZO();oF.exports=iY;var tF="\0SLASH"+Math.random()+"\0",rF="\0OPEN"+Math.random()+"\0",eE="\0CLOSE"+Math.random()+"\0",nF="\0COMMA"+Math.random()+"\0",iF="\0PERIOD"+Math.random()+"\0";function Zv(n){return parseInt(n,10)==n?parseInt(n,10):n.charCodeAt(0)}a(Zv,"numeric");function rY(n){return n.split("\\\\").join(tF).split("\\{").join(rF).split("\\}").join(eE).split("\\,").join(nF).split("\\.").join(iF)}a(rY,"escapeBraces");function nY(n){return n.split(tF).join("\\").split(rF).join("{").split(eE).join("}").split(nF).join(",").split(iF).join(".")}a(nY,"unescapeBraces");function sF(n){if(!n)return[""];var e=[],t=eF("{","}",n);if(!t)return n.split(",");var r=t.pre,i=t.body,s=t.post,o=r.split(",");o[o.length-1]+="{"+i+"}";var l=sF(s);return s.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),e.push.apply(e,o),e}a(sF,"parseCommaParts");function iY(n){return n?(n.substr(0,2)==="{}"&&(n="\\{\\}"+n.substr(2)),Gf(rY(n),!0).map(nY)):[]}a(iY,"expandTop");function sY(n){return"{"+n+"}"}a(sY,"embrace");function oY(n){return/^-?0\d/.test(n)}a(oY,"isPadded");function aY(n,e){return n<=e}a(aY,"lte");function lY(n,e){return n>=e}a(lY,"gte");function Gf(n,e){var t=[],r=eF("{","}",n);if(!r)return[n];var i=r.pre,s=r.post.length?Gf(r.post,!1):[""];if(/\$$/.test(r.pre))for(var o=0;o<s.length;o++){var l=i+"{"+r.body+"}"+s[o];t.push(l)}else{var c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),f=c||u,d=r.body.indexOf(",")>=0;if(!f&&!d)return r.post.match(/,(?!,).*\}/)?(n=r.pre+"{"+r.body+eE+r.post,Gf(n)):[n];var h;if(f)h=r.body.split(/\.\./);else if(h=sF(r.body),h.length===1&&(h=Gf(h[0],!1).map(sY),h.length===1))return s.map(function(Y){return r.pre+h[0]+Y});var p;if(f){var g=Zv(h[0]),_=Zv(h[1]),v=Math.max(h[0].length,h[1].length),w=h.length==3?Math.max(Math.abs(Zv(h[2])),1):1,E=aY,I=_<g;I&&(w*=-1,E=lY);var O=h.some(oY);p=[];for(var C=g;E(C,_);C+=w){var H;if(u)H=String.fromCharCode(C),H==="\\"&&(H="");else if(H=String(C),O){var ne=v-H.length;if(ne>0){var de=new Array(ne+1).join("0");C<0?H="-"+de+H.slice(1):H=de+H}}p.push(H)}}else{p=[];for(var N=0;N<h.length;N++)p.push.apply(p,Gf(h[N],!1))}for(var N=0;N<p.length;N++)for(var o=0;o<s.length;o++){var l=i+p[N]+s[o];(!e||f||l)&&t.push(l)}}return t}a(Gf,"expand")});var dN=S(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.createPathBasedTargetResolver=Yi;Gr.createCreateRelatedTaskService=UZ;Gr.createCreateRelatedProjectService=VZ;Gr.createCreateAssetService=BZ;Gr.createArchiveAssetService=GZ;Gr.createCleanPropertiesService=qZ;Gr.createFixMissingLabelService=WZ;Gr.createRenameToUidService=zZ;Gr.createRepairFolderService=HZ;Gr.createPlanForEveningService=QZ;Gr.createUpdatePropertyService=YZ;Gr.createRemovePropertyService=XZ;Gr.createSetStatusService=KZ;Gr.createDuplicateAssetService=JZ;Gr.rewriteFrontmatterScalars=fN;var Ly=It();function Yi(n){return{resolveFile(e){let t=(0,Ly.iriToVaultPath)(e)??e,r=t.endsWith(".md")?t:`${t}.md`,i=n.getAbstractFileByPath(r);if(!i||!("basename"in i))throw new Error(`Cannot resolve target file for IRI: ${e}`);return i}}}a(Yi,"createPathBasedTargetResolver");var S2=a(()=>null,"NULL_CLASS_RESOLVER");function Dy(n){return n.startsWith('"[[')&&n.endsWith(']]"')?n:n.startsWith("[[")&&n.endsWith("]]")?`"${n}"`:`"[[${n}]]"`}a(Dy,"toQuotedWikilink");function UZ(n,e,t=Yi(n),r,i=S2){return{async execute(s,o){let l=o?.label;if(!l)throw new Error("createRelatedTask requires userInput.label");let c=t.resolveFile(s),u=n.getFrontmatter(c)??{},f=c.parent?.path||"",d={ems__Effort_status:'"[[c42245d0-01de-4c35-bfcf-d910445ea28e]]"'},h=o?.parentProperty;h&&c.basename&&(d[h]=`"[[${c.basename}]]"`);let p=await e.createAsset({className:"ems__Task",label:l,folderPath:f,propertyValues:d,parentFile:c,parentMetadata:u,classResolver:i});r&&await r(p)}}}a(UZ,"createCreateRelatedTaskService");function VZ(n,e,t=Yi(n),r,i=S2){return{async execute(s,o){let l=o?.label;if(!l)throw new Error("createRelatedProject requires userInput.label");let c=t.resolveFile(s),u=n.getFrontmatter(c)??{},f=c.parent?.path||"",d={ems__Effort_status:'"[[c42245d0-01de-4c35-bfcf-d910445ea28e]]"'},h=o?.parentProperty;h&&c.basename&&(d[h]=`"[[${c.basename}]]"`);let p=await e.createAsset({className:"ems__Project",label:l,folderPath:f,propertyValues:d,parentFile:c,parentMetadata:u,classResolver:i});r&&await r(p)}}}a(VZ,"createCreateRelatedProjectService");function BZ(n,e,t=S2,r=Yi(n)){return{async execute(i,s){let o=s?.prototypeUID??s?.prototype,l=s?.label,c=s?.folder,u=s?.ownerIdentity,f=s?.isDefinedBy;if(!o)throw new Error("createAsset requires userInput.prototypeUID");if(!l)throw new Error("createAsset requires userInput.label");let d,h;if(i)try{let C=r.resolveFile(i);d=C.path,h=n.getFrontmatter(C)??void 0}catch{}if(!c&&d){let C=d.lastIndexOf("/");c=C>=0?d.substring(0,C):""}if(c===void 0)throw new Error("createAsset requires userInput.folder");let p=o.endsWith("Prototype")?o.slice(0,-9):o,g=crypto.randomUUID(),_=Ly.DateFormatter.toISOTimestamp(new Date),v=`${g}.md`,w=c?`${c}/${v}`:v,E=["---",`exo__Asset_uid: ${g}`,`exo__Asset_createdAt: ${_}`,`exo__Asset_label: ${l}`,`exo__Asset_prototype: "[[${o}]]"`,"exo__Instance_class:",` - "[[${p}]]"`],I=!1;if(f&&(E.push(`exo__Asset_isDefinedBy: ${Dy(f)}`),I=!0),h){let C=h.exo__Instance_class,ne=(Array.isArray(C)?C:C!=null?[C]:[]).some(N=>Ly.WikiLinkHelpers.resolveSymbolic(String(N),t).includes("Area")),de=d?d.substring(d.lastIndexOf("/")+1).replace(/\.md$/,""):void 0;if(de){let N=ne?"ems__Effort_area":"ems__Effort_parent";E.push(`${N}: "[[${de}]]"`)}!ne&&h.ems__Effort_area&&E.push(`ems__Effort_area: ${Dy(String(h.ems__Effort_area))}`),E.push('ems__Effort_status: "[[753a44d5-846c-4b82-9196-4fd9a4d48777]]"'),!I&&h.exo__Asset_isDefinedBy&&(E.push(`exo__Asset_isDefinedBy: ${Dy(String(h.exo__Asset_isDefinedBy))}`),I=!0)}!I&&u&&E.push(`exo__Asset_isDefinedBy: ${Dy(u)}`),E.push("---","");let O=E.join(`
466
+ `);await e.createFile(w,O)}}}a(BZ,"createCreateAssetService");function GZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.archiveAsset(i)}}}a(GZ,"createArchiveAssetService");function qZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.cleanEmptyProperties(i)}}}a(qZ,"createCleanPropertiesService");function WZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.fixMissingLabel(i)}}}a(WZ,"createFixMissingLabelService");function zZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r),s=n.getFrontmatter(i)??{};await e.renameToUid(i,s)}}}a(zZ,"createRenameToUidService");function HZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r),s=n.getFrontmatter(i)??{},o=await e.getExpectedFolder(i,s);if(o===null)throw new Error("repairFolder: cannot determine expected folder (missing exo__Asset_isDefinedBy or referenced asset not found)");(i.parent?.path??"")!==o&&await e.repairFolder(i,o)}}}a(HZ,"createRepairFolderService");function QZ(n,e,t=Yi(n)){return{async execute(r){let i=t.resolveFile(r);await e.planForEvening(i)}}}a(QZ,"createPlanForEveningService");function YZ(n,e,t){return{async execute(r,i){let s=i?.property,o=i?.value;if(!s)throw new Error("updateProperty requires userInput.property");if(o===void 0)throw new Error("updateProperty requires userInput.value");let l=await t.resolveTargetPath(r),c=await n.readFile(l),u=e.updateProperty(c,s,o);await n.updateFile(l,u)}}}a(YZ,"createUpdatePropertyService");function XZ(n,e,t){return{async execute(r,i){let s=i?.property;if(!s)throw new Error("removeProperty requires userInput.property");let o=await t.resolveTargetPath(r),l=await n.readFile(o),c=e.removeProperty(l,s);await n.updateFile(o,c)}}}a(XZ,"createRemovePropertyService");function KZ(n,e,t){return{async execute(r,i){let s=i?.statusUID;if(!s)throw new Error("setStatus requires userInput.statusUID");let o=await t.resolveTargetPath(r),l=await n.readFile(o),c=e.updateProperty(l,"ems__Effort_status",`"[[${s}]]"`);await n.updateFile(o,c)}}}a(KZ,"createSetStatusService");function JZ(n,e=Yi(n),t){return{async execute(r){if(!r)throw new Error("duplicateAsset requires an active target \u2014 open an Exocortex asset before invoking");let i=e.resolveFile(r),s=await n.read(i),o=crypto.randomUUID(),l=Ly.DateFormatter.toLocalTimestamp(new Date),c=fN(s,{exo__Asset_uid:o,exo__Asset_createdAt:l}),u=i.parent?.path??"",f=u?`${u}/${o}.md`:`${o}.md`,d=await n.create(f,c);t&&await t(d)}}}a(JZ,"createDuplicateAssetService");function fN(n,e){let t=n.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!t)throw new Error("duplicateAsset: source file has no YAML frontmatter block");let r=t[1],i=new Map(Object.entries(e)),s=r.split(`
467
467
  `).map(u=>{let f=u.match(/^([A-Za-z_][A-Za-z0-9_]*):/);if(!f)return u;let d=f[1],h=i.get(d);return h===void 0?u:(i.delete(d),`${d}: ${h}`)});for(let[u,f]of i)s.push(`${u}: ${f}`);let o=s.join(`
468
468
  `),l=t[0].includes(`\r
469
469
  `)?`\r
@@ -499,7 +499,7 @@ GFS4: `),console.error(n)},"debug"));Vt[$r]||(iC=global[$r]||[],oC(Vt,iC),Vt.clo
499
499
  `+n.slice(i,s),i=s+1),o=l;return c+=`
500
500
  `,n.length-i>e&&o>i?c+=n.slice(i,o)+`
501
501
  `+n.slice(o+1):c+=n.slice(i),c.slice(1)}a(iO,"foldLine");function LQ(n){for(var e="",t=0,r,i=0;i<n.length;t>=65536?i+=2:i++)t=jf(n,i),r=Jr[t],!r&&Bf(t)?(e+=n[i],t>=65536&&(e+=n[i+1])):e+=r||IQ(t);return e}a(LQ,"escapeString");function NQ(n,e,t){var r="",i=n.tag,s,o,l;for(s=0,o=t.length;s<o;s+=1)l=t[s],n.replacer&&(l=n.replacer.call(t,String(s),l)),(go(n,e,l,!1,!1)||typeof l>"u"&&go(n,e,null,!1,!1))&&(r!==""&&(r+=","+(n.condenseFlow?"":" ")),r+=n.dump);n.tag=i,n.dump="["+r+"]"}a(NQ,"writeFlowSequence");function sO(n,e,t,r){var i="",s=n.tag,o,l,c;for(o=0,l=t.length;o<l;o+=1)c=t[o],n.replacer&&(c=n.replacer.call(t,String(o),c)),(go(n,e+1,c,!0,!0,!1,!0)||typeof c>"u"&&go(n,e+1,null,!0,!0,!1,!0))&&((!r||i!=="")&&(i+=qv(n,e)),n.dump&&Uf===n.dump.charCodeAt(0)?i+="-":i+="- ",i+=n.dump);n.tag=s,n.dump=i||"[]"}a(sO,"writeBlockSequence");function kQ(n,e,t){var r="",i=n.tag,s=Object.keys(t),o,l,c,u,f;for(o=0,l=s.length;o<l;o+=1)f="",r!==""&&(f+=", "),n.condenseFlow&&(f+='"'),c=s[o],u=t[c],n.replacer&&(u=n.replacer.call(t,c,u)),go(n,e,c,!1,!1)&&(n.dump.length>1024&&(f+="? "),f+=n.dump+(n.condenseFlow?'"':"")+":"+(n.condenseFlow?"":" "),go(n,e,u,!1,!1)&&(f+=n.dump,r+=f));n.tag=i,n.dump="{"+r+"}"}a(kQ,"writeFlowMapping");function MQ(n,e,t,r){var i="",s=n.tag,o=Object.keys(t),l,c,u,f,d,h;if(n.sortKeys===!0)o.sort();else if(typeof n.sortKeys=="function")o.sort(n.sortKeys);else if(n.sortKeys)throw new _n("sortKeys must be a boolean or a function");for(l=0,c=o.length;l<c;l+=1)h="",(!r||i!=="")&&(h+=qv(n,e)),u=o[l],f=t[u],n.replacer&&(f=n.replacer.call(t,u,f)),go(n,e+1,u,!0,!0,!0)&&(d=n.tag!==null&&n.tag!=="?"||n.dump&&n.dump.length>1024,d&&(n.dump&&Uf===n.dump.charCodeAt(0)?h+="?":h+="? "),h+=n.dump,d&&(h+=qv(n,e)),go(n,e+1,f,!0,d)&&(n.dump&&Uf===n.dump.charCodeAt(0)?h+=":":h+=": ",h+=n.dump,i+=h));n.tag=s,n.dump=i||"{}"}a(MQ,"writeBlockMapping");function oO(n,e,t){var r,i,s,o,l,c;for(i=t?n.explicitTypes:n.implicitTypes,s=0,o=i.length;s<o;s+=1)if(l=i[s],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof e=="object"&&e instanceof l.instanceOf)&&(!l.predicate||l.predicate(e))){if(t?l.multi&&l.representName?n.tag=l.representName(e):n.tag=l.tag:n.tag="?",l.represent){if(c=n.styleMap[l.tag]||l.defaultStyle,jO.call(l.represent)==="[object Function]")r=l.represent(e,c);else if($O.call(l.represent,c))r=l.represent[c](e,c);else throw new _n("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');n.dump=r}return!0}return!1}a(oO,"detectType");function go(n,e,t,r,i,s,o){n.tag=null,n.dump=t,oO(n,t,!1)||oO(n,t,!0);var l=jO.call(n.dump),c=r,u;r&&(r=n.flowLevel<0||n.flowLevel>e);var f=l==="[object Object]"||l==="[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),l==="[object Object]")r&&Object.keys(n.dump).length!==0?(MQ(n,e,n.dump,i),h&&(n.dump="&ref_"+d+n.dump)):(kQ(n,e,n.dump),h&&(n.dump="&ref_"+d+" "+n.dump));else if(l==="[object Array]")r&&n.dump.length!==0?(n.noArrayIndent&&!o&&e>0?sO(n,e-1,n.dump,i):sO(n,e,n.dump,i),h&&(n.dump="&ref_"+d+n.dump)):(NQ(n,e,n.dump),h&&(n.dump="&ref_"+d+" "+n.dump));else if(l==="[object String]")n.tag!=="?"&&FQ(n,n.dump,e,s,c);else{if(l==="[object Undefined]")return!1;if(n.skipInvalid)return!1;throw new _n("unacceptable kind of an object to dump "+l)}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}a(go,"writeNode");function jQ(n,e){var t=[],r=[],i,s;for(zv(n,t,r),i=0,s=r.length;i<s;i+=1)e.duplicates.push(t[r[i]]);e.usedDuplicates=new Array(s)}a(jQ,"getDuplicateReferences");function zv(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)zv(n[i],e,t);else for(r=Object.keys(n),i=0,s=r.length;i<s;i+=1)zv(n[r[i]],e,t)}a(zv,"inspectNode");function $Q(n,e){e=e||{};var t=new AQ(e);t.noRefs||jQ(n,t);var r=n;return t.replacer&&(r=t.replacer.call({"":r},"",r)),go(t,0,r,!0,!0)?t.dump+`
502
- `:""}a($Q,"dump$1");var UQ=$Q,VQ={dump:UQ};function Jv(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.")}}a(Jv,"renamed");var BQ=Ur,GQ=cO,qQ=hO,WQ=_O,zQ=bO,HQ=Qv,QQ=MO.load,YQ=MO.loadAll,XQ=VQ.dump,KQ=_n,JQ={binary:TO,float:yO,map:dO,null:pO,pairs:xO,set:AO,timestamp:vO,bool:mO,int:gO,merge:EO,omap:IO,seq:fO,str:uO},ZQ=Jv("safeLoad","load"),eY=Jv("safeLoadAll","loadAll"),tY=Jv("safeDump","dump"),Wt={Type:BQ,Schema:GQ,FAILSAFE_SCHEMA:qQ,JSON_SCHEMA:WQ,CORE_SCHEMA:zQ,DEFAULT_SCHEMA:HQ,load:QQ,loadAll:YQ,dump:XQ,YAMLException:KQ,types:JQ,safeLoad:ZQ,safeLoadAll:eY,safeDump:tY};var bE=Z(Jo()),il=Z(require("path"));var gF=Z(aF(),1);var qf=a(n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var cY={"[: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]},Wf=a(n=>n.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),uY=a(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),lF=a(n=>n.join(""),"rangesToString"),cF=a((n,e)=>{let t=e;if(n.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=t+1,o=!1,l=!1,c=!1,u=!1,f=t,d="";e:for(;s<n.length;){let _=n.charAt(s);if((_==="!"||_==="^")&&s===t+1){u=!0,s++;continue}if(_==="]"&&o&&!c){f=s+1;break}if(o=!0,_==="\\"&&!c){c=!0,s++;continue}if(_==="["&&!c){for(let[v,[w,E,I]]of Object.entries(cY))if(n.startsWith(v,s)){if(d)return["$.",!1,n.length-t,!0];s+=v.length,I?i.push(w):r.push(w),l=l||E;continue e}}if(c=!1,d){_>d?r.push(Wf(d)+"-"+Wf(_)):_===d&&r.push(Wf(_)),d="",s++;continue}if(n.startsWith("-]",s+1)){r.push(Wf(_+"-")),s+=2;continue}if(n.startsWith("-",s+1)){d=_,s+=2;continue}r.push(Wf(_)),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 _=r[0].length===2?r[0].slice(-1):r[0];return[uY(_),!1,f-t,!1]}let h="["+(u?"^":"")+lF(r)+"]",p="["+(u?"":"^")+lF(i)+"]";return[r.length&&i.length?"("+h+"|"+p+")":r.length?h:p,l,f-t,!0]},"parseClass");var Vi=a((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),"unescape");var Mn,fY=new Set(["!","?","+","*","@"]),tE=a(n=>fY.has(n),"isExtglobType"),uF=a(n=>tE(n.type),"isExtglobAST"),dY=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),hY=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),pY=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),fF=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),mY="(?!(?:^|/)\\.\\.?(?:$|/))",Ag="(?!\\.)",gY=new Set(["[","."]),yY=new Set(["..","."]),_Y=new Set("().*{}+?[]^$\\!"),bY=a(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),rE="[^/]",dF=rE+"*?",hF=rE+"+?",tl=class{static{a(this,"AST")}type;#e;#n;#r=!1;#t=[];#l;#_;#i;#u=!1;#s;#c;#o=!1;constructor(e,t,r={}){this.type=e,e&&(this.#n=!0),this.#l=t,this.#e=this.#l?this.#l.#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.#l?this.#l.#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.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#c=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.#l;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.#l}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof Mn&&t.#l===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.#l?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#l?.isStart())return!1;if(this.#_===0)return!0;let e=this.#l;for(let t=0;t<this.#_;t++){let r=e.#t[t];if(!(r instanceof Mn&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#l?.type==="!")return!0;if(!this.#l?.isEnd())return!1;if(!this.type)return this.#l?.isEnd();let e=this.#l?this.#l.#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 Mn(this.type,e);for(let r of this.#t)t.copyIn(r);return t}static#g(e,t,r,i,s){let o=i.maxExtglobRecursion??2,l=!1,c=!1,u=-1,f=!1;if(t.type===null){let _=r,v="";for(;_<e.length;){let w=e.charAt(_++);if(l||w==="\\"){l=!l,v+=w;continue}if(c){_===u+1?(w==="^"||w==="!")&&(f=!0):w==="]"&&!(_===u+2&&f)&&(c=!1),v+=w;continue}else if(w==="["){c=!0,u=_,f=!1,v+=w;continue}if(!i.noext&&tE(w)&&e.charAt(_)==="("&&s<=o){t.push(v),v="";let I=new Mn(w,t);_=Mn.#g(e,I,_,i,s+1),t.push(I);continue}v+=w}return t.push(v),_}let d=r+1,h=new Mn(null,t),p=[],g="";for(;d<e.length;){let _=e.charAt(d++);if(l||_==="\\"){l=!l,g+=_;continue}if(c){d===u+1?(_==="^"||_==="!")&&(f=!0):_==="]"&&!(d===u+2&&f)&&(c=!1),g+=_;continue}else if(_==="["){c=!0,u=d,f=!1,g+=_;continue}if(tE(_)&&e.charAt(d)==="("&&(s<=o||t&&t.#y(_))){let w=t&&t.#y(_)?0:1;h.push(g),g="";let E=new Mn(_,h);h.push(E),d=Mn.#g(e,E,d,i,s+w);continue}if(_==="|"){h.push(g),g="",p.push(h),h=new Mn(null,t);continue}if(_===")")return g===""&&t.#t.length===0&&(t.#o=!0),h.push(g),g="",t.push(...p,h),d;g+=_}return t.type=null,t.#n=void 0,t.#t=[e.substring(r-1)],d}#d(e){return this.#m(e,hY)}#m(e,t=dY){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=pY){return!!t.get(this.type)?.includes(e)}#f(e,t){let r=e.#t[0],i=new Mn(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.#l=this);this.#c=void 0}#T(e){return!!fF.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=fF.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.#l=this);this.type=i,this.#c=void 0,this.#o=!1}#S(){if(uF(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.#c=void 0}static fromGlob(e,t={}){let r=new Mn(null,void 0,t);return Mn.#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 l=(this.#s.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,l),{_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()),!uF(this)){let c=this.isStart()&&this.isEnd(),u=this.#t.map(p=>{let[g,_,v,w]=typeof p=="string"?Mn.#x(p,this.#n,c):p.toRegExpSource(e);return this.#n=this.#n||v,this.#r=this.#r||w,g}).join(""),f="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&yY.has(this.#t[0]))){let g=gY,_=t&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),v=!t&&!e&&g.has(u.charAt(0));f=_?mY:v?Ag:""}let d="";return this.isEnd()&&this.#e.#u&&this.#l?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,Vi(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 c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#n=void 0,[c,Vi(this.toString()),!1,!1]}let o=!r||e||t||!Ag?"":this.#w(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let l="";if(this.type==="!"&&this.#o)l=(this.isStart()&&!t?Ag:"")+hF;else{let c=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Ag:"")+dF+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;l=i+s+c}return[l,Vi(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,o]=t.toRegExpSource(e);return this.#r=this.#r||o,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#x(e,t,r=!1){let i=!1,s="",o=!1,l=!1;for(let c=0;c<e.length;c++){let u=e.charAt(c);if(i){i=!1,s+=(_Y.has(u)?"\\":"")+u,l=!1;continue}if(u==="\\"){c===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,h,p]=cF(e,c);if(h){s+=f,o=o||d,c+=h-1,t=t||p,l=!1;continue}}if(u==="*"){if(l)continue;l=!0,s+=r&&/^[*]+$/.test(e)?hF:dF,t=!0;continue}else l=!1;if(u==="?"){s+=rE,t=!0;continue}s+=bY(u)}return[s,Vi(e),!!t,o]}};Mn=tl;var Vc=a((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Vr=a((n,e,t={})=>(qf(e),!t.nocomment&&e.charAt(0)==="#"?!1:new zn(e,t).match(n)),"minimatch"),SY=/^\*+([^+@!?\*\[\(]*)$/,wY=a(n=>e=>!e.startsWith(".")&&e.endsWith(n),"starDotExtTest"),vY=a(n=>e=>e.endsWith(n),"starDotExtTestDot"),EY=a(n=>(n=n.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(n)),"starDotExtTestNocase"),TY=a(n=>(n=n.toLowerCase(),e=>e.toLowerCase().endsWith(n)),"starDotExtTestNocaseDot"),IY=/^\*+\.\*+$/,xY=a(n=>!n.startsWith(".")&&n.includes("."),"starDotStarTest"),AY=a(n=>n!=="."&&n!==".."&&n.includes("."),"starDotStarTestDot"),RY=/^\.\*+$/,CY=a(n=>n!=="."&&n!==".."&&n.startsWith("."),"dotStarTest"),PY=/^\*+$/,OY=a(n=>n.length!==0&&!n.startsWith("."),"starTest"),FY=a(n=>n.length!==0&&n!=="."&&n!=="..","starTestDot"),DY=/^\?+([^+@!?\*\[\(]*)?$/,LY=a(([n,e=""])=>{let t=yF([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),NY=a(([n,e=""])=>{let t=_F([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),kY=a(([n,e=""])=>{let t=_F([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTestDot"),MY=a(([n,e=""])=>{let t=yF([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTest"),yF=a(([n])=>{let e=n.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),_F=a(([n])=>{let e=n.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),bF=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",pF={win32:{sep:"\\"},posix:{sep:"/"}},jY=bF==="win32"?pF.win32.sep:pF.posix.sep;Vr.sep=jY;var Yt=Symbol("globstar **");Vr.GLOBSTAR=Yt;var $Y="[^/]",UY=$Y+"*?",VY="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",BY="(?:(?!(?:\\/|^)\\.).)*?",GY=a((n,e={})=>t=>Vr(t,n,e),"filter");Vr.filter=GY;var li=a((n,e={})=>Object.assign({},n,e),"ext"),qY=a(n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return Vr;let e=Vr;return Object.assign(a((r,i,s={})=>e(r,i,li(n,s)),"m"),{Minimatch:class extends e.Minimatch{static{a(this,"Minimatch")}constructor(i,s={}){super(i,li(n,s))}static defaults(i){return e.defaults(li(n,i)).Minimatch}},AST:class extends e.AST{static{a(this,"AST")}constructor(i,s,o={}){super(i,s,li(n,o))}static fromGlob(i,s={}){return e.AST.fromGlob(i,li(n,s))}},unescape:a((r,i={})=>e.unescape(r,li(n,i)),"unescape"),escape:a((r,i={})=>e.escape(r,li(n,i)),"escape"),filter:a((r,i={})=>e.filter(r,li(n,i)),"filter"),defaults:a(r=>e.defaults(li(n,r)),"defaults"),makeRe:a((r,i={})=>e.makeRe(r,li(n,i)),"makeRe"),braceExpand:a((r,i={})=>e.braceExpand(r,li(n,i)),"braceExpand"),match:a((r,i,s={})=>e.match(r,i,li(n,s)),"match"),sep:e.sep,GLOBSTAR:Yt})},"defaults");Vr.defaults=qY;var SF=a((n,e={})=>(qf(n),e.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,gF.default)(n)),"braceExpand");Vr.braceExpand=SF;var WY=a((n,e={})=>new zn(n,e).makeRe(),"makeRe");Vr.makeRe=WY;var zY=a((n,e,t={})=>{let r=new zn(e,t);return n=n.filter(i=>r.match(i)),r.options.nonull&&!n.length&&n.push(e),n},"match");Vr.match=zY;var mF=/[?*]|[+@!]\(.*?\)|\[|\]/,HY=a(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),zn=class{static{a(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){qf(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||bF,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,o,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!mF.test(s[2]))&&!mF.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)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(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let 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 o=i;for(;r[o+1]==="**";)o++;o>i&&r.splice(i+1,o-i);let l=r[i+1],c=r[i+2],u=r[i+3];if(l!==".."||!c||c==="."||c===".."||!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 o=1;o<r.length-1;o++){let l=r[o];o===1&&l===""&&r[0]===""||(l==="."||l==="")&&(t=!0,r.splice(o,1),o--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let o=r[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let c=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...c),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,o=[],l="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])o.push(l==="b"?t[s]:e[i]),i++,s++;else if(r&&e[i]==="**"&&t[s]===e[i+1])o.push(e[i]),i++;else if(r&&t[s]==="**"&&e[i]===t[s+1])o.push(t[s]),s++;else if(e[i]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(l==="b")return!1;l="a",o.push(e[i]),i++,s++}else if(t[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(l==="a")return!1;l="b",o.push(t[s]),i++,s++}else return!1;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,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 l=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),c=!l&&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=c?3:l?0:void 0,h=f?3:u?0:void 0;if(typeof d=="number"&&typeof h=="number"){let[p,g]=[e[d],t[h]];p.toLowerCase()===g.toLowerCase()&&(t[h]=p,s=h,i=d)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Yt)?this.#e(e,t,r,i,s):this.#r(e,t,r,i,s)}#e(e,t,r,i,s){let o=t.indexOf(Yt,s),l=t.lastIndexOf(Yt),[c,u,f]=r?[t.slice(s,o),t.slice(o+1),[]]:[t.slice(s,o),t.slice(o+1,l),t.slice(l+1)];if(c.length){let E=e.slice(i,i+c.length);if(!this.#r(E,c,r,0,0))return!1;i+=c.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let E=e.length-f.length;if(this.#r(e,f,r,E,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(E--,!this.#r(e,f,r,E,0)))return!1;d=f.length+1}}if(!u.length){let E=!!d;for(let I=i;I<e.length-d;I++){let A=String(e[I]);if(E=!0,A==="."||A===".."||!this.options.dot&&A.startsWith("."))return!1}return r||E}let h=[[[],0]],p=h[0],g=0,_=[0];for(let E of u)E===Yt?(_.push(g),p=[[],0],h.push(p)):(p[0].push(E),g++);let v=h.length-1,w=e.length-d;for(let E of h)E[1]=w-(_[v--]+E[0].length);return!!this.#n(e,h,i,0,r,0,!!d)}#n(e,t,r,i,s,o,l){let c=t[i];if(!c){for(let d=r;d<e.length;d++){l=!0;let h=e[d];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1}return l}let[u,f]=c;for(;r<=f;){if(this.#r(e.slice(0,r+u.length),u,s,r,0)&&o<this.maxGlobstarRecursion){let p=this.#n(e,t,r+u.length,i+1,s,o+1,l);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 o,l,c,u;for(o=i,l=s,u=e.length,c=t.length;o<u&&l<c;o++,l++){this.debug("matchOne loop");let f=t[l],d=e[o];if(this.debug(t,f,d),f===!1||f===Yt)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(o===u&&l===c)return!0;if(o===u)return r;if(l===c)return o===u-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return SF(this.pattern,this.options)}parse(e){qf(e);let t=this.options;if(e==="**")return Yt;if(e==="")return"";let r,i=null;(r=e.match(PY))?i=t.dot?FY:OY:(r=e.match(SY))?i=(t.nocase?t.dot?TY:EY:t.dot?vY:wY)(r[1]):(r=e.match(DY))?i=(t.nocase?t.dot?NY:LY:t.dot?kY:MY)(r):(r=e.match(IY))?i=t.dot?AY:xY:(r=e.match(RY))&&(i=CY);let s=tl.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?UY:t.dot?VY:BY,i=new Set(t.nocase?["i"]:[]),s=e.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let d of f.flags.split(""))i.add(d);return typeof f=="string"?HY(f):f===Yt?Yt:f._src});return u.forEach((f,d)=>{let h=u[d+1],p=u[d-1];f!==Yt||p===Yt||(p===void 0?h!==void 0&&h!==Yt?u[d+1]="(?:\\/|"+r+"\\/)?"+h:u[d]=r:h===void 0?u[d-1]=p+"(?:\\/|"+r+")?":h!==Yt&&(u[d-1]=p+"(?:\\/|\\/"+r+"\\/)"+h,u[d+1]=Yt))}),u.filter(f=>f!==Yt).join("/")}).join("|"),[o,l]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+l+"$",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 o=i[i.length-1];if(!o)for(let l=i.length-2;!o&&l>=0;l--)o=i[l];for(let l=0;l<s.length;l++){let c=s[l],u=i;if(r.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Vr.defaults(e).Minimatch}};Vr.AST=tl;Vr.Minimatch=zn;Vr.escape=Vc;Vr.unescape=Vi;var qF=require("node:url");var Bc=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,vF=new Set,nE=typeof process=="object"&&process?process:{},EF=a((n,e,t,r)=>{typeof nE.emitWarning=="function"?nE.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)},"emitWarning"),Rg=globalThis.AbortController,wF=globalThis.AbortSignal;if(typeof Rg>"u"){wF=class{static{a(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},Rg=class{static{a(this,"AbortController")}constructor(){e()}signal=new wF;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=nE.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=a(()=>{n&&(n=!1,EF("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 QY=a(n=>!vF.has(n),"shouldWarn");var ta=a(n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),"isPosInt"),TF=a(n=>ta(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Gc:null:null,"getUintArray"),Gc=class extends Array{static{a(this,"ZeroArray")}constructor(e){super(e),this.fill(0)}},iE=class n{static{a(this,"Stack")}heap;length;static#e=!1;static create(e){let t=TF(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]}},zf=class n{static{a(this,"LRUCache")}#e;#n;#r;#t;#l;#_;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#u;#s;#c;#o;#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.#c,valList:e.#o,next:e.#p,prev:e.#g,get head(){return e.#d},get tail(){return e.#m},free:e.#y,isBackgroundFetch:a(t=>e.#h(t),"isBackgroundFetch"),backgroundFetch:a((t,r,i,s)=>e.#j(t,r,i,s),"backgroundFetch"),moveToTail:a(t=>e.#U(t),"moveToTail"),indexes:a(t=>e.#R(t),"indexes"),rindexes:a(t=>e.#C(t),"rindexes"),isStale:a(t=>e.#I(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.#l}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:o,updateAgeOnHas:l,allowStale:c,dispose:u,disposeAfter:f,noDisposeOnSet:d,noUpdateTTL:h,maxSize:p=0,maxEntrySize:g=0,sizeCalculation:_,fetchMethod:v,memoMethod:w,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:I,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:D,ignoreFetchAbort:K}=e;if(t!==0&&!ta(t))throw new TypeError("max option must be a nonnegative integer");let oe=t?TF(t):Array;if(!oe)throw new Error("invalid max value: "+t);if(this.#e=t,this.#n=p,this.maxEntrySize=g||this.#n,this.sizeCalculation=_,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.#l=v,this.#S=!!v,this.#s=new Map,this.#c=new Array(t).fill(void 0),this.#o=new Array(t).fill(void 0),this.#p=new oe(t),this.#g=new oe(t),this.#d=0,this.#m=0,this.#y=iE.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=!!E,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!K,this.maxEntrySize!==0){if(this.#n!==0&&!ta(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!ta(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!I,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=ta(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!ta(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 me="LRU_CACHE_UNBOUNDED";QY(me)&&(vF.add(me),EF("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",me,n))}}getRemainingTTL(e){return this.#s.has(e)?1/0:0}#x(){let e=new Gc(this.#e),t=new Gc(this.#e);this.#b=e,this.#T=t,this.#F=(s,o,l=Bc.now())=>{if(t[s]=o!==0?l:0,e[s]=o,o!==0&&this.ttlAutopurge){let c=setTimeout(()=>{this.#I(s)&&this.#O(this.#c[s],"expire")},o+1);c.unref&&c.unref()}},this.#A=s=>{t[s]=e[s]!==0?Bc.now():0},this.#a=(s,o)=>{if(e[o]){let l=e[o],c=t[o];if(!l||!c)return;s.ttl=l,s.start=c,s.now=r||i();let u=s.now-c;s.remainingTTL=l-u}};let r=0,i=a(()=>{let s=Bc.now();if(this.ttlResolution>0){r=s;let o=setTimeout(()=>r=0,this.ttlResolution);o.unref&&o.unref()}return s},"getNow");this.getRemainingTTL=s=>{let o=this.#s.get(s);if(o===void 0)return 0;let l=e[o],c=t[o];if(!l||!c)return 1/0;let u=(r||i())-c;return l-u},this.#I=s=>{let o=t[s],l=e[s];return!!l&&!!o&&(r||i())-o>l}}#A=a(()=>{},"#updateItemAge");#a=a(()=>{},"#statusTTL");#F=a(()=>{},"#setItemTTL");#I=a(()=>!1,"#isStale");#P(){let e=new Gc(this.#e);this.#u=0,this.#E=e,this.#D=t=>{this.#u-=e[t],e[t]=0},this.#N=(t,r,i,s)=>{if(this.#h(r))return 0;if(!ta(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!ta(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#L=(t,r,i)=>{if(e[t]=r,this.#n){let s=this.#n-e[t];for(;this.#u>s;)this.#M(!0)}this.#u+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#u)}}#D=a(e=>{},"#removeItemSize");#L=a((e,t,r)=>{},"#addItemSize");#N=a((e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#R({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#m;!(!this.#k(t)||((e||!this.#I(t))&&(yield t),t===this.#d));)t=this.#g[t]}*#C({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#d;!(!this.#k(t)||((e||!this.#I(t))&&(yield t),t===this.#m));)t=this.#p[t]}#k(e){return e!==void 0&&this.#s.get(this.#c[e])===e}*entries(){for(let e of this.#R())this.#o[e]!==void 0&&this.#c[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#c[e],this.#o[e]])}*rentries(){for(let e of this.#C())this.#o[e]!==void 0&&this.#c[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#c[e],this.#o[e]])}*keys(){for(let e of this.#R()){let t=this.#c[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*rkeys(){for(let e of this.#C()){let t=this.#c[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*values(){for(let e of this.#R())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#C())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#R()){let i=this.#o[r],s=this.#h(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#c[r],this))return this.get(this.#c[r],t)}}forEach(e,t=this){for(let r of this.#R()){let i=this.#o[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}rforEach(e,t=this){for(let r of this.#C()){let i=this.#o[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}purgeStale(){let e=!1;for(let t of this.#C({allowStale:!0}))this.#I(t)&&(this.#O(this.#c[t],"expire"),e=!0);return e}info(e){let t=this.#s.get(e);if(t===void 0)return;let r=this.#o[t],i=this.#h(r)?r.__staleWhileFetching:r;if(i===void 0)return;let s={value:i};if(this.#b&&this.#T){let o=this.#b[t],l=this.#T[t];if(o&&l){let c=o-(Bc.now()-l);s.ttl=c,s.start=Date.now()}}return this.#E&&(s.size=this.#E[t]),s}dump(){let e=[];for(let t of this.#R({allowStale:!0})){let r=this.#c[t],i=this.#o[t],s=this.#h(i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;let o={value:s};if(this.#b&&this.#T){o.ttl=this.#b[t];let l=Bc.now()-this.#T[t];o.start=Math.floor(Date.now()-l)}this.#E&&(o.size=this.#E[t]),e.unshift([r,o])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=Bc.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:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=r,{noUpdateTTL:u=this.noUpdateTTL}=r,f=this.#N(e,t,r.size||0,l);if(this.maxEntrySize&&f>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#O(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.#M(!1):this.#i,this.#c[d]=e,this.#o[d]=t,this.#s.set(e,d),this.#p[this.#m]=d,this.#g[d]=this.#m,this.#m=d,this.#i++,this.#L(d,f,c),c&&(c.set="add"),u=!1;else{this.#U(d);let h=this.#o[d];if(t!==h){if(this.#S&&this.#h(h)){h.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=h;p!==void 0&&!o&&(this.#v&&this.#r?.(p,e,"set"),this.#w&&this.#f?.push([p,e,"set"]))}else o||(this.#v&&this.#r?.(h,e,"set"),this.#w&&this.#f?.push([h,e,"set"]));if(this.#D(d),this.#L(d,f,c),this.#o[d]=t,c){c.set="replace";let p=h&&this.#h(h)?h.__staleWhileFetching:h;p!==void 0&&(c.oldValue=p)}}else c&&(c.set="update")}if(i!==0&&!this.#b&&this.#x(),this.#b&&(u||this.#F(d,i,s),c&&this.#a(c,d)),!o&&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.#o[this.#d];if(this.#M(!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)}}}#M(e){let t=this.#d,r=this.#c[t],i=this.#o[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.#c[t]=void 0,this.#o[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 o=this.#o[s];if(this.#h(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#I(s))i&&(i.has="stale",this.#a(i,s));else return r&&this.#A(s),i&&(i.has="hit",this.#a(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.#I(i))return;let s=this.#o[i];return this.#h(s)?s.__staleWhileFetching:s}#j(e,t,r,i){let s=t===void 0?void 0:this.#o[t];if(this.#h(s))return s;let o=new Rg,{signal:l}=r;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let c={signal:o.signal,options:r,context:i},u=a((_,v=!1)=>{let{aborted:w}=o.signal,E=r.ignoreFetchAbort&&_!==void 0;if(r.status&&(w&&!v?(r.status.fetchAborted=!0,r.status.fetchError=o.signal.reason,E&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),w&&!E&&!v)return d(o.signal.reason);let I=p;return this.#o[t]===p&&(_===void 0?I.__staleWhileFetching?this.#o[t]=I.__staleWhileFetching:this.#O(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,_,c.options))),_},"cb"),f=a(_=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=_),d(_)),"eb"),d=a(_=>{let{aborted:v}=o.signal,w=v&&r.allowStaleOnFetchAbort,E=w||r.allowStaleOnFetchRejection,I=E||r.noDeleteOnFetchRejection,A=p;if(this.#o[t]===p&&(!I||A.__staleWhileFetching===void 0?this.#O(e,"fetch"):w||(this.#o[t]=A.__staleWhileFetching)),E)return r.status&&A.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),A.__staleWhileFetching;if(A.__returned===A)throw _},"fetchFail"),h=a((_,v)=>{let w=this.#l?.(e,s,c);w&&w instanceof Promise&&w.then(E=>_(E===void 0?void 0:E),v),o.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(_(void 0),r.allowStaleOnFetchAbort&&(_=a(E=>u(E,!0),"res")))})},"pcall");r.status&&(r.status.fetchDispatched=!0);let p=new Promise(h).then(u,f),g=Object.assign(p,{__abortController:o,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,g,{...c.options,status:void 0}),t=this.#s.get(e)):this.#o[t]=g,g}#h(e){if(!this.#S)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Rg}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:_,forceRefresh:v=!1,status:w,signal:E}=t;if(!this.#S)return w&&(w.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:w});let I={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:o,noDisposeOnSet:l,size:c,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:g,ignoreFetchAbort:p,status:w,signal:E},A=this.#s.get(e);if(A===void 0){w&&(w.fetch="miss");let D=this.#j(e,A,I,_);return D.__returned=D}else{let D=this.#o[A];if(this.#h(D)){let Q=r&&D.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",Q&&(w.returnedStale=!0)),Q?D.__staleWhileFetching:D.__returned=D}let K=this.#I(A);if(!v&&!K)return w&&(w.fetch="hit"),this.#U(A),i&&this.#A(A),w&&this.#a(w,A),D;let oe=this.#j(e,A,I,_),N=oe.__staleWhileFetching!==void 0&&r;return w&&(w.fetch=K?"stale":"refresh",N&&K&&(w.returnedStale=!0)),N?oe.__staleWhileFetching:oe.__returned=oe}}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,...o}=t,l=this.get(e,o);if(!s&&l!==void 0)return l;let c=r(e,l,{options:o,context:i});return this.set(e,c,o),c}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:o}=t,l=this.#s.get(e);if(l!==void 0){let c=this.#o[l],u=this.#h(c);return o&&this.#a(o,l),this.#I(l)?(o&&(o.get="stale"),u?(o&&r&&c.__staleWhileFetching!==void 0&&(o.returnedStale=!0),r?c.__staleWhileFetching:void 0):(s||this.#O(e,"expire"),o&&r&&(o.returnedStale=!0),r?c:void 0)):(o&&(o.get="hit"),u?c.__staleWhileFetching:(this.#U(l),i&&this.#A(l),c))}else o&&(o.get="miss")}#$(e,t){this.#g[t]=e,this.#p[e]=t}#U(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.#O(e,"delete")}#O(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.#V(t);else{this.#D(i);let s=this.#o[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.#c[i]=void 0,this.#o[i]=void 0,i===this.#m)this.#m=this.#g[i];else if(i===this.#d)this.#d=this.#p[i];else{let o=this.#g[i];this.#p[o]=this.#p[i];let l=this.#p[i];this.#g[l]=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.#V("delete")}#V(e){for(let t of this.#C({allowStale:!0})){let r=this.#o[t];if(this.#h(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#c[t];this.#v&&this.#r?.(r,i,e),this.#w&&this.#f?.push([r,i,e])}}if(this.#s.clear(),this.#o.fill(void 0),this.#c.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 zc=require("node:path"),LF=require("node:url"),Ts=require("fs"),iX=Z(require("node:fs"),1),ia=require("node:fs/promises");var Ng=require("node:events"),fE=Z(require("node:stream"),1),CF=require("node:string_decoder");var IF=typeof process=="object"&&process?process:{stdout:null,stderr:null},YY=a(n=>!!n&&typeof n=="object"&&(n instanceof na||n instanceof fE.default||XY(n)||KY(n)),"isStream"),XY=a(n=>!!n&&typeof n=="object"&&n instanceof Ng.EventEmitter&&typeof n.pipe=="function"&&n.pipe!==fE.default.Writable.prototype.pipe,"isReadable"),KY=a(n=>!!n&&typeof n=="object"&&n instanceof Ng.EventEmitter&&typeof n.write=="function"&&typeof n.end=="function","isWritable"),yo=Symbol("EOF"),_o=Symbol("maybeEmitEnd"),ra=Symbol("emittedEnd"),Cg=Symbol("emittingEnd"),Hf=Symbol("emittedError"),Pg=Symbol("closed"),xF=Symbol("read"),Og=Symbol("flush"),AF=Symbol("flushChunk"),Bi=Symbol("encoding"),qc=Symbol("decoder"),Ir=Symbol("flowing"),Qf=Symbol("paused"),Wc=Symbol("resume"),xr=Symbol("buffer"),bn=Symbol("pipes"),Ar=Symbol("bufferLength"),sE=Symbol("bufferPush"),Fg=Symbol("bufferShift"),Zr=Symbol("objectMode"),Xt=Symbol("destroyed"),oE=Symbol("error"),aE=Symbol("emitData"),RF=Symbol("emitEnd"),lE=Symbol("emitEnd2"),vs=Symbol("async"),cE=Symbol("abort"),Dg=Symbol("aborted"),Yf=Symbol("signal"),rl=Symbol("dataListeners"),Hn=Symbol("discarded"),Xf=a(n=>Promise.resolve().then(n),"defer"),JY=a(n=>n(),"nodefer"),ZY=a(n=>n==="end"||n==="finish"||n==="prefinish","isEndish"),eX=a(n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,"isArrayBufferLike"),tX=a(n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),"isArrayBufferView"),Lg=class{static{a(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[Wc](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},uE=class extends Lg{static{a(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)}},rX=a(n=>!!n.objectMode,"isObjectModeOptions"),nX=a(n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer","isEncodingOptions"),na=class extends Ng.EventEmitter{static{a(this,"Minipass")}[Ir]=!1;[Qf]=!1;[bn]=[];[xr]=[];[Zr];[Bi];[vs];[qc];[yo]=!1;[ra]=!1;[Cg]=!1;[Pg]=!1;[Hf]=null;[Ar]=0;[Xt]=!1;[Yf];[Dg]=!1;[rl]=0;[Hn]=!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");rX(t)?(this[Zr]=!0,this[Bi]=null):nX(t)?(this[Bi]=t.encoding,this[Zr]=!1):(this[Zr]=!1,this[Bi]=null),this[vs]=!!t.async,this[qc]=this[Bi]?new CF.StringDecoder(this[Bi]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:a(()=>this[xr],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:a(()=>this[bn],"get")});let{signal:r}=t;r&&(this[Yf]=r,r.aborted?this[cE]():r.addEventListener("abort",()=>this[cE]()))}get bufferLength(){return this[Ar]}get encoding(){return this[Bi]}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[Zr]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vs]}set async(e){this[vs]=this[vs]||!!e}[cE](){this[Dg]=!0,this.emit("abort",this[Yf]?.reason),this.destroy(this[Yf]?.reason)}get aborted(){return this[Dg]}set aborted(e){}write(e,t,r){if(this[Dg])return!1;if(this[yo])throw new Error("write after end");if(this[Xt])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[vs]?Xf:JY;if(!this[Zr]&&!Buffer.isBuffer(e)){if(tX(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(eX(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Zr]?(this[Ir]&&this[Ar]!==0&&this[Og](!0),this[Ir]?this.emit("data",e):this[sE](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Ir]):e.length?(typeof e=="string"&&!(t===this[Bi]&&!this[qc]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Bi]&&(e=this[qc].write(e)),this[Ir]&&this[Ar]!==0&&this[Og](!0),this[Ir]?this.emit("data",e):this[sE](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Ir]):(this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Ir])}read(e){if(this[Xt])return null;if(this[Hn]=!1,this[Ar]===0||e===0||e&&e>this[Ar])return this[_o](),null;this[Zr]&&(e=null),this[xr].length>1&&!this[Zr]&&(this[xr]=[this[Bi]?this[xr].join(""):Buffer.concat(this[xr],this[Ar])]);let t=this[xF](e||null,this[xr][0]);return this[_o](),t}[xF](e,t){if(this[Zr])this[Fg]();else{let r=t;e===r.length||e===null?this[Fg]():typeof r=="string"?(this[xr][0]=r.slice(e),t=r.slice(0,e),this[Ar]-=e):(this[xr][0]=r.subarray(e),t=r.subarray(0,e),this[Ar]-=e)}return this.emit("data",t),!this[xr].length&&!this[yo]&&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[yo]=!0,this.writable=!1,(this[Ir]||!this[Qf])&&this[_o](),this}[Wc](){this[Xt]||(!this[rl]&&!this[bn].length&&(this[Hn]=!0),this[Qf]=!1,this[Ir]=!0,this.emit("resume"),this[xr].length?this[Og]():this[yo]?this[_o]():this.emit("drain"))}resume(){return this[Wc]()}pause(){this[Ir]=!1,this[Qf]=!0,this[Hn]=!1}get destroyed(){return this[Xt]}get flowing(){return this[Ir]}get paused(){return this[Qf]}[sE](e){this[Zr]?this[Ar]+=1:this[Ar]+=e.length,this[xr].push(e)}[Fg](){return this[Zr]?this[Ar]-=1:this[Ar]-=this[xr][0].length,this[xr].shift()}[Og](e=!1){do;while(this[AF](this[Fg]())&&this[xr].length);!e&&!this[xr].length&&!this[yo]&&this.emit("drain")}[AF](e){return this.emit("data",e),this[Ir]}pipe(e,t){if(this[Xt])return e;this[Hn]=!1;let r=this[ra];return t=t||{},e===IF.stdout||e===IF.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[bn].push(t.proxyErrors?new uE(this,e,t):new Lg(this,e,t)),this[vs]?Xf(()=>this[Wc]()):this[Wc]()),e}unpipe(e){let t=this[bn].find(r=>r.dest===e);t&&(this[bn].length===1?(this[Ir]&&this[rl]===0&&(this[Ir]=!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[Hn]=!1,this[rl]++,!this[bn].length&&!this[Ir]&&this[Wc]();else if(e==="readable"&&this[Ar]!==0)super.emit("readable");else if(ZY(e)&&this[ra])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Hf]){let i=t;this[vs]?Xf(()=>i.call(this,this[Hf])):i.call(this,this[Hf])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[rl]=this.listeners("data").length,this[rl]===0&&!this[Hn]&&!this[bn].length&&(this[Ir]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[rl]=0,!this[Hn]&&!this[bn].length&&(this[Ir]=!1)),t}get emittedEnd(){return this[ra]}[_o](){!this[Cg]&&!this[ra]&&!this[Xt]&&this[xr].length===0&&this[yo]&&(this[Cg]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Pg]&&this.emit("close"),this[Cg]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==Xt&&this[Xt])return!1;if(e==="data")return!this[Zr]&&!r?!1:this[vs]?(Xf(()=>this[aE](r)),!0):this[aE](r);if(e==="end")return this[RF]();if(e==="close"){if(this[Pg]=!0,!this[ra]&&!this[Xt])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[Hf]=r,super.emit(oE,r);let s=!this[Yf]||this.listeners("error").length?super.emit("error",r):!1;return this[_o](),s}else if(e==="resume"){let s=super.emit("resume");return this[_o](),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[_o](),i}[aE](e){for(let r of this[bn])r.dest.write(e)===!1&&this.pause();let t=this[Hn]?!1:super.emit("data",e);return this[_o](),t}[RF](){return this[ra]?!1:(this[ra]=!0,this.readable=!1,this[vs]?(Xf(()=>this[lE]()),!0):this[lE]())}[lE](){if(this[qc]){let t=this[qc].end();if(t){for(let r of this[bn])r.dest.write(t);this[Hn]||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[Zr]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[Zr]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[Zr])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Bi]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(Xt,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Hn]=!1;let e=!1,t=a(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:a(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[yo])return t();let s,o,l=a(d=>{this.off("data",c),this.off("end",u),this.off(Xt,f),t(),o(d)},"onerr"),c=a(d=>{this.off("error",l),this.off("end",u),this.off(Xt,f),this.pause(),s({value:d,done:!!this[yo]})},"ondata"),u=a(()=>{this.off("error",l),this.off("data",c),this.off(Xt,f),t(),s({done:!0,value:void 0})},"onend"),f=a(()=>l(new Error("stream destroyed")),"ondestroy");return new Promise((d,h)=>{o=h,s=d,this.once(Xt,f),this.once("error",l),this.once("end",u),this.once("data",c)})},"next"),throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Hn]=!1;let e=!1,t=a(()=>(this.pause(),this.off(oE,t),this.off(Xt,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),r=a(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(oE,t),this.once(Xt,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[Xt])return e?this.emit("error",e):this.emit(Xt),this;this[Xt]=!0,this[Hn]=!0,this[xr].length=0,this[Ar]=0;let t=this;return typeof t.close=="function"&&!this[Pg]&&t.close(),e?this.emit("error",e):this.emit(Xt),this}static get isStream(){return YY}};var sX=Ts.realpathSync.native,Jf={lstatSync:Ts.lstatSync,readdir:Ts.readdir,readdirSync:Ts.readdirSync,readlinkSync:Ts.readlinkSync,realpathSync:sX,promises:{lstat:ia.lstat,readdir:ia.readdir,readlink:ia.readlink,realpath:ia.realpath}},NF=a(n=>!n||n===Jf||n===iX?Jf:{...Jf,...n,promises:{...Jf.promises,...n.promises||{}}},"fsFromOption"),kF=/^\\\\\?\\([a-z]:)\\?$/i,oX=a(n=>n.replace(/\//g,"\\").replace(kF,"$1\\"),"uncToDrive"),aX=/[\\\/]/,ui=0,MF=1,jF=2,Es=4,$F=6,UF=8,nl=10,VF=12,ci=15,Kf=~ci,dE=16,PF=32,Zf=64,Gi=128,kg=256,jg=512,OF=Zf|Gi|jg,lX=1023,hE=a(n=>n.isFile()?UF:n.isDirectory()?Es:n.isSymbolicLink()?nl:n.isCharacterDevice()?jF:n.isBlockDevice()?$F:n.isSocket()?VF:n.isFIFO()?MF:ui,"entToType"),FF=new Map,ed=a(n=>{let e=FF.get(n);if(e)return e;let t=n.normalize("NFKD");return FF.set(n,t),t},"normalize"),DF=new Map,Mg=a(n=>{let e=DF.get(n);if(e)return e;let t=ed(n.toLowerCase());return DF.set(n,t),t},"normalizeNocase"),$g=class extends zf{static{a(this,"ResolveCache")}constructor(){super({max:256})}},pE=class extends zf{static{a(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:a(t=>t.length+1,"sizeCalculation")})}},BF=Symbol("PathScurry setAsCwd"),en=class{static{a(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}#l;get uid(){return this.#l}#_;get gid(){return this.#_}#i;get rdev(){return this.#i}#u;get blksize(){return this.#u}#s;get ino(){return this.#s}#c;get size(){return this.#c}#o;get blocks(){return this.#o}#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;#A;#a;#F;#I;#P;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=ui,r,i,s,o,l){this.name=e,this.#b=s?Mg(e):ed(e),this.#a=t&lX,this.nocase=s,this.roots=i,this.root=r||this,this.#F=o,this.#S=l.fullpath,this.#x=l.relative,this.#A=l.relativePosix,this.parent=l.parent,this.parent?this.#e=this.parent.#e:this.#e=NF(l.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.#a&=~dE,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?Mg(e):ed(e);for(let c of r)if(c.#b===i)return c;let s=this.parent?this.sep:"",o=this.#S?this.#S+s+e:void 0,l=this.newChild(e,ui,{...t,parent:this,fullpath:o});return this.canReaddir()||(l.#a|=Gi),r.push(l),l}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.#A!==void 0)return this.#A;let e=this.name,t=this.parent;if(!t)return this.#A=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.#a&ci)===ui}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.#a&ci)===UF}isDirectory(){return(this.#a&ci)===Es}isCharacterDevice(){return(this.#a&ci)===jF}isBlockDevice(){return(this.#a&ci)===$F}isFIFO(){return(this.#a&ci)===MF}isSocket(){return(this.#a&ci)===VF}isSymbolicLink(){return(this.#a&nl)===nl}lstatCached(){return this.#a&PF?this:void 0}readlinkCached(){return this.#I}realpathCached(){return this.#P}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#I)return!0;if(!this.parent)return!1;let e=this.#a&ci;return!(e!==ui&&e!==nl||this.#a&kg||this.#a&Gi)}calledReaddir(){return!!(this.#a&dE)}isENOENT(){return!!(this.#a&Gi)}isNamed(e){return this.nocase?this.#b===Mg(e):this.#b===ed(e)}async readlink(){let e=this.#I;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.#I=r}catch(t){this.#h(t.code);return}}readlinkSync(){let e=this.#I;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.#I=r}catch(t){this.#h(t.code);return}}#L(e){this.#a|=dE;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#N()}}#N(){this.#a&Gi||(this.#a=(this.#a|Gi)&Kf,this.#R())}#R(){let e=this.children();e.provisional=0;for(let t of e)t.#N()}#C(){this.#a|=jg,this.#k()}#k(){if(this.#a&Zf)return;let e=this.#a;(e&ci)===Es&&(e&=Kf),this.#a=e|Zf,this.#R()}#M(e=""){e==="ENOTDIR"||e==="EPERM"?this.#k():e==="ENOENT"?this.#N():this.children().provisional=0}#j(e=""){e==="ENOTDIR"?this.parent.#k():e==="ENOENT"&&this.#N()}#h(e=""){let t=this.#a;t|=kg,e==="ENOENT"&&(t|=Gi),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Kf),this.#a=t,e==="ENOTDIR"&&this.parent&&this.parent.#k()}#$(e,t){return this.#O(e,t)||this.#U(e,t)}#U(e,t){let r=hE(e),i=this.newChild(e.name,r,{parent:this}),s=i.#a&ci;return s!==Es&&s!==nl&&s!==ui&&(i.#a|=Zf),t.unshift(i),t.provisional++,i}#O(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?Mg(e.name):ed(e.name))===i.#b)return this.#V(e,i,r,t)}}#V(e,t,r,i){let s=t.name;return t.#a=t.#a&Kf|hE(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.#a&Gi)===0)try{return this.#W(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#j(e.code)}}lstatSync(){if((this.#a&Gi)===0)try{return this.#W(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#j(e.code)}}#W(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:s,blksize:o,blocks:l,ctime:c,ctimeMs:u,dev:f,gid:d,ino:h,mode:p,mtime:g,mtimeMs:_,nlink:v,rdev:w,size:E,uid:I}=e;this.#y=t,this.#p=r,this.#T=i,this.#m=s,this.#u=o,this.#o=l,this.#E=c,this.#d=u,this.#n=f,this.#_=d,this.#s=h,this.#r=p,this.#f=g,this.#g=_,this.#t=v,this.#i=w,this.#c=E,this.#l=I;let A=hE(e);this.#a=this.#a&Kf|A|PF,A!==ui&&A!==Es&&A!==nl&&(this.#a|=Zf)}#G=[];#q=!1;#z(e){this.#q=!1;let t=this.#G.slice();this.#G.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.#G.push(e),this.#q)return;this.#q=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,o)=>{if(s)this.#M(s.code),r.provisional=0;else{for(let l of o)this.#$(l,r);this.#L(r)}this.#z(r.slice(0,r.provisional))})}#B;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.#B)await this.#B;else{let r=a(()=>{},"resolve");this.#B=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#$(i,e);this.#L(e)}catch(i){this.#M(i.code),e.provisional=0}this.#B=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.#L(e)}catch(r){this.#M(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#a&OF)return!1;let e=ci&this.#a;return e===ui||e===Es||e===nl}shouldWalk(e,t){return(this.#a&Es)===Es&&!(this.#a&OF)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#P)return this.#P;if(!((jg|kg|Gi)&this.#a))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#P=this.resolve(e)}catch{this.#C()}}realpathSync(){if(this.#P)return this.#P;if(!((jg|kg|Gi)&this.#a))try{let e=this.#e.realpathSync(this.fullpath());return this.#P=this.resolve(e)}catch{this.#C()}}[BF](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.#A=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#x=void 0,i.#A=void 0,i=i.parent}},Ug=class n extends en{static{a(this,"PathWin32")}sep="\\";splitSep=aX;constructor(e,t=ui,r,i,s,o,l){super(e,t,r,i,s,o,l)}newChild(e,t=ui,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return zc.win32.parse(e).root}getRoot(e){if(e=oX(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 Hc(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(kF,"$1\\"),e===t}},Vg=class n extends en{static{a(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=ui,r,i,s,o,l){super(e,t,r,i,s,o,l)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=ui,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Bg=class{static{a(this,"PathScurryBase")}root;rootPath;roots;cwd;#e;#n;#r;nocase;#t;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:s=16*1024,fs:o=Jf}={}){this.#t=NF(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,LF.fileURLToPath)(e));let l=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(l),this.#e=new $g,this.#n=new $g,this.#r=new pE(s);let c=l.substring(this.rootPath.length).split(r);if(c.length===1&&!c[0]&&c.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=c.length-1,d=t.sep,h=this.rootPath,p=!1;for(let g of c){let _=f--;u=u.child(g,{relative:new Array(_).fill("..").join(d),relativePosix:new Array(_).fill("..").join("/"),fullpath:h+=(p?"":d)+g}),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 o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))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 o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))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 en||(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 en||(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 en||(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 en||(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 en||(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 en||(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 en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=[];(!s||s(e))&&l.push(r?e:e.fullpath());let c=new Set,u=a((d,h)=>{c.add(d),d.readdirCB((p,g)=>{if(p)return h(p);let _=g.length;if(!_)return h();let v=a(()=>{--_===0&&h()},"next");for(let w of g)(!s||s(w))&&l.push(r?w:w.fullpath()),i&&w.isSymbolicLink()?w.realpath().then(E=>E?.isUnknown()?E.lstat():E).then(E=>E?.shouldWalk(c,o)?u(E,v):v()):w.shouldWalk(c,o)?u(w,v):v()},!0)},"walk"),f=e;return new Promise((d,h)=>{u(f,p=>{if(p)return h(p);d(l)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=[];(!s||s(e))&&l.push(r?e:e.fullpath());let c=new Set([e]);for(let u of c){let f=u.readdirSync();for(let d of f){(!s||s(d))&&l.push(r?d:d.fullpath());let h=d;if(d.isSymbolicLink()){if(!(i&&(h=d.realpathSync())))continue;h.isUnknown()&&h.lstatSync()}h.shouldWalk(c,o)&&c.add(h)}}return l}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(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 en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t;(!s||s(e))&&(yield r?e:e.fullpath());let l=new Set([e]);for(let c of l){let u=c.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(l,o)&&l.add(d)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=new na({objectMode:!0});(!s||s(e))&&l.write(r?e:e.fullpath());let c=new Set,u=[e],f=0,d=a(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&l.end();return}f++,c.add(p);let g=a((v,w,E=!1)=>{if(v)return l.emit("error",v);if(i&&!E){let I=[];for(let A of w)A.isSymbolicLink()&&I.push(A.realpath().then(D=>D?.isUnknown()?D.lstat():D));if(I.length){Promise.all(I).then(()=>g(null,w,!0));return}}for(let I of w)I&&(!s||s(I))&&(l.write(r?I:I.fullpath())||(h=!0));f--;for(let I of w){let A=I.realpathCached()||I;A.shouldWalk(c,o)&&u.push(A)}h&&!l.flowing?l.once("drain",d):_||d()},"onReaddir"),_=!0;p.readdirCB(g,!0),_=!1}},"process");return d(),l}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=new na({objectMode:!0}),c=new Set;(!s||s(e))&&l.write(r?e:e.fullpath());let u=[e],f=0,d=a(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&l.end();return}f++,c.add(p);let g=p.readdirSync();for(let _ of g)(!s||s(_))&&(l.write(r?_:_.fullpath())||(h=!0));f--;for(let _ of g){let v=_;if(_.isSymbolicLink()){if(!(i&&(v=_.realpathSync())))continue;v.isUnknown()&&v.lstatSync()}v.shouldWalk(c,o)&&u.push(v)}}h&&!l.flowing&&l.once("drain",d)},"process");return d(),l}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[BF](t)}},Hc=class extends Bg{static{a(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,zc.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return zc.win32.parse(e).root.toUpperCase()}newRoot(e){return new Ug(this.rootPath,Es,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Qc=class extends Bg{static{a(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,zc.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new Vg(this.rootPath,Es,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},td=class extends Qc{static{a(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},phe=process.platform==="win32"?Ug:Vg,GF=process.platform==="win32"?Hc:process.platform==="darwin"?td:Qc;var cX=a(n=>n.length>=1,"isPatternList"),uX=a(n=>n.length>=1,"isGlobList"),Yc=class n{static{a(this,"Pattern")}#e;#n;#r;length;#t;#l;#_;#i;#u;#s;#c=!0;constructor(e,t,r,i){if(!cX(e))throw new TypeError("empty pattern list");if(!uX(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,o,l,c,...u]=this.#e,[f,d,h,p,...g]=this.#n;u[0]===""&&(u.shift(),g.shift());let _=[s,o,l,c,""].join("/"),v=[f,d,h,p,""].join("/");this.#e=[_,...u],this.#n=[v,...g],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...o]=this.#e,[l,...c]=this.#n;o[0]===""&&(o.shift(),c.shift());let u=s+"/",f=l+"/";this.#e=[u,...o],this.#n=[f,...c],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]===Yt}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.#l!==void 0?this.#l:this.hasMore()?(this.#l=new n(this.#e,this.#n,this.#r+1,this.#t),this.#l.#s=this.#s,this.#l.#u=this.#u,this.#l.#i=this.#i,this.#l):this.#l=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.#c)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var fX=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Xc=class{static{a(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:s,platform:o=fX}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:s,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let l of e)this.add(l)}add(e){let t=new zn(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 o=new Yc(i,s,0,this.platform),l=new zn(o.globString(),this.mmopts),c=s[s.length-1]==="**",u=o.isAbsolute();u?this.absolute.push(l):this.relative.push(l),c&&(u?this.absoluteChildren.push(l):this.relativeChildren.push(l))}}ignored(e){let t=e.fullpath(),r=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(s))return!0;for(let o of this.absolute)if(o.match(t)||o.match(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 mE=class n{static{a(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()]))}},gE=class{static{a(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)])}},yE=class{static{a(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())}},rd=class n{static{a(this,"Processor")}hasWalkedCache;matches=new gE;subwalks=new yE;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new mE}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 o=s.root(),l=s.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let d=s.rest();if(d)s=d;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,u,f=!1;for(;typeof(c=s.pattern())=="string"&&(u=s.rest());)i=i.resolve(c),s=u,f=!0;if(c=s.pattern(),u=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof c=="string"){let d=c===".."||c===""||c===".";this.matches.add(i.resolve(c),l,d);continue}else if(c===Yt){(!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,l,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,l,!0)}}else c 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 o of r){let l=o.isAbsolute(),c=o.pattern(),u=o.rest();c===Yt?i.testGlobstar(s,o,u,l):c instanceof RegExp?i.testRegExp(s,c,u,l):i.testString(s,c,u,l)}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 o=e.parent||e;this.subwalks.add(o,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 dX=a((n,e)=>typeof n=="string"?new Xc([n],e):Array.isArray(n)?new Xc(n,e):n,"makeIgnore"),Gg=class{static{a(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=dX(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)}#l(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 o=await s.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(s,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#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 o=s.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.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(),o=this.opts.dotRelative&&!s.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(s?o+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 rd(this.opts),r)}walkCB2(e,t,r,i){if(this.#l(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,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||(s++,this.match(l,c,u).then(()=>o()));for(let l of r.subwalkTargets()){if(this.maxDepth!==1/0&&l.depth()>=this.maxDepth)continue;s++;let c=l.readdirCached();l.calledReaddir()?this.walkCB3(l,c,r,o):l.readdirCB((u,f)=>this.walkCB3(l,f,r,o),!0)}o()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||(s++,this.match(l,c,u).then(()=>o()));for(let[l,c]of r.subwalks.entries())s++,this.walkCB2(l,c,r.child(),o);o()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new rd(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#l(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,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||this.matchSync(l,c,u);for(let l of r.subwalkTargets()){if(this.maxDepth!==1/0&&l.depth()>=this.maxDepth)continue;s++;let c=l.readdirSync();this.walkCB3Sync(l,c,r,o)}o()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||this.matchSync(l,c,u);for(let[l,c]of r.subwalks.entries())s++,this.walkCB2Sync(l,c,r.child(),o);o()}},nd=class extends Gg{static{a(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}},id=class extends Gg{static{a(this,"GlobStream")}results;constructor(e,t,r){super(e,t,r),this.results=new na({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 hX=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",qi=class{static{a(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,qF.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(c=>c.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=e,this.platform=t.platform||hX,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 c=t.platform==="win32"?Hc:t.platform==="darwin"?td:t.platform?Qc:GF;this.scurry=new c(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(c=>new zn(c,i)),[o,l]=s.reduce((c,u)=>(c[0].push(...u.set),c[1].push(...u.globParts),c),[[],[]]);this.patterns=o.map((c,u)=>{let f=l[u];if(!f)throw new Error("invalid pattern object");return new Yc(c,f,0,this.platform)})}async walk(){return[...await new nd(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 nd(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 id(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 id(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 _E=a((n,e={})=>{Array.isArray(n)||(n=[n]);for(let t of n)if(new zn(t,e).hasMagic())return!0;return!1},"hasMagic");function qg(n,e={}){return new qi(n,e).streamSync()}a(qg,"globStreamSync");function zF(n,e={}){return new qi(n,e).stream()}a(zF,"globStream");function HF(n,e={}){return new qi(n,e).walkSync()}a(HF,"globSync");async function WF(n,e={}){return new qi(n,e).walk()}a(WF,"glob_");function Wg(n,e={}){return new qi(n,e).iterateSync()}a(Wg,"globIterateSync");function QF(n,e={}){return new qi(n,e).iterate()}a(QF,"globIterate");var pX=qg,mX=Object.assign(zF,{sync:qg}),gX=Wg,yX=Object.assign(QF,{sync:Wg}),_X=Object.assign(HF,{stream:qg,iterate:Wg}),Kc=Object.assign(WF,{glob:WF,globSync:HF,sync:_X,globStream:zF,stream:mX,globStreamSync:qg,streamSync:pX,globIterate:QF,iterate:yX,globIterateSync:Wg,iterateSync:gX,Glob:qi,hasMagic:_E,escape:Vc,unescape:Vi});Kc.glob=Kc;async function XF(n,e,t,r={}){let{dryRun:i=!1,excludeRelPath:s}=r,o=il.default.join(n,"**/*.md"),l=await Kc(o,{nodir:!0,ignore:[il.default.join(n,".obsidian/**"),il.default.join(n,".trash/**"),il.default.join(n,"**/.obsidian/**"),il.default.join(n,"**/.trash/**")]}),c={filesScanned:0,filesModified:0,replacements:0,modifiedFiles:[]};for(let u of l){let f=il.default.relative(n,u);if(s&&f===s)continue;c.filesScanned+=1;let d;try{d=await bE.default.readFile(u,"utf-8")}catch{continue}let{updated:h,replacements:p}=bX(d,e,t);p>0&&(c.filesModified+=1,c.replacements+=p,c.modifiedFiles.push(f),i||await bE.default.writeFile(u,h,"utf-8"))}return c}a(XF,"rewriteInboundWikilinks");function bX(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 o=r[s],l=SX(o,e,t);i+=l.replacements,r[s]=l.updated}return{updated:r.join(""),replacements:i}}a(bX,"rewriteContent");function SX(n,e,t){let r=n.split(/(`[^`\n]*`)/),i=0;for(let s=0;s<r.length;s++){if(s%2===1)continue;let o=wX(r[s],e,t);i+=o.replacements,r[s]=o.updated}return{updated:r.join(""),replacements:i}}a(SX,"rewriteProseSegment");function wX(n,e,t){let r=/(?<!!)\[\[([^\[\]\n|#^]+)((?:[#^][^\[\]\n|]*)?)(?:\|[^\[\]\n]*)?\]\]/g,i=0;return{updated:n.replace(r,(o,l,c)=>l.trim()!==e?o:(i+=1,`[[${t}${c}]]`)),replacements:i}}a(wX,"replaceWikilinks");var vX=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,xt=class{constructor(e,t={}){this.rootPath=e;this.uuidIndex=null;this.basenameIndex=null;this.aliasIndex=null;this.siblingAdapters=t.siblingAdapters??[],this.subjectIriPrefix=t.subjectIriPrefix??""}static{a(this,"FileSystemVaultAdapter")}getSubjectIriPrefix(){return this.subjectIriPrefix}async read(e){let t=this.resolvePath(e.path);if(!await lr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);return lr.default.readFile(t,"utf-8")}async create(e,t){let r=this.resolvePath(e);if(await lr.default.pathExists(r))throw new Error(`File already exists: ${e}`);return await lr.default.ensureDir(Rt.default.dirname(r)),await lr.default.writeFile(r,t,"utf-8"),this.createFileObject(e)}async modify(e,t){let r=this.resolvePath(e.path);if(!await lr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await lr.default.writeFile(r,t,"utf-8")}async delete(e){let t=this.resolvePath(e.path);if(!await lr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);await lr.default.remove(t)}async exists(e){let t=this.resolvePath(e);return lr.default.pathExists(t)}getAbstractFileByPath(e){let t=this.resolvePath(e);try{let r=lr.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=Rt.default.relative(this.rootPath,t);e.push(this.createFileObject(r))}}),e}getFrontmatter(e){try{let t=lr.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),o=this.replaceFrontmatter(r,s);await this.modify(e,o)}async rename(e,t){let r=this.resolvePath(e.path),i=this.resolvePath(t);if(!await lr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await lr.default.ensureDir(Rt.default.dirname(i)),await lr.default.move(r,i)}async createFolder(e){let t=this.resolvePath(e);await lr.default.ensureDir(t)}getFirstLinkpathDest(e,t){let r=e.split("|")[0].trim();if(!r)return null;if(vX.test(r)){this.uuidIndex===null&&this.buildUuidIndex();let u=r.toLowerCase(),f=this.uuidIndex.get(u);return f?this.createFileObject(f):null}let i=Rt.default.dirname(this.resolvePath(t)),s;if(Rt.default.isAbsolute(r)?s=this.resolvePath(r):s=Rt.default.resolve(i,r),r.endsWith(".md")||(s+=".md"),lr.default.existsSync(s)){let u=Rt.default.relative(this.rootPath,s);return this.createFileObject(u)}(this.basenameIndex===null||this.aliasIndex===null)&&this.buildLinkpathIndex();let o=r.toLowerCase(),l=this.basenameIndex.get(o);if(l)return this.createFileObject(l);let c=this.aliasIndex.get(o);if(c)return this.createFileObject(c);for(let u of this.siblingAdapters){let f=u.getSubjectIriPrefix();if(!f)continue;let d=u.getFirstLinkpathDest(r,"");if(d){let h=`${f}/${d.path}`;return this.createCrossVaultFileObject(h)}}return null}createCrossVaultFileObject(e){let t=Rt.default.basename(e),r=Rt.default.basename(e,Rt.default.extname(e)),i=Rt.default.dirname(e);return{path:e,basename:r,name:t,parent:i!=="."?{path:i,name:Rt.default.basename(i)}:null}}buildLinkpathIndex(){this.basenameIndex=new Map,this.aliasIndex=new Map,this.walkDirectory(this.rootPath,e=>{if(!e.endsWith(".md"))return;let t=Rt.default.relative(this.rootPath,e),r=Rt.default.basename(e,".md").toLowerCase();this.basenameIndex.has(r)||this.basenameIndex.set(r,t);let i;try{i=lr.default.readFileSync(e,"utf-8")}catch{return}let s=this.extractFrontmatter(i);if(!s)return;let o=s.aliases,l=Array.isArray(o)?o:typeof o=="string"?[o]:[];for(let c of l){if(typeof c!="string")continue;let u=c.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=Rt.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=Rt.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=Rt.default.basename(t,".md");await XF(this.rootPath,r,i,{excludeRelPath:e})}resolvePath(e){return Rt.default.isAbsolute(e)?e:Rt.default.join(this.rootPath,e)}createFileObject(e){let t=Rt.default.basename(e),r=Rt.default.basename(e,Rt.default.extname(e)),i=Rt.default.dirname(e);return{path:e,basename:r,name:t,parent:i!=="."?this.createFolderObject(i):null}}createFolderObject(e){return{path:e,name:Rt.default.basename(e)}}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return null;try{let i=Wt.load(r[1]);return typeof i=="object"&&i!==null?i:null}catch{return null}}replaceFrontmatter(e,t){let r=Wt.dump(t,{lineWidth:-1,noRefs:!0,quotingType:'"'}),i=/^---\n([\s\S]*?)\n---/;return e.match(i)?e.replace(i,`---
502
+ `:""}a($Q,"dump$1");var UQ=$Q,VQ={dump:UQ};function Jv(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.")}}a(Jv,"renamed");var BQ=Ur,GQ=cO,qQ=hO,WQ=_O,zQ=bO,HQ=Qv,QQ=MO.load,YQ=MO.loadAll,XQ=VQ.dump,KQ=_n,JQ={binary:TO,float:yO,map:dO,null:pO,pairs:xO,set:AO,timestamp:vO,bool:mO,int:gO,merge:EO,omap:IO,seq:fO,str:uO},ZQ=Jv("safeLoad","load"),eY=Jv("safeLoadAll","loadAll"),tY=Jv("safeDump","dump"),Wt={Type:BQ,Schema:GQ,FAILSAFE_SCHEMA:qQ,JSON_SCHEMA:WQ,CORE_SCHEMA:zQ,DEFAULT_SCHEMA:HQ,load:QQ,loadAll:YQ,dump:XQ,YAMLException:KQ,types:JQ,safeLoad:ZQ,safeLoadAll:eY,safeDump:tY};var bE=Z(Jo()),il=Z(require("path"));var gF=Z(aF(),1);var qf=a(n=>{if(typeof n!="string")throw new TypeError("invalid pattern");if(n.length>65536)throw new TypeError("pattern is too long")},"assertValidPattern");var cY={"[: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]},Wf=a(n=>n.replace(/[[\]\\-]/g,"\\$&"),"braceEscape"),uY=a(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regexpEscape"),lF=a(n=>n.join(""),"rangesToString"),cF=a((n,e)=>{let t=e;if(n.charAt(t)!=="[")throw new Error("not in a brace expression");let r=[],i=[],s=t+1,o=!1,l=!1,c=!1,u=!1,f=t,d="";e:for(;s<n.length;){let _=n.charAt(s);if((_==="!"||_==="^")&&s===t+1){u=!0,s++;continue}if(_==="]"&&o&&!c){f=s+1;break}if(o=!0,_==="\\"&&!c){c=!0,s++;continue}if(_==="["&&!c){for(let[v,[w,E,I]]of Object.entries(cY))if(n.startsWith(v,s)){if(d)return["$.",!1,n.length-t,!0];s+=v.length,I?i.push(w):r.push(w),l=l||E;continue e}}if(c=!1,d){_>d?r.push(Wf(d)+"-"+Wf(_)):_===d&&r.push(Wf(_)),d="",s++;continue}if(n.startsWith("-]",s+1)){r.push(Wf(_+"-")),s+=2;continue}if(n.startsWith("-",s+1)){d=_,s+=2;continue}r.push(Wf(_)),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 _=r[0].length===2?r[0].slice(-1):r[0];return[uY(_),!1,f-t,!1]}let h="["+(u?"^":"")+lF(r)+"]",p="["+(u?"":"^")+lF(i)+"]";return[r.length&&i.length?"("+h+"|"+p+")":r.length?h:p,l,f-t,!0]},"parseClass");var Vi=a((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/\[([^\/\\])\]/g,"$1"):n.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),"unescape");var Mn,fY=new Set(["!","?","+","*","@"]),tE=a(n=>fY.has(n),"isExtglobType"),uF=a(n=>tE(n.type),"isExtglobAST"),dY=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),hY=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),pY=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),fF=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),mY="(?!(?:^|/)\\.\\.?(?:$|/))",Ag="(?!\\.)",gY=new Set(["[","."]),yY=new Set(["..","."]),_Y=new Set("().*{}+?[]^$\\!"),bY=a(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),rE="[^/]",dF=rE+"*?",hF=rE+"+?",tl=class{static{a(this,"AST")}type;#e;#n;#r=!1;#t=[];#l;#_;#i;#u=!1;#s;#c;#o=!1;constructor(e,t,r={}){this.type=e,e&&(this.#n=!0),this.#l=t,this.#e=this.#l?this.#l.#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.#l?this.#l.#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.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#t.map(e=>String(e)).join("|")+")":this.#c=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.#l;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.#l}}return this}push(...e){for(let t of e)if(t!==""){if(typeof t!="string"&&!(t instanceof Mn&&t.#l===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.#l?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#l?.isStart())return!1;if(this.#_===0)return!0;let e=this.#l;for(let t=0;t<this.#_;t++){let r=e.#t[t];if(!(r instanceof Mn&&r.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#l?.type==="!")return!0;if(!this.#l?.isEnd())return!1;if(!this.type)return this.#l?.isEnd();let e=this.#l?this.#l.#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 Mn(this.type,e);for(let r of this.#t)t.copyIn(r);return t}static#g(e,t,r,i,s){let o=i.maxExtglobRecursion??2,l=!1,c=!1,u=-1,f=!1;if(t.type===null){let _=r,v="";for(;_<e.length;){let w=e.charAt(_++);if(l||w==="\\"){l=!l,v+=w;continue}if(c){_===u+1?(w==="^"||w==="!")&&(f=!0):w==="]"&&!(_===u+2&&f)&&(c=!1),v+=w;continue}else if(w==="["){c=!0,u=_,f=!1,v+=w;continue}if(!i.noext&&tE(w)&&e.charAt(_)==="("&&s<=o){t.push(v),v="";let I=new Mn(w,t);_=Mn.#g(e,I,_,i,s+1),t.push(I);continue}v+=w}return t.push(v),_}let d=r+1,h=new Mn(null,t),p=[],g="";for(;d<e.length;){let _=e.charAt(d++);if(l||_==="\\"){l=!l,g+=_;continue}if(c){d===u+1?(_==="^"||_==="!")&&(f=!0):_==="]"&&!(d===u+2&&f)&&(c=!1),g+=_;continue}else if(_==="["){c=!0,u=d,f=!1,g+=_;continue}if(tE(_)&&e.charAt(d)==="("&&(s<=o||t&&t.#y(_))){let w=t&&t.#y(_)?0:1;h.push(g),g="";let E=new Mn(_,h);h.push(E),d=Mn.#g(e,E,d,i,s+w);continue}if(_==="|"){h.push(g),g="",p.push(h),h=new Mn(null,t);continue}if(_===")")return g===""&&t.#t.length===0&&(t.#o=!0),h.push(g),g="",t.push(...p,h),d;g+=_}return t.type=null,t.#n=void 0,t.#t=[e.substring(r-1)],d}#d(e){return this.#m(e,hY)}#m(e,t=dY){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=pY){return!!t.get(this.type)?.includes(e)}#f(e,t){let r=e.#t[0],i=new Mn(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.#l=this);this.#c=void 0}#T(e){return!!fF.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=fF.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.#l=this);this.type=i,this.#c=void 0,this.#o=!1}#S(){if(uF(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.#c=void 0}static fromGlob(e,t={}){let r=new Mn(null,void 0,t);return Mn.#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 l=(this.#s.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,l),{_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()),!uF(this)){let c=this.isStart()&&this.isEnd(),u=this.#t.map(p=>{let[g,_,v,w]=typeof p=="string"?Mn.#x(p,this.#n,c):p.toRegExpSource(e);return this.#n=this.#n||v,this.#r=this.#r||w,g}).join(""),f="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&yY.has(this.#t[0]))){let g=gY,_=t&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),v=!t&&!e&&g.has(u.charAt(0));f=_?mY:v?Ag:""}let d="";return this.isEnd()&&this.#e.#u&&this.#l?.type==="!"&&(d="(?:$|\\/)"),[f+u+d,Vi(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 c=this.toString(),u=this;return u.#t=[c],u.type=null,u.#n=void 0,[c,Vi(this.toString()),!1,!1]}let o=!r||e||t||!Ag?"":this.#w(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let l="";if(this.type==="!"&&this.#o)l=(this.isStart()&&!t?Ag:"")+hF;else{let c=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Ag:"")+dF+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;l=i+s+c}return[l,Vi(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,o]=t.toRegExpSource(e);return this.#r=this.#r||o,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#x(e,t,r=!1){let i=!1,s="",o=!1,l=!1;for(let c=0;c<e.length;c++){let u=e.charAt(c);if(i){i=!1,s+=(_Y.has(u)?"\\":"")+u,l=!1;continue}if(u==="\\"){c===e.length-1?s+="\\\\":i=!0;continue}if(u==="["){let[f,d,h,p]=cF(e,c);if(h){s+=f,o=o||d,c+=h-1,t=t||p,l=!1;continue}}if(u==="*"){if(l)continue;l=!0,s+=r&&/^[*]+$/.test(e)?hF:dF,t=!0;continue}else l=!1;if(u==="?"){s+=rE,t=!0;continue}s+=bY(u)}return[s,Vi(e),!!t,o]}};Mn=tl;var Vc=a((n,{windowsPathsNoEscape:e=!1}={})=>e?n.replace(/[?*()[\]]/g,"[$&]"):n.replace(/[?*()[\]\\]/g,"\\$&"),"escape");var Vr=a((n,e,t={})=>(qf(e),!t.nocomment&&e.charAt(0)==="#"?!1:new zn(e,t).match(n)),"minimatch"),SY=/^\*+([^+@!?\*\[\(]*)$/,wY=a(n=>e=>!e.startsWith(".")&&e.endsWith(n),"starDotExtTest"),vY=a(n=>e=>e.endsWith(n),"starDotExtTestDot"),EY=a(n=>(n=n.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(n)),"starDotExtTestNocase"),TY=a(n=>(n=n.toLowerCase(),e=>e.toLowerCase().endsWith(n)),"starDotExtTestNocaseDot"),IY=/^\*+\.\*+$/,xY=a(n=>!n.startsWith(".")&&n.includes("."),"starDotStarTest"),AY=a(n=>n!=="."&&n!==".."&&n.includes("."),"starDotStarTestDot"),RY=/^\.\*+$/,CY=a(n=>n!=="."&&n!==".."&&n.startsWith("."),"dotStarTest"),PY=/^\*+$/,OY=a(n=>n.length!==0&&!n.startsWith("."),"starTest"),FY=a(n=>n.length!==0&&n!=="."&&n!=="..","starTestDot"),DY=/^\?+([^+@!?\*\[\(]*)?$/,LY=a(([n,e=""])=>{let t=yF([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocase"),NY=a(([n,e=""])=>{let t=_F([n]);return e?(e=e.toLowerCase(),r=>t(r)&&r.toLowerCase().endsWith(e)):t},"qmarksTestNocaseDot"),kY=a(([n,e=""])=>{let t=_F([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTestDot"),MY=a(([n,e=""])=>{let t=yF([n]);return e?r=>t(r)&&r.endsWith(e):t},"qmarksTest"),yF=a(([n])=>{let e=n.length;return t=>t.length===e&&!t.startsWith(".")},"qmarksTestNoExt"),_F=a(([n])=>{let e=n.length;return t=>t.length===e&&t!=="."&&t!==".."},"qmarksTestNoExtDot"),bF=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",pF={win32:{sep:"\\"},posix:{sep:"/"}},jY=bF==="win32"?pF.win32.sep:pF.posix.sep;Vr.sep=jY;var Yt=Symbol("globstar **");Vr.GLOBSTAR=Yt;var $Y="[^/]",UY=$Y+"*?",VY="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",BY="(?:(?!(?:\\/|^)\\.).)*?",GY=a((n,e={})=>t=>Vr(t,n,e),"filter");Vr.filter=GY;var li=a((n,e={})=>Object.assign({},n,e),"ext"),qY=a(n=>{if(!n||typeof n!="object"||!Object.keys(n).length)return Vr;let e=Vr;return Object.assign(a((r,i,s={})=>e(r,i,li(n,s)),"m"),{Minimatch:class extends e.Minimatch{static{a(this,"Minimatch")}constructor(i,s={}){super(i,li(n,s))}static defaults(i){return e.defaults(li(n,i)).Minimatch}},AST:class extends e.AST{static{a(this,"AST")}constructor(i,s,o={}){super(i,s,li(n,o))}static fromGlob(i,s={}){return e.AST.fromGlob(i,li(n,s))}},unescape:a((r,i={})=>e.unescape(r,li(n,i)),"unescape"),escape:a((r,i={})=>e.escape(r,li(n,i)),"escape"),filter:a((r,i={})=>e.filter(r,li(n,i)),"filter"),defaults:a(r=>e.defaults(li(n,r)),"defaults"),makeRe:a((r,i={})=>e.makeRe(r,li(n,i)),"makeRe"),braceExpand:a((r,i={})=>e.braceExpand(r,li(n,i)),"braceExpand"),match:a((r,i,s={})=>e.match(r,i,li(n,s)),"match"),sep:e.sep,GLOBSTAR:Yt})},"defaults");Vr.defaults=qY;var SF=a((n,e={})=>(qf(n),e.nobrace||!/\{(?:(?!\{).)*\}/.test(n)?[n]:(0,gF.default)(n)),"braceExpand");Vr.braceExpand=SF;var WY=a((n,e={})=>new zn(n,e).makeRe(),"makeRe");Vr.makeRe=WY;var zY=a((n,e,t={})=>{let r=new zn(e,t);return n=n.filter(i=>r.match(i)),r.options.nonull&&!n.length&&n.push(e),n},"match");Vr.match=zY;var mF=/[?*]|[+@!]\(.*?\)|\[|\]/,HY=a(n=>n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"regExpEscape"),zn=class{static{a(this,"Minimatch")}options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){qf(e),t=t||{},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||bF,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,o,l)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!mF.test(s[2]))&&!mF.test(s[3]),u=/^[a-z]:/i.test(s[0]);if(c)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(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let 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 o=i;for(;r[o+1]==="**";)o++;o>i&&r.splice(i+1,o-i);let l=r[i+1],c=r[i+2],u=r[i+3];if(l!==".."||!c||c==="."||c===".."||!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 o=1;o<r.length-1;o++){let l=r[o];o===1&&l===""&&r[0]===""||(l==="."||l==="")&&(t=!0,r.splice(o,1),o--)}r[0]==="."&&r.length===2&&(r[1]==="."||r[1]==="")&&(t=!0,r.pop())}let s=0;for(;(s=r.indexOf("..",s+1))!==-1;){let o=r[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let c=s===1&&r[s+1]==="**"?["."]:[];r.splice(s-1,2,...c),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,o=[],l="";for(;i<e.length&&s<t.length;)if(e[i]===t[s])o.push(l==="b"?t[s]:e[i]),i++,s++;else if(r&&e[i]==="**"&&t[s]===e[i+1])o.push(e[i]),i++;else if(r&&t[s]==="**"&&e[i]===t[s+1])o.push(t[s]),s++;else if(e[i]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(l==="b")return!1;l="a",o.push(e[i]),i++,s++}else if(t[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(l==="a")return!1;l="b",o.push(t[s]),i++,s++}else return!1;return e.length===t.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,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 l=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),c=!l&&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=c?3:l?0:void 0,h=f?3:u?0:void 0;if(typeof d=="number"&&typeof h=="number"){let[p,g]=[e[d],t[h]];p.toLowerCase()===g.toLowerCase()&&(t[h]=p,s=h,i=d)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(Yt)?this.#e(e,t,r,i,s):this.#r(e,t,r,i,s)}#e(e,t,r,i,s){let o=t.indexOf(Yt,s),l=t.lastIndexOf(Yt),[c,u,f]=r?[t.slice(s,o),t.slice(o+1),[]]:[t.slice(s,o),t.slice(o+1,l),t.slice(l+1)];if(c.length){let E=e.slice(i,i+c.length);if(!this.#r(E,c,r,0,0))return!1;i+=c.length}let d=0;if(f.length){if(f.length+i>e.length)return!1;let E=e.length-f.length;if(this.#r(e,f,r,E,0))d=f.length;else{if(e[e.length-1]!==""||i+f.length===e.length||(E--,!this.#r(e,f,r,E,0)))return!1;d=f.length+1}}if(!u.length){let E=!!d;for(let I=i;I<e.length-d;I++){let O=String(e[I]);if(E=!0,O==="."||O===".."||!this.options.dot&&O.startsWith("."))return!1}return r||E}let h=[[[],0]],p=h[0],g=0,_=[0];for(let E of u)E===Yt?(_.push(g),p=[[],0],h.push(p)):(p[0].push(E),g++);let v=h.length-1,w=e.length-d;for(let E of h)E[1]=w-(_[v--]+E[0].length);return!!this.#n(e,h,i,0,r,0,!!d)}#n(e,t,r,i,s,o,l){let c=t[i];if(!c){for(let d=r;d<e.length;d++){l=!0;let h=e[d];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1}return l}let[u,f]=c;for(;r<=f;){if(this.#r(e.slice(0,r+u.length),u,s,r,0)&&o<this.maxGlobstarRecursion){let p=this.#n(e,t,r+u.length,i+1,s,o+1,l);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 o,l,c,u;for(o=i,l=s,u=e.length,c=t.length;o<u&&l<c;o++,l++){this.debug("matchOne loop");let f=t[l],d=e[o];if(this.debug(t,f,d),f===!1||f===Yt)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(o===u&&l===c)return!0;if(o===u)return r;if(l===c)return o===u-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return SF(this.pattern,this.options)}parse(e){qf(e);let t=this.options;if(e==="**")return Yt;if(e==="")return"";let r,i=null;(r=e.match(PY))?i=t.dot?FY:OY:(r=e.match(SY))?i=(t.nocase?t.dot?TY:EY:t.dot?vY:wY)(r[1]):(r=e.match(DY))?i=(t.nocase?t.dot?NY:LY:t.dot?kY:MY)(r):(r=e.match(IY))?i=t.dot?AY:xY:(r=e.match(RY))&&(i=CY);let s=tl.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?UY:t.dot?VY:BY,i=new Set(t.nocase?["i"]:[]),s=e.map(c=>{let u=c.map(f=>{if(f instanceof RegExp)for(let d of f.flags.split(""))i.add(d);return typeof f=="string"?HY(f):f===Yt?Yt:f._src});return u.forEach((f,d)=>{let h=u[d+1],p=u[d-1];f!==Yt||p===Yt||(p===void 0?h!==void 0&&h!==Yt?u[d+1]="(?:\\/|"+r+"\\/)?"+h:u[d]=r:h===void 0?u[d-1]=p+"(?:\\/|"+r+")?":h!==Yt&&(u[d-1]=p+"(?:\\/|\\/"+r+"\\/)"+h,u[d+1]=Yt))}),u.filter(f=>f!==Yt).join("/")}).join("|"),[o,l]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+l+"$",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 o=i[i.length-1];if(!o)for(let l=i.length-2;!o&&l>=0;l--)o=i[l];for(let l=0;l<s.length;l++){let c=s[l],u=i;if(r.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,t))return r.flipNegate?!0:!this.negate}return r.flipNegate?!1:this.negate}static defaults(e){return Vr.defaults(e).Minimatch}};Vr.AST=tl;Vr.Minimatch=zn;Vr.escape=Vc;Vr.unescape=Vi;var qF=require("node:url");var Bc=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,vF=new Set,nE=typeof process=="object"&&process?process:{},EF=a((n,e,t,r)=>{typeof nE.emitWarning=="function"?nE.emitWarning(n,e,t,r):console.error(`[${t}] ${e}: ${n}`)},"emitWarning"),Rg=globalThis.AbortController,wF=globalThis.AbortSignal;if(typeof Rg>"u"){wF=class{static{a(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(r,i){this._onabort.push(i)}},Rg=class{static{a(this,"AbortController")}constructor(){e()}signal=new wF;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=nE.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=a(()=>{n&&(n=!1,EF("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 QY=a(n=>!vF.has(n),"shouldWarn");var ta=a(n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),"isPosInt"),TF=a(n=>ta(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?Gc:null:null,"getUintArray"),Gc=class extends Array{static{a(this,"ZeroArray")}constructor(e){super(e),this.fill(0)}},iE=class n{static{a(this,"Stack")}heap;length;static#e=!1;static create(e){let t=TF(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]}},zf=class n{static{a(this,"LRUCache")}#e;#n;#r;#t;#l;#_;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#u;#s;#c;#o;#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.#c,valList:e.#o,next:e.#p,prev:e.#g,get head(){return e.#d},get tail(){return e.#m},free:e.#y,isBackgroundFetch:a(t=>e.#h(t),"isBackgroundFetch"),backgroundFetch:a((t,r,i,s)=>e.#j(t,r,i,s),"backgroundFetch"),moveToTail:a(t=>e.#U(t),"moveToTail"),indexes:a(t=>e.#R(t),"indexes"),rindexes:a(t=>e.#C(t),"rindexes"),isStale:a(t=>e.#I(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.#l}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:o,updateAgeOnHas:l,allowStale:c,dispose:u,disposeAfter:f,noDisposeOnSet:d,noUpdateTTL:h,maxSize:p=0,maxEntrySize:g=0,sizeCalculation:_,fetchMethod:v,memoMethod:w,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:I,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:C,ignoreFetchAbort:H}=e;if(t!==0&&!ta(t))throw new TypeError("max option must be a nonnegative integer");let ne=t?TF(t):Array;if(!ne)throw new Error("invalid max value: "+t);if(this.#e=t,this.#n=p,this.maxEntrySize=g||this.#n,this.sizeCalculation=_,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.#l=v,this.#S=!!v,this.#s=new Map,this.#c=new Array(t).fill(void 0),this.#o=new Array(t).fill(void 0),this.#p=new ne(t),this.#g=new ne(t),this.#d=0,this.#m=0,this.#y=iE.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=!!E,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!H,this.maxEntrySize!==0){if(this.#n!==0&&!ta(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!ta(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!I,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=ta(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!ta(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 de="LRU_CACHE_UNBOUNDED";QY(de)&&(vF.add(de),EF("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",de,n))}}getRemainingTTL(e){return this.#s.has(e)?1/0:0}#x(){let e=new Gc(this.#e),t=new Gc(this.#e);this.#b=e,this.#T=t,this.#F=(s,o,l=Bc.now())=>{if(t[s]=o!==0?l:0,e[s]=o,o!==0&&this.ttlAutopurge){let c=setTimeout(()=>{this.#I(s)&&this.#O(this.#c[s],"expire")},o+1);c.unref&&c.unref()}},this.#A=s=>{t[s]=e[s]!==0?Bc.now():0},this.#a=(s,o)=>{if(e[o]){let l=e[o],c=t[o];if(!l||!c)return;s.ttl=l,s.start=c,s.now=r||i();let u=s.now-c;s.remainingTTL=l-u}};let r=0,i=a(()=>{let s=Bc.now();if(this.ttlResolution>0){r=s;let o=setTimeout(()=>r=0,this.ttlResolution);o.unref&&o.unref()}return s},"getNow");this.getRemainingTTL=s=>{let o=this.#s.get(s);if(o===void 0)return 0;let l=e[o],c=t[o];if(!l||!c)return 1/0;let u=(r||i())-c;return l-u},this.#I=s=>{let o=t[s],l=e[s];return!!l&&!!o&&(r||i())-o>l}}#A=a(()=>{},"#updateItemAge");#a=a(()=>{},"#statusTTL");#F=a(()=>{},"#setItemTTL");#I=a(()=>!1,"#isStale");#P(){let e=new Gc(this.#e);this.#u=0,this.#E=e,this.#D=t=>{this.#u-=e[t],e[t]=0},this.#N=(t,r,i,s)=>{if(this.#h(r))return 0;if(!ta(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(r,t),!ta(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#L=(t,r,i)=>{if(e[t]=r,this.#n){let s=this.#n-e[t];for(;this.#u>s;)this.#M(!0)}this.#u+=e[t],i&&(i.entrySize=r,i.totalCalculatedSize=this.#u)}}#D=a(e=>{},"#removeItemSize");#L=a((e,t,r)=>{},"#addItemSize");#N=a((e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#R({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#m;!(!this.#k(t)||((e||!this.#I(t))&&(yield t),t===this.#d));)t=this.#g[t]}*#C({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#d;!(!this.#k(t)||((e||!this.#I(t))&&(yield t),t===this.#m));)t=this.#p[t]}#k(e){return e!==void 0&&this.#s.get(this.#c[e])===e}*entries(){for(let e of this.#R())this.#o[e]!==void 0&&this.#c[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#c[e],this.#o[e]])}*rentries(){for(let e of this.#C())this.#o[e]!==void 0&&this.#c[e]!==void 0&&!this.#h(this.#o[e])&&(yield[this.#c[e],this.#o[e]])}*keys(){for(let e of this.#R()){let t=this.#c[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*rkeys(){for(let e of this.#C()){let t=this.#c[e];t!==void 0&&!this.#h(this.#o[e])&&(yield t)}}*values(){for(let e of this.#R())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}*rvalues(){for(let e of this.#C())this.#o[e]!==void 0&&!this.#h(this.#o[e])&&(yield this.#o[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#R()){let i=this.#o[r],s=this.#h(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#c[r],this))return this.get(this.#c[r],t)}}forEach(e,t=this){for(let r of this.#R()){let i=this.#o[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}rforEach(e,t=this){for(let r of this.#C()){let i=this.#o[r],s=this.#h(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(t,s,this.#c[r],this)}}purgeStale(){let e=!1;for(let t of this.#C({allowStale:!0}))this.#I(t)&&(this.#O(this.#c[t],"expire"),e=!0);return e}info(e){let t=this.#s.get(e);if(t===void 0)return;let r=this.#o[t],i=this.#h(r)?r.__staleWhileFetching:r;if(i===void 0)return;let s={value:i};if(this.#b&&this.#T){let o=this.#b[t],l=this.#T[t];if(o&&l){let c=o-(Bc.now()-l);s.ttl=c,s.start=Date.now()}}return this.#E&&(s.size=this.#E[t]),s}dump(){let e=[];for(let t of this.#R({allowStale:!0})){let r=this.#c[t],i=this.#o[t],s=this.#h(i)?i.__staleWhileFetching:i;if(s===void 0||r===void 0)continue;let o={value:s};if(this.#b&&this.#T){o.ttl=this.#b[t];let l=Bc.now()-this.#T[t];o.start=Math.floor(Date.now()-l)}this.#E&&(o.size=this.#E[t]),e.unshift([r,o])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=Bc.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:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=r,{noUpdateTTL:u=this.noUpdateTTL}=r,f=this.#N(e,t,r.size||0,l);if(this.maxEntrySize&&f>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#O(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.#M(!1):this.#i,this.#c[d]=e,this.#o[d]=t,this.#s.set(e,d),this.#p[this.#m]=d,this.#g[d]=this.#m,this.#m=d,this.#i++,this.#L(d,f,c),c&&(c.set="add"),u=!1;else{this.#U(d);let h=this.#o[d];if(t!==h){if(this.#S&&this.#h(h)){h.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=h;p!==void 0&&!o&&(this.#v&&this.#r?.(p,e,"set"),this.#w&&this.#f?.push([p,e,"set"]))}else o||(this.#v&&this.#r?.(h,e,"set"),this.#w&&this.#f?.push([h,e,"set"]));if(this.#D(d),this.#L(d,f,c),this.#o[d]=t,c){c.set="replace";let p=h&&this.#h(h)?h.__staleWhileFetching:h;p!==void 0&&(c.oldValue=p)}}else c&&(c.set="update")}if(i!==0&&!this.#b&&this.#x(),this.#b&&(u||this.#F(d,i,s),c&&this.#a(c,d)),!o&&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.#o[this.#d];if(this.#M(!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)}}}#M(e){let t=this.#d,r=this.#c[t],i=this.#o[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.#c[t]=void 0,this.#o[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 o=this.#o[s];if(this.#h(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#I(s))i&&(i.has="stale",this.#a(i,s));else return r&&this.#A(s),i&&(i.has="hit",this.#a(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.#I(i))return;let s=this.#o[i];return this.#h(s)?s.__staleWhileFetching:s}#j(e,t,r,i){let s=t===void 0?void 0:this.#o[t];if(this.#h(s))return s;let o=new Rg,{signal:l}=r;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let c={signal:o.signal,options:r,context:i},u=a((_,v=!1)=>{let{aborted:w}=o.signal,E=r.ignoreFetchAbort&&_!==void 0;if(r.status&&(w&&!v?(r.status.fetchAborted=!0,r.status.fetchError=o.signal.reason,E&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),w&&!E&&!v)return d(o.signal.reason);let I=p;return this.#o[t]===p&&(_===void 0?I.__staleWhileFetching?this.#o[t]=I.__staleWhileFetching:this.#O(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,_,c.options))),_},"cb"),f=a(_=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=_),d(_)),"eb"),d=a(_=>{let{aborted:v}=o.signal,w=v&&r.allowStaleOnFetchAbort,E=w||r.allowStaleOnFetchRejection,I=E||r.noDeleteOnFetchRejection,O=p;if(this.#o[t]===p&&(!I||O.__staleWhileFetching===void 0?this.#O(e,"fetch"):w||(this.#o[t]=O.__staleWhileFetching)),E)return r.status&&O.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),O.__staleWhileFetching;if(O.__returned===O)throw _},"fetchFail"),h=a((_,v)=>{let w=this.#l?.(e,s,c);w&&w instanceof Promise&&w.then(E=>_(E===void 0?void 0:E),v),o.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(_(void 0),r.allowStaleOnFetchAbort&&(_=a(E=>u(E,!0),"res")))})},"pcall");r.status&&(r.status.fetchDispatched=!0);let p=new Promise(h).then(u,f),g=Object.assign(p,{__abortController:o,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,g,{...c.options,status:void 0}),t=this.#s.get(e)):this.#o[t]=g,g}#h(e){if(!this.#S)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Rg}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:f=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:_,forceRefresh:v=!1,status:w,signal:E}=t;if(!this.#S)return w&&(w.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:w});let I={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:o,noDisposeOnSet:l,size:c,sizeCalculation:u,noUpdateTTL:f,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:g,ignoreFetchAbort:p,status:w,signal:E},O=this.#s.get(e);if(O===void 0){w&&(w.fetch="miss");let C=this.#j(e,O,I,_);return C.__returned=C}else{let C=this.#o[O];if(this.#h(C)){let Y=r&&C.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",Y&&(w.returnedStale=!0)),Y?C.__staleWhileFetching:C.__returned=C}let H=this.#I(O);if(!v&&!H)return w&&(w.fetch="hit"),this.#U(O),i&&this.#A(O),w&&this.#a(w,O),C;let ne=this.#j(e,O,I,_),N=ne.__staleWhileFetching!==void 0&&r;return w&&(w.fetch=H?"stale":"refresh",N&&H&&(w.returnedStale=!0)),N?ne.__staleWhileFetching:ne.__returned=ne}}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,...o}=t,l=this.get(e,o);if(!s&&l!==void 0)return l;let c=r(e,l,{options:o,context:i});return this.set(e,c,o),c}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:o}=t,l=this.#s.get(e);if(l!==void 0){let c=this.#o[l],u=this.#h(c);return o&&this.#a(o,l),this.#I(l)?(o&&(o.get="stale"),u?(o&&r&&c.__staleWhileFetching!==void 0&&(o.returnedStale=!0),r?c.__staleWhileFetching:void 0):(s||this.#O(e,"expire"),o&&r&&(o.returnedStale=!0),r?c:void 0)):(o&&(o.get="hit"),u?c.__staleWhileFetching:(this.#U(l),i&&this.#A(l),c))}else o&&(o.get="miss")}#$(e,t){this.#g[t]=e,this.#p[e]=t}#U(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.#O(e,"delete")}#O(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.#V(t);else{this.#D(i);let s=this.#o[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.#c[i]=void 0,this.#o[i]=void 0,i===this.#m)this.#m=this.#g[i];else if(i===this.#d)this.#d=this.#p[i];else{let o=this.#g[i];this.#p[o]=this.#p[i];let l=this.#p[i];this.#g[l]=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.#V("delete")}#V(e){for(let t of this.#C({allowStale:!0})){let r=this.#o[t];if(this.#h(r))r.__abortController.abort(new Error("deleted"));else{let i=this.#c[t];this.#v&&this.#r?.(r,i,e),this.#w&&this.#f?.push([r,i,e])}}if(this.#s.clear(),this.#o.fill(void 0),this.#c.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 zc=require("node:path"),LF=require("node:url"),Ts=require("fs"),iX=Z(require("node:fs"),1),ia=require("node:fs/promises");var Ng=require("node:events"),fE=Z(require("node:stream"),1),CF=require("node:string_decoder");var IF=typeof process=="object"&&process?process:{stdout:null,stderr:null},YY=a(n=>!!n&&typeof n=="object"&&(n instanceof na||n instanceof fE.default||XY(n)||KY(n)),"isStream"),XY=a(n=>!!n&&typeof n=="object"&&n instanceof Ng.EventEmitter&&typeof n.pipe=="function"&&n.pipe!==fE.default.Writable.prototype.pipe,"isReadable"),KY=a(n=>!!n&&typeof n=="object"&&n instanceof Ng.EventEmitter&&typeof n.write=="function"&&typeof n.end=="function","isWritable"),yo=Symbol("EOF"),_o=Symbol("maybeEmitEnd"),ra=Symbol("emittedEnd"),Cg=Symbol("emittingEnd"),Hf=Symbol("emittedError"),Pg=Symbol("closed"),xF=Symbol("read"),Og=Symbol("flush"),AF=Symbol("flushChunk"),Bi=Symbol("encoding"),qc=Symbol("decoder"),Ir=Symbol("flowing"),Qf=Symbol("paused"),Wc=Symbol("resume"),xr=Symbol("buffer"),bn=Symbol("pipes"),Ar=Symbol("bufferLength"),sE=Symbol("bufferPush"),Fg=Symbol("bufferShift"),Zr=Symbol("objectMode"),Xt=Symbol("destroyed"),oE=Symbol("error"),aE=Symbol("emitData"),RF=Symbol("emitEnd"),lE=Symbol("emitEnd2"),vs=Symbol("async"),cE=Symbol("abort"),Dg=Symbol("aborted"),Yf=Symbol("signal"),rl=Symbol("dataListeners"),Hn=Symbol("discarded"),Xf=a(n=>Promise.resolve().then(n),"defer"),JY=a(n=>n(),"nodefer"),ZY=a(n=>n==="end"||n==="finish"||n==="prefinish","isEndish"),eX=a(n=>n instanceof ArrayBuffer||!!n&&typeof n=="object"&&n.constructor&&n.constructor.name==="ArrayBuffer"&&n.byteLength>=0,"isArrayBufferLike"),tX=a(n=>!Buffer.isBuffer(n)&&ArrayBuffer.isView(n),"isArrayBufferView"),Lg=class{static{a(this,"Pipe")}src;dest;opts;ondrain;constructor(e,t,r){this.src=e,this.dest=t,this.opts=r,this.ondrain=()=>e[Wc](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},uE=class extends Lg{static{a(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)}},rX=a(n=>!!n.objectMode,"isObjectModeOptions"),nX=a(n=>!n.objectMode&&!!n.encoding&&n.encoding!=="buffer","isEncodingOptions"),na=class extends Ng.EventEmitter{static{a(this,"Minipass")}[Ir]=!1;[Qf]=!1;[bn]=[];[xr]=[];[Zr];[Bi];[vs];[qc];[yo]=!1;[ra]=!1;[Cg]=!1;[Pg]=!1;[Hf]=null;[Ar]=0;[Xt]=!1;[Yf];[Dg]=!1;[rl]=0;[Hn]=!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");rX(t)?(this[Zr]=!0,this[Bi]=null):nX(t)?(this[Bi]=t.encoding,this[Zr]=!1):(this[Zr]=!1,this[Bi]=null),this[vs]=!!t.async,this[qc]=this[Bi]?new CF.StringDecoder(this[Bi]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:a(()=>this[xr],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:a(()=>this[bn],"get")});let{signal:r}=t;r&&(this[Yf]=r,r.aborted?this[cE]():r.addEventListener("abort",()=>this[cE]()))}get bufferLength(){return this[Ar]}get encoding(){return this[Bi]}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[Zr]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vs]}set async(e){this[vs]=this[vs]||!!e}[cE](){this[Dg]=!0,this.emit("abort",this[Yf]?.reason),this.destroy(this[Yf]?.reason)}get aborted(){return this[Dg]}set aborted(e){}write(e,t,r){if(this[Dg])return!1;if(this[yo])throw new Error("write after end");if(this[Xt])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[vs]?Xf:JY;if(!this[Zr]&&!Buffer.isBuffer(e)){if(tX(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(eX(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Zr]?(this[Ir]&&this[Ar]!==0&&this[Og](!0),this[Ir]?this.emit("data",e):this[sE](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Ir]):e.length?(typeof e=="string"&&!(t===this[Bi]&&!this[qc]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[Bi]&&(e=this[qc].write(e)),this[Ir]&&this[Ar]!==0&&this[Og](!0),this[Ir]?this.emit("data",e):this[sE](e),this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Ir]):(this[Ar]!==0&&this.emit("readable"),r&&i(r),this[Ir])}read(e){if(this[Xt])return null;if(this[Hn]=!1,this[Ar]===0||e===0||e&&e>this[Ar])return this[_o](),null;this[Zr]&&(e=null),this[xr].length>1&&!this[Zr]&&(this[xr]=[this[Bi]?this[xr].join(""):Buffer.concat(this[xr],this[Ar])]);let t=this[xF](e||null,this[xr][0]);return this[_o](),t}[xF](e,t){if(this[Zr])this[Fg]();else{let r=t;e===r.length||e===null?this[Fg]():typeof r=="string"?(this[xr][0]=r.slice(e),t=r.slice(0,e),this[Ar]-=e):(this[xr][0]=r.subarray(e),t=r.subarray(0,e),this[Ar]-=e)}return this.emit("data",t),!this[xr].length&&!this[yo]&&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[yo]=!0,this.writable=!1,(this[Ir]||!this[Qf])&&this[_o](),this}[Wc](){this[Xt]||(!this[rl]&&!this[bn].length&&(this[Hn]=!0),this[Qf]=!1,this[Ir]=!0,this.emit("resume"),this[xr].length?this[Og]():this[yo]?this[_o]():this.emit("drain"))}resume(){return this[Wc]()}pause(){this[Ir]=!1,this[Qf]=!0,this[Hn]=!1}get destroyed(){return this[Xt]}get flowing(){return this[Ir]}get paused(){return this[Qf]}[sE](e){this[Zr]?this[Ar]+=1:this[Ar]+=e.length,this[xr].push(e)}[Fg](){return this[Zr]?this[Ar]-=1:this[Ar]-=this[xr][0].length,this[xr].shift()}[Og](e=!1){do;while(this[AF](this[Fg]())&&this[xr].length);!e&&!this[xr].length&&!this[yo]&&this.emit("drain")}[AF](e){return this.emit("data",e),this[Ir]}pipe(e,t){if(this[Xt])return e;this[Hn]=!1;let r=this[ra];return t=t||{},e===IF.stdout||e===IF.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,r?t.end&&e.end():(this[bn].push(t.proxyErrors?new uE(this,e,t):new Lg(this,e,t)),this[vs]?Xf(()=>this[Wc]()):this[Wc]()),e}unpipe(e){let t=this[bn].find(r=>r.dest===e);t&&(this[bn].length===1?(this[Ir]&&this[rl]===0&&(this[Ir]=!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[Hn]=!1,this[rl]++,!this[bn].length&&!this[Ir]&&this[Wc]();else if(e==="readable"&&this[Ar]!==0)super.emit("readable");else if(ZY(e)&&this[ra])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Hf]){let i=t;this[vs]?Xf(()=>i.call(this,this[Hf])):i.call(this,this[Hf])}return r}removeListener(e,t){return this.off(e,t)}off(e,t){let r=super.off(e,t);return e==="data"&&(this[rl]=this.listeners("data").length,this[rl]===0&&!this[Hn]&&!this[bn].length&&(this[Ir]=!1)),r}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[rl]=0,!this[Hn]&&!this[bn].length&&(this[Ir]=!1)),t}get emittedEnd(){return this[ra]}[_o](){!this[Cg]&&!this[ra]&&!this[Xt]&&this[xr].length===0&&this[yo]&&(this[Cg]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Pg]&&this.emit("close"),this[Cg]=!1)}emit(e,...t){let r=t[0];if(e!=="error"&&e!=="close"&&e!==Xt&&this[Xt])return!1;if(e==="data")return!this[Zr]&&!r?!1:this[vs]?(Xf(()=>this[aE](r)),!0):this[aE](r);if(e==="end")return this[RF]();if(e==="close"){if(this[Pg]=!0,!this[ra]&&!this[Xt])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[Hf]=r,super.emit(oE,r);let s=!this[Yf]||this.listeners("error").length?super.emit("error",r):!1;return this[_o](),s}else if(e==="resume"){let s=super.emit("resume");return this[_o](),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[_o](),i}[aE](e){for(let r of this[bn])r.dest.write(e)===!1&&this.pause();let t=this[Hn]?!1:super.emit("data",e);return this[_o](),t}[RF](){return this[ra]?!1:(this[ra]=!0,this.readable=!1,this[vs]?(Xf(()=>this[lE]()),!0):this[lE]())}[lE](){if(this[qc]){let t=this[qc].end();if(t){for(let r of this[bn])r.dest.write(t);this[Hn]||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[Zr]||(e.dataLength=0);let t=this.promise();return this.on("data",r=>{e.push(r),this[Zr]||(e.dataLength+=r.length)}),await t,e}async concat(){if(this[Zr])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Bi]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(Xt,()=>t(new Error("stream destroyed"))),this.on("error",r=>t(r)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Hn]=!1;let e=!1,t=a(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"stop");return{next:a(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[yo])return t();let s,o,l=a(d=>{this.off("data",c),this.off("end",u),this.off(Xt,f),t(),o(d)},"onerr"),c=a(d=>{this.off("error",l),this.off("end",u),this.off(Xt,f),this.pause(),s({value:d,done:!!this[yo]})},"ondata"),u=a(()=>{this.off("error",l),this.off("data",c),this.off(Xt,f),t(),s({done:!0,value:void 0})},"onend"),f=a(()=>l(new Error("stream destroyed")),"ondestroy");return new Promise((d,h)=>{o=h,s=d,this.once(Xt,f),this.once("error",l),this.once("end",u),this.once("data",c)})},"next"),throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Hn]=!1;let e=!1,t=a(()=>(this.pause(),this.off(oE,t),this.off(Xt,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"stop"),r=a(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next");return this.once("end",t),this.once(oE,t),this.once(Xt,t),{next:r,throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[Xt])return e?this.emit("error",e):this.emit(Xt),this;this[Xt]=!0,this[Hn]=!0,this[xr].length=0,this[Ar]=0;let t=this;return typeof t.close=="function"&&!this[Pg]&&t.close(),e?this.emit("error",e):this.emit(Xt),this}static get isStream(){return YY}};var sX=Ts.realpathSync.native,Jf={lstatSync:Ts.lstatSync,readdir:Ts.readdir,readdirSync:Ts.readdirSync,readlinkSync:Ts.readlinkSync,realpathSync:sX,promises:{lstat:ia.lstat,readdir:ia.readdir,readlink:ia.readlink,realpath:ia.realpath}},NF=a(n=>!n||n===Jf||n===iX?Jf:{...Jf,...n,promises:{...Jf.promises,...n.promises||{}}},"fsFromOption"),kF=/^\\\\\?\\([a-z]:)\\?$/i,oX=a(n=>n.replace(/\//g,"\\").replace(kF,"$1\\"),"uncToDrive"),aX=/[\\\/]/,ui=0,MF=1,jF=2,Es=4,$F=6,UF=8,nl=10,VF=12,ci=15,Kf=~ci,dE=16,PF=32,Zf=64,Gi=128,kg=256,jg=512,OF=Zf|Gi|jg,lX=1023,hE=a(n=>n.isFile()?UF:n.isDirectory()?Es:n.isSymbolicLink()?nl:n.isCharacterDevice()?jF:n.isBlockDevice()?$F:n.isSocket()?VF:n.isFIFO()?MF:ui,"entToType"),FF=new Map,ed=a(n=>{let e=FF.get(n);if(e)return e;let t=n.normalize("NFKD");return FF.set(n,t),t},"normalize"),DF=new Map,Mg=a(n=>{let e=DF.get(n);if(e)return e;let t=ed(n.toLowerCase());return DF.set(n,t),t},"normalizeNocase"),$g=class extends zf{static{a(this,"ResolveCache")}constructor(){super({max:256})}},pE=class extends zf{static{a(this,"ChildrenCache")}constructor(e=16*1024){super({maxSize:e,sizeCalculation:a(t=>t.length+1,"sizeCalculation")})}},BF=Symbol("PathScurry setAsCwd"),en=class{static{a(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}#l;get uid(){return this.#l}#_;get gid(){return this.#_}#i;get rdev(){return this.#i}#u;get blksize(){return this.#u}#s;get ino(){return this.#s}#c;get size(){return this.#c}#o;get blocks(){return this.#o}#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;#A;#a;#F;#I;#P;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,t=ui,r,i,s,o,l){this.name=e,this.#b=s?Mg(e):ed(e),this.#a=t&lX,this.nocase=s,this.roots=i,this.root=r||this,this.#F=o,this.#S=l.fullpath,this.#x=l.relative,this.#A=l.relativePosix,this.parent=l.parent,this.parent?this.#e=this.parent.#e:this.#e=NF(l.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.#a&=~dE,t}child(e,t){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let r=this.children(),i=this.nocase?Mg(e):ed(e);for(let c of r)if(c.#b===i)return c;let s=this.parent?this.sep:"",o=this.#S?this.#S+s+e:void 0,l=this.newChild(e,ui,{...t,parent:this,fullpath:o});return this.canReaddir()||(l.#a|=Gi),r.push(l),l}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.#A!==void 0)return this.#A;let e=this.name,t=this.parent;if(!t)return this.#A=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.#a&ci)===ui}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.#a&ci)===UF}isDirectory(){return(this.#a&ci)===Es}isCharacterDevice(){return(this.#a&ci)===jF}isBlockDevice(){return(this.#a&ci)===$F}isFIFO(){return(this.#a&ci)===MF}isSocket(){return(this.#a&ci)===VF}isSymbolicLink(){return(this.#a&nl)===nl}lstatCached(){return this.#a&PF?this:void 0}readlinkCached(){return this.#I}realpathCached(){return this.#P}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#I)return!0;if(!this.parent)return!1;let e=this.#a&ci;return!(e!==ui&&e!==nl||this.#a&kg||this.#a&Gi)}calledReaddir(){return!!(this.#a&dE)}isENOENT(){return!!(this.#a&Gi)}isNamed(e){return this.nocase?this.#b===Mg(e):this.#b===ed(e)}async readlink(){let e=this.#I;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.#I=r}catch(t){this.#h(t.code);return}}readlinkSync(){let e=this.#I;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.#I=r}catch(t){this.#h(t.code);return}}#L(e){this.#a|=dE;for(let t=e.provisional;t<e.length;t++){let r=e[t];r&&r.#N()}}#N(){this.#a&Gi||(this.#a=(this.#a|Gi)&Kf,this.#R())}#R(){let e=this.children();e.provisional=0;for(let t of e)t.#N()}#C(){this.#a|=jg,this.#k()}#k(){if(this.#a&Zf)return;let e=this.#a;(e&ci)===Es&&(e&=Kf),this.#a=e|Zf,this.#R()}#M(e=""){e==="ENOTDIR"||e==="EPERM"?this.#k():e==="ENOENT"?this.#N():this.children().provisional=0}#j(e=""){e==="ENOTDIR"?this.parent.#k():e==="ENOENT"&&this.#N()}#h(e=""){let t=this.#a;t|=kg,e==="ENOENT"&&(t|=Gi),(e==="EINVAL"||e==="UNKNOWN")&&(t&=Kf),this.#a=t,e==="ENOTDIR"&&this.parent&&this.parent.#k()}#$(e,t){return this.#O(e,t)||this.#U(e,t)}#U(e,t){let r=hE(e),i=this.newChild(e.name,r,{parent:this}),s=i.#a&ci;return s!==Es&&s!==nl&&s!==ui&&(i.#a|=Zf),t.unshift(i),t.provisional++,i}#O(e,t){for(let r=t.provisional;r<t.length;r++){let i=t[r];if((this.nocase?Mg(e.name):ed(e.name))===i.#b)return this.#V(e,i,r,t)}}#V(e,t,r,i){let s=t.name;return t.#a=t.#a&Kf|hE(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.#a&Gi)===0)try{return this.#W(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#j(e.code)}}lstatSync(){if((this.#a&Gi)===0)try{return this.#W(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#j(e.code)}}#W(e){let{atime:t,atimeMs:r,birthtime:i,birthtimeMs:s,blksize:o,blocks:l,ctime:c,ctimeMs:u,dev:f,gid:d,ino:h,mode:p,mtime:g,mtimeMs:_,nlink:v,rdev:w,size:E,uid:I}=e;this.#y=t,this.#p=r,this.#T=i,this.#m=s,this.#u=o,this.#o=l,this.#E=c,this.#d=u,this.#n=f,this.#_=d,this.#s=h,this.#r=p,this.#f=g,this.#g=_,this.#t=v,this.#i=w,this.#c=E,this.#l=I;let O=hE(e);this.#a=this.#a&Kf|O|PF,O!==ui&&O!==Es&&O!==nl&&(this.#a|=Zf)}#G=[];#q=!1;#z(e){this.#q=!1;let t=this.#G.slice();this.#G.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.#G.push(e),this.#q)return;this.#q=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,o)=>{if(s)this.#M(s.code),r.provisional=0;else{for(let l of o)this.#$(l,r);this.#L(r)}this.#z(r.slice(0,r.provisional))})}#B;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.#B)await this.#B;else{let r=a(()=>{},"resolve");this.#B=new Promise(i=>r=i);try{for(let i of await this.#e.promises.readdir(t,{withFileTypes:!0}))this.#$(i,e);this.#L(e)}catch(i){this.#M(i.code),e.provisional=0}this.#B=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.#L(e)}catch(r){this.#M(r.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#a&OF)return!1;let e=ci&this.#a;return e===ui||e===Es||e===nl}shouldWalk(e,t){return(this.#a&Es)===Es&&!(this.#a&OF)&&!e.has(this)&&(!t||t(this))}async realpath(){if(this.#P)return this.#P;if(!((jg|kg|Gi)&this.#a))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#P=this.resolve(e)}catch{this.#C()}}realpathSync(){if(this.#P)return this.#P;if(!((jg|kg|Gi)&this.#a))try{let e=this.#e.realpathSync(this.fullpath());return this.#P=this.resolve(e)}catch{this.#C()}}[BF](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.#A=r.join("/"),i=i.parent,r.push("..");for(i=e;i&&i.parent&&!t.has(i);)i.#x=void 0,i.#A=void 0,i=i.parent}},Ug=class n extends en{static{a(this,"PathWin32")}sep="\\";splitSep=aX;constructor(e,t=ui,r,i,s,o,l){super(e,t,r,i,s,o,l)}newChild(e,t=ui,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}getRootString(e){return zc.win32.parse(e).root}getRoot(e){if(e=oX(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 Hc(e,this).root}sameRoot(e,t=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(kF,"$1\\"),e===t}},Vg=class n extends en{static{a(this,"PathPosix")}splitSep="/";sep="/";constructor(e,t=ui,r,i,s,o,l){super(e,t,r,i,s,o,l)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,t=ui,r={}){return new n(e,t,this.root,this.roots,this.nocase,this.childrenCache(),r)}},Bg=class{static{a(this,"PathScurryBase")}root;rootPath;roots;cwd;#e;#n;#r;nocase;#t;constructor(e=process.cwd(),t,r,{nocase:i,childrenCacheSize:s=16*1024,fs:o=Jf}={}){this.#t=NF(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,LF.fileURLToPath)(e));let l=t.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(l),this.#e=new $g,this.#n=new $g,this.#r=new pE(s);let c=l.substring(this.rootPath.length).split(r);if(c.length===1&&!c[0]&&c.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=c.length-1,d=t.sep,h=this.rootPath,p=!1;for(let g of c){let _=f--;u=u.child(g,{relative:new Array(_).fill("..").join(d),relativePosix:new Array(_).fill("..").join("/"),fullpath:h+=(p?"":d)+g}),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 o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))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 o=e[s];if(!(!o||o===".")&&(t=t?`${o}/${t}`:o,this.isAbsolute(o)))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 en||(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 en||(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 en||(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 en||(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 en||(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 en||(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 en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=[];(!s||s(e))&&l.push(r?e:e.fullpath());let c=new Set,u=a((d,h)=>{c.add(d),d.readdirCB((p,g)=>{if(p)return h(p);let _=g.length;if(!_)return h();let v=a(()=>{--_===0&&h()},"next");for(let w of g)(!s||s(w))&&l.push(r?w:w.fullpath()),i&&w.isSymbolicLink()?w.realpath().then(E=>E?.isUnknown()?E.lstat():E).then(E=>E?.shouldWalk(c,o)?u(E,v):v()):w.shouldWalk(c,o)?u(w,v):v()},!0)},"walk"),f=e;return new Promise((d,h)=>{u(f,p=>{if(p)return h(p);d(l)})})}walkSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=[];(!s||s(e))&&l.push(r?e:e.fullpath());let c=new Set([e]);for(let u of c){let f=u.readdirSync();for(let d of f){(!s||s(d))&&l.push(r?d:d.fullpath());let h=d;if(d.isSymbolicLink()){if(!(i&&(h=d.realpathSync())))continue;h.isUnknown()&&h.lstatSync()}h.shouldWalk(c,o)&&c.add(h)}}return l}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,t={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(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 en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t;(!s||s(e))&&(yield r?e:e.fullpath());let l=new Set([e]);for(let c of l){let u=c.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(l,o)&&l.add(d)}}}stream(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=new na({objectMode:!0});(!s||s(e))&&l.write(r?e:e.fullpath());let c=new Set,u=[e],f=0,d=a(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&l.end();return}f++,c.add(p);let g=a((v,w,E=!1)=>{if(v)return l.emit("error",v);if(i&&!E){let I=[];for(let O of w)O.isSymbolicLink()&&I.push(O.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(I.length){Promise.all(I).then(()=>g(null,w,!0));return}}for(let I of w)I&&(!s||s(I))&&(l.write(r?I:I.fullpath())||(h=!0));f--;for(let I of w){let O=I.realpathCached()||I;O.shouldWalk(c,o)&&u.push(O)}h&&!l.flowing?l.once("drain",d):_||d()},"onReaddir"),_=!0;p.readdirCB(g,!0),_=!1}},"process");return d(),l}streamSync(e=this.cwd,t={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof en||(t=e,e=this.cwd);let{withFileTypes:r=!0,follow:i=!1,filter:s,walkFilter:o}=t,l=new na({objectMode:!0}),c=new Set;(!s||s(e))&&l.write(r?e:e.fullpath());let u=[e],f=0,d=a(()=>{let h=!1;for(;!h;){let p=u.shift();if(!p){f===0&&l.end();return}f++,c.add(p);let g=p.readdirSync();for(let _ of g)(!s||s(_))&&(l.write(r?_:_.fullpath())||(h=!0));f--;for(let _ of g){let v=_;if(_.isSymbolicLink()){if(!(i&&(v=_.realpathSync())))continue;v.isUnknown()&&v.lstatSync()}v.shouldWalk(c,o)&&u.push(v)}}h&&!l.flowing&&l.once("drain",d)},"process");return d(),l}chdir(e=this.cwd){let t=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[BF](t)}},Hc=class extends Bg{static{a(this,"PathScurryWin32")}sep="\\";constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,zc.win32,"\\",{...t,nocase:r}),this.nocase=r;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return zc.win32.parse(e).root.toUpperCase()}newRoot(e){return new Ug(this.rootPath,Es,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},Qc=class extends Bg{static{a(this,"PathScurryPosix")}sep="/";constructor(e=process.cwd(),t={}){let{nocase:r=!1}=t;super(e,zc.posix,"/",{...t,nocase:r}),this.nocase=r}parseRootPath(e){return"/"}newRoot(e){return new Vg(this.rootPath,Es,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},td=class extends Qc{static{a(this,"PathScurryDarwin")}constructor(e=process.cwd(),t={}){let{nocase:r=!0}=t;super(e,{...t,nocase:r})}},phe=process.platform==="win32"?Ug:Vg,GF=process.platform==="win32"?Hc:process.platform==="darwin"?td:Qc;var cX=a(n=>n.length>=1,"isPatternList"),uX=a(n=>n.length>=1,"isGlobList"),Yc=class n{static{a(this,"Pattern")}#e;#n;#r;length;#t;#l;#_;#i;#u;#s;#c=!0;constructor(e,t,r,i){if(!cX(e))throw new TypeError("empty pattern list");if(!uX(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,o,l,c,...u]=this.#e,[f,d,h,p,...g]=this.#n;u[0]===""&&(u.shift(),g.shift());let _=[s,o,l,c,""].join("/"),v=[f,d,h,p,""].join("/");this.#e=[_,...u],this.#n=[v,...g],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...o]=this.#e,[l,...c]=this.#n;o[0]===""&&(o.shift(),c.shift());let u=s+"/",f=l+"/";this.#e=[u,...o],this.#n=[f,...c],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]===Yt}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.#l!==void 0?this.#l:this.hasMore()?(this.#l=new n(this.#e,this.#n,this.#r+1,this.#t),this.#l.#s=this.#s,this.#l.#u=this.#u,this.#l.#i=this.#i,this.#l):this.#l=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.#c)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var fX=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Xc=class{static{a(this,"Ignore")}relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:t,nocase:r,noext:i,noglobstar:s,platform:o=fX}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:t,nocase:r,noext:i,noglobstar:s,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let l of e)this.add(l)}add(e){let t=new zn(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 o=new Yc(i,s,0,this.platform),l=new zn(o.globString(),this.mmopts),c=s[s.length-1]==="**",u=o.isAbsolute();u?this.absolute.push(l):this.relative.push(l),c&&(u?this.absoluteChildren.push(l):this.relativeChildren.push(l))}}ignored(e){let t=e.fullpath(),r=`${t}/`,i=e.relative()||".",s=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(s))return!0;for(let o of this.absolute)if(o.match(t)||o.match(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 mE=class n{static{a(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()]))}},gE=class{static{a(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)])}},yE=class{static{a(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())}},rd=class n{static{a(this,"Processor")}hasWalkedCache;matches=new gE;subwalks=new yE;patterns;follow;dot;opts;constructor(e,t){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=t?t.copy():new mE}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 o=s.root(),l=s.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let d=s.rest();if(d)s=d;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,u,f=!1;for(;typeof(c=s.pattern())=="string"&&(u=s.rest());)i=i.resolve(c),s=u,f=!0;if(c=s.pattern(),u=s.rest(),f){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof c=="string"){let d=c===".."||c===""||c===".";this.matches.add(i.resolve(c),l,d);continue}else if(c===Yt){(!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,l,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,l,!0)}}else c 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 o of r){let l=o.isAbsolute(),c=o.pattern(),u=o.rest();c===Yt?i.testGlobstar(s,o,u,l):c instanceof RegExp?i.testRegExp(s,c,u,l):i.testString(s,c,u,l)}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 o=e.parent||e;this.subwalks.add(o,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 dX=a((n,e)=>typeof n=="string"?new Xc([n],e):Array.isArray(n)?new Xc(n,e):n,"makeIgnore"),Gg=class{static{a(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=dX(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)}#l(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 o=await s.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(s,t)}matchCheckTest(e,t){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!t||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#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 o=s.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.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(),o=this.opts.dotRelative&&!s.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(s?o+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 rd(this.opts),r)}walkCB2(e,t,r,i){if(this.#l(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,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||(s++,this.match(l,c,u).then(()=>o()));for(let l of r.subwalkTargets()){if(this.maxDepth!==1/0&&l.depth()>=this.maxDepth)continue;s++;let c=l.readdirCached();l.calledReaddir()?this.walkCB3(l,c,r,o):l.readdirCB((u,f)=>this.walkCB3(l,f,r,o),!0)}o()}walkCB3(e,t,r,i){r=r.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||(s++,this.match(l,c,u).then(()=>o()));for(let[l,c]of r.subwalks.entries())s++,this.walkCB2(l,c,r.child(),o);o()}walkCBSync(e,t,r){this.signal?.aborted&&r(),this.walkCB2Sync(e,t,new rd(this.opts),r)}walkCB2Sync(e,t,r,i){if(this.#l(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,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||this.matchSync(l,c,u);for(let l of r.subwalkTargets()){if(this.maxDepth!==1/0&&l.depth()>=this.maxDepth)continue;s++;let c=l.readdirSync();this.walkCB3Sync(l,c,r,o)}o()}walkCB3Sync(e,t,r,i){r=r.filterEntries(e,t);let s=1,o=a(()=>{--s===0&&i()},"next");for(let[l,c,u]of r.matches.entries())this.#t(l)||this.matchSync(l,c,u);for(let[l,c]of r.subwalks.entries())s++,this.walkCB2Sync(l,c,r.child(),o);o()}},nd=class extends Gg{static{a(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}},id=class extends Gg{static{a(this,"GlobStream")}results;constructor(e,t,r){super(e,t,r),this.results=new na({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 hX=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",qi=class{static{a(this,"Glob")}absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,t){if(!t)throw new TypeError("glob options required");if(this.withFileTypes=!!t.withFileTypes,this.signal=t.signal,this.follow=!!t.follow,this.dot=!!t.dot,this.dotRelative=!!t.dotRelative,this.nodir=!!t.nodir,this.mark=!!t.mark,t.cwd?(t.cwd instanceof URL||t.cwd.startsWith("file://"))&&(t.cwd=(0,qF.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(c=>c.replace(/\\/g,"/"))),this.matchBase){if(t.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=e,this.platform=t.platform||hX,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 c=t.platform==="win32"?Hc:t.platform==="darwin"?td:t.platform?Qc:GF;this.scurry=new c(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(c=>new zn(c,i)),[o,l]=s.reduce((c,u)=>(c[0].push(...u.set),c[1].push(...u.globParts),c),[[],[]]);this.patterns=o.map((c,u)=>{let f=l[u];if(!f)throw new Error("invalid pattern object");return new Yc(c,f,0,this.platform)})}async walk(){return[...await new nd(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 nd(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 id(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 id(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 _E=a((n,e={})=>{Array.isArray(n)||(n=[n]);for(let t of n)if(new zn(t,e).hasMagic())return!0;return!1},"hasMagic");function qg(n,e={}){return new qi(n,e).streamSync()}a(qg,"globStreamSync");function zF(n,e={}){return new qi(n,e).stream()}a(zF,"globStream");function HF(n,e={}){return new qi(n,e).walkSync()}a(HF,"globSync");async function WF(n,e={}){return new qi(n,e).walk()}a(WF,"glob_");function Wg(n,e={}){return new qi(n,e).iterateSync()}a(Wg,"globIterateSync");function QF(n,e={}){return new qi(n,e).iterate()}a(QF,"globIterate");var pX=qg,mX=Object.assign(zF,{sync:qg}),gX=Wg,yX=Object.assign(QF,{sync:Wg}),_X=Object.assign(HF,{stream:qg,iterate:Wg}),Kc=Object.assign(WF,{glob:WF,globSync:HF,sync:_X,globStream:zF,stream:mX,globStreamSync:qg,streamSync:pX,globIterate:QF,iterate:yX,globIterateSync:Wg,iterateSync:gX,Glob:qi,hasMagic:_E,escape:Vc,unescape:Vi});Kc.glob=Kc;async function XF(n,e,t,r={}){let{dryRun:i=!1,excludeRelPath:s}=r,o=il.default.join(n,"**/*.md"),l=await Kc(o,{nodir:!0,ignore:[il.default.join(n,".obsidian/**"),il.default.join(n,".trash/**"),il.default.join(n,"**/.obsidian/**"),il.default.join(n,"**/.trash/**")]}),c={filesScanned:0,filesModified:0,replacements:0,modifiedFiles:[]};for(let u of l){let f=il.default.relative(n,u);if(s&&f===s)continue;c.filesScanned+=1;let d;try{d=await bE.default.readFile(u,"utf-8")}catch{continue}let{updated:h,replacements:p}=bX(d,e,t);p>0&&(c.filesModified+=1,c.replacements+=p,c.modifiedFiles.push(f),i||await bE.default.writeFile(u,h,"utf-8"))}return c}a(XF,"rewriteInboundWikilinks");function bX(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 o=r[s],l=SX(o,e,t);i+=l.replacements,r[s]=l.updated}return{updated:r.join(""),replacements:i}}a(bX,"rewriteContent");function SX(n,e,t){let r=n.split(/(`[^`\n]*`)/),i=0;for(let s=0;s<r.length;s++){if(s%2===1)continue;let o=wX(r[s],e,t);i+=o.replacements,r[s]=o.updated}return{updated:r.join(""),replacements:i}}a(SX,"rewriteProseSegment");function wX(n,e,t){let r=/(?<!!)\[\[([^\[\]\n|#^]+)((?:[#^][^\[\]\n|]*)?)(?:\|[^\[\]\n]*)?\]\]/g,i=0;return{updated:n.replace(r,(o,l,c)=>l.trim()!==e?o:(i+=1,`[[${t}${c}]]`)),replacements:i}}a(wX,"replaceWikilinks");var vX=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,xt=class{constructor(e,t={}){this.rootPath=e;this.uuidIndex=null;this.basenameIndex=null;this.aliasIndex=null;this.siblingAdapters=t.siblingAdapters??[],this.subjectIriPrefix=t.subjectIriPrefix??""}static{a(this,"FileSystemVaultAdapter")}getSubjectIriPrefix(){return this.subjectIriPrefix}async read(e){let t=this.resolvePath(e.path);if(!await lr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);return lr.default.readFile(t,"utf-8")}async create(e,t){let r=this.resolvePath(e);if(await lr.default.pathExists(r))throw new Error(`File already exists: ${e}`);return await lr.default.ensureDir(Rt.default.dirname(r)),await lr.default.writeFile(r,t,"utf-8"),this.createFileObject(e)}async modify(e,t){let r=this.resolvePath(e.path);if(!await lr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await lr.default.writeFile(r,t,"utf-8")}async delete(e){let t=this.resolvePath(e.path);if(!await lr.default.pathExists(t))throw new Error(`File not found: ${e.path}`);await lr.default.remove(t)}async exists(e){let t=this.resolvePath(e);return lr.default.pathExists(t)}getAbstractFileByPath(e){let t=this.resolvePath(e);try{let r=lr.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=Rt.default.relative(this.rootPath,t);e.push(this.createFileObject(r))}}),e}getFrontmatter(e){try{let t=lr.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),o=this.replaceFrontmatter(r,s);await this.modify(e,o)}async rename(e,t){let r=this.resolvePath(e.path),i=this.resolvePath(t);if(!await lr.default.pathExists(r))throw new Error(`File not found: ${e.path}`);await lr.default.ensureDir(Rt.default.dirname(i)),await lr.default.move(r,i)}async createFolder(e){let t=this.resolvePath(e);await lr.default.ensureDir(t)}getFirstLinkpathDest(e,t){let r=e.split("|")[0].trim();if(!r)return null;if(vX.test(r)){this.uuidIndex===null&&this.buildUuidIndex();let u=r.toLowerCase(),f=this.uuidIndex.get(u);return f?this.createFileObject(f):null}let i=Rt.default.dirname(this.resolvePath(t)),s;if(Rt.default.isAbsolute(r)?s=this.resolvePath(r):s=Rt.default.resolve(i,r),r.endsWith(".md")||(s+=".md"),lr.default.existsSync(s)){let u=Rt.default.relative(this.rootPath,s);return this.createFileObject(u)}(this.basenameIndex===null||this.aliasIndex===null)&&this.buildLinkpathIndex();let o=r.toLowerCase(),l=this.basenameIndex.get(o);if(l)return this.createFileObject(l);let c=this.aliasIndex.get(o);if(c)return this.createFileObject(c);for(let u of this.siblingAdapters){let f=u.getSubjectIriPrefix();if(!f)continue;let d=u.getFirstLinkpathDest(r,"");if(d){let h=`${f}/${d.path}`;return this.createCrossVaultFileObject(h)}}return null}createCrossVaultFileObject(e){let t=Rt.default.basename(e),r=Rt.default.basename(e,Rt.default.extname(e)),i=Rt.default.dirname(e);return{path:e,basename:r,name:t,parent:i!=="."?{path:i,name:Rt.default.basename(i)}:null}}buildLinkpathIndex(){this.basenameIndex=new Map,this.aliasIndex=new Map,this.walkDirectory(this.rootPath,e=>{if(!e.endsWith(".md"))return;let t=Rt.default.relative(this.rootPath,e),r=Rt.default.basename(e,".md").toLowerCase();this.basenameIndex.has(r)||this.basenameIndex.set(r,t);let i;try{i=lr.default.readFileSync(e,"utf-8")}catch{return}let s=this.extractFrontmatter(i);if(!s)return;let o=s.aliases,l=Array.isArray(o)?o:typeof o=="string"?[o]:[];for(let c of l){if(typeof c!="string")continue;let u=c.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=Rt.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=Rt.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=Rt.default.basename(t,".md");await XF(this.rootPath,r,i,{excludeRelPath:e})}resolvePath(e){return Rt.default.isAbsolute(e)?e:Rt.default.join(this.rootPath,e)}createFileObject(e){let t=Rt.default.basename(e),r=Rt.default.basename(e,Rt.default.extname(e)),i=Rt.default.dirname(e);return{path:e,basename:r,name:t,parent:i!=="."?this.createFolderObject(i):null}}createFolderObject(e){return{path:e,name:Rt.default.basename(e)}}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return null;try{let i=Wt.load(r[1]);return typeof i=="object"&&i!==null?i:null}catch{return null}}replaceFrontmatter(e,t){let r=Wt.dump(t,{lineWidth:-1,noRefs:!0,quotingType:'"'}),i=/^---\n([\s\S]*?)\n---/;return e.match(i)?e.replace(i,`---
503
503
  ${r.trim()}
504
504
  ---`):`---
505
505
  ${r.trim()}
@@ -514,9 +514,9 @@ ${e}`}shouldSkipDirectory(e){return e.startsWith(".")}walkDirectory(e,t){let r;t
514
514
  \u{1F4A1} ${this.guidance}`),this.context&&Object.keys(this.context).length>0){e+=`
515
515
 
516
516
  \u{1F4CB} Context:`;for(let[t,r]of Object.entries(this.context))e+=`
517
- ${t}: ${JSON.stringify(r)}`}return e}toStructuredResponse(e=!1){return Ne.error(this.errorCode,this.message,this.exitCode,{recovery:this.recoveryHint||{message:this.guidance},context:this.context,stack:e?this.stack:void 0})}formatJson(e=!1){return JSON.stringify(this.toStructuredResponse(e),null,2)}};var se=class n{static{a(this,"ErrorHandler")}static{this.outputFormat="text"}static setFormat(e){n.outputFormat=e}static getFormat(){return n.outputFormat}static isDebugMode(){return!!process.env.DEBUG}static handle(e){if(e instanceof tn){if(n.outputFormat==="json"){let i=e.toStructuredResponse(n.isDebugMode());console.log(JSON.stringify(i,null,2))}else console.error(e.format()),n.isDebugMode()&&(console.error(`
517
+ ${t}: ${JSON.stringify(r)}`}return e}toStructuredResponse(e=!1){return Ne.error(this.errorCode,this.message,this.exitCode,{recovery:this.recoveryHint||{message:this.guidance},context:this.context,stack:e?this.stack:void 0})}formatJson(e=!1){return JSON.stringify(this.toStructuredResponse(e),null,2)}};var oe=class n{static{a(this,"ErrorHandler")}static{this.outputFormat="text"}static setFormat(e){n.outputFormat=e}static getFormat(){return n.outputFormat}static isDebugMode(){return!!process.env.DEBUG}static handle(e){if(e instanceof tn){if(n.outputFormat==="json"){let i=e.toStructuredResponse(n.isDebugMode());console.log(JSON.stringify(i,null,2))}else console.error(e.format()),n.isDebugMode()&&(console.error(`
518
518
  \u{1F4CD} Stack trace:`),console.error(e.stack));process.exit(e.exitCode)}let{exitCode:t,errorCode:r}=n.classifyError(e);if(n.outputFormat==="json"){let i=n.buildErrorResponse(r,e.message,t,n.isDebugMode()?e.stack:void 0);console.log(JSON.stringify(i,null,2))}else console.error(`\u274C Error: ${e.message}`),n.isDebugMode()&&console.error(e.stack);process.exit(t)}static handleWithMessage(e,t=1,r="INTERNAL_UNKNOWN"){if(n.outputFormat==="json"){let i=n.buildErrorResponse(r,e,t);console.log(JSON.stringify(i,null,2))}else console.error(`\u274C Error: ${e}`);process.exit(t)}static classifyError(e){let t=e.message.toLowerCase();return t.includes("transition")?{exitCode:6,errorCode:"STATE_INVALID_TRANSITION"}:t.includes("transaction")?{exitCode:7,errorCode:"INTERNAL_TRANSACTION_FAILED"}:t.includes("concurrent")||t.includes("modified")?{exitCode:8,errorCode:"STATE_CONCURRENT_MODIFICATION"}:e.message.includes("not found")||e.message.includes("ENOENT")?{exitCode:3,errorCode:"VALIDATION_FILE_NOT_FOUND"}:e.message.includes("EACCES")||e.message.includes("permission denied")?{exitCode:4,errorCode:"PERMISSION_DENIED"}:e.message.includes("Invalid")||e.message.includes("outside vault")||e.message.includes("Not a")?{exitCode:2,errorCode:"VALIDATION_INVALID_ARGUMENTS"}:{exitCode:1,errorCode:"INTERNAL_UNKNOWN"}}static buildErrorResponse(e,t,r,i){return Ne.error(e,t,r,{recovery:n.getRecoveryHint(e),stack:i})}static getRecoveryHint(e){switch(e){case"VALIDATION_FILE_NOT_FOUND":return{message:"Verify the file path is correct and the file exists",suggestion:"Check file path spelling and ensure the file is in the vault"};case"VALIDATION_VAULT_NOT_FOUND":return{message:"Verify the vault path is correct",suggestion:"Check --vault option or current directory"};case"VALIDATION_INVALID_ARGUMENTS":return{message:"Check command syntax and argument format",suggestion:"Use --help for usage information"};case"STATE_INVALID_TRANSITION":return{message:"The requested state transition is not allowed",suggestion:"Check the current asset state and valid transitions"};case"STATE_CONCURRENT_MODIFICATION":return{message:"File was modified by another process",suggestion:"Wait and retry the command"};case"PERMISSION_DENIED":return{message:"Check file permissions",suggestion:"Ensure you have write access to the vault"};case"INTERNAL_TRANSACTION_FAILED":return{message:"Transaction could not complete",suggestion:"Check for locked files and retry"};default:return{message:"An unexpected error occurred",suggestion:"Check the error details and retry"}}}};var it=class extends tn{constructor(t,r,i){let s=`Check command syntax and argument format.
519
- Use: exocortex command --help for usage information.`;super(t,i,{message:r||"Check command syntax and argument format",suggestion:"exocortex command --help"});this.exitCode=2;this.errorCode="VALIDATION_INVALID_ARGUMENTS";this.guidance=r||s}static{a(this,"InvalidArgumentsError")}};var he=class extends tn{constructor(t,r){super(`Vault not found: ${t}`,{vaultPath:t,...r},{message:"Verify the vault path is correct and the directory exists",suggestion:`ls -la "${t}" or check --vault option`});this.exitCode=3;this.errorCode="VALIDATION_VAULT_NOT_FOUND";this.guidance=`The specified vault directory does not exist.
519
+ Use: exocortex command --help for usage information.`;super(t,i,{message:r||"Check command syntax and argument format",suggestion:"exocortex command --help"});this.exitCode=2;this.errorCode="VALIDATION_INVALID_ARGUMENTS";this.guidance=r||s}static{a(this,"InvalidArgumentsError")}};var pe=class extends tn{constructor(t,r){super(`Vault not found: ${t}`,{vaultPath:t,...r},{message:"Verify the vault path is correct and the directory exists",suggestion:`ls -la "${t}" or check --vault option`});this.exitCode=3;this.errorCode="VALIDATION_VAULT_NOT_FOUND";this.guidance=`The specified vault directory does not exist.
520
520
  Check:
521
521
  \u2022 Path spelling and case sensitivity
522
522
  \u2022 Directory exists and is accessible
@@ -605,26 +605,26 @@ Available prefixes: ${u}`,this.wellKnownPrefixes[r]&&l.push(`Add: PREFIX ${r}: <
605
605
  `)}formatForJSON(e){return{type:e.type,message:e.message,originalMessage:e.originalMessage,suggestions:e.suggestions,line:e.line,column:e.column,context:e.context?{startLine:e.context.startLine,endLine:e.context.endLine,errorLine:e.context.errorLine,errorColumn:e.context.errorColumn,lines:e.context.lines.map(t=>({number:t.number,content:t.content,isError:t.isError}))}:void 0}}};var ay=class n{static{a(this,"NTriplesFormatter")}static escapeString(e){let t=e.replace(/\\/g,"\\\\");return t=t.replace(/"/g,'\\"'),t=t.replace(/\n/g,"\\n"),t=t.replace(/\r/g,"\\r"),t=t.replace(/\t/g,"\\t"),t}static formatObject(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("urn:")?`<${e}>`:`"${n.escapeString(e)}"`}};var ll=require("fs"),zE=require("path");function aa(n){let e=new Map,t="obsidian://vault/",r;try{r=(0,ll.readdirSync)(n)}catch{return e}for(let i of r){let s=(0,zE.join)(n,i);if(i.startsWith("."))continue;let o;try{o=(0,ll.statSync)(s)}catch{continue}if(!o.isDirectory())continue;let l;try{l=(0,ll.readdirSync)(s)}catch{continue}for(let c of l){let u=(0,zE.join)(s,c);if(c.startsWith("."))continue;let f;try{f=(0,ll.statSync)(u)}catch{continue}if(!f.isDirectory())continue;let d=!1;try{d=(0,ll.readdirSync)(u).some(p=>p.endsWith(".md"))}catch{continue}if(d){let h=`${i}/${c}`,p=encodeURI(h),g=`${t}${p}/`;/^[a-zA-Z][a-zA-Z0-9_]*$/.test(c)&&e.set(c,g)}}}return e}a(aa,"scanVaultNamespaces");var RD=Z(It());var bK="https://exocortex.my/ontology/",SK=/^[a-z][a-zA-Z0-9]*$/,CD=new Set(["exo","ems","ims","gtd","period","lit","inbox","rdf","rdfs","owl","xsd"]),wK=/(<)([a-zA-Z][a-zA-Z0-9]*)__([a-zA-Z][a-zA-Z0-9_]*)(>)/g;function la(n){let e=new Set,t=/PREFIX\s+(\w+)\s*:/gi,r;for(;(r=t.exec(n))!==null;)e.add(r[1].toLowerCase());let i=RD.SPARQL_PREFIXES.split(`
606
606
  `).filter(f=>f.trim().length>0),s=[];for(let f of i){let d=/PREFIX\s+(\w+)\s*:/i.exec(f);d&&!e.has(d[1].toLowerCase())&&s.push(f)}let o=/(?<![:\w])([a-z][a-zA-Z0-9]*):[a-zA-Z_]/g,l=new Set,c;for(;(c=o.exec(n))!==null;)l.add(c[1]);let u=new Set(e);for(let f of s){let d=/PREFIX\s+(\w+)\s*:/i.exec(f);d&&u.add(d[1].toLowerCase())}for(let f of l)u.has(f.toLowerCase())||SK.test(f)&&(s.push(`PREFIX ${f}: <${bK}${f}#>`),u.add(f.toLowerCase()));return s.length===0?n:s.join(`
607
607
  `)+`
608
- `+n}a(la,"injectExocortexPrefixes");function ou(n){return n.replace(wK,(e,t,r,i,s)=>CD.has(r.toLowerCase())?`${r}:${i}`:e)}a(ou,"transformShorthandNotation");function ca(n){let e=new Map(n);for(let t of CD)e.delete(t);return e}a(ca,"filterOntologyPrefixes");var ly=Z(Jo()),cy=Z(require("path"));var vK="49fd2e56-4656-4ca7-a789-f472b16ea260",EK="c9c65b0f-1e01-47c1-a1f9-1bf70b11df6a",TK="0cde1557-6320-4bd0-a7c4-8b72afc38720",IK=new Set([vK,EK,TK]),xK="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb",AK="3de846cd-1f0e-4f98-8613-b8587aa15174",RK=5,au=class{static{a(this,"CliFocusProfileResolver")}constructor(e){let t=e.alsoVaultPaths??[];this.vaultPaths=[e.vaultPath,...t].map(r=>cy.default.resolve(r)),this.maxExtendsDepth=e.maxExtendsDepth??RK,this.warn=e.warn??(()=>{})}async resolveFilter(e){if(e==null||e==="")return{outcome:"no-profile"};let t;try{t=await this.scanAllVaults()}catch(u){let f=`[CliFocusProfileResolver] vault scan threw \u2014 ${String(u)}`;return this.warn(f),{outcome:"error",reason:f}}if(t.profiles.get(e)===void 0)return this.warn(`[CliFocusProfileResolver] profileUid=${e} not found in any scanned vault \u2014 falling back to no-filter (full vault).`),{outcome:"missing-profile",profileUid:e};let i=new Set;try{this.walkProfileChain(e,t.profiles,i,new Set,0)}catch(u){let f=`[CliFocusProfileResolver] profile chain walk threw \u2014 ${String(u)}`;return this.warn(f),{outcome:"error",reason:f}}let s=new Set(t.folderMap.values()),o=new Set,l=[];for(let u of i){if(s.has(u)){o.add(u);continue}let f=t.ontologyToAs.get(u);if(f!==void 0){o.add(f);continue}l.push(u)}for(let u of IK)o.add(u);if(!Array.from(o).some(u=>s.has(u))){let u=`[CliFocusProfileResolver] profileUid=${e} produced effective set with zero AssetSpace folder overlap (${o.size} AS UIDs after translation+floor; ${t.folderMap.size} folders known). Likely cause: profile declares Ontology UIDs not covered by containsOntology, or vault has no scanned AssetSpaces. Falling back to no-filter (full vault indexed).`;return this.warn(u),{outcome:"degraded",reason:u}}return{outcome:"engaged",result:{effective:o,folderMap:t.folderMap,declaredOntologies:i,untranslated:l}}}walkProfileChain(e,t,r,i,s){if(s>this.maxExtendsDepth)throw new Error(`FocusProfile chain exceeds max depth ${this.maxExtendsDepth} at ${e} \u2014 possible cycle`);if(i.has(e))return;i.add(e);let o=t.get(e);if(o!==void 0){for(let l of o.includes)r.add(l);for(let l of o.alwaysOnOverlay)r.add(l);typeof o.extends=="string"&&o.extends.length>0&&this.walkProfileChain(o.extends,t,r,i,s+1)}}async scanAllVaults(){let e=new Map,t=new Map,r=new Map;for(let i of this.vaultPaths){if(!await ly.default.pathExists(i)){this.warn(`[CliFocusProfileResolver] vault path does not exist: ${i} \u2014 skipping.`);continue}let s=await this.walkVault(i);for(let o of s){let l=yd(o.frontmatter.exo__Instance_class);if(l.some(c=>c===xK)){let c=PK(o.filePath,o.vaultRoot);c.length>0&&e.set(c,o.uid);let u=yd(o.frontmatter.exo__AssetSpace_containsOntology);for(let f of u)t.set(f,o.uid)}if(l.some(c=>c===AK)){let c={uid:o.uid,label:typeof o.frontmatter.exo__Asset_label=="string"?o.frontmatter.exo__Asset_label:void 0,includes:yd(o.frontmatter.exo__FocusProfile_includes),extends:yd(o.frontmatter.exo__FocusProfile_extends)[0]??null,alwaysOnOverlay:yd(o.frontmatter.exo__FocusProfile_alwaysOnOverlay)};r.set(o.uid,c)}}}return{folderMap:e,ontologyToAs:t,profiles:r}}async walkVault(e){let t=[],r=[e];for(;r.length>0;){let i=r.pop(),s;try{s=await ly.default.readdir(i,{withFileTypes:!0})}catch{continue}for(let o of s){let l=cy.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules"||o.name===".obsidian"||o.name===".exocortex")continue;r.push(l);continue}if(!o.isFile()||!o.name.endsWith(".md"))continue;let c=await this.tryReadFrontmatter(l);if(c===null)continue;let u=c.exo__Asset_uid;typeof u!="string"||u.length===0||t.push({uid:u,filePath:l,vaultRoot:e,frontmatter:c})}}return t}async tryReadFrontmatter(e){let t;try{t=await ly.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let r=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(r===null)return null;try{let i=Wt.load(r[1]);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function yd(n){if(n==null)return[];let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(typeof r!="string")continue;let i=CK(r);i!==null&&t.push(i)}return t}a(yd,"parseWikilinkArray");function CK(n){let e=n.trim().replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0].trim();return e.length===0?null:e}a(CK,"extractUidFromWikilink");function PK(n,e){let t=cy.default.relative(e,n).replace(/\\/g,"/");if(!t.startsWith("assetspaces/"))return"";let r=t.slice(12),i=r.indexOf("/");return i<0?"":`assetspaces/${r.slice(0,i)}`}a(PK,"parentFolderRelative");async function ua(n){let{profileUid:e,primaryVaultPath:t,alsoVaultPaths:r,outputFormat:i}=n;if(e===void 0||e==="")return null;let o=await new au({vaultPath:t,alsoVaultPaths:r,warn:i==="text"?l=>console.warn(l):void 0}).resolveFilter(e);switch(o.outcome){case"engaged":{if(i==="text"){let l=FK(o.result.effective);console.log(`\u{1F3AF} Profile ${e.slice(0,8)} engaged \u2014 ${o.result.effective.size} AS UIDs in scope (incl. ${l} TS-floor), ${o.result.folderMap.size} folders mapped.`),o.result.untranslated.length>0&&console.log(` \u2139\uFE0F ${o.result.untranslated.length} declared Ontology UID(s) had no AssetSpace_containsOntology mapping; passed through unfiltered.`)}return{effective:o.result.effective,folderMap:o.result.folderMap}}case"no-profile":return null;case"missing-profile":return i==="text"&&console.log(`\u26A0\uFE0F --profile ${o.profileUid} not found in vault(s) \u2014 indexing full vault.`),null;case"degraded":return i==="text"&&console.log(`\u26A0\uFE0F ${o.reason}`),null;case"error":return i==="text"&&console.log(`\u26A0\uFE0F ${o.reason}`),null}}a(ua,"resolveProfileFilter");var OK=new Set(["49fd2e56-4656-4ca7-a789-f472b16ea260","c9c65b0f-1e01-47c1-a1f9-1bf70b11df6a","0cde1557-6320-4bd0-a7c4-8b72afc38720"]);function FK(n){let e=0;for(let t of n)OK.has(t)&&e++;return e}a(FK,"countTsFloor");var PD=require("path");var DK=/\/assetspaces\/([^/]+)\/?$/;function uy(n){let e=(0,PD.resolve)(n).replace(/\\/g,"/"),t=DK.exec(e);return t?`assetspaces/${t[1]}`:""}a(uy,"deriveSubjectIriPrefix");var $n=Z(It());var LK=new Map([["exo__","https://exocortex.my/ontology/exo#"],["ems__","https://exocortex.my/ontology/ems#"],["exocmd__","https://exocortex.my/ontology/exocmd#"],["ims__","https://exocortex.my/ontology/ims#"],["ztlk__","https://exocortex.my/ontology/ztlk#"],["ptms__","https://exocortex.my/ontology/ptms#"],["lit__","https://exocortex.my/ontology/lit#"],["inbox__","https://exocortex.my/ontology/inbox#"],["place__","https://exocortex.my/ontology/place#"],["exoob__","https://exocortex.my/ontology/exoob#"],["pn__","https://exocortex.my/ontology/pn#"],["period__","https://exocortex.my/ontology/period#"],["rdf__","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["rdfs__","http://www.w3.org/2000/01/rdf-schema#"],["owl__","http://www.w3.org/2002/07/owl#"]]);function NK(n){let e=n.indexOf("__");if(e===-1)return null;let t=n.slice(0,e+2),r=n.slice(e+2),i=LK.get(t);return!i||!r?null:i+r}a(NK,"labelToOntologyIRI");var OD="https://exocortex.my/ontology/exo#Instance_class",kK="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",MK="http://www.w3.org/2000/01/rdf-schema#label",jK="https://exocortex.my/ontology/exo#Asset_label",$K=/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i,UK=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function fy(n){let e=new Map;for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==MK&&i.predicate.value!==jK)continue;let s=UK.exec(i.subject.value);if(!s)continue;let o=s[1].toLowerCase();if(e.has(o))continue;let l=i.object.value.trim();if(/\s/.test(l))continue;let c=NK(l);c&&e.set(o,c)}if(e.size===0)return n;let t=new Set,r=[];for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==OD)continue;let s=i.object.value.trim(),o=$K.exec(s);if(!o)continue;let l=o[1].toLowerCase(),c=e.get(l);if(!c)continue;let f=`${i.subject.value}\0${c}`;if(t.has(f))continue;t.add(f);let d=new $n.DomainIRI(c);r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(OD),d)),r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(kK),d))}return r.length>0?n.concat(r):n}a(fy,"resolveCrossVaultInstanceClassWikilinks");var VK=300,FD=3e4,BK="EXOCORTEX_SPARQL_TIMEOUT";function GK(){let n=process.env[BK];if(!n)return FD;try{let e=qK(n);if(e!==null&&e>0)return e}catch{}return FD}a(GK,"getDefaultTimeout");function qK(n){let e=n.trim().toLowerCase();if(!e)return null;if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);return isNaN(r)||r<=0?null:r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);return isNaN(r)||r<=0?null:r*1e3}let t=parseInt(e,10);return isNaN(t)||t<=0?null:t*1e3}a(qK,"parseTimeoutSafe");function WK(n){if(!n)return VK;let e=parseInt(n.trim(),10);if(isNaN(e)||e<=0)throw new it(`Invalid cache TTL: "${n}". Must be a positive number (seconds).`,'exocortex sparql query --cache-ttl 600 "SELECT * WHERE { ?s ?p ?o }"');return e}a(WK,"parseCacheTtl");function zK(n){let e=n.trim().toLowerCase();if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);if(isNaN(r)||r<=0)throw new it(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);if(isNaN(r)||r<=0)throw new it(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return r*1e3}let t=parseInt(e,10);if(isNaN(t)||t<=0)throw new it(`Invalid timeout format: "${n}". Use formats like "30s", "5000ms", or just a number (seconds).`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return t*1e3}a(zK,"parseTimeout");async function HE(n,e,t=Date.now()){let r,i=new Promise((s,o)=>{r=setTimeout(()=>{let l=Date.now()-t;o(new sd(e,l))},e),r&&typeof r=="object"&&"unref"in r&&r.unref()});return Promise.race([n,i])}a(HE,"executeWithTimeout");function HK(n,e){return e.concat([n])}a(HK,"collectAlso");function LD(){return new ce("query").description("Execute SPARQL query against Obsidian vault").argument("[query]","SPARQL query string or path to .sparql file (optional if --template is used)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to include in query (repeatable)",HK,[]).option("--format <type>","Output format: table|json|csv|ntriples","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--timeout <duration>","Query timeout (e.g., 30s, 5000ms)","30s").option("--dry-run","Validate query syntax without executing (no vault loading)").option("--explain","Show optimized query plan").option("--stats","Show execution statistics").option("--no-optimize","Disable query optimization").option("--use-cache","Use persistent triple cache (faster vault loading)").option("--cache-ttl <seconds>","Query result cache TTL in seconds (default: 300)").option("--no-cache","Bypass query result cache").option("--template <name>","Use a predefined query template").option("--param <params>","Template parameters (format: key=value,key2=value2)").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").option("--strict","Fail on unresolved label-form wikilinks in property paths (sets EXOCORTEX_SPARQL_STRICT=1, Issue #3282)").action(async(n,e)=>{let t=e.output||"text";se.setFormat(t);let r=process.env.EXOCORTEX_SPARQL_STRICT;e.strict&&(process.env.EXOCORTEX_SPARQL_STRICT="1");let i="";try{let s=Date.now(),o=e.timeout?zK(e.timeout):GK(),l=WK(e.cacheTtl),c=e.profile!==void 0&&e.profile!=="",u=e.cache!==!1&&!c;if(c&&e.cache!==!1&&t==="text"&&console.log("\u26A0\uFE0F Query result cache bypassed because --profile is active (cache is not profile-aware; MVP limitation)."),e.template){let V=new sy,Y=e.param?V.parseParamString(e.param):{};if(i=V.applyTemplate(e.template,Y),t==="text"){let re=V.getTemplate(e.template);console.log(`\u{1F4CB} Using template: ${e.template}`),Object.keys(Y).length>0&&console.log(` Parameters: ${Object.entries(Y).map(([G,ne])=>`${G}=${ne}`).join(", ")}`),console.log()}}else if(n)i=QK(n);else throw new it("Either a query argument or --template flag is required.",'exocortex sparql query "SELECT * WHERE { ?s ?p ?o }" or exocortex sparql query --template tasks-by-date --param date=2024-01-15');if(e.dryRun){await YK(i,e,t);return}let f=(0,cl.resolve)(e.vault);if(u){let Y=await new ru().get(i,l);if(Y!==null){let re=Date.now()-s;if(t==="json"){let G=Ne.success(Y,{durationMs:re,itemCount:Y.count||0,queryResultCacheHit:!0});console.log(JSON.stringify(G,null,2))}else{console.log(`\u{1F4E6} (cached) Query result loaded from cache in ${re}ms
609
- `);let G=Y;G.type==="select"&&G.bindings?(console.log(`\u2705 Found ${G.bindings.length} result(s)
608
+ `+n}a(la,"injectExocortexPrefixes");function ou(n){return n.replace(wK,(e,t,r,i,s)=>CD.has(r.toLowerCase())?`${r}:${i}`:e)}a(ou,"transformShorthandNotation");function ca(n){let e=new Map(n);for(let t of CD)e.delete(t);return e}a(ca,"filterOntologyPrefixes");var ly=Z(Jo()),cy=Z(require("path"));var vK="49fd2e56-4656-4ca7-a789-f472b16ea260",EK="c9c65b0f-1e01-47c1-a1f9-1bf70b11df6a",TK="0cde1557-6320-4bd0-a7c4-8b72afc38720",IK=new Set([vK,EK,TK]),xK="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb",AK="3de846cd-1f0e-4f98-8613-b8587aa15174",RK=5,au=class{static{a(this,"CliFocusProfileResolver")}constructor(e){let t=e.alsoVaultPaths??[];this.vaultPaths=[e.vaultPath,...t].map(r=>cy.default.resolve(r)),this.maxExtendsDepth=e.maxExtendsDepth??RK,this.warn=e.warn??(()=>{})}async resolveFilter(e){if(e==null||e==="")return{outcome:"no-profile"};let t;try{t=await this.scanAllVaults()}catch(u){let f=`[CliFocusProfileResolver] vault scan threw \u2014 ${String(u)}`;return this.warn(f),{outcome:"error",reason:f}}if(t.profiles.get(e)===void 0)return this.warn(`[CliFocusProfileResolver] profileUid=${e} not found in any scanned vault \u2014 falling back to no-filter (full vault).`),{outcome:"missing-profile",profileUid:e};let i=new Set;try{this.walkProfileChain(e,t.profiles,i,new Set,0)}catch(u){let f=`[CliFocusProfileResolver] profile chain walk threw \u2014 ${String(u)}`;return this.warn(f),{outcome:"error",reason:f}}let s=new Set(t.folderMap.values()),o=new Set,l=[];for(let u of i){if(s.has(u)){o.add(u);continue}let f=t.ontologyToAs.get(u);if(f!==void 0){o.add(f);continue}l.push(u)}for(let u of IK)o.add(u);if(!Array.from(o).some(u=>s.has(u))){let u=`[CliFocusProfileResolver] profileUid=${e} produced effective set with zero AssetSpace folder overlap (${o.size} AS UIDs after translation+floor; ${t.folderMap.size} folders known). Likely cause: profile declares Ontology UIDs not covered by containsOntology, or vault has no scanned AssetSpaces. Falling back to no-filter (full vault indexed).`;return this.warn(u),{outcome:"degraded",reason:u}}return{outcome:"engaged",result:{effective:o,folderMap:t.folderMap,declaredOntologies:i,untranslated:l}}}walkProfileChain(e,t,r,i,s){if(s>this.maxExtendsDepth)throw new Error(`FocusProfile chain exceeds max depth ${this.maxExtendsDepth} at ${e} \u2014 possible cycle`);if(i.has(e))return;i.add(e);let o=t.get(e);if(o!==void 0){for(let l of o.includes)r.add(l);for(let l of o.alwaysOnOverlay)r.add(l);typeof o.extends=="string"&&o.extends.length>0&&this.walkProfileChain(o.extends,t,r,i,s+1)}}async scanAllVaults(){let e=new Map,t=new Map,r=new Map;for(let i of this.vaultPaths){if(!await ly.default.pathExists(i)){this.warn(`[CliFocusProfileResolver] vault path does not exist: ${i} \u2014 skipping.`);continue}let s=await this.walkVault(i);for(let o of s){let l=yd(o.frontmatter.exo__Instance_class);if(l.some(c=>c===xK)){let c=PK(o.filePath,o.vaultRoot);c.length>0&&e.set(c,o.uid);let u=yd(o.frontmatter.exo__AssetSpace_containsOntology);for(let f of u)t.set(f,o.uid)}if(l.some(c=>c===AK)){let c={uid:o.uid,label:typeof o.frontmatter.exo__Asset_label=="string"?o.frontmatter.exo__Asset_label:void 0,includes:yd(o.frontmatter.exo__FocusProfile_includes),extends:yd(o.frontmatter.exo__FocusProfile_extends)[0]??null,alwaysOnOverlay:yd(o.frontmatter.exo__FocusProfile_alwaysOnOverlay)};r.set(o.uid,c)}}}return{folderMap:e,ontologyToAs:t,profiles:r}}async walkVault(e){let t=[],r=[e];for(;r.length>0;){let i=r.pop(),s;try{s=await ly.default.readdir(i,{withFileTypes:!0})}catch{continue}for(let o of s){let l=cy.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules"||o.name===".obsidian"||o.name===".exocortex")continue;r.push(l);continue}if(!o.isFile()||!o.name.endsWith(".md"))continue;let c=await this.tryReadFrontmatter(l);if(c===null)continue;let u=c.exo__Asset_uid;typeof u!="string"||u.length===0||t.push({uid:u,filePath:l,vaultRoot:e,frontmatter:c})}}return t}async tryReadFrontmatter(e){let t;try{t=await ly.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let r=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(r===null)return null;try{let i=Wt.load(r[1]);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function yd(n){if(n==null)return[];let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(typeof r!="string")continue;let i=CK(r);i!==null&&t.push(i)}return t}a(yd,"parseWikilinkArray");function CK(n){let e=n.trim().replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0].trim();return e.length===0?null:e}a(CK,"extractUidFromWikilink");function PK(n,e){let t=cy.default.relative(e,n).replace(/\\/g,"/");if(!t.startsWith("assetspaces/"))return"";let r=t.slice(12),i=r.indexOf("/");return i<0?"":`assetspaces/${r.slice(0,i)}`}a(PK,"parentFolderRelative");async function ua(n){let{profileUid:e,primaryVaultPath:t,alsoVaultPaths:r,outputFormat:i}=n;if(e===void 0||e==="")return null;let o=await new au({vaultPath:t,alsoVaultPaths:r,warn:i==="text"?l=>console.warn(l):void 0}).resolveFilter(e);switch(o.outcome){case"engaged":{if(i==="text"){let l=FK(o.result.effective);console.log(`\u{1F3AF} Profile ${e.slice(0,8)} engaged \u2014 ${o.result.effective.size} AS UIDs in scope (incl. ${l} TS-floor), ${o.result.folderMap.size} folders mapped.`),o.result.untranslated.length>0&&console.log(` \u2139\uFE0F ${o.result.untranslated.length} declared Ontology UID(s) had no AssetSpace_containsOntology mapping; passed through unfiltered.`)}return{effective:o.result.effective,folderMap:o.result.folderMap}}case"no-profile":return null;case"missing-profile":return i==="text"&&console.log(`\u26A0\uFE0F --profile ${o.profileUid} not found in vault(s) \u2014 indexing full vault.`),null;case"degraded":return i==="text"&&console.log(`\u26A0\uFE0F ${o.reason}`),null;case"error":return i==="text"&&console.log(`\u26A0\uFE0F ${o.reason}`),null}}a(ua,"resolveProfileFilter");var OK=new Set(["49fd2e56-4656-4ca7-a789-f472b16ea260","c9c65b0f-1e01-47c1-a1f9-1bf70b11df6a","0cde1557-6320-4bd0-a7c4-8b72afc38720"]);function FK(n){let e=0;for(let t of n)OK.has(t)&&e++;return e}a(FK,"countTsFloor");var PD=require("path");var DK=/\/assetspaces\/([^/]+)\/?$/;function uy(n){let e=(0,PD.resolve)(n).replace(/\\/g,"/"),t=DK.exec(e);return t?`assetspaces/${t[1]}`:""}a(uy,"deriveSubjectIriPrefix");var $n=Z(It());var LK=new Map([["exo__","https://exocortex.my/ontology/exo#"],["ems__","https://exocortex.my/ontology/ems#"],["exocmd__","https://exocortex.my/ontology/exocmd#"],["ims__","https://exocortex.my/ontology/ims#"],["ztlk__","https://exocortex.my/ontology/ztlk#"],["ptms__","https://exocortex.my/ontology/ptms#"],["lit__","https://exocortex.my/ontology/lit#"],["inbox__","https://exocortex.my/ontology/inbox#"],["place__","https://exocortex.my/ontology/place#"],["exoob__","https://exocortex.my/ontology/exoob#"],["pn__","https://exocortex.my/ontology/pn#"],["period__","https://exocortex.my/ontology/period#"],["rdf__","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["rdfs__","http://www.w3.org/2000/01/rdf-schema#"],["owl__","http://www.w3.org/2002/07/owl#"]]);function NK(n){let e=n.indexOf("__");if(e===-1)return null;let t=n.slice(0,e+2),r=n.slice(e+2),i=LK.get(t);return!i||!r?null:i+r}a(NK,"labelToOntologyIRI");var OD="https://exocortex.my/ontology/exo#Instance_class",kK="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",MK="http://www.w3.org/2000/01/rdf-schema#label",jK="https://exocortex.my/ontology/exo#Asset_label",$K=/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i,UK=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function fy(n){let e=new Map;for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==MK&&i.predicate.value!==jK)continue;let s=UK.exec(i.subject.value);if(!s)continue;let o=s[1].toLowerCase();if(e.has(o))continue;let l=i.object.value.trim();if(/\s/.test(l))continue;let c=NK(l);c&&e.set(o,c)}if(e.size===0)return n;let t=new Set,r=[];for(let i of n){if(!(i.subject instanceof $n.DomainIRI)||!(i.predicate instanceof $n.DomainIRI)||!(i.object instanceof $n.DomainLiteral)||i.predicate.value!==OD)continue;let s=i.object.value.trim(),o=$K.exec(s);if(!o)continue;let l=o[1].toLowerCase(),c=e.get(l);if(!c)continue;let f=`${i.subject.value}\0${c}`;if(t.has(f))continue;t.add(f);let d=new $n.DomainIRI(c);r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(OD),d)),r.push(new $n.DomainTriple(i.subject,new $n.DomainIRI(kK),d))}return r.length>0?n.concat(r):n}a(fy,"resolveCrossVaultInstanceClassWikilinks");var VK=300,FD=3e4,BK="EXOCORTEX_SPARQL_TIMEOUT";function GK(){let n=process.env[BK];if(!n)return FD;try{let e=qK(n);if(e!==null&&e>0)return e}catch{}return FD}a(GK,"getDefaultTimeout");function qK(n){let e=n.trim().toLowerCase();if(!e)return null;if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);return isNaN(r)||r<=0?null:r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);return isNaN(r)||r<=0?null:r*1e3}let t=parseInt(e,10);return isNaN(t)||t<=0?null:t*1e3}a(qK,"parseTimeoutSafe");function WK(n){if(!n)return VK;let e=parseInt(n.trim(),10);if(isNaN(e)||e<=0)throw new it(`Invalid cache TTL: "${n}". Must be a positive number (seconds).`,'exocortex sparql query --cache-ttl 600 "SELECT * WHERE { ?s ?p ?o }"');return e}a(WK,"parseCacheTtl");function zK(n){let e=n.trim().toLowerCase();if(e.endsWith("ms")){let r=parseInt(e.slice(0,-2),10);if(isNaN(r)||r<=0)throw new it(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return r}if(e.endsWith("s")){let r=parseInt(e.slice(0,-1),10);if(isNaN(r)||r<=0)throw new it(`Invalid timeout format: "${n}". Value must be a positive number.`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return r*1e3}let t=parseInt(e,10);if(isNaN(t)||t<=0)throw new it(`Invalid timeout format: "${n}". Use formats like "30s", "5000ms", or just a number (seconds).`,'exocortex sparql query --timeout "30s" or --timeout "5000ms"');return t*1e3}a(zK,"parseTimeout");async function HE(n,e,t=Date.now()){let r,i=new Promise((s,o)=>{r=setTimeout(()=>{let l=Date.now()-t;o(new sd(e,l))},e),r&&typeof r=="object"&&"unref"in r&&r.unref()});return Promise.race([n,i])}a(HE,"executeWithTimeout");function HK(n,e){return e.concat([n])}a(HK,"collectAlso");function LD(){return new ce("query").description("Execute SPARQL query against Obsidian vault").argument("[query]","SPARQL query string or path to .sparql file (optional if --template is used)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to include in query (repeatable)",HK,[]).option("--format <type>","Output format: table|json|csv|ntriples","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--timeout <duration>","Query timeout (e.g., 30s, 5000ms)","30s").option("--dry-run","Validate query syntax without executing (no vault loading)").option("--explain","Show optimized query plan").option("--stats","Show execution statistics").option("--no-optimize","Disable query optimization").option("--use-cache","Use persistent triple cache (faster vault loading)").option("--cache-ttl <seconds>","Query result cache TTL in seconds (default: 300)").option("--no-cache","Bypass query result cache").option("--template <name>","Use a predefined query template").option("--param <params>","Template parameters (format: key=value,key2=value2)").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").option("--strict","Fail on unresolved label-form wikilinks in property paths (sets EXOCORTEX_SPARQL_STRICT=1, Issue #3282)").action(async(n,e)=>{let t=e.output||"text";oe.setFormat(t);let r=process.env.EXOCORTEX_SPARQL_STRICT;e.strict&&(process.env.EXOCORTEX_SPARQL_STRICT="1");let i="";try{let s=Date.now(),o=e.timeout?zK(e.timeout):GK(),l=WK(e.cacheTtl),c=e.profile!==void 0&&e.profile!=="",u=e.cache!==!1&&!c;if(c&&e.cache!==!1&&t==="text"&&console.log("\u26A0\uFE0F Query result cache bypassed because --profile is active (cache is not profile-aware; MVP limitation)."),e.template){let V=new sy,X=e.param?V.parseParamString(e.param):{};if(i=V.applyTemplate(e.template,X),t==="text"){let re=V.getTemplate(e.template);console.log(`\u{1F4CB} Using template: ${e.template}`),Object.keys(X).length>0&&console.log(` Parameters: ${Object.entries(X).map(([G,ie])=>`${G}=${ie}`).join(", ")}`),console.log()}}else if(n)i=QK(n);else throw new it("Either a query argument or --template flag is required.",'exocortex sparql query "SELECT * WHERE { ?s ?p ?o }" or exocortex sparql query --template tasks-by-date --param date=2024-01-15');if(e.dryRun){await YK(i,e,t);return}let f=(0,cl.resolve)(e.vault);if(u){let X=await new ru().get(i,l);if(X!==null){let re=Date.now()-s;if(t==="json"){let G=Ne.success(X,{durationMs:re,itemCount:X.count||0,queryResultCacheHit:!0});console.log(JSON.stringify(G,null,2))}else{console.log(`\u{1F4E6} (cached) Query result loaded from cache in ${re}ms
609
+ `);let G=X;G.type==="select"&&G.bindings?(console.log(`\u2705 Found ${G.bindings.length} result(s)
610
610
  `),JK(G.bindings,e.format)):G.type==="construct"&&G.triples&&(console.log(`\u2705 Generated ${G.triples.length} triple(s)
611
- `),ZK(G.triples,e.format))}return}}if(!(0,lu.existsSync)(f))throw new he(f);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${f}...`);let d=Date.now(),h=e.also||[],p=await ua({profileUid:e.profile,primaryVaultPath:f,alsoVaultPaths:h.map(V=>(0,cl.resolve)(V)),outputFormat:t}),g=e.useCache??!1;g&&p!==null&&(t==="text"&&console.log("\u26A0\uFE0F --use-cache disabled because --profile is active (cache is not profile-aware; MVP limitation)."),g=!1);let _=[],v=!1,w=!1;if(g&&h.length>0&&p===null){let V=new tu(f,h.map(re=>(0,cl.resolve)(re))),Y=await V.loadIfValid();Y!==null?(_=Y.triples,v=!0,w=!0,t==="text"&&console.log(`\u{1F680} Combined cache hit! Loaded ${_.length} triples from cross-vault index (${V.getAllVaultPaths().length} vaults).`)):t==="text"&&console.log("\u2139\uFE0F Combined cache miss (or invalid). Falling back to per-vault load. Run `exocortex sparql index --vault <primary> --also <...>` to build the cross-vault index.")}if(!w){let V=[],Y=[];for(let re of h){let G=(0,cl.resolve)(re);if(!(0,lu.existsSync)(G))throw new he(G);let ne=uy(G);V.push(new xt(G,{subjectIriPrefix:ne})),Y.push({resolvedAlsoPath:G,subjectIriPrefix:ne})}if(g){let G=await new di(f).loadOrBuild();_=G.triples,v=G.cacheHit,t==="text"&&v&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let re=new xt(f,{siblingAdapters:V});_=await new kt.NoteToRDFConverter(re).convertVault(p!==null?{effectiveOntologies:p.effective,assetSpaceFolderToUid:p.folderMap}:{})}for(let re=0;re<V.length;re++){let G=V[re],{resolvedAlsoPath:ne,subjectIriPrefix:q}=Y[re];t==="text"&&console.log(`\u{1F4E6} Loading additional vault: ${ne}...`);let B=await new kt.NoteToRDFConverter(G,void 0,{subjectIriPrefix:q}).convertVault(p!==null?{effectiveOntologies:p.effective,assetSpaceFolderToUid:p.folderMap}:{});_=_.concat(B),t==="text"&&console.log(` \u2795 Added ${B.length} triples from ${ne}`)}if(h.length>0&&(_=fy(_),sl())){let re=new xt(f,{siblingAdapters:V}),G=Hg([re,...V]),ne=kt.IRICanonicalizer.canonicalize(_,G);_=ne.triples,t==="text"&&ne.remapCount>0&&console.log(` \u{1FA84} IRI canonicalization (Issue #3286): remapped ${ne.remapCount} triple(s) covering ${ne.uniqueRemapCount} distinct synth-A IRI(s)`)}}let E=new kt.InMemoryTripleStore;await E.addAll(_);let I=Date.now()-d;if(t==="text"){let V=v?" (from cache)":"",Y=h.length>0?` (${h.length+1} vaults)`:"";console.log(`\u2705 Loaded ${_.length} triples in ${I}ms${V}${Y}
612
- `),console.log("\u{1F50D} Parsing SPARQL query...")}let A=new kt.ExoQLParser;i=ou(i),i=la(i);let D=ca(aa(f));for(let V of h){let Y=ca(aa((0,cl.resolve)(V)));for(let[re,G]of Y)D.has(re)||D.set(re,G)}D.size>0&&A.setVaultPrefixes(D);let K=A.parse(i);if(K.type==="update"){t==="text"&&console.log("\u{1F504} Executing SPARQL UPDATE...");let V=Date.now(),Y=new kt.UpdateExecutor(E),re=await HE(Y.execute(K),o,V),G=Date.now()-V,ne=Date.now()-s;if(t==="json"){let q=Ne.success({query:i,type:"update",results:re},{durationMs:ne,itemCount:re.length,loadDurationMs:I,execDurationMs:G,triplesScanned:_.length,cacheHit:v});console.log(JSON.stringify(q,null,2))}else tJ(re,e.format),console.log(),console.log("\u26A0\uFE0F Changes applied to in-memory store only (not persisted to vault files)"),e.stats&&(console.log(`
613
- \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${I}ms${v?" (from cache)":""}`),console.log(` Query execution: ${G}ms`),console.log(` Total time: ${ne}ms`),console.log(` Triples scanned: ${_.length}`));return}t==="text"&&console.log("\u{1F504} Translating to algebra...");let me=new kt.ExoQLAlgebraTranslator().translate(K);if(!e.noOptimize&&me.type!=="construct")me=new kt.AlgebraOptimizer().optimize(me);else if(!e.noOptimize&&me.type==="construct"){let V=new kt.AlgebraOptimizer,Y=me;me={...Y,where:V.optimize(Y.where)}}if(e.explain&&t==="text"){console.log("\u{1F4CA} Query Plan:");let V=new kt.AlgebraSerializer;if(me.type==="construct"){let Y=me;console.log("CONSTRUCT Template:"),console.log(" (template patterns)"),console.log("WHERE:"),console.log(V.toString(Y.where))}else console.log(V.toString(me));console.log()}let N=Date.now(),Q=new kt.ExoQLQueryExecutor(E);typeof Q.setTimeout=="function"&&Q.setTimeout(o);let ie=t==="text"?new ry("Executing query",{delayMs:2e3}):null;if(Q.isConstructQuery(me)){ie?.start();let V=await HE(Q.executeConstruct(me),o,N),Y=Date.now()-N;ie?.stop();let re=Date.now()-s;if(u){let G=new eu,ne={type:"construct",count:V.length,triples:JSON.parse(G.formatJson(V))};await new ru().set(i,ne,l)}if(t==="json"){let G=new eu,ne={query:i,count:V.length,triples:JSON.parse(G.formatJson(V))},q=Ne.success(ne,{durationMs:re,itemCount:V.length,loadDurationMs:I,execDurationMs:Y,triplesScanned:_.length,cacheHit:v,queryResultCacheHit:!1});console.log(JSON.stringify(q,null,2))}else console.log(`\u2705 Generated ${V.length} triple(s) in ${Y}ms
611
+ `),ZK(G.triples,e.format))}return}}if(!(0,lu.existsSync)(f))throw new pe(f);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${f}...`);let d=Date.now(),h=e.also||[],p=await ua({profileUid:e.profile,primaryVaultPath:f,alsoVaultPaths:h.map(V=>(0,cl.resolve)(V)),outputFormat:t}),g=e.useCache??!1;g&&p!==null&&(t==="text"&&console.log("\u26A0\uFE0F --use-cache disabled because --profile is active (cache is not profile-aware; MVP limitation)."),g=!1);let _=[],v=!1,w=!1;if(g&&h.length>0&&p===null){let V=new tu(f,h.map(re=>(0,cl.resolve)(re))),X=await V.loadIfValid();X!==null?(_=X.triples,v=!0,w=!0,t==="text"&&console.log(`\u{1F680} Combined cache hit! Loaded ${_.length} triples from cross-vault index (${V.getAllVaultPaths().length} vaults).`)):t==="text"&&console.log("\u2139\uFE0F Combined cache miss (or invalid). Falling back to per-vault load. Run `exocortex sparql index --vault <primary> --also <...>` to build the cross-vault index.")}if(!w){let V=[],X=[];for(let re of h){let G=(0,cl.resolve)(re);if(!(0,lu.existsSync)(G))throw new pe(G);let ie=uy(G);V.push(new xt(G,{subjectIriPrefix:ie})),X.push({resolvedAlsoPath:G,subjectIriPrefix:ie})}if(g){let G=await new di(f).loadOrBuild();_=G.triples,v=G.cacheHit,t==="text"&&v&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let re=new xt(f,{siblingAdapters:V});_=await new kt.NoteToRDFConverter(re).convertVault(p!==null?{effectiveOntologies:p.effective,assetSpaceFolderToUid:p.folderMap}:{})}for(let re=0;re<V.length;re++){let G=V[re],{resolvedAlsoPath:ie,subjectIriPrefix:q}=X[re];t==="text"&&console.log(`\u{1F4E6} Loading additional vault: ${ie}...`);let B=await new kt.NoteToRDFConverter(G,void 0,{subjectIriPrefix:q}).convertVault(p!==null?{effectiveOntologies:p.effective,assetSpaceFolderToUid:p.folderMap}:{});_=_.concat(B),t==="text"&&console.log(` \u2795 Added ${B.length} triples from ${ie}`)}if(h.length>0&&(_=fy(_),sl())){let re=new xt(f,{siblingAdapters:V}),G=Hg([re,...V]),ie=kt.IRICanonicalizer.canonicalize(_,G);_=ie.triples,t==="text"&&ie.remapCount>0&&console.log(` \u{1FA84} IRI canonicalization (Issue #3286): remapped ${ie.remapCount} triple(s) covering ${ie.uniqueRemapCount} distinct synth-A IRI(s)`)}}let E=new kt.InMemoryTripleStore;await E.addAll(_);let I=Date.now()-d;if(t==="text"){let V=v?" (from cache)":"",X=h.length>0?` (${h.length+1} vaults)`:"";console.log(`\u2705 Loaded ${_.length} triples in ${I}ms${V}${X}
612
+ `),console.log("\u{1F50D} Parsing SPARQL query...")}let O=new kt.ExoQLParser;i=ou(i),i=la(i);let C=ca(aa(f));for(let V of h){let X=ca(aa((0,cl.resolve)(V)));for(let[re,G]of X)C.has(re)||C.set(re,G)}C.size>0&&O.setVaultPrefixes(C);let H=O.parse(i);if(H.type==="update"){t==="text"&&console.log("\u{1F504} Executing SPARQL UPDATE...");let V=Date.now(),X=new kt.UpdateExecutor(E),re=await HE(X.execute(H),o,V),G=Date.now()-V,ie=Date.now()-s;if(t==="json"){let q=Ne.success({query:i,type:"update",results:re},{durationMs:ie,itemCount:re.length,loadDurationMs:I,execDurationMs:G,triplesScanned:_.length,cacheHit:v});console.log(JSON.stringify(q,null,2))}else tJ(re,e.format),console.log(),console.log("\u26A0\uFE0F Changes applied to in-memory store only (not persisted to vault files)"),e.stats&&(console.log(`
613
+ \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${I}ms${v?" (from cache)":""}`),console.log(` Query execution: ${G}ms`),console.log(` Total time: ${ie}ms`),console.log(` Triples scanned: ${_.length}`));return}t==="text"&&console.log("\u{1F504} Translating to algebra...");let de=new kt.ExoQLAlgebraTranslator().translate(H);if(!e.noOptimize&&de.type!=="construct")de=new kt.AlgebraOptimizer().optimize(de);else if(!e.noOptimize&&de.type==="construct"){let V=new kt.AlgebraOptimizer,X=de;de={...X,where:V.optimize(X.where)}}if(e.explain&&t==="text"){console.log("\u{1F4CA} Query Plan:");let V=new kt.AlgebraSerializer;if(de.type==="construct"){let X=de;console.log("CONSTRUCT Template:"),console.log(" (template patterns)"),console.log("WHERE:"),console.log(V.toString(X.where))}else console.log(V.toString(de));console.log()}let N=Date.now(),Y=new kt.ExoQLQueryExecutor(E);typeof Y.setTimeout=="function"&&Y.setTimeout(o);let se=t==="text"?new ry("Executing query",{delayMs:2e3}):null;if(Y.isConstructQuery(de)){se?.start();let V=await HE(Y.executeConstruct(de),o,N),X=Date.now()-N;se?.stop();let re=Date.now()-s;if(u){let G=new eu,ie={type:"construct",count:V.length,triples:JSON.parse(G.formatJson(V))};await new ru().set(i,ie,l)}if(t==="json"){let G=new eu,ie={query:i,count:V.length,triples:JSON.parse(G.formatJson(V))},q=Ne.success(ie,{durationMs:re,itemCount:V.length,loadDurationMs:I,execDurationMs:X,triplesScanned:_.length,cacheHit:v,queryResultCacheHit:!1});console.log(JSON.stringify(q,null,2))}else console.log(`\u2705 Generated ${V.length} triple(s) in ${X}ms
614
614
  `),V.length>0?KK(V,e.format):console.log("No triples generated."),e.stats&&(console.log(`
615
- \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${I}ms${v?" (from cache)":""}`),console.log(` Query execution: ${Y}ms`),console.log(` Total time: ${re}ms`),console.log(` Triples scanned: ${_.length}`),console.log(` Triples generated: ${V.length}`),e.useCache&&console.log(` Triple cache: ${v?"HIT":"MISS (rebuilt)"}`),u&&console.log(" Query result cache: MISS (cached for next run)"))}else{ie?.start();let V=await HE(Q.executeAll(me),o,N),Y=Date.now()-N;ie?.stop();let re=Date.now()-s,G=V.map(ne=>ne.toJSON());if(u){let ne={type:"select",count:V.length,bindings:G};await new ru().set(i,ne,l)}if(t==="json"){let ne={query:i,count:V.length,bindings:G},q=Ne.success(ne,{durationMs:re,itemCount:V.length,loadDurationMs:I,execDurationMs:Y,triplesScanned:_.length,cacheHit:v,queryResultCacheHit:!1});console.log(JSON.stringify(q,null,2))}else console.log(`\u2705 Found ${V.length} result(s) in ${Y}ms
615
+ \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${I}ms${v?" (from cache)":""}`),console.log(` Query execution: ${X}ms`),console.log(` Total time: ${re}ms`),console.log(` Triples scanned: ${_.length}`),console.log(` Triples generated: ${V.length}`),e.useCache&&console.log(` Triple cache: ${v?"HIT":"MISS (rebuilt)"}`),u&&console.log(" Query result cache: MISS (cached for next run)"))}else{se?.start();let V=await HE(Y.executeAll(de),o,N),X=Date.now()-N;se?.stop();let re=Date.now()-s,G=V.map(ie=>ie.toJSON());if(u){let ie={type:"select",count:V.length,bindings:G};await new ru().set(i,ie,l)}if(t==="json"){let ie={query:i,count:V.length,bindings:G},q=Ne.success(ie,{durationMs:re,itemCount:V.length,loadDurationMs:I,execDurationMs:X,triplesScanned:_.length,cacheHit:v,queryResultCacheHit:!1});console.log(JSON.stringify(q,null,2))}else console.log(`\u2705 Found ${V.length} result(s) in ${X}ms
616
616
  `),V.length>0?XK(V,e.format):console.log("No results found."),e.stats&&(console.log(`
617
- \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${I}ms${v?" (from cache)":""}`),console.log(` Query execution: ${Y}ms`),console.log(` Total time: ${re}ms`),console.log(` Triples scanned: ${_.length}`),console.log(` Results returned: ${V.length}`),e.useCache&&console.log(` Triple cache: ${v?"HIT":"MISS (rebuilt)"}`),u&&console.log(" Query result cache: MISS (cached for next run)"))}}catch(s){ND(s,i,t)}finally{e.strict&&(r===void 0?delete process.env.EXOCORTEX_SPARQL_STRICT:process.env.EXOCORTEX_SPARQL_STRICT=r)}})}a(LD,"sparqlQueryCommand");function ND(n,e,t){let r=new oy;if(r.classifyError(n)!=="unknown"){let s=r.enhanceError(n,e);if(t==="json"){let o=Ne.error("VALIDATION_INVALID_FORMAT",s.message,2,{context:{errorType:s.type,suggestions:s.suggestions,line:s.line,column:s.column,queryContext:s.context?{startLine:s.context.startLine,endLine:s.context.endLine,errorLine:s.context.errorLine}:void 0},recovery:{message:s.suggestions?.[0]||"Check query syntax"}});console.log(JSON.stringify(o,null,2)),process.exit(2)}else console.error(r.formatForText(s)),process.exit(2)}se.handle(n)}a(ND,"handleSparqlError");function QK(n){if(n.includes("SELECT")||n.includes("CONSTRUCT")||n.includes("INSERT")||n.includes("DELETE"))return n;let e=(0,cl.resolve)(n);return(0,lu.existsSync)(e)?(0,lu.readFileSync)(e,"utf-8"):n}a(QK,"loadQuery");async function YK(n,e,t){if(e.explain){let i=new ny,s=await i.analyze(n,{includeAlgebraPlan:!0,optimize:!e.noOptimize});if(t==="json"){let o=Ne.success(s);console.log(JSON.stringify(o,null,2))}else s.valid?(console.log(`\u2705 Query syntax is valid
618
- `),console.log(i.formatAnalysis(s,"text"))):(console.log(i.formatAnalysis(s,"text")),process.exit(2));return}let r=new kt.ExoQLParser;try{let i=r.parse(n);if(i.type!=="update"){let o=new kt.ExoQLAlgebraTranslator().translate(i);if(!e.noOptimize&&o.type!=="construct")o=new kt.AlgebraOptimizer().optimize(o);else if(!e.noOptimize&&o.type==="construct"){let l=new kt.AlgebraOptimizer,c=o;o={...c,where:l.optimize(c.where)}}}if(t==="json"){let s=Ne.success({valid:!0,queryType:DD(i),message:"Query syntax is valid"});console.log(JSON.stringify(s,null,2))}else console.log("\u2705 Query syntax is valid"),console.log(` Query type: ${DD(i)}`)}catch(i){ND(i,n,t)}}a(YK,"executeDryRun");function DD(n){return n.type==="update"?"UPDATE":"queryType"in n?n.queryType:"UNKNOWN"}a(DD,"getQueryType");function XK(n,e){switch(e){case"json":let t=new Zc;console.log(t.format(n));break;case"csv":let r=new zg;console.log(r.format(n));break;case"table":default:let i=new Jc;console.log(i.format(n));break}}a(XK,"formatSelectResults");function KK(n,e){let t=new eu;switch(e){case"json":console.log(t.formatJson(n));break;case"ntriples":console.log(t.formatNTriples(n));break;case"table":default:console.log(t.formatTable(n));break}}a(KK,"formatConstructResults");function JK(n,e){switch(e){case"json":console.log(JSON.stringify(n,null,2));break;case"csv":if(n.length===0){console.log("");return}let t=Object.keys(n[0]);console.log(t.join(","));for(let i of n){let s=t.map(o=>{let l=i[o];return l==null?"":String(l).includes(",")?`"${l}"`:String(l)});console.log(s.join(","))}break;case"table":default:if(n.length===0){console.log("No results.");return}let r=Object.keys(n[0]);console.log(r.join(" ")),console.log(r.map(()=>"---").join(" "));for(let i of n){let s=r.map(o=>String(i[o]??""));console.log(s.join(" "))}break}}a(JK,"formatCachedSelectResults");function ZK(n,e){switch(e){case"json":console.log(JSON.stringify(n,null,2));break;case"ntriples":for(let t of n)console.log(`<${t.subject}> <${t.predicate}> ${eJ(t.object)} .`);break;case"table":default:console.log("Subject Predicate Object"),console.log("--- --- ---");for(let t of n)console.log(`${t.subject} ${t.predicate} ${t.object}`);break}}a(ZK,"formatCachedConstructResults");function eJ(n){return ay.formatObject(n)}a(eJ,"formatNTriplesObject");function tJ(n,e){for(let t of n){let r=[`${t.type.toUpperCase()}`];switch(t.inserted!==void 0&&r.push(`inserted: ${t.inserted}`),t.deleted!==void 0&&r.push(`deleted: ${t.deleted}`),r.push(t.success?"OK":"FAILED"),e){case"json":console.log(JSON.stringify(t,null,2));break;case"csv":n.indexOf(t)===0&&console.log("type,inserted,deleted,success"),console.log(`${t.type},${t.inserted??""},${t.deleted??""},${t.success}`);break;case"table":default:console.log(`\u2705 ${r.join(" | ")}`);break}}}a(tJ,"formatUpdateResults");var XE=require("fs"),KE=require("path"),xs=Z(It());var QE=require("fs"),YE=require("path"),Sn=Z(It());async function kD(n,e,t={}){let r=t.silent??!1,i=t.log??(w=>console.log(w)),s=(0,YE.resolve)(n);if(!(0,QE.existsSync)(s))throw new he(s);let o=[];for(let w of e){let E=(0,YE.resolve)(w);if(!(0,QE.existsSync)(E))throw new he(E);E===s||o.includes(E)||o.push(E)}let l=[],c=[];for(let w of o){let E=uy(w);l.push(new xt(w,{subjectIriPrefix:E})),c.push(E)}r||i(`\u{1F4E6} Loading primary vault: ${s}...`);let u=[],f=new xt(s,{siblingAdapters:l}),h=await new Sn.NoteToRDFConverter(f).convertVault();u=u.concat(h),r||i(` \u2795 Added ${h.length} triples from primary vault`);for(let w=0;w<l.length;w++){let E=o[w],I=l[w],A=c[w];r||i(`\u{1F4E6} Loading additional vault: ${E}...`);let K=await new Sn.NoteToRDFConverter(I,void 0,{subjectIriPrefix:A}).convertVault();u=u.concat(K),r||i(` \u2795 Added ${K.length} triples from ${E}`)}let p=u.length,g=0;if(o.length>0){let w=u.length;u=fy(u),g=u.length-w,!r&&g>0&&i(` \u{1F517} Cross-vault Instance_class resolution: emitted ${g} canonical-IRI triple(s)`)}let _=0;if(sl()&&o.length>0){let w=Hg([f,...l]),E=Sn.IRICanonicalizer.canonicalize(u,w);u=E.triples,_=E.remapCount,!r&&_>0&&i(` \u{1FA84} IRI canonicalization (Issue #3286): remapped ${_} triple(s) covering ${E.uniqueRemapCount} distinct synth-A IRI(s)`)}let v=0;if(t.noInference!==!0){let w=new Sn.InMemoryTripleStore;await w.addAll(u);let I=await new Sn.RDFSInferenceEngine().materialize(w);v+=I;let A=new Sn.NonInheritablePropertyRegistry;await A.initialize(w);let D=new Sn.PropertyCardinalityRegistry;await D.initialize(w);let oe=await new Sn.PrototypeChainMaterializer(A,D).materialize(w);v+=oe,v>0&&(u=await w.match(),r||i(`\u{1F9E0} Materialized ${v} inferred triples on combined store (RDFS + prototype chain)`))}return{triples:u,rawTripleCount:p,crossVaultAddedTripleCount:g,inferredTripleCount:v,canonicalizedTripleCount:_}}a(kD,"buildCombinedTriples");function rJ(n,e){return e.concat([n])}a(rJ,"collectAlso");function MD(){return new ce("index").description("Build or refresh the triple cache for faster SPARQL queries").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to include in combined index (repeatable, Issue #3281)",rJ,[]).option("--output <type>","Response format: text|json (for MCP tools)","text").option("--stats","Show cache statistics after building").option("--force","Force rebuild even if cache is valid").option("--strict","Fail on first invalid IRI instead of skipping").option("--no-inference","Disable RDFS subClassOf inference materialization").action(async n=>{let e=n.output||"text";se.setFormat(e);try{let t=(0,KE.resolve)(n.vault);if(!(0,XE.existsSync)(t))throw new he(t);let r=n.also??[];if(r.length>0){await nJ(t,r,n,e);return}let i=new di(t),s=i.getCachePath();n.force&&(e==="text"&&console.log("\u{1F5D1}\uFE0F Invalidating existing cache..."),await i.invalidate()),e==="text"&&console.log(`\u{1F4E6} Building triple cache for: ${t}...`);let o=Date.now(),l=await i.buildCacheWithValidation({strict:n.strict??!1}),c=0;if(n.inference!==!1){let{triples:f}=await i.loadOrBuild(),d=new xs.InMemoryTripleStore;await d.addAll(f),c=await new xs.RDFSInferenceEngine().materialize(d);let p=new xs.NonInheritablePropertyRegistry;await p.initialize(d);let g=new xs.PropertyCardinalityRegistry;await g.initialize(d);let v=await new xs.PrototypeChainMaterializer(p,g).materialize(d);if(c+=v,c>0){let w=await d.match();await i.saveTriples(w),l.tripleCount+=c}e==="text"&&c>0&&console.log(`\u{1F9E0} Materialized ${c} inferred triples (RDFS + prototype chain)`)}let u=Date.now()-o;if(e==="json"){let f={action:"build",cachePath:s,tripleCount:l.tripleCount,durationMs:l.durationMs},d={summary:l.summary,skippedFiles:l.skippedFiles};if(n.stats){let h=await i.getCacheStats();if(h){let p={tripleCount:h.tripleCount,createdAt:h.createdAt.toISOString(),isValid:h.isValid,sizeBytes:h.sizeBytes,cachePath:s},g=Ne.success({cache:f,stats:p,validation:d},{durationMs:u});console.log(JSON.stringify(g,null,2))}}else{let h=Ne.success({cache:f,validation:d},{durationMs:u});console.log(JSON.stringify(h,null,2))}}else{if(l.skippedFiles.length>0){console.log(`
617
+ \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${I}ms${v?" (from cache)":""}`),console.log(` Query execution: ${X}ms`),console.log(` Total time: ${re}ms`),console.log(` Triples scanned: ${_.length}`),console.log(` Results returned: ${V.length}`),e.useCache&&console.log(` Triple cache: ${v?"HIT":"MISS (rebuilt)"}`),u&&console.log(" Query result cache: MISS (cached for next run)"))}}catch(s){ND(s,i,t)}finally{e.strict&&(r===void 0?delete process.env.EXOCORTEX_SPARQL_STRICT:process.env.EXOCORTEX_SPARQL_STRICT=r)}})}a(LD,"sparqlQueryCommand");function ND(n,e,t){let r=new oy;if(r.classifyError(n)!=="unknown"){let s=r.enhanceError(n,e);if(t==="json"){let o=Ne.error("VALIDATION_INVALID_FORMAT",s.message,2,{context:{errorType:s.type,suggestions:s.suggestions,line:s.line,column:s.column,queryContext:s.context?{startLine:s.context.startLine,endLine:s.context.endLine,errorLine:s.context.errorLine}:void 0},recovery:{message:s.suggestions?.[0]||"Check query syntax"}});console.log(JSON.stringify(o,null,2)),process.exit(2)}else console.error(r.formatForText(s)),process.exit(2)}oe.handle(n)}a(ND,"handleSparqlError");function QK(n){if(n.includes("SELECT")||n.includes("CONSTRUCT")||n.includes("INSERT")||n.includes("DELETE"))return n;let e=(0,cl.resolve)(n);return(0,lu.existsSync)(e)?(0,lu.readFileSync)(e,"utf-8"):n}a(QK,"loadQuery");async function YK(n,e,t){if(e.explain){let i=new ny,s=await i.analyze(n,{includeAlgebraPlan:!0,optimize:!e.noOptimize});if(t==="json"){let o=Ne.success(s);console.log(JSON.stringify(o,null,2))}else s.valid?(console.log(`\u2705 Query syntax is valid
618
+ `),console.log(i.formatAnalysis(s,"text"))):(console.log(i.formatAnalysis(s,"text")),process.exit(2));return}let r=new kt.ExoQLParser;try{let i=r.parse(n);if(i.type!=="update"){let o=new kt.ExoQLAlgebraTranslator().translate(i);if(!e.noOptimize&&o.type!=="construct")o=new kt.AlgebraOptimizer().optimize(o);else if(!e.noOptimize&&o.type==="construct"){let l=new kt.AlgebraOptimizer,c=o;o={...c,where:l.optimize(c.where)}}}if(t==="json"){let s=Ne.success({valid:!0,queryType:DD(i),message:"Query syntax is valid"});console.log(JSON.stringify(s,null,2))}else console.log("\u2705 Query syntax is valid"),console.log(` Query type: ${DD(i)}`)}catch(i){ND(i,n,t)}}a(YK,"executeDryRun");function DD(n){return n.type==="update"?"UPDATE":"queryType"in n?n.queryType:"UNKNOWN"}a(DD,"getQueryType");function XK(n,e){switch(e){case"json":let t=new Zc;console.log(t.format(n));break;case"csv":let r=new zg;console.log(r.format(n));break;case"table":default:let i=new Jc;console.log(i.format(n));break}}a(XK,"formatSelectResults");function KK(n,e){let t=new eu;switch(e){case"json":console.log(t.formatJson(n));break;case"ntriples":console.log(t.formatNTriples(n));break;case"table":default:console.log(t.formatTable(n));break}}a(KK,"formatConstructResults");function JK(n,e){switch(e){case"json":console.log(JSON.stringify(n,null,2));break;case"csv":if(n.length===0){console.log("");return}let t=Object.keys(n[0]);console.log(t.join(","));for(let i of n){let s=t.map(o=>{let l=i[o];return l==null?"":String(l).includes(",")?`"${l}"`:String(l)});console.log(s.join(","))}break;case"table":default:if(n.length===0){console.log("No results.");return}let r=Object.keys(n[0]);console.log(r.join(" ")),console.log(r.map(()=>"---").join(" "));for(let i of n){let s=r.map(o=>String(i[o]??""));console.log(s.join(" "))}break}}a(JK,"formatCachedSelectResults");function ZK(n,e){switch(e){case"json":console.log(JSON.stringify(n,null,2));break;case"ntriples":for(let t of n)console.log(`<${t.subject}> <${t.predicate}> ${eJ(t.object)} .`);break;case"table":default:console.log("Subject Predicate Object"),console.log("--- --- ---");for(let t of n)console.log(`${t.subject} ${t.predicate} ${t.object}`);break}}a(ZK,"formatCachedConstructResults");function eJ(n){return ay.formatObject(n)}a(eJ,"formatNTriplesObject");function tJ(n,e){for(let t of n){let r=[`${t.type.toUpperCase()}`];switch(t.inserted!==void 0&&r.push(`inserted: ${t.inserted}`),t.deleted!==void 0&&r.push(`deleted: ${t.deleted}`),r.push(t.success?"OK":"FAILED"),e){case"json":console.log(JSON.stringify(t,null,2));break;case"csv":n.indexOf(t)===0&&console.log("type,inserted,deleted,success"),console.log(`${t.type},${t.inserted??""},${t.deleted??""},${t.success}`);break;case"table":default:console.log(`\u2705 ${r.join(" | ")}`);break}}}a(tJ,"formatUpdateResults");var XE=require("fs"),KE=require("path"),xs=Z(It());var QE=require("fs"),YE=require("path"),Sn=Z(It());async function kD(n,e,t={}){let r=t.silent??!1,i=t.log??(w=>console.log(w)),s=(0,YE.resolve)(n);if(!(0,QE.existsSync)(s))throw new pe(s);let o=[];for(let w of e){let E=(0,YE.resolve)(w);if(!(0,QE.existsSync)(E))throw new pe(E);E===s||o.includes(E)||o.push(E)}let l=[],c=[];for(let w of o){let E=uy(w);l.push(new xt(w,{subjectIriPrefix:E})),c.push(E)}r||i(`\u{1F4E6} Loading primary vault: ${s}...`);let u=[],f=new xt(s,{siblingAdapters:l}),h=await new Sn.NoteToRDFConverter(f).convertVault();u=u.concat(h),r||i(` \u2795 Added ${h.length} triples from primary vault`);for(let w=0;w<l.length;w++){let E=o[w],I=l[w],O=c[w];r||i(`\u{1F4E6} Loading additional vault: ${E}...`);let H=await new Sn.NoteToRDFConverter(I,void 0,{subjectIriPrefix:O}).convertVault();u=u.concat(H),r||i(` \u2795 Added ${H.length} triples from ${E}`)}let p=u.length,g=0;if(o.length>0){let w=u.length;u=fy(u),g=u.length-w,!r&&g>0&&i(` \u{1F517} Cross-vault Instance_class resolution: emitted ${g} canonical-IRI triple(s)`)}let _=0;if(sl()&&o.length>0){let w=Hg([f,...l]),E=Sn.IRICanonicalizer.canonicalize(u,w);u=E.triples,_=E.remapCount,!r&&_>0&&i(` \u{1FA84} IRI canonicalization (Issue #3286): remapped ${_} triple(s) covering ${E.uniqueRemapCount} distinct synth-A IRI(s)`)}let v=0;if(t.noInference!==!0){let w=new Sn.InMemoryTripleStore;await w.addAll(u);let I=await new Sn.RDFSInferenceEngine().materialize(w);v+=I;let O=new Sn.NonInheritablePropertyRegistry;await O.initialize(w);let C=new Sn.PropertyCardinalityRegistry;await C.initialize(w);let ne=await new Sn.PrototypeChainMaterializer(O,C).materialize(w);v+=ne,v>0&&(u=await w.match(),r||i(`\u{1F9E0} Materialized ${v} inferred triples on combined store (RDFS + prototype chain)`))}return{triples:u,rawTripleCount:p,crossVaultAddedTripleCount:g,inferredTripleCount:v,canonicalizedTripleCount:_}}a(kD,"buildCombinedTriples");function rJ(n,e){return e.concat([n])}a(rJ,"collectAlso");function MD(){return new ce("index").description("Build or refresh the triple cache for faster SPARQL queries").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to include in combined index (repeatable, Issue #3281)",rJ,[]).option("--output <type>","Response format: text|json (for MCP tools)","text").option("--stats","Show cache statistics after building").option("--force","Force rebuild even if cache is valid").option("--strict","Fail on first invalid IRI instead of skipping").option("--no-inference","Disable RDFS subClassOf inference materialization").action(async n=>{let e=n.output||"text";oe.setFormat(e);try{let t=(0,KE.resolve)(n.vault);if(!(0,XE.existsSync)(t))throw new pe(t);let r=n.also??[];if(r.length>0){await nJ(t,r,n,e);return}let i=new di(t),s=i.getCachePath();n.force&&(e==="text"&&console.log("\u{1F5D1}\uFE0F Invalidating existing cache..."),await i.invalidate()),e==="text"&&console.log(`\u{1F4E6} Building triple cache for: ${t}...`);let o=Date.now(),l=await i.buildCacheWithValidation({strict:n.strict??!1}),c=0;if(n.inference!==!1){let{triples:f}=await i.loadOrBuild(),d=new xs.InMemoryTripleStore;await d.addAll(f),c=await new xs.RDFSInferenceEngine().materialize(d);let p=new xs.NonInheritablePropertyRegistry;await p.initialize(d);let g=new xs.PropertyCardinalityRegistry;await g.initialize(d);let v=await new xs.PrototypeChainMaterializer(p,g).materialize(d);if(c+=v,c>0){let w=await d.match();await i.saveTriples(w),l.tripleCount+=c}e==="text"&&c>0&&console.log(`\u{1F9E0} Materialized ${c} inferred triples (RDFS + prototype chain)`)}let u=Date.now()-o;if(e==="json"){let f={action:"build",cachePath:s,tripleCount:l.tripleCount,durationMs:l.durationMs},d={summary:l.summary,skippedFiles:l.skippedFiles};if(n.stats){let h=await i.getCacheStats();if(h){let p={tripleCount:h.tripleCount,createdAt:h.createdAt.toISOString(),isValid:h.isValid,sizeBytes:h.sizeBytes,cachePath:s},g=Ne.success({cache:f,stats:p,validation:d},{durationMs:u});console.log(JSON.stringify(g,null,2))}}else{let h=Ne.success({cache:f,validation:d},{durationMs:u});console.log(JSON.stringify(h,null,2))}}else{if(l.skippedFiles.length>0){console.log(`
619
619
  \u26A0\uFE0F Files skipped due to IRI issues:`);for(let f of l.skippedFiles)console.log(` - ${f.path}`),console.log(` ${f.reason}`);console.log("")}if(console.log(`\u2705 Indexed ${l.summary.indexed} files, skipped ${l.summary.skipped} (total: ${l.summary.total})`),console.log(`\u{1F4CA} Created cache with ${l.tripleCount.toLocaleString()} triples at ${s}`),console.log(`\u23F1\uFE0F Build time: ${l.durationMs}ms`),n.stats){let f=await i.getCacheStats();f&&(console.log(`
620
- \u{1F4CA} Cache Statistics:`),console.log(` Triples: ${f.tripleCount.toLocaleString()}`),console.log(` Created: ${f.createdAt.toISOString()}`),console.log(` Valid: ${f.isValid?"\u2705 Yes":"\u274C No"}`),console.log(` Size: ${jD(f.sizeBytes)}`))}}}catch(t){se.handle(t)}})}a(MD,"sparqlIndexCommand");async function nJ(n,e,t,r){for(let f of e){let d=(0,KE.resolve)(f);if(!(0,XE.existsSync)(d))throw new he(d)}let i=new tu(n,e),s=i.getCachePath();t.force&&(r==="text"&&console.log("\u{1F5D1}\uFE0F Invalidating existing combined cache..."),await i.invalidate()),r==="text"&&console.log(`\u{1F4E6} Building combined triple cache (${i.getAllVaultPaths().length} vaults)...`);let o=Date.now(),l=await kD(n,e,{noInference:t.inference===!1,silent:r!=="text"});await i.saveTriples(l.triples);let c=Date.now()-o,u=l.triples.length;if(r==="json"){let f={action:"build",cachePath:s,tripleCount:u,durationMs:c};if(t.stats){let h=await i.getCacheStats();if(h){let p={tripleCount:h.tripleCount,createdAt:h.createdAt.toISOString(),isValid:h.isValid,sizeBytes:h.sizeBytes,cachePath:s},g=Ne.success({cache:f,stats:p,combined:{vaultPaths:i.getAllVaultPaths(),rawTripleCount:l.rawTripleCount,crossVaultAddedTripleCount:l.crossVaultAddedTripleCount,inferredTripleCount:l.inferredTripleCount,canonicalizedTripleCount:l.canonicalizedTripleCount}},{durationMs:c});console.log(JSON.stringify(g,null,2));return}}let d=Ne.success({cache:f,combined:{vaultPaths:i.getAllVaultPaths(),rawTripleCount:l.rawTripleCount,crossVaultAddedTripleCount:l.crossVaultAddedTripleCount,inferredTripleCount:l.inferredTripleCount,canonicalizedTripleCount:l.canonicalizedTripleCount}},{durationMs:c});console.log(JSON.stringify(d,null,2))}else if(console.log(`\u{1F4CA} Created combined cache with ${u.toLocaleString()} triples at ${s}`),console.log(`\u23F1\uFE0F Build time: ${c}ms`),t.stats){let f=await i.getCacheStats();if(f){console.log(`
621
- \u{1F4CA} Combined Cache Statistics:`),console.log(` Triples: ${f.tripleCount.toLocaleString()}`),console.log(` Created: ${f.createdAt.toISOString()}`),console.log(` Valid: ${f.isValid?"\u2705 Yes":"\u274C No"}`),console.log(` Size: ${jD(f.sizeBytes)}`),console.log(` Vaults (${f.vaultPaths.length}):`);for(let d of f.vaultPaths)console.log(` - ${d}`)}}}a(nJ,"runCombinedIndex");function jD(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}a(jD,"formatBytes");var UD=require("path");var bo=Z(require("fs")),JE=Z(require("path")),$D=require("events");var iJ={watch:bo.default.watch.bind(bo.default),existsSync:bo.default.existsSync.bind(bo.default),statSync:bo.default.statSync.bind(bo.default),readFileSync:bo.default.readFileSync.bind(bo.default)},dy=class extends $D.EventEmitter{constructor(t,r={}){super();this.watcher=null;this.debounceTimers=new Map;this.isRunning=!1;this.vaultPath=JE.default.resolve(t),this.fsAdapter=r.fsAdapter??iJ,this.options={pattern:r.pattern??"**/*.md",assetType:r.assetType??"",debounceMs:r.debounceMs??100,recursive:r.recursive??!0}}static{a(this,"FileSystemWatcher")}start(){this.isRunning||(this.watcher=this.fsAdapter.watch(this.vaultPath,{recursive:this.options.recursive},(t,r)=>{r&&this.handleFileEvent(t,r.toString())}),this.watcher.on("error",t=>{this.emit("error",t)}),this.isRunning=!0,this.emit("started"))}stop(){if(this.isRunning){for(let t of this.debounceTimers.values())clearTimeout(t);this.debounceTimers.clear(),this.watcher&&(this.watcher.close(),this.watcher=null),this.isRunning=!1,this.emit("stopped")}}isWatching(){return this.isRunning}handleFileEvent(t,r){let i=JE.default.join(this.vaultPath,r),s=r;if(!this.matchesPattern(s))return;let o=this.debounceTimers.get(i);o&&clearTimeout(o);let l=setTimeout(()=>{this.debounceTimers.delete(i),this.processFileEvent(i,s)},this.options.debounceMs);this.debounceTimers.set(i,l)}processFileEvent(t,r){let i=this.fsAdapter.existsSync(t),s;if(!i)s="delete";else{let c=this.fsAdapter.statSync(t);s=Date.now()-c.birthtimeMs<1e3?"create":"modify"}let o;if(i&&t.endsWith(".md")&&(o=this.extractAssetType(t)),this.options.assetType&&o!==this.options.assetType)return;let l={type:s,path:t,relativePath:r,timestamp:new Date().toISOString(),assetType:o};this.emit("change",l)}matchesPattern(t){return this.options.pattern?Vr(t,this.options.pattern):!0}extractAssetType(t){try{let i=this.fsAdapter.readFileSync(t,"utf-8").match(/^---\n([\s\S]*?)\n---/);if(!i)return;let o=i[1].match(/exo__Instance_class:\s*(?:\[?"?\[\[([^\]]+)\]\]"?\]?|"?\[\[([^\]]+)\]\]"?)/);return o?o[1]||o[2]:void 0}catch{return}}};var ZE=Z(require("fs"));function VD(){return new ce("watch").description("Watch vault for file changes and emit NDJSON events").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--pattern <glob>","Glob pattern to filter files (e.g., '*.md', 'tasks/**')").option("--asset-type <type>","Filter by asset type (e.g., 'ems__Task', 'ems__Project')").option("--debounce <ms>","Debounce interval in milliseconds","100").action(async n=>{se.setFormat("json");try{let e=(0,UD.resolve)(n.vault);if(!ZE.default.existsSync(e))throw new he(e);if(!ZE.default.statSync(e).isDirectory())throw new it(`Vault path is not a directory: ${e}`,"Provide a path to a directory, not a file",{vaultPath:e});let t=parseInt(n.debounce?.toString()??"100",10);if(isNaN(t)||t<0)throw new it("--debounce must be a non-negative integer","Use a positive integer value for debounce",{debounce:n.debounce});let r=new dy(e,{pattern:n.pattern,assetType:n.assetType,debounceMs:t});r.on("change",s=>{console.log(JSON.stringify(s))}),r.on("error",s=>{let o=Ne.error("INTERNAL_OPERATION_FAILED",s.message,5,{recovery:{message:"Check file permissions and vault access",suggestion:"Ensure the vault directory is accessible"}});console.log(JSON.stringify(o))});let i=a(()=>{r.stop(),process.exit(0)},"shutdown");process.on("SIGINT",i),process.on("SIGTERM",i),console.error(`Watching vault: ${e}`),n.pattern&&console.error(` Pattern filter: ${n.pattern}`),n.assetType&&console.error(` Asset type filter: ${n.assetType}`),console.error(` Debounce: ${t}ms`),console.error("Press Ctrl+C to stop"),r.start()}catch(e){se.handle(e)}})}a(VD,"watchCommand");var hy=require("fs"),Hi=require("path");function BD(){return new ce("resolve").description("Resolve UUID to file path").argument("<uuid>","Full or partial UUID to resolve").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: uri|path|json (default: uri)","uri").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--partial","Match partial UUIDs (returns all matches)").action(async(n,e)=>{let t=e.output||"text";se.setFormat(t);try{let r=Date.now();if(!sJ(n))throw new it(`Invalid UUID format: ${n}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:n});let i=(0,Hi.resolve)(e.vault);if(!(0,hy.existsSync)(i))throw new he(i);let s=oJ(i,n,e.partial??!1),o=Date.now()-r;if(s.length===0){if(t==="json"){let l=Ne.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${n}`,3,{context:{uuid:n}});console.log(JSON.stringify(l,null,2))}else console.error(`UUID not found: ${n}`);process.exit(1)}e.partial||s.length>1?lJ(s,i,e.format,t,n,o):aJ(s[0],i,e.format,t,n,o)}catch(r){se.handle(r)}})}a(BD,"resolveCommand");function sJ(n){if(n.length<4)return!1;let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,t=/^[0-9a-f-]+$/i;return e.test(n)||t.test(n)}a(sJ,"isValidUuidFormat");function oJ(n,e,t){let r=[],i=e.toLowerCase();function s(o){let l=(0,hy.readdirSync)(o,{withFileTypes:!0});for(let c of l){let u=(0,Hi.join)(o,c.name);if(c.isDirectory())!c.name.startsWith(".")&&c.name!=="node_modules"&&s(u);else if(c.isFile()&&c.name.endsWith(".md")){let f=c.name.toLowerCase();t?f.includes(i)&&r.push(u):(f.startsWith(i+".md")||f.startsWith(i+" ")||f.startsWith(i+"-"))&&r.push(u)}}}return a(s,"walk"),s(n),r}a(oJ,"findFilesWithUuid");function GD(n){return`obsidian://vault/${encodeURI(n)}`}a(GD,"pathToObsidianUri");function qD(n){let e=n.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);return e?e[1]:(0,Hi.basename)(n,".md")}a(qD,"extractUuidFromFilename");function aJ(n,e,t,r,i,s){let o=(0,Hi.relative)(e,n),l=GD(o),c=qD((0,Hi.basename)(n));if(r==="json"){let u={uuid:c,path:o,absolutePath:n,uri:l},f=Ne.success(u,{durationMs:s,searchUuid:i});console.log(JSON.stringify(f,null,2))}else switch(t){case"path":console.log(n);break;case"json":console.log(JSON.stringify({uuid:c,path:o,absolutePath:n,uri:l},null,2));break;case"uri":default:console.log(l);break}}a(aJ,"outputSingleResult");function lJ(n,e,t,r,i,s){let o=n.map(l=>{let c=(0,Hi.relative)(e,l),u=GD(c);return{uuid:qD((0,Hi.basename)(l)),path:c,absolutePath:l,uri:u}});if(r==="json"){let l=Ne.success({matches:o,count:o.length},{durationMs:s,searchUuid:i,itemCount:o.length});console.log(JSON.stringify(l,null,2))}else switch(t){case"path":for(let l of o)console.log(l.absolutePath);break;case"json":console.log(JSON.stringify(o,null,2));break;case"uri":default:for(let l of o)console.log(l.uri);break}}a(lJ,"outputMultipleResults");var WD=require("fs"),zD=require("path"),Un=Z(It());function HD(){return new ce("ask").description("Ask a question in natural language about your vault").argument("<question>","Question in natural language (Russian or English)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--show-query","Show the generated SPARQL query").option("--explain","Show explanation of the query conversion").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").action(async(n,e)=>{let t=e.output||"text";se.setFormat(t);try{let r=Date.now(),i=(0,zD.resolve)(e.vault);if(!(0,WD.existsSync)(i))throw new he(i);let s=new Un.NLToSPARQLService;t==="text"&&console.log(`\u{1F9E0} Analyzing question: "${n}"
620
+ \u{1F4CA} Cache Statistics:`),console.log(` Triples: ${f.tripleCount.toLocaleString()}`),console.log(` Created: ${f.createdAt.toISOString()}`),console.log(` Valid: ${f.isValid?"\u2705 Yes":"\u274C No"}`),console.log(` Size: ${jD(f.sizeBytes)}`))}}}catch(t){oe.handle(t)}})}a(MD,"sparqlIndexCommand");async function nJ(n,e,t,r){for(let f of e){let d=(0,KE.resolve)(f);if(!(0,XE.existsSync)(d))throw new pe(d)}let i=new tu(n,e),s=i.getCachePath();t.force&&(r==="text"&&console.log("\u{1F5D1}\uFE0F Invalidating existing combined cache..."),await i.invalidate()),r==="text"&&console.log(`\u{1F4E6} Building combined triple cache (${i.getAllVaultPaths().length} vaults)...`);let o=Date.now(),l=await kD(n,e,{noInference:t.inference===!1,silent:r!=="text"});await i.saveTriples(l.triples);let c=Date.now()-o,u=l.triples.length;if(r==="json"){let f={action:"build",cachePath:s,tripleCount:u,durationMs:c};if(t.stats){let h=await i.getCacheStats();if(h){let p={tripleCount:h.tripleCount,createdAt:h.createdAt.toISOString(),isValid:h.isValid,sizeBytes:h.sizeBytes,cachePath:s},g=Ne.success({cache:f,stats:p,combined:{vaultPaths:i.getAllVaultPaths(),rawTripleCount:l.rawTripleCount,crossVaultAddedTripleCount:l.crossVaultAddedTripleCount,inferredTripleCount:l.inferredTripleCount,canonicalizedTripleCount:l.canonicalizedTripleCount}},{durationMs:c});console.log(JSON.stringify(g,null,2));return}}let d=Ne.success({cache:f,combined:{vaultPaths:i.getAllVaultPaths(),rawTripleCount:l.rawTripleCount,crossVaultAddedTripleCount:l.crossVaultAddedTripleCount,inferredTripleCount:l.inferredTripleCount,canonicalizedTripleCount:l.canonicalizedTripleCount}},{durationMs:c});console.log(JSON.stringify(d,null,2))}else if(console.log(`\u{1F4CA} Created combined cache with ${u.toLocaleString()} triples at ${s}`),console.log(`\u23F1\uFE0F Build time: ${c}ms`),t.stats){let f=await i.getCacheStats();if(f){console.log(`
621
+ \u{1F4CA} Combined Cache Statistics:`),console.log(` Triples: ${f.tripleCount.toLocaleString()}`),console.log(` Created: ${f.createdAt.toISOString()}`),console.log(` Valid: ${f.isValid?"\u2705 Yes":"\u274C No"}`),console.log(` Size: ${jD(f.sizeBytes)}`),console.log(` Vaults (${f.vaultPaths.length}):`);for(let d of f.vaultPaths)console.log(` - ${d}`)}}}a(nJ,"runCombinedIndex");function jD(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}a(jD,"formatBytes");var UD=require("path");var bo=Z(require("fs")),JE=Z(require("path")),$D=require("events");var iJ={watch:bo.default.watch.bind(bo.default),existsSync:bo.default.existsSync.bind(bo.default),statSync:bo.default.statSync.bind(bo.default),readFileSync:bo.default.readFileSync.bind(bo.default)},dy=class extends $D.EventEmitter{constructor(t,r={}){super();this.watcher=null;this.debounceTimers=new Map;this.isRunning=!1;this.vaultPath=JE.default.resolve(t),this.fsAdapter=r.fsAdapter??iJ,this.options={pattern:r.pattern??"**/*.md",assetType:r.assetType??"",debounceMs:r.debounceMs??100,recursive:r.recursive??!0}}static{a(this,"FileSystemWatcher")}start(){this.isRunning||(this.watcher=this.fsAdapter.watch(this.vaultPath,{recursive:this.options.recursive},(t,r)=>{r&&this.handleFileEvent(t,r.toString())}),this.watcher.on("error",t=>{this.emit("error",t)}),this.isRunning=!0,this.emit("started"))}stop(){if(this.isRunning){for(let t of this.debounceTimers.values())clearTimeout(t);this.debounceTimers.clear(),this.watcher&&(this.watcher.close(),this.watcher=null),this.isRunning=!1,this.emit("stopped")}}isWatching(){return this.isRunning}handleFileEvent(t,r){let i=JE.default.join(this.vaultPath,r),s=r;if(!this.matchesPattern(s))return;let o=this.debounceTimers.get(i);o&&clearTimeout(o);let l=setTimeout(()=>{this.debounceTimers.delete(i),this.processFileEvent(i,s)},this.options.debounceMs);this.debounceTimers.set(i,l)}processFileEvent(t,r){let i=this.fsAdapter.existsSync(t),s;if(!i)s="delete";else{let c=this.fsAdapter.statSync(t);s=Date.now()-c.birthtimeMs<1e3?"create":"modify"}let o;if(i&&t.endsWith(".md")&&(o=this.extractAssetType(t)),this.options.assetType&&o!==this.options.assetType)return;let l={type:s,path:t,relativePath:r,timestamp:new Date().toISOString(),assetType:o};this.emit("change",l)}matchesPattern(t){return this.options.pattern?Vr(t,this.options.pattern):!0}extractAssetType(t){try{let i=this.fsAdapter.readFileSync(t,"utf-8").match(/^---\n([\s\S]*?)\n---/);if(!i)return;let o=i[1].match(/exo__Instance_class:\s*(?:\[?"?\[\[([^\]]+)\]\]"?\]?|"?\[\[([^\]]+)\]\]"?)/);return o?o[1]||o[2]:void 0}catch{return}}};var ZE=Z(require("fs"));function VD(){return new ce("watch").description("Watch vault for file changes and emit NDJSON events").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--pattern <glob>","Glob pattern to filter files (e.g., '*.md', 'tasks/**')").option("--asset-type <type>","Filter by asset type (e.g., 'ems__Task', 'ems__Project')").option("--debounce <ms>","Debounce interval in milliseconds","100").action(async n=>{oe.setFormat("json");try{let e=(0,UD.resolve)(n.vault);if(!ZE.default.existsSync(e))throw new pe(e);if(!ZE.default.statSync(e).isDirectory())throw new it(`Vault path is not a directory: ${e}`,"Provide a path to a directory, not a file",{vaultPath:e});let t=parseInt(n.debounce?.toString()??"100",10);if(isNaN(t)||t<0)throw new it("--debounce must be a non-negative integer","Use a positive integer value for debounce",{debounce:n.debounce});let r=new dy(e,{pattern:n.pattern,assetType:n.assetType,debounceMs:t});r.on("change",s=>{console.log(JSON.stringify(s))}),r.on("error",s=>{let o=Ne.error("INTERNAL_OPERATION_FAILED",s.message,5,{recovery:{message:"Check file permissions and vault access",suggestion:"Ensure the vault directory is accessible"}});console.log(JSON.stringify(o))});let i=a(()=>{r.stop(),process.exit(0)},"shutdown");process.on("SIGINT",i),process.on("SIGTERM",i),console.error(`Watching vault: ${e}`),n.pattern&&console.error(` Pattern filter: ${n.pattern}`),n.assetType&&console.error(` Asset type filter: ${n.assetType}`),console.error(` Debounce: ${t}ms`),console.error("Press Ctrl+C to stop"),r.start()}catch(e){oe.handle(e)}})}a(VD,"watchCommand");var hy=require("fs"),Hi=require("path");function BD(){return new ce("resolve").description("Resolve UUID to file path").argument("<uuid>","Full or partial UUID to resolve").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: uri|path|json (default: uri)","uri").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--partial","Match partial UUIDs (returns all matches)").action(async(n,e)=>{let t=e.output||"text";oe.setFormat(t);try{let r=Date.now();if(!sJ(n))throw new it(`Invalid UUID format: ${n}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:n});let i=(0,Hi.resolve)(e.vault);if(!(0,hy.existsSync)(i))throw new pe(i);let s=oJ(i,n,e.partial??!1),o=Date.now()-r;if(s.length===0){if(t==="json"){let l=Ne.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${n}`,3,{context:{uuid:n}});console.log(JSON.stringify(l,null,2))}else console.error(`UUID not found: ${n}`);process.exit(1)}e.partial||s.length>1?lJ(s,i,e.format,t,n,o):aJ(s[0],i,e.format,t,n,o)}catch(r){oe.handle(r)}})}a(BD,"resolveCommand");function sJ(n){if(n.length<4)return!1;let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,t=/^[0-9a-f-]+$/i;return e.test(n)||t.test(n)}a(sJ,"isValidUuidFormat");function oJ(n,e,t){let r=[],i=e.toLowerCase();function s(o){let l=(0,hy.readdirSync)(o,{withFileTypes:!0});for(let c of l){let u=(0,Hi.join)(o,c.name);if(c.isDirectory())!c.name.startsWith(".")&&c.name!=="node_modules"&&s(u);else if(c.isFile()&&c.name.endsWith(".md")){let f=c.name.toLowerCase();t?f.includes(i)&&r.push(u):(f.startsWith(i+".md")||f.startsWith(i+" ")||f.startsWith(i+"-"))&&r.push(u)}}}return a(s,"walk"),s(n),r}a(oJ,"findFilesWithUuid");function GD(n){return`obsidian://vault/${encodeURI(n)}`}a(GD,"pathToObsidianUri");function qD(n){let e=n.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);return e?e[1]:(0,Hi.basename)(n,".md")}a(qD,"extractUuidFromFilename");function aJ(n,e,t,r,i,s){let o=(0,Hi.relative)(e,n),l=GD(o),c=qD((0,Hi.basename)(n));if(r==="json"){let u={uuid:c,path:o,absolutePath:n,uri:l},f=Ne.success(u,{durationMs:s,searchUuid:i});console.log(JSON.stringify(f,null,2))}else switch(t){case"path":console.log(n);break;case"json":console.log(JSON.stringify({uuid:c,path:o,absolutePath:n,uri:l},null,2));break;case"uri":default:console.log(l);break}}a(aJ,"outputSingleResult");function lJ(n,e,t,r,i,s){let o=n.map(l=>{let c=(0,Hi.relative)(e,l),u=GD(c);return{uuid:qD((0,Hi.basename)(l)),path:c,absolutePath:l,uri:u}});if(r==="json"){let l=Ne.success({matches:o,count:o.length},{durationMs:s,searchUuid:i,itemCount:o.length});console.log(JSON.stringify(l,null,2))}else switch(t){case"path":for(let l of o)console.log(l.absolutePath);break;case"json":console.log(JSON.stringify(o,null,2));break;case"uri":default:for(let l of o)console.log(l.uri);break}}a(lJ,"outputMultipleResults");var WD=require("fs"),zD=require("path"),Un=Z(It());function HD(){return new ce("ask").description("Ask a question in natural language about your vault").argument("<question>","Question in natural language (Russian or English)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--show-query","Show the generated SPARQL query").option("--explain","Show explanation of the query conversion").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").action(async(n,e)=>{let t=e.output||"text";oe.setFormat(t);try{let r=Date.now(),i=(0,zD.resolve)(e.vault);if(!(0,WD.existsSync)(i))throw new pe(i);let s=new Un.NLToSPARQLService;t==="text"&&console.log(`\u{1F9E0} Analyzing question: "${n}"
622
622
  `);let o=s.convert(n);e.showQuery&&t==="text"&&(console.log("\u{1F4DD} Generated SPARQL Query:"),console.log("\u2500".repeat(50)),console.log(o.query),console.log("\u2500".repeat(50)),console.log()),e.explain&&t==="text"&&(console.log(`\u{1F4D6} Explanation: ${o.explanation}`),console.log(`\u{1F3AF} Confidence: ${(o.confidence*100).toFixed(0)}%`),o.templateName&&console.log(`\u{1F4CB} Template: ${o.templateName}`),o.isFallback&&console.log("\u26A0\uFE0F Using fallback generic search query"),console.log()),t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let l=Date.now(),c=await ua({profileUid:e.profile,primaryVaultPath:i,outputFormat:t}),u=new xt(i),d=await new Un.NoteToRDFConverter(u).convertVault(c!==null?{effectiveOntologies:c.effective,assetSpaceFolderToUid:c.folderMap}:{}),h=new Un.InMemoryTripleStore;await h.addAll(d);let p=Date.now()-l;t==="text"&&console.log(`\u2705 Loaded ${d.length} triples in ${p}ms
623
- `);let g=o.query;g=ou(g),g=la(g);let _=new Un.ExoQLParser,v=ca(aa(i));v.size>0&&_.setVaultPrefixes(v);let w=_.parse(g),I=new Un.ExoQLAlgebraTranslator().translate(w);I=new Un.AlgebraOptimizer().optimize(I);let D=Date.now(),oe=await new Un.ExoQLQueryExecutor(h).executeAll(I),me=Date.now()-D,N=Date.now()-r,Q=s.getSuggestions(n);if(t==="json"){let ie=oe.map(re=>re.toJSON()),V={question:n,query:o.query,template:o.templateName,parameters:o.parameters,confidence:o.confidence,explanation:o.explanation,count:oe.length,bindings:ie,suggestions:Q.length>0?Q:void 0},Y=Ne.success(V,{durationMs:N,itemCount:oe.length,loadDurationMs:p,execDurationMs:me,triplesScanned:d.length});console.log(JSON.stringify(Y,null,2))}else{if(console.log(`\u2705 Found ${oe.length} result(s) in ${me}ms
624
- `),oe.length>0?cJ(oe,e.format):console.log("No results found."),Q.length>0){console.log(`
625
- \u{1F4A1} Suggestions:`);for(let ie of Q)console.log(` \u2022 ${ie}`)}if(o.confidence<.6&&o.alternatives.length>0){console.log(`
626
- \u{1F504} Alternative queries that might work better:`);for(let ie=0;ie<Math.min(2,o.alternatives.length);ie++)console.log(` ${ie+1}. ${o.alternatives[ie].split(`
627
- `).slice(-3)[0]?.trim()||"..."}`)}}}catch(r){se.handle(r)}})}a(HD,"askCommand");function cJ(n,e){let t=n;switch(e){case"json":let r=new Zc;console.log(r.format(t));break;case"table":default:let i=new Jc;console.log(i.format(t));break}}a(cJ,"formatResults");var uL=require("fs"),fL=require("path");var pi=require("fs"),wn=require("path"),YD=require("child_process"),Ce=Z(It());var uJ=new Set(["aliases","archived","tags","cssclasses","publish","permalink","description","image","cover","banner","title","share","share_link","share_updated","metadata","uri"]),t2=new Map([["exo__","https://exocortex.my/ontology/exo#"],["ems__","https://exocortex.my/ontology/ems#"],["exocmd__","https://exocortex.my/ontology/exocmd#"],["ims__","https://exocortex.my/ontology/ims#"],["ztlk__","https://exocortex.my/ontology/ztlk#"],["ptms__","https://exocortex.my/ontology/ptms#"],["lit__","https://exocortex.my/ontology/lit#"],["inbox__","https://exocortex.my/ontology/inbox#"],["place__","https://exocortex.my/ontology/place#"],["exoob__","https://exocortex.my/ontology/exoob#"],["pn__","https://exocortex.my/ontology/pn#"],["period__","https://exocortex.my/ontology/period#"],["rdf__","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["rdfs__","http://www.w3.org/2000/01/rdf-schema#"],["owl__","http://www.w3.org/2002/07/owl#"]]);function fJ(n,e){if(!n)return!1;let t=n.exo__Instance_class;if(t==null)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/),o=s?s[1]:i;if(o===e||o.includes(e))return!0}return!1}a(fJ,"frontmatterMatchesClass");function dJ(n,e){return e.concat([n])}a(dJ,"collectAlso");async function XD(n,e,t,r){t&&e.length>0&&(r&&console.log("\u26A0\uFE0F --use-cache is disabled when --also is specified (per-vault cache cannot represent multi-vault state)."),t=!1);let i,s=!1;if(t){let l=await new di(n).loadOrBuild();i=l.triples,s=l.cacheHit}else{let o=new xt(n);i=await new Ce.NoteToRDFConverter(o).convertVault()}for(let o of e){let l=(0,wn.resolve)(o);if(!(0,pi.existsSync)(l))throw new he(l);r&&console.log(`\u{1F4E6} Loading additional vault: ${l}...`);let c=new xt(l),f=await new Ce.NoteToRDFConverter(c).convertVault();i=i.concat(f),r&&console.log(` \u2795 Added ${f.length} triples from ${l}`)}if(e.length>0){let o=i.length;if(i=mJ(i),r){let l=i.length-o;l>0&&console.log(` \u{1F517} Cross-vault Instance_class resolution: emitted ${l} additional canonical-IRI triple(s)`)}}return{triples:i,cacheHit:s}}a(XD,"loadTriplesFromAllVaults");var QD="https://exocortex.my/ontology/exo#Instance_class",KD="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",hJ=/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i,pJ=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function mJ(n){let e=new Map;for(let i of n){if(!(i.subject instanceof Ce.DomainIRI)||!(i.predicate instanceof Ce.DomainIRI)||!(i.object instanceof Ce.DomainLiteral)||i.predicate.value!==rL&&i.predicate.value!==gJ)continue;let s=pJ.exec(i.subject.value);if(!s)continue;let o=s[1].toLowerCase();if(e.has(o))continue;let l=i.object.value.trim();if(/\s/.test(l))continue;let c=r2(l);c&&e.set(o,c)}if(e.size===0)return n;let t=new Set,r=[];for(let i of n){if(!(i.subject instanceof Ce.DomainIRI)||!(i.predicate instanceof Ce.DomainIRI)||!(i.object instanceof Ce.DomainLiteral)||i.predicate.value!==QD)continue;let s=i.object.value.trim(),o=hJ.exec(s);if(!o)continue;let l=o[1].toLowerCase(),c=e.get(l);if(!c)continue;let f=`${i.subject.value}\0${c}`;if(t.has(f))continue;t.add(f);let d=new Ce.DomainIRI(c);r.push(new Ce.DomainTriple(i.subject,new Ce.DomainIRI(QD),d)),r.push(new Ce.DomainTriple(i.subject,new Ce.DomainIRI(KD),d))}return r.length>0?n.concat(r):n}a(mJ,"resolveCrossVaultInstanceClassWikilinks");var gJ="https://exocortex.my/ontology/exo#Asset_label";function yJ(n,e){let t="obsidian://vault/",r=n;if(n.startsWith(t))r=decodeURIComponent(n.substring(t.length));else return n;for(let i of e){let s=(0,wn.join)(i,r);if((0,pi.existsSync)(s))return s}return(0,wn.join)(e[0]??"",r)}a(yJ,"qualifyFocusNodePath");function JD(n){let e=n.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!e)return n.match(/^---\r?\n---/)?{}:null;let t=e[1].split(`
623
+ `);let g=o.query;g=ou(g),g=la(g);let _=new Un.ExoQLParser,v=ca(aa(i));v.size>0&&_.setVaultPrefixes(v);let w=_.parse(g),I=new Un.ExoQLAlgebraTranslator().translate(w);I=new Un.AlgebraOptimizer().optimize(I);let C=Date.now(),ne=await new Un.ExoQLQueryExecutor(h).executeAll(I),de=Date.now()-C,N=Date.now()-r,Y=s.getSuggestions(n);if(t==="json"){let se=ne.map(re=>re.toJSON()),V={question:n,query:o.query,template:o.templateName,parameters:o.parameters,confidence:o.confidence,explanation:o.explanation,count:ne.length,bindings:se,suggestions:Y.length>0?Y:void 0},X=Ne.success(V,{durationMs:N,itemCount:ne.length,loadDurationMs:p,execDurationMs:de,triplesScanned:d.length});console.log(JSON.stringify(X,null,2))}else{if(console.log(`\u2705 Found ${ne.length} result(s) in ${de}ms
624
+ `),ne.length>0?cJ(ne,e.format):console.log("No results found."),Y.length>0){console.log(`
625
+ \u{1F4A1} Suggestions:`);for(let se of Y)console.log(` \u2022 ${se}`)}if(o.confidence<.6&&o.alternatives.length>0){console.log(`
626
+ \u{1F504} Alternative queries that might work better:`);for(let se=0;se<Math.min(2,o.alternatives.length);se++)console.log(` ${se+1}. ${o.alternatives[se].split(`
627
+ `).slice(-3)[0]?.trim()||"..."}`)}}}catch(r){oe.handle(r)}})}a(HD,"askCommand");function cJ(n,e){let t=n;switch(e){case"json":let r=new Zc;console.log(r.format(t));break;case"table":default:let i=new Jc;console.log(i.format(t));break}}a(cJ,"formatResults");var uL=require("fs"),fL=require("path");var pi=require("fs"),wn=require("path"),YD=require("child_process"),Ce=Z(It());var uJ=new Set(["aliases","archived","tags","cssclasses","publish","permalink","description","image","cover","banner","title","share","share_link","share_updated","metadata","uri"]),t2=new Map([["exo__","https://exocortex.my/ontology/exo#"],["ems__","https://exocortex.my/ontology/ems#"],["exocmd__","https://exocortex.my/ontology/exocmd#"],["ims__","https://exocortex.my/ontology/ims#"],["ztlk__","https://exocortex.my/ontology/ztlk#"],["ptms__","https://exocortex.my/ontology/ptms#"],["lit__","https://exocortex.my/ontology/lit#"],["inbox__","https://exocortex.my/ontology/inbox#"],["place__","https://exocortex.my/ontology/place#"],["exoob__","https://exocortex.my/ontology/exoob#"],["pn__","https://exocortex.my/ontology/pn#"],["period__","https://exocortex.my/ontology/period#"],["rdf__","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["rdfs__","http://www.w3.org/2000/01/rdf-schema#"],["owl__","http://www.w3.org/2002/07/owl#"]]);function fJ(n,e){if(!n)return!1;let t=n.exo__Instance_class;if(t==null)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/),o=s?s[1]:i;if(o===e||o.includes(e))return!0}return!1}a(fJ,"frontmatterMatchesClass");function dJ(n,e){return e.concat([n])}a(dJ,"collectAlso");async function XD(n,e,t,r){t&&e.length>0&&(r&&console.log("\u26A0\uFE0F --use-cache is disabled when --also is specified (per-vault cache cannot represent multi-vault state)."),t=!1);let i,s=!1;if(t){let l=await new di(n).loadOrBuild();i=l.triples,s=l.cacheHit}else{let o=new xt(n);i=await new Ce.NoteToRDFConverter(o).convertVault()}for(let o of e){let l=(0,wn.resolve)(o);if(!(0,pi.existsSync)(l))throw new pe(l);r&&console.log(`\u{1F4E6} Loading additional vault: ${l}...`);let c=new xt(l),f=await new Ce.NoteToRDFConverter(c).convertVault();i=i.concat(f),r&&console.log(` \u2795 Added ${f.length} triples from ${l}`)}if(e.length>0){let o=i.length;if(i=mJ(i),r){let l=i.length-o;l>0&&console.log(` \u{1F517} Cross-vault Instance_class resolution: emitted ${l} additional canonical-IRI triple(s)`)}}return{triples:i,cacheHit:s}}a(XD,"loadTriplesFromAllVaults");var QD="https://exocortex.my/ontology/exo#Instance_class",KD="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",hJ=/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i,pJ=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function mJ(n){let e=new Map;for(let i of n){if(!(i.subject instanceof Ce.DomainIRI)||!(i.predicate instanceof Ce.DomainIRI)||!(i.object instanceof Ce.DomainLiteral)||i.predicate.value!==rL&&i.predicate.value!==gJ)continue;let s=pJ.exec(i.subject.value);if(!s)continue;let o=s[1].toLowerCase();if(e.has(o))continue;let l=i.object.value.trim();if(/\s/.test(l))continue;let c=r2(l);c&&e.set(o,c)}if(e.size===0)return n;let t=new Set,r=[];for(let i of n){if(!(i.subject instanceof Ce.DomainIRI)||!(i.predicate instanceof Ce.DomainIRI)||!(i.object instanceof Ce.DomainLiteral)||i.predicate.value!==QD)continue;let s=i.object.value.trim(),o=hJ.exec(s);if(!o)continue;let l=o[1].toLowerCase(),c=e.get(l);if(!c)continue;let f=`${i.subject.value}\0${c}`;if(t.has(f))continue;t.add(f);let d=new Ce.DomainIRI(c);r.push(new Ce.DomainTriple(i.subject,new Ce.DomainIRI(QD),d)),r.push(new Ce.DomainTriple(i.subject,new Ce.DomainIRI(KD),d))}return r.length>0?n.concat(r):n}a(mJ,"resolveCrossVaultInstanceClassWikilinks");var gJ="https://exocortex.my/ontology/exo#Asset_label";function yJ(n,e){let t="obsidian://vault/",r=n;if(n.startsWith(t))r=decodeURIComponent(n.substring(t.length));else return n;for(let i of e){let s=(0,wn.join)(i,r);if((0,pi.existsSync)(s))return s}return(0,wn.join)(e[0]??"",r)}a(yJ,"qualifyFocusNodePath");function JD(n){let e=n.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!e)return n.match(/^---\r?\n---/)?{}:null;let t=e[1].split(`
628
628
  `),r={};for(let i of t){let s=i.match(/^(\w[\w]*):\s*(.*)$/);s&&(r[s[1]]=!0)}return r}a(JD,"extractFrontmatter");function ZD(n){for(let e of t2.keys())if(n.startsWith(e))return!0;return!1}a(ZD,"hasKnownPrefix");function eL(n){for(let[e,t]of t2)if(n.startsWith(e))return t+n.substring(e.length);return null}a(eL,"keyToURI");function _J(n){let e=[],t=[];for(let r of n)uJ.has(r)||(ZD(r)?e.push(r):t.push(r));return{toValidate:e,unknownPrefix:t}}a(_J,"classifyKeys");function tL(n){try{return(0,YD.execSync)("git diff --cached --name-only",{cwd:n,encoding:"utf-8"}).split(`
629
629
  `).filter(t=>t.endsWith(".md")&&t.trim().length>0)}catch{return[]}}a(tL,"getStagedMdFiles");function bJ(n){let e=[];function t(r){let i=(0,pi.readdirSync)(r);for(let s of i){if(s.startsWith(".")||s==="node_modules")continue;let o=(0,wn.join)(r,s);(0,pi.statSync)(o).isDirectory()?t(o):s.endsWith(".md")&&e.push((0,wn.relative)(n,o))}}return a(t,"walk"),t(n),e}a(bJ,"collectMdFiles");function SJ(n){let e=n.lastIndexOf("/");if(e===-1)return null;let t=decodeURIComponent(n.substring(e+1));return t.endsWith(".md")&&(t=t.slice(0,-3)),ZD(t)?t:null}a(SJ,"extractPropertyNameFromURI");async function wJ(n){let e=new Ce.InMemoryTripleStore;await e.addAll(n);let t=new Ce.ExoQLParser,r=la(`SELECT ?s ?label WHERE {
630
630
  {
@@ -643,19 +643,19 @@ Available prefixes: ${u}`,this.wellKnownPrefixes[r]&&l.push(`Add: PREFIX ${r}: <
643
643
  FILTER(!CONTAINS(STR(?class), "PropertyCardinality"))
644
644
  }
645
645
  OPTIONAL { ?s exo:Asset_label ?label }
646
- }`),i=t.parse(r),o=new Ce.ExoQLAlgebraTranslator().translate(i);o=new Ce.AlgebraOptimizer().optimize(o);let u=await new Ce.ExoQLQueryExecutor(e).executeAll(o),f=new Set;for(let d of u){let h=d.toJSON(),p=h.s;if(typeof p=="string"){let _=SJ(p);if(_){let v=eL(_);v&&f.add(v)}}let g=h.label;typeof g=="string"&&g.startsWith("https://exocortex.my/ontology/")&&f.add(g)}return f}a(wJ,"loadDeclaredProperties");function vJ(n,e,t){let r=[],i;try{i=(0,pi.readFileSync)(n,"utf-8")}catch{return[]}let s=JD(i);if(!s)return[];let o=Object.keys(s),{toValidate:l,unknownPrefix:c}=_J(o);for(let u of c)r.push({file:e,property:u,reason:`Unknown namespace prefix in "${u}"`});for(let u of l){let f=eL(u);f&&!t.has(f)&&r.push({file:e,property:u,reason:`Property "${u}" is not declared in the ontology`})}return r}a(vJ,"validateFile");var EJ="http://www.w3.org/2000/01/rdf-schema#subClassOf",TJ="https://exocortex.my/ontology/exo#Class_superClass",rL="http://www.w3.org/2000/01/rdf-schema#label";function r2(n){let e=n.indexOf("__");if(e===-1)return null;let t=n.slice(0,e+2),r=n.slice(e+2),i=t2.get(t);return!i||!r?null:i+r}a(r2,"labelToOntologyIRI");function IJ(n){let e=decodeURIComponent(n),t=e.lastIndexOf("/");if(t===-1)return null;let r=e.slice(t+1),i=r.endsWith(".md")?r.slice(0,-3):r;return r2(i)}a(IJ,"fileIriToOntologyURIFromFilename");function xJ(n){let e=a(r=>{if(r instanceof Ce.DomainIRI)return{type:"iri",value:r.value};if(r instanceof Ce.DomainLiteral){let i={type:"literal",value:r.value};return r.datatype&&(i.datatype=r.datatype.value),r.language&&(i.language=r.language),i}return null},"mapNode"),t=[];for(let r of n){let i=e(r.subject),s=e(r.predicate),o=e(r.object);i&&s&&o&&t.push({subject:i,predicate:s,object:o})}return t}a(xJ,"domainToAlgebraTriples");var e2=class{constructor(e){this.subClassMap=new Map;let t=new Map,r=new Set,i=a(o=>o===EJ||o===TJ,"isSubClassPredicate");for(let o of e)o.predicate instanceof Ce.DomainIRI&&i(o.predicate.value)&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainIRI&&(r.add(o.subject.value),r.add(o.object.value));for(let o of e)if(o.predicate instanceof Ce.DomainIRI&&o.predicate.value===rL&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainLiteral){let l=r2(o.object.value);l&&t.set(o.subject.value,l)}for(let o of r)if(!t.has(o)){let l=IJ(o);l&&t.set(o,l)}for(let[o,l]of t){let c=this.subClassMap.get(o)??new Set;c.add(l),this.subClassMap.set(o,c)}for(let o of e)if(o.predicate instanceof Ce.DomainIRI&&i(o.predicate.value)&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainIRI){let l=o.subject.value,c=o.object.value,u=this.subClassMap.get(l)??new Set;u.add(c),this.subClassMap.set(l,u);let f=t.get(l),d=c.startsWith("obsidian://")?t.get(c):c;if(f&&d){let h=this.subClassMap.get(f)??new Set;h.add(d),this.subClassMap.set(f,h)}}let s=e.filter(o=>o.predicate instanceof Ce.DomainIRI&&o.predicate.value===KD&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainIRI);for(let o of s){let l=o.subject.value,c=o.object.value,u=this.collectAncestors(c);for(let d of u){if(l===d)continue;let h=this.subClassMap.get(l)??new Set;h.add(d),this.subClassMap.set(l,h)}let f=t.get(l);if(f)for(let d of u){let h=d.startsWith("obsidian://")?t.get(d):d;if(!h||f===h)continue;let p=this.subClassMap.get(f)??new Set;p.add(h),this.subClassMap.set(f,p)}}}static{a(this,"TripleClassHierarchy")}collectAncestors(e){let t=new Set,r=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(r.has(s))continue;r.add(s);let o=this.subClassMap.get(s);if(o)for(let l of o)l!==e&&(t.add(l),r.has(l)||i.push(l))}return t}isSubClassOf(e,t){let r=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(s===t)return!0;if(r.has(s))continue;r.add(s);let o=this.subClassMap.get(s);if(o)for(let l of o)i.push(l)}return!1}};function nL(n,e){let t=`file://${n}`,r="https://exocortex.my/cli/shacl-validator",i={earl:"http://www.w3.org/ns/earl#",dc:"http://purl.org/dc/terms/",xsd:"http://www.w3.org/2001/XMLSchema#",sh:"http://www.w3.org/ns/shacl#"},s=[{"@type":"earl:Assertor","@id":r,"dc:title":"Exocortex CLI SHACL-lite Validator"},{"@type":"earl:TestSubject","@id":t,"dc:title":n}];if(e.violations.length===0)s.push({"@type":"earl:Assertion","earl:assertedBy":{"@id":r},"earl:subject":{"@id":t},"earl:result":{"@type":"earl:TestResult","earl:outcome":{"@id":"earl:passed"},"dc:description":"All nodes conform to shapes"}});else for(let o of e.violations)s.push({"@type":"earl:Assertion","earl:assertedBy":{"@id":r},"earl:subject":{"@id":t},"earl:test":{"@id":o.propertyPath},"earl:result":{"@type":"earl:TestResult","earl:outcome":{"@id":"earl:failed"},"dc:description":o.message,"sh:focusNode":o.focusNode,"sh:resultPath":o.propertyPath,"sh:resultSeverity":{"@id":`sh:${o.severity.replace("sh:","")}`},...o.actualValue!==void 0?{"sh:value":o.actualValue}:{}}});return{"@context":i,"@graph":s}}a(nL,"buildEARLReport");var AJ="https://exocortex.my/ontology/exo#Asset_legacyValidationException";function RJ(n,e){let t=new Set(n.filter(i=>i.predicate instanceof Ce.DomainIRI&&i.predicate.value===AJ).map(i=>i.subject instanceof Ce.DomainIRI?i.subject.value:null).filter(i=>i!==null));if(t.size===0)return e;let r=e.violations.filter(i=>!t.has(i.focusNode));return{conforms:r.every(i=>i.severity!=="sh:Violation"),violations:r}}a(RJ,"applyLegacyExceptionFilter");async function CJ(n,e,t=[]){let r=new Ce.InMemoryTripleStore;await r.addAll(e);let i=new Ce.ShaclShapeRegistry((await Ce.ShapeLoader.loadFromRDFGraph(r)).getAll()),s=new e2(e),o=xJ(e);return(0,Ce.shaclValidate)(o,i,s)}a(CJ,"runShapesValidation");function PJ(n,e){let t="obsidian://vault/",r=n.violations.filter(i=>{if(!i.focusNode.startsWith(t))return!1;let s;try{s=decodeURIComponent(i.focusNode.substring(t.length))}catch{s=i.focusNode.substring(t.length)}return e.has(s)});return{conforms:r.every(i=>i.severity!=="sh:Violation"),violations:r}}a(PJ,"filterReportToStagedFocusNodes");function OJ(n,e,t){if(t==="earl"){let r=nL(n,{conforms:!0,violations:[]});console.log(JSON.stringify(r,null,2))}else if(t==="json"){let r=Ne.success({vaultPath:n,alsoPaths:e.map(i=>(0,wn.resolve)(i)),conforms:!0,violationCount:0,violations:[]});console.log(JSON.stringify(r,null,2))}else console.log("\u2705 No staged .md files to validate.")}a(OJ,"emitEmptyStagedShapesResult");async function FJ(n,e={}){let t=n.format||"text",r=e.getStagedMdFiles??tL;try{let i=(0,wn.resolve)(n.vault);if(!(0,pi.existsSync)(i))throw new he(i);let s=n.also??[],o=[i,...s.map(p=>(0,wn.resolve)(p))],l=null;if(n.staged){let p=r(i);if(p.length===0){OJ(i,s,t);return}t==="text"&&s.length>0&&console.log("\u26A0\uFE0F --staged scopes git diff --cached to the primary vault; focusNode IRIs from --also vaults that match a staged relPath will also pass the filter."),l=new Set(p)}t==="text"&&console.log(`\u{1F4E6} Loading vault (shapes-mode): ${i}...`);let{triples:c,cacheHit:u}=await XD(i,s,!!n.useCache,t==="text");t==="text"&&u&&console.log("\u{1F680} Cache hit! Loading from persistent cache..."),t==="text"&&(console.log(`\u2705 Loaded ${c.length} triples`),console.log("\u{1F50D} Running SHACL-lite validation..."));let f=await CJ(i,c,s),d=RJ(c,f);l&&(d=PJ(d,l));let h=a(p=>o.length>1?yJ(p,o):p,"qualifyNode");if(t==="earl"){let p=nL(i,d);console.log(JSON.stringify(p,null,2))}else if(t==="json"){let p=d.violations.map(_=>({..._,vaultQualifiedPath:h(_.focusNode)})),g=Ne.success({vaultPath:i,alsoPaths:s.map(_=>(0,wn.resolve)(_)),conforms:d.conforms,violationCount:d.violations.length,violations:p});console.log(JSON.stringify(g,null,2))}else if(d.conforms)console.log(`\u2705 Vault conforms to all shapes (${d.violations.length===0?"no violations":`${d.violations.length} warning(s)`}).`);else{let p=new Map;for(let g of d.violations){let _=p.get(g.focusNode)??[];_.push(g),p.set(g.focusNode,_)}console.log(`\u26A0\uFE0F Found ${d.violations.length} SHACL violation(s) in ${p.size} node(s):
647
- `);for(let[g,_]of p){let v=o.length>1?h(g):g;console.log(` \u274C ${v}`);for(let w of _){let E=w.severity.replace("sh:","");console.log(` [${E}] ${w.message}`)}}}d.conforms||(process.exitCode=1)}catch(i){se.handle(i)}}a(FJ,"runShapesModeAction");function iL(){return new ce("schema").description("Check frontmatter properties against ontology (Issue #2713)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to merge into validation graph (repeatable). --use-cache is disabled when --also is present.",dJ,[]).option("--output <type>","Response format: text|json (for MCP tools)","text").option("--staged","Only validate git-staged .md files (for pre-commit hooks)").option("--use-cache","Use persistent triple cache (faster vault loading; disabled when --also is set)").option("--shapes-mode","Run SHACL-lite shapes validation instead of schema linting").option("--format <type>","Output format for shapes-mode: text|json|earl","text").option("--class <iri>","Only validate assets whose exo__Instance_class matches this IRI/slug (RFC 8e83442b T1.4)").action(async n=>{let e=n.output||"text";if(se.setFormat(e),n.shapesMode){await FJ(n);return}try{let t=(0,wn.resolve)(n.vault);if(!(0,pi.existsSync)(t))throw new he(t);let r;if(n.staged){if(r=tL(t),r.length===0){if(e==="json"){let d=Ne.success({vaultPath:t,filesChecked:0,violations:[],healthy:!0});console.log(JSON.stringify(d,null,2))}else console.log("\u2705 No staged .md files to validate.");return}}else r=bJ(t);if(n.class){let d=n.class;r=r.filter(h=>{try{let p=(0,pi.readFileSync)((0,wn.resolve)(t,h),"utf-8"),g=JD(p);return fJ(g,d)}catch{return!1}})}e==="text"&&console.log(`\u{1F4E6} Loading vault: ${t}...`);let i=n.also??[],{triples:s,cacheHit:o}=await XD(t,i,!!n.useCache,e==="text"),l=s;e==="text"&&o&&console.log("\u{1F680} Cache hit! Loading from persistent cache..."),e==="text"&&(console.log(`\u2705 Loaded ${l.length} triples`),console.log("\u{1F50D} Querying ontology for declared properties..."));let c=await wJ(l);e==="text"&&(console.log(`\u{1F4CB} Found ${c.size} declared properties in ontology`),console.log(`\u{1F50D} Validating ${r.length} file(s)...
646
+ }`),i=t.parse(r),o=new Ce.ExoQLAlgebraTranslator().translate(i);o=new Ce.AlgebraOptimizer().optimize(o);let u=await new Ce.ExoQLQueryExecutor(e).executeAll(o),f=new Set;for(let d of u){let h=d.toJSON(),p=h.s;if(typeof p=="string"){let _=SJ(p);if(_){let v=eL(_);v&&f.add(v)}}let g=h.label;typeof g=="string"&&g.startsWith("https://exocortex.my/ontology/")&&f.add(g)}return f}a(wJ,"loadDeclaredProperties");function vJ(n,e,t){let r=[],i;try{i=(0,pi.readFileSync)(n,"utf-8")}catch{return[]}let s=JD(i);if(!s)return[];let o=Object.keys(s),{toValidate:l,unknownPrefix:c}=_J(o);for(let u of c)r.push({file:e,property:u,reason:`Unknown namespace prefix in "${u}"`});for(let u of l){let f=eL(u);f&&!t.has(f)&&r.push({file:e,property:u,reason:`Property "${u}" is not declared in the ontology`})}return r}a(vJ,"validateFile");var EJ="http://www.w3.org/2000/01/rdf-schema#subClassOf",TJ="https://exocortex.my/ontology/exo#Class_superClass",rL="http://www.w3.org/2000/01/rdf-schema#label";function r2(n){let e=n.indexOf("__");if(e===-1)return null;let t=n.slice(0,e+2),r=n.slice(e+2),i=t2.get(t);return!i||!r?null:i+r}a(r2,"labelToOntologyIRI");function IJ(n){let e=decodeURIComponent(n),t=e.lastIndexOf("/");if(t===-1)return null;let r=e.slice(t+1),i=r.endsWith(".md")?r.slice(0,-3):r;return r2(i)}a(IJ,"fileIriToOntologyURIFromFilename");function xJ(n){let e=a(r=>{if(r instanceof Ce.DomainIRI)return{type:"iri",value:r.value};if(r instanceof Ce.DomainLiteral){let i={type:"literal",value:r.value};return r.datatype&&(i.datatype=r.datatype.value),r.language&&(i.language=r.language),i}return null},"mapNode"),t=[];for(let r of n){let i=e(r.subject),s=e(r.predicate),o=e(r.object);i&&s&&o&&t.push({subject:i,predicate:s,object:o})}return t}a(xJ,"domainToAlgebraTriples");var e2=class{constructor(e){this.subClassMap=new Map;let t=new Map,r=new Set,i=a(o=>o===EJ||o===TJ,"isSubClassPredicate");for(let o of e)o.predicate instanceof Ce.DomainIRI&&i(o.predicate.value)&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainIRI&&(r.add(o.subject.value),r.add(o.object.value));for(let o of e)if(o.predicate instanceof Ce.DomainIRI&&o.predicate.value===rL&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainLiteral){let l=r2(o.object.value);l&&t.set(o.subject.value,l)}for(let o of r)if(!t.has(o)){let l=IJ(o);l&&t.set(o,l)}for(let[o,l]of t){let c=this.subClassMap.get(o)??new Set;c.add(l),this.subClassMap.set(o,c)}for(let o of e)if(o.predicate instanceof Ce.DomainIRI&&i(o.predicate.value)&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainIRI){let l=o.subject.value,c=o.object.value,u=this.subClassMap.get(l)??new Set;u.add(c),this.subClassMap.set(l,u);let f=t.get(l),d=c.startsWith("obsidian://")?t.get(c):c;if(f&&d){let h=this.subClassMap.get(f)??new Set;h.add(d),this.subClassMap.set(f,h)}}let s=e.filter(o=>o.predicate instanceof Ce.DomainIRI&&o.predicate.value===KD&&o.subject instanceof Ce.DomainIRI&&o.object instanceof Ce.DomainIRI);for(let o of s){let l=o.subject.value,c=o.object.value,u=this.collectAncestors(c);for(let d of u){if(l===d)continue;let h=this.subClassMap.get(l)??new Set;h.add(d),this.subClassMap.set(l,h)}let f=t.get(l);if(f)for(let d of u){let h=d.startsWith("obsidian://")?t.get(d):d;if(!h||f===h)continue;let p=this.subClassMap.get(f)??new Set;p.add(h),this.subClassMap.set(f,p)}}}static{a(this,"TripleClassHierarchy")}collectAncestors(e){let t=new Set,r=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(r.has(s))continue;r.add(s);let o=this.subClassMap.get(s);if(o)for(let l of o)l!==e&&(t.add(l),r.has(l)||i.push(l))}return t}isSubClassOf(e,t){let r=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(s===t)return!0;if(r.has(s))continue;r.add(s);let o=this.subClassMap.get(s);if(o)for(let l of o)i.push(l)}return!1}};function nL(n,e){let t=`file://${n}`,r="https://exocortex.my/cli/shacl-validator",i={earl:"http://www.w3.org/ns/earl#",dc:"http://purl.org/dc/terms/",xsd:"http://www.w3.org/2001/XMLSchema#",sh:"http://www.w3.org/ns/shacl#"},s=[{"@type":"earl:Assertor","@id":r,"dc:title":"Exocortex CLI SHACL-lite Validator"},{"@type":"earl:TestSubject","@id":t,"dc:title":n}];if(e.violations.length===0)s.push({"@type":"earl:Assertion","earl:assertedBy":{"@id":r},"earl:subject":{"@id":t},"earl:result":{"@type":"earl:TestResult","earl:outcome":{"@id":"earl:passed"},"dc:description":"All nodes conform to shapes"}});else for(let o of e.violations)s.push({"@type":"earl:Assertion","earl:assertedBy":{"@id":r},"earl:subject":{"@id":t},"earl:test":{"@id":o.propertyPath},"earl:result":{"@type":"earl:TestResult","earl:outcome":{"@id":"earl:failed"},"dc:description":o.message,"sh:focusNode":o.focusNode,"sh:resultPath":o.propertyPath,"sh:resultSeverity":{"@id":`sh:${o.severity.replace("sh:","")}`},...o.actualValue!==void 0?{"sh:value":o.actualValue}:{}}});return{"@context":i,"@graph":s}}a(nL,"buildEARLReport");var AJ="https://exocortex.my/ontology/exo#Asset_legacyValidationException";function RJ(n,e){let t=new Set(n.filter(i=>i.predicate instanceof Ce.DomainIRI&&i.predicate.value===AJ).map(i=>i.subject instanceof Ce.DomainIRI?i.subject.value:null).filter(i=>i!==null));if(t.size===0)return e;let r=e.violations.filter(i=>!t.has(i.focusNode));return{conforms:r.every(i=>i.severity!=="sh:Violation"),violations:r}}a(RJ,"applyLegacyExceptionFilter");async function CJ(n,e,t=[]){let r=new Ce.InMemoryTripleStore;await r.addAll(e);let i=new Ce.ShaclShapeRegistry((await Ce.ShapeLoader.loadFromRDFGraph(r)).getAll()),s=new e2(e),o=xJ(e);return(0,Ce.shaclValidate)(o,i,s)}a(CJ,"runShapesValidation");function PJ(n,e){let t="obsidian://vault/",r=n.violations.filter(i=>{if(!i.focusNode.startsWith(t))return!1;let s;try{s=decodeURIComponent(i.focusNode.substring(t.length))}catch{s=i.focusNode.substring(t.length)}return e.has(s)});return{conforms:r.every(i=>i.severity!=="sh:Violation"),violations:r}}a(PJ,"filterReportToStagedFocusNodes");function OJ(n,e,t){if(t==="earl"){let r=nL(n,{conforms:!0,violations:[]});console.log(JSON.stringify(r,null,2))}else if(t==="json"){let r=Ne.success({vaultPath:n,alsoPaths:e.map(i=>(0,wn.resolve)(i)),conforms:!0,violationCount:0,violations:[]});console.log(JSON.stringify(r,null,2))}else console.log("\u2705 No staged .md files to validate.")}a(OJ,"emitEmptyStagedShapesResult");async function FJ(n,e={}){let t=n.format||"text",r=e.getStagedMdFiles??tL;try{let i=(0,wn.resolve)(n.vault);if(!(0,pi.existsSync)(i))throw new pe(i);let s=n.also??[],o=[i,...s.map(p=>(0,wn.resolve)(p))],l=null;if(n.staged){let p=r(i);if(p.length===0){OJ(i,s,t);return}t==="text"&&s.length>0&&console.log("\u26A0\uFE0F --staged scopes git diff --cached to the primary vault; focusNode IRIs from --also vaults that match a staged relPath will also pass the filter."),l=new Set(p)}t==="text"&&console.log(`\u{1F4E6} Loading vault (shapes-mode): ${i}...`);let{triples:c,cacheHit:u}=await XD(i,s,!!n.useCache,t==="text");t==="text"&&u&&console.log("\u{1F680} Cache hit! Loading from persistent cache..."),t==="text"&&(console.log(`\u2705 Loaded ${c.length} triples`),console.log("\u{1F50D} Running SHACL-lite validation..."));let f=await CJ(i,c,s),d=RJ(c,f);l&&(d=PJ(d,l));let h=a(p=>o.length>1?yJ(p,o):p,"qualifyNode");if(t==="earl"){let p=nL(i,d);console.log(JSON.stringify(p,null,2))}else if(t==="json"){let p=d.violations.map(_=>({..._,vaultQualifiedPath:h(_.focusNode)})),g=Ne.success({vaultPath:i,alsoPaths:s.map(_=>(0,wn.resolve)(_)),conforms:d.conforms,violationCount:d.violations.length,violations:p});console.log(JSON.stringify(g,null,2))}else if(d.conforms)console.log(`\u2705 Vault conforms to all shapes (${d.violations.length===0?"no violations":`${d.violations.length} warning(s)`}).`);else{let p=new Map;for(let g of d.violations){let _=p.get(g.focusNode)??[];_.push(g),p.set(g.focusNode,_)}console.log(`\u26A0\uFE0F Found ${d.violations.length} SHACL violation(s) in ${p.size} node(s):
647
+ `);for(let[g,_]of p){let v=o.length>1?h(g):g;console.log(` \u274C ${v}`);for(let w of _){let E=w.severity.replace("sh:","");console.log(` [${E}] ${w.message}`)}}}d.conforms||(process.exitCode=1)}catch(i){oe.handle(i)}}a(FJ,"runShapesModeAction");function iL(){return new ce("schema").description("Check frontmatter properties against ontology (Issue #2713)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--also <path>","Additional vault to merge into validation graph (repeatable). --use-cache is disabled when --also is present.",dJ,[]).option("--output <type>","Response format: text|json (for MCP tools)","text").option("--staged","Only validate git-staged .md files (for pre-commit hooks)").option("--use-cache","Use persistent triple cache (faster vault loading; disabled when --also is set)").option("--shapes-mode","Run SHACL-lite shapes validation instead of schema linting").option("--format <type>","Output format for shapes-mode: text|json|earl","text").option("--class <iri>","Only validate assets whose exo__Instance_class matches this IRI/slug (RFC 8e83442b T1.4)").action(async n=>{let e=n.output||"text";if(oe.setFormat(e),n.shapesMode){await FJ(n);return}try{let t=(0,wn.resolve)(n.vault);if(!(0,pi.existsSync)(t))throw new pe(t);let r;if(n.staged){if(r=tL(t),r.length===0){if(e==="json"){let d=Ne.success({vaultPath:t,filesChecked:0,violations:[],healthy:!0});console.log(JSON.stringify(d,null,2))}else console.log("\u2705 No staged .md files to validate.");return}}else r=bJ(t);if(n.class){let d=n.class;r=r.filter(h=>{try{let p=(0,pi.readFileSync)((0,wn.resolve)(t,h),"utf-8"),g=JD(p);return fJ(g,d)}catch{return!1}})}e==="text"&&console.log(`\u{1F4E6} Loading vault: ${t}...`);let i=n.also??[],{triples:s,cacheHit:o}=await XD(t,i,!!n.useCache,e==="text"),l=s;e==="text"&&o&&console.log("\u{1F680} Cache hit! Loading from persistent cache..."),e==="text"&&(console.log(`\u2705 Loaded ${l.length} triples`),console.log("\u{1F50D} Querying ontology for declared properties..."));let c=await wJ(l);e==="text"&&(console.log(`\u{1F4CB} Found ${c.size} declared properties in ontology`),console.log(`\u{1F50D} Validating ${r.length} file(s)...
648
648
  `));let u=[];for(let d of r){let h=(0,wn.resolve)(t,d),p=vJ(h,d,c);u.push(...p)}let f={vaultPath:t,filesChecked:r.length,violations:u,healthy:u.length===0};if(e==="json"){let d=Ne.success(f);console.log(JSON.stringify(d,null,2))}else if(u.length===0)console.log(`\u2705 All ${r.length} file(s) pass schema validation.`);else{let d=new Map;for(let h of u){let p=d.get(h.file)||[];p.push(h),d.set(h.file,p)}console.log(`\u26A0\uFE0F Found ${u.length} schema violation(s) in ${d.size} file(s):
649
649
  `);for(let[h,p]of d){console.log(` \u274C ${h}`);for(let g of p)console.log(` \u2022 ${g.reason}`)}console.log(`
650
- \u{1F4DD} To fix these issues:`),console.log(" - Remove undeclared properties from frontmatter"),console.log(" - Or declare them in the ontology as Property instances")}u.length>0&&(process.exitCode=1)}catch(t){se.handle(t)}})}a(iL,"validateSchemaCommand");var sL=require("fs"),oL=require("path"),aL=require("child_process"),lL=Z(It());var DJ={exo__Asset_uid:"add `exo__Asset_uid: <uuid>` to frontmatter",exo__Asset_isDefinedBy:'add `exo__Asset_isDefinedBy: "[[!kitelev]]"` (or your own ontology marker) to frontmatter',exo__Asset_label:'add `exo__Asset_label: "<short label>"` to frontmatter',exo__Instance_class:'add `exo__Instance_class: ["[[<ClassName>]]"]` to frontmatter'};function LJ(n,e){switch(e.code){case"MISSING_PROPERTY":return{file:n,code:e.code,property:e.property,reason:e.message,hint:DJ[e.property]??`add \`${e.property}: <value>\` to frontmatter`};case"EMPTY_PROPERTY":return{file:n,code:e.code,property:e.property,reason:e.message,hint:`set a non-empty value for \`${e.property}\` (or remove the asset markers if this file is not an Exocortex asset)`};case"EMPTY_OPTIONAL_PROPERTY":return{file:n,code:e.code,property:e.property,reason:e.message,hint:`remove \`${e.property}\` from frontmatter or fill it with a non-empty value`};case"INVALID_INSTANCE_CLASS_IRI":return{file:n,code:e.code,property:e.property,reason:e.message,hint:`fix the \`${e.property}\` wikilink target \u2014 namespaced classes (e.g. \`ems__\`, \`exo__\`) cannot contain whitespace or parentheses, otherwise they expand into invalid IRIs`}}}a(LJ,"violationToError");function NJ(n){try{return(0,aL.execSync)("git diff --cached --name-only",{cwd:n,encoding:"utf-8"}).split(`
651
- `).filter(t=>t.endsWith(".md")&&t.trim().length>0)}catch{return[]}}a(NJ,"getStagedMdFiles");function cL(){return new ce("frontmatter").description("Check vault frontmatter for missing/empty properties and malformed IRIs (Issue #2997 Phase 4)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json (for MCP tools)","text").option("--staged","Only validate git-staged .md files (for pre-commit hooks)").action(async n=>{let e=n.output||"text";se.setFormat(e);try{let t=(0,oL.resolve)(n.vault);if(!(0,sL.existsSync)(t))throw new he(t);let r=new xt(t),i=new lL.NoteToRDFConverter(r),s=r.getAllFiles();if(n.staged){let c=new Set(NJ(t));s=s.filter(u=>c.has(u.path))}let o=[];for(let c of s){let u=r.getFrontmatter(c);if(u){let f=i.validateExocortexAsset(u);f&&o.push(LJ(c.path,f))}try{i.notePathToIRI(c.path)}catch(f){let d=f instanceof Error?f.message:String(f);o.push({file:c.path,code:"INVALID_PATH_IRI",reason:`Invalid IRI format for vault path: ${d}`,hint:`rename the file \u2014 its path \`${c.path}\` cannot be encoded into a valid \`obsidian://vault/...\` IRI (avoid raw whitespace, control characters, and angle brackets)`})}}let l={vaultPath:t,filesChecked:s.length,errors:o,healthy:o.length===0};if(e==="json")console.log(JSON.stringify(Ne.success(l),null,2));else if(o.length===0)console.log(`\u2705 All ${s.length} file(s) pass frontmatter validation.`);else{console.log(`\u26A0\uFE0F Found ${o.length} frontmatter error(s) in ${new Set(o.map(c=>c.file)).size} file(s):
650
+ \u{1F4DD} To fix these issues:`),console.log(" - Remove undeclared properties from frontmatter"),console.log(" - Or declare them in the ontology as Property instances")}u.length>0&&(process.exitCode=1)}catch(t){oe.handle(t)}})}a(iL,"validateSchemaCommand");var sL=require("fs"),oL=require("path"),aL=require("child_process"),lL=Z(It());var DJ={exo__Asset_uid:"add `exo__Asset_uid: <uuid>` to frontmatter",exo__Asset_isDefinedBy:'add `exo__Asset_isDefinedBy: "[[!kitelev]]"` (or your own ontology marker) to frontmatter',exo__Asset_label:'add `exo__Asset_label: "<short label>"` to frontmatter',exo__Instance_class:'add `exo__Instance_class: ["[[<ClassName>]]"]` to frontmatter'};function LJ(n,e){switch(e.code){case"MISSING_PROPERTY":return{file:n,code:e.code,property:e.property,reason:e.message,hint:DJ[e.property]??`add \`${e.property}: <value>\` to frontmatter`};case"EMPTY_PROPERTY":return{file:n,code:e.code,property:e.property,reason:e.message,hint:`set a non-empty value for \`${e.property}\` (or remove the asset markers if this file is not an Exocortex asset)`};case"EMPTY_OPTIONAL_PROPERTY":return{file:n,code:e.code,property:e.property,reason:e.message,hint:`remove \`${e.property}\` from frontmatter or fill it with a non-empty value`};case"INVALID_INSTANCE_CLASS_IRI":return{file:n,code:e.code,property:e.property,reason:e.message,hint:`fix the \`${e.property}\` wikilink target \u2014 namespaced classes (e.g. \`ems__\`, \`exo__\`) cannot contain whitespace or parentheses, otherwise they expand into invalid IRIs`}}}a(LJ,"violationToError");function NJ(n){try{return(0,aL.execSync)("git diff --cached --name-only",{cwd:n,encoding:"utf-8"}).split(`
651
+ `).filter(t=>t.endsWith(".md")&&t.trim().length>0)}catch{return[]}}a(NJ,"getStagedMdFiles");function cL(){return new ce("frontmatter").description("Check vault frontmatter for missing/empty properties and malformed IRIs (Issue #2997 Phase 4)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json (for MCP tools)","text").option("--staged","Only validate git-staged .md files (for pre-commit hooks)").action(async n=>{let e=n.output||"text";oe.setFormat(e);try{let t=(0,oL.resolve)(n.vault);if(!(0,sL.existsSync)(t))throw new pe(t);let r=new xt(t),i=new lL.NoteToRDFConverter(r),s=r.getAllFiles();if(n.staged){let c=new Set(NJ(t));s=s.filter(u=>c.has(u.path))}let o=[];for(let c of s){let u=r.getFrontmatter(c);if(u){let f=i.validateExocortexAsset(u);f&&o.push(LJ(c.path,f))}try{i.notePathToIRI(c.path)}catch(f){let d=f instanceof Error?f.message:String(f);o.push({file:c.path,code:"INVALID_PATH_IRI",reason:`Invalid IRI format for vault path: ${d}`,hint:`rename the file \u2014 its path \`${c.path}\` cannot be encoded into a valid \`obsidian://vault/...\` IRI (avoid raw whitespace, control characters, and angle brackets)`})}}let l={vaultPath:t,filesChecked:s.length,errors:o,healthy:o.length===0};if(e==="json")console.log(JSON.stringify(Ne.success(l),null,2));else if(o.length===0)console.log(`\u2705 All ${s.length} file(s) pass frontmatter validation.`);else{console.log(`\u26A0\uFE0F Found ${o.length} frontmatter error(s) in ${new Set(o.map(c=>c.file)).size} file(s):
652
652
  `);for(let c of o)console.log(` \u274C ${c.file}`),console.log(` ${c.reason}`),console.log(` \u{1F4A1} ${c.hint}`);console.log(`
653
- \u{1F4DD} These shapes prevented the file from loading into the SPARQL store (Issue #2997 Phase 2). Fix them so the asset can be indexed.`)}o.length>0&&(process.exitCode=1)}catch(t){se.handle(t)}})}a(cL,"validateFrontmatterCommand");function kJ(){return new ce("iri").description("Check vault files for IRI issues (Issue #2205)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json (for MCP tools)","text").action(async n=>{let e=n.output||"text";se.setFormat(e);try{let t=(0,fL.resolve)(n.vault);if(!(0,uL.existsSync)(t))throw new he(t);let r=new di(t);e==="text"&&console.log(`\u{1F50D} Validating vault: ${t}...`);let i=await r.validateVault();if(e==="json"){let s=Ne.success({vaultPath:t,issueCount:i.length,issues:i,healthy:i.length===0});console.log(JSON.stringify(s,null,2))}else if(i.length===0)console.log("\u2705 Vault is healthy! No IRI issues found.");else{console.log(`
653
+ \u{1F4DD} These shapes prevented the file from loading into the SPARQL store (Issue #2997 Phase 2). Fix them so the asset can be indexed.`)}o.length>0&&(process.exitCode=1)}catch(t){oe.handle(t)}})}a(cL,"validateFrontmatterCommand");function kJ(){return new ce("iri").description("Check vault files for IRI issues (Issue #2205)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json (for MCP tools)","text").action(async n=>{let e=n.output||"text";oe.setFormat(e);try{let t=(0,fL.resolve)(n.vault);if(!(0,uL.existsSync)(t))throw new pe(t);let r=new di(t);e==="text"&&console.log(`\u{1F50D} Validating vault: ${t}...`);let i=await r.validateVault();if(e==="json"){let s=Ne.success({vaultPath:t,issueCount:i.length,issues:i,healthy:i.length===0});console.log(JSON.stringify(s,null,2))}else if(i.length===0)console.log("\u2705 Vault is healthy! No IRI issues found.");else{console.log(`
654
654
  \u26A0\uFE0F Found ${i.length} file(s) with IRI issues:
655
655
  `);for(let s of i)console.log(` \u274C ${s.path}`),console.log(` ${s.reason}`);console.log(`
656
656
  \u{1F4DD} To fix these issues:`),console.log(" - Rename files to remove spaces and special characters"),console.log(" - Use dashes (-) or underscores (_) instead of spaces"),console.log(" - Avoid angle brackets (<>) and other special characters"),console.log(`
657
- \u{1F4A1} Run 'exocortex sparql index --strict' to fail on first issue`)}i.length>0&&(process.exitCode=1)}catch(t){se.handle(t)}})}a(kJ,"validateIriCommand");function dL(){let n=new ce("validate").description("Validate vault files (IRI checks, schema linting, frontmatter shapes)");return n.addCommand(kJ()),n.addCommand(iL()),n.addCommand(cL()),n}a(dL,"validateCommand");var hL=require("fs"),pL=require("path"),Rr=Z(It());function mL(){return new ce("classes").alias("describe-class").description("List RDF classes in vault, or describe a class (predicates + counts). Alias `describe-class` is provided per #3043 RFC \xA7B (schema introspection).").argument("[class-name]","Optional class name to show details (e.g., ems__Task)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--use-cache","Use persistent cache (faster for repeated queries)").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").action(async(n,e)=>{let t=e.output||"text";se.setFormat(t);try{let r=Date.now(),i=(0,pL.resolve)(e.vault);if(!(0,hL.existsSync)(i))throw new he(i);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let s=await ua({profileUid:e.profile,primaryVaultPath:i,outputFormat:t}),o=e.useCache??!1;o&&s!==null&&(t==="text"&&console.log("\u26A0\uFE0F --use-cache disabled because --profile is active (cache is not profile-aware)."),o=!1);let l,c=!1;if(o){let h=await new di(i).loadOrBuild();l=h.triples,c=h.cacheHit,t==="text"&&c&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let d=new xt(i);l=await new Rr.NoteToRDFConverter(d).convertVault(s!==null?{effectiveOntologies:s.effective,assetSpaceFolderToUid:s.folderMap}:{})}let u=new Rr.InMemoryTripleStore;await u.addAll(l);let f=Date.now()-r;if(t==="text"){let d=c?" (from cache)":"";console.log(`\u2705 Loaded ${l.length} triples in ${f}ms${d}
658
- `)}n?await jJ(u,n,e,t):await MJ(u,e,t)}catch(r){se.handle(r)}})}a(mL,"classesCommand");async function MJ(n,e,t){let s=new Rr.ExoQLParser().parse(`
657
+ \u{1F4A1} Run 'exocortex sparql index --strict' to fail on first issue`)}i.length>0&&(process.exitCode=1)}catch(t){oe.handle(t)}})}a(kJ,"validateIriCommand");function dL(){let n=new ce("validate").description("Validate vault files (IRI checks, schema linting, frontmatter shapes)");return n.addCommand(kJ()),n.addCommand(iL()),n.addCommand(cL()),n}a(dL,"validateCommand");var hL=require("fs"),pL=require("path"),Rr=Z(It());function mL(){return new ce("classes").alias("describe-class").description("List RDF classes in vault, or describe a class (predicates + counts). Alias `describe-class` is provided per #3043 RFC \xA7B (schema introspection).").argument("[class-name]","Optional class name to show details (e.g., ems__Task)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: table|json","table").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--use-cache","Use persistent cache (faster for repeated queries)").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").action(async(n,e)=>{let t=e.output||"text";oe.setFormat(t);try{let r=Date.now(),i=(0,pL.resolve)(e.vault);if(!(0,hL.existsSync)(i))throw new pe(i);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let s=await ua({profileUid:e.profile,primaryVaultPath:i,outputFormat:t}),o=e.useCache??!1;o&&s!==null&&(t==="text"&&console.log("\u26A0\uFE0F --use-cache disabled because --profile is active (cache is not profile-aware)."),o=!1);let l,c=!1;if(o){let h=await new di(i).loadOrBuild();l=h.triples,c=h.cacheHit,t==="text"&&c&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let d=new xt(i);l=await new Rr.NoteToRDFConverter(d).convertVault(s!==null?{effectiveOntologies:s.effective,assetSpaceFolderToUid:s.folderMap}:{})}let u=new Rr.InMemoryTripleStore;await u.addAll(l);let f=Date.now()-r;if(t==="text"){let d=c?" (from cache)":"";console.log(`\u2705 Loaded ${l.length} triples in ${f}ms${d}
658
+ `)}n?await jJ(u,n,e,t):await MJ(u,e,t)}catch(r){oe.handle(r)}})}a(mL,"classesCommand");async function MJ(n,e,t){let s=new Rr.ExoQLParser().parse(`
659
659
  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
660
660
  SELECT ?class (COUNT(?instance) AS ?count)
661
661
  WHERE {
@@ -686,15 +686,15 @@ Available prefixes: ${u}`,this.wellKnownPrefixes[r]&&l.push(`Add: PREFIX ${r}: <
686
686
  `),console.log(` Instances: ${h}`),console.log(` Properties: ${_.length}
687
687
  `),_.length===0){console.log(" No properties found.");return}let w=Math.max(..._.map(E=>E.name.length),10);console.log(" \u250C"+"\u2500".repeat(w+2)+"\u252C"+"\u2500".repeat(10)+"\u2510"),console.log(" \u2502 "+"Property".padEnd(w)+" \u2502 "+"Usage".padEnd(8)+" \u2502"),console.log(" \u251C"+"\u2500".repeat(w+2)+"\u253C"+"\u2500".repeat(10)+"\u2524");for(let E of _)console.log(" \u2502 "+E.name.padEnd(w)+" \u2502 "+E.usageCount.toString().padStart(8)+" \u2502");console.log(" \u2514"+"\u2500".repeat(w+2)+"\u2534"+"\u2500".repeat(10)+"\u2518")}}a(jJ,"showClassDetails");function gL(n){let e=n.replace(/^<|>$/g,""),t=e.lastIndexOf("#");if(t!==-1)return e.substring(t+1);let r=e.lastIndexOf("/");return r!==-1?e.substring(r+1):e}a(gL,"extractLocalName");var EL=require("path"),c2=require("fs"),TL=require("fs"),IL=Z(It());var gr=Z(Jo()),fa=Z(require("path"));var ul=Z(It());var yr=class{constructor(e){this.rootPath=e}static{a(this,"NodeFsAdapter")}async readFile(e){let t=this.resolvePath(e);if(!await gr.default.pathExists(t))throw new ul.FileNotFoundError(e);return gr.default.readFile(t,"utf-8")}async fileExists(e){let t=this.resolvePath(e);return gr.default.pathExists(t)}async getFileMetadata(e){let t=await this.readFile(e);return this.extractFrontmatter(t)}async createFile(e,t){let r=this.resolvePath(e);if(await gr.default.pathExists(r))throw new ul.FileAlreadyExistsError(e);return await gr.default.ensureDir(fa.default.dirname(r)),await gr.default.writeFile(r,t,"utf-8"),e}async updateFile(e,t){let r=this.resolvePath(e);if(!await gr.default.pathExists(r))throw new ul.FileNotFoundError(e);await gr.default.writeFile(r,t,"utf-8")}async writeFile(e,t){let r=this.resolvePath(e);await gr.default.ensureDir(fa.default.dirname(r)),await gr.default.writeFile(r,t,"utf-8")}async deleteFile(e){let t=this.resolvePath(e);if(!await gr.default.pathExists(t))throw new ul.FileNotFoundError(e);await gr.default.remove(t)}async renameFile(e,t){let r=this.resolvePath(e),i=this.resolvePath(t);if(!await gr.default.pathExists(r))throw new ul.FileNotFoundError(e);await gr.default.ensureDir(fa.default.dirname(i)),await gr.default.move(r,i)}async createDirectory(e){let t=this.resolvePath(e);await gr.default.ensureDir(t)}async directoryExists(e){let t=this.resolvePath(e);return await gr.default.pathExists(t)?(await gr.default.stat(t)).isDirectory():!1}async getMarkdownFiles(e){let t=e?this.resolvePath(e):this.rootPath,r=fa.default.join(t,"**/*.md");return(await Kc(r,{nodir:!0})).map(o=>fa.default.relative(this.rootPath,o))}async findFilesByMetadata(e){let t=await this.getMarkdownFiles(),r=[];for(let i of t)try{let s=await this.getFileMetadata(i);this.matchesQuery(s,e)&&r.push(i)}catch{continue}return r}async findFileByUID(e){let t=await this.findFilesByMetadata({exo__Asset_uid:e});return t.length>0?t[0]:null}resolvePath(e){return fa.default.isAbsolute(e)?e:fa.default.join(this.rootPath,e)}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);if(!r)return{};try{let i=Wt.load(r[1]);return typeof i=="object"&&i!==null?i:{}}catch{return{}}}matchesQuery(e,t){for(let[r,i]of Object.entries(t)){let s=e[r];if(Array.isArray(s)){if(!s.some(o=>this.normalizeValue(o)===this.normalizeValue(i)))return!1}else if(this.normalizeValue(s)!==this.normalizeValue(i))return!1}return!0}normalizeValue(e){return e==null?"":String(e).replace(/["'[\]]/g,"").trim()}};var n2=class extends Error{static{a(this,"ClassNotFoundError")}constructor(e,t){let r=`Class '${e}' not found in vault`;t&&t.length>0&&(r+=`
688
688
  Available classes: ${t.join(", ")}`),super(r),this.name="ClassNotFoundError"}},cu=class{constructor(e){this.fsAdapter=e;this.cache=new Map}static{a(this,"ClassResolverService")}async resolve(e,t){if(this.isUUID(t))return t;let r=await this.getOrBuildIndex(e),i=r.get(t);if(!i){let s=Array.from(r.keys()).filter(o=>!this.isUUID(o));throw new n2(t,s)}return i}async listClasses(e){let t=await this.getOrBuildIndex(e);return Array.from(t.keys())}async getOrBuildIndex(e){if(this.cache.has(e))return this.cache.get(e);let t=await this.buildIndex(e);return this.cache.set(e,t),t}async buildIndex(e){let t=new Map,r=await this.fsAdapter.getMarkdownFiles();for(let i of r)try{let s=await this.fsAdapter.getFileMetadata(i);if(!this.isClassDefinition(s))continue;let o=this.getBasename(i),l=s.exo__Asset_uid;if(!l&&this.isUUID(o)&&(l=o),!l)continue;let c=String(l);o&&t.set(o,c);let u=s.exo__Asset_label;u&&typeof u=="string"&&u!==o&&t.set(u,c)}catch{continue}return t}isClassDefinition(e){let t=e.exo__Instance_class;return t?(Array.isArray(t)?t:[t]).some(i=>{let s=String(i);return s.includes("ims__Class")||s.includes("exo__Class")}):!1}getBasename(e){let t=e.split("/");return t[t.length-1].replace(/\.md$/,"")}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)}};var i2=class extends Error{static{a(this,"WikilinkNotFoundError")}constructor(e,t){let r=t?`|${t}`:"";super(`Wikilink [[${e}${r}]] \u2014 file not found in vault`),this.name="WikilinkNotFoundError"}},py=class{constructor(e){this.fsAdapter=e}static{a(this,"WikilinkValidator")}static{this.WIKILINK_PATTERN=/\[\[([^\]|]+)(?:\|[^\]]*)?]]/g}async validatePropertyValues(e){for(let[,t]of Object.entries(e))await this.validateValue(t)}async validateValue(e){let t=this.extractWikilinks(e);for(let r of t)await this.validateWikilink(r.uuid,r.label)}extractWikilinks(e){let t=[],r=/\[\[([^\]|]+)(?:\|([^\]]*))?\]\]/g,i;for(;(i=r.exec(e))!==null;)t.push({uuid:i[1].trim(),label:i[2]?.trim()});return t}async validateWikilink(e,t){if(!this.looksLikeUUID(e))return;if(!await this.fsAdapter.fileExists(`${e}.md`)&&!await this.fsAdapter.findFileByUID(e))throw new i2(e,t)}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};var Br=[];for(let n=0;n<256;++n)Br.push((n+256).toString(16).slice(1));function yL(n,e=0){return(Br[n[e+0]]+Br[n[e+1]]+Br[n[e+2]]+Br[n[e+3]]+"-"+Br[n[e+4]]+Br[n[e+5]]+"-"+Br[n[e+6]]+Br[n[e+7]]+"-"+Br[n[e+8]]+Br[n[e+9]]+"-"+Br[n[e+10]]+Br[n[e+11]]+Br[n[e+12]]+Br[n[e+13]]+Br[n[e+14]]+Br[n[e+15]]).toLowerCase()}a(yL,"unsafeStringify");var _L=require("node:crypto");var gy=new Uint8Array(256),my=gy.length;function s2(){return my>gy.length-16&&((0,_L.randomFillSync)(gy),my=0),gy.slice(my,my+=16)}a(s2,"rng");var bL=require("node:crypto"),o2={randomUUID:bL.randomUUID};function $J(n,e,t){n=n||{};let r=n.random??n.rng?.()??s2();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=r[i];return e}return yL(r)}a($J,"_v4");function UJ(n,e,t){return o2.randomUUID&&!e&&!n?o2.randomUUID():$J(n,e,t)}a(UJ,"v4");var a2=UJ;var _y=Z(It());var VJ="de20a3f1-7483-4714-ab28-b45f5cf02c76",BJ="Asia/Almaty";function GJ(n,e){return!e||e===n?`"[[${n}]]"`:`"[[${n}|${e}]]"`}a(GJ,"buildClassWikilink");var yy=class{constructor(e,t,r,i){this.fsAdapter=e;this.classResolver=t;this.wikilinkValidator=r;this.shapeRegistry=i}static{a(this,"AssetCreationService")}async create(e){if(!e.label||e.label.trim().length===0)throw new Error("Label cannot be empty");let t=e.label.trim(),r=await this.classResolver.resolve(e.vault,e.classShortName);e.properties&&!e.skipWikilinkValidation&&await this.wikilinkValidator.validatePropertyValues(e.properties);let i=a2(),s=this.generateTimestamp(e.timezone),o=this.buildFrontmatter({assetUuid:i,classShortName:e.classShortName,classUuid:r,label:t,aliases:e.aliases,properties:e.properties,createdBy:e.createdBy||VJ,timestamp:s}),l=_y.MetadataHelpers.buildFileContent(o,e.body),c=`01 Inbox/${i}.md`;return e.dryRun||await this.fsAdapter.createFile(c,l),{uuid:i,path:c,label:t,frontmatter:o}}buildFrontmatter(e){let t={};t.exo__Asset_uid=e.assetUuid,t.exo__Asset_label=e.label,t.exo__Asset_createdAt=e.timestamp,t.exo__Asset_createdBy=`"[[${e.createdBy}]]"`,t.exo__Instance_class=[GJ(e.classUuid,e.classShortName)];let r=[e.label];if(e.aliases&&e.aliases.length>0)for(let i of e.aliases)r.includes(i)||r.push(i);if(t.aliases=r,e.properties)for(let[i,s]of Object.entries(e.properties))i==="exo__Asset_uid"||i==="exo__Asset_label"||i==="exo__Asset_createdAt"||i==="exo__Asset_createdBy"||i==="exo__Instance_class"||i==="aliases"||(t[i]=this.formatPropertyValue(i,s));return t}formatPropertyValue(e,t){if(!t.includes("[["))return t;let r=t.startsWith('"')&&t.endsWith('"')?t:`"${t}"`;return this.shouldEmitAsArray(e)?[r]:r}shouldEmitAsArray(e){if(!this.shapeRegistry)return!1;let t=_y.Namespace.fromPropertyKey(e);if(!t)return!1;let r=t.namespace.term(t.localName).value;return this.shapeRegistry.get(r)?.cardinality==="Multiple"}generateTimestamp(e){let t=e||BJ,r=new Date,s=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),o=a(l=>s.find(c=>c.type===l)?.value||"00","get");return`${o("year")}-${o("month")}-${o("day")}T${o("hour")}:${o("minute")}:${o("second")}`}};var uu=require("fs"),l2=require("path"),wL=Z(It());function by(n){(0,wL.registerOrderSpecLoader)(()=>{let e=qJ(n);for(let t of e){let r=WJ(t);if(r)return r}return null})}a(by,"registerOrderSpecFromVault");function qJ(n){return[(0,l2.join)(n,"assetspaces","exo")]}a(qJ,"collectCandidateDirs");function WJ(n){if(!(0,uu.existsSync)(n))return null;let e;try{e=(0,uu.readdirSync)(n)}catch{return null}for(let t of e){if(!t.endsWith(".md"))continue;let r=(0,l2.join)(n,t),i;try{i=(0,uu.readFileSync)(r,"utf-8")}catch{continue}let s=zJ(i);if(s&&/^exo__FrontmatterOrderSpec_default:\s*true\b/m.test(s))return{head:SL(s,"exo__FrontmatterOrderSpec_head"),tail:SL(s,"exo__FrontmatterOrderSpec_tail"),middleStrategy:HJ(s,"exo__FrontmatterOrderSpec_middleStrategy")??"alphabetical"}}return null}a(WJ,"scanDirForDefault");function zJ(n){let e=n.match(/^---\n([\s\S]*?)\n---/);return e?e[1]:null}a(zJ,"extractFrontmatter");function HJ(n,e){let t=new RegExp(`^${vL(e)}:\\s*(.+)$`,"m"),r=n.match(t);return r?r[1].trim():null}a(HJ,"extractScalar");function SL(n,e){let t=new RegExp(`^${vL(e)}:\\s*\\n((?: -.*\\n?)+)`,"m"),r=n.match(t);return r?r[1].split(`
689
- `).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>i.slice(2).trim()):[]}a(SL,"extractList");function vL(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(vL,"escapeRegex");function QJ(n){if(!n||n.length===0)return{};let e={};for(let t of n){let r=t.indexOf("=");if(r===-1)throw new Error(`Invalid property format: "${t}". Expected "key=value" format.`);let i=t.substring(0,r).trim(),s=t.substring(r+1).trim();if(!i)throw new Error(`Invalid property format: "${t}". Key cannot be empty.`);e[i]=s}return e}a(QJ,"parseProperties");async function YJ(n){if(n.bodyFile){if(!(0,c2.existsSync)(n.bodyFile))throw new Error(`Body file not found: ${n.bodyFile}`);return(0,TL.readFileSync)(n.bodyFile,"utf-8")}if(n.body==="-")return XJ(3e4);if(n.body)return n.body}a(YJ,"resolveBody");function XJ(n){return new Promise((e,t)=>{let r=[],i=setTimeout(()=>{process.stdin.removeAllListeners(),process.stdin.destroy(),t(new Error(`Stdin read timed out after ${n}ms. Ensure you pipe content to stdin or close the pipe.`))},n);process.stdin.on("data",s=>{r.push(s)}),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(r).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)}),process.stdin.isTTY&&(clearTimeout(i),e("")),process.stdin.resume()})}a(XJ,"readStdin");function xL(){return new ce("create").description("Create a new vault asset with auto-generated UUID, timestamp, and frontmatter").requiredOption("--class <name>","Class short name (e.g. ztlk__PermanentNote) or UUID").requiredOption("--label <text>","Human-readable label for the asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--aliases <names...>","Additional aliases for the asset").option("--property <key=value...>","Property key-value pairs (repeatable)",KJ,[]).option("--body <text>","Markdown body content (use '-' to read from stdin)").option("--body-file <path>","Read body content from file").option("--dry-run","Preview frontmatter without writing file").option("--created-by <uuid>","Creator UUID (defaults to ExoAssistant)").option("--timezone <tz>","Timezone for timestamps (defaults to Asia/Almaty)").option("--skip-wikilink-validation","Skip wikilink existence validation").action(async n=>{try{let e=(0,EL.resolve)(n.vault);if(!(0,c2.existsSync)(e))throw new he(e);by(e);let t=QJ(n.property),r=await YJ(n);r&&(r=r.replace(/\\n/g,`
689
+ `).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>i.slice(2).trim()):[]}a(SL,"extractList");function vL(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(vL,"escapeRegex");function QJ(n){if(!n||n.length===0)return{};let e={};for(let t of n){let r=t.indexOf("=");if(r===-1)throw new Error(`Invalid property format: "${t}". Expected "key=value" format.`);let i=t.substring(0,r).trim(),s=t.substring(r+1).trim();if(!i)throw new Error(`Invalid property format: "${t}". Key cannot be empty.`);e[i]=s}return e}a(QJ,"parseProperties");async function YJ(n){if(n.bodyFile){if(!(0,c2.existsSync)(n.bodyFile))throw new Error(`Body file not found: ${n.bodyFile}`);return(0,TL.readFileSync)(n.bodyFile,"utf-8")}if(n.body==="-")return XJ(3e4);if(n.body)return n.body}a(YJ,"resolveBody");function XJ(n){return new Promise((e,t)=>{let r=[],i=setTimeout(()=>{process.stdin.removeAllListeners(),process.stdin.destroy(),t(new Error(`Stdin read timed out after ${n}ms. Ensure you pipe content to stdin or close the pipe.`))},n);process.stdin.on("data",s=>{r.push(s)}),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(r).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)}),process.stdin.isTTY&&(clearTimeout(i),e("")),process.stdin.resume()})}a(XJ,"readStdin");function xL(){return new ce("create").description("Create a new vault asset with auto-generated UUID, timestamp, and frontmatter").requiredOption("--class <name>","Class short name (e.g. ztlk__PermanentNote) or UUID").requiredOption("--label <text>","Human-readable label for the asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--aliases <names...>","Additional aliases for the asset").option("--property <key=value...>","Property key-value pairs (repeatable)",KJ,[]).option("--body <text>","Markdown body content (use '-' to read from stdin)").option("--body-file <path>","Read body content from file").option("--dry-run","Preview frontmatter without writing file").option("--created-by <uuid>","Creator UUID (defaults to ExoAssistant)").option("--timezone <tz>","Timezone for timestamps (defaults to Asia/Almaty)").option("--skip-wikilink-validation","Skip wikilink existence validation").action(async n=>{try{let e=(0,EL.resolve)(n.vault);if(!(0,c2.existsSync)(e))throw new pe(e);by(e);let t=QJ(n.property),r=await YJ(n);r&&(r=r.replace(/\\n/g,`
690
690
  `));let i=new yr(e),s=new cu(i),o=new py(i),l;try{l=await IL.ShapeLoader.loadFromVaultFS(e)}catch{l=void 0}let u=await new yy(i,s,o,l).create({classShortName:n.class,label:n.label,aliases:n.aliases,properties:Object.keys(t).length>0?t:void 0,body:r,vault:e,dryRun:n.dryRun,createdBy:n.createdBy,timezone:n.timezone,skipWikilinkValidation:n.skipWikilinkValidation});if(n.dryRun){let d=JJ(u.frontmatter,r);process.stderr.write(d+`
691
691
  `)}let f={uuid:u.uuid,path:u.path,label:u.label};process.stdout.write(JSON.stringify(f)+`
692
- `),process.exit(0)}catch(e){se.handle(e)}})}a(xL,"createCommand");function KJ(n,e){return e.concat([n])}a(KJ,"collect");function JJ(n,e){let t=["--- DRY RUN PREVIEW ---","---"];for(let[r,i]of Object.entries(n))if(Array.isArray(i)){t.push(`${r}:`);for(let s of i)t.push(` - ${s}`)}else t.push(`${r}: ${i}`);return t.push("---"),e&&(t.push(""),t.push(e)),t.push("--- END PREVIEW ---"),t.join(`
692
+ `),process.exit(0)}catch(e){oe.handle(e)}})}a(xL,"createCommand");function KJ(n,e){return e.concat([n])}a(KJ,"collect");function JJ(n,e){let t=["--- DRY RUN PREVIEW ---","---"];for(let[r,i]of Object.entries(n))if(Array.isArray(i)){t.push(`${r}:`);for(let s of i)t.push(` - ${s}`)}else t.push(`${r}: ${i}`);return t.push("---"),e&&(t.push(""),t.push(e)),t.push("--- END PREVIEW ---"),t.join(`
693
693
  `)}a(JJ,"formatFrontmatterPreview");var d2=require("path"),h2=require("fs");var AL=Z(require("path"));var Sy=class{constructor(e,t,r){this.activeFs=e;this.archiveFs=t;this.classResolver=r}static{a(this,"ArchiveService")}async archive(e){let t=await this.resolveClasses(e.vaultPath,e.classes),r=await this.activeFs.getMarkdownFiles(),i=[],s=[];for(let f of r)try{let d=await this.activeFs.readFile(f),h=this.extractFrontmatter(d);if(this.isCandidate(h,t,e.year)){let p=this.extractUUID(f,h);p&&i.push({relativePath:f,uuid:p,metadata:h,content:d})}else h.archived===!0||s.push(d)}catch{continue}let o=this.buildReferenceSet(s),l=[],c=[];for(let f of i)if(e.noReferenced&&o.has(f.uuid)){let d=this.findReferencingFiles(f.uuid,s);l.push({uuid:f.uuid,file:f.relativePath,status:"blocked",reason:"Referenced by non-archived assets",blockedBy:d})}else c.push(f);let u=0;if(e.dryRun){u=await this.countArchiveOntologies(c,e.vaultPath,e.archiveVaultPath);for(let f of c)l.push({uuid:f.uuid,file:f.relativePath,status:"moved",reason:"dry-run: would be moved"})}else{u=await this.createArchiveOntologies(c,e.vaultPath,e.archiveVaultPath);for(let f of c)await this.transferFile(f,e.archiveVaultPath),l.push({uuid:f.uuid,file:f.relativePath,status:"moved"})}return{moved:c.length,blocked:l.filter(f=>f.status==="blocked").length,skipped:0,ontologies_created:u,details:l}}async resolveClasses(e,t){let r=new Set;for(let i of t)try{let s=await this.classResolver.resolve(e,i);r.add(s),r.add(i)}catch{r.add(i)}return r}isCandidate(e,t,r){return!(e.archived!==!0||!this.matchesClass(e,t)||!this.matchesYear(e,r))}matchesClass(e,t){let r=e.exo__Instance_class;return r?(Array.isArray(r)?r:[r]).some(s=>{let o=String(s).replace(/["'[\]]/g,"").trim();return t.has(o)}):!1}matchesYear(e,t){let r=[e.ems__Effort_resolutionTimestamp,e.ems__Effort_endTimestamp];for(let i of r)if(i&&this.extractYear(i)===t)return!0;return!1}extractYear(e){if(e instanceof Date)return e.getFullYear();let r=String(e).match(/^(\d{4})/);return r?parseInt(r[1],10):null}extractUUID(e,t){let r=t.exo__Asset_uid;if(r)return String(r);let i=AL.default.basename(e,".md");return this.isUUID(i)?i:null}buildReferenceSet(e){let t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,r=new Set;for(let i of e){let s=i.match(t);if(s)for(let o of s)r.add(o.toLowerCase())}return r}findReferencingFiles(e,t){return["referenced in active vault"]}async createArchiveOntologies(e,t,r){let i=this.collectOntologies(e),s=0;for(let[o,l]of i.entries()){let c=this.getArchiveOntologyName(o),u=c+".md";if(!await this.archiveFs.fileExists(u))try{let d=await this.activeFs.readFile(o+".md"),h=this.extractFrontmatter(d),p=h.exo__Ontology_url;if(p){let g=String(p).replace(/#$/,"")+"/archive#",_=this.buildOntologyFile(c,g,h);await this.archiveFs.writeFile(u,_),s++}}catch{continue}}return s}async countArchiveOntologies(e,t,r){let i=this.collectOntologies(e),s=0;for(let[o,l]of i.entries()){let u=this.getArchiveOntologyName(o)+".md";if(!await this.archiveFs.fileExists(u))try{let d=await this.activeFs.readFile(o+".md");this.extractFrontmatter(d).exo__Ontology_url&&s++}catch{continue}}return s}collectOntologies(e){let t=new Map;for(let r of e){let i=r.metadata.exo__Asset_isDefinedBy;if(!i)continue;let s=this.extractWikilinkTarget(String(i));if(!s)continue;let o=t.get(s)||[];o.push(r),t.set(s,o)}return t}getArchiveOntologyName(e){return e+"_archive"}buildOntologyFile(e,t,r){let i={exo__Instance_class:r.exo__Instance_class||"exo__Ontology",exo__Asset_label:`${r.exo__Asset_label||e} (Archive)`,exo__Ontology_url:t};return`---
694
694
  ${Wt.dump(i,{lineWidth:-1})}---
695
695
  `}async transferFile(e,t){let r=e.content,i=e.metadata.exo__Asset_isDefinedBy;if(i){let o=this.extractWikilinkTarget(String(i));if(o){let l=this.getArchiveOntologyName(o);r=r.replace(String(i),String(i).replace(o,l))}}let s=e.uuid+".md";await this.archiveFs.writeFile(s,r),await this.activeFs.deleteFile(e.relativePath)}extractWikilinkTarget(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/);return t?t[1]:null}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}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)}};var u2=Z(require("path"));var wy=class{constructor(e,t){this.activeFs=e;this.archiveFs=t}static{a(this,"ArchiveVerifyService")}async verify(){let e=await this.activeFs.getMarkdownFiles(),t=await this.archiveFs.getMarkdownFiles(),r=new Set;for(let c of t){let u=u2.default.basename(c,".md");this.isUUID(u)&&r.add(u.toLowerCase())}let i=[],s=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;for(let c of e)try{let u=await this.activeFs.readFile(c);if(this.extractFrontmatter(u).archived===!0)continue;let d=u.match(s);if(d){let h=new Set;for(let p of d){let g=p.toLowerCase();r.has(g)&&!h.has(g)&&(h.add(g),i.push({uuid:g,referenced_from:c}))}}}catch{continue}let o=await this.checkArchiveOntologies(t),l=i.length===0&&o.length===0;return{broken_links:i.length,broken_link_details:i,missing_ontologies:o,stats:{active_files:e.length,archive_files:t.length},ok:l}}async checkArchiveOntologies(e){let t=new Set;for(let i of e)if(!u2.default.basename(i,".md").startsWith("!"))try{let o=await this.archiveFs.readFile(i),c=this.extractFrontmatter(o).exo__Asset_isDefinedBy;if(c){let u=this.extractWikilinkTarget(String(c));if(u&&u.startsWith("!")){let f=u.endsWith("_archive")?u:u+"_archive";t.add(f)}}}catch{continue}let r=[];for(let i of t){let s=i+".md";await this.archiveFs.fileExists(s)||r.push(i)}return r.sort()}extractWikilinkTarget(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/);return t?t[1]:null}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}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)}};var RL=Z(require("path"));var f2=100,vy=class{constructor(e,t){this.activeFs=e;this.archiveFs=t}static{a(this,"ArchiveCascadeService")}async cascade(e){let t={iterations:0,total_moved:0,still_blocked:0,iterations_detail:[]};for(let r=0;r<f2;r++){let i=await this.activeFs.getMarkdownFiles(),s=await this.readAllFiles(i),o=s.filter(d=>d.isArchived&&d.uuid),l=s.filter(d=>!d.isArchived);if(o.length===0)break;let c=this.buildReferenceSet(l.map(d=>d.content)),u=o.filter(d=>!c.has(d.uuid.toLowerCase()));if(u.length===0){t.still_blocked=o.length;break}let f=[];if(e.dryRun)for(let d of u)f.push(d.uuid);else{await this.createArchiveOntologies(u);for(let d of u)await this.transferFile(d),f.push(d.uuid)}if(t.iterations++,t.total_moved+=f.length,t.iterations_detail.push({iteration:t.iterations,moved:f}),e.dryRun){let d=o.length-u.length;t.still_blocked=d;break}}if(t.iterations>=f2)throw new Error(`MAX_ITERATIONS (${f2}) exceeded during cascade archive. This likely indicates a bug. Moved ${t.total_moved} assets before stopping.`);if(t.iterations>0&&t.still_blocked===0&&!e.dryRun){let r=await this.activeFs.getMarkdownFiles(),i=await this.readAllFiles(r);t.still_blocked=i.filter(s=>s.isArchived&&s.uuid).length}return t}async readAllFiles(e){let t=[];for(let r of e)try{let i=await this.activeFs.readFile(r),s=this.extractFrontmatter(i),o=s.archived===!0,l=this.extractUUID(r,s);t.push({relativePath:r,uuid:l||"",metadata:s,content:i,isArchived:o})}catch{continue}return t}buildReferenceSet(e){let t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,r=new Set;for(let i of e){let s=i.match(t);if(s)for(let o of s)r.add(o.toLowerCase())}return r}async createArchiveOntologies(e){let t=this.collectOntologies(e),r=0;for(let[i]of t.entries()){let s=i+"_archive",o=s+".md";if(!await this.archiveFs.fileExists(o))try{let c=await this.activeFs.readFile(i+".md"),u=this.extractFrontmatter(c),f=u.exo__Ontology_url;if(f){let d=String(f).replace(/#$/,"")+"/archive#",h=this.buildOntologyFile(s,d,u);await this.archiveFs.writeFile(o,h),r++}}catch{continue}}return r}collectOntologies(e){let t=new Map;for(let r of e){let i=r.metadata.exo__Asset_isDefinedBy;if(!i)continue;let s=this.extractWikilinkTarget(String(i));if(!s)continue;let o=t.get(s)||[];o.push(r),t.set(s,o)}return t}buildOntologyFile(e,t,r){let i={exo__Instance_class:r.exo__Instance_class||"exo__Ontology",exo__Asset_label:`${r.exo__Asset_label||e} (Archive)`,exo__Ontology_url:t};return`---
696
696
  ${Wt.dump(i,{lineWidth:-1})}---
697
- `}async transferFile(e){let t=e.content,r=e.metadata.exo__Asset_isDefinedBy;if(r){let s=this.extractWikilinkTarget(String(r));if(s){let o=s+"_archive";t=t.replace(String(r),String(r).replace(s,o))}}let i=e.uuid+".md";await this.archiveFs.writeFile(i,t),await this.activeFs.deleteFile(e.relativePath)}extractWikilinkTarget(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/);return t?t[1]:null}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}extractUUID(e,t){let r=t.exo__Asset_uid;if(r)return String(r);let i=RL.default.basename(e,".md");return this.isUUID(i)?i: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)}};var Ey=class{constructor(e){this.fs=e}static{a(this,"ArchiveStatsService")}async collect(){let e=await this.fs.getMarkdownFiles(),t={total:0,by_class:{},by_year:{},cross:{}};for(let r of e)try{let i=await this.fs.readFile(r),s=this.extractFrontmatter(i);t.total++;let o=this.extractClass(s);t.by_class[o]=(t.by_class[o]??0)+1;let l=this.extractYear(s);t.by_year[l]=(t.by_year[l]??0)+1,t.cross[o]||(t.cross[o]={}),t.cross[o][l]=(t.cross[o][l]??0)+1}catch{continue}return t}extractClass(e){let t=e.exo__Instance_class;if(!t)return"unknown";let r=Array.isArray(t)?t[0]:t,i=String(r).replace(/^"|"$/g,""),s=i.match(/\[\[[^\]|]+\|([^\]]+)\]\]/);if(s)return s[1];let o=i.match(/\[\[([^\]]+)\]\]/);return o?o[1]:i||"unknown"}extractYear(e){let t=e.ems__Effort_resolutionTimestamp??e.ems__Effort_endTimestamp;if(!t)return"unknown";if(t instanceof Date){let s=t.getFullYear();return isNaN(s)?"unknown":s.toString()}let i=String(t).match(/^(\d{4})/);return i?i[1]:"unknown"}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}};function CL(){return new ce("archive").description("Archive assets from active vault to archive vault (automated asset archival)").requiredOption("--vault <path>","Path to the active vault").requiredOption("--archive-vault <path>","Path to the archive vault").option("--class <names>","Comma-separated class short names or UUIDs (e.g. ems__Task,ems__Meeting)").option("--year <year>","Filter by resolution/end timestamp year (e.g. 2025)").option("--dry-run","Preview without writing files",!1).option("--no-referenced","Skip assets referenced by non-archived (default: true)").option("--verify","Verify archive integrity instead of archiving (read-only)",!1).option("--cascade","Iteratively resolve archived-to-archived chains (no --class/--year needed)",!1).option("--stats","Print archive vault statistics by class and year (read-only)",!1).action(async n=>{try{let e=(0,d2.resolve)(n.vault);if(!(0,h2.existsSync)(e))throw new he(e);let t=(0,d2.resolve)(n.archiveVault);if(!(0,h2.existsSync)(t))throw new he(t);if(n.stats){let h=new yr(t),g=await new Ey(h).collect();process.stderr.write(ZJ(g)),process.stdout.write(JSON.stringify(g)+`
697
+ `}async transferFile(e){let t=e.content,r=e.metadata.exo__Asset_isDefinedBy;if(r){let s=this.extractWikilinkTarget(String(r));if(s){let o=s+"_archive";t=t.replace(String(r),String(r).replace(s,o))}}let i=e.uuid+".md";await this.archiveFs.writeFile(i,t),await this.activeFs.deleteFile(e.relativePath)}extractWikilinkTarget(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/);return t?t[1]:null}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}extractUUID(e,t){let r=t.exo__Asset_uid;if(r)return String(r);let i=RL.default.basename(e,".md");return this.isUUID(i)?i: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)}};var Ey=class{constructor(e){this.fs=e}static{a(this,"ArchiveStatsService")}async collect(){let e=await this.fs.getMarkdownFiles(),t={total:0,by_class:{},by_year:{},cross:{}};for(let r of e)try{let i=await this.fs.readFile(r),s=this.extractFrontmatter(i);t.total++;let o=this.extractClass(s);t.by_class[o]=(t.by_class[o]??0)+1;let l=this.extractYear(s);t.by_year[l]=(t.by_year[l]??0)+1,t.cross[o]||(t.cross[o]={}),t.cross[o][l]=(t.cross[o][l]??0)+1}catch{continue}return t}extractClass(e){let t=e.exo__Instance_class;if(!t)return"unknown";let r=Array.isArray(t)?t[0]:t,i=String(r).replace(/^"|"$/g,""),s=i.match(/\[\[[^\]|]+\|([^\]]+)\]\]/);if(s)return s[1];let o=i.match(/\[\[([^\]]+)\]\]/);return o?o[1]:i||"unknown"}extractYear(e){let t=e.ems__Effort_resolutionTimestamp??e.ems__Effort_endTimestamp;if(!t)return"unknown";if(t instanceof Date){let s=t.getFullYear();return isNaN(s)?"unknown":s.toString()}let i=String(t).match(/^(\d{4})/);return i?i[1]:"unknown"}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}};function CL(){return new ce("archive").description("Archive assets from active vault to archive vault (automated asset archival)").requiredOption("--vault <path>","Path to the active vault").requiredOption("--archive-vault <path>","Path to the archive vault").option("--class <names>","Comma-separated class short names or UUIDs (e.g. ems__Task,ems__Meeting)").option("--year <year>","Filter by resolution/end timestamp year (e.g. 2025)").option("--dry-run","Preview without writing files",!1).option("--no-referenced","Skip assets referenced by non-archived (default: true)").option("--verify","Verify archive integrity instead of archiving (read-only)",!1).option("--cascade","Iteratively resolve archived-to-archived chains (no --class/--year needed)",!1).option("--stats","Print archive vault statistics by class and year (read-only)",!1).action(async n=>{try{let e=(0,d2.resolve)(n.vault);if(!(0,h2.existsSync)(e))throw new pe(e);let t=(0,d2.resolve)(n.archiveVault);if(!(0,h2.existsSync)(t))throw new pe(t);if(n.stats){let h=new yr(t),g=await new Ey(h).collect();process.stderr.write(ZJ(g)),process.stdout.write(JSON.stringify(g)+`
698
698
  `),process.exit(0)}if(n.verify){let h=new yr(e),p=new yr(t),_=await new wy(h,p).verify();process.stdout.write(JSON.stringify(_,null,2)+`
699
699
  `),process.exit(_.ok?0:1)}if(n.cascade){let h=new yr(e),p=new yr(t),_=await new vy(h,p).cascade({vaultPath:e,archiveVaultPath:t,dryRun:n.dryRun||!1});n.dryRun&&(process.stderr.write(`--- CASCADE DRY RUN PREVIEW ---
700
700
  `),process.stderr.write(`Would move: ${_.total_moved} assets
@@ -709,23 +709,23 @@ ${Wt.dump(i,{lineWidth:-1})}---
709
709
  `),process.stderr.write(`Would create: ${f.ontologies_created} archive ontologies
710
710
  `),process.stderr.write(`--- END PREVIEW ---
711
711
  `)),process.stdout.write(JSON.stringify(d)+`
712
- `),process.exit(0)}catch(e){se.handle(e)}})}a(CL,"archiveCommand");function ZJ(n){let e=["--- ARCHIVE STATS ---"];if(e.push(`Total assets: ${n.total}`),Object.keys(n.by_class).length>0){e.push(""),e.push("By class:");let t=Object.entries(n.by_class).sort((r,i)=>i[1]-r[1]);for(let[r,i]of t)e.push(` ${r}: ${i}`)}if(Object.keys(n.by_year).length>0){e.push(""),e.push("By year:");let t=Object.entries(n.by_year).sort((r,i)=>r[0].localeCompare(i[0]));for(let[r,i]of t)e.push(` ${r}: ${i}`)}return e.push("--- END STATS ---"),e.join(`
712
+ `),process.exit(0)}catch(e){oe.handle(e)}})}a(CL,"archiveCommand");function ZJ(n){let e=["--- ARCHIVE STATS ---"];if(e.push(`Total assets: ${n.total}`),Object.keys(n.by_class).length>0){e.push(""),e.push("By class:");let t=Object.entries(n.by_class).sort((r,i)=>i[1]-r[1]);for(let[r,i]of t)e.push(` ${r}: ${i}`)}if(Object.keys(n.by_year).length>0){e.push(""),e.push("By year:");let t=Object.entries(n.by_year).sort((r,i)=>r[0].localeCompare(i[0]));for(let[r,i]of t)e.push(` ${r}: ${i}`)}return e.push("--- END STATS ---"),e.join(`
713
713
  `)+`
714
- `}a(ZJ,"formatStatsSummary");var m2=require("path"),g2=require("fs");var p2=Z(require("path"));var Ty=class{constructor(e,t){this.activeFs=e;this.archiveFs=t}static{a(this,"UnarchiveService")}async unarchive(e){let{uuid:t,dryRun:r}=e,i=await this.findAssetByUUID(t);if(!i)return{success:!1,uuid:t,error:`UUID ${t} not found in archive vault`};let s=await this.archiveFs.readFile(i),l=this.extractFrontmatter(s).exo__Asset_isDefinedBy,c=l?this.resolveActiveOntology(String(l)):null,u=p2.default.join("03 Knowledge","inbox",p2.default.basename(i));if(r)return{success:!0,uuid:t,movedTo:u,isDefinedBy:c||void 0};let f=s;return l&&c&&(f=f.replace(String(l),c)),await this.activeFs.writeFile(u,f),await this.archiveFs.deleteFile(i),{success:!0,uuid:t,movedTo:u,isDefinedBy:c||void 0}}async findAssetByUUID(e){let t=e+".md";if(await this.archiveFs.fileExists(t))return t;let i=await this.archiveFs.getMarkdownFiles();for(let s of i)try{let o=await this.archiveFs.readFile(s),c=this.extractFrontmatter(o).exo__Asset_uid;if(c&&String(c).toLowerCase()===e.toLowerCase())return s}catch{continue}return null}resolveActiveOntology(e){let t=e.match(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/);if(!t)return null;let r=t[1],i=t[2];if(!r.endsWith("_archive"))return e;let s=r.replace(/_archive$/,"");if(i){let o=i.replace(/\s*\(Archive\)$/,"");return`[[${s}|${o}]]`}return`[[${s}]]`}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}};function PL(){return new ce("unarchive").description("Restore asset from archive vault to active vault (reverse of archive)").requiredOption("--uuid <uuid>","UUID of the asset to restore").requiredOption("--vault <path>","Path to the active vault").requiredOption("--archive-vault <path>","Path to the archive vault").option("--dry-run","Preview without writing files",!1).action(async n=>{try{let e=(0,m2.resolve)(n.vault);if(!(0,g2.existsSync)(e))throw new he(e);let t=(0,m2.resolve)(n.archiveVault);if(!(0,g2.existsSync)(t))throw new he(t);if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n.uuid))throw new Error(`Invalid UUID format: ${n.uuid}. Expected format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`);let i=new yr(e),s=new yr(t),l=await new Ty(i,s).unarchive({uuid:n.uuid,vaultPath:e,archiveVaultPath:t,dryRun:n.dryRun||!1});l.success||(process.stdout.write(JSON.stringify({error:l.error})+`
714
+ `}a(ZJ,"formatStatsSummary");var m2=require("path"),g2=require("fs");var p2=Z(require("path"));var Ty=class{constructor(e,t){this.activeFs=e;this.archiveFs=t}static{a(this,"UnarchiveService")}async unarchive(e){let{uuid:t,dryRun:r}=e,i=await this.findAssetByUUID(t);if(!i)return{success:!1,uuid:t,error:`UUID ${t} not found in archive vault`};let s=await this.archiveFs.readFile(i),l=this.extractFrontmatter(s).exo__Asset_isDefinedBy,c=l?this.resolveActiveOntology(String(l)):null,u=p2.default.join("03 Knowledge","inbox",p2.default.basename(i));if(r)return{success:!0,uuid:t,movedTo:u,isDefinedBy:c||void 0};let f=s;return l&&c&&(f=f.replace(String(l),c)),await this.activeFs.writeFile(u,f),await this.archiveFs.deleteFile(i),{success:!0,uuid:t,movedTo:u,isDefinedBy:c||void 0}}async findAssetByUUID(e){let t=e+".md";if(await this.archiveFs.fileExists(t))return t;let i=await this.archiveFs.getMarkdownFiles();for(let s of i)try{let o=await this.archiveFs.readFile(s),c=this.extractFrontmatter(o).exo__Asset_uid;if(c&&String(c).toLowerCase()===e.toLowerCase())return s}catch{continue}return null}resolveActiveOntology(e){let t=e.match(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/);if(!t)return null;let r=t[1],i=t[2];if(!r.endsWith("_archive"))return e;let s=r.replace(/_archive$/,"");if(i){let o=i.replace(/\s*\(Archive\)$/,"");return`[[${s}|${o}]]`}return`[[${s}]]`}extractFrontmatter(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return{};try{let r=Wt.load(t[1]);return typeof r=="object"&&r!==null?r:{}}catch{return{}}}};function PL(){return new ce("unarchive").description("Restore asset from archive vault to active vault (reverse of archive)").requiredOption("--uuid <uuid>","UUID of the asset to restore").requiredOption("--vault <path>","Path to the active vault").requiredOption("--archive-vault <path>","Path to the archive vault").option("--dry-run","Preview without writing files",!1).action(async n=>{try{let e=(0,m2.resolve)(n.vault);if(!(0,g2.existsSync)(e))throw new pe(e);let t=(0,m2.resolve)(n.archiveVault);if(!(0,g2.existsSync)(t))throw new pe(t);if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n.uuid))throw new Error(`Invalid UUID format: ${n.uuid}. Expected format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`);let i=new yr(e),s=new yr(t),l=await new Ty(i,s).unarchive({uuid:n.uuid,vaultPath:e,archiveVaultPath:t,dryRun:n.dryRun||!1});l.success||(process.stdout.write(JSON.stringify({error:l.error})+`
715
715
  `),process.exit(1)),n.dryRun&&(process.stderr.write(`--- DRY RUN PREVIEW ---
716
716
  `),process.stderr.write(`Would restore: ${l.uuid}
717
717
  `),process.stderr.write(`Target: ${l.movedTo}
718
718
  `),l.isDefinedBy&&process.stderr.write(`isDefinedBy: ${l.isDefinedBy}
719
719
  `),process.stderr.write(`--- END PREVIEW ---
720
720
  `)),process.stdout.write(JSON.stringify(l)+`
721
- `),process.exit(0)}catch(e){se.handle(e)}})}a(PL,"unarchiveCommand");var wo=require("fs"),du=require("path"),vn=Z(It());function FL(){let n=new ce("workflow").description("Manage custom workflow definitions");return n.command("list").description("List all workflow definitions in the vault").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async e=>{let t=e.output||"text";se.setFormat(t);try{let r=(0,du.resolve)(e.vault);if(!(0,wo.existsSync)(r))throw new he(r);let i=LL(r);if(t==="json"){let s=Ne.success({workflows:i,totalWorkflows:i.length});console.log(JSON.stringify(s,null,2))}else{if(i.length===0){console.log("No workflows found in vault.");return}console.log(`
721
+ `),process.exit(0)}catch(e){oe.handle(e)}})}a(PL,"unarchiveCommand");var wo=require("fs"),du=require("path"),vn=Z(It());function FL(){let n=new ce("workflow").description("Manage custom workflow definitions");return n.command("list").description("List all workflow definitions in the vault").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async e=>{let t=e.output||"text";oe.setFormat(t);try{let r=(0,du.resolve)(e.vault);if(!(0,wo.existsSync)(r))throw new pe(r);let i=LL(r);if(t==="json"){let s=Ne.success({workflows:i,totalWorkflows:i.length});console.log(JSON.stringify(s,null,2))}else{if(i.length===0){console.log("No workflows found in vault.");return}console.log(`
722
722
  \u{1F4CB} Found ${i.length} workflow(s):
723
- `);let s=Math.max(...i.map(l=>l.label.length),4),o=Math.max(...i.map(l=>l.targetClass.length),12);console.log("\u250C"+"\u2500".repeat(s+2)+"\u252C"+"\u2500".repeat(o+2)+"\u252C"+"\u2500".repeat(8)+"\u252C"+"\u2500".repeat(13)+"\u252C"+"\u2500".repeat(9)+"\u2510"),console.log("\u2502 "+"Name".padEnd(s)+" \u2502 "+"Target Class".padEnd(o)+" \u2502 "+"States".padEnd(6)+" \u2502 "+"Transitions".padEnd(11)+" \u2502 "+"Default".padEnd(7)+" \u2502"),console.log("\u251C"+"\u2500".repeat(s+2)+"\u253C"+"\u2500".repeat(o+2)+"\u253C"+"\u2500".repeat(8)+"\u253C"+"\u2500".repeat(13)+"\u253C"+"\u2500".repeat(9)+"\u2524");for(let l of i)console.log("\u2502 "+l.label.padEnd(s)+" \u2502 "+l.targetClass.padEnd(o)+" \u2502 "+l.stateCount.toString().padStart(6)+" \u2502 "+l.transitionCount.toString().padStart(11)+" \u2502 "+(l.isDefault?" yes ":" no ")+" \u2502");console.log("\u2514"+"\u2500".repeat(s+2)+"\u2534"+"\u2500".repeat(o+2)+"\u2534"+"\u2500".repeat(8)+"\u2534"+"\u2500".repeat(13)+"\u2534"+"\u2500".repeat(9)+"\u2518")}}catch(r){se.handle(r)}}),n.command("show").description("Show details of a workflow definition").argument("<uid>","UID of the workflow asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async(e,t)=>{let r=t.output||"text";se.setFormat(r);try{let i=(0,du.resolve)(t.vault);if(!(0,wo.existsSync)(i))throw new he(i);let s=OL(i,e);if(!s){if(r==="json"){let o=Ne.success({error:`Workflow with UID "${e}" not found`});console.log(JSON.stringify(o,null,2))}else console.log(`\u274C Workflow with UID "${e}" not found.`);process.exitCode=1;return}if(r==="json"){let o=Ne.success(s);console.log(JSON.stringify(o,null,2))}else{console.log(`
723
+ `);let s=Math.max(...i.map(l=>l.label.length),4),o=Math.max(...i.map(l=>l.targetClass.length),12);console.log("\u250C"+"\u2500".repeat(s+2)+"\u252C"+"\u2500".repeat(o+2)+"\u252C"+"\u2500".repeat(8)+"\u252C"+"\u2500".repeat(13)+"\u252C"+"\u2500".repeat(9)+"\u2510"),console.log("\u2502 "+"Name".padEnd(s)+" \u2502 "+"Target Class".padEnd(o)+" \u2502 "+"States".padEnd(6)+" \u2502 "+"Transitions".padEnd(11)+" \u2502 "+"Default".padEnd(7)+" \u2502"),console.log("\u251C"+"\u2500".repeat(s+2)+"\u253C"+"\u2500".repeat(o+2)+"\u253C"+"\u2500".repeat(8)+"\u253C"+"\u2500".repeat(13)+"\u253C"+"\u2500".repeat(9)+"\u2524");for(let l of i)console.log("\u2502 "+l.label.padEnd(s)+" \u2502 "+l.targetClass.padEnd(o)+" \u2502 "+l.stateCount.toString().padStart(6)+" \u2502 "+l.transitionCount.toString().padStart(11)+" \u2502 "+(l.isDefault?" yes ":" no ")+" \u2502");console.log("\u2514"+"\u2500".repeat(s+2)+"\u2534"+"\u2500".repeat(o+2)+"\u2534"+"\u2500".repeat(8)+"\u2534"+"\u2500".repeat(13)+"\u2534"+"\u2500".repeat(9)+"\u2518")}}catch(r){oe.handle(r)}}),n.command("show").description("Show details of a workflow definition").argument("<uid>","UID of the workflow asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async(e,t)=>{let r=t.output||"text";oe.setFormat(r);try{let i=(0,du.resolve)(t.vault);if(!(0,wo.existsSync)(i))throw new pe(i);let s=OL(i,e);if(!s){if(r==="json"){let o=Ne.success({error:`Workflow with UID "${e}" not found`});console.log(JSON.stringify(o,null,2))}else console.log(`\u274C Workflow with UID "${e}" not found.`);process.exitCode=1;return}if(r==="json"){let o=Ne.success(s);console.log(JSON.stringify(o,null,2))}else{console.log(`
724
724
  \u{1F4CB} Workflow: ${s.name}
725
725
  `),console.log(` ID: ${s.id}`),console.log(` Target class: ${s.targetClass}`),console.log(` Initial state: ${s.initialState}`),console.log(` Terminal states: ${s.terminalStates.join(", ")}`),console.log(` Default: ${s.isDefault?"yes":"no"}`),console.log(`
726
726
  States (${s.states.length}):`);for(let o of s.states){let l=o.optional?" (optional)":"",c=o.timestampOnEnter.length>0?` [timestamps: ${o.timestampOnEnter.join(", ")}]`:"";console.log(` ${o.order}. ${o.status}${l}${c}`)}console.log(`
727
- Transitions (${s.transitions.length}):`);for(let o of s.transitions){let l=o.isRollback?" (rollback)":"";console.log(` ${o.label}: ${o.from} \u2192 ${o.to}${l}`)}}}catch(i){se.handle(i)}}),n.command("validate").description("Validate a workflow definition").argument("<uid>","UID of the workflow asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async(e,t)=>{let r=t.output||"text";se.setFormat(r);try{let i=(0,du.resolve)(t.vault);if(!(0,wo.existsSync)(i))throw new he(i);let s=OL(i,e);if(!s){if(r==="json"){let c=Ne.success({error:`Workflow with UID "${e}" not found`});console.log(JSON.stringify(c,null,2))}else console.log(`\u274C Workflow with UID "${e}" not found.`);process.exitCode=1;return}let l=new vn.WorkflowEngine(s).validate();if(r==="json"){let c=Ne.success({workflow:s.name,uid:s.id,...l});console.log(JSON.stringify(c,null,2))}else if(l.valid)console.log(`\u2705 Workflow "${s.name}" is valid.`);else{console.log(`\u274C Workflow "${s.name}" has ${l.errors.length} error(s):
728
- `);for(let c of l.errors)console.log(` \u2022 ${c}`);process.exitCode=1}}catch(i){se.handle(i)}}),n}a(FL,"workflowCommand");var DL=new vn.FrontmatterService;function LL(n){let e=[],t=[];NL(n,t);let r=new Map;for(let{fm:c}of t){let u=c.exo__Asset_uid,f=c.exo__Asset_label;u&&f&&r.set(String(u),String(f))}let i=a(c=>r.get(c)??null,"resolver"),s=a(c=>{let u=vn.WikiLinkHelpers.resolveSymbolic(typeof c=="string"?c:String(c??""),i);return u.includes("ems__Workflow")&&!u.includes("WorkflowState")&&!u.includes("WorkflowTransition")},"isWorkflowClass"),o=a(c=>vn.WikiLinkHelpers.resolveSymbolic(typeof c=="string"?c:String(c??""),i).includes("ems__WorkflowState"),"isWorkflowStateClass"),l=a(c=>vn.WikiLinkHelpers.resolveSymbolic(typeof c=="string"?c:String(c??""),i).includes("ems__WorkflowTransition"),"isWorkflowTransitionClass");for(let{filePath:c,fm:u}of t){let f=u.exo__Instance_class;if(!f||!(Array.isArray(f)?f.some(s):s(f)))continue;let h=u.exo__Asset_uid??"",p=u.exo__Asset_label??eZ(c),g=So(u.ems__Workflow_targetClass??"ems__Task"),_=u.ems__Workflow_isDefault===!0||u.ems__Workflow_isDefault==="true",v=0,w=0;for(let{fm:E}of t){let I=E.exo__Instance_class;if(!So(E.ems__WorkflowState_workflow??E.ems__WorkflowTransition_workflow??"").includes(h))continue;let K=Array.isArray(I)?I.some(o):o(I),oe=Array.isArray(I)?I.some(l):l(I);K&&v++,oe&&w++}e.push({filePath:c,uid:h,label:p,targetClass:g,isDefault:_,stateCount:v,transitionCount:w})}return e}a(LL,"scanWorkflows");function NL(n,e){let t;try{t=(0,wo.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,du.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;NL(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,wo.readFileSync)(i,"utf-8"),o=DL.parse(s);o.exists&&e.push({filePath:i,fm:kL(o.content)})}catch{}}}a(NL,"collectParsedFiles");function OL(n,e){let r=LL(n).find(i=>i.uid===e);if(!r)return null;try{let i=(0,wo.readFileSync)(r.filePath,"utf-8"),s=DL.parse(i);if(!s.exists)return null;let o=kL(s.content),l=So(o.ems__Workflow_targetClass??"ems__Task"),c=So(o.ems__Workflow_initialState??"ems__EffortStatusDraft"),u=fu(c)??vn.EffortStatus.DRAFT,d=(Array.isArray(o.ems__Workflow_terminalStates)?o.ems__Workflow_terminalStates.map(w=>So(w)):[]).map(fu).filter(w=>w!==null),h=o.ems__Workflow_isDefault===!0||o.ems__Workflow_isDefault==="true",g=(Array.isArray(o.ems__Workflow_states)?o.ems__Workflow_states:[]).map((w,E)=>typeof w=="string"?{status:fu(So(w))??vn.EffortStatus.DRAFT,order:E+1,optional:!1,timestampOnEnter:[]}:{status:fu(So(w.status??""))??vn.EffortStatus.DRAFT,order:w.order??E+1,optional:w.optional===!0||w.optional==="true",timestampOnEnter:Array.isArray(w.timestampOnEnter)?w.timestampOnEnter:[],badgeColor:w.badgeColor}),v=(Array.isArray(o.ems__Workflow_transitions)?o.ems__Workflow_transitions:[]).map(w=>{let E=fu(So(w.from??"")),I=fu(So(w.to??""));return!E||!I?null:{from:E,to:I,label:w.label??`${E} \u2192 ${I}`,icon:w.icon,isRollback:w.isRollback===!0||w.isRollback==="true"}}).filter(w=>w!==null);return{id:e,name:r.label,targetClass:l,states:g,transitions:v,initialState:u,terminalStates:d.length>0?d:[vn.EffortStatus.DONE,vn.EffortStatus.TRASHED],isDefault:h}}catch{return null}}a(OL,"loadWorkflowByUid");function kL(n){let e={},t=n.split(`
727
+ Transitions (${s.transitions.length}):`);for(let o of s.transitions){let l=o.isRollback?" (rollback)":"";console.log(` ${o.label}: ${o.from} \u2192 ${o.to}${l}`)}}}catch(i){oe.handle(i)}}),n.command("validate").description("Validate a workflow definition").argument("<uid>","UID of the workflow asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--output <type>","Response format: text|json","text").action(async(e,t)=>{let r=t.output||"text";oe.setFormat(r);try{let i=(0,du.resolve)(t.vault);if(!(0,wo.existsSync)(i))throw new pe(i);let s=OL(i,e);if(!s){if(r==="json"){let c=Ne.success({error:`Workflow with UID "${e}" not found`});console.log(JSON.stringify(c,null,2))}else console.log(`\u274C Workflow with UID "${e}" not found.`);process.exitCode=1;return}let l=new vn.WorkflowEngine(s).validate();if(r==="json"){let c=Ne.success({workflow:s.name,uid:s.id,...l});console.log(JSON.stringify(c,null,2))}else if(l.valid)console.log(`\u2705 Workflow "${s.name}" is valid.`);else{console.log(`\u274C Workflow "${s.name}" has ${l.errors.length} error(s):
728
+ `);for(let c of l.errors)console.log(` \u2022 ${c}`);process.exitCode=1}}catch(i){oe.handle(i)}}),n}a(FL,"workflowCommand");var DL=new vn.FrontmatterService;function LL(n){let e=[],t=[];NL(n,t);let r=new Map;for(let{fm:c}of t){let u=c.exo__Asset_uid,f=c.exo__Asset_label;u&&f&&r.set(String(u),String(f))}let i=a(c=>r.get(c)??null,"resolver"),s=a(c=>{let u=vn.WikiLinkHelpers.resolveSymbolic(typeof c=="string"?c:String(c??""),i);return u.includes("ems__Workflow")&&!u.includes("WorkflowState")&&!u.includes("WorkflowTransition")},"isWorkflowClass"),o=a(c=>vn.WikiLinkHelpers.resolveSymbolic(typeof c=="string"?c:String(c??""),i).includes("ems__WorkflowState"),"isWorkflowStateClass"),l=a(c=>vn.WikiLinkHelpers.resolveSymbolic(typeof c=="string"?c:String(c??""),i).includes("ems__WorkflowTransition"),"isWorkflowTransitionClass");for(let{filePath:c,fm:u}of t){let f=u.exo__Instance_class;if(!f||!(Array.isArray(f)?f.some(s):s(f)))continue;let h=u.exo__Asset_uid??"",p=u.exo__Asset_label??eZ(c),g=So(u.ems__Workflow_targetClass??"ems__Task"),_=u.ems__Workflow_isDefault===!0||u.ems__Workflow_isDefault==="true",v=0,w=0;for(let{fm:E}of t){let I=E.exo__Instance_class;if(!So(E.ems__WorkflowState_workflow??E.ems__WorkflowTransition_workflow??"").includes(h))continue;let H=Array.isArray(I)?I.some(o):o(I),ne=Array.isArray(I)?I.some(l):l(I);H&&v++,ne&&w++}e.push({filePath:c,uid:h,label:p,targetClass:g,isDefault:_,stateCount:v,transitionCount:w})}return e}a(LL,"scanWorkflows");function NL(n,e){let t;try{t=(0,wo.readdirSync)(n,{withFileTypes:!0})}catch{return}for(let r of t){let i=(0,du.join)(n,r.name);if(r.isDirectory()){if(r.name.startsWith(".")||r.name==="node_modules")continue;NL(i,e)}else if(r.name.endsWith(".md"))try{let s=(0,wo.readFileSync)(i,"utf-8"),o=DL.parse(s);o.exists&&e.push({filePath:i,fm:kL(o.content)})}catch{}}}a(NL,"collectParsedFiles");function OL(n,e){let r=LL(n).find(i=>i.uid===e);if(!r)return null;try{let i=(0,wo.readFileSync)(r.filePath,"utf-8"),s=DL.parse(i);if(!s.exists)return null;let o=kL(s.content),l=So(o.ems__Workflow_targetClass??"ems__Task"),c=So(o.ems__Workflow_initialState??"ems__EffortStatusDraft"),u=fu(c)??vn.EffortStatus.DRAFT,d=(Array.isArray(o.ems__Workflow_terminalStates)?o.ems__Workflow_terminalStates.map(w=>So(w)):[]).map(fu).filter(w=>w!==null),h=o.ems__Workflow_isDefault===!0||o.ems__Workflow_isDefault==="true",g=(Array.isArray(o.ems__Workflow_states)?o.ems__Workflow_states:[]).map((w,E)=>typeof w=="string"?{status:fu(So(w))??vn.EffortStatus.DRAFT,order:E+1,optional:!1,timestampOnEnter:[]}:{status:fu(So(w.status??""))??vn.EffortStatus.DRAFT,order:w.order??E+1,optional:w.optional===!0||w.optional==="true",timestampOnEnter:Array.isArray(w.timestampOnEnter)?w.timestampOnEnter:[],badgeColor:w.badgeColor}),v=(Array.isArray(o.ems__Workflow_transitions)?o.ems__Workflow_transitions:[]).map(w=>{let E=fu(So(w.from??"")),I=fu(So(w.to??""));return!E||!I?null:{from:E,to:I,label:w.label??`${E} \u2192 ${I}`,icon:w.icon,isRollback:w.isRollback===!0||w.isRollback==="true"}}).filter(w=>w!==null);return{id:e,name:r.label,targetClass:l,states:g,transitions:v,initialState:u,terminalStates:d.length>0?d:[vn.EffortStatus.DONE,vn.EffortStatus.TRASHED],isDefault:h}}catch{return null}}a(OL,"loadWorkflowByUid");function kL(n){let e={},t=n.split(`
729
729
  `),r="",i=null;for(let s of t){if(s.match(/^\s+-\s+/)&&r){let l=s.replace(/^\s+-\s+/,"").trim();i||(i=[]),i.push(l),e[r]=i;continue}let o=s.match(/^([a-zA-Z0-9_]+):\s*(.*)/);if(o){r=o[1],i=null;let l=o[2].trim();if((l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),l==="true"?l=!0:l==="false"&&(l=!1),l===""){e[r]=[],i=e[r];continue}e[r]=l}}return e}a(kL,"parseYamlFrontmatter");function So(n){return typeof n!="string"?"":n.replace(/["'[\]]/g,"").trim()}a(So,"normalizeWikilink");function eZ(n){let e=n.split("/");return e[e.length-1].replace(/\.md$/,"")}a(eZ,"extractLabelFromFilename");function fu(n){return Object.values(vn.EffortStatus).includes(n)?n:null}a(fu,"resolveEffortStatus");var VL=require("path"),BL=require("fs");var jL=require("node:crypto");function _d(n){if(typeof n!="string")return null;let e=n.trim();if(e.length===0)return null;let t=e.match(/^\[\[([^|\]]+)(?:\|[^\]]*)?\]\]$/);return t?t[1].trim():e}a(_d,"wikilinkInner");function tZ(n){if(!Array.isArray(n))return[];let e=[];for(let t of n)typeof t=="string"&&t.trim().length>0&&e.push(t.trim());return e}a(tZ,"normaliseColumns");function rZ(n){if(Array.isArray(n))return n.map(e=>typeof e=="string"?_d(e):null).filter(e=>e!==null);if(typeof n=="string"){let e=_d(n);return e?[e]:[]}return[]}a(rZ,"normaliseInstanceClass");function $L(n){let e=rZ(n.exo__Instance_class);for(let t of e)if(t==="ui__RelationColumnSet"||t==="97fc9862-c886-4d86-9a60-e0cf9d778575"||t.includes("ui__RelationColumnSet"))return!0;return!1}a($L,"isRelColSetFrontmatter");function UL(n,e){let t=e.exo__Asset_uid;if(typeof t!="string"||t.trim().length===0)return null;let r=e.exo__Asset_label,i=typeof r=="string"&&r.trim().length>0?r.trim():null,s=e.ui__RelationColumnSet_targetClass,o=Array.isArray(s)?_d(s[0]):_d(s),l=_d(e.ui__RelationColumnSet_referencingProperty),c=tZ(e.ui__RelationColumnSet_columns),u=e.ui__RelationColumnSet_priority,f=typeof u=="number"?u:typeof u=="string"&&u.trim()!==""?Number.parseInt(u,10):null;return{uid:t.trim(),path:n,label:i,targetClass:o,referencingProperty:l,columns:c,priority:f!==null&&Number.isNaN(f)?null:f}}a(UL,"extractRelColSetConfig");function ML(n){if(n===null||n.trim().length===0)return"";let e=n.trim();return e.startsWith("[[")&&e.endsWith("]]")?e:`[[${e}]]`}a(ML,"wikilinkOf");function nZ(n,e){let t=(0,jL.createHash)("sha256").update(`${n}:${e}:exo-layout-migration-v1`).digest("hex");return t.slice(0,8)+"-"+t.slice(8,12)+"-4"+t.slice(13,16)+"-8"+t.slice(17,20)+"-"+t.slice(20,32)}a(nZ,"defaultUidFor");var Iy=class{static{a(this,"RelColSetToExoLayoutMigratorService")}constructor(e={}){this.uidFor=e.uidFor??nZ}migrate(e){let t=[],r=[];for(let i of e){if(i.targetClass===null&&i.referencingProperty===null){r.push({sourcePath:i.path,reason:"RelColSet lacks both targetClass and referencingProperty \u2014 nothing to migrate"});continue}t.push(this.migrateOne(i))}return{pairs:t,skipped:r}}migrateOne(e){let t=this.uidFor(e.uid,"layout"),r=this.uidFor(e.uid,"block"),i=[],s=e.label??e.uid,o=`Migrated layout (from ${s})`,l=`Migrated backlinks table (from ${s})`,c=ML(e.targetClass),u=ML(e.referencingProperty);e.targetClass===null&&i.push("RelColSet has no targetClass \u2014 using placeholder; set exo__Layout_targetClass and exo__BacklinksTableBlock_rowClass manually."),e.referencingProperty===null&&i.push("RelColSet has no referencingProperty \u2014 set exo__BacklinksTableBlock_referencingProperty manually."),i.push("RelColSet is additive (appends to Name/InstanceClass); exo__BacklinksTableBlock is replacing. The generated block renders only the configured columns."),i.push("exo__Layout.targetClass is the class of the PAGE the layout renders on. RelColSet encodes the row class, not the page class. Review and adjust before --apply.");let f=e.columns.length===0?"[]":`
730
730
  `+e.columns.map(g=>` - "${g}"`).join(`
731
731
  `),d=e.priority===null?"":`exo__Layout_priority: ${e.priority}
@@ -752,8 +752,8 @@ exo__BacklinksTableBlock_referencingProperty: "${u}"
752
752
  exo__BacklinksTableBlock_columns:${f==="[]"?" []":f}
753
753
  # Migrated from ui__RelationColumnSet ${e.uid} (${e.path}).
754
754
  ---
755
- `;return{sourceUid:e.uid,sourcePath:e.path,layout:{uid:t,filename:`${t}.md`,content:h},block:{uid:r,filename:`${r}.md`,content:p},warnings:i}}};function GL(){return new ce("migrate-relcolset-to-exolayout").description("Generate exo__Layout + exo__BacklinksTableBlock pairs from existing ui__RelationColumnSet configs (dry-run by default; --apply to write)").requiredOption("--vault <path>","Path to the source vault").option("--out-dir <path>","Vault-relative folder where generated Layout+Block files land on --apply","exo-layout-migrated").option("--apply","Write generated files to the vault (default: dry-run, prints to stderr)",!1).option("--json","Emit the migration report as JSON to stdout",!1).action(async n=>{try{let e=(0,VL.resolve)(n.vault);if(!(0,BL.existsSync)(e))throw new he(e);let t=new yr(e),r=new Iy,i=await t.getMarkdownFiles(),s=[];for(let l of i)try{let c=await t.getFileMetadata(l);if(!$L(c))continue;let u=UL(l,c);u!==null&&s.push(u)}catch{}let o=r.migrate(s);n.apply?await iZ(t,o,n.outDir):sZ(o),n.json?process.stdout.write(JSON.stringify(aZ(o,n),null,2)+`
756
- `):process.stderr.write(oZ(o,n)),process.exit(0)}catch(e){se.handle(e)}})}a(GL,"migrateRelColSetToExoLayoutCommand");async function iZ(n,e,t){for(let r of e.pairs){let i=`${t}/${r.layout.filename}`,s=`${t}/${r.block.filename}`;await n.writeFile(i,r.layout.content),await n.writeFile(s,r.block.content)}}a(iZ,"writePairs");function sZ(n){process.stderr.write(`--- DRY RUN PREVIEW ---
755
+ `;return{sourceUid:e.uid,sourcePath:e.path,layout:{uid:t,filename:`${t}.md`,content:h},block:{uid:r,filename:`${r}.md`,content:p},warnings:i}}};function GL(){return new ce("migrate-relcolset-to-exolayout").description("Generate exo__Layout + exo__BacklinksTableBlock pairs from existing ui__RelationColumnSet configs (dry-run by default; --apply to write)").requiredOption("--vault <path>","Path to the source vault").option("--out-dir <path>","Vault-relative folder where generated Layout+Block files land on --apply","exo-layout-migrated").option("--apply","Write generated files to the vault (default: dry-run, prints to stderr)",!1).option("--json","Emit the migration report as JSON to stdout",!1).action(async n=>{try{let e=(0,VL.resolve)(n.vault);if(!(0,BL.existsSync)(e))throw new pe(e);let t=new yr(e),r=new Iy,i=await t.getMarkdownFiles(),s=[];for(let l of i)try{let c=await t.getFileMetadata(l);if(!$L(c))continue;let u=UL(l,c);u!==null&&s.push(u)}catch{}let o=r.migrate(s);n.apply?await iZ(t,o,n.outDir):sZ(o),n.json?process.stdout.write(JSON.stringify(aZ(o,n),null,2)+`
756
+ `):process.stderr.write(oZ(o,n)),process.exit(0)}catch(e){oe.handle(e)}})}a(GL,"migrateRelColSetToExoLayoutCommand");async function iZ(n,e,t){for(let r of e.pairs){let i=`${t}/${r.layout.filename}`,s=`${t}/${r.block.filename}`;await n.writeFile(i,r.layout.content),await n.writeFile(s,r.block.content)}}a(iZ,"writePairs");function sZ(n){process.stderr.write(`--- DRY RUN PREVIEW ---
757
757
  `);for(let e of n.pairs)if(process.stderr.write(`
758
758
  # from ${e.sourcePath}
759
759
  `),process.stderr.write(`## Layout (${e.layout.filename})
@@ -774,38 +774,38 @@ exo__BacklinksTableBlock_columns:${f==="[]"?" []":f}
774
774
  `),console.log(`${"Rank".padEnd(6)}${"Term".padEnd(30)}${"Freq".padEnd(8)}Sample UIDs`),console.log("-".repeat(90)),l.forEach((u,f)=>{let d=`#${f+1}`.padEnd(6),h=u.term.padEnd(30),p=String(u.frequency).padEnd(8),g=u.sample_uids.join(", ");console.log(`${d}${h}${p}${g}`)})})}a(XL,"backfillOrphanTermsCommand");function KL(){let n=new ce("backfill").description("Concept backfill tools for aiKnow assets");return n.addCommand(YL()),n.addCommand(XL()),n}a(KL,"backfillCommand");var Fy=require("path"),sN=require("fs"),oN=require("os");var Py=require("child_process"),Oy=require("fs"),tN=require("path");var Qi=require("fs"),Cy=Z(require("path")),ZL=require("crypto");var TZ=/^---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n([\s\S]*))?$/;function JL(n){let e=n.match(TZ);if(!e)return null;let[,t,r=""]=e,i=Wt.load(t);if(i==null)return{frontmatter:{},body:r};if(typeof i!="object"||Array.isArray(i))throw new Error("frontmatter is not a YAML mapping");return{frontmatter:i,body:r}}a(JL,"parseFile");function IZ(n,e){let t=Wt.dump(n,{lineWidth:-1,quotingType:'"',forceQuotes:!1,noRefs:!0}),r=e.length>0?e:"";return`---
775
775
  ${t}---
776
776
  ${r}`}a(IZ,"serializeFile");function eN(n,e,t={}){let r=Cy.default.dirname(n),i=Cy.default.basename(n),s=Cy.default.join(r,`.${i}.tmp.${process.pid}.${(0,ZL.randomBytes)(6).toString("hex")}`);try{let o=(0,Qi.readFileSync)(n,"utf8"),l;try{l=JL(o)}catch(f){return{success:!1,verified:!1,reason:"parse-error",error:f.message}}if(!l)return{success:!1,verified:!1,reason:"no-frontmatter"};let c={...l.frontmatter,...e},u=IZ(c,l.body);if((0,Qi.writeFileSync)(s,u,"utf8"),(0,Qi.renameSync)(s,n),t.verifyKey!==void 0){let f=(0,Qi.readFileSync)(n,"utf8"),d;try{d=JL(f)}catch(p){return{success:!1,verified:!1,reason:"parse-error",error:p.message}}if(!d)return{success:!1,verified:!1,reason:"no-frontmatter"};let h=d.frontmatter[t.verifyKey];return h!==t.verifyValue?{success:!1,verified:!1,reason:"verify-mismatch",error:`expected ${t.verifyKey}=${String(t.verifyValue)}, got ${String(h)}`}:{success:!0,verified:!0}}return{success:!0,verified:!0}}catch(o){if((0,Qi.existsSync)(s))try{(0,Qi.unlinkSync)(s)}catch{}return{success:!1,verified:!1,reason:"fs-error",error:o.message}}}a(eN,"atomicUpdateFrontmatter");var xZ=/^claude-child-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/,AZ=/^claude-child-([0-9a-f]{8})-(\d+)$/,RZ="EffortStatusDoing";function rN(n){return e=>new Promise((t,r)=>{n(e,(i,s,o)=>{i?r(Object.assign(i,{stdout:s,stderr:o})):t(s)})})}a(rN,"makeExecPromise");async function CZ(n=Py.exec){let e=rN(n),t;try{t=await e("tmux list-sessions -F '#{session_name}' 2>/dev/null")}catch{return[]}let r=[];for(let i of t.split(`
777
- `).map(s=>s.trim()).filter(Boolean)){let s=xZ.exec(i);if(s){r.push({sessionName:i,uuid:s[1],type:"full"});continue}let o=AZ.exec(i);o&&r.push({sessionName:i,uuid:o[1],type:"short"})}return r}a(CZ,"listClaudeChildSessions");function PZ(n,e,t){let r=null,i=e.toLowerCase();function s(o){if(r)return;let l;try{l=(0,Oy.readdirSync)(o,{withFileTypes:!0})}catch{return}for(let c of l){if(r)return;if(c.name.startsWith(".")||c.name==="node_modules")continue;let u=(0,tN.join)(o,c.name);if(c.isDirectory())s(u);else if(c.name.endsWith(".md")){let f=c.name.slice(0,-3).toLowerCase();(t==="full"&&f===i||t==="short"&&f.startsWith(i))&&(r=u)}}}return a(s,"walk"),s(n),r}a(PZ,"findVaultFile");function OZ(n,e){try{let i=(e??(s=>(0,Oy.readFileSync)(s,"utf8")))(n).match(/ems__Effort_status\s*:.*\[\[([^\]]+)\]\]/);return i?i[1].includes(RZ):!1}catch{return!1}}a(OZ,"isTaskDoing");async function nN(n,e=Py.exec,t){let r=await CZ(e),i=[];for(let s of r){let o=PZ(n,s.uuid,s.type);if(!o){i.push({sessionName:s.sessionName,taskUuid:s.uuid,taskFilePath:null,reason:"vault task not found"});continue}OZ(o,t)||i.push({sessionName:s.sessionName,taskUuid:s.uuid,taskFilePath:o,reason:"vault task status != Doing"})}return i}a(nN,"detectOrphans");async function iN(n,e,t=Py.exec,r=eN){let i=rN(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(o){return{ok:!1,error:`vault update failed: ${o.message}`}}try{await i(`tmux kill-session -t ${JSON.stringify(n.sessionName)}`)}catch{}return{ok:!0}}a(iN,"recoverOrphan");function FZ(){return process.env.EXOCORTEX_VAULT??(0,Fy.join)((0,oN.homedir)(),"vault-2025")}a(FZ,"defaultVault");function aN(){return new ce("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",FZ()).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,Fy.resolve)(n.vault);if(!(0,sN.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 nN(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 o of r){let l=o.taskFilePath??"(not found in vault)";console.log(` session=${o.sessionName} uuid=${o.taskUuid} reason=${o.reason}`),console.log(` file=${l}`)}if(t){console.log("[recover] Dry-run mode: no changes applied. Use --apply to recover.");return}let i=0,s=0;for(let o of r){let l=await iN(o,!1);l.ok?(i++,console.log(`[recover] RECOVERED: ${o.sessionName}`)):(s++,console.error(`[recover] ERROR recovering ${o.sessionName}: ${l.error}`))}console.log(`[recover] Done: recovered=${i} errors=${s}`),s>0&&(process.exitCode=1)})}a(aN,"recoverCommand");var b2=require("fs"),Sd=require("path"),Kn=Z(It());function DZ(n,e){return e.concat([n])}a(DZ,"collectAlso");var LZ="https://exocortex.my/ontology/find#Alias_sparql",NZ="https://exocortex.my/ontology/exo#Asset_label";function mu(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}a(mu,"nodeValue");async function kZ(n,e){let t=await n.match(void 0,void 0,void 0),r=[];for(let s of t)mu(s.predicate)!==NZ||mu(s.object)!==e||r.push(mu(s.subject));if(r.length===0)return null;let i=[];for(let s of r)for(let o of t)mu(o.predicate)===LZ&&mu(o.subject)===s&&i.push(mu(o.object));if(i.length===0)return null;if(i.length>1)throw new it(`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]}a(kZ,"resolveAliasFragment");var MZ=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,jZ="https://exocortex.my/ontology/";function $Z(n,e){let t=MZ.exec(e);if(t){let i=`<${jZ}${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}"`)}a($Z,"bindValueLiteral");function lN(){return new ce("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)",DZ,[]).option("--sparql <query>","SPARQL SELECT query (must bind ?path)").option("--class <value>","Filter by class label via find__Alias 'class' (e.g. ems__Task)").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").action(async n=>{se.setFormat("text");try{if(n.sparql&&n.class)throw new it("--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 it("one of --sparql <query> or --class <value> is required",'exocortex find --class ems__Task OR exocortex find --sparql "SELECT ?path WHERE { ... }"');let e=(0,Sd.resolve)(n.vault);if(!(0,b2.existsSync)(e))throw new he(e);let t=n.also||[],r=await ua({profileUid:n.profile,primaryVaultPath:e,alsoVaultPaths:t.map(I=>(0,Sd.resolve)(I)),outputFormat:"text"}),i=r!==null?{effectiveOntologies:r.effective,assetSpaceFolderToUid:r.folderMap}:{},s=new xt(e),l=await new Kn.NoteToRDFConverter(s).convertVault(i);for(let I of t){let A=(0,Sd.resolve)(I);if(!(0,b2.existsSync)(A))throw new he(A);let D=new xt(A),oe=await new Kn.NoteToRDFConverter(D).convertVault(i);l=l.concat(oe)}let c=new Kn.InMemoryTripleStore;await c.addAll(l);let u;if(n.class){let I=await kZ(c,"class");if(I===null)throw new it('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");u=`SELECT ?path WHERE { ${$Z(I,n.class)} }`}else u=n.sparql;let f=ou(u);f=la(f);let d=new Kn.ExoQLParser,h=ca(aa(e));for(let I of t){let A=ca(aa((0,Sd.resolve)(I)));for(let[D,K]of A)h.has(D)||h.set(D,K)}h.size>0&&d.setVaultPrefixes(h);let p=d.parse(f),_=new Kn.ExoQLAlgebraTranslator().translate(p);_.type!=="construct"&&(_=new Kn.AlgebraOptimizer().optimize(_));let w=await new Kn.ExoQLQueryExecutor(c).executeAll(_),E="obsidian://vault/";for(let I of w){let D=I.toJSON().path;if(typeof D!="string"||!D.startsWith(E))continue;let K=D.slice(E.length),oe;try{oe=decodeURIComponent(K)}catch{oe=K}process.stdout.write(oe+`
778
- `)}}catch(e){se.handle(e),process.exit(5)}})}a(lN,"findCommand");var v2=require("fs"),E2=require("path"),Pe=Z(It());var cN=Z(It());function uN(n,e){return t=>{let r=typeof t.filePath=="string"&&t.filePath.length>0?t.filePath:null;if(r===null)return!1;let i=n.getAbstractFileByPath(r);if(i===null||!("basename"in i))return!1;let s=i,o=n.getFrontmatter(s)??{},l=e.getExpectedFolderSync(s,o),c=typeof t.currentFolder=="string"?t.currentFolder:s.parent?.path??"";return(0,cN.needsFolderRepair)(c,l)}}a(uN,"createIsInWrongFolderHostFunction");var gN=Z(It()),Mt=Z(hN());var pN="obsidian://vault/";function ZZ(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(pN))r=decodeURI(r.slice(pN.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}}}a(ZZ,"createCliPathResolver");var eee=["openFile","sparqlSelect","getActiveFileIRI","getActiveFilePath","trashFile","duplicateFile"],w2=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{a(this,"CliServiceNotImplementedError")}};function mN(n){return{async execute(){throw new w2(n)}}}a(mN,"notImplementedService");function tee(n){return e=>{let t=n.getFirstLinkpathDest(e,"");if(!t||!("basename"in t))return null;let i=n.getFrontmatter(t)?.exo__Asset_label;return typeof i=="string"&&i.length>0?i:null}}a(tee,"createCliClassResolver");function yN(n,e){for(let t of eee)n.register(t,mN(t));for(let t of["updateProperty","removeProperty","setStatus","createAsset"])n.register(t,mN(t));if(e){if(e.fsAdapter){let t=new gN.FrontmatterService,r=ZZ(e.fsAdapter);n.register("updateProperty",(0,Mt.createUpdatePropertyService)(e.fsAdapter,t,r)),n.register("removeProperty",(0,Mt.createRemovePropertyService)(e.fsAdapter,t,r)),n.register("setStatus",(0,Mt.createSetStatusService)(e.fsAdapter,t,r)),n.register("createAsset",(0,Mt.createCreateAssetService)(e.vaultAdapter,e.fsAdapter,tee(e.vaultAdapter)))}n.register("createRelatedTask",(0,Mt.createCreateRelatedTaskService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("createRelatedProject",(0,Mt.createCreateRelatedProjectService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("archiveAsset",(0,Mt.createArchiveAssetService)(e.vaultAdapter,e.archiveAssetService)),n.register("planForEvening",(0,Mt.createPlanForEveningService)(e.vaultAdapter,e.taskStatusService)),n.register("cleanProperties",(0,Mt.createCleanPropertiesService)(e.vaultAdapter,e.propertyCleanupService)),n.register("renameToUid",(0,Mt.createRenameToUidService)(e.vaultAdapter,e.renameToUidService)),n.register("repairFolder",(0,Mt.createRepairFolderService)(e.vaultAdapter,e.folderRepairService)),n.register("fixMissingLabel",(0,Mt.createFixMissingLabelService)(e.vaultAdapter,e.fixMissingLabelService))}}a(yN,"populateCliServiceRegistry");var ree=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function nee(){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(`
779
- `).map(t=>t.trim()).filter(t=>t.length>0)}a(nee,"readStdinLines");function Ny(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}a(Ny,"nodeValue");async function iee(n,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),r=await n.match(void 0,t,void 0),i=[];for(let s of r)if(Ny(s.object)===e){let c=Ny(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);c&&i.push(c[1])}if(i.length===0)return null;if(i.length>1)throw new it(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}a(iee,"resolveSlugToUuid");async function see(n,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),r=await n.match(void 0,t,void 0);for(let i of r)if(Ny(i.subject).includes(e)){let o=Ny(i.object);if(o==="true"||o==="True")return!0}return!1}a(see,"isDestructive");async function oee(n,e,t,r,i,s,o,l){let c=(0,E2.resolve)(n,i);if(!(0,v2.existsSync)(c))return console.error(`\u274C Target file not found: ${i}`),!1;let u=new Pe.CommandResolver(e),f=await u.loadCommand(r);if(!f)return console.error(`\u274C Command with UID "${r}" not found.`),!1;if(await see(e,r)&&!s.dryRun&&!s.yes)return console.error(`\u274C Command "${f.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),!1;let h=(0,Pe.vaultPathToIRI)(i),p=new xt(n),g=new Pe.FolderRepairService(p),_=new Pe.PreconditionEvaluator(e,void 0,{clock:o});(0,Pe.registerDefaultHostFunctions)(_),_.registerHostFunction("isInWrongFolder",uN(p,g));let v=p.getAbstractFileByPath(i),w=v!==null&&"basename"in v?v:null,E=w?p.getFrontmatter(w):null,I=E&&typeof E=="object"?E.exo__Asset_uid:void 0,A={targetIRI:h,filePath:i,fileBasename:w?.basename,assetUid:typeof I=="string"?I:void 0};if(!await _.evaluate(f.precondition,h,A))return console.error(`\u274C Precondition not satisfied for "${f.name}" on "${i}".`),!1;if(s.dryRun)return console.log(`\u{1F50D} Dry-run: would apply "${f.name}" to "${i}" (precondition passed).`),!0;let K=new Pe.ServiceRegistry,oe=new Pe.GenericAssetCreationService(p).withDeterminism({clock:o,uidGenerator:l}),me=new Pe.ArchiveAssetService(p),N=new Pe.PropertyCleanupService(p),Q=new Pe.FixMissingLabelService(p),ie=new Pe.RenameToUidService(p),V=new Pe.TaskStatusService(p,new Pe.EffortStatusWorkflow,new Pe.StatusTimestampService(p)),Y=new yr(n);yN(K,{vaultAdapter:p,fsAdapter:Y,genericAssetCreationService:oe,archiveAssetService:me,taskStatusService:V,propertyCleanupService:N,fixMissingLabelService:Q,renameToUidService:ie,folderRepairService:g});let re=new Pe.GroundingExecutor(Y,Y,K,(0,Pe.createVaultFrontmatterClassLabelResolver)(Y),{clock:o,uidGenerator:l,workflowResolver:t,groundingLoader:a(q=>u.loadGroundingByUid(q),"groundingLoader")}),G;if(s.input)try{let q=JSON.parse(s.input);if(typeof q!="object"||q===null||Array.isArray(q))throw new Error("must be a JSON object");G=q}catch(q){let U=q instanceof Error?q.message:String(q);return console.error(`\u274C --input: invalid JSON object (${U})`),!1}let ne=await re.execute(f.grounding,h,i,G);if(ne.success){let q=f.successMessage??`Applied "${f.name}" to "${i}".`;return console.log(`\u2705 ${q}`),!0}else return console.error(`\u274C "${f.name}" failed on "${i}": ${ne.error}`),!1}a(oee,"executeOnTarget");function _N(){return new ce("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").option("--seed <uuid>","Deterministic UID seed for test/replay (uses seededUidGenerator)").option("--frozen-clock <iso>","Freeze clock to ISO timestamp for test/replay (uses frozenClock)").action(async(n,e,t)=>{se.setFormat("text");try{let r=(0,E2.resolve)(t.vault);if(!(0,v2.existsSync)(r))throw new he(r);by(r);let i=t.frozenClock?(0,Pe.frozenClock)(t.frozenClock):(0,Pe.liveClock)(),s=t.seed?(0,Pe.seededUidGenerator)(t.seed):(0,Pe.liveUidGenerator)(),o=new xt(r),c=await new Pe.NoteToRDFConverter(o).convertVault(),u=new Pe.InMemoryTripleStore;await u.addAll(c);let f=new Pe.WorkflowResolver(u),d;if(ree.test(n))d=n;else{let _=await iee(u,n);_||(console.error(`\u274C No command found with UUID or cliName "${n}".`),process.exit(3)),d=_}let h;if(e)h=[e];else if(h=await nee(),h.length===0)throw new it("No target path provided and stdin is empty.","exocortex apply <uuid> <path> OR exocortex find ... | exocortex apply <uuid>");let p=0,g=0;for(let _ of h)await oee(r,u,f,d,_,t,i,s)?p++:g++;h.length>1&&console.log(`
780
- \u{1F4CA} Applied to ${p}/${h.length} target(s) (${g} failed).`),g>0&&process.exit(5)}catch(r){se.handle(r),process.exit(5)}})}a(_N,"applyCommand");var da=require("fs"),gu=require("path");var bN=/^---\s*$/,aee=/^exocmd__Grounding_type:\s*(.+?)\s*$/,lee=/^"?\[\[[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?:\|[^\]]*)?\]\]"?$/i,cee=new Set(["node_modules"]);function uee(n){return n.startsWith(".")||cee.has(n)}a(uee,"shouldSkipDir");function*SN(n){let e;try{e=(0,da.readdirSync)(n,{withFileTypes:!0})}catch(t){let r=t;if(r.code==="EPERM"||r.code==="EACCES"||r.code==="ENOENT")return;throw t}for(let t of e){let r=(0,gu.join)(n,t.name);if(t.isDirectory()){if(uee(t.name))continue;yield*SN(r)}else t.isFile()&&t.name.endsWith(".md")&&(yield r)}}a(SN,"walkMarkdownFiles");function fee(n){let e=n.split(/\r?\n/);if(e.length<2||!bN.test(e[0]))return null;for(let t=1;t<e.length;t++)if(bN.test(e[t]))return{lines:e.slice(1,t),startLine:2};return null}a(fee,"extractFrontmatter");function dee(n){let e=n.trim();return e===""||e==="null"||e==="~"?!1:!lee.test(e)}a(dee,"isLiteralForm");function hee(n){let e=[];for(let t of SN(n)){let r;try{r=(0,da.readFileSync)(t,"utf-8")}catch{continue}let i=fee(r);if(i)for(let s=0;s<i.lines.length;s++){let o=i.lines[s].match(aee);if(!o)continue;let l=o[1];dee(l)&&e.push({path:(0,gu.relative)(n,t),line:i.startLine+s,value:l})}}return e}a(hee,"scanVaultForLiteralForm");function wN(){return new ce("grounding-type-literal-form").description("Detect post-Phase-4+1 regressions: any exocmd__Grounding_type literal-string form (not wikilink) in vault frontmatter").requiredOption("--vault <path>","Vault root directory").option("--output <type>","Response format: text|json","text").action(n=>{let e=n.output??"text";se.setFormat(e);try{let t=(0,gu.resolve)(n.vault);if(!(0,da.existsSync)(t)||!(0,da.statSync)(t).isDirectory())throw new he(t);let r=hee(t);if(e==="json")console.log(JSON.stringify({vaultPath:t,violationCount:r.length,violations:r,clean:r.length===0},null,2));else if(r.length===0)console.log(`OK ${t}: 0 exocmd__Grounding_type literal-form violations`);else{console.error(`FAIL ${t}: ${r.length} exocmd__Grounding_type literal-form violation(s):`);for(let i of r)console.error(` ${i.path}:${i.line} \u2014 value: ${i.value}`);console.error("\nRFC 9d20c91f Phase 3 migrated all values to wikilink form `[[<uid>]]`. Re-run the Phase 3 migration script or hand-edit offending files.")}r.length>0&&(process.exitCode=1)}catch(t){se.handle(t)}})}a(wN,"auditGroundingTypeLiteralFormCommand");function vN(){let n=new ce("audit").description("Audit vault for regression patterns (RFC cutover detectors)");return n.addCommand(wN()),n}a(vN,"auditCommand");var EN=require("fs"),TN=require("path");var pee=a(n=>{process.stderr.write(`${n}
777
+ `).map(s=>s.trim()).filter(Boolean)){let s=xZ.exec(i);if(s){r.push({sessionName:i,uuid:s[1],type:"full"});continue}let o=AZ.exec(i);o&&r.push({sessionName:i,uuid:o[1],type:"short"})}return r}a(CZ,"listClaudeChildSessions");function PZ(n,e,t){let r=null,i=e.toLowerCase();function s(o){if(r)return;let l;try{l=(0,Oy.readdirSync)(o,{withFileTypes:!0})}catch{return}for(let c of l){if(r)return;if(c.name.startsWith(".")||c.name==="node_modules")continue;let u=(0,tN.join)(o,c.name);if(c.isDirectory())s(u);else if(c.name.endsWith(".md")){let f=c.name.slice(0,-3).toLowerCase();(t==="full"&&f===i||t==="short"&&f.startsWith(i))&&(r=u)}}}return a(s,"walk"),s(n),r}a(PZ,"findVaultFile");function OZ(n,e){try{let i=(e??(s=>(0,Oy.readFileSync)(s,"utf8")))(n).match(/ems__Effort_status\s*:.*\[\[([^\]]+)\]\]/);return i?i[1].includes(RZ):!1}catch{return!1}}a(OZ,"isTaskDoing");async function nN(n,e=Py.exec,t){let r=await CZ(e),i=[];for(let s of r){let o=PZ(n,s.uuid,s.type);if(!o){i.push({sessionName:s.sessionName,taskUuid:s.uuid,taskFilePath:null,reason:"vault task not found"});continue}OZ(o,t)||i.push({sessionName:s.sessionName,taskUuid:s.uuid,taskFilePath:o,reason:"vault task status != Doing"})}return i}a(nN,"detectOrphans");async function iN(n,e,t=Py.exec,r=eN){let i=rN(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(o){return{ok:!1,error:`vault update failed: ${o.message}`}}try{await i(`tmux kill-session -t ${JSON.stringify(n.sessionName)}`)}catch{}return{ok:!0}}a(iN,"recoverOrphan");function FZ(){return process.env.EXOCORTEX_VAULT??(0,Fy.join)((0,oN.homedir)(),"vault-2025")}a(FZ,"defaultVault");function aN(){return new ce("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",FZ()).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,Fy.resolve)(n.vault);if(!(0,sN.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 nN(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 o of r){let l=o.taskFilePath??"(not found in vault)";console.log(` session=${o.sessionName} uuid=${o.taskUuid} reason=${o.reason}`),console.log(` file=${l}`)}if(t){console.log("[recover] Dry-run mode: no changes applied. Use --apply to recover.");return}let i=0,s=0;for(let o of r){let l=await iN(o,!1);l.ok?(i++,console.log(`[recover] RECOVERED: ${o.sessionName}`)):(s++,console.error(`[recover] ERROR recovering ${o.sessionName}: ${l.error}`))}console.log(`[recover] Done: recovered=${i} errors=${s}`),s>0&&(process.exitCode=1)})}a(aN,"recoverCommand");var b2=require("fs"),Sd=require("path"),Kn=Z(It());function DZ(n,e){return e.concat([n])}a(DZ,"collectAlso");var LZ="https://exocortex.my/ontology/find#Alias_sparql",NZ="https://exocortex.my/ontology/exo#Asset_label";function mu(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}a(mu,"nodeValue");async function kZ(n,e){let t=await n.match(void 0,void 0,void 0),r=[];for(let s of t)mu(s.predicate)!==NZ||mu(s.object)!==e||r.push(mu(s.subject));if(r.length===0)return null;let i=[];for(let s of r)for(let o of t)mu(o.predicate)===LZ&&mu(o.subject)===s&&i.push(mu(o.object));if(i.length===0)return null;if(i.length>1)throw new it(`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]}a(kZ,"resolveAliasFragment");var MZ=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,jZ="https://exocortex.my/ontology/";function $Z(n,e){let t=MZ.exec(e);if(t){let i=`<${jZ}${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}"`)}a($Z,"bindValueLiteral");function lN(){return new ce("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)",DZ,[]).option("--sparql <query>","SPARQL SELECT query (must bind ?path)").option("--class <value>","Filter by class label via find__Alias 'class' (e.g. ems__Task)").option("--profile <uid>","FocusProfile UID \u2014 restrict graph to effective AssetSpace set (RFC 0a0791c1)").action(async n=>{oe.setFormat("text");try{if(n.sparql&&n.class)throw new it("--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 it("one of --sparql <query> or --class <value> is required",'exocortex find --class ems__Task OR exocortex find --sparql "SELECT ?path WHERE { ... }"');let e=(0,Sd.resolve)(n.vault);if(!(0,b2.existsSync)(e))throw new pe(e);let t=n.also||[],r=await ua({profileUid:n.profile,primaryVaultPath:e,alsoVaultPaths:t.map(I=>(0,Sd.resolve)(I)),outputFormat:"text"}),i=r!==null?{effectiveOntologies:r.effective,assetSpaceFolderToUid:r.folderMap}:{},s=new xt(e),l=await new Kn.NoteToRDFConverter(s).convertVault(i);for(let I of t){let O=(0,Sd.resolve)(I);if(!(0,b2.existsSync)(O))throw new pe(O);let C=new xt(O),ne=await new Kn.NoteToRDFConverter(C).convertVault(i);l=l.concat(ne)}let c=new Kn.InMemoryTripleStore;await c.addAll(l);let u;if(n.class){let I=await kZ(c,"class");if(I===null)throw new it('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");u=`SELECT ?path WHERE { ${$Z(I,n.class)} }`}else u=n.sparql;let f=ou(u);f=la(f);let d=new Kn.ExoQLParser,h=ca(aa(e));for(let I of t){let O=ca(aa((0,Sd.resolve)(I)));for(let[C,H]of O)h.has(C)||h.set(C,H)}h.size>0&&d.setVaultPrefixes(h);let p=d.parse(f),_=new Kn.ExoQLAlgebraTranslator().translate(p);_.type!=="construct"&&(_=new Kn.AlgebraOptimizer().optimize(_));let w=await new Kn.ExoQLQueryExecutor(c).executeAll(_),E="obsidian://vault/";for(let I of w){let C=I.toJSON().path;if(typeof C!="string"||!C.startsWith(E))continue;let H=C.slice(E.length),ne;try{ne=decodeURIComponent(H)}catch{ne=H}process.stdout.write(ne+`
778
+ `)}}catch(e){oe.handle(e),process.exit(5)}})}a(lN,"findCommand");var v2=require("fs"),E2=require("path"),Pe=Z(It());var cN=Z(It());function uN(n,e){return t=>{let r=typeof t.filePath=="string"&&t.filePath.length>0?t.filePath:null;if(r===null)return!1;let i=n.getAbstractFileByPath(r);if(i===null||!("basename"in i))return!1;let s=i,o=n.getFrontmatter(s)??{},l=e.getExpectedFolderSync(s,o),c=typeof t.currentFolder=="string"?t.currentFolder:s.parent?.path??"";return(0,cN.needsFolderRepair)(c,l)}}a(uN,"createIsInWrongFolderHostFunction");var gN=Z(It()),Mt=Z(hN());var pN="obsidian://vault/";function ZZ(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(pN))r=decodeURI(r.slice(pN.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}}}a(ZZ,"createCliPathResolver");var eee=["openFile","sparqlSelect","getActiveFileIRI","getActiveFilePath","trashFile","duplicateFile"],w2=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{a(this,"CliServiceNotImplementedError")}};function mN(n){return{async execute(){throw new w2(n)}}}a(mN,"notImplementedService");function tee(n){return e=>{let t=n.getFirstLinkpathDest(e,"");if(!t||!("basename"in t))return null;let i=n.getFrontmatter(t)?.exo__Asset_label;return typeof i=="string"&&i.length>0?i:null}}a(tee,"createCliClassResolver");function yN(n,e){for(let t of eee)n.register(t,mN(t));for(let t of["updateProperty","removeProperty","setStatus","createAsset"])n.register(t,mN(t));if(e){if(e.fsAdapter){let t=new gN.FrontmatterService,r=ZZ(e.fsAdapter);n.register("updateProperty",(0,Mt.createUpdatePropertyService)(e.fsAdapter,t,r)),n.register("removeProperty",(0,Mt.createRemovePropertyService)(e.fsAdapter,t,r)),n.register("setStatus",(0,Mt.createSetStatusService)(e.fsAdapter,t,r)),n.register("createAsset",(0,Mt.createCreateAssetService)(e.vaultAdapter,e.fsAdapter,tee(e.vaultAdapter)))}n.register("createRelatedTask",(0,Mt.createCreateRelatedTaskService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("createRelatedProject",(0,Mt.createCreateRelatedProjectService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("archiveAsset",(0,Mt.createArchiveAssetService)(e.vaultAdapter,e.archiveAssetService)),n.register("planForEvening",(0,Mt.createPlanForEveningService)(e.vaultAdapter,e.taskStatusService)),n.register("cleanProperties",(0,Mt.createCleanPropertiesService)(e.vaultAdapter,e.propertyCleanupService)),n.register("renameToUid",(0,Mt.createRenameToUidService)(e.vaultAdapter,e.renameToUidService)),n.register("repairFolder",(0,Mt.createRepairFolderService)(e.vaultAdapter,e.folderRepairService)),n.register("fixMissingLabel",(0,Mt.createFixMissingLabelService)(e.vaultAdapter,e.fixMissingLabelService))}}a(yN,"populateCliServiceRegistry");var ree=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function nee(){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(`
779
+ `).map(t=>t.trim()).filter(t=>t.length>0)}a(nee,"readStdinLines");function Ny(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}a(Ny,"nodeValue");async function iee(n,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),r=await n.match(void 0,t,void 0),i=[];for(let s of r)if(Ny(s.object)===e){let c=Ny(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);c&&i.push(c[1])}if(i.length===0)return null;if(i.length>1)throw new it(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}a(iee,"resolveSlugToUuid");async function see(n,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),r=await n.match(void 0,t,void 0);for(let i of r)if(Ny(i.subject).includes(e)){let o=Ny(i.object);if(o==="true"||o==="True")return!0}return!1}a(see,"isDestructive");async function oee(n,e,t,r,i,s,o,l){let c=(0,E2.resolve)(n,i);if(!(0,v2.existsSync)(c))return console.error(`\u274C Target file not found: ${i}`),!1;let u=new Pe.CommandResolver(e),f=await u.loadCommand(r);if(!f)return console.error(`\u274C Command with UID "${r}" not found.`),!1;if(await see(e,r)&&!s.dryRun&&!s.yes)return console.error(`\u274C Command "${f.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),!1;let h=(0,Pe.vaultPathToIRI)(i),p=new xt(n),g=new Pe.FolderRepairService(p),_=new Pe.PreconditionEvaluator(e,void 0,{clock:o});(0,Pe.registerDefaultHostFunctions)(_),_.registerHostFunction("isInWrongFolder",uN(p,g));let v=p.getAbstractFileByPath(i),w=v!==null&&"basename"in v?v:null,E=w?p.getFrontmatter(w):null,I=E&&typeof E=="object"?E.exo__Asset_uid:void 0,O={targetIRI:h,filePath:i,fileBasename:w?.basename,assetUid:typeof I=="string"?I:void 0};if(!await _.evaluate(f.precondition,h,O))return console.error(`\u274C Precondition not satisfied for "${f.name}" on "${i}".`),!1;if(s.dryRun)return console.log(`\u{1F50D} Dry-run: would apply "${f.name}" to "${i}" (precondition passed).`),!0;let H=new Pe.ServiceRegistry,ne=new Pe.GenericAssetCreationService(p).withDeterminism({clock:o,uidGenerator:l}),de=new Pe.ArchiveAssetService(p),N=new Pe.PropertyCleanupService(p),Y=new Pe.FixMissingLabelService(p),se=new Pe.RenameToUidService(p),V=new Pe.TaskStatusService(p,new Pe.EffortStatusWorkflow,new Pe.StatusTimestampService(p)),X=new yr(n);yN(H,{vaultAdapter:p,fsAdapter:X,genericAssetCreationService:ne,archiveAssetService:de,taskStatusService:V,propertyCleanupService:N,fixMissingLabelService:Y,renameToUidService:se,folderRepairService:g});let re=new Pe.GroundingExecutor(X,X,H,(0,Pe.createVaultFrontmatterClassLabelResolver)(X),{clock:o,uidGenerator:l,workflowResolver:t,groundingLoader:a(q=>u.loadGroundingByUid(q),"groundingLoader")}),G;if(s.input)try{let q=JSON.parse(s.input);if(typeof q!="object"||q===null||Array.isArray(q))throw new Error("must be a JSON object");G=q}catch(q){let U=q instanceof Error?q.message:String(q);return console.error(`\u274C --input: invalid JSON object (${U})`),!1}let ie=await re.execute(f.grounding,h,i,G);if(ie.success){let q=f.successMessage??`Applied "${f.name}" to "${i}".`;return console.log(`\u2705 ${q}`),!0}else return console.error(`\u274C "${f.name}" failed on "${i}": ${ie.error}`),!1}a(oee,"executeOnTarget");function _N(){return new ce("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").option("--seed <uuid>","Deterministic UID seed for test/replay (uses seededUidGenerator)").option("--frozen-clock <iso>","Freeze clock to ISO timestamp for test/replay (uses frozenClock)").action(async(n,e,t)=>{oe.setFormat("text");try{let r=(0,E2.resolve)(t.vault);if(!(0,v2.existsSync)(r))throw new pe(r);by(r);let i=t.frozenClock?(0,Pe.frozenClock)(t.frozenClock):(0,Pe.liveClock)(),s=t.seed?(0,Pe.seededUidGenerator)(t.seed):(0,Pe.liveUidGenerator)(),o=new xt(r),c=await new Pe.NoteToRDFConverter(o).convertVault(),u=new Pe.InMemoryTripleStore;await u.addAll(c);let f=new Pe.WorkflowResolver(u),d;if(ree.test(n))d=n;else{let _=await iee(u,n);_||(console.error(`\u274C No command found with UUID or cliName "${n}".`),process.exit(3)),d=_}let h;if(e)h=[e];else if(h=await nee(),h.length===0)throw new it("No target path provided and stdin is empty.","exocortex apply <uuid> <path> OR exocortex find ... | exocortex apply <uuid>");let p=0,g=0;for(let _ of h)await oee(r,u,f,d,_,t,i,s)?p++:g++;h.length>1&&console.log(`
780
+ \u{1F4CA} Applied to ${p}/${h.length} target(s) (${g} failed).`),g>0&&process.exit(5)}catch(r){oe.handle(r),process.exit(5)}})}a(_N,"applyCommand");var da=require("fs"),gu=require("path");var bN=/^---\s*$/,aee=/^exocmd__Grounding_type:\s*(.+?)\s*$/,lee=/^"?\[\[[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?:\|[^\]]*)?\]\]"?$/i,cee=new Set(["node_modules"]);function uee(n){return n.startsWith(".")||cee.has(n)}a(uee,"shouldSkipDir");function*SN(n){let e;try{e=(0,da.readdirSync)(n,{withFileTypes:!0})}catch(t){let r=t;if(r.code==="EPERM"||r.code==="EACCES"||r.code==="ENOENT")return;throw t}for(let t of e){let r=(0,gu.join)(n,t.name);if(t.isDirectory()){if(uee(t.name))continue;yield*SN(r)}else t.isFile()&&t.name.endsWith(".md")&&(yield r)}}a(SN,"walkMarkdownFiles");function fee(n){let e=n.split(/\r?\n/);if(e.length<2||!bN.test(e[0]))return null;for(let t=1;t<e.length;t++)if(bN.test(e[t]))return{lines:e.slice(1,t),startLine:2};return null}a(fee,"extractFrontmatter");function dee(n){let e=n.trim();return e===""||e==="null"||e==="~"?!1:!lee.test(e)}a(dee,"isLiteralForm");function hee(n){let e=[];for(let t of SN(n)){let r;try{r=(0,da.readFileSync)(t,"utf-8")}catch{continue}let i=fee(r);if(i)for(let s=0;s<i.lines.length;s++){let o=i.lines[s].match(aee);if(!o)continue;let l=o[1];dee(l)&&e.push({path:(0,gu.relative)(n,t),line:i.startLine+s,value:l})}}return e}a(hee,"scanVaultForLiteralForm");function wN(){return new ce("grounding-type-literal-form").description("Detect post-Phase-4+1 regressions: any exocmd__Grounding_type literal-string form (not wikilink) in vault frontmatter").requiredOption("--vault <path>","Vault root directory").option("--output <type>","Response format: text|json","text").action(n=>{let e=n.output??"text";oe.setFormat(e);try{let t=(0,gu.resolve)(n.vault);if(!(0,da.existsSync)(t)||!(0,da.statSync)(t).isDirectory())throw new pe(t);let r=hee(t);if(e==="json")console.log(JSON.stringify({vaultPath:t,violationCount:r.length,violations:r,clean:r.length===0},null,2));else if(r.length===0)console.log(`OK ${t}: 0 exocmd__Grounding_type literal-form violations`);else{console.error(`FAIL ${t}: ${r.length} exocmd__Grounding_type literal-form violation(s):`);for(let i of r)console.error(` ${i.path}:${i.line} \u2014 value: ${i.value}`);console.error("\nRFC 9d20c91f Phase 3 migrated all values to wikilink form `[[<uid>]]`. Re-run the Phase 3 migration script or hand-edit offending files.")}r.length>0&&(process.exitCode=1)}catch(t){oe.handle(t)}})}a(wN,"auditGroundingTypeLiteralFormCommand");function vN(){let n=new ce("audit").description("Audit vault for regression patterns (RFC cutover detectors)");return n.addCommand(wN()),n}a(vN,"auditCommand");var EN=require("fs"),TN=require("path");var pee=a(n=>{process.stderr.write(`${n}
781
781
  `)},"DEFAULT_LOG"),ky=class{static{a(this,"HeadlessConfirmGate")}constructor(e){this.yes=e.yes,this.verbose=e.verbose??!1,this.log=e.log??pee}async confirmHardSwitch(e){if(this.verbose){let t=Array.from(e.filesToDestroy.values()).reduce((r,i)=>r+i.length,0);this.log(`[hard-switch] Target: ${e.targetProfileLabel} (${e.targetProfileUid})`),this.log(`[hard-switch] Source: ${e.sourceProfileLabel}`),this.log(`[hard-switch] ${t} files to remove, ${e.assetSpacesBeingTornDown.length} AS to tear down, ${e.assetSpacesBeingMaterialized.length} AS to materialize`)}return this.yes?!0:(this.log("[hard-switch] Refused: --yes flag required for headless mode (Decision #2 safety)."),!1)}};var mee="[hard-switch] CLI command scaffolded. hardSwitchProfile() implementation pending Phase 3.";function gee(n,e){return{targetProfileUid:n,targetProfileLabel:e,sourceProfileUid:null,sourceProfileLabel:"<unknown>",filesToDestroy:new Map,assetSpacesBeingTornDown:[],assetSpacesBeingMaterialized:[]}}a(gee,"buildScaffoldPlan");async function yee(n,e,t={}){let r=[],i=[],s=t.out??(_=>process.stdout.write(`${_}
782
782
  `)),o=t.err??(_=>process.stderr.write(`${_}
783
- `)),l=a(_=>{r.push(_),s(_)},"out"),c=a(_=>{i.push(_),o(_)},"err");if(!e.vault)throw new it("--vault is required");let u=(0,TN.resolve)(e.vault);if(!(0,EN.existsSync)(u))throw new he(u);if(!n||n.length===0)throw new it("profile-uid argument is required","exocortex hard-switch <profile-uid> --vault <path>");let d=await(t.resolverFactory?.(e)??new au({vaultPath:u,warn:a(_=>c(_),"warn")})).resolveFilter(n);if(d.outcome==="missing-profile")throw new it(`Profile not found: ${n}`,"Run `exocortex find --class exo__FocusProfile` to list available profiles");if(d.outcome==="error")return c(`[hard-switch] Resolver error: ${d.reason}`),{exitCode:5,stdout:r,stderr:i};if(d.outcome==="degraded")return c(`[hard-switch] Refused: profile resolution degraded \u2014 ${d.reason}. Hard switch aborted to prevent vault corruption.`),{exitCode:5,stdout:r,stderr:i};let h=t.confirmGate??new ky({yes:e.yes??!1,verbose:e.verbose??!1,log:a(_=>c(_),"log")}),p=gee(n,n);return await h.confirmHardSwitch(p)?(l(mee),{exitCode:0,stdout:r,stderr:i}):{exitCode:0,stdout:r,stderr:i}}a(yee,"runHardSwitch");function IN(){return new ce("hard-switch").description("Hard switch to specified FocusProfile (filesystem mutation, Phase 3+). Requires --yes for headless mode.").argument("<profile-uid>","Target FocusProfile UID").requiredOption("--vault <path>","Path to Obsidian vault").option("--yes","Confirm hard switch (headless mode safety override per RFC 22b50a17 Decision #2)",!1).option("--verbose","Print plan summary to stderr before deciding",!1).action(async(e,t)=>{try{let r=await yee(e,t);process.exit(r.exitCode)}catch(r){se.handle(r)}})}a(IN,"hardSwitchCommand");var dl=require("node:path"),hl=require("node:fs");var Cr=require("node:fs"),AN=require("node:fs/promises"),RN=require("node:os"),Rs=require("node:path"),CN=Z(It());var _ee=/^https:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+?)(?:\.git)?$/,xN=50*1024*1024,fl=class n{static{a(this,"BootstrapAssetSpaceService")}constructor(e={}){this.fetchImpl=e.fetchImpl??globalThis.fetch}static parseGitHubURL(e){let t=e.match(_ee);if(t===null)throw new Error(`parseGitHubURL: invalid URL shape \u2014 expected https://github.com/<owner>/<repo>, got: ${e}`);return{owner:t[1],repo:t[2]}}static deriveFolderName(e){let{repo:t}=n.parseGitHubURL(e);return t.startsWith("exoas-")?t.slice(6):t}async pullAssetSpace(e,t,r){let{owner:i,repo:s}=n.parseGitHubURL(e);if((0,Cr.existsSync)(r)&&(0,Cr.readdirSync)(r).length>0)throw new Error(`pullAssetSpace: target ${r} exists \u0438 not empty \u2014 refusing \u043A overwrite`);let o=`https://api.github.com/repos/${i}/${s}/tarball/${t}`,l=await this.fetchImpl(o,{signal:AbortSignal.timeout(6e4)});if(!l.ok){if(l.status===403){let A=l.headers?.get?.("x-ratelimit-remaining"),D=l.headers?.get?.("x-ratelimit-reset");if(A==="0"||D!=null){let K=D!=null?new Date(Number(D)*1e3).toISOString():"unknown";throw new Error(`pullAssetSpace: GitHub anonymous API rate-limit exceeded (60 req/hour). Reset at ${K}. Wait or use authenticated CLI.`)}}throw new Error(`pullAssetSpace: fetch failed (${l.status} ${l.statusText}) for ${o}`)}let c=await l.arrayBuffer();if(c.byteLength>xN)throw new Error(`pullAssetSpace: tarball too large (${c.byteLength} bytes > ${xN})`);let u=new Uint8Array(c),f=await(0,CN.parseTarballGzip)(u);if(f.length===0)throw new Error(`pullAssetSpace: empty tarball for ${i}/${s}@${t}`);let d=a(A=>A==="globalExtendedHeader"||A==="extendedHeader","isHeaderType"),h=f.find(A=>!d(A.type)&&A.name.includes("/"));if(h===void 0)throw new Error("pullAssetSpace: no wrapper-bearing entry in tarball");let p=h.name.indexOf("/"),g=h.name.slice(0,p),_=g+"/";for(let A of f)if(!d(A.type)&&!(A.name===g||A.name===_)&&!A.name.startsWith(_))throw new Error(`pullAssetSpace: entry "${A.name}" not under wrapper "${g}"`);let v=g.match(/-([0-9a-fA-F]{7,40})$/);if(v===null)throw new Error(`pullAssetSpace: cannot extract SHA from wrapper "${g}"`);let w=v[1].toLowerCase(),E=await(0,AN.mkdtemp)((0,Rs.join)((0,RN.tmpdir)(),`exo-bootstrap-${i}-${s}-`)),I=0;try{for(let A of f){if(A.type==="symbolicLink"||A.type==="hardLink")throw new Error(`pullAssetSpace: ${A.type} entry "${A.name}" rejected for security`);if(d(A.type))continue;let D=A.name.slice(_.length);if(D.length===0||A.type==="directory"||A.data===void 0)continue;if(D.split("/").some(oe=>oe===".."))throw new Error(`pullAssetSpace: path traversal detected for entry "${A.name}"`);let K=(0,Rs.resolve)(E,D);if(K!==E&&!K.startsWith(E+Rs.sep))throw new Error(`pullAssetSpace: zip-slip detected for entry "${A.name}"`);(0,Cr.mkdirSync)((0,Rs.dirname)(K),{recursive:!0}),(0,Cr.writeFileSync)(K,A.data),I++}(0,Cr.mkdirSync)((0,Rs.dirname)(r),{recursive:!0});try{(0,Cr.renameSync)(E,r)}catch(A){if(A.code==="EXDEV"){let{cpSync:D}=await import("node:fs");D(E,r,{recursive:!0}),(0,Cr.rmSync)(E,{recursive:!0,force:!0})}else throw A}}catch(A){throw(0,Cr.rmSync)(E,{recursive:!0,force:!0}),A}return{sha:w,fileCount:I}}ensureGitmodulesEntry(e,t,r){let i=(0,Rs.join)(e,".gitmodules"),o=`${`[submodule "${t}"]`}
783
+ `)),l=a(_=>{r.push(_),s(_)},"out"),c=a(_=>{i.push(_),o(_)},"err");if(!e.vault)throw new it("--vault is required");let u=(0,TN.resolve)(e.vault);if(!(0,EN.existsSync)(u))throw new pe(u);if(!n||n.length===0)throw new it("profile-uid argument is required","exocortex hard-switch <profile-uid> --vault <path>");let d=await(t.resolverFactory?.(e)??new au({vaultPath:u,warn:a(_=>c(_),"warn")})).resolveFilter(n);if(d.outcome==="missing-profile")throw new it(`Profile not found: ${n}`,"Run `exocortex find --class exo__FocusProfile` to list available profiles");if(d.outcome==="error")return c(`[hard-switch] Resolver error: ${d.reason}`),{exitCode:5,stdout:r,stderr:i};if(d.outcome==="degraded")return c(`[hard-switch] Refused: profile resolution degraded \u2014 ${d.reason}. Hard switch aborted to prevent vault corruption.`),{exitCode:5,stdout:r,stderr:i};let h=t.confirmGate??new ky({yes:e.yes??!1,verbose:e.verbose??!1,log:a(_=>c(_),"log")}),p=gee(n,n);return await h.confirmHardSwitch(p)?(l(mee),{exitCode:0,stdout:r,stderr:i}):{exitCode:0,stdout:r,stderr:i}}a(yee,"runHardSwitch");function IN(){return new ce("hard-switch").description("Hard switch to specified FocusProfile (filesystem mutation, Phase 3+). Requires --yes for headless mode.").argument("<profile-uid>","Target FocusProfile UID").requiredOption("--vault <path>","Path to Obsidian vault").option("--yes","Confirm hard switch (headless mode safety override per RFC 22b50a17 Decision #2)",!1).option("--verbose","Print plan summary to stderr before deciding",!1).action(async(e,t)=>{try{let r=await yee(e,t);process.exit(r.exitCode)}catch(r){oe.handle(r)}})}a(IN,"hardSwitchCommand");var dl=require("node:path"),hl=require("node:fs");var Cr=require("node:fs"),AN=require("node:fs/promises"),RN=require("node:os"),Rs=require("node:path"),CN=Z(It());var _ee=/^https:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+?)(?:\.git)?$/,xN=50*1024*1024,fl=class n{static{a(this,"BootstrapAssetSpaceService")}static{this.PAT_REGEX=/(?:gh[pousr]_[A-Za-z0-9_]{36,}|github_pat_[A-Za-z0-9_]{22,}_[A-Za-z0-9_]{59,})/g}constructor(e={}){this.fetchImpl=e.fetchImpl??globalThis.fetch,this.token=e.token??""}redact(e){return(typeof e=="string"?e:String(e)).replace(n.PAT_REGEX,"***REDACTED***")}static parseGitHubURL(e){let t=e.match(_ee);if(t===null)throw new Error(`parseGitHubURL: invalid URL shape \u2014 expected https://github.com/<owner>/<repo>, got: ${e}`);return{owner:t[1],repo:t[2]}}static deriveFolderName(e){let{repo:t}=n.parseGitHubURL(e);return t.startsWith("exoas-")?t.slice(6):t}async pullAssetSpace(e,t,r){let{owner:i,repo:s}=n.parseGitHubURL(e);if((0,Cr.existsSync)(r)&&(0,Cr.readdirSync)(r).length>0)throw new Error(`pullAssetSpace: target ${r} exists \u0438 not empty \u2014 refusing \u043A overwrite`);let o=`https://api.github.com/repos/${i}/${s}/tarball/${t}`,l={signal:AbortSignal.timeout(6e4)};this.token.length>0&&(l.headers={Authorization:`Bearer ${this.token}`,"User-Agent":"exocortex-cli","X-GitHub-Api-Version":"2022-11-28"});let c;try{c=await this.fetchImpl(o,l)}catch(C){throw new Error(this.redact(`pullAssetSpace: fetch error for ${o}: ${C instanceof Error?C.message:String(C)}`))}if(!c.ok){if(c.status===403){let C=c.headers?.get?.("x-ratelimit-remaining"),H=c.headers?.get?.("x-ratelimit-reset");if(C==="0"||H!=null){let ne=H!=null?new Date(Number(H)*1e3).toISOString():"unknown";throw new Error(`pullAssetSpace: GitHub anonymous API rate-limit exceeded (60 req/hour). Reset at ${ne}. Wait or use authenticated CLI.`)}}if(c.status===404){let C=this.token.length>0?"repo not found, or the provided token lacks access to it":"if this is a private repo, pass --token <pat> (or set GITHUB_TOKEN / GH_TOKEN)";throw new Error(this.redact(`pullAssetSpace: fetch failed (404 Not Found) for ${o} \u2014 ${C}`))}throw new Error(this.redact(`pullAssetSpace: fetch failed (${c.status} ${c.statusText}) for ${o}`))}let u=await c.arrayBuffer();if(u.byteLength>xN)throw new Error(`pullAssetSpace: tarball too large (${u.byteLength} bytes > ${xN})`);let f=new Uint8Array(u),d=await(0,CN.parseTarballGzip)(f);if(d.length===0)throw new Error(`pullAssetSpace: empty tarball for ${i}/${s}@${t}`);let h=a(C=>C==="globalExtendedHeader"||C==="extendedHeader","isHeaderType"),p=d.find(C=>!h(C.type)&&C.name.includes("/"));if(p===void 0)throw new Error("pullAssetSpace: no wrapper-bearing entry in tarball");let g=p.name.indexOf("/"),_=p.name.slice(0,g),v=_+"/";for(let C of d)if(!h(C.type)&&!(C.name===_||C.name===v)&&!C.name.startsWith(v))throw new Error(`pullAssetSpace: entry "${C.name}" not under wrapper "${_}"`);let w=_.match(/-([0-9a-fA-F]{7,40})$/);if(w===null)throw new Error(`pullAssetSpace: cannot extract SHA from wrapper "${_}"`);let E=w[1].toLowerCase(),I=await(0,AN.mkdtemp)((0,Rs.join)((0,RN.tmpdir)(),`exo-bootstrap-${i}-${s}-`)),O=0;try{for(let C of d){if(C.type==="symbolicLink"||C.type==="hardLink")throw new Error(`pullAssetSpace: ${C.type} entry "${C.name}" rejected for security`);if(h(C.type))continue;let H=C.name.slice(v.length);if(H.length===0||C.type==="directory"||C.data===void 0)continue;if(H.split("/").some(de=>de===".."))throw new Error(`pullAssetSpace: path traversal detected for entry "${C.name}"`);let ne=(0,Rs.resolve)(I,H);if(ne!==I&&!ne.startsWith(I+Rs.sep))throw new Error(`pullAssetSpace: zip-slip detected for entry "${C.name}"`);(0,Cr.mkdirSync)((0,Rs.dirname)(ne),{recursive:!0}),(0,Cr.writeFileSync)(ne,C.data),O++}(0,Cr.mkdirSync)((0,Rs.dirname)(r),{recursive:!0});try{(0,Cr.renameSync)(I,r)}catch(C){if(C.code==="EXDEV"){let{cpSync:H}=await import("node:fs");H(I,r,{recursive:!0}),(0,Cr.rmSync)(I,{recursive:!0,force:!0})}else throw C}}catch(C){throw(0,Cr.rmSync)(I,{recursive:!0,force:!0}),C}return{sha:E,fileCount:O}}ensureGitmodulesEntry(e,t,r){let i=(0,Rs.join)(e,".gitmodules"),o=`${`[submodule "${t}"]`}
784
784
  path = ${t}
785
785
  url = ${r}
786
786
  `,l=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`^\\s*\\[submodule "${l}"\\]`,"m"),u="";try{u=(0,Cr.readFileSync)(i,"utf8")}catch(d){if(d.code!=="ENOENT")throw d}if(u.length>0&&c.test(u))return{added:!1};let f=u.length===0||u.endsWith(`
787
787
  `)?"":`
788
- `;return(0,Cr.appendFileSync)(i,f+o,{encoding:"utf8"}),{added:!0}}};function PN(){return new ce("bootstrap").description("Phase 6.2: bootstrap empty vault \u0441 TS-floor AssetSpaces (exo + exocmd). Pulls tarballs from public GitHub repos, extracts \u043A assetspaces/, writes .gitmodules. Example URLs: https://github.com/kitelev/exoas-exo, https://github.com/kitelev/exoas-exocmd.").requiredOption("--vault <path>","Path \u043A target vault").requiredOption("--exo <url>","Public GitHub URL \u0434\u043B\u044F exo TBox AssetSpace (e.g. https://github.com/kitelev/exoas-exo)").requiredOption("--exocmd <url>","Public GitHub URL \u0434\u043B\u044F exocmd TBox AssetSpace (e.g. https://github.com/kitelev/exoas-exocmd)").option("--ref <branch>","Branch ref \u043A pull from","main").option("--json","Emit result as JSON",!1).action(async n=>{try{if(!n.vault)throw new it("--vault is required");let e=(0,dl.resolve)(n.vault);(0,hl.mkdirSync)(e,{recursive:!0});let t=(0,dl.join)(e,".gitmodules"),r=(0,dl.join)(e,"assetspaces");if((0,hl.existsSync)(t))throw new it(`Vault ${e} already has .gitmodules \u2014 refusing \u043A re-bootstrap. Use \`assetspace add\` \u0434\u043B\u044F individual AS.`);if((0,hl.existsSync)(r)&&(0,hl.readdirSync)(r).length>0)throw new it(`Vault ${e}/assetspaces/ already has content \u2014 refusing \u043A re-bootstrap.`);let i=new fl,s=n.ref??"main",o=[],l="exo",c=(0,dl.join)(e,"assetspaces",l);process.stderr.write(`[bootstrap] Pulling ${n.exo}@${s} \u2192 assetspaces/${l}/...
789
- `);let u=await i.pullAssetSpace(n.exo,s,c);i.ensureGitmodulesEntry(e,`assetspaces/${l}`,n.exo),o.push({folder:`assetspaces/${l}`,url:n.exo,sha:u.sha,fileCount:u.fileCount});let f="exocmd",d=(0,dl.join)(e,"assetspaces",f);process.stderr.write(`[bootstrap] Pulling ${n.exocmd}@${s} \u2192 assetspaces/${f}/...
790
- `);let h=await i.pullAssetSpace(n.exocmd,s,d);if(i.ensureGitmodulesEntry(e,`assetspaces/${f}`,n.exocmd),o.push({folder:`assetspaces/${f}`,url:n.exocmd,sha:h.sha,fileCount:h.fileCount}),n.json)process.stdout.write(JSON.stringify({vault:e,materialized:o},null,2)+`
788
+ `;return(0,Cr.appendFileSync)(i,f+o,{encoding:"utf8"}),{added:!0}}};function PN(){return new ce("bootstrap").description("Phase 6.2: bootstrap empty vault \u0441 TS-floor AssetSpaces (exo + exocmd). Pulls tarballs from public GitHub repos, extracts \u043A assetspaces/, writes .gitmodules. Example URLs: https://github.com/kitelev/exoas-exo, https://github.com/kitelev/exoas-exocmd.").requiredOption("--vault <path>","Path \u043A target vault").requiredOption("--exo <url>","Public GitHub URL \u0434\u043B\u044F exo TBox AssetSpace (e.g. https://github.com/kitelev/exoas-exo)").requiredOption("--exocmd <url>","Public GitHub URL \u0434\u043B\u044F exocmd TBox AssetSpace (e.g. https://github.com/kitelev/exoas-exocmd)").option("--ref <branch>","Branch ref \u043A pull from","main").option("--token <pat>","GitHub PAT for private repos (or env GITHUB_TOKEN / GH_TOKEN). Optional \u2014 anonymous for public repos.").option("--json","Emit result as JSON",!1).action(async n=>{try{if(!n.vault)throw new it("--vault is required");let e=(0,dl.resolve)(n.vault);(0,hl.mkdirSync)(e,{recursive:!0});let t=(0,dl.join)(e,".gitmodules"),r=(0,dl.join)(e,"assetspaces");if((0,hl.existsSync)(t))throw new it(`Vault ${e} already has .gitmodules \u2014 refusing \u043A re-bootstrap. Use \`assetspace add\` \u0434\u043B\u044F individual AS.`);if((0,hl.existsSync)(r)&&(0,hl.readdirSync)(r).length>0)throw new it(`Vault ${e}/assetspaces/ already has content \u2014 refusing \u043A re-bootstrap.`);let i=n.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,s=new fl({token:i}),o=n.ref??"main",l=[],c="exo",u=(0,dl.join)(e,"assetspaces",c);process.stderr.write(`[bootstrap] Pulling ${n.exo}@${o} \u2192 assetspaces/${c}/...
789
+ `);let f=await s.pullAssetSpace(n.exo,o,u);s.ensureGitmodulesEntry(e,`assetspaces/${c}`,n.exo),l.push({folder:`assetspaces/${c}`,url:n.exo,sha:f.sha,fileCount:f.fileCount});let d="exocmd",h=(0,dl.join)(e,"assetspaces",d);process.stderr.write(`[bootstrap] Pulling ${n.exocmd}@${o} \u2192 assetspaces/${d}/...
790
+ `);let p=await s.pullAssetSpace(n.exocmd,o,h);if(s.ensureGitmodulesEntry(e,`assetspaces/${d}`,n.exocmd),l.push({folder:`assetspaces/${d}`,url:n.exocmd,sha:p.sha,fileCount:p.fileCount}),n.json)process.stdout.write(JSON.stringify({vault:e,materialized:l},null,2)+`
791
791
  `);else{process.stdout.write(`
792
792
  \u2713 Bootstrap complete
793
793
  `),process.stdout.write(` Vault: ${e}
794
- `);for(let p of o)process.stdout.write(` ${p.folder} \u2190 ${p.url}@${p.sha} (${p.fileCount} files)
794
+ `);for(let g of l)process.stdout.write(` ${g.folder} \u2190 ${g.url}@${g.sha} (${g.fileCount} files)
795
795
  `);process.stdout.write(`
796
796
  Next steps:
797
797
  `),process.stdout.write(` 1. cd ${e} && git init (if not initialized)
798
798
  `),process.stdout.write(` 2. git add . && git commit -m "feat: bootstrap vault"
799
799
  `),process.stdout.write(` 3. Add additional AssetSpaces via \`exocortex assetspace add --vault ${e} --url <github-url>\`
800
- `)}process.exit(0)}catch(e){se.handle(e)}})}a(PN,"bootstrapCommand");var My=require("node:path"),ON=require("node:fs");function FN(){return new ce("assetspace-add").description("Phase 6.3: add single AssetSpace \u043A existing vault by public GitHub URL. Pulls tarball, extracts \u043A assetspaces/<folder>/, updates .gitmodules.").requiredOption("--vault <path>","Path \u043A target vault").requiredOption("--url <url>","Public GitHub URL \u0434\u043B\u044F the AssetSpace (e.g. https://github.com/kitelev/exoas-pmbok-ontology)").option("--folder <name>","Local folder name \u043F\u043E\u0434 assetspaces/. Defaults \u043A URL-derived (strips exoas- prefix)").option("--ref <branch>","Branch ref \u043A pull from","main").option("--json","Emit result as JSON",!1).action(async n=>{try{if(!n.vault)throw new it("--vault is required");if(!n.url)throw new it("--url is required");let e=(0,My.resolve)(n.vault);if(!(0,ON.existsSync)(e))throw new he(e);let t=new fl,r=n.ref??"main",i=n.folder??fl.deriveFolderName(n.url),s=(0,My.join)(e,"assetspaces",i);process.stderr.write(`[assetspace-add] Pulling ${n.url}@${r} \u2192 assetspaces/${i}/...
801
- `);let o=await t.pullAssetSpace(n.url,r,s),l=t.ensureGitmodulesEntry(e,`assetspaces/${i}`,n.url);n.json?process.stdout.write(JSON.stringify({vault:e,folder:`assetspaces/${i}`,url:n.url,sha:o.sha,fileCount:o.fileCount,gitmodulesEntryAdded:l.added},null,2)+`
800
+ `)}process.exit(0)}catch(e){oe.handle(e)}})}a(PN,"bootstrapCommand");var My=require("node:path"),ON=require("node:fs");function FN(){return new ce("assetspace-add").description("Phase 6.3: add single AssetSpace \u043A existing vault by public GitHub URL. Pulls tarball, extracts \u043A assetspaces/<folder>/, updates .gitmodules.").requiredOption("--vault <path>","Path \u043A target vault").requiredOption("--url <url>","Public GitHub URL \u0434\u043B\u044F the AssetSpace (e.g. https://github.com/kitelev/exoas-pmbok-ontology)").option("--folder <name>","Local folder name \u043F\u043E\u0434 assetspaces/. Defaults \u043A URL-derived (strips exoas- prefix)").option("--ref <branch>","Branch ref \u043A pull from","main").option("--token <pat>","GitHub PAT for private repos (or env GITHUB_TOKEN / GH_TOKEN). Optional \u2014 anonymous for public repos.").option("--json","Emit result as JSON",!1).action(async n=>{try{if(!n.vault)throw new it("--vault is required");if(!n.url)throw new it("--url is required");let e=(0,My.resolve)(n.vault);if(!(0,ON.existsSync)(e))throw new pe(e);let t=n.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,r=new fl({token:t}),i=n.ref??"main",s=n.folder??fl.deriveFolderName(n.url),o=(0,My.join)(e,"assetspaces",s);process.stderr.write(`[assetspace-add] Pulling ${n.url}@${i} \u2192 assetspaces/${s}/...
801
+ `);let l=await r.pullAssetSpace(n.url,i,o),c=r.ensureGitmodulesEntry(e,`assetspaces/${s}`,n.url);n.json?process.stdout.write(JSON.stringify({vault:e,folder:`assetspaces/${s}`,url:n.url,sha:l.sha,fileCount:l.fileCount,gitmodulesEntryAdded:c.added},null,2)+`
802
802
  `):(process.stdout.write(`
803
803
  \u2713 AssetSpace added
804
- `),process.stdout.write(` Folder: assetspaces/${i}
804
+ `),process.stdout.write(` Folder: assetspaces/${s}
805
805
  `),process.stdout.write(` URL: ${n.url}
806
- `),process.stdout.write(` SHA: ${o.sha} (${o.fileCount} files)
807
- `),process.stdout.write(` .gitmodules: ${l.added?"entry added":"entry already present"}
808
- `)),process.exit(0)}catch(e){se.handle(e)}})}a(FN,"assetSpaceAddCommand");function DN(n){let e=new ce;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.60.13"),e.addCommand(lN()),e.addCommand(_N()),e.addCommand(LD()),e.addCommand(MD()),e.addCommand(dL()),e.addCommand(VD()),e.addCommand(BD()),e.addCommand(HD()),e.addCommand(mL()),e.addCommand(xL()),e.addCommand(CL()),e.addCommand(PL()),e.addCommand(FL()),e.addCommand(GL()),e.addCommand(qL()),e.addCommand(KL()),e.addCommand(aN()),e.addCommand(vN()),e.addCommand(IN()),e.addCommand(PN()),e.addCommand(FN()),e}a(DN,"createProgram");DN().parse();0&&(module.exports={createProgram});
806
+ `),process.stdout.write(` SHA: ${l.sha} (${l.fileCount} files)
807
+ `),process.stdout.write(` .gitmodules: ${c.added?"entry added":"entry already present"}
808
+ `)),process.exit(0)}catch(e){oe.handle(e)}})}a(FN,"assetSpaceAddCommand");function DN(n){let e=new ce;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system").version(n??"16.61.1"),e.addCommand(lN()),e.addCommand(_N()),e.addCommand(LD()),e.addCommand(MD()),e.addCommand(dL()),e.addCommand(VD()),e.addCommand(BD()),e.addCommand(HD()),e.addCommand(mL()),e.addCommand(xL()),e.addCommand(CL()),e.addCommand(PL()),e.addCommand(FL()),e.addCommand(GL()),e.addCommand(qL()),e.addCommand(KL()),e.addCommand(aN()),e.addCommand(vN()),e.addCommand(IN()),e.addCommand(PN()),e.addCommand(FN()),e}a(DN,"createProgram");DN().parse();0&&(module.exports={createProgram});
809
809
  /*! Bundled license information:
810
810
 
811
811
  reflect-metadata/Reflect.js: