@kitelev/exocortex-cli 16.239.3 → 16.240.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +35 -35
- 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.
|
|
2
|
+
// @kitelev/exocortex-cli v16.240.0
|
|
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 m8=Object.create;var hp=Object.defineProperty;var g8=Object.getOwnPropertyDescriptor;var y8=Object.getOwnPropertyNames;var _8=Object.getPrototypeOf,b8=Object.prototype.hasOwnProperty;var a=(r,e)=>hp(r,"name",{value:e,configurable:!0});var qe=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var v=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Ig=(r,e)=>{for(var t in e)hp(r,t,{get:e[t],enumerable:!0})},VP=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of y8(e))!b8.call(r,i)&&i!==t&&hp(r,i,{get:()=>e[i],enumerable:!(n=g8(e,i))||n.enumerable});return r};var ne=(r,e,t)=>(t=r!=null?m8(_8(r)):{},VP(e||!r||!r.__esModule?hp(t,"default",{value:r,enumerable:!0}):t,r)),Rg=r=>VP(hp({},"__esModule",{value:!0}),r);var EE=v(()=>{var GP;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(l,u){return function(f,d){Object.defineProperty(l,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 c(){return s()||o()}a(c,"sloppyModeThis")})(function(e,t){var n=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",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,f={create:c?function(){return et(Object.create(null))}:l?function(){return et({__proto__:null})}:function(){return et({})},has:u?function(C,x){return n.call(C,x)}:function(C,x){return x in C},get:u?function(C,x){return n.call(C,x)?C[x]:void 0}:function(C,x){return C[x]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:je(),h=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ze(),m=typeof WeakMap=="function"?WeakMap:nt(),g=i?Symbol.for("@reflect-metadata:registry"):void 0,_=De(),b=Fe(_);function T(C,x,k,G){if(re(k)){if(!Ie(C))throw new TypeError;if(!ve(x))throw new TypeError;return Z(C,x)}else{if(!Ie(C))throw new TypeError;if(!Y(x))throw new TypeError;if(!Y(G)&&!re(G)&&!Q(G))throw new TypeError;return Q(G)&&(G=void 0),k=de(k),J(C,x,k,G)}}a(T,"decorate"),e("decorate",T);function I(C,x){function k(G,Te){if(!Y(G))throw new TypeError;if(!re(Te)&&!Ae(Te))throw new TypeError;W(C,x,G,Te)}return a(k,"decorator"),k}a(I,"metadata"),e("metadata",I);function w(C,x,k,G){if(!Y(k))throw new TypeError;return re(G)||(G=de(G)),W(C,x,k,G)}a(w,"defineMetadata"),e("defineMetadata",w);function S(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=de(k)),U(C,x,k)}a(S,"hasMetadata"),e("hasMetadata",S);function R(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=de(k)),K(C,x,k)}a(R,"hasOwnMetadata"),e("hasOwnMetadata",R);function L(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=de(k)),_e(C,x,k)}a(L,"getMetadata"),e("getMetadata",L);function P(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=de(k)),le(C,x,k)}a(P,"getOwnMetadata"),e("getOwnMetadata",P);function M(C,x){if(!Y(C))throw new TypeError;return re(x)||(x=de(x)),H(C,x)}a(M,"getMetadataKeys"),e("getMetadataKeys",M);function O(C,x){if(!Y(C))throw new TypeError;return re(x)||(x=de(x)),oe(C,x)}a(O,"getOwnMetadataKeys"),e("getOwnMetadataKeys",O);function F(C,x,k){if(!Y(x))throw new TypeError;if(re(k)||(k=de(k)),!Y(x))throw new TypeError;re(k)||(k=de(k));var G=Ce(x,k,!1);return re(G)?!1:G.OrdinaryDeleteMetadata(C,x,k)}a(F,"deleteMetadata"),e("deleteMetadata",F);function Z(C,x){for(var k=C.length-1;k>=0;--k){var G=C[k],Te=G(x);if(!re(Te)&&!Q(Te)){if(!ve(Te))throw new TypeError;x=Te}}return x}a(Z,"DecorateConstructor");function J(C,x,k,G){for(var Te=C.length-1;Te>=0;--Te){var Vt=C[Te],Kt=Vt(x,k,G);if(!re(Kt)&&!Q(Kt)){if(!Y(Kt))throw new TypeError;G=Kt}}return G}a(J,"DecorateProperty");function U(C,x,k){var G=K(C,x,k);if(G)return!0;var Te=Re(x);return Q(Te)?!1:U(C,Te,k)}a(U,"OrdinaryHasMetadata");function K(C,x,k){var G=Ce(x,k,!1);return re(G)?!1:N(G.OrdinaryHasOwnMetadata(C,x,k))}a(K,"OrdinaryHasOwnMetadata");function _e(C,x,k){var G=K(C,x,k);if(G)return le(C,x,k);var Te=Re(x);if(!Q(Te))return _e(C,Te,k)}a(_e,"OrdinaryGetMetadata");function le(C,x,k){var G=Ce(x,k,!1);if(!re(G))return G.OrdinaryGetOwnMetadata(C,x,k)}a(le,"OrdinaryGetOwnMetadata");function W(C,x,k,G){var Te=Ce(k,G,!0);Te.OrdinaryDefineOwnMetadata(C,x,k,G)}a(W,"OrdinaryDefineOwnMetadata");function H(C,x){var k=oe(C,x),G=Re(C);if(G===null)return k;var Te=H(G,x);if(Te.length<=0)return k;if(k.length<=0)return Te;for(var Vt=new h,Kt=[],tt=0,he=k;tt<he.length;tt++){var me=he[tt],ge=Vt.has(me);ge||(Vt.add(me),Kt.push(me))}for(var Se=0,Xe=Te;Se<Xe.length;Se++){var me=Xe[Se],ge=Vt.has(me);ge||(Vt.add(me),Kt.push(me))}return Kt}a(H,"OrdinaryMetadataKeys");function oe(C,x){var k=Ce(C,x,!1);return k?k.OrdinaryOwnMetadataKeys(C,x):[]}a(oe,"OrdinaryOwnMetadataKeys");function xe(C){if(C===null)return 1;switch(typeof C){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return C===null?1:6;default:return 6}}a(xe,"Type");function re(C){return C===void 0}a(re,"IsUndefined");function Q(C){return C===null}a(Q,"IsNull");function ie(C){return typeof C=="symbol"}a(ie,"IsSymbol");function Y(C){return typeof C=="object"?C!==null:typeof C=="function"}a(Y,"IsObject");function ae(C,x){switch(xe(C)){case 0:return C;case 1:return C;case 2:return C;case 3:return C;case 4:return C;case 5:return C}var k=x===3?"string":x===5?"number":"default",G=V(C,s);if(G!==void 0){var Te=G.call(C,k);if(Y(Te))throw new TypeError;return Te}return Me(C,k==="default"?"number":k)}a(ae,"ToPrimitive");function Me(C,x){if(x==="string"){var k=C.toString;if(we(k)){var G=k.call(C);if(!Y(G))return G}var Te=C.valueOf;if(we(Te)){var G=Te.call(C);if(!Y(G))return G}}else{var Te=C.valueOf;if(we(Te)){var G=Te.call(C);if(!Y(G))return G}var Vt=C.toString;if(we(Vt)){var G=Vt.call(C);if(!Y(G))return G}}throw new TypeError}a(Me,"OrdinaryToPrimitive");function N(C){return!!C}a(N,"ToBoolean");function ue(C){return""+C}a(ue,"ToString");function de(C){var x=ae(C,3);return ie(x)?x:ue(x)}a(de,"ToPropertyKey");function Ie(C){return Array.isArray?Array.isArray(C):C instanceof Object?C instanceof Array:Object.prototype.toString.call(C)==="[object Array]"}a(Ie,"IsArray");function we(C){return typeof C=="function"}a(we,"IsCallable");function ve(C){return typeof C=="function"}a(ve,"IsConstructor");function Ae(C){switch(xe(C)){case 3:return!0;case 4:return!0;default:return!1}}a(Ae,"IsPropertyKey");function pe(C,x){return C===x||C!==C&&x!==x}a(pe,"SameValueZero");function V(C,x){var k=C[x];if(k!=null){if(!we(k))throw new TypeError;return k}}a(V,"GetMethod");function D(C){var x=V(C,o);if(!we(x))throw new TypeError;var k=x.call(C);if(!Y(k))throw new TypeError;return k}a(D,"GetIterator");function z(C){return C.value}a(z,"IteratorValue");function se(C){var x=C.next();return x.done?!1:x}a(se,"IteratorStep");function be(C){var x=C.return;x&&x.call(C)}a(be,"IteratorClose");function Re(C){var x=Object.getPrototypeOf(C);if(typeof C!="function"||C===d||x!==d)return x;var k=C.prototype,G=k&&Object.getPrototypeOf(k);if(G==null||G===Object.prototype)return x;var Te=G.constructor;return typeof Te!="function"||Te===C?x:Te}a(Re,"OrdinaryGetPrototypeOf");function Be(){var C;!re(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(C=Ve(t.Reflect));var x,k,G,Te=new m,Vt={registerProvider:Kt,getProvider:he,setProvider:ge};return Vt;function Kt(Se){if(!Object.isExtensible(Vt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case C===Se:break;case re(x):x=Se;break;case x===Se:break;case re(k):k=Se;break;case k===Se:break;default:G===void 0&&(G=new h),G.add(Se);break}}function tt(Se,Xe){if(!re(x)){if(x.isProviderFor(Se,Xe))return x;if(!re(k)){if(k.isProviderFor(Se,Xe))return x;if(!re(G))for(var Et=D(G);;){var vt=se(Et);if(!vt)return;var cn=z(vt);if(cn.isProviderFor(Se,Xe))return be(Et),cn}}}if(!re(C)&&C.isProviderFor(Se,Xe))return C}function he(Se,Xe){var Et=Te.get(Se),vt;return re(Et)||(vt=Et.get(Xe)),re(vt)&&(vt=tt(Se,Xe),re(vt)||(re(Et)&&(Et=new p,Te.set(Se,Et)),Et.set(Xe,vt))),vt}function me(Se){if(re(Se))throw new TypeError;return x===Se||k===Se||!re(G)&&G.has(Se)}function ge(Se,Xe,Et){if(!me(Et))throw new Error("Metadata provider not registered.");var vt=he(Se,Xe);if(vt!==Et){if(!re(vt))return!1;var cn=Te.get(Se);re(cn)&&(cn=new p,Te.set(Se,cn)),cn.set(Xe,Et)}return!0}}a(Be,"CreateMetadataRegistry");function De(){var C;return!re(g)&&Y(t.Reflect)&&Object.isExtensible(t.Reflect)&&(C=t.Reflect[g]),re(C)&&(C=Be()),!re(g)&&Y(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:C}),C}a(De,"GetOrCreateMetadataRegistry");function Fe(C){var x=new m,k={isProviderFor:a(function(me,ge){var Se=x.get(me);return re(Se)?!1:Se.has(ge)},"isProviderFor"),OrdinaryDefineOwnMetadata:Kt,OrdinaryHasOwnMetadata:Te,OrdinaryGetOwnMetadata:Vt,OrdinaryOwnMetadataKeys:tt,OrdinaryDeleteMetadata:he};return _.registerProvider(k),k;function G(me,ge,Se){var Xe=x.get(me),Et=!1;if(re(Xe)){if(!Se)return;Xe=new p,x.set(me,Xe),Et=!0}var vt=Xe.get(ge);if(re(vt)){if(!Se)return;if(vt=new p,Xe.set(ge,vt),!C.setProvider(me,ge,k))throw Xe.delete(ge),Et&&x.delete(me),new Error("Wrong provider for target.")}return vt}a(G,"GetOrCreateMetadataMap");function Te(me,ge,Se){var Xe=G(ge,Se,!1);return re(Xe)?!1:N(Xe.has(me))}a(Te,"OrdinaryHasOwnMetadata");function Vt(me,ge,Se){var Xe=G(ge,Se,!1);if(!re(Xe))return Xe.get(me)}a(Vt,"OrdinaryGetOwnMetadata");function Kt(me,ge,Se,Xe){var Et=G(Se,Xe,!0);Et.set(me,ge)}a(Kt,"OrdinaryDefineOwnMetadata");function tt(me,ge){var Se=[],Xe=G(me,ge,!1);if(re(Xe))return Se;for(var Et=Xe.keys(),vt=D(Et),cn=0;;){var di=se(vt);if(!di)return Se.length=cn,Se;var Fi=z(di);try{Se[cn]=Fi}catch(qn){try{be(vt)}finally{throw qn}}cn++}}a(tt,"OrdinaryOwnMetadataKeys");function he(me,ge,Se){var Xe=G(ge,Se,!1);if(re(Xe)||!Xe.delete(me))return!1;if(Xe.size===0){var Et=x.get(ge);re(Et)||(Et.delete(Se),Et.size===0&&x.delete(Et))}return!0}a(he,"OrdinaryDeleteMetadata")}a(Fe,"CreateMetadataProvider");function Ve(C){var x=C.defineMetadata,k=C.hasOwnMetadata,G=C.getOwnMetadata,Te=C.getOwnMetadataKeys,Vt=C.deleteMetadata,Kt=new m,tt={isProviderFor:a(function(he,me){var ge=Kt.get(he);return!re(ge)&&ge.has(me)?!0:Te(he,me).length?(re(ge)&&(ge=new h,Kt.set(he,ge)),ge.add(me),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:x,OrdinaryHasOwnMetadata:k,OrdinaryGetOwnMetadata:G,OrdinaryOwnMetadataKeys:Te,OrdinaryDeleteMetadata:Vt};return tt}a(Ve,"CreateFallbackProvider");function Ce(C,x,k){var G=_.getProvider(C,x);if(!re(G))return G;if(k){if(_.setProvider(C,x,b))return b;throw new Error("Illegal state.")}}a(Ce,"GetMetadataProvider");function je(){var C={},x=[],k=(function(){function tt(he,me,ge){this._index=0,this._keys=he,this._values=me,this._selector=ge}return a(tt,"MapIterator"),tt.prototype["@@iterator"]=function(){return this},tt.prototype[o]=function(){return this},tt.prototype.next=function(){var he=this._index;if(he>=0&&he<this._keys.length){var me=this._selector(this._keys[he],this._values[he]);return he+1>=this._keys.length?(this._index=-1,this._keys=x,this._values=x):this._index++,{value:me,done:!1}}return{value:void 0,done:!0}},tt.prototype.throw=function(he){throw this._index>=0&&(this._index=-1,this._keys=x,this._values=x),he},tt.prototype.return=function(he){return this._index>=0&&(this._index=-1,this._keys=x,this._values=x),{value:he,done:!0}},tt})(),G=(function(){function tt(){this._keys=[],this._values=[],this._cacheKey=C,this._cacheIndex=-2}return a(tt,"Map"),Object.defineProperty(tt.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),tt.prototype.has=function(he){return this._find(he,!1)>=0},tt.prototype.get=function(he){var me=this._find(he,!1);return me>=0?this._values[me]:void 0},tt.prototype.set=function(he,me){var ge=this._find(he,!0);return this._values[ge]=me,this},tt.prototype.delete=function(he){var me=this._find(he,!1);if(me>=0){for(var ge=this._keys.length,Se=me+1;Se<ge;Se++)this._keys[Se-1]=this._keys[Se],this._values[Se-1]=this._values[Se];return this._keys.length--,this._values.length--,pe(he,this._cacheKey)&&(this._cacheKey=C,this._cacheIndex=-2),!0}return!1},tt.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=C,this._cacheIndex=-2},tt.prototype.keys=function(){return new k(this._keys,this._values,Te)},tt.prototype.values=function(){return new k(this._keys,this._values,Vt)},tt.prototype.entries=function(){return new k(this._keys,this._values,Kt)},tt.prototype["@@iterator"]=function(){return this.entries()},tt.prototype[o]=function(){return this.entries()},tt.prototype._find=function(he,me){if(!pe(this._cacheKey,he)){this._cacheIndex=-1;for(var ge=0;ge<this._keys.length;ge++)if(pe(this._keys[ge],he)){this._cacheIndex=ge;break}}return this._cacheIndex<0&&me&&(this._cacheIndex=this._keys.length,this._keys.push(he),this._values.push(void 0)),this._cacheIndex},tt})();return G;function Te(tt,he){return tt}function Vt(tt,he){return he}function Kt(tt,he){return[tt,he]}}a(je,"CreateMapPolyfill");function Ze(){var C=(function(){function x(){this._map=new p}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(k){return this._map.has(k)},x.prototype.add=function(k){return this._map.set(k,k),this},x.prototype.delete=function(k){return this._map.delete(k)},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 C}a(Ze,"CreateSetPolyfill");function nt(){var C=16,x=f.create(),k=G();return(function(){function he(){this._key=G()}return a(he,"WeakMap"),he.prototype.has=function(me){var ge=Te(me,!1);return ge!==void 0?f.has(ge,this._key):!1},he.prototype.get=function(me){var ge=Te(me,!1);return ge!==void 0?f.get(ge,this._key):void 0},he.prototype.set=function(me,ge){var Se=Te(me,!0);return Se[this._key]=ge,this},he.prototype.delete=function(me){var ge=Te(me,!1);return ge!==void 0?delete ge[this._key]:!1},he.prototype.clear=function(){this._key=G()},he})();function G(){var he;do he="@@WeakMap@@"+tt();while(f.has(x,he));return x[he]=!0,he}function Te(he,me){if(!n.call(he,k)){if(!me)return;Object.defineProperty(he,k,{value:f.create()})}return he[k]}function Vt(he,me){for(var ge=0;ge<me;++ge)he[ge]=Math.random()*255|0;return he}function Kt(he){if(typeof Uint8Array=="function"){var me=new Uint8Array(he);return typeof crypto<"u"?crypto.getRandomValues(me):typeof msCrypto<"u"?msCrypto.getRandomValues(me):Vt(me,he),me}return Vt(new Array(he),he)}function tt(){var he=Kt(C);he[6]=he[6]&79|64,he[8]=he[8]&191|128;for(var me="",ge=0;ge<C;++ge){var Se=he[ge];(ge===4||ge===6||ge===8)&&(me+="-"),Se<16&&(me+="0"),me+=Se.toString(16).toLowerCase()}return me}}a(nt,"CreateWeakMapPolyfill");function et(C){return C.__=void 0,delete C.__,C}a(et,"MakeDictionary")})})(GP||(GP={}))});var za,tl,mp=qe(()=>{za=class extends Error{static{a(this,"CommanderError")}constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},tl=class extends za{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}});function Cg(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}var gp,xg=qe(()=>{mp();gp=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,n)=>{if(!this.argChoices.includes(t))throw new tl(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};a(Cg,"humanReadableArgName")});var qP,yp,vE=qe(()=>{xg();qP=require("node:util"),yp=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),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let n=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!i&&!s?t.push(n):n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.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(n=>Cg(n)).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((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+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(n=>JSON.stringify(n)).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 n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function s(d,p){return t.formatItem(d,n,p,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(c),i),""]));let l=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let h=d.map(m=>s(t.styleOptionTerm(t.optionTerm(m)),t.styleOptionDescription(t.optionDescription(m))));o=o.concat(this.formatItemList(p,h,t))}),t.showGlobalOptions){let d=t.visibleGlobalOptions(e).map(p=>s(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",d,t))}return this.groupItems(e.commands,t.visibleCommands(e),d=>d.helpGroup()||"Commands:").forEach((d,p)=>{let h=d.map(m=>s(t.styleSubcommandTerm(t.subcommandTerm(m)),t.styleSubcommandDescription(t.subcommandDescription(m))));o=o.concat(this.formatItemList(p,h,t))}),o.join(`
|
|
6
|
+
"use strict";var m8=Object.create;var hp=Object.defineProperty;var g8=Object.getOwnPropertyDescriptor;var y8=Object.getOwnPropertyNames;var _8=Object.getPrototypeOf,b8=Object.prototype.hasOwnProperty;var a=(r,e)=>hp(r,"name",{value:e,configurable:!0});var qe=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var v=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Ig=(r,e)=>{for(var t in e)hp(r,t,{get:e[t],enumerable:!0})},VP=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of y8(e))!b8.call(r,i)&&i!==t&&hp(r,i,{get:()=>e[i],enumerable:!(n=g8(e,i))||n.enumerable});return r};var ne=(r,e,t)=>(t=r!=null?m8(_8(r)):{},VP(e||!r||!r.__esModule?hp(t,"default",{value:r,enumerable:!0}):t,r)),Rg=r=>VP(hp({},"__esModule",{value:!0}),r);var EE=v(()=>{var GP;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(l,u){return function(f,d){Object.defineProperty(l,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 c(){return s()||o()}a(c,"sloppyModeThis")})(function(e,t){var n=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",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,f={create:c?function(){return et(Object.create(null))}:l?function(){return et({__proto__:null})}:function(){return et({})},has:u?function(C,x){return n.call(C,x)}:function(C,x){return x in C},get:u?function(C,x){return n.call(C,x)?C[x]:void 0}:function(C,x){return C[x]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:je(),h=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ze(),m=typeof WeakMap=="function"?WeakMap:nt(),g=i?Symbol.for("@reflect-metadata:registry"):void 0,_=De(),b=Fe(_);function T(C,x,k,G){if(re(k)){if(!Ie(C))throw new TypeError;if(!ve(x))throw new TypeError;return Z(C,x)}else{if(!Ie(C))throw new TypeError;if(!Y(x))throw new TypeError;if(!Y(G)&&!re(G)&&!Q(G))throw new TypeError;return Q(G)&&(G=void 0),k=fe(k),J(C,x,k,G)}}a(T,"decorate"),e("decorate",T);function I(C,x){function k(G,Te){if(!Y(G))throw new TypeError;if(!re(Te)&&!Ae(Te))throw new TypeError;W(C,x,G,Te)}return a(k,"decorator"),k}a(I,"metadata"),e("metadata",I);function w(C,x,k,G){if(!Y(k))throw new TypeError;return re(G)||(G=fe(G)),W(C,x,k,G)}a(w,"defineMetadata"),e("defineMetadata",w);function S(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=fe(k)),U(C,x,k)}a(S,"hasMetadata"),e("hasMetadata",S);function R(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=fe(k)),K(C,x,k)}a(R,"hasOwnMetadata"),e("hasOwnMetadata",R);function L(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=fe(k)),_e(C,x,k)}a(L,"getMetadata"),e("getMetadata",L);function P(C,x,k){if(!Y(x))throw new TypeError;return re(k)||(k=fe(k)),le(C,x,k)}a(P,"getOwnMetadata"),e("getOwnMetadata",P);function M(C,x){if(!Y(C))throw new TypeError;return re(x)||(x=fe(x)),H(C,x)}a(M,"getMetadataKeys"),e("getMetadataKeys",M);function O(C,x){if(!Y(C))throw new TypeError;return re(x)||(x=fe(x)),oe(C,x)}a(O,"getOwnMetadataKeys"),e("getOwnMetadataKeys",O);function F(C,x,k){if(!Y(x))throw new TypeError;if(re(k)||(k=fe(k)),!Y(x))throw new TypeError;re(k)||(k=fe(k));var G=Ce(x,k,!1);return re(G)?!1:G.OrdinaryDeleteMetadata(C,x,k)}a(F,"deleteMetadata"),e("deleteMetadata",F);function Z(C,x){for(var k=C.length-1;k>=0;--k){var G=C[k],Te=G(x);if(!re(Te)&&!Q(Te)){if(!ve(Te))throw new TypeError;x=Te}}return x}a(Z,"DecorateConstructor");function J(C,x,k,G){for(var Te=C.length-1;Te>=0;--Te){var Vt=C[Te],Kt=Vt(x,k,G);if(!re(Kt)&&!Q(Kt)){if(!Y(Kt))throw new TypeError;G=Kt}}return G}a(J,"DecorateProperty");function U(C,x,k){var G=K(C,x,k);if(G)return!0;var Te=Re(x);return Q(Te)?!1:U(C,Te,k)}a(U,"OrdinaryHasMetadata");function K(C,x,k){var G=Ce(x,k,!1);return re(G)?!1:N(G.OrdinaryHasOwnMetadata(C,x,k))}a(K,"OrdinaryHasOwnMetadata");function _e(C,x,k){var G=K(C,x,k);if(G)return le(C,x,k);var Te=Re(x);if(!Q(Te))return _e(C,Te,k)}a(_e,"OrdinaryGetMetadata");function le(C,x,k){var G=Ce(x,k,!1);if(!re(G))return G.OrdinaryGetOwnMetadata(C,x,k)}a(le,"OrdinaryGetOwnMetadata");function W(C,x,k,G){var Te=Ce(k,G,!0);Te.OrdinaryDefineOwnMetadata(C,x,k,G)}a(W,"OrdinaryDefineOwnMetadata");function H(C,x){var k=oe(C,x),G=Re(C);if(G===null)return k;var Te=H(G,x);if(Te.length<=0)return k;if(k.length<=0)return Te;for(var Vt=new h,Kt=[],tt=0,he=k;tt<he.length;tt++){var me=he[tt],ge=Vt.has(me);ge||(Vt.add(me),Kt.push(me))}for(var Se=0,Xe=Te;Se<Xe.length;Se++){var me=Xe[Se],ge=Vt.has(me);ge||(Vt.add(me),Kt.push(me))}return Kt}a(H,"OrdinaryMetadataKeys");function oe(C,x){var k=Ce(C,x,!1);return k?k.OrdinaryOwnMetadataKeys(C,x):[]}a(oe,"OrdinaryOwnMetadataKeys");function xe(C){if(C===null)return 1;switch(typeof C){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return C===null?1:6;default:return 6}}a(xe,"Type");function re(C){return C===void 0}a(re,"IsUndefined");function Q(C){return C===null}a(Q,"IsNull");function ie(C){return typeof C=="symbol"}a(ie,"IsSymbol");function Y(C){return typeof C=="object"?C!==null:typeof C=="function"}a(Y,"IsObject");function ae(C,x){switch(xe(C)){case 0:return C;case 1:return C;case 2:return C;case 3:return C;case 4:return C;case 5:return C}var k=x===3?"string":x===5?"number":"default",G=V(C,s);if(G!==void 0){var Te=G.call(C,k);if(Y(Te))throw new TypeError;return Te}return Me(C,k==="default"?"number":k)}a(ae,"ToPrimitive");function Me(C,x){if(x==="string"){var k=C.toString;if(we(k)){var G=k.call(C);if(!Y(G))return G}var Te=C.valueOf;if(we(Te)){var G=Te.call(C);if(!Y(G))return G}}else{var Te=C.valueOf;if(we(Te)){var G=Te.call(C);if(!Y(G))return G}var Vt=C.toString;if(we(Vt)){var G=Vt.call(C);if(!Y(G))return G}}throw new TypeError}a(Me,"OrdinaryToPrimitive");function N(C){return!!C}a(N,"ToBoolean");function ue(C){return""+C}a(ue,"ToString");function fe(C){var x=ae(C,3);return ie(x)?x:ue(x)}a(fe,"ToPropertyKey");function Ie(C){return Array.isArray?Array.isArray(C):C instanceof Object?C instanceof Array:Object.prototype.toString.call(C)==="[object Array]"}a(Ie,"IsArray");function we(C){return typeof C=="function"}a(we,"IsCallable");function ve(C){return typeof C=="function"}a(ve,"IsConstructor");function Ae(C){switch(xe(C)){case 3:return!0;case 4:return!0;default:return!1}}a(Ae,"IsPropertyKey");function pe(C,x){return C===x||C!==C&&x!==x}a(pe,"SameValueZero");function V(C,x){var k=C[x];if(k!=null){if(!we(k))throw new TypeError;return k}}a(V,"GetMethod");function D(C){var x=V(C,o);if(!we(x))throw new TypeError;var k=x.call(C);if(!Y(k))throw new TypeError;return k}a(D,"GetIterator");function z(C){return C.value}a(z,"IteratorValue");function se(C){var x=C.next();return x.done?!1:x}a(se,"IteratorStep");function be(C){var x=C.return;x&&x.call(C)}a(be,"IteratorClose");function Re(C){var x=Object.getPrototypeOf(C);if(typeof C!="function"||C===d||x!==d)return x;var k=C.prototype,G=k&&Object.getPrototypeOf(k);if(G==null||G===Object.prototype)return x;var Te=G.constructor;return typeof Te!="function"||Te===C?x:Te}a(Re,"OrdinaryGetPrototypeOf");function Be(){var C;!re(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(C=Ve(t.Reflect));var x,k,G,Te=new m,Vt={registerProvider:Kt,getProvider:he,setProvider:ge};return Vt;function Kt(Se){if(!Object.isExtensible(Vt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case C===Se:break;case re(x):x=Se;break;case x===Se:break;case re(k):k=Se;break;case k===Se:break;default:G===void 0&&(G=new h),G.add(Se);break}}function tt(Se,Xe){if(!re(x)){if(x.isProviderFor(Se,Xe))return x;if(!re(k)){if(k.isProviderFor(Se,Xe))return x;if(!re(G))for(var Et=D(G);;){var vt=se(Et);if(!vt)return;var cn=z(vt);if(cn.isProviderFor(Se,Xe))return be(Et),cn}}}if(!re(C)&&C.isProviderFor(Se,Xe))return C}function he(Se,Xe){var Et=Te.get(Se),vt;return re(Et)||(vt=Et.get(Xe)),re(vt)&&(vt=tt(Se,Xe),re(vt)||(re(Et)&&(Et=new p,Te.set(Se,Et)),Et.set(Xe,vt))),vt}function me(Se){if(re(Se))throw new TypeError;return x===Se||k===Se||!re(G)&&G.has(Se)}function ge(Se,Xe,Et){if(!me(Et))throw new Error("Metadata provider not registered.");var vt=he(Se,Xe);if(vt!==Et){if(!re(vt))return!1;var cn=Te.get(Se);re(cn)&&(cn=new p,Te.set(Se,cn)),cn.set(Xe,Et)}return!0}}a(Be,"CreateMetadataRegistry");function De(){var C;return!re(g)&&Y(t.Reflect)&&Object.isExtensible(t.Reflect)&&(C=t.Reflect[g]),re(C)&&(C=Be()),!re(g)&&Y(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:C}),C}a(De,"GetOrCreateMetadataRegistry");function Fe(C){var x=new m,k={isProviderFor:a(function(me,ge){var Se=x.get(me);return re(Se)?!1:Se.has(ge)},"isProviderFor"),OrdinaryDefineOwnMetadata:Kt,OrdinaryHasOwnMetadata:Te,OrdinaryGetOwnMetadata:Vt,OrdinaryOwnMetadataKeys:tt,OrdinaryDeleteMetadata:he};return _.registerProvider(k),k;function G(me,ge,Se){var Xe=x.get(me),Et=!1;if(re(Xe)){if(!Se)return;Xe=new p,x.set(me,Xe),Et=!0}var vt=Xe.get(ge);if(re(vt)){if(!Se)return;if(vt=new p,Xe.set(ge,vt),!C.setProvider(me,ge,k))throw Xe.delete(ge),Et&&x.delete(me),new Error("Wrong provider for target.")}return vt}a(G,"GetOrCreateMetadataMap");function Te(me,ge,Se){var Xe=G(ge,Se,!1);return re(Xe)?!1:N(Xe.has(me))}a(Te,"OrdinaryHasOwnMetadata");function Vt(me,ge,Se){var Xe=G(ge,Se,!1);if(!re(Xe))return Xe.get(me)}a(Vt,"OrdinaryGetOwnMetadata");function Kt(me,ge,Se,Xe){var Et=G(Se,Xe,!0);Et.set(me,ge)}a(Kt,"OrdinaryDefineOwnMetadata");function tt(me,ge){var Se=[],Xe=G(me,ge,!1);if(re(Xe))return Se;for(var Et=Xe.keys(),vt=D(Et),cn=0;;){var di=se(vt);if(!di)return Se.length=cn,Se;var Fi=z(di);try{Se[cn]=Fi}catch(qn){try{be(vt)}finally{throw qn}}cn++}}a(tt,"OrdinaryOwnMetadataKeys");function he(me,ge,Se){var Xe=G(ge,Se,!1);if(re(Xe)||!Xe.delete(me))return!1;if(Xe.size===0){var Et=x.get(ge);re(Et)||(Et.delete(Se),Et.size===0&&x.delete(Et))}return!0}a(he,"OrdinaryDeleteMetadata")}a(Fe,"CreateMetadataProvider");function Ve(C){var x=C.defineMetadata,k=C.hasOwnMetadata,G=C.getOwnMetadata,Te=C.getOwnMetadataKeys,Vt=C.deleteMetadata,Kt=new m,tt={isProviderFor:a(function(he,me){var ge=Kt.get(he);return!re(ge)&&ge.has(me)?!0:Te(he,me).length?(re(ge)&&(ge=new h,Kt.set(he,ge)),ge.add(me),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:x,OrdinaryHasOwnMetadata:k,OrdinaryGetOwnMetadata:G,OrdinaryOwnMetadataKeys:Te,OrdinaryDeleteMetadata:Vt};return tt}a(Ve,"CreateFallbackProvider");function Ce(C,x,k){var G=_.getProvider(C,x);if(!re(G))return G;if(k){if(_.setProvider(C,x,b))return b;throw new Error("Illegal state.")}}a(Ce,"GetMetadataProvider");function je(){var C={},x=[],k=(function(){function tt(he,me,ge){this._index=0,this._keys=he,this._values=me,this._selector=ge}return a(tt,"MapIterator"),tt.prototype["@@iterator"]=function(){return this},tt.prototype[o]=function(){return this},tt.prototype.next=function(){var he=this._index;if(he>=0&&he<this._keys.length){var me=this._selector(this._keys[he],this._values[he]);return he+1>=this._keys.length?(this._index=-1,this._keys=x,this._values=x):this._index++,{value:me,done:!1}}return{value:void 0,done:!0}},tt.prototype.throw=function(he){throw this._index>=0&&(this._index=-1,this._keys=x,this._values=x),he},tt.prototype.return=function(he){return this._index>=0&&(this._index=-1,this._keys=x,this._values=x),{value:he,done:!0}},tt})(),G=(function(){function tt(){this._keys=[],this._values=[],this._cacheKey=C,this._cacheIndex=-2}return a(tt,"Map"),Object.defineProperty(tt.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),tt.prototype.has=function(he){return this._find(he,!1)>=0},tt.prototype.get=function(he){var me=this._find(he,!1);return me>=0?this._values[me]:void 0},tt.prototype.set=function(he,me){var ge=this._find(he,!0);return this._values[ge]=me,this},tt.prototype.delete=function(he){var me=this._find(he,!1);if(me>=0){for(var ge=this._keys.length,Se=me+1;Se<ge;Se++)this._keys[Se-1]=this._keys[Se],this._values[Se-1]=this._values[Se];return this._keys.length--,this._values.length--,pe(he,this._cacheKey)&&(this._cacheKey=C,this._cacheIndex=-2),!0}return!1},tt.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=C,this._cacheIndex=-2},tt.prototype.keys=function(){return new k(this._keys,this._values,Te)},tt.prototype.values=function(){return new k(this._keys,this._values,Vt)},tt.prototype.entries=function(){return new k(this._keys,this._values,Kt)},tt.prototype["@@iterator"]=function(){return this.entries()},tt.prototype[o]=function(){return this.entries()},tt.prototype._find=function(he,me){if(!pe(this._cacheKey,he)){this._cacheIndex=-1;for(var ge=0;ge<this._keys.length;ge++)if(pe(this._keys[ge],he)){this._cacheIndex=ge;break}}return this._cacheIndex<0&&me&&(this._cacheIndex=this._keys.length,this._keys.push(he),this._values.push(void 0)),this._cacheIndex},tt})();return G;function Te(tt,he){return tt}function Vt(tt,he){return he}function Kt(tt,he){return[tt,he]}}a(je,"CreateMapPolyfill");function Ze(){var C=(function(){function x(){this._map=new p}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(k){return this._map.has(k)},x.prototype.add=function(k){return this._map.set(k,k),this},x.prototype.delete=function(k){return this._map.delete(k)},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 C}a(Ze,"CreateSetPolyfill");function nt(){var C=16,x=f.create(),k=G();return(function(){function he(){this._key=G()}return a(he,"WeakMap"),he.prototype.has=function(me){var ge=Te(me,!1);return ge!==void 0?f.has(ge,this._key):!1},he.prototype.get=function(me){var ge=Te(me,!1);return ge!==void 0?f.get(ge,this._key):void 0},he.prototype.set=function(me,ge){var Se=Te(me,!0);return Se[this._key]=ge,this},he.prototype.delete=function(me){var ge=Te(me,!1);return ge!==void 0?delete ge[this._key]:!1},he.prototype.clear=function(){this._key=G()},he})();function G(){var he;do he="@@WeakMap@@"+tt();while(f.has(x,he));return x[he]=!0,he}function Te(he,me){if(!n.call(he,k)){if(!me)return;Object.defineProperty(he,k,{value:f.create()})}return he[k]}function Vt(he,me){for(var ge=0;ge<me;++ge)he[ge]=Math.random()*255|0;return he}function Kt(he){if(typeof Uint8Array=="function"){var me=new Uint8Array(he);return typeof crypto<"u"?crypto.getRandomValues(me):typeof msCrypto<"u"?msCrypto.getRandomValues(me):Vt(me,he),me}return Vt(new Array(he),he)}function tt(){var he=Kt(C);he[6]=he[6]&79|64,he[8]=he[8]&191|128;for(var me="",ge=0;ge<C;++ge){var Se=he[ge];(ge===4||ge===6||ge===8)&&(me+="-"),Se<16&&(me+="0"),me+=Se.toString(16).toLowerCase()}return me}}a(nt,"CreateWeakMapPolyfill");function et(C){return C.__=void 0,delete C.__,C}a(et,"MakeDictionary")})})(GP||(GP={}))});var za,tl,mp=qe(()=>{za=class extends Error{static{a(this,"CommanderError")}constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},tl=class extends za{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}});function Cg(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}var gp,xg=qe(()=>{mp();gp=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,n)=>{if(!this.argChoices.includes(t))throw new tl(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};a(Cg,"humanReadableArgName")});var qP,yp,vE=qe(()=>{xg();qP=require("node:util"),yp=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),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let n=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!i&&!s?t.push(n):n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.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(n=>Cg(n)).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((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+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(n=>JSON.stringify(n)).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 n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function s(d,p){return t.formatItem(d,n,p,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(c),i),""]));let l=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let h=d.map(m=>s(t.styleOptionTerm(t.optionTerm(m)),t.styleOptionDescription(t.optionDescription(m))));o=o.concat(this.formatItemList(p,h,t))}),t.showGlobalOptions){let d=t.visibleGlobalOptions(e).map(p=>s(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",d,t))}return this.groupItems(e.commands,t.visibleCommands(e),d=>d.helpGroup()||"Commands:").forEach((d,p)=>{let h=d.map(m=>s(t.styleSubcommandTerm(t.subcommandTerm(m)),t.styleSubcommandDescription(t.subcommandDescription(m))));o=o.concat(this.formatItemList(p,h,t))}),o.join(`
|
|
7
7
|
`)}displayWidth(e){return(0,qP.stripVTControlCharacters)(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,n,i){let o=" ".repeat(2);if(!n)return o+e;let c=e.padEnd(t+e.length-i.displayWidth(e)),l=2,f=(this.helpWidth??80)-t-l-2,d;return f<this.minWidthToWrap||i.preformatted(n)?d=n:d=i.boxWrap(n,f).replace(/\n/g,`
|
|
8
8
|
`+" ".repeat(t+l)),o+c+" ".repeat(l)+d.replace(/\n/g,`
|
|
9
9
|
${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return n.forEach(o=>{let c=o.match(i);if(c===null){s.push("");return}let l=[c.shift()],u=this.displayWidth(l[0]);c.forEach(f=>{let d=this.displayWidth(f);if(u+d<=t){l.push(f),u+=d;return}s.push(l.join(""));let p=f.trimStart();l=[p],u=this.displayWidth(p)}),s.push(l.join(""))}),s.join(`
|
|
@@ -15,7 +15,7 @@ ${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i
|
|
|
15
15
|
- too many long flags`):new Error(`${c}
|
|
16
16
|
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:e,longFlag:t}}var Cu,Og,TE=qe(()=>{mp();Cu=class{static{a(this,"Option")}constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=S8(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new tl(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?WP(this.name().replace(/^no-/,"")):WP(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Og=class{static{a(this,"DualOptions")}constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,s=i!==void 0?i:!1;return t.negate===(s===e)}};a(WP,"camelcase");a(S8,"splitOptionFlags")});function w8(r,e){if(Math.abs(r.length-e.length)>3)return Math.max(r.length,e.length);let t=[];for(let n=0;n<=r.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=r.length;i++){let s;r[i-1]===e[n-1]?s=0:s=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+s),i>1&&n>1&&r[i-1]===e[n-2]&&r[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[r.length][e.length]}function AE(r,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=r.startsWith("--");t&&(r=r.slice(2),e=e.map(o=>o.slice(2)));let n=[],i=3,s=.4;return e.forEach(o=>{if(o.length<=1)return;let c=w8(r,o),l=Math.max(r.length,o.length);(l-c)/l>s&&(c<i?(i=c,n=[o]):c===i&&n.push(o))}),n.sort((o,c)=>o.localeCompare(c)),t&&(n=n.map(o=>`--${o}`)),n.length>1?`
|
|
17
17
|
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
18
|
-
(Did you mean ${n[0]}?)`:""}var HP=qe(()=>{a(w8,"editDistance");a(AE,"suggestSimilar")});function zP(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="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]:n=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],n=s[3],i=s[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function KP(){if(bt.default.env.NO_COLOR||bt.default.env.FORCE_COLOR==="0"||bt.default.env.FORCE_COLOR==="false")return!1;if(bt.default.env.FORCE_COLOR||bt.default.env.CLICOLOR_FORCE!==void 0)return!0}var YP,Pg,ro,_p,bt,QP,
|
|
18
|
+
(Did you mean ${n[0]}?)`:""}var HP=qe(()=>{a(w8,"editDistance");a(AE,"suggestSimilar")});function zP(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="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]:n=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],n=s[3],i=s[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function KP(){if(bt.default.env.NO_COLOR||bt.default.env.FORCE_COLOR==="0"||bt.default.env.FORCE_COLOR==="false")return!1;if(bt.default.env.FORCE_COLOR||bt.default.env.CLICOLOR_FORCE!==void 0)return!0}var YP,Pg,ro,_p,bt,QP,de,XP=qe(()=>{YP=require("node:events"),Pg=ne(require("node:child_process"),1),ro=ne(require("node:path"),1),_p=ne(require("node:fs"),1),bt=ne(require("node:process"),1),QP=require("node:util");xg();mp();vE();TE();HP();de=class r extends YP.EventEmitter{static{a(this,"Command")}constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:a(t=>bt.default.stdout.write(t),"writeOut"),writeErr:a(t=>bt.default.stderr.write(t),"writeErr"),outputError:a((t,n)=>n(t),"outputError"),getOutHelpWidth:a(()=>bt.default.stdout.isTTY?bt.default.stdout.columns:void 0,"getOutHelpWidth"),getErrHelpWidth:a(()=>bt.default.stderr.isTTY?bt.default.stderr.columns:void 0,"getErrHelpWidth"),getOutHasColors:a(()=>KP()??(bt.default.stdout.isTTY&&bt.default.stdout.hasColors?.()),"getOutHasColors"),getErrHasColors:a(()=>KP()??(bt.default.stderr.isTTY&&bt.default.stderr.hasColors?.()),"getErrHasColors"),stripColor:a(t=>(0,QP.stripVTControlCharacters)(t),"stripColor")},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,s=n;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,o,c]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),s.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(s.noHelp||s.hidden),l._executableFile=s.executableFile||null,c&&l.arguments(c),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new r(e)}createHelp(){return Object.assign(new yp,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
19
19
|
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new gp(e,t)}argument(e,t,n,i){let s=this.createArgument(e,t);return typeof n=="function"?s.default(i).argParser(n):s.default(n),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,s]=n.match(/([^ ]+) *(.*)/),o=t??"display help for command",c=this.createCommand(i);return c.helpOption(!1),s&&c.arguments(s),o&&c.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=c,(e||t)&&this._initCommandGroup(c),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
20
20
|
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new za(e,t,n)),bt.default.exit(e)}action(e){let t=a(n=>{let i=this.registeredArguments.length,s=n.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)},"listener");return this._actionHandler=t,this}createOption(e,t){return new Cu(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${i} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
21
21
|
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=a(i=>[i.name()].concat(i.aliases()),"knownBy"),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=a((s,o,c)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let l=this.getOptionValue(n);s!==null&&e.parseArg?s=this._callParseArg(e,s,l,o):s!==null&&e.variadic&&(s=e._collectValue(s,l)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(n,s,c)},"handleOptionValue");return this.on("option:"+t,s=>{let o=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let o=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,o,"env")}),this}_optionEx(e,t,n,i,s){if(typeof t=="object"&&t instanceof Cu)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,n);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(s).argParser(i);else if(i instanceof RegExp){let c=i;i=a((l,u)=>{let f=c.exec(l);return f?f[0]:u},"fn"),o.default(s).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){bt.default.versions?.electron&&(t.from="electron");let i=bt.default.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=bt.default.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":bt.default.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
@@ -28,11 +28,11 @@ Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
28
28
|
`),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,s=n.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in bt.default.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,bt.default.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Og(this.options),t=a(n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n)),"hasCustomOptionValue");this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=a(o=>{let c=o.attributeName(),l=this.getOptionValue(c),u=this.options.find(d=>d.negate&&c===d.attributeName()),f=this.options.find(d=>!d.negate&&c===d.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:f||o},"findBestOptionFromValue"),i=a(o=>{let c=n(o),l=c.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${c.envVar}'`:`option '${c.flags}'`},"getErrorMessage"),s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(c=>c.long).map(c=>c.long);i=i.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);t=AE(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=e.length,s=this.parent?` for '${this.name()}'`:"",o=e.join(", "),c=`error: too many arguments${s}. Expected ${t} argument${n} but got ${i}: ${o}.`;this.error(c,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),t=AE(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
29
29
|
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>Cg(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=ro.default.basename(e,ro.default.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,s;return t?(n=a(c=>this._outputConfiguration.writeErr(c),"baseWrite"),i=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(n=a(c=>this._outputConfiguration.writeOut(c),"baseWrite"),i=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:t,write:a(c=>(i||(c=this._outputConfiguration.stripColor(c)),n(c)),"write"),hasColors:i,helpWidth:s}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let s=this.helpInformation({error:n.error});if(t&&(s=t(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(bt.default.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
30
30
|
Expecting one of '${n.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
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};a(zP,"incrementNodeInspectorPort");a(KP,"useColor")});var g_e,ct=qe(()=>{xg();XP();mp();vE();TE();g_e=new fe});var rl=v(Dg=>{"use strict";Object.defineProperty(Dg,"__esModule",{value:!0});Dg.AssetClass=void 0;var JP;(function(r){r.AREA="ems__Area",r.TASK="ems__Task",r.PROJECT="ems__Project",r.ACTION="ems__Action",r.MEETING="ems__Meeting",r.INITIATIVE="ems__Initiative",r.TASK_PROTOTYPE="ems__TaskPrototype",r.MEETING_PROTOTYPE="ems__MeetingPrototype",r.EVENT_PROTOTYPE="exo__EventPrototype",r.PROJECT_PROTOTYPE="ems__ProjectPrototype",r.EVENT="exo__Event",r.DAILY_NOTE="pn__DailyNote",r.CONCEPT="ims__Concept",r.SESSION_START_EVENT="ems__SessionStartEvent",r.SESSION_END_EVENT="ems__SessionEndEvent",r.PROTOTYPE="exo__Prototype",r.CLASS="exo__Class",r.FLEETING_NOTE="ztlk__FleetingNote",r.WORKFLOW="ems__Workflow",r.WORKFLOW_STATE="ems__WorkflowState",r.WORKFLOW_TRANSITION="ems__WorkflowTransition",r.COMMAND="exocmd__Command",r.PRECONDITION="exocmd__Precondition",r.GROUNDING="exocmd__Grounding",r.COMMAND_BINDING="exocmd__CommandBinding"})(JP||(Dg.AssetClass=JP={}))});var nl=v(Fg=>{"use strict";Object.defineProperty(Fg,"__esModule",{value:!0});Fg.EffortStatus=void 0;var ZP;(function(r){r.DRAFT="ems__EffortStatusDraft",r.BACKLOG="ems__EffortStatusBacklog",r.DOING="ems__EffortStatusDoing",r.WAITING="ems__EffortStatusWaiting",r.DONE="ems__EffortStatusDone",r.TRASHED="ems__EffortStatusTrashed"})(ZP||(Fg.EffortStatus=ZP={}))});var Ou=v(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.EFFORT_STATUS_BY_UID=Bo.EFFORT_STATUS_UID=void 0;Bo.normalizeEffortStatus=T8;var xu=nl();Bo.EFFORT_STATUS_UID={[xu.EffortStatus.DRAFT]:"c42245d0-01de-4c35-bfcf-d910445ea28e",[xu.EffortStatus.BACKLOG]:"753a44d5-846c-4b82-9196-4fd9a4d48777",[xu.EffortStatus.DOING]:"027e78f4-6e16-4b36-b8fb-5510507d5745",[xu.EffortStatus.WAITING]:"0610947c-6a62-41c8-9d44-7863d3ba3a8e",[xu.EffortStatus.DONE]:"7b9b3116-7c3c-438c-9618-94fe301320a6",[xu.EffortStatus.TRASHED]:"5d14f18d-db2b-4847-9ac1-144cb93b2541"};Bo.EFFORT_STATUS_BY_UID=Object.freeze(Object.fromEntries(Object.entries(Bo.EFFORT_STATUS_UID).map(([r,e])=>[e,r])));var IE=/^ems__EffortStatus[A-Za-z]+$/,E8=/\s+[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,v8=/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;function T8(r){let e=r;if(e==null)return null;if(Array.isArray(e)){if(e.length!==1)return null;e=e[0]}let t=String(e).trim().replace(/^["']/,"").replace(/["']$/,"").replace(/^\[\[/,"").replace(/\]\]$/,"").trim();if(!t)return null;if(IE.test(t))return t;let n=t.indexOf("|"),i=n===-1?t:t.slice(0,n).trim();if(n!==-1){let c=t.slice(n+1).trim();if(IE.test(c))return c}let s=i.replace(E8,"").trim();if(IE.test(s))return s;let o=i.match(v8);return o?Bo.EFFORT_STATUS_BY_UID[o[1].toLowerCase()]??null:null}a(T8,"normalizeEffortStatus")});var RE=v(Lg=>{"use strict";Object.defineProperty(Lg,"__esModule",{value:!0});Lg.EFFORT_STATUS_OPTIONS=void 0;var A8=Ou();Lg.EFFORT_STATUS_OPTIONS=Object.freeze(Object.keys(A8.EFFORT_STATUS_UID).map(r=>Object.freeze({value:`[[${r}]]`,label:r.replace(/^ems__EffortStatus/,"")})))});var Ka=v(Ng=>{"use strict";Object.defineProperty(Ng,"__esModule",{value:!0});Ng.GroundingType=void 0;var e3;(function(r){r.SPARQL_UPDATE="sparql_update",r.PROPERTY_DELETE="property_delete",r.PROPERTY_SET="property_set",r.COMPOSITE="composite",r.SERVICE_CALL="service_call",r.CREATE_INSTANCE="create_instance",r.PROPERTY_APPEND="property_append",r.PROPERTY_INCREMENT="property_increment",r.PROPERTY_SHIFT="property_shift",r.WORKFLOW_TRANSITION="workflow_transition",r.BODY_TEMPLATE="body_template"})(e3||(Ng.GroundingType=e3={}))});var bp=v(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.GROUNDING_TYPE_IRI_TO_ENUM=hi.GROUNDING_TYPE_UID_TO_ENUM=hi.GROUNDING_TYPE_UIDS=void 0;hi.resolveGroundingTypeFromIRI=R8;hi.resolveGroundingTypeFromWikilinkLiteral=C8;var lr=Ka();hi.GROUNDING_TYPE_UIDS={[lr.GroundingType.PROPERTY_SET]:"cf3bb923-f1f1-40be-b728-782844402426",[lr.GroundingType.PROPERTY_DELETE]:"4bdf1d0b-e9da-4d96-bafe-c5aaef8c2bd5",[lr.GroundingType.COMPOSITE]:"8f9a57db-3865-4886-92fb-c5ab7f3c3fa3",[lr.GroundingType.SERVICE_CALL]:"9bf9fc99-ac37-4e51-b9f5-bd920099947c",[lr.GroundingType.CREATE_INSTANCE]:"4367e2d6-6c92-450a-becb-abce1fb07682",[lr.GroundingType.PROPERTY_APPEND]:"572f7e69-a8a1-42f6-8113-5aa65cc4b552",[lr.GroundingType.PROPERTY_INCREMENT]:"afc29f90-45eb-4f94-9fe2-2ce738759161",[lr.GroundingType.PROPERTY_SHIFT]:"f4e5266f-f3cc-49fd-a5a5-ce1e8b7847a4",[lr.GroundingType.SPARQL_UPDATE]:"79c3e709-8d1d-4694-bcc6-b9ff07d59b86",[lr.GroundingType.WORKFLOW_TRANSITION]:"5c1a2552-d576-496d-8823-563573dd1e2f",[lr.GroundingType.BODY_TEMPLATE]:"6093bfcb-cf9b-4565-86c3-ff74d8bc11c0"};hi.GROUNDING_TYPE_UID_TO_ENUM=Object.freeze(Object.fromEntries(Object.entries(hi.GROUNDING_TYPE_UIDS).map(([r,e])=>[e,r])));var us="https://exocortex.my/ontology/exocmd#";hi.GROUNDING_TYPE_IRI_TO_ENUM=Object.freeze({[`${us}GroundingTypePropertySet`]:lr.GroundingType.PROPERTY_SET,[`${us}GroundingTypePropertyDelete`]:lr.GroundingType.PROPERTY_DELETE,[`${us}GroundingTypeComposite`]:lr.GroundingType.COMPOSITE,[`${us}GroundingTypeServiceCall`]:lr.GroundingType.SERVICE_CALL,[`${us}GroundingTypeCreateInstance`]:lr.GroundingType.CREATE_INSTANCE,[`${us}GroundingTypePropertyAppend`]:lr.GroundingType.PROPERTY_APPEND,[`${us}GroundingTypePropertyIncrement`]:lr.GroundingType.PROPERTY_INCREMENT,[`${us}GroundingTypePropertyShift`]:lr.GroundingType.PROPERTY_SHIFT,[`${us}GroundingTypeSparqlUpdate`]:lr.GroundingType.SPARQL_UPDATE,[`${us}GroundingTypeWorkflowTransition`]:lr.GroundingType.WORKFLOW_TRANSITION,[`${us}GroundingTypeBodyTemplate`]:lr.GroundingType.BODY_TEMPLATE});var I8=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;function R8(r){let e=hi.GROUNDING_TYPE_IRI_TO_ENUM[r];if(e!==void 0)return e;let t=r.match(I8);return t?hi.GROUNDING_TYPE_UID_TO_ENUM[t[1].toLowerCase()]??null:null}a(R8,"resolveGroundingTypeFromIRI");function C8(r){let e=r.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return e?hi.GROUNDING_TYPE_UID_TO_ENUM[e[1].toLowerCase()]??null:null}a(C8,"resolveGroundingTypeFromWikilinkLiteral")});var CE=v(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.CommandBindingStyleProperty=Qi.CommandBindingProperty=Qi.GroundingProperty=Qi.PreconditionProperty=Qi.CommandProperty=void 0;Qi.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"};Qi.PreconditionProperty={SPARQL_ASK:"exocmd__Precondition_sparqlAsk",QUERY:"exocmd__Precondition_query"};Qi.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"};Qi.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"};Qi.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 xE=v(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.STYLE_SOURCE_VALUES=mi.LABEL_CLASS_VALUES=mi.COMMAND_VARIANT_VALUES=void 0;mi.isCommandVariant=x8;mi.isLabelClass=O8;mi.isStyleSource=P8;mi.COMMAND_VARIANT_VALUES=Object.freeze(["primary","secondary","success","warning","danger","muted"]);mi.LABEL_CLASS_VALUES=Object.freeze(["muted","bold","uppercase","compact"]);mi.STYLE_SOURCE_VALUES=Object.freeze(["vendor","user"]);function x8(r){return typeof r=="string"&&mi.COMMAND_VARIANT_VALUES.includes(r)}a(x8,"isCommandVariant");function O8(r){return typeof r=="string"&&mi.LABEL_CLASS_VALUES.includes(r)}a(O8,"isLabelClass");function P8(r){return typeof r=="string"&&mi.STYLE_SOURCE_VALUES.includes(r)}a(P8,"isStyleSource")});var t3=v(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});Pu.isCommandFrontmatter=D8;Pu.isPreconditionFrontmatter=F8;Pu.isGroundingFrontmatter=L8;Pu.isCommandBindingFrontmatter=N8;function D8(r){return kg(r,"exocmd__Command")}a(D8,"isCommandFrontmatter");function F8(r){return kg(r,"exocmd__Precondition")}a(F8,"isPreconditionFrontmatter");function L8(r){return kg(r,"exocmd__Grounding")}a(L8,"isGroundingFrontmatter");function N8(r){return kg(r,"exocmd__CommandBinding")}a(N8,"isCommandBindingFrontmatter");function kg(r,e){let t=r.exo__Instance_class;if(t==null)return!1;let n=Array.isArray(t)?t:[t];for(let i of n){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}a(kg,"hasInstanceClass")});var r3=v(OE=>{"use strict";Object.defineProperty(OE,"__esModule",{value:!0});OE.parseGroundingDefinitionFromFrontmatter=M8;var k8=bp();function Mg(r){if(typeof r!="string")return"";let e=r.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.slice(0,t).trim():e}a(Mg,"normalizeGroundingRef");function M8(r,e,t){let n=e.exocmd__Grounding_type,i=(()=>{if(typeof n!="string")return n;let S=(0,k8.resolveGroundingTypeFromWikilinkLiteral)(n);if(S!==null)return S;throw new Error(`[exocmd-grounding-type-literal-form] legacy literal-string '${n}' for exocmd__Grounding_type in fixture ${r}. 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 S=e.exocmd__Grounding_steps;Array.isArray(S)&&(o=S.map(R=>t(Mg(R))))}let c=e.exocmd__Grounding_incrementBy,l;if(c!=null&&c!==""){let S=Number.parseInt(String(c),10);Number.isFinite(S)&&(l=S)}let u=e.exocmd__Grounding_targetValueRef,f=u?Mg(u):void 0,d=e.exocmd__Grounding_templateRef,p=d?Mg(d):void 0,h=e.exocmd__Grounding_cloneTargetBody,m=h===!0||h==="true",g=e.exocmd__Grounding_targetsCreatedInstance,_=g===!0||g==="true",b=e.exocmd__Grounding_omitLabel,T=b===!0||b==="true",I=e.exocmd__Grounding_targetQuery,w=I?Mg(I):void 0;return{id:r,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:l,linkBackProperty:e.exocmd__Grounding_linkBackProperty,bodyTemplate:e.exocmd__Grounding_bodyTemplate,templateRef:p,cloneTargetBody:m,targetsCreatedInstance:_,omitLabel:T,targetQuery:w,steps:o}}a(M8,"parseGroundingDefinitionFromFrontmatter")});var n3=v(jg=>{"use strict";Object.defineProperty(jg,"__esModule",{value:!0});jg.hasPosition=j8;jg.isFixed=$8;function j8(r){return typeof r.x=="number"&&typeof r.y=="number"}a(j8,"hasPosition");function $8(r){return r.fx!==null&&r.fx!==void 0&&r.fy!==null&&r.fy!==void 0}a($8,"isFixed")});var i3=v($g=>{"use strict";Object.defineProperty($g,"__esModule",{value:!0});$g.createEmptyGraphData=U8;$g.mergeGraphData=B8;function U8(){return{nodes:[],edges:[],lastUpdated:Date.now(),version:0}}a(U8,"createEmptyGraphData");function B8(r,e){let t=new Map,n=new Set,i=[];for(let s of r.nodes)t.set(s.id,s);for(let s of e.nodes)t.set(s.id,s);for(let s of r.edges){let o=`${s.source}->${s.target}:${s.type}`;n.has(o)||(n.add(o),i.push(s))}for(let s of e.edges){let o=`${s.source}->${s.target}:${s.type}`;n.has(o)||(n.add(o),i.push(s))}return{nodes:Array.from(t.values()),edges:i,lastUpdated:Date.now(),version:Math.max(r.version??0,e.version??0)+1}}a(B8,"mergeGraphData")});var PE=v(Ug=>{"use strict";Object.defineProperty(Ug,"__esModule",{value:!0});Ug.createEdgeId=V8;Ug.edgesEqual=G8;function V8(r,e,t,n){let i=n?`|${n}`:"";return`${r}->${e}:${t}${i}`}a(V8,"createEdgeId");function G8(r,e){return r.source===e.source&&r.target===e.target&&r.type===e.type&&r.predicate===e.predicate}a(G8,"edgesEqual")});var DE=v(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.BUILT_IN_EDGE_STYLES=ur.BUILT_IN_NODE_STYLES=ur.DEFAULT_EDGE_STYLE=ur.DEFAULT_NODE_STYLE=ur.RDF_TYPE_PREDICATES=void 0;ur.mergeNodeStyles=q8;ur.mergeEdgeStyles=W8;ur.extractLocalName=H8;ur.isClassType=z8;ur.isTypePredicate=K8;ur.isSubClassPredicate=Y8;ur.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"};ur.DEFAULT_NODE_STYLE={color:"#6366f1",borderColor:"#4f46e5",borderWidth:2,size:30,shape:"circle",icon:"",opacity:1,shadow:!1,animation:"none"};ur.DEFAULT_EDGE_STYLE={color:"#9ca3af",width:1,lineStyle:"solid",arrow:"standard",curvature:0,opacity:.6,showLabel:!1,labelPosition:.5};ur.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"},person__Person:{color:"#06b6d4",shape:"circle"},ims__Person:{color:"#06b6d4",shape:"circle"}};ur.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 q8(r,e){return{...r,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(q8,"mergeNodeStyles");function W8(r,e){return{...r,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(W8,"mergeEdgeStyles");function H8(r){let e=r.lastIndexOf("#"),t=r.lastIndexOf("/"),n=Math.max(e,t);return n>=0?r.substring(n+1):r}a(H8,"extractLocalName");function z8(r){return r===ur.RDF_TYPE_PREDICATES.RDFS_CLASS||r===ur.RDF_TYPE_PREDICATES.OWL_CLASS}a(z8,"isClassType");function K8(r){return r===ur.RDF_TYPE_PREDICATES.RDF_TYPE}a(K8,"isTypePredicate");function Y8(r){return r===ur.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF}a(Y8,"isSubClassPredicate")});var o3=v(s3=>{"use strict";Object.defineProperty(s3,"__esModule",{value:!0})});var $e=v(Bg=>{"use strict";Object.defineProperty(Bg,"__esModule",{value:!0});Bg.IRI=void 0;var FE=class r{static{a(this,"IRI")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("IRI cannot be empty");if(!r.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 n=["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(!n.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)}}};Bg.IRI=FE});var Qe=v(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});il.Literal=void 0;il.parseLanguageTag=a3;il.createDirectionalLiteral=X8;il.createLiteralFromLanguageTag=J8;var Q8="http://www.w3.org/2001/XMLSchema#string",Sp=class{static{a(this,"Literal")}constructor(e,t,n,i){if(e.length===0)throw new Error("Literal value cannot be empty");if(t&&n)throw new Error("Literal cannot have both datatype and language tag");if(i&&!n)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=n?n.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(),n=e.normalizedDatatype();return t===n}normalizedDatatype(){return!this._datatype||this._datatype.value===Q8?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}};il.Literal=Sp;function a3(r){let t=r.lastIndexOf("--");if(t===-1)return{language:r.toLowerCase()};let n=r.substring(t+2),i=r.substring(0,t);return n==="ltr"||n==="rtl"?{language:i.toLowerCase(),direction:n}:{language:r.toLowerCase()}}a(a3,"parseLanguageTag");function X8(r,e,t){return new Sp(r,void 0,e,t)}a(X8,"createDirectionalLiteral");function J8(r,e){let{language:t,direction:n}=a3(e);return new Sp(r,void 0,t,n)}a(J8,"createLiteralFromLanguageTag")});var nr=v(Gg=>{"use strict";Object.defineProperty(Gg,"__esModule",{value:!0});Gg.BlankNode=void 0;var Vg=class r{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${++r.counter}`}static create(){return new r(r.generateId())}};Gg.BlankNode=Vg;Vg.counter=0});var Qt=v(qg=>{"use strict";Object.defineProperty(qg,"__esModule",{value:!0});qg.Namespace=void 0;var c3=$e(),He=class r{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 c3.IRI(t)}get prefix(){return this._prefix}get iri(){return this._iri}term(e){return new c3.IRI(`${this._iri.value}${e}`)}expand(e){let t=e.split(":");if(t.length!==2)return null;let[n,i]=t;return n!==this._prefix?null:this.term(i)}static forPrefix(e){if(!/^[a-z][a-zA-Z0-9]*$/.test(e))return null;let t=r.KNOWN_NAMESPACES.find(n=>n.prefix===e);return t||new r(e,`${r.EXOCORTEX_ONTOLOGY_BASE}${e}#`)}static fromPropertyKey(e){let t=/^([a-z][a-zA-Z0-9]*)__(.+)$/.exec(e);if(!t)return null;let n=r.forPrefix(t[1]);return n?{namespace:n,localName:t[2]}:null}static fromTermIRI(e){if(typeof e!="string"||e.length===0)return null;let t=a(l=>l.length>0&&!l.includes("#")&&!l.includes("/")?l:null,"cleanLocal");for(let l of r.KNOWN_NAMESPACES){let u=l.iri.value;if(e.startsWith(u)){let f=t(e.slice(u.length));return f===null?null:{namespace:l,localName:f}}}if(!e.startsWith(r.EXOCORTEX_ONTOLOGY_BASE))return null;let n=e.slice(r.EXOCORTEX_ONTOLOGY_BASE.length),i=n.indexOf("#");if(i<=0)return null;let s=n.slice(0,i);if(!/^[a-z][a-zA-Z0-9]*$/.test(s))return null;let o=t(n.slice(i+1));if(o===null)return null;let c=r.forPrefix(s);return c?{namespace:c,localName:o}:null}static knownNamespaces(){return r.KNOWN_NAMESPACES}};qg.Namespace=He;He.RDF=new He("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");He.RDFS=new He("rdfs","http://www.w3.org/2000/01/rdf-schema#");He.OWL=new He("owl","http://www.w3.org/2002/07/owl#");He.XSD=new He("xsd","http://www.w3.org/2001/XMLSchema#");He.SHACL=new He("sh","http://www.w3.org/ns/shacl#");He.EXO=new He("exo","https://exocortex.my/ontology/exo#");He.EMS=new He("ems","https://exocortex.my/ontology/ems#");He.EXOCMD=new He("exocmd","https://exocortex.my/ontology/exocmd#");He.IMS=new He("ims","https://exocortex.my/ontology/ims#");He.ZTLK=new He("ztlk","https://exocortex.my/ontology/ztlk#");He.PTMS=new He("ptms","https://exocortex.my/ontology/ptms#");He.LIT=new He("lit","https://exocortex.my/ontology/lit#");He.INBOX=new He("inbox","https://exocortex.my/ontology/inbox#");He.PMBOK=new He("pmbok","https://exocortex.my/ontology/pmbok#");He.EXOCORTEX_ONTOLOGY_BASE="https://exocortex.my/ontology/";He.KNOWN_NAMESPACES=[He.EXO,He.EMS,He.EXOCMD,He.IMS,He.ZTLK,He.PTMS,He.LIT,He.INBOX,He.PMBOK,He.RDF,He.RDFS,He.OWL,He.XSD,He.SHACL]});var gi=v(Wg=>{"use strict";Object.defineProperty(Wg,"__esModule",{value:!0});Wg.Triple=void 0;var LE=$e(),NE=Qe(),kE=nr(),ME=class{static{a(this,"Triple")}constructor(e,t,n){this._subject=e,this._predicate=t,this._object=n}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 LE.IRI&&t instanceof LE.IRI||e instanceof kE.BlankNode&&t instanceof kE.BlankNode||e instanceof NE.Literal&&t instanceof NE.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}>`,n=this.nodeToString(this._object);return`${e} ${t} ${n} .`}nodeToString(e){return e instanceof LE.IRI?`<${e.value}>`:e instanceof kE.BlankNode||e instanceof NE.Literal||this.isQuotedTriple(e)?e.toString():""}};Wg.Triple=ME});var wp=v(Hg=>{"use strict";Object.defineProperty(Hg,"__esModule",{value:!0});Hg.QuotedTriple=void 0;var jE=$e(),$E=Qe(),UE=nr(),BE=class r{static{a(this,"QuotedTriple")}constructor(e,t,n){this._subject=e,this._predicate=t,this._object=n}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 jE.IRI&&t instanceof jE.IRI||e instanceof UE.BlankNode&&t instanceof UE.BlankNode||e instanceof $E.Literal&&t instanceof $E.Literal||e instanceof r&&t instanceof r?e.equals(t):!1}get termType(){return"QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,n=this.nodeToString(this._object);return`<< ${e} ${t} ${n} >>`}nodeToString(e){return e instanceof jE.IRI?`<${e.value}>`:e instanceof UE.BlankNode||e instanceof $E.Literal||e instanceof r?e.toString():""}};Hg.QuotedTriple=BE});var l3=v(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.QuotedTriple=Rr.Triple=Rr.Namespace=Rr.BlankNode=Rr.createLiteralFromLanguageTag=Rr.createDirectionalLiteral=Rr.parseLanguageTag=Rr.Literal=Rr.IRI=void 0;var Z8=$e();Object.defineProperty(Rr,"IRI",{enumerable:!0,get:a(function(){return Z8.IRI},"get")});var zg=Qe();Object.defineProperty(Rr,"Literal",{enumerable:!0,get:a(function(){return zg.Literal},"get")});Object.defineProperty(Rr,"parseLanguageTag",{enumerable:!0,get:a(function(){return zg.parseLanguageTag},"get")});Object.defineProperty(Rr,"createDirectionalLiteral",{enumerable:!0,get:a(function(){return zg.createDirectionalLiteral},"get")});Object.defineProperty(Rr,"createLiteralFromLanguageTag",{enumerable:!0,get:a(function(){return zg.createLiteralFromLanguageTag},"get")});var eV=nr();Object.defineProperty(Rr,"BlankNode",{enumerable:!0,get:a(function(){return eV.BlankNode},"get")});var tV=Qt();Object.defineProperty(Rr,"Namespace",{enumerable:!0,get:a(function(){return tV.Namespace},"get")});var rV=gi();Object.defineProperty(Rr,"Triple",{enumerable:!0,get:a(function(){return rV.Triple},"get")});var nV=wp();Object.defineProperty(Rr,"QuotedTriple",{enumerable:!0,get:a(function(){return nV.QuotedTriple},"get")})});var Kg=v(Ji=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0});Ji.UUID_URL_NAMESPACE=Ji.DEFAULT_LANGUAGE_TAG=Ji.REQUIRED_PROPERTIES=Ji.ALLOWED_PROPERTIES=Ji.Exo003MetadataType=void 0;var Xi;(function(r){r.Namespace="namespace",r.Anchor="anchor",r.BlankNode="blank_node",r.Statement="statement",r.Body="body"})(Xi||(Ji.Exo003MetadataType=Xi={}));Ji.ALLOWED_PROPERTIES={[Xi.Namespace]:["metadata","uri","aliases"],[Xi.Anchor]:["metadata","uri","aliases"],[Xi.BlankNode]:["metadata","uri","aliases"],[Xi.Statement]:["metadata","subject","predicate","object","aliases"],[Xi.Body]:["metadata","subject","predicate","aliases"]};Ji.REQUIRED_PROPERTIES={[Xi.Namespace]:["metadata","uri"],[Xi.Anchor]:["metadata","uri"],[Xi.BlankNode]:["metadata","uri"],[Xi.Statement]:["metadata","subject","predicate","object"],[Xi.Body]:["metadata","subject","predicate"]};Ji.DEFAULT_LANGUAGE_TAG="ru";Ji.UUID_URL_NAMESPACE="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});var u3=v(VE=>{"use strict";Object.defineProperty(VE,"__esModule",{value:!0});VE.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var f3=v(GE=>{"use strict";Object.defineProperty(GE,"__esModule",{value:!0});GE.default="00000000-0000-0000-0000-000000000000"});var d3=v(qE=>{"use strict";Object.defineProperty(qE,"__esModule",{value:!0});qE.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 Ep=v(WE=>{"use strict";Object.defineProperty(WE,"__esModule",{value:!0});var iV=d3();function sV(r){return typeof r=="string"&&iV.default.test(r)}a(sV,"validate");WE.default=sV});var vp=v(HE=>{"use strict";Object.defineProperty(HE,"__esModule",{value:!0});var oV=Ep();function aV(r){if(!(0,oV.default)(r))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(r.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(r.slice(9,13),16))>>>8,e&255,(e=parseInt(r.slice(14,18),16))>>>8,e&255,(e=parseInt(r.slice(19,23),16))>>>8,e&255,(e=parseInt(r.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}a(aV,"parse");HE.default=aV});var Vo=v(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});Tp.unsafeStringify=void 0;var cV=Ep(),fn=[];for(let r=0;r<256;++r)fn.push((r+256).toString(16).slice(1));function p3(r,e=0){return(fn[r[e+0]]+fn[r[e+1]]+fn[r[e+2]]+fn[r[e+3]]+"-"+fn[r[e+4]]+fn[r[e+5]]+"-"+fn[r[e+6]]+fn[r[e+7]]+"-"+fn[r[e+8]]+fn[r[e+9]]+"-"+fn[r[e+10]]+fn[r[e+11]]+fn[r[e+12]]+fn[r[e+13]]+fn[r[e+14]]+fn[r[e+15]]).toLowerCase()}a(p3,"unsafeStringify");Tp.unsafeStringify=p3;function lV(r,e=0){let t=p3(r,e);if(!(0,cV.default)(t))throw TypeError("Stringified UUID is invalid");return t}a(lV,"stringify");Tp.default=lV});var Xg=v(zE=>{"use strict";Object.defineProperty(zE,"__esModule",{value:!0});var uV=require("crypto"),Qg=new Uint8Array(256),Yg=Qg.length;function fV(){return Yg>Qg.length-16&&((0,uV.randomFillSync)(Qg),Yg=0),Qg.slice(Yg,Yg+=16)}a(fV,"rng");zE.default=fV});var KE=v(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});Ip.updateV1State=void 0;var h3=Xg(),dV=Vo(),Ap={};function pV(r,e,t){let n,i=r?._v6??!1;if(r){let s=Object.keys(r);s.length===1&&s[0]==="_v6"&&(r=void 0)}if(r)n=m3(r.random??r.rng?.()??(0,h3.default)(),r.msecs,r.nsecs,r.clockseq,r.node,e,t);else{let s=Date.now(),o=(0,h3.default)();g3(Ap,s,o),n=m3(o,Ap.msecs,Ap.nsecs,i?void 0:Ap.clockseq,i?void 0:Ap.node,e,t)}return e??(0,dV.unsafeStringify)(n)}a(pV,"v1");function g3(r,e,t){return r.msecs??=-1/0,r.nsecs??=0,e===r.msecs?(r.nsecs++,r.nsecs>=1e4&&(r.node=void 0,r.nsecs=0)):e>r.msecs?r.nsecs=0:e<r.msecs&&(r.node=void 0),r.node||(r.node=t.slice(10,16),r.node[0]|=1,r.clockseq=(t[8]<<8|t[9])&16383),r.msecs=e,r}a(g3,"updateV1State");Ip.updateV1State=g3;function m3(r,e,t,n,i,s,o=0){if(r.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,n??=(r[8]<<8|r[9])&16383,i??=r.slice(10,16),e+=122192928e5;let c=((e&268435455)*1e4+t)%4294967296;s[o++]=c>>>24&255,s[o++]=c>>>16&255,s[o++]=c>>>8&255,s[o++]=c&255;let l=e/4294967296*1e4&268435455;s[o++]=l>>>8&255,s[o++]=l&255,s[o++]=l>>>24&15|16,s[o++]=l>>>16&255,s[o++]=n>>>8|128,s[o++]=n&255;for(let u=0;u<6;++u)s[o++]=i[u];return s}a(m3,"v1Bytes");Ip.default=pV});var QE=v(YE=>{"use strict";Object.defineProperty(YE,"__esModule",{value:!0});var hV=vp(),mV=Vo();function gV(r){let e=typeof r=="string"?(0,hV.default)(r):r,t=yV(e);return typeof r=="string"?(0,mV.unsafeStringify)(t):t}a(gV,"v1ToV6");YE.default=gV;function yV(r){return Uint8Array.of((r[6]&15)<<4|r[7]>>4&15,(r[7]&15)<<4|(r[4]&240)>>4,(r[4]&15)<<4|(r[5]&240)>>4,(r[5]&15)<<4|(r[0]&240)>>4,(r[0]&15)<<4|(r[1]&240)>>4,(r[1]&15)<<4|(r[2]&240)>>4,96|r[2]&15,r[3],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15])}a(yV,"_v1ToV6")});var y3=v(XE=>{"use strict";Object.defineProperty(XE,"__esModule",{value:!0});var _V=require("crypto");function bV(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),(0,_V.createHash)("md5").update(r).digest()}a(bV,"md5");XE.default=bV});var Rp=v(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.URL=Go.DNS=Go.stringToBytes=void 0;var _3=vp(),SV=Vo();function b3(r){r=unescape(encodeURIComponent(r));let e=new Uint8Array(r.length);for(let t=0;t<r.length;++t)e[t]=r.charCodeAt(t);return e}a(b3,"stringToBytes");Go.stringToBytes=b3;Go.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Go.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function wV(r,e,t,n,i,s){let o=typeof t=="string"?b3(t):t,c=typeof n=="string"?(0,_3.default)(n):n;if(typeof n=="string"&&(n=(0,_3.default)(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+o.length);if(l.set(c),l.set(o,c.length),l=e(l),l[6]=l[6]&15|r,l[8]=l[8]&63|128,i){if(s=s||0,s<0||s+16>i.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`);for(let u=0;u<16;++u)i[s+u]=l[u];return i}return(0,SV.unsafeStringify)(l)}a(wV,"v35");Go.default=wV});var w3=v(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});sl.URL=sl.DNS=void 0;var EV=y3(),JE=Rp(),S3=Rp();Object.defineProperty(sl,"DNS",{enumerable:!0,get:a(function(){return S3.DNS},"get")});Object.defineProperty(sl,"URL",{enumerable:!0,get:a(function(){return S3.URL},"get")});function ZE(r,e,t,n){return(0,JE.default)(48,EV.default,r,e,t,n)}a(ZE,"v3");ZE.DNS=JE.DNS;ZE.URL=JE.URL;sl.default=ZE});var E3=v(ev=>{"use strict";Object.defineProperty(ev,"__esModule",{value:!0});var vV=require("crypto");ev.default={randomUUID:vV.randomUUID}});var T3=v(tv=>{"use strict";Object.defineProperty(tv,"__esModule",{value:!0});var v3=E3(),TV=Xg(),AV=Vo();function IV(r,e,t){if(v3.default.randomUUID&&!e&&!r)return v3.default.randomUUID();r=r||{};let n=r.random??r.rng?.()??(0,TV.default)();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[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]=n[i];return e}return(0,AV.unsafeStringify)(n)}a(IV,"v4");tv.default=IV});var A3=v(rv=>{"use strict";Object.defineProperty(rv,"__esModule",{value:!0});var RV=require("crypto");function CV(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),(0,RV.createHash)("sha1").update(r).digest()}a(CV,"sha1");rv.default=CV});var R3=v(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.URL=ol.DNS=void 0;var xV=A3(),nv=Rp(),I3=Rp();Object.defineProperty(ol,"DNS",{enumerable:!0,get:a(function(){return I3.DNS},"get")});Object.defineProperty(ol,"URL",{enumerable:!0,get:a(function(){return I3.URL},"get")});function iv(r,e,t,n){return(0,nv.default)(80,xV.default,r,e,t,n)}a(iv,"v5");iv.DNS=nv.DNS;iv.URL=nv.URL;ol.default=iv});var C3=v(sv=>{"use strict";Object.defineProperty(sv,"__esModule",{value:!0});var OV=Vo(),PV=KE(),DV=QE();function FV(r,e,t){r??={},t??=0;let n=(0,PV.default)({...r,_v6:!0},new Uint8Array(16));if(n=(0,DV.default)(n),e){if(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]=n[i];return e}return(0,OV.unsafeStringify)(n)}a(FV,"v6");sv.default=FV});var x3=v(ov=>{"use strict";Object.defineProperty(ov,"__esModule",{value:!0});var LV=vp(),NV=Vo();function kV(r){let e=typeof r=="string"?(0,LV.default)(r):r,t=MV(e);return typeof r=="string"?(0,NV.unsafeStringify)(t):t}a(kV,"v6ToV1");ov.default=kV;function MV(r){return Uint8Array.of((r[3]&15)<<4|r[4]>>4&15,(r[4]&15)<<4|(r[5]&240)>>4,(r[5]&15)<<4|r[6]&15,r[7],(r[1]&15)<<4|(r[2]&240)>>4,(r[2]&15)<<4|(r[3]&240)>>4,16|(r[0]&240)>>4,(r[0]&15)<<4|(r[1]&240)>>4,r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15])}a(MV,"_v6ToV1")});var F3=v(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.updateV7State=void 0;var O3=Xg(),jV=Vo(),av={};function $V(r,e,t){let n;if(r)n=P3(r.random??r.rng?.()??(0,O3.default)(),r.msecs,r.seq,e,t);else{let i=Date.now(),s=(0,O3.default)();D3(av,i,s),n=P3(s,av.msecs,av.seq,e,t)}return e??(0,jV.unsafeStringify)(n)}a($V,"v7");function D3(r,e,t){return r.msecs??=-1/0,r.seq??=0,e>r.msecs?(r.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],r.msecs=e):(r.seq=r.seq+1|0,r.seq===0&&r.msecs++),r}a(D3,"updateV7State");Cp.updateV7State=D3;function P3(r,e,t,n,i=0){if(r.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return e??=Date.now(),t??=r[6]*127<<24|r[7]<<16|r[8]<<8|r[9],n[i++]=e/1099511627776&255,n[i++]=e/4294967296&255,n[i++]=e/16777216&255,n[i++]=e/65536&255,n[i++]=e/256&255,n[i++]=e&255,n[i++]=112|t>>>28&15,n[i++]=t>>>20&255,n[i++]=128|t>>>14&63,n[i++]=t>>>6&255,n[i++]=t<<2&255|r[10]&3,n[i++]=r[11],n[i++]=r[12],n[i++]=r[13],n[i++]=r[14],n[i++]=r[15],n}a(P3,"v7Bytes");Cp.default=$V});var L3=v(cv=>{"use strict";Object.defineProperty(cv,"__esModule",{value:!0});var UV=Ep();function BV(r){if(!(0,UV.default)(r))throw TypeError("Invalid UUID");return parseInt(r.slice(14,15),16)}a(BV,"version");cv.default=BV});var al=v(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.version=Ct.validate=Ct.v7=Ct.v6ToV1=Ct.v6=Ct.v5=Ct.v4=Ct.v3=Ct.v1ToV6=Ct.v1=Ct.stringify=Ct.parse=Ct.NIL=Ct.MAX=void 0;var VV=u3();Object.defineProperty(Ct,"MAX",{enumerable:!0,get:a(function(){return VV.default},"get")});var GV=f3();Object.defineProperty(Ct,"NIL",{enumerable:!0,get:a(function(){return GV.default},"get")});var qV=vp();Object.defineProperty(Ct,"parse",{enumerable:!0,get:a(function(){return qV.default},"get")});var WV=Vo();Object.defineProperty(Ct,"stringify",{enumerable:!0,get:a(function(){return WV.default},"get")});var HV=KE();Object.defineProperty(Ct,"v1",{enumerable:!0,get:a(function(){return HV.default},"get")});var zV=QE();Object.defineProperty(Ct,"v1ToV6",{enumerable:!0,get:a(function(){return zV.default},"get")});var KV=w3();Object.defineProperty(Ct,"v3",{enumerable:!0,get:a(function(){return KV.default},"get")});var YV=T3();Object.defineProperty(Ct,"v4",{enumerable:!0,get:a(function(){return YV.default},"get")});var QV=R3();Object.defineProperty(Ct,"v5",{enumerable:!0,get:a(function(){return QV.default},"get")});var XV=C3();Object.defineProperty(Ct,"v6",{enumerable:!0,get:a(function(){return XV.default},"get")});var JV=x3();Object.defineProperty(Ct,"v6ToV1",{enumerable:!0,get:a(function(){return JV.default},"get")});var ZV=F3();Object.defineProperty(Ct,"v7",{enumerable:!0,get:a(function(){return ZV.default},"get")});var eG=Ep();Object.defineProperty(Ct,"validate",{enumerable:!0,get:a(function(){return eG.default},"get")});var tG=L3();Object.defineProperty(Ct,"version",{enumerable:!0,get:a(function(){return tG.default},"get")})});var fv=v(Jg=>{"use strict";Object.defineProperty(Jg,"__esModule",{value:!0});Jg.Exo003UUIDGenerator=void 0;var lv=al(),N3=Kg(),uv=class{static{a(this,"Exo003UUIDGenerator")}static generateNamespaceUUID(e){if(!e||e.trim().length===0)throw new Error("Namespace URI cannot be empty");return(0,lv.v5)(e,N3.UUID_URL_NAMESPACE)}static generateAssetUUID(e,t){if(!t||t.trim().length===0)throw new Error("Local identifier cannot be empty");let n=this.generateNamespaceUUID(e);return(0,lv.v5)(t,n)}static generateFromIRI(e){if(!e||e.trim().length===0)throw new Error("IRI cannot be empty");let{namespace:t,localName:n}=this.splitIRI(e);return n?this.generateAssetUUID(t,n):(0,lv.v5)(e,N3.UUID_URL_NAMESPACE)}static generateBlankNodeUUID(e,t){if(!e||e.trim().length===0)throw new Error("Blank node ID cannot be empty");let n="urn:exocortex:blank-node:",i=t?`${t}#${e}`:e;return this.generateAssetUUID(n,i)}static generateStatementUUID(e,t,n){if(!e||!t||!n)throw new Error("Subject, predicate, and object cannot be empty");let i="urn:exocortex:statement:",s=`${e} ${t} ${n}`;return this.generateAssetUUID(i,s)}static generateBodyUUID(e,t){let n="urn:exocortex:body:",i=e;return t?.datatype?i+=`^^${t.datatype}`:t?.language&&(i+=`@${t.language}`,t.direction&&(i+=`--${t.direction}`)),this.generateAssetUUID(n,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 n=e.lastIndexOf("/"),i=e.indexOf("://");return n!==-1&&n>i+2&&n<e.length-1?{namespace:e.substring(0,n+1),localName:e.substring(n+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)}};Jg.Exo003UUIDGenerator=uv});var M3=v(ey=>{"use strict";Object.defineProperty(ey,"__esModule",{value:!0});ey.Exo003Parser=void 0;var Nt=Kg(),xp=fv(),Ya=$e(),Zg=Qe(),k3=nr(),rG=gi(),dv=class{static{a(this,"Exo003Parser")}static parse(e,t){let n=this.validate(e);if(!n.valid)return{success:!1,errors:n.errors};let i=e.metadata;try{return{success:!0,metadata:this.parseByType(e,i),bodyContent:i===Nt.Exo003MetadataType.Body?t:void 0}}catch(s){return{success:!1,errors:[s instanceof Error?s.message:String(s)]}}}static validate(e){let t=[],n=[];if(!e.metadata)return t.push("Missing required property: metadata"),{valid:!1,errors:t,warnings:n};let i=e.metadata;if(!Object.values(Nt.Exo003MetadataType).includes(i))return t.push(`Invalid metadata: ${i}. Valid types: ${Object.values(Nt.Exo003MetadataType).join(", ")}`),{valid:!1,errors:t,warnings:n};let s=i,o=Nt.ALLOWED_PROPERTIES[s],c=Nt.REQUIRED_PROPERTIES[s];for(let l of c)(e[l]===void 0||e[l]===null)&&t.push(`Missing required property: ${l}`);for(let l of Object.keys(e))o.includes(l)||t.push(`Forbidden property for ${s}: ${l}`);switch(s){case Nt.Exo003MetadataType.Namespace:this.validateNamespaceMetadata(e,t);break;case Nt.Exo003MetadataType.Anchor:this.validateAnchorMetadata(e,t);break;case Nt.Exo003MetadataType.BlankNode:this.validateBlankNodeMetadata(e,t);break;case Nt.Exo003MetadataType.Statement:this.validateStatementMetadata(e,t);break;case Nt.Exo003MetadataType.Body:this.validateBodyMetadata(e,t,n);break}return{valid:t.length===0,errors:t,warnings:n}}static parseByType(e,t){let n={metadata:t,aliases:e.aliases};switch(t){case Nt.Exo003MetadataType.Namespace:return{...n,metadata:Nt.Exo003MetadataType.Namespace,uri:e.uri};case Nt.Exo003MetadataType.Anchor:return{...n,metadata:Nt.Exo003MetadataType.Anchor,uri:e.uri};case Nt.Exo003MetadataType.BlankNode:return{...n,metadata:Nt.Exo003MetadataType.BlankNode,uri:e.uri};case Nt.Exo003MetadataType.Statement:return{...n,metadata:Nt.Exo003MetadataType.Statement,subject:e.subject,predicate:e.predicate,object:e.object};case Nt.Exo003MetadataType.Body:return{...n,metadata:Nt.Exo003MetadataType.Body,subject:e.subject,predicate:e.predicate}}}static validateNamespaceMetadata(e,t){let n=e.uri;if(n&&typeof n!="string")t.push("uri must be a string");else if(n)try{new Ya.IRI(n)}catch{t.push(`uri is not a valid IRI: ${String(n)}`)}}static validateAnchorMetadata(e,t){let n=e.uri;if(n&&typeof n!="string")t.push("uri must be a string");else if(n)try{new Ya.IRI(n)}catch{t.push(`uri is not a valid IRI: ${String(n)}`)}}static validateBlankNodeMetadata(e,t){let n=e.uri;if(n&&typeof n!="string")t.push("uri must be a string");else if(n){let i=n;if(!i.startsWith("_:"))try{new Ya.IRI(i)}catch{t.push(`uri is not a valid IRI or blank node identifier: ${String(n)}`)}}}static validateStatementMetadata(e,t){let n=e.subject,i=e.predicate,s=e.object,o=[["subject",n],["predicate",i],["object",s]];for(let[c,l]of o)l&&typeof l!="string"&&t.push(`${c} must be a string`)}static validateBodyMetadata(e,t,n){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,n){let i=t(e.subject),s;if(i.type==="iri")s=new Ya.IRI(i.value);else if(i.type==="blank")s=new k3.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 c=new Ya.IRI(o.value),l=t(e.object),u;if(l.type==="iri")u=new Ya.IRI(l.value);else if(l.type==="blank")u=new k3.BlankNode(l.value);else{let f=n||l.value;if(l.datatype)u=new Zg.Literal(f,new Ya.IRI(l.datatype));else{let d=l.language||Nt.DEFAULT_LANGUAGE_TAG;u=(0,Zg.createDirectionalLiteral)(f,d,l.direction)}}return new rG.Triple(s,c,u)}static toLiteral(e,t,n){if(n?.datatype)return new Zg.Literal(t,new Ya.IRI(n.datatype));let i=n?.language||Nt.DEFAULT_LANGUAGE_TAG;return(0,Zg.createDirectionalLiteral)(t,i,n?.direction)}static isExo003Format(e){let t=e.metadata;return typeof t=="string"&&Object.values(Nt.Exo003MetadataType).includes(t)}static generateUUID(e,t){switch(e.metadata){case Nt.Exo003MetadataType.Namespace:return xp.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Nt.Exo003MetadataType.Anchor:return xp.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Nt.Exo003MetadataType.BlankNode:return xp.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Nt.Exo003MetadataType.Statement:{let n=e;return xp.Exo003UUIDGenerator.generateStatementUUID(n.subject,n.predicate,n.object)}case Nt.Exo003MetadataType.Body:{let n=e;return xp.Exo003UUIDGenerator.generateBodyUUID(n.subject+"|"+n.predicate)}}}};ey.Exo003Parser=dv});var pv=v(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.Exo003Parser=In.Exo003UUIDGenerator=In.UUID_URL_NAMESPACE=In.DEFAULT_LANGUAGE_TAG=In.REQUIRED_PROPERTIES=In.ALLOWED_PROPERTIES=In.Exo003MetadataType=void 0;var Op=Kg();Object.defineProperty(In,"Exo003MetadataType",{enumerable:!0,get:a(function(){return Op.Exo003MetadataType},"get")});Object.defineProperty(In,"ALLOWED_PROPERTIES",{enumerable:!0,get:a(function(){return Op.ALLOWED_PROPERTIES},"get")});Object.defineProperty(In,"REQUIRED_PROPERTIES",{enumerable:!0,get:a(function(){return Op.REQUIRED_PROPERTIES},"get")});Object.defineProperty(In,"DEFAULT_LANGUAGE_TAG",{enumerable:!0,get:a(function(){return Op.DEFAULT_LANGUAGE_TAG},"get")});Object.defineProperty(In,"UUID_URL_NAMESPACE",{enumerable:!0,get:a(function(){return Op.UUID_URL_NAMESPACE},"get")});var nG=fv();Object.defineProperty(In,"Exo003UUIDGenerator",{enumerable:!0,get:a(function(){return nG.Exo003UUIDGenerator},"get")});var iG=M3();Object.defineProperty(In,"Exo003Parser",{enumerable:!0,get:a(function(){return iG.Exo003Parser},"get")})});var no=v(ty=>{"use strict";Object.defineProperty(ty,"__esModule",{value:!0});ty.WikiLinkHelpers=void 0;var Pp=class{static{a(this,"WikiLinkHelpers")}static normalize(e){if(!e)return"";let t=e.replace(this.WIKI_LINK_PATTERN,"").trim();if(!t)return"";let n=t.indexOf("|");if(n===-1)return t;let i=t.substring(0,n).trim(),s=t.substring(n+1).trim();return this.UUID_PATTERN.test(i)&&s||i}static normalizeArray(e){return e?(Array.isArray(e)?e:[e]).map(n=>this.normalize(n)).filter(n=>n.length>0):[]}static equals(e,t){return this.normalize(e)===this.normalize(t)}static includes(e,t){let n=this.normalizeArray(e),i=this.normalize(t);return n.includes(i)}static resolveSymbolic(e,t){let n=this.normalize(e);if(!n)return"";if(this.UUID_PATTERN.test(n)){let i=t(n);return i&&i.length>0?i:n}return n}static resolveSymbolicArray(e,t){return e?(Array.isArray(e)?e:[e]).map(i=>this.resolveSymbolic(i,t)).filter(i=>i.length>0):[]}};ty.WikiLinkHelpers=Pp;Pp.WIKI_LINK_PATTERN=/\[\[|\]\]/g;Pp.UUID_PATTERN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});var Fp=v(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.CommandBindingProperty=ut.GroundingProperty=ut.PreconditionProperty=ut.CommandProperty=ut.resolveGroundingTypeFromWikilinkLiteral=ut.resolveGroundingTypeFromIRI=ut.GROUNDING_TYPE_IRI_TO_ENUM=ut.GROUNDING_TYPE_UID_TO_ENUM=ut.GROUNDING_TYPE_UIDS=ut.GroundingType=ut.EFFORT_STATUS_OPTIONS=ut.normalizeEffortStatus=ut.EFFORT_STATUS_BY_UID=ut.EFFORT_STATUS_UID=ut.EffortStatus=ut.AssetClass=void 0;var sG=rl();Object.defineProperty(ut,"AssetClass",{enumerable:!0,get:a(function(){return sG.AssetClass},"get")});var oG=nl();Object.defineProperty(ut,"EffortStatus",{enumerable:!0,get:a(function(){return oG.EffortStatus},"get")});var hv=Ou();Object.defineProperty(ut,"EFFORT_STATUS_UID",{enumerable:!0,get:a(function(){return hv.EFFORT_STATUS_UID},"get")});Object.defineProperty(ut,"EFFORT_STATUS_BY_UID",{enumerable:!0,get:a(function(){return hv.EFFORT_STATUS_BY_UID},"get")});Object.defineProperty(ut,"normalizeEffortStatus",{enumerable:!0,get:a(function(){return hv.normalizeEffortStatus},"get")});var aG=RE();Object.defineProperty(ut,"EFFORT_STATUS_OPTIONS",{enumerable:!0,get:a(function(){return aG.EFFORT_STATUS_OPTIONS},"get")});var cG=Ka();Object.defineProperty(ut,"GroundingType",{enumerable:!0,get:a(function(){return cG.GroundingType},"get")});var Dp=bp();Object.defineProperty(ut,"GROUNDING_TYPE_UIDS",{enumerable:!0,get:a(function(){return Dp.GROUNDING_TYPE_UIDS},"get")});Object.defineProperty(ut,"GROUNDING_TYPE_UID_TO_ENUM",{enumerable:!0,get:a(function(){return Dp.GROUNDING_TYPE_UID_TO_ENUM},"get")});Object.defineProperty(ut,"GROUNDING_TYPE_IRI_TO_ENUM",{enumerable:!0,get:a(function(){return Dp.GROUNDING_TYPE_IRI_TO_ENUM},"get")});Object.defineProperty(ut,"resolveGroundingTypeFromIRI",{enumerable:!0,get:a(function(){return Dp.resolveGroundingTypeFromIRI},"get")});Object.defineProperty(ut,"resolveGroundingTypeFromWikilinkLiteral",{enumerable:!0,get:a(function(){return Dp.resolveGroundingTypeFromWikilinkLiteral},"get")});var ry=CE();Object.defineProperty(ut,"CommandProperty",{enumerable:!0,get:a(function(){return ry.CommandProperty},"get")});Object.defineProperty(ut,"PreconditionProperty",{enumerable:!0,get:a(function(){return ry.PreconditionProperty},"get")});Object.defineProperty(ut,"GroundingProperty",{enumerable:!0,get:a(function(){return ry.GroundingProperty},"get")});Object.defineProperty(ut,"CommandBindingProperty",{enumerable:!0,get:a(function(){return ry.CommandBindingProperty},"get")})});var B3=v(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.hasClass=ll;Rn.isAreaOrProject=lG;Rn.isEffort=uG;Rn.hasStatus=fG;Rn.isAssetArchived=dG;Rn.hasEmptyProperties=pG;Rn.needsFolderRepair=hG;Rn.getTodayDateString=mv;Rn.isPlannedForToday=mG;Rn.hasPlannedStartTimestamp=gG;Rn.extractDailyNoteDate=yG;Rn.isCurrentDateGteDay=_G;Rn.inheritsFromPrototype=U3;Rn.isPrototypeClass=SG;var $3=no(),cl=Fp();function ll(r,e){return r?(Array.isArray(r)?r:[r]).some(n=>$3.WikiLinkHelpers.normalize(n)===e):!1}a(ll,"hasClass");function lG(r){return ll(r,cl.AssetClass.AREA)||ll(r,cl.AssetClass.PROJECT)}a(lG,"isAreaOrProject");function uG(r){return ll(r,cl.AssetClass.TASK)||ll(r,cl.AssetClass.PROJECT)||ll(r,cl.AssetClass.MEETING)}a(uG,"isEffort");function fG(r,e){if(!r)return!1;let t=Array.isArray(r)?r[0]:r;return t?$3.WikiLinkHelpers.normalize(t)===e:!1}a(fG,"hasStatus");function dG(r){if(r===!0||r===1)return!0;if(typeof r=="string"){let e=r.toLowerCase();return e==="true"||e==="yes"}return!1}a(dG,"isAssetArchived");function pG(r){if(!r||Object.keys(r).length===0)return!1;let e=a(t=>t==null||t==="","isEmptyArrayItem");return Object.values(r).some(t=>t==null?!0:typeof t=="string"?t==="":Array.isArray(t)?t.length===0||t.every(e):typeof t=="object"&&Object.keys(t).length===0)}a(pG,"hasEmptyProperties");function hG(r,e){if(!e)return!1;let t=r.replace(/\/$/,""),n=e.replace(/\/$/,"");return t!==n}a(hG,"needsFolderRepair");function mv(){let r=new Date,e=r.getFullYear(),t=String(r.getMonth()+1).padStart(2,"0"),n=String(r.getDate()).padStart(2,"0");return`${e}-${t}-${n}`}a(mv,"getTodayDateString");function mG(r){let e=r.ems__Effort_plannedStartTimestamp;if(!e)return!1;let t=mv();return typeof e=="string"?e.split("T")[0]===t:Array.isArray(e)&&e.length>0?String(e[0]).split("T")[0]===t:!1}a(mG,"isPlannedForToday");function gG(r){let e=r.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(gG,"hasPlannedStartTimestamp");function yG(r){let e=r.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]),n=t.match(/\[\[([^\[\]]+)\]\]/);return n?n[1]:t}return null}a(yG,"extractDailyNoteDate");function _G(r){return mv()>=r}a(_G,"isCurrentDateGteDay");function j3(r){return r?r.replace(/^["']|["']$/g,"").replace(/\[\[|\]\]/g,"").trim():""}a(j3,"normalizeWithQuotes");var bG=10;function U3(r,e=bG){let t=r.exo__Class_superClass;if(!t)return!1;let n=new Set,i=[],s=Array.isArray(t)?t:[t];for(let o of s){let c=j3(o);c&&i.push({className:c,depth:0})}for(;i.length>0;){let o=i.shift();if(!o)continue;let{className:c,depth:l}=o;if(l>e)continue;if(c===cl.AssetClass.PROTOTYPE)return!0;if(n.has(c))continue;n.add(c);let u=`${c}__exo__Class_superClass`,f=r[u];if(f){let d=Array.isArray(f)?f:[f];for(let p of d){let h=j3(p);h&&!n.has(h)&&i.push({className:h,depth:l+1})}}}return!1}a(U3,"inheritsFromPrototype");function SG(r,e){return ll(r,cl.AssetClass.CLASS)?U3(e):!1}a(SG,"isPrototypeClass")});var V3=v(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.isPrototypeClass=xt.inheritsFromPrototype=xt.isCurrentDateGteDay=xt.extractDailyNoteDate=xt.hasPlannedStartTimestamp=xt.isPlannedForToday=xt.getTodayDateString=xt.needsFolderRepair=xt.hasEmptyProperties=xt.isAssetArchived=xt.hasStatus=xt.isEffort=xt.isAreaOrProject=xt.hasClass=void 0;var yi=B3();Object.defineProperty(xt,"hasClass",{enumerable:!0,get:a(function(){return yi.hasClass},"get")});Object.defineProperty(xt,"isAreaOrProject",{enumerable:!0,get:a(function(){return yi.isAreaOrProject},"get")});Object.defineProperty(xt,"isEffort",{enumerable:!0,get:a(function(){return yi.isEffort},"get")});Object.defineProperty(xt,"hasStatus",{enumerable:!0,get:a(function(){return yi.hasStatus},"get")});Object.defineProperty(xt,"isAssetArchived",{enumerable:!0,get:a(function(){return yi.isAssetArchived},"get")});Object.defineProperty(xt,"hasEmptyProperties",{enumerable:!0,get:a(function(){return yi.hasEmptyProperties},"get")});Object.defineProperty(xt,"needsFolderRepair",{enumerable:!0,get:a(function(){return yi.needsFolderRepair},"get")});Object.defineProperty(xt,"getTodayDateString",{enumerable:!0,get:a(function(){return yi.getTodayDateString},"get")});Object.defineProperty(xt,"isPlannedForToday",{enumerable:!0,get:a(function(){return yi.isPlannedForToday},"get")});Object.defineProperty(xt,"hasPlannedStartTimestamp",{enumerable:!0,get:a(function(){return yi.hasPlannedStartTimestamp},"get")});Object.defineProperty(xt,"extractDailyNoteDate",{enumerable:!0,get:a(function(){return yi.extractDailyNoteDate},"get")});Object.defineProperty(xt,"isCurrentDateGteDay",{enumerable:!0,get:a(function(){return yi.isCurrentDateGteDay},"get")});Object.defineProperty(xt,"inheritsFromPrototype",{enumerable:!0,get:a(function(){return yi.inheritsFromPrototype},"get")});Object.defineProperty(xt,"isPrototypeClass",{enumerable:!0,get:a(function(){return yi.isPrototypeClass},"get")})});var G3=v(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.TsFloorViolationError=Ot.CATALOG_KEEP_NAMESPACES=Ot.PLUGIN_UI_FLOOR=Ot.SDK_FLOOR=Ot.PLUGIN_UI_FLOOR_ASSETSPACE_UIDS=Ot.SDK_FLOOR_ASSETSPACE_UIDS=Ot.TS_FLOOR_AS_UID_SHARED_IDENTITIES=Ot.TS_FLOOR_AS_UID_EXOCMD=Ot.TS_FLOOR_AS_UID_EXO=void 0;Ot.assertTsFloor=wG;Ot.assertTsFloorReconciled=EG;Ot.isTsFloorAssetSpace=vG;Ot.isTsFloorMountPath=TG;Ot.TS_FLOOR_AS_UID_EXO="49fd2e56-4656-4ca7-a789-f472b16ea260";Ot.TS_FLOOR_AS_UID_EXOCMD="c9c65b0f-1e01-47c1-a1f9-1bf70b11df6a";Ot.TS_FLOOR_AS_UID_SHARED_IDENTITIES="0cde1557-6320-4bd0-a7c4-8b72afc38720";Ot.SDK_FLOOR_ASSETSPACE_UIDS=new Set([Ot.TS_FLOOR_AS_UID_EXO]);Ot.PLUGIN_UI_FLOOR_ASSETSPACE_UIDS=new Set([Ot.TS_FLOOR_AS_UID_EXO]);Ot.SDK_FLOOR=[{uid:Ot.TS_FLOOR_AS_UID_EXO,namespace:"exo"}];Ot.PLUGIN_UI_FLOOR=Ot.SDK_FLOOR;Ot.CATALOG_KEEP_NAMESPACES=new Set(["registry","profiles"]);var Lp=class extends Error{static{a(this,"TsFloorViolationError")}constructor(e){super(e),this.name="TsFloorViolationError"}};Ot.TsFloorViolationError=Lp;function wG(r,e){let t=[];for(let n of e)r.has(n)||t.push(n);if(t.length>0)throw new Lp(`Target profile's declared set excludes TS-floor AssetSpace UID(s): ${t.join(", ")}. Profile switch aborted to prevent runtime self-brick (R24).`)}a(wG,"assertTsFloor");function EG(r,e,t){let n=[];for(let i of t)r.has(i.uid)||e.has(i.namespace)||n.push(`${i.namespace} (${i.uid})`);if(n.length>0)throw new Lp(`Target profile's declared set excludes TS-floor AssetSpace(s): ${n.join(", ")}. Profile switch aborted to prevent runtime self-brick (R24).`)}a(EG,"assertTsFloorReconciled");function vG(r,e,t=Ot.SDK_FLOOR){return t.some(n=>r.length>0&&n.uid===r||e.length>0&&n.namespace===e)}a(vG,"isTsFloorAssetSpace");function TG(r,e=Ot.SDK_FLOOR){let t=r.replace(/\/+$/,""),n=t.slice(t.lastIndexOf("/")+1),i=n.startsWith("exoas-")?n.slice(6):n;return i.length===0?!1:e.some(s=>s.namespace===i)}a(TG,"isTsFloorMountPath")});var q3=v(gv=>{"use strict";Object.defineProperty(gv,"__esModule",{value:!0});gv.transitiveDependsOnClosure=AG;function AG(r,e){let t=new Set,n=[];for(let i of r)t.has(i)||(t.add(i),n.push(i));for(;n.length>0;){let i=n.shift();if(i===void 0)break;let s=e.get(i);if(s!==void 0)for(let o of s)t.has(o)||(t.add(o),n.push(o))}return t}a(AG,"transitiveDependsOnClosure")});var yv=v(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.PARKED_ROOT=_i.DEPENDENCY_KIND_REFERENCE_UID=_i.DEPENDENCY_KIND_TBOX_UID=void 0;_i.resolveDependencyKind=H3;_i.parkedPathFor=RG;_i.classifyMountTransition=CG;_i.DEPENDENCY_KIND_TBOX_UID="e1d7fb5c-d334-448d-935b-953b7b033e78";_i.DEPENDENCY_KIND_REFERENCE_UID="fe529085-5370-4ac0-bbe4-1c7351242dee";var IG="dependencykindreference";function H3(r){let e=Array.isArray(r)?r[0]:r;if(typeof e!="string")return"tbox";let t=e.toLowerCase();return t.includes(_i.DEPENDENCY_KIND_TBOX_UID)?"tbox":t.includes(_i.DEPENDENCY_KIND_REFERENCE_UID)||t.includes(IG)?"reference":"tbox"}a(H3,"resolveDependencyKind");_i.PARKED_ROOT=".exocortex/parked";var W3="assetspaces/";function RG(r){let e=r.split("/");if(r.length===0||!r.startsWith(W3)||e.some(t=>t.length===0||t==="."||t===".."))throw new Error(`parkedPathFor: refusing unsafe mount folder "${r}"`);return`${_i.PARKED_ROOT}/${r.slice(W3.length)}`}a(RG,"parkedPathFor");function CG(r){let{state:e,inEffectiveSet:t,dependsOnKind:n,canPark:i=!0}=r;switch(e){case"active":return t?"none":i&&H3(n)==="reference"?"park":"destroy";case"parked":return t?"unpark":"none";case"absent":return t?"materialize":"none"}}a(CG,"classifyMountTransition")});var Y3=v(ny=>{"use strict";Object.defineProperty(ny,"__esModule",{value:!0});ny.ParkedAssetIndex=void 0;var z3=yv();function xG(r){let t=r.replace(/^\[\[|\]\]$/g,"").replace(/^"|"$/g,"").trim().split("#")[0].trim();return(t.split("/").pop()??t).replace(/\.md$/i,"")}a(xG,"normalizeLinkTarget");function K3(r){let e=r.match(/^---\r?\n([\s\S]*?)\r?\n---/);return e===null?null:e[1]}a(K3,"frontmatterOf");function OG(r){let e=K3(r);if(e===null)return!1;let t=e.match(/^exo__Asset_uid:[ \t]*(.+)$/m);return t!==null&&t[1].trim().length>0}a(OG,"hasAssetUid");function PG(r){let e=K3(r);if(e===null)return null;let t=e.match(/^exo__Asset_label:[ \t]*(.+)$/m);if(t===null)return null;let n=t[1].trim();return n.length<1?null:n.length>=2&&n.startsWith('"')&&n.endsWith('"')?_v(n.slice(1,-1).replace(/\\(["\\ntr])/g,(i,s)=>s==="n"?`
|
|
31
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};a(zP,"incrementNodeInspectorPort");a(KP,"useColor")});var g_e,ct=qe(()=>{xg();XP();mp();vE();TE();g_e=new de});var rl=v(Dg=>{"use strict";Object.defineProperty(Dg,"__esModule",{value:!0});Dg.AssetClass=void 0;var JP;(function(r){r.AREA="ems__Area",r.TASK="ems__Task",r.PROJECT="ems__Project",r.ACTION="ems__Action",r.MEETING="ems__Meeting",r.INITIATIVE="ems__Initiative",r.TASK_PROTOTYPE="ems__TaskPrototype",r.MEETING_PROTOTYPE="ems__MeetingPrototype",r.EVENT_PROTOTYPE="exo__EventPrototype",r.PROJECT_PROTOTYPE="ems__ProjectPrototype",r.EVENT="exo__Event",r.DAILY_NOTE="pn__DailyNote",r.CONCEPT="ims__Concept",r.SESSION_START_EVENT="ems__SessionStartEvent",r.SESSION_END_EVENT="ems__SessionEndEvent",r.PROTOTYPE="exo__Prototype",r.CLASS="exo__Class",r.FLEETING_NOTE="ztlk__FleetingNote",r.WORKFLOW="ems__Workflow",r.WORKFLOW_STATE="ems__WorkflowState",r.WORKFLOW_TRANSITION="ems__WorkflowTransition",r.COMMAND="exocmd__Command",r.PRECONDITION="exocmd__Precondition",r.GROUNDING="exocmd__Grounding",r.COMMAND_BINDING="exocmd__CommandBinding"})(JP||(Dg.AssetClass=JP={}))});var nl=v(Fg=>{"use strict";Object.defineProperty(Fg,"__esModule",{value:!0});Fg.EffortStatus=void 0;var ZP;(function(r){r.DRAFT="ems__EffortStatusDraft",r.BACKLOG="ems__EffortStatusBacklog",r.DOING="ems__EffortStatusDoing",r.WAITING="ems__EffortStatusWaiting",r.DONE="ems__EffortStatusDone",r.TRASHED="ems__EffortStatusTrashed"})(ZP||(Fg.EffortStatus=ZP={}))});var Ou=v(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.EFFORT_STATUS_BY_UID=Bo.EFFORT_STATUS_UID=void 0;Bo.normalizeEffortStatus=T8;var xu=nl();Bo.EFFORT_STATUS_UID={[xu.EffortStatus.DRAFT]:"c42245d0-01de-4c35-bfcf-d910445ea28e",[xu.EffortStatus.BACKLOG]:"753a44d5-846c-4b82-9196-4fd9a4d48777",[xu.EffortStatus.DOING]:"027e78f4-6e16-4b36-b8fb-5510507d5745",[xu.EffortStatus.WAITING]:"0610947c-6a62-41c8-9d44-7863d3ba3a8e",[xu.EffortStatus.DONE]:"7b9b3116-7c3c-438c-9618-94fe301320a6",[xu.EffortStatus.TRASHED]:"5d14f18d-db2b-4847-9ac1-144cb93b2541"};Bo.EFFORT_STATUS_BY_UID=Object.freeze(Object.fromEntries(Object.entries(Bo.EFFORT_STATUS_UID).map(([r,e])=>[e,r])));var IE=/^ems__EffortStatus[A-Za-z]+$/,E8=/\s+[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,v8=/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;function T8(r){let e=r;if(e==null)return null;if(Array.isArray(e)){if(e.length!==1)return null;e=e[0]}let t=String(e).trim().replace(/^["']/,"").replace(/["']$/,"").replace(/^\[\[/,"").replace(/\]\]$/,"").trim();if(!t)return null;if(IE.test(t))return t;let n=t.indexOf("|"),i=n===-1?t:t.slice(0,n).trim();if(n!==-1){let c=t.slice(n+1).trim();if(IE.test(c))return c}let s=i.replace(E8,"").trim();if(IE.test(s))return s;let o=i.match(v8);return o?Bo.EFFORT_STATUS_BY_UID[o[1].toLowerCase()]??null:null}a(T8,"normalizeEffortStatus")});var RE=v(Lg=>{"use strict";Object.defineProperty(Lg,"__esModule",{value:!0});Lg.EFFORT_STATUS_OPTIONS=void 0;var A8=Ou();Lg.EFFORT_STATUS_OPTIONS=Object.freeze(Object.keys(A8.EFFORT_STATUS_UID).map(r=>Object.freeze({value:`[[${r}]]`,label:r.replace(/^ems__EffortStatus/,"")})))});var Ka=v(Ng=>{"use strict";Object.defineProperty(Ng,"__esModule",{value:!0});Ng.GroundingType=void 0;var e3;(function(r){r.SPARQL_UPDATE="sparql_update",r.PROPERTY_DELETE="property_delete",r.PROPERTY_SET="property_set",r.COMPOSITE="composite",r.SERVICE_CALL="service_call",r.CREATE_INSTANCE="create_instance",r.PROPERTY_APPEND="property_append",r.PROPERTY_INCREMENT="property_increment",r.PROPERTY_SHIFT="property_shift",r.WORKFLOW_TRANSITION="workflow_transition",r.BODY_TEMPLATE="body_template"})(e3||(Ng.GroundingType=e3={}))});var bp=v(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.GROUNDING_TYPE_IRI_TO_ENUM=hi.GROUNDING_TYPE_UID_TO_ENUM=hi.GROUNDING_TYPE_UIDS=void 0;hi.resolveGroundingTypeFromIRI=R8;hi.resolveGroundingTypeFromWikilinkLiteral=C8;var lr=Ka();hi.GROUNDING_TYPE_UIDS={[lr.GroundingType.PROPERTY_SET]:"cf3bb923-f1f1-40be-b728-782844402426",[lr.GroundingType.PROPERTY_DELETE]:"4bdf1d0b-e9da-4d96-bafe-c5aaef8c2bd5",[lr.GroundingType.COMPOSITE]:"8f9a57db-3865-4886-92fb-c5ab7f3c3fa3",[lr.GroundingType.SERVICE_CALL]:"9bf9fc99-ac37-4e51-b9f5-bd920099947c",[lr.GroundingType.CREATE_INSTANCE]:"4367e2d6-6c92-450a-becb-abce1fb07682",[lr.GroundingType.PROPERTY_APPEND]:"572f7e69-a8a1-42f6-8113-5aa65cc4b552",[lr.GroundingType.PROPERTY_INCREMENT]:"afc29f90-45eb-4f94-9fe2-2ce738759161",[lr.GroundingType.PROPERTY_SHIFT]:"f4e5266f-f3cc-49fd-a5a5-ce1e8b7847a4",[lr.GroundingType.SPARQL_UPDATE]:"79c3e709-8d1d-4694-bcc6-b9ff07d59b86",[lr.GroundingType.WORKFLOW_TRANSITION]:"5c1a2552-d576-496d-8823-563573dd1e2f",[lr.GroundingType.BODY_TEMPLATE]:"6093bfcb-cf9b-4565-86c3-ff74d8bc11c0"};hi.GROUNDING_TYPE_UID_TO_ENUM=Object.freeze(Object.fromEntries(Object.entries(hi.GROUNDING_TYPE_UIDS).map(([r,e])=>[e,r])));var us="https://exocortex.my/ontology/exocmd#";hi.GROUNDING_TYPE_IRI_TO_ENUM=Object.freeze({[`${us}GroundingTypePropertySet`]:lr.GroundingType.PROPERTY_SET,[`${us}GroundingTypePropertyDelete`]:lr.GroundingType.PROPERTY_DELETE,[`${us}GroundingTypeComposite`]:lr.GroundingType.COMPOSITE,[`${us}GroundingTypeServiceCall`]:lr.GroundingType.SERVICE_CALL,[`${us}GroundingTypeCreateInstance`]:lr.GroundingType.CREATE_INSTANCE,[`${us}GroundingTypePropertyAppend`]:lr.GroundingType.PROPERTY_APPEND,[`${us}GroundingTypePropertyIncrement`]:lr.GroundingType.PROPERTY_INCREMENT,[`${us}GroundingTypePropertyShift`]:lr.GroundingType.PROPERTY_SHIFT,[`${us}GroundingTypeSparqlUpdate`]:lr.GroundingType.SPARQL_UPDATE,[`${us}GroundingTypeWorkflowTransition`]:lr.GroundingType.WORKFLOW_TRANSITION,[`${us}GroundingTypeBodyTemplate`]:lr.GroundingType.BODY_TEMPLATE});var I8=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;function R8(r){let e=hi.GROUNDING_TYPE_IRI_TO_ENUM[r];if(e!==void 0)return e;let t=r.match(I8);return t?hi.GROUNDING_TYPE_UID_TO_ENUM[t[1].toLowerCase()]??null:null}a(R8,"resolveGroundingTypeFromIRI");function C8(r){let e=r.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return e?hi.GROUNDING_TYPE_UID_TO_ENUM[e[1].toLowerCase()]??null:null}a(C8,"resolveGroundingTypeFromWikilinkLiteral")});var CE=v(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.CommandBindingStyleProperty=Qi.CommandBindingProperty=Qi.GroundingProperty=Qi.PreconditionProperty=Qi.CommandProperty=void 0;Qi.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"};Qi.PreconditionProperty={SPARQL_ASK:"exocmd__Precondition_sparqlAsk",QUERY:"exocmd__Precondition_query"};Qi.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"};Qi.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"};Qi.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 xE=v(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.STYLE_SOURCE_VALUES=mi.LABEL_CLASS_VALUES=mi.COMMAND_VARIANT_VALUES=void 0;mi.isCommandVariant=x8;mi.isLabelClass=O8;mi.isStyleSource=P8;mi.COMMAND_VARIANT_VALUES=Object.freeze(["primary","secondary","success","warning","danger","muted"]);mi.LABEL_CLASS_VALUES=Object.freeze(["muted","bold","uppercase","compact"]);mi.STYLE_SOURCE_VALUES=Object.freeze(["vendor","user"]);function x8(r){return typeof r=="string"&&mi.COMMAND_VARIANT_VALUES.includes(r)}a(x8,"isCommandVariant");function O8(r){return typeof r=="string"&&mi.LABEL_CLASS_VALUES.includes(r)}a(O8,"isLabelClass");function P8(r){return typeof r=="string"&&mi.STYLE_SOURCE_VALUES.includes(r)}a(P8,"isStyleSource")});var t3=v(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});Pu.isCommandFrontmatter=D8;Pu.isPreconditionFrontmatter=F8;Pu.isGroundingFrontmatter=L8;Pu.isCommandBindingFrontmatter=N8;function D8(r){return kg(r,"exocmd__Command")}a(D8,"isCommandFrontmatter");function F8(r){return kg(r,"exocmd__Precondition")}a(F8,"isPreconditionFrontmatter");function L8(r){return kg(r,"exocmd__Grounding")}a(L8,"isGroundingFrontmatter");function N8(r){return kg(r,"exocmd__CommandBinding")}a(N8,"isCommandBindingFrontmatter");function kg(r,e){let t=r.exo__Instance_class;if(t==null)return!1;let n=Array.isArray(t)?t:[t];for(let i of n){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}a(kg,"hasInstanceClass")});var r3=v(OE=>{"use strict";Object.defineProperty(OE,"__esModule",{value:!0});OE.parseGroundingDefinitionFromFrontmatter=M8;var k8=bp();function Mg(r){if(typeof r!="string")return"";let e=r.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.slice(0,t).trim():e}a(Mg,"normalizeGroundingRef");function M8(r,e,t){let n=e.exocmd__Grounding_type,i=(()=>{if(typeof n!="string")return n;let S=(0,k8.resolveGroundingTypeFromWikilinkLiteral)(n);if(S!==null)return S;throw new Error(`[exocmd-grounding-type-literal-form] legacy literal-string '${n}' for exocmd__Grounding_type in fixture ${r}. 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 S=e.exocmd__Grounding_steps;Array.isArray(S)&&(o=S.map(R=>t(Mg(R))))}let c=e.exocmd__Grounding_incrementBy,l;if(c!=null&&c!==""){let S=Number.parseInt(String(c),10);Number.isFinite(S)&&(l=S)}let u=e.exocmd__Grounding_targetValueRef,f=u?Mg(u):void 0,d=e.exocmd__Grounding_templateRef,p=d?Mg(d):void 0,h=e.exocmd__Grounding_cloneTargetBody,m=h===!0||h==="true",g=e.exocmd__Grounding_targetsCreatedInstance,_=g===!0||g==="true",b=e.exocmd__Grounding_omitLabel,T=b===!0||b==="true",I=e.exocmd__Grounding_targetQuery,w=I?Mg(I):void 0;return{id:r,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:l,linkBackProperty:e.exocmd__Grounding_linkBackProperty,bodyTemplate:e.exocmd__Grounding_bodyTemplate,templateRef:p,cloneTargetBody:m,targetsCreatedInstance:_,omitLabel:T,targetQuery:w,steps:o}}a(M8,"parseGroundingDefinitionFromFrontmatter")});var n3=v(jg=>{"use strict";Object.defineProperty(jg,"__esModule",{value:!0});jg.hasPosition=j8;jg.isFixed=$8;function j8(r){return typeof r.x=="number"&&typeof r.y=="number"}a(j8,"hasPosition");function $8(r){return r.fx!==null&&r.fx!==void 0&&r.fy!==null&&r.fy!==void 0}a($8,"isFixed")});var i3=v($g=>{"use strict";Object.defineProperty($g,"__esModule",{value:!0});$g.createEmptyGraphData=U8;$g.mergeGraphData=B8;function U8(){return{nodes:[],edges:[],lastUpdated:Date.now(),version:0}}a(U8,"createEmptyGraphData");function B8(r,e){let t=new Map,n=new Set,i=[];for(let s of r.nodes)t.set(s.id,s);for(let s of e.nodes)t.set(s.id,s);for(let s of r.edges){let o=`${s.source}->${s.target}:${s.type}`;n.has(o)||(n.add(o),i.push(s))}for(let s of e.edges){let o=`${s.source}->${s.target}:${s.type}`;n.has(o)||(n.add(o),i.push(s))}return{nodes:Array.from(t.values()),edges:i,lastUpdated:Date.now(),version:Math.max(r.version??0,e.version??0)+1}}a(B8,"mergeGraphData")});var PE=v(Ug=>{"use strict";Object.defineProperty(Ug,"__esModule",{value:!0});Ug.createEdgeId=V8;Ug.edgesEqual=G8;function V8(r,e,t,n){let i=n?`|${n}`:"";return`${r}->${e}:${t}${i}`}a(V8,"createEdgeId");function G8(r,e){return r.source===e.source&&r.target===e.target&&r.type===e.type&&r.predicate===e.predicate}a(G8,"edgesEqual")});var DE=v(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.BUILT_IN_EDGE_STYLES=ur.BUILT_IN_NODE_STYLES=ur.DEFAULT_EDGE_STYLE=ur.DEFAULT_NODE_STYLE=ur.RDF_TYPE_PREDICATES=void 0;ur.mergeNodeStyles=q8;ur.mergeEdgeStyles=W8;ur.extractLocalName=H8;ur.isClassType=z8;ur.isTypePredicate=K8;ur.isSubClassPredicate=Y8;ur.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"};ur.DEFAULT_NODE_STYLE={color:"#6366f1",borderColor:"#4f46e5",borderWidth:2,size:30,shape:"circle",icon:"",opacity:1,shadow:!1,animation:"none"};ur.DEFAULT_EDGE_STYLE={color:"#9ca3af",width:1,lineStyle:"solid",arrow:"standard",curvature:0,opacity:.6,showLabel:!1,labelPosition:.5};ur.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"},person__Person:{color:"#06b6d4",shape:"circle"},ims__Person:{color:"#06b6d4",shape:"circle"}};ur.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 q8(r,e){return{...r,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(q8,"mergeNodeStyles");function W8(r,e){return{...r,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(W8,"mergeEdgeStyles");function H8(r){let e=r.lastIndexOf("#"),t=r.lastIndexOf("/"),n=Math.max(e,t);return n>=0?r.substring(n+1):r}a(H8,"extractLocalName");function z8(r){return r===ur.RDF_TYPE_PREDICATES.RDFS_CLASS||r===ur.RDF_TYPE_PREDICATES.OWL_CLASS}a(z8,"isClassType");function K8(r){return r===ur.RDF_TYPE_PREDICATES.RDF_TYPE}a(K8,"isTypePredicate");function Y8(r){return r===ur.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF}a(Y8,"isSubClassPredicate")});var o3=v(s3=>{"use strict";Object.defineProperty(s3,"__esModule",{value:!0})});var $e=v(Bg=>{"use strict";Object.defineProperty(Bg,"__esModule",{value:!0});Bg.IRI=void 0;var FE=class r{static{a(this,"IRI")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("IRI cannot be empty");if(!r.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 n=["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(!n.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)}}};Bg.IRI=FE});var Qe=v(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});il.Literal=void 0;il.parseLanguageTag=a3;il.createDirectionalLiteral=X8;il.createLiteralFromLanguageTag=J8;var Q8="http://www.w3.org/2001/XMLSchema#string",Sp=class{static{a(this,"Literal")}constructor(e,t,n,i){if(e.length===0)throw new Error("Literal value cannot be empty");if(t&&n)throw new Error("Literal cannot have both datatype and language tag");if(i&&!n)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=n?n.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(),n=e.normalizedDatatype();return t===n}normalizedDatatype(){return!this._datatype||this._datatype.value===Q8?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}};il.Literal=Sp;function a3(r){let t=r.lastIndexOf("--");if(t===-1)return{language:r.toLowerCase()};let n=r.substring(t+2),i=r.substring(0,t);return n==="ltr"||n==="rtl"?{language:i.toLowerCase(),direction:n}:{language:r.toLowerCase()}}a(a3,"parseLanguageTag");function X8(r,e,t){return new Sp(r,void 0,e,t)}a(X8,"createDirectionalLiteral");function J8(r,e){let{language:t,direction:n}=a3(e);return new Sp(r,void 0,t,n)}a(J8,"createLiteralFromLanguageTag")});var nr=v(Gg=>{"use strict";Object.defineProperty(Gg,"__esModule",{value:!0});Gg.BlankNode=void 0;var Vg=class r{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${++r.counter}`}static create(){return new r(r.generateId())}};Gg.BlankNode=Vg;Vg.counter=0});var Qt=v(qg=>{"use strict";Object.defineProperty(qg,"__esModule",{value:!0});qg.Namespace=void 0;var c3=$e(),He=class r{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 c3.IRI(t)}get prefix(){return this._prefix}get iri(){return this._iri}term(e){return new c3.IRI(`${this._iri.value}${e}`)}expand(e){let t=e.split(":");if(t.length!==2)return null;let[n,i]=t;return n!==this._prefix?null:this.term(i)}static forPrefix(e){if(!/^[a-z][a-zA-Z0-9]*$/.test(e))return null;let t=r.KNOWN_NAMESPACES.find(n=>n.prefix===e);return t||new r(e,`${r.EXOCORTEX_ONTOLOGY_BASE}${e}#`)}static fromPropertyKey(e){let t=/^([a-z][a-zA-Z0-9]*)__(.+)$/.exec(e);if(!t)return null;let n=r.forPrefix(t[1]);return n?{namespace:n,localName:t[2]}:null}static fromTermIRI(e){if(typeof e!="string"||e.length===0)return null;let t=a(l=>l.length>0&&!l.includes("#")&&!l.includes("/")?l:null,"cleanLocal");for(let l of r.KNOWN_NAMESPACES){let u=l.iri.value;if(e.startsWith(u)){let f=t(e.slice(u.length));return f===null?null:{namespace:l,localName:f}}}if(!e.startsWith(r.EXOCORTEX_ONTOLOGY_BASE))return null;let n=e.slice(r.EXOCORTEX_ONTOLOGY_BASE.length),i=n.indexOf("#");if(i<=0)return null;let s=n.slice(0,i);if(!/^[a-z][a-zA-Z0-9]*$/.test(s))return null;let o=t(n.slice(i+1));if(o===null)return null;let c=r.forPrefix(s);return c?{namespace:c,localName:o}:null}static knownNamespaces(){return r.KNOWN_NAMESPACES}};qg.Namespace=He;He.RDF=new He("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");He.RDFS=new He("rdfs","http://www.w3.org/2000/01/rdf-schema#");He.OWL=new He("owl","http://www.w3.org/2002/07/owl#");He.XSD=new He("xsd","http://www.w3.org/2001/XMLSchema#");He.SHACL=new He("sh","http://www.w3.org/ns/shacl#");He.EXO=new He("exo","https://exocortex.my/ontology/exo#");He.EMS=new He("ems","https://exocortex.my/ontology/ems#");He.EXOCMD=new He("exocmd","https://exocortex.my/ontology/exocmd#");He.IMS=new He("ims","https://exocortex.my/ontology/ims#");He.ZTLK=new He("ztlk","https://exocortex.my/ontology/ztlk#");He.PTMS=new He("ptms","https://exocortex.my/ontology/ptms#");He.LIT=new He("lit","https://exocortex.my/ontology/lit#");He.INBOX=new He("inbox","https://exocortex.my/ontology/inbox#");He.PMBOK=new He("pmbok","https://exocortex.my/ontology/pmbok#");He.EXOCORTEX_ONTOLOGY_BASE="https://exocortex.my/ontology/";He.KNOWN_NAMESPACES=[He.EXO,He.EMS,He.EXOCMD,He.IMS,He.ZTLK,He.PTMS,He.LIT,He.INBOX,He.PMBOK,He.RDF,He.RDFS,He.OWL,He.XSD,He.SHACL]});var gi=v(Wg=>{"use strict";Object.defineProperty(Wg,"__esModule",{value:!0});Wg.Triple=void 0;var LE=$e(),NE=Qe(),kE=nr(),ME=class{static{a(this,"Triple")}constructor(e,t,n){this._subject=e,this._predicate=t,this._object=n}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 LE.IRI&&t instanceof LE.IRI||e instanceof kE.BlankNode&&t instanceof kE.BlankNode||e instanceof NE.Literal&&t instanceof NE.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}>`,n=this.nodeToString(this._object);return`${e} ${t} ${n} .`}nodeToString(e){return e instanceof LE.IRI?`<${e.value}>`:e instanceof kE.BlankNode||e instanceof NE.Literal||this.isQuotedTriple(e)?e.toString():""}};Wg.Triple=ME});var wp=v(Hg=>{"use strict";Object.defineProperty(Hg,"__esModule",{value:!0});Hg.QuotedTriple=void 0;var jE=$e(),$E=Qe(),UE=nr(),BE=class r{static{a(this,"QuotedTriple")}constructor(e,t,n){this._subject=e,this._predicate=t,this._object=n}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 jE.IRI&&t instanceof jE.IRI||e instanceof UE.BlankNode&&t instanceof UE.BlankNode||e instanceof $E.Literal&&t instanceof $E.Literal||e instanceof r&&t instanceof r?e.equals(t):!1}get termType(){return"QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,n=this.nodeToString(this._object);return`<< ${e} ${t} ${n} >>`}nodeToString(e){return e instanceof jE.IRI?`<${e.value}>`:e instanceof UE.BlankNode||e instanceof $E.Literal||e instanceof r?e.toString():""}};Hg.QuotedTriple=BE});var l3=v(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.QuotedTriple=Rr.Triple=Rr.Namespace=Rr.BlankNode=Rr.createLiteralFromLanguageTag=Rr.createDirectionalLiteral=Rr.parseLanguageTag=Rr.Literal=Rr.IRI=void 0;var Z8=$e();Object.defineProperty(Rr,"IRI",{enumerable:!0,get:a(function(){return Z8.IRI},"get")});var zg=Qe();Object.defineProperty(Rr,"Literal",{enumerable:!0,get:a(function(){return zg.Literal},"get")});Object.defineProperty(Rr,"parseLanguageTag",{enumerable:!0,get:a(function(){return zg.parseLanguageTag},"get")});Object.defineProperty(Rr,"createDirectionalLiteral",{enumerable:!0,get:a(function(){return zg.createDirectionalLiteral},"get")});Object.defineProperty(Rr,"createLiteralFromLanguageTag",{enumerable:!0,get:a(function(){return zg.createLiteralFromLanguageTag},"get")});var eV=nr();Object.defineProperty(Rr,"BlankNode",{enumerable:!0,get:a(function(){return eV.BlankNode},"get")});var tV=Qt();Object.defineProperty(Rr,"Namespace",{enumerable:!0,get:a(function(){return tV.Namespace},"get")});var rV=gi();Object.defineProperty(Rr,"Triple",{enumerable:!0,get:a(function(){return rV.Triple},"get")});var nV=wp();Object.defineProperty(Rr,"QuotedTriple",{enumerable:!0,get:a(function(){return nV.QuotedTriple},"get")})});var Kg=v(Ji=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0});Ji.UUID_URL_NAMESPACE=Ji.DEFAULT_LANGUAGE_TAG=Ji.REQUIRED_PROPERTIES=Ji.ALLOWED_PROPERTIES=Ji.Exo003MetadataType=void 0;var Xi;(function(r){r.Namespace="namespace",r.Anchor="anchor",r.BlankNode="blank_node",r.Statement="statement",r.Body="body"})(Xi||(Ji.Exo003MetadataType=Xi={}));Ji.ALLOWED_PROPERTIES={[Xi.Namespace]:["metadata","uri","aliases"],[Xi.Anchor]:["metadata","uri","aliases"],[Xi.BlankNode]:["metadata","uri","aliases"],[Xi.Statement]:["metadata","subject","predicate","object","aliases"],[Xi.Body]:["metadata","subject","predicate","aliases"]};Ji.REQUIRED_PROPERTIES={[Xi.Namespace]:["metadata","uri"],[Xi.Anchor]:["metadata","uri"],[Xi.BlankNode]:["metadata","uri"],[Xi.Statement]:["metadata","subject","predicate","object"],[Xi.Body]:["metadata","subject","predicate"]};Ji.DEFAULT_LANGUAGE_TAG="ru";Ji.UUID_URL_NAMESPACE="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});var u3=v(VE=>{"use strict";Object.defineProperty(VE,"__esModule",{value:!0});VE.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var f3=v(GE=>{"use strict";Object.defineProperty(GE,"__esModule",{value:!0});GE.default="00000000-0000-0000-0000-000000000000"});var d3=v(qE=>{"use strict";Object.defineProperty(qE,"__esModule",{value:!0});qE.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 Ep=v(WE=>{"use strict";Object.defineProperty(WE,"__esModule",{value:!0});var iV=d3();function sV(r){return typeof r=="string"&&iV.default.test(r)}a(sV,"validate");WE.default=sV});var vp=v(HE=>{"use strict";Object.defineProperty(HE,"__esModule",{value:!0});var oV=Ep();function aV(r){if(!(0,oV.default)(r))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(r.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(r.slice(9,13),16))>>>8,e&255,(e=parseInt(r.slice(14,18),16))>>>8,e&255,(e=parseInt(r.slice(19,23),16))>>>8,e&255,(e=parseInt(r.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}a(aV,"parse");HE.default=aV});var Vo=v(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});Tp.unsafeStringify=void 0;var cV=Ep(),fn=[];for(let r=0;r<256;++r)fn.push((r+256).toString(16).slice(1));function p3(r,e=0){return(fn[r[e+0]]+fn[r[e+1]]+fn[r[e+2]]+fn[r[e+3]]+"-"+fn[r[e+4]]+fn[r[e+5]]+"-"+fn[r[e+6]]+fn[r[e+7]]+"-"+fn[r[e+8]]+fn[r[e+9]]+"-"+fn[r[e+10]]+fn[r[e+11]]+fn[r[e+12]]+fn[r[e+13]]+fn[r[e+14]]+fn[r[e+15]]).toLowerCase()}a(p3,"unsafeStringify");Tp.unsafeStringify=p3;function lV(r,e=0){let t=p3(r,e);if(!(0,cV.default)(t))throw TypeError("Stringified UUID is invalid");return t}a(lV,"stringify");Tp.default=lV});var Xg=v(zE=>{"use strict";Object.defineProperty(zE,"__esModule",{value:!0});var uV=require("crypto"),Qg=new Uint8Array(256),Yg=Qg.length;function fV(){return Yg>Qg.length-16&&((0,uV.randomFillSync)(Qg),Yg=0),Qg.slice(Yg,Yg+=16)}a(fV,"rng");zE.default=fV});var KE=v(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});Ip.updateV1State=void 0;var h3=Xg(),dV=Vo(),Ap={};function pV(r,e,t){let n,i=r?._v6??!1;if(r){let s=Object.keys(r);s.length===1&&s[0]==="_v6"&&(r=void 0)}if(r)n=m3(r.random??r.rng?.()??(0,h3.default)(),r.msecs,r.nsecs,r.clockseq,r.node,e,t);else{let s=Date.now(),o=(0,h3.default)();g3(Ap,s,o),n=m3(o,Ap.msecs,Ap.nsecs,i?void 0:Ap.clockseq,i?void 0:Ap.node,e,t)}return e??(0,dV.unsafeStringify)(n)}a(pV,"v1");function g3(r,e,t){return r.msecs??=-1/0,r.nsecs??=0,e===r.msecs?(r.nsecs++,r.nsecs>=1e4&&(r.node=void 0,r.nsecs=0)):e>r.msecs?r.nsecs=0:e<r.msecs&&(r.node=void 0),r.node||(r.node=t.slice(10,16),r.node[0]|=1,r.clockseq=(t[8]<<8|t[9])&16383),r.msecs=e,r}a(g3,"updateV1State");Ip.updateV1State=g3;function m3(r,e,t,n,i,s,o=0){if(r.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,n??=(r[8]<<8|r[9])&16383,i??=r.slice(10,16),e+=122192928e5;let c=((e&268435455)*1e4+t)%4294967296;s[o++]=c>>>24&255,s[o++]=c>>>16&255,s[o++]=c>>>8&255,s[o++]=c&255;let l=e/4294967296*1e4&268435455;s[o++]=l>>>8&255,s[o++]=l&255,s[o++]=l>>>24&15|16,s[o++]=l>>>16&255,s[o++]=n>>>8|128,s[o++]=n&255;for(let u=0;u<6;++u)s[o++]=i[u];return s}a(m3,"v1Bytes");Ip.default=pV});var QE=v(YE=>{"use strict";Object.defineProperty(YE,"__esModule",{value:!0});var hV=vp(),mV=Vo();function gV(r){let e=typeof r=="string"?(0,hV.default)(r):r,t=yV(e);return typeof r=="string"?(0,mV.unsafeStringify)(t):t}a(gV,"v1ToV6");YE.default=gV;function yV(r){return Uint8Array.of((r[6]&15)<<4|r[7]>>4&15,(r[7]&15)<<4|(r[4]&240)>>4,(r[4]&15)<<4|(r[5]&240)>>4,(r[5]&15)<<4|(r[0]&240)>>4,(r[0]&15)<<4|(r[1]&240)>>4,(r[1]&15)<<4|(r[2]&240)>>4,96|r[2]&15,r[3],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15])}a(yV,"_v1ToV6")});var y3=v(XE=>{"use strict";Object.defineProperty(XE,"__esModule",{value:!0});var _V=require("crypto");function bV(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),(0,_V.createHash)("md5").update(r).digest()}a(bV,"md5");XE.default=bV});var Rp=v(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.URL=Go.DNS=Go.stringToBytes=void 0;var _3=vp(),SV=Vo();function b3(r){r=unescape(encodeURIComponent(r));let e=new Uint8Array(r.length);for(let t=0;t<r.length;++t)e[t]=r.charCodeAt(t);return e}a(b3,"stringToBytes");Go.stringToBytes=b3;Go.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Go.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function wV(r,e,t,n,i,s){let o=typeof t=="string"?b3(t):t,c=typeof n=="string"?(0,_3.default)(n):n;if(typeof n=="string"&&(n=(0,_3.default)(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+o.length);if(l.set(c),l.set(o,c.length),l=e(l),l[6]=l[6]&15|r,l[8]=l[8]&63|128,i){if(s=s||0,s<0||s+16>i.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`);for(let u=0;u<16;++u)i[s+u]=l[u];return i}return(0,SV.unsafeStringify)(l)}a(wV,"v35");Go.default=wV});var w3=v(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});sl.URL=sl.DNS=void 0;var EV=y3(),JE=Rp(),S3=Rp();Object.defineProperty(sl,"DNS",{enumerable:!0,get:a(function(){return S3.DNS},"get")});Object.defineProperty(sl,"URL",{enumerable:!0,get:a(function(){return S3.URL},"get")});function ZE(r,e,t,n){return(0,JE.default)(48,EV.default,r,e,t,n)}a(ZE,"v3");ZE.DNS=JE.DNS;ZE.URL=JE.URL;sl.default=ZE});var E3=v(ev=>{"use strict";Object.defineProperty(ev,"__esModule",{value:!0});var vV=require("crypto");ev.default={randomUUID:vV.randomUUID}});var T3=v(tv=>{"use strict";Object.defineProperty(tv,"__esModule",{value:!0});var v3=E3(),TV=Xg(),AV=Vo();function IV(r,e,t){if(v3.default.randomUUID&&!e&&!r)return v3.default.randomUUID();r=r||{};let n=r.random??r.rng?.()??(0,TV.default)();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[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]=n[i];return e}return(0,AV.unsafeStringify)(n)}a(IV,"v4");tv.default=IV});var A3=v(rv=>{"use strict";Object.defineProperty(rv,"__esModule",{value:!0});var RV=require("crypto");function CV(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),(0,RV.createHash)("sha1").update(r).digest()}a(CV,"sha1");rv.default=CV});var R3=v(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.URL=ol.DNS=void 0;var xV=A3(),nv=Rp(),I3=Rp();Object.defineProperty(ol,"DNS",{enumerable:!0,get:a(function(){return I3.DNS},"get")});Object.defineProperty(ol,"URL",{enumerable:!0,get:a(function(){return I3.URL},"get")});function iv(r,e,t,n){return(0,nv.default)(80,xV.default,r,e,t,n)}a(iv,"v5");iv.DNS=nv.DNS;iv.URL=nv.URL;ol.default=iv});var C3=v(sv=>{"use strict";Object.defineProperty(sv,"__esModule",{value:!0});var OV=Vo(),PV=KE(),DV=QE();function FV(r,e,t){r??={},t??=0;let n=(0,PV.default)({...r,_v6:!0},new Uint8Array(16));if(n=(0,DV.default)(n),e){if(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]=n[i];return e}return(0,OV.unsafeStringify)(n)}a(FV,"v6");sv.default=FV});var x3=v(ov=>{"use strict";Object.defineProperty(ov,"__esModule",{value:!0});var LV=vp(),NV=Vo();function kV(r){let e=typeof r=="string"?(0,LV.default)(r):r,t=MV(e);return typeof r=="string"?(0,NV.unsafeStringify)(t):t}a(kV,"v6ToV1");ov.default=kV;function MV(r){return Uint8Array.of((r[3]&15)<<4|r[4]>>4&15,(r[4]&15)<<4|(r[5]&240)>>4,(r[5]&15)<<4|r[6]&15,r[7],(r[1]&15)<<4|(r[2]&240)>>4,(r[2]&15)<<4|(r[3]&240)>>4,16|(r[0]&240)>>4,(r[0]&15)<<4|(r[1]&240)>>4,r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15])}a(MV,"_v6ToV1")});var F3=v(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.updateV7State=void 0;var O3=Xg(),jV=Vo(),av={};function $V(r,e,t){let n;if(r)n=P3(r.random??r.rng?.()??(0,O3.default)(),r.msecs,r.seq,e,t);else{let i=Date.now(),s=(0,O3.default)();D3(av,i,s),n=P3(s,av.msecs,av.seq,e,t)}return e??(0,jV.unsafeStringify)(n)}a($V,"v7");function D3(r,e,t){return r.msecs??=-1/0,r.seq??=0,e>r.msecs?(r.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],r.msecs=e):(r.seq=r.seq+1|0,r.seq===0&&r.msecs++),r}a(D3,"updateV7State");Cp.updateV7State=D3;function P3(r,e,t,n,i=0){if(r.length<16)throw new Error("Random bytes length must be >= 16");if(!n)n=new Uint8Array(16),i=0;else if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return e??=Date.now(),t??=r[6]*127<<24|r[7]<<16|r[8]<<8|r[9],n[i++]=e/1099511627776&255,n[i++]=e/4294967296&255,n[i++]=e/16777216&255,n[i++]=e/65536&255,n[i++]=e/256&255,n[i++]=e&255,n[i++]=112|t>>>28&15,n[i++]=t>>>20&255,n[i++]=128|t>>>14&63,n[i++]=t>>>6&255,n[i++]=t<<2&255|r[10]&3,n[i++]=r[11],n[i++]=r[12],n[i++]=r[13],n[i++]=r[14],n[i++]=r[15],n}a(P3,"v7Bytes");Cp.default=$V});var L3=v(cv=>{"use strict";Object.defineProperty(cv,"__esModule",{value:!0});var UV=Ep();function BV(r){if(!(0,UV.default)(r))throw TypeError("Invalid UUID");return parseInt(r.slice(14,15),16)}a(BV,"version");cv.default=BV});var al=v(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.version=Ct.validate=Ct.v7=Ct.v6ToV1=Ct.v6=Ct.v5=Ct.v4=Ct.v3=Ct.v1ToV6=Ct.v1=Ct.stringify=Ct.parse=Ct.NIL=Ct.MAX=void 0;var VV=u3();Object.defineProperty(Ct,"MAX",{enumerable:!0,get:a(function(){return VV.default},"get")});var GV=f3();Object.defineProperty(Ct,"NIL",{enumerable:!0,get:a(function(){return GV.default},"get")});var qV=vp();Object.defineProperty(Ct,"parse",{enumerable:!0,get:a(function(){return qV.default},"get")});var WV=Vo();Object.defineProperty(Ct,"stringify",{enumerable:!0,get:a(function(){return WV.default},"get")});var HV=KE();Object.defineProperty(Ct,"v1",{enumerable:!0,get:a(function(){return HV.default},"get")});var zV=QE();Object.defineProperty(Ct,"v1ToV6",{enumerable:!0,get:a(function(){return zV.default},"get")});var KV=w3();Object.defineProperty(Ct,"v3",{enumerable:!0,get:a(function(){return KV.default},"get")});var YV=T3();Object.defineProperty(Ct,"v4",{enumerable:!0,get:a(function(){return YV.default},"get")});var QV=R3();Object.defineProperty(Ct,"v5",{enumerable:!0,get:a(function(){return QV.default},"get")});var XV=C3();Object.defineProperty(Ct,"v6",{enumerable:!0,get:a(function(){return XV.default},"get")});var JV=x3();Object.defineProperty(Ct,"v6ToV1",{enumerable:!0,get:a(function(){return JV.default},"get")});var ZV=F3();Object.defineProperty(Ct,"v7",{enumerable:!0,get:a(function(){return ZV.default},"get")});var eG=Ep();Object.defineProperty(Ct,"validate",{enumerable:!0,get:a(function(){return eG.default},"get")});var tG=L3();Object.defineProperty(Ct,"version",{enumerable:!0,get:a(function(){return tG.default},"get")})});var fv=v(Jg=>{"use strict";Object.defineProperty(Jg,"__esModule",{value:!0});Jg.Exo003UUIDGenerator=void 0;var lv=al(),N3=Kg(),uv=class{static{a(this,"Exo003UUIDGenerator")}static generateNamespaceUUID(e){if(!e||e.trim().length===0)throw new Error("Namespace URI cannot be empty");return(0,lv.v5)(e,N3.UUID_URL_NAMESPACE)}static generateAssetUUID(e,t){if(!t||t.trim().length===0)throw new Error("Local identifier cannot be empty");let n=this.generateNamespaceUUID(e);return(0,lv.v5)(t,n)}static generateFromIRI(e){if(!e||e.trim().length===0)throw new Error("IRI cannot be empty");let{namespace:t,localName:n}=this.splitIRI(e);return n?this.generateAssetUUID(t,n):(0,lv.v5)(e,N3.UUID_URL_NAMESPACE)}static generateBlankNodeUUID(e,t){if(!e||e.trim().length===0)throw new Error("Blank node ID cannot be empty");let n="urn:exocortex:blank-node:",i=t?`${t}#${e}`:e;return this.generateAssetUUID(n,i)}static generateStatementUUID(e,t,n){if(!e||!t||!n)throw new Error("Subject, predicate, and object cannot be empty");let i="urn:exocortex:statement:",s=`${e} ${t} ${n}`;return this.generateAssetUUID(i,s)}static generateBodyUUID(e,t){let n="urn:exocortex:body:",i=e;return t?.datatype?i+=`^^${t.datatype}`:t?.language&&(i+=`@${t.language}`,t.direction&&(i+=`--${t.direction}`)),this.generateAssetUUID(n,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 n=e.lastIndexOf("/"),i=e.indexOf("://");return n!==-1&&n>i+2&&n<e.length-1?{namespace:e.substring(0,n+1),localName:e.substring(n+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)}};Jg.Exo003UUIDGenerator=uv});var M3=v(ey=>{"use strict";Object.defineProperty(ey,"__esModule",{value:!0});ey.Exo003Parser=void 0;var Nt=Kg(),xp=fv(),Ya=$e(),Zg=Qe(),k3=nr(),rG=gi(),dv=class{static{a(this,"Exo003Parser")}static parse(e,t){let n=this.validate(e);if(!n.valid)return{success:!1,errors:n.errors};let i=e.metadata;try{return{success:!0,metadata:this.parseByType(e,i),bodyContent:i===Nt.Exo003MetadataType.Body?t:void 0}}catch(s){return{success:!1,errors:[s instanceof Error?s.message:String(s)]}}}static validate(e){let t=[],n=[];if(!e.metadata)return t.push("Missing required property: metadata"),{valid:!1,errors:t,warnings:n};let i=e.metadata;if(!Object.values(Nt.Exo003MetadataType).includes(i))return t.push(`Invalid metadata: ${i}. Valid types: ${Object.values(Nt.Exo003MetadataType).join(", ")}`),{valid:!1,errors:t,warnings:n};let s=i,o=Nt.ALLOWED_PROPERTIES[s],c=Nt.REQUIRED_PROPERTIES[s];for(let l of c)(e[l]===void 0||e[l]===null)&&t.push(`Missing required property: ${l}`);for(let l of Object.keys(e))o.includes(l)||t.push(`Forbidden property for ${s}: ${l}`);switch(s){case Nt.Exo003MetadataType.Namespace:this.validateNamespaceMetadata(e,t);break;case Nt.Exo003MetadataType.Anchor:this.validateAnchorMetadata(e,t);break;case Nt.Exo003MetadataType.BlankNode:this.validateBlankNodeMetadata(e,t);break;case Nt.Exo003MetadataType.Statement:this.validateStatementMetadata(e,t);break;case Nt.Exo003MetadataType.Body:this.validateBodyMetadata(e,t,n);break}return{valid:t.length===0,errors:t,warnings:n}}static parseByType(e,t){let n={metadata:t,aliases:e.aliases};switch(t){case Nt.Exo003MetadataType.Namespace:return{...n,metadata:Nt.Exo003MetadataType.Namespace,uri:e.uri};case Nt.Exo003MetadataType.Anchor:return{...n,metadata:Nt.Exo003MetadataType.Anchor,uri:e.uri};case Nt.Exo003MetadataType.BlankNode:return{...n,metadata:Nt.Exo003MetadataType.BlankNode,uri:e.uri};case Nt.Exo003MetadataType.Statement:return{...n,metadata:Nt.Exo003MetadataType.Statement,subject:e.subject,predicate:e.predicate,object:e.object};case Nt.Exo003MetadataType.Body:return{...n,metadata:Nt.Exo003MetadataType.Body,subject:e.subject,predicate:e.predicate}}}static validateNamespaceMetadata(e,t){let n=e.uri;if(n&&typeof n!="string")t.push("uri must be a string");else if(n)try{new Ya.IRI(n)}catch{t.push(`uri is not a valid IRI: ${String(n)}`)}}static validateAnchorMetadata(e,t){let n=e.uri;if(n&&typeof n!="string")t.push("uri must be a string");else if(n)try{new Ya.IRI(n)}catch{t.push(`uri is not a valid IRI: ${String(n)}`)}}static validateBlankNodeMetadata(e,t){let n=e.uri;if(n&&typeof n!="string")t.push("uri must be a string");else if(n){let i=n;if(!i.startsWith("_:"))try{new Ya.IRI(i)}catch{t.push(`uri is not a valid IRI or blank node identifier: ${String(n)}`)}}}static validateStatementMetadata(e,t){let n=e.subject,i=e.predicate,s=e.object,o=[["subject",n],["predicate",i],["object",s]];for(let[c,l]of o)l&&typeof l!="string"&&t.push(`${c} must be a string`)}static validateBodyMetadata(e,t,n){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,n){let i=t(e.subject),s;if(i.type==="iri")s=new Ya.IRI(i.value);else if(i.type==="blank")s=new k3.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 c=new Ya.IRI(o.value),l=t(e.object),u;if(l.type==="iri")u=new Ya.IRI(l.value);else if(l.type==="blank")u=new k3.BlankNode(l.value);else{let f=n||l.value;if(l.datatype)u=new Zg.Literal(f,new Ya.IRI(l.datatype));else{let d=l.language||Nt.DEFAULT_LANGUAGE_TAG;u=(0,Zg.createDirectionalLiteral)(f,d,l.direction)}}return new rG.Triple(s,c,u)}static toLiteral(e,t,n){if(n?.datatype)return new Zg.Literal(t,new Ya.IRI(n.datatype));let i=n?.language||Nt.DEFAULT_LANGUAGE_TAG;return(0,Zg.createDirectionalLiteral)(t,i,n?.direction)}static isExo003Format(e){let t=e.metadata;return typeof t=="string"&&Object.values(Nt.Exo003MetadataType).includes(t)}static generateUUID(e,t){switch(e.metadata){case Nt.Exo003MetadataType.Namespace:return xp.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Nt.Exo003MetadataType.Anchor:return xp.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Nt.Exo003MetadataType.BlankNode:return xp.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Nt.Exo003MetadataType.Statement:{let n=e;return xp.Exo003UUIDGenerator.generateStatementUUID(n.subject,n.predicate,n.object)}case Nt.Exo003MetadataType.Body:{let n=e;return xp.Exo003UUIDGenerator.generateBodyUUID(n.subject+"|"+n.predicate)}}}};ey.Exo003Parser=dv});var pv=v(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.Exo003Parser=In.Exo003UUIDGenerator=In.UUID_URL_NAMESPACE=In.DEFAULT_LANGUAGE_TAG=In.REQUIRED_PROPERTIES=In.ALLOWED_PROPERTIES=In.Exo003MetadataType=void 0;var Op=Kg();Object.defineProperty(In,"Exo003MetadataType",{enumerable:!0,get:a(function(){return Op.Exo003MetadataType},"get")});Object.defineProperty(In,"ALLOWED_PROPERTIES",{enumerable:!0,get:a(function(){return Op.ALLOWED_PROPERTIES},"get")});Object.defineProperty(In,"REQUIRED_PROPERTIES",{enumerable:!0,get:a(function(){return Op.REQUIRED_PROPERTIES},"get")});Object.defineProperty(In,"DEFAULT_LANGUAGE_TAG",{enumerable:!0,get:a(function(){return Op.DEFAULT_LANGUAGE_TAG},"get")});Object.defineProperty(In,"UUID_URL_NAMESPACE",{enumerable:!0,get:a(function(){return Op.UUID_URL_NAMESPACE},"get")});var nG=fv();Object.defineProperty(In,"Exo003UUIDGenerator",{enumerable:!0,get:a(function(){return nG.Exo003UUIDGenerator},"get")});var iG=M3();Object.defineProperty(In,"Exo003Parser",{enumerable:!0,get:a(function(){return iG.Exo003Parser},"get")})});var no=v(ty=>{"use strict";Object.defineProperty(ty,"__esModule",{value:!0});ty.WikiLinkHelpers=void 0;var Pp=class{static{a(this,"WikiLinkHelpers")}static normalize(e){if(!e)return"";let t=e.replace(this.WIKI_LINK_PATTERN,"").trim();if(!t)return"";let n=t.indexOf("|");if(n===-1)return t;let i=t.substring(0,n).trim(),s=t.substring(n+1).trim();return this.UUID_PATTERN.test(i)&&s||i}static normalizeArray(e){return e?(Array.isArray(e)?e:[e]).map(n=>this.normalize(n)).filter(n=>n.length>0):[]}static equals(e,t){return this.normalize(e)===this.normalize(t)}static includes(e,t){let n=this.normalizeArray(e),i=this.normalize(t);return n.includes(i)}static resolveSymbolic(e,t){let n=this.normalize(e);if(!n)return"";if(this.UUID_PATTERN.test(n)){let i=t(n);return i&&i.length>0?i:n}return n}static resolveSymbolicArray(e,t){return e?(Array.isArray(e)?e:[e]).map(i=>this.resolveSymbolic(i,t)).filter(i=>i.length>0):[]}};ty.WikiLinkHelpers=Pp;Pp.WIKI_LINK_PATTERN=/\[\[|\]\]/g;Pp.UUID_PATTERN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});var Fp=v(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.CommandBindingProperty=ut.GroundingProperty=ut.PreconditionProperty=ut.CommandProperty=ut.resolveGroundingTypeFromWikilinkLiteral=ut.resolveGroundingTypeFromIRI=ut.GROUNDING_TYPE_IRI_TO_ENUM=ut.GROUNDING_TYPE_UID_TO_ENUM=ut.GROUNDING_TYPE_UIDS=ut.GroundingType=ut.EFFORT_STATUS_OPTIONS=ut.normalizeEffortStatus=ut.EFFORT_STATUS_BY_UID=ut.EFFORT_STATUS_UID=ut.EffortStatus=ut.AssetClass=void 0;var sG=rl();Object.defineProperty(ut,"AssetClass",{enumerable:!0,get:a(function(){return sG.AssetClass},"get")});var oG=nl();Object.defineProperty(ut,"EffortStatus",{enumerable:!0,get:a(function(){return oG.EffortStatus},"get")});var hv=Ou();Object.defineProperty(ut,"EFFORT_STATUS_UID",{enumerable:!0,get:a(function(){return hv.EFFORT_STATUS_UID},"get")});Object.defineProperty(ut,"EFFORT_STATUS_BY_UID",{enumerable:!0,get:a(function(){return hv.EFFORT_STATUS_BY_UID},"get")});Object.defineProperty(ut,"normalizeEffortStatus",{enumerable:!0,get:a(function(){return hv.normalizeEffortStatus},"get")});var aG=RE();Object.defineProperty(ut,"EFFORT_STATUS_OPTIONS",{enumerable:!0,get:a(function(){return aG.EFFORT_STATUS_OPTIONS},"get")});var cG=Ka();Object.defineProperty(ut,"GroundingType",{enumerable:!0,get:a(function(){return cG.GroundingType},"get")});var Dp=bp();Object.defineProperty(ut,"GROUNDING_TYPE_UIDS",{enumerable:!0,get:a(function(){return Dp.GROUNDING_TYPE_UIDS},"get")});Object.defineProperty(ut,"GROUNDING_TYPE_UID_TO_ENUM",{enumerable:!0,get:a(function(){return Dp.GROUNDING_TYPE_UID_TO_ENUM},"get")});Object.defineProperty(ut,"GROUNDING_TYPE_IRI_TO_ENUM",{enumerable:!0,get:a(function(){return Dp.GROUNDING_TYPE_IRI_TO_ENUM},"get")});Object.defineProperty(ut,"resolveGroundingTypeFromIRI",{enumerable:!0,get:a(function(){return Dp.resolveGroundingTypeFromIRI},"get")});Object.defineProperty(ut,"resolveGroundingTypeFromWikilinkLiteral",{enumerable:!0,get:a(function(){return Dp.resolveGroundingTypeFromWikilinkLiteral},"get")});var ry=CE();Object.defineProperty(ut,"CommandProperty",{enumerable:!0,get:a(function(){return ry.CommandProperty},"get")});Object.defineProperty(ut,"PreconditionProperty",{enumerable:!0,get:a(function(){return ry.PreconditionProperty},"get")});Object.defineProperty(ut,"GroundingProperty",{enumerable:!0,get:a(function(){return ry.GroundingProperty},"get")});Object.defineProperty(ut,"CommandBindingProperty",{enumerable:!0,get:a(function(){return ry.CommandBindingProperty},"get")})});var B3=v(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.hasClass=ll;Rn.isAreaOrProject=lG;Rn.isEffort=uG;Rn.hasStatus=fG;Rn.isAssetArchived=dG;Rn.hasEmptyProperties=pG;Rn.needsFolderRepair=hG;Rn.getTodayDateString=mv;Rn.isPlannedForToday=mG;Rn.hasPlannedStartTimestamp=gG;Rn.extractDailyNoteDate=yG;Rn.isCurrentDateGteDay=_G;Rn.inheritsFromPrototype=U3;Rn.isPrototypeClass=SG;var $3=no(),cl=Fp();function ll(r,e){return r?(Array.isArray(r)?r:[r]).some(n=>$3.WikiLinkHelpers.normalize(n)===e):!1}a(ll,"hasClass");function lG(r){return ll(r,cl.AssetClass.AREA)||ll(r,cl.AssetClass.PROJECT)}a(lG,"isAreaOrProject");function uG(r){return ll(r,cl.AssetClass.TASK)||ll(r,cl.AssetClass.PROJECT)||ll(r,cl.AssetClass.MEETING)}a(uG,"isEffort");function fG(r,e){if(!r)return!1;let t=Array.isArray(r)?r[0]:r;return t?$3.WikiLinkHelpers.normalize(t)===e:!1}a(fG,"hasStatus");function dG(r){if(r===!0||r===1)return!0;if(typeof r=="string"){let e=r.toLowerCase();return e==="true"||e==="yes"}return!1}a(dG,"isAssetArchived");function pG(r){if(!r||Object.keys(r).length===0)return!1;let e=a(t=>t==null||t==="","isEmptyArrayItem");return Object.values(r).some(t=>t==null?!0:typeof t=="string"?t==="":Array.isArray(t)?t.length===0||t.every(e):typeof t=="object"&&Object.keys(t).length===0)}a(pG,"hasEmptyProperties");function hG(r,e){if(!e)return!1;let t=r.replace(/\/$/,""),n=e.replace(/\/$/,"");return t!==n}a(hG,"needsFolderRepair");function mv(){let r=new Date,e=r.getFullYear(),t=String(r.getMonth()+1).padStart(2,"0"),n=String(r.getDate()).padStart(2,"0");return`${e}-${t}-${n}`}a(mv,"getTodayDateString");function mG(r){let e=r.ems__Effort_plannedStartTimestamp;if(!e)return!1;let t=mv();return typeof e=="string"?e.split("T")[0]===t:Array.isArray(e)&&e.length>0?String(e[0]).split("T")[0]===t:!1}a(mG,"isPlannedForToday");function gG(r){let e=r.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(gG,"hasPlannedStartTimestamp");function yG(r){let e=r.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]),n=t.match(/\[\[([^\[\]]+)\]\]/);return n?n[1]:t}return null}a(yG,"extractDailyNoteDate");function _G(r){return mv()>=r}a(_G,"isCurrentDateGteDay");function j3(r){return r?r.replace(/^["']|["']$/g,"").replace(/\[\[|\]\]/g,"").trim():""}a(j3,"normalizeWithQuotes");var bG=10;function U3(r,e=bG){let t=r.exo__Class_superClass;if(!t)return!1;let n=new Set,i=[],s=Array.isArray(t)?t:[t];for(let o of s){let c=j3(o);c&&i.push({className:c,depth:0})}for(;i.length>0;){let o=i.shift();if(!o)continue;let{className:c,depth:l}=o;if(l>e)continue;if(c===cl.AssetClass.PROTOTYPE)return!0;if(n.has(c))continue;n.add(c);let u=`${c}__exo__Class_superClass`,f=r[u];if(f){let d=Array.isArray(f)?f:[f];for(let p of d){let h=j3(p);h&&!n.has(h)&&i.push({className:h,depth:l+1})}}}return!1}a(U3,"inheritsFromPrototype");function SG(r,e){return ll(r,cl.AssetClass.CLASS)?U3(e):!1}a(SG,"isPrototypeClass")});var V3=v(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.isPrototypeClass=xt.inheritsFromPrototype=xt.isCurrentDateGteDay=xt.extractDailyNoteDate=xt.hasPlannedStartTimestamp=xt.isPlannedForToday=xt.getTodayDateString=xt.needsFolderRepair=xt.hasEmptyProperties=xt.isAssetArchived=xt.hasStatus=xt.isEffort=xt.isAreaOrProject=xt.hasClass=void 0;var yi=B3();Object.defineProperty(xt,"hasClass",{enumerable:!0,get:a(function(){return yi.hasClass},"get")});Object.defineProperty(xt,"isAreaOrProject",{enumerable:!0,get:a(function(){return yi.isAreaOrProject},"get")});Object.defineProperty(xt,"isEffort",{enumerable:!0,get:a(function(){return yi.isEffort},"get")});Object.defineProperty(xt,"hasStatus",{enumerable:!0,get:a(function(){return yi.hasStatus},"get")});Object.defineProperty(xt,"isAssetArchived",{enumerable:!0,get:a(function(){return yi.isAssetArchived},"get")});Object.defineProperty(xt,"hasEmptyProperties",{enumerable:!0,get:a(function(){return yi.hasEmptyProperties},"get")});Object.defineProperty(xt,"needsFolderRepair",{enumerable:!0,get:a(function(){return yi.needsFolderRepair},"get")});Object.defineProperty(xt,"getTodayDateString",{enumerable:!0,get:a(function(){return yi.getTodayDateString},"get")});Object.defineProperty(xt,"isPlannedForToday",{enumerable:!0,get:a(function(){return yi.isPlannedForToday},"get")});Object.defineProperty(xt,"hasPlannedStartTimestamp",{enumerable:!0,get:a(function(){return yi.hasPlannedStartTimestamp},"get")});Object.defineProperty(xt,"extractDailyNoteDate",{enumerable:!0,get:a(function(){return yi.extractDailyNoteDate},"get")});Object.defineProperty(xt,"isCurrentDateGteDay",{enumerable:!0,get:a(function(){return yi.isCurrentDateGteDay},"get")});Object.defineProperty(xt,"inheritsFromPrototype",{enumerable:!0,get:a(function(){return yi.inheritsFromPrototype},"get")});Object.defineProperty(xt,"isPrototypeClass",{enumerable:!0,get:a(function(){return yi.isPrototypeClass},"get")})});var G3=v(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.TsFloorViolationError=Ot.CATALOG_KEEP_NAMESPACES=Ot.PLUGIN_UI_FLOOR=Ot.SDK_FLOOR=Ot.PLUGIN_UI_FLOOR_ASSETSPACE_UIDS=Ot.SDK_FLOOR_ASSETSPACE_UIDS=Ot.TS_FLOOR_AS_UID_SHARED_IDENTITIES=Ot.TS_FLOOR_AS_UID_EXOCMD=Ot.TS_FLOOR_AS_UID_EXO=void 0;Ot.assertTsFloor=wG;Ot.assertTsFloorReconciled=EG;Ot.isTsFloorAssetSpace=vG;Ot.isTsFloorMountPath=TG;Ot.TS_FLOOR_AS_UID_EXO="49fd2e56-4656-4ca7-a789-f472b16ea260";Ot.TS_FLOOR_AS_UID_EXOCMD="c9c65b0f-1e01-47c1-a1f9-1bf70b11df6a";Ot.TS_FLOOR_AS_UID_SHARED_IDENTITIES="0cde1557-6320-4bd0-a7c4-8b72afc38720";Ot.SDK_FLOOR_ASSETSPACE_UIDS=new Set([Ot.TS_FLOOR_AS_UID_EXO]);Ot.PLUGIN_UI_FLOOR_ASSETSPACE_UIDS=new Set([Ot.TS_FLOOR_AS_UID_EXO]);Ot.SDK_FLOOR=[{uid:Ot.TS_FLOOR_AS_UID_EXO,namespace:"exo"}];Ot.PLUGIN_UI_FLOOR=Ot.SDK_FLOOR;Ot.CATALOG_KEEP_NAMESPACES=new Set(["registry","profiles"]);var Lp=class extends Error{static{a(this,"TsFloorViolationError")}constructor(e){super(e),this.name="TsFloorViolationError"}};Ot.TsFloorViolationError=Lp;function wG(r,e){let t=[];for(let n of e)r.has(n)||t.push(n);if(t.length>0)throw new Lp(`Target profile's declared set excludes TS-floor AssetSpace UID(s): ${t.join(", ")}. Profile switch aborted to prevent runtime self-brick (R24).`)}a(wG,"assertTsFloor");function EG(r,e,t){let n=[];for(let i of t)r.has(i.uid)||e.has(i.namespace)||n.push(`${i.namespace} (${i.uid})`);if(n.length>0)throw new Lp(`Target profile's declared set excludes TS-floor AssetSpace(s): ${n.join(", ")}. Profile switch aborted to prevent runtime self-brick (R24).`)}a(EG,"assertTsFloorReconciled");function vG(r,e,t=Ot.SDK_FLOOR){return t.some(n=>r.length>0&&n.uid===r||e.length>0&&n.namespace===e)}a(vG,"isTsFloorAssetSpace");function TG(r,e=Ot.SDK_FLOOR){let t=r.replace(/\/+$/,""),n=t.slice(t.lastIndexOf("/")+1),i=n.startsWith("exoas-")?n.slice(6):n;return i.length===0?!1:e.some(s=>s.namespace===i)}a(TG,"isTsFloorMountPath")});var q3=v(gv=>{"use strict";Object.defineProperty(gv,"__esModule",{value:!0});gv.transitiveDependsOnClosure=AG;function AG(r,e){let t=new Set,n=[];for(let i of r)t.has(i)||(t.add(i),n.push(i));for(;n.length>0;){let i=n.shift();if(i===void 0)break;let s=e.get(i);if(s!==void 0)for(let o of s)t.has(o)||(t.add(o),n.push(o))}return t}a(AG,"transitiveDependsOnClosure")});var yv=v(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.PARKED_ROOT=_i.DEPENDENCY_KIND_REFERENCE_UID=_i.DEPENDENCY_KIND_TBOX_UID=void 0;_i.resolveDependencyKind=H3;_i.parkedPathFor=RG;_i.classifyMountTransition=CG;_i.DEPENDENCY_KIND_TBOX_UID="e1d7fb5c-d334-448d-935b-953b7b033e78";_i.DEPENDENCY_KIND_REFERENCE_UID="fe529085-5370-4ac0-bbe4-1c7351242dee";var IG="dependencykindreference";function H3(r){let e=Array.isArray(r)?r[0]:r;if(typeof e!="string")return"tbox";let t=e.toLowerCase();return t.includes(_i.DEPENDENCY_KIND_TBOX_UID)?"tbox":t.includes(_i.DEPENDENCY_KIND_REFERENCE_UID)||t.includes(IG)?"reference":"tbox"}a(H3,"resolveDependencyKind");_i.PARKED_ROOT=".exocortex/parked";var W3="assetspaces/";function RG(r){let e=r.split("/");if(r.length===0||!r.startsWith(W3)||e.some(t=>t.length===0||t==="."||t===".."))throw new Error(`parkedPathFor: refusing unsafe mount folder "${r}"`);return`${_i.PARKED_ROOT}/${r.slice(W3.length)}`}a(RG,"parkedPathFor");function CG(r){let{state:e,inEffectiveSet:t,dependsOnKind:n,canPark:i=!0}=r;switch(e){case"active":return t?"none":i&&H3(n)==="reference"?"park":"destroy";case"parked":return t?"unpark":"none";case"absent":return t?"materialize":"none"}}a(CG,"classifyMountTransition")});var Y3=v(ny=>{"use strict";Object.defineProperty(ny,"__esModule",{value:!0});ny.ParkedAssetIndex=void 0;var z3=yv();function xG(r){let t=r.replace(/^\[\[|\]\]$/g,"").replace(/^"|"$/g,"").trim().split("#")[0].trim();return(t.split("/").pop()??t).replace(/\.md$/i,"")}a(xG,"normalizeLinkTarget");function K3(r){let e=r.match(/^---\r?\n([\s\S]*?)\r?\n---/);return e===null?null:e[1]}a(K3,"frontmatterOf");function OG(r){let e=K3(r);if(e===null)return!1;let t=e.match(/^exo__Asset_uid:[ \t]*(.+)$/m);return t!==null&&t[1].trim().length>0}a(OG,"hasAssetUid");function PG(r){let e=K3(r);if(e===null)return null;let t=e.match(/^exo__Asset_label:[ \t]*(.+)$/m);if(t===null)return null;let n=t[1].trim();return n.length<1?null:n.length>=2&&n.startsWith('"')&&n.endsWith('"')?_v(n.slice(1,-1).replace(/\\(["\\ntr])/g,(i,s)=>s==="n"?`
|
|
32
32
|
`:s==="t"?" ":s==="r"?"\r":s)):n.length>=2&&n.startsWith("'")&&n.endsWith("'")?_v(n.slice(1,-1).replace(/''/g,"'")):_v(n)}a(PG,"extractLabel");function _v(r){return r.length===0?null:r}a(_v,"orNull");var bv=class{static{a(this,"ParkedAssetIndex")}constructor(e){this.index=null,this.building=null,this.generation=0,this.reader=e}invalidate(){this.index=null,this.building=null,this.generation+=1}async lookup(e){let t=xG(e);if(t.length===0)return null;let i=(await this.ensureIndex()).get(t);if(i===void 0)return null;let s=DG(i);if(s===null)return null;let o;try{o=await this.reader.read(i)}catch{return null}return OG(o)?{path:i,assetSpace:s,label:PG(o)}:null}async ensureIndex(){if(this.index!==null)return this.index;let e=this.generation;this.building===null&&(this.building=this.buildIndex());let t=this.building,n=await t;return e!==this.generation?(this.building===t&&(this.building=null),this.ensureIndex()):(this.index=n,this.building===t&&(this.building=null),n)}async buildIndex(){let e=new Map;return await this.walk(z3.PARKED_ROOT,e),e}async walk(e,t){let n;try{if(!await this.reader.exists(e))return;n=await this.reader.list(e)}catch{return}for(let i of n.files){if(!i.toLowerCase().endsWith(".md"))continue;let s=(i.split("/").pop()??i).replace(/\.md$/i,"");s.length===0||t.has(s)||t.set(s,i)}for(let i of n.folders)(i.split("/").pop()??i).startsWith(".")||await this.walk(i,t)}};ny.ParkedAssetIndex=bv;function DG(r){let e=`${z3.PARKED_ROOT}/`;if(!r.startsWith(e))return null;let t=r.slice(e.length).split("/");if(t.length<3)return null;let[n,i]=t;return n.length===0||i.length===0?null:`${n}/${i}`}a(DG,"assetSpaceOf")});var iy=v(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});Np.PropertyFieldType=void 0;Np.rangeToFieldType=NG;var dn;(function(r){r.Text="text",r.Number="number",r.Date="date",r.DateTime="datetime",r.Boolean="boolean",r.Reference="reference",r.Enum="enum",r.StatusSelect="status-select",r.SizeSelect="size-select",r.Wikilink="wikilink",r.Timestamp="timestamp",r.Unknown="unknown"})(dn||(Np.PropertyFieldType=dn={}));var Q3="http://www.w3.org/2001/XMLSchema#",FG="https://exocortex.my/ontology/exo#",LG="https://exocortex.my/ontology/ems#";function NG(r){if(!r)return dn.Unknown;let e=r.trim();if(!e)return dn.Unknown;if(e.startsWith(Q3)){let t=e.substring(Q3.length);return Sv(t)}if(e.startsWith("xsd:")){let t=e.substring(4);return Sv(t)}if(e.includes("XMLSchema#")){let t=e.indexOf("XMLSchema#"),n=e.substring(t+10);return Sv(n)}return e.startsWith(LG)||e.startsWith("ems:")?kG(e):e.startsWith(FG)||e.startsWith("exo:")||MG(e)?dn.Reference:dn.Text}a(NG,"rangeToFieldType");function Sv(r){switch(r.toLowerCase()){case"string":case"normalizedstring":case"token":case"language":case"nmtoken":case"name":case"ncname":case"anyuri":return dn.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 dn.Number;case"date":return dn.Date;case"datetime":case"datetimestamp":return dn.DateTime;case"boolean":return dn.Boolean;case"time":return dn.Timestamp;default:return dn.Text}}a(Sv,"xsdTypeToFieldType");function kG(r){let e=r.toLowerCase();return e.includes("effortstatus")?dn.StatusSelect:e.includes("tasksize")?dn.SizeSelect:dn.Reference}a(kG,"emsTypeToFieldType");function MG(r){let e=r.toLowerCase();return e.includes("exocortex.my/ontology")?!0:["asset","task","project","area","effort","class","property","concept"].some(n=>e.includes(n))}a(MG,"isClassReference")});var wv=v(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});kp.propertyNameToUri=jG;kp.uriToPropertyName=X3;kp.extractPropertyLabel=$G;function jG(r){return r.replace(/^([a-z]+)__/,"$1:")}a(jG,"propertyNameToUri");function X3(r){if(r.startsWith("http://")||r.startsWith("https://")){let e=r.match(/\/([a-z]+)#([A-Za-z0-9_]+)$/);if(e)return`${e[1]}__${e[2]}`;let t=r.lastIndexOf("#"),n=r.lastIndexOf("/"),i=Math.max(t,n);return i>=0?r.substring(i+1):r}return r.replace(/^([a-z]+):/,"$1__")}a(X3,"uriToPropertyName");function $G(r){let n=(r.includes(":")?X3(r):r).replace(/^[a-z]+__/,"").split("_");return(n.length>1?n.slice(1).join(" "):n[0]).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,s=>s.toUpperCase())}a($G,"extractPropertyLabel")});var sy={};Ig(sy,{__assign:()=>vv,__asyncDelegator:()=>JG,__asyncGenerator:()=>XG,__asyncValues:()=>ZG,__await:()=>Mp,__awaiter:()=>WG,__classPrivateFieldGet:()=>nq,__classPrivateFieldSet:()=>iq,__createBinding:()=>zG,__decorate:()=>VG,__exportStar:()=>KG,__extends:()=>UG,__generator:()=>HG,__importDefault:()=>rq,__importStar:()=>tq,__makeTemplateObject:()=>eq,__metadata:()=>qG,__param:()=>GG,__read:()=>J3,__rest:()=>BG,__spread:()=>YG,__spreadArrays:()=>QG,__values:()=>Tv});function UG(r,e){Ev(r,e);function t(){this.constructor=r}a(t,"__"),r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function BG(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function VG(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function GG(r,e){return function(t,n){e(t,n,r)}}function qG(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function WG(r,e,t,n){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 c(f){try{u(n.next(f))}catch(d){o(d)}}a(c,"fulfilled");function l(f){try{u(n.throw(f))}catch(d){o(d)}}a(l,"rejected");function u(f){f.done?s(f.value):i(f.value).then(c,l)}a(u,"step"),u((n=n.apply(r,e||[])).next())})}function HG(r,e){var t={label:0,sent:a(function(){if(s[0]&1)throw s[1];return s[1]},"sent"),trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(f){return l([u,f])}}function l(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=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(r,t)}catch(f){u=[6,f],i=0}finally{n=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function zG(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]}function KG(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function Tv(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:a(function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}},"next")};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function J3(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s}function YG(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(J3(arguments[e]));return r}function QG(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),i=0,e=0;e<t;e++)for(var s=arguments[e],o=0,c=s.length;o<c;o++,i++)n[i]=s[o];return n}function Mp(r){return this instanceof Mp?(this.v=r,this):new Mp(r)}function XG(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(p){n[p]&&(i[p]=function(h){return new Promise(function(m,g){s.push([p,h,m,g])>1||c(p,h)})})}function c(p,h){try{l(n[p](h))}catch(m){d(s[0][3],m)}}function l(p){p.value instanceof Mp?Promise.resolve(p.value.v).then(u,f):d(s[0][2],p)}function u(p){c("next",p)}function f(p){c("throw",p)}function d(p,h){p(h),s.shift(),s.length&&c(s[0][0],s[0][1])}}function JG(r){var e,t;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=r[i]?function(o){return(t=!t)?{value:Mp(r[i](o)),done:i==="return"}:s?s(o):o}:s}}function ZG(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Tv=="function"?Tv(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=r[s]&&function(o){return new Promise(function(c,l){o=r[s](o),i(c,l,o.done,o.value)})}}function i(s,o,c,l){Promise.resolve(l).then(function(u){s({value:u,done:c})},o)}}function eq(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function tq(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function rq(r){return r&&r.__esModule?r:{default:r}}function nq(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function iq(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var Ev,vv,oy=qe(()=>{Ev=a(function(r,e){return Ev=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},Ev(r,e)},"extendStatics");a(UG,"__extends");vv=a(function(){return vv=Object.assign||a(function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},"__assign"),vv.apply(this,arguments)},"__assign");a(BG,"__rest");a(VG,"__decorate");a(GG,"__param");a(qG,"__metadata");a(WG,"__awaiter");a(HG,"__generator");a(zG,"__createBinding");a(KG,"__exportStar");a(Tv,"__values");a(J3,"__read");a(YG,"__spread");a(QG,"__spreadArrays");a(Mp,"__await");a(XG,"__asyncGenerator");a(JG,"__asyncDelegator");a(ZG,"__asyncValues");a(eq,"__makeTemplateObject");a(tq,"__importStar");a(rq,"__importDefault");a(nq,"__classPrivateFieldGet");a(iq,"__classPrivateFieldSet")});var Rv=v(Iv=>{"use strict";Object.defineProperty(Iv,"__esModule",{value:!0});var Av;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Av||(Av={}));Iv.default=Av});var Z3=v(Cv=>{"use strict";Object.defineProperty(Cv,"__esModule",{value:!0});var sq=Rv();Object.defineProperty(Cv,"Lifecycle",{enumerable:!0,get:a(function(){return sq.default},"get")})});var ul=v(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.defineInjectionTokenMetadata=fs.getParamInfo=fs.INJECTION_TOKEN_METADATA_KEY=void 0;fs.INJECTION_TOKEN_METADATA_KEY="injectionTokens";function oq(r){let e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(fs.INJECTION_TOKEN_METADATA_KEY,r)||{};return Object.keys(t).forEach(n=>{e[+n]=t[n]}),e}a(oq,"getParamInfo");fs.getParamInfo=oq;function aq(r,e){return function(t,n,i){let s=Reflect.getOwnMetadata(fs.INJECTION_TOKEN_METADATA_KEY,t)||{};s[i]=e?{token:r,transform:e.transformToken,transformArgs:e.args||[]}:r,Reflect.defineMetadata(fs.INJECTION_TOKEN_METADATA_KEY,s,t)}}a(aq,"defineInjectionTokenMetadata");fs.defineInjectionTokenMetadata=aq});var xv=v(ay=>{"use strict";Object.defineProperty(ay,"__esModule",{value:!0});ay.isClassProvider=void 0;function cq(r){return!!r.useClass}a(cq,"isClassProvider");ay.isClassProvider=cq});var Ov=v(cy=>{"use strict";Object.defineProperty(cy,"__esModule",{value:!0});cy.isFactoryProvider=void 0;function lq(r){return!!r.useFactory}a(lq,"isFactoryProvider");cy.isFactoryProvider=lq});var uy=v(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});Du.delay=Du.DelayedConstructor=void 0;var ly=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={},n=!1,i,s=a(()=>(n||(i=e(this.wrap()),n=!0),i),"delayedObject");return new Proxy(t,this.createHandler(s))}createHandler(e){let t={},n=a(i=>{t[i]=(...s)=>{s[0]=e();let o=Reflect[i];return o(...s)}},"install");return this.reflectMethods.forEach(n),t}};Du.DelayedConstructor=ly;function uq(r){if(typeof r>"u")throw new Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new ly(r)}a(uq,"delay");Du.delay=uq});var fy=v(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.isConstructorToken=io.isTransformDescriptor=io.isTokenDescriptor=io.isNormalToken=void 0;var fq=uy();function dq(r){return typeof r=="string"||typeof r=="symbol"}a(dq,"isNormalToken");io.isNormalToken=dq;function pq(r){return typeof r=="object"&&"token"in r&&"multiple"in r}a(pq,"isTokenDescriptor");io.isTokenDescriptor=pq;function hq(r){return typeof r=="object"&&"token"in r&&"transform"in r}a(hq,"isTransformDescriptor");io.isTransformDescriptor=hq;function mq(r){return typeof r=="function"||r instanceof fq.DelayedConstructor}a(mq,"isConstructorToken");io.isConstructorToken=mq});var Pv=v(dy=>{"use strict";Object.defineProperty(dy,"__esModule",{value:!0});dy.isTokenProvider=void 0;function gq(r){return!!r.useToken}a(gq,"isTokenProvider");dy.isTokenProvider=gq});var Dv=v(py=>{"use strict";Object.defineProperty(py,"__esModule",{value:!0});py.isValueProvider=void 0;function yq(r){return r.useValue!=null}a(yq,"isValueProvider");py.isValueProvider=yq});var Fv=v(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var _q=xv();Object.defineProperty(fl,"isClassProvider",{enumerable:!0,get:a(function(){return _q.isClassProvider},"get")});var bq=Ov();Object.defineProperty(fl,"isFactoryProvider",{enumerable:!0,get:a(function(){return bq.isFactoryProvider},"get")});var Sq=fy();Object.defineProperty(fl,"isNormalToken",{enumerable:!0,get:a(function(){return Sq.isNormalToken},"get")});var wq=Pv();Object.defineProperty(fl,"isTokenProvider",{enumerable:!0,get:a(function(){return wq.isTokenProvider},"get")});var Eq=Dv();Object.defineProperty(fl,"isValueProvider",{enumerable:!0,get:a(function(){return Eq.isValueProvider},"get")})});var eD=v(hy=>{"use strict";Object.defineProperty(hy,"__esModule",{value:!0});hy.isProvider=void 0;var vq=xv(),Tq=Dv(),Aq=Pv(),Iq=Ov();function Rq(r){return vq.isClassProvider(r)||Tq.isValueProvider(r)||Aq.isTokenProvider(r)||Iq.isFactoryProvider(r)}a(Rq,"isProvider");hy.isProvider=Rq});var kv=v(Nv=>{"use strict";Object.defineProperty(Nv,"__esModule",{value:!0});var Lv=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,[])}};Nv.default=Lv});var tD=v(jv=>{"use strict";Object.defineProperty(jv,"__esModule",{value:!0});var Cq=kv(),Mv=class extends Cq.default{static{a(this,"Registry")}};jv.default=Mv});var rD=v(Uv=>{"use strict";Object.defineProperty(Uv,"__esModule",{value:!0});var $v=class{static{a(this,"ResolutionContext")}constructor(){this.scopedResolutions=new Map}};Uv.default=$v});var Bv=v(my=>{"use strict";Object.defineProperty(my,"__esModule",{value:!0});my.formatErrorCtor=void 0;function xq(r,e){return r===null?`at position #${e}`:`"${r.split(",")[e].trim()}" at position #${e}`}a(xq,"formatDependency");function Oq(r,e,t=" "){return[r,...e.message.split(`
|
|
33
33
|
`).map(n=>t+n)].join(`
|
|
34
34
|
`)}a(Oq,"composeErrorMessage");function Pq(r,e,t){let[,n=null]=r.toString().match(/constructor\(([\w, ]+)\)/)||[],i=xq(n,e);return Oq(`Cannot inject the dependency ${i} of "${r.name}" constructor. Reason:`,t)}a(Pq,"formatErrorCtor");my.formatErrorCtor=Pq});var nD=v(gy=>{"use strict";Object.defineProperty(gy,"__esModule",{value:!0});gy.isDisposable=void 0;function Dq(r){return!(typeof r.dispose!="function"||r.dispose.length>0)}a(Dq,"isDisposable");gy.isDisposable=Dq});var sD=v(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});dl.PostResolutionInterceptors=dl.PreResolutionInterceptors=void 0;var iD=kv(),yy=class extends iD.default{static{a(this,"PreResolutionInterceptors")}};dl.PreResolutionInterceptors=yy;var _y=class extends iD.default{static{a(this,"PostResolutionInterceptors")}};dl.PostResolutionInterceptors=_y;var Vv=class{static{a(this,"Interceptors")}constructor(){this.preResolution=new yy,this.postResolution=new _y}};dl.default=Vv});var Qa=v(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.instance=qo.typeInfo=void 0;var Fq=(oy(),Rg(sy)),Kn=Fv(),Lq=eD(),by=fy(),Nq=tD(),bi=Rv(),Sy=rD(),kq=Bv(),Mq=uy(),jq=nD(),$q=sD();qo.typeInfo=new Map;var Gv=class r{static{a(this,"InternalDependencyContainer")}constructor(e){this.parent=e,this._registry=new Nq.default,this.interceptors=new $q.default,this.disposed=!1,this.disposables=new Set}register(e,t,n={lifecycle:bi.default.Transient}){this.ensureNotDisposed();let i;if(Lq.isProvider(t)?i=t:i={useClass:t},Kn.isTokenProvider(i)){let s=[e],o=i;for(;o!=null;){let c=o.useToken;if(s.includes(c))throw new Error(`Token registration cycle detected! ${[...s,c].join(" -> ")}`);s.push(c);let l=this._registry.get(c);l&&Kn.isTokenProvider(l.provider)?o=l.provider:o=null}}if((n.lifecycle===bi.default.Singleton||n.lifecycle==bi.default.ContainerScoped||n.lifecycle==bi.default.ResolutionScoped)&&(Kn.isValueProvider(i)||Kn.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${bi.default[n.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:n}),this}registerType(e,t){return this.ensureNotDisposed(),Kn.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(),Kn.isNormalToken(e)){if(Kn.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:bi.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:bi.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let n=e;return t&&!Kn.isNormalToken(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:bi.default.Singleton})}resolve(e,t=new Sy.default,n=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&Kn.isNormalToken(e)){if(n)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(by.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 n=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&n.push(i),i.callback(e,t);this.interceptors.preResolution.setAll(e,n)}}executePostResolutionInterceptor(e,t,n){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,n);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===bi.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let n=e.options.lifecycle===bi.default.Singleton,i=e.options.lifecycle===bi.default.ContainerScoped,s=n||i,o;return Kn.isValueProvider(e.provider)?o=e.provider.useValue:Kn.isTokenProvider(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Kn.isClassProvider(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Kn.isFactoryProvider(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===bi.default.ResolutionScoped&&t.scopedResolutions.set(e,o),o}resolveAll(e,t=new Sy.default,n=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&Kn.isNormalToken(e)){if(n)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let o=i.map(c=>this.resolveRegistration(c,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(n=>!Kn.isValueProvider(n.provider)).map(n=>(n.instance=void 0,n)))}createChildContainer(){this.ensureNotDisposed();let e=new r(this);for(let[t,n]of this._registry.entries())n.some(({options:i})=>i.lifecycle===bi.default.ContainerScoped)&&e._registry.setAll(t,n.map(i=>i.options.lifecycle===bi.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,t,n={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:t,options:n})}afterResolution(e,t,n={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:t,options:n})}dispose(){return Fq.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let n=t.dispose();n&&e.push(n)}),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 Mq.DelayedConstructor)return e.createProxy(i=>this.resolve(i,t));let n=(()=>{let i=qo.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 jq.isDisposable(n)&&this.disposables.add(n),n}resolveParams(e,t){return(n,i)=>{try{return by.isTokenDescriptor(n)?by.isTransformDescriptor(n)?n.multiple?this.resolve(n.transform).transform(this.resolveAll(n.token,new Sy.default,n.isOptional),...n.transformArgs):this.resolve(n.transform).transform(this.resolve(n.token,e,n.isOptional),...n.transformArgs):n.multiple?this.resolveAll(n.token,new Sy.default,n.isOptional):this.resolve(n.token,e,n.isOptional):by.isTransformDescriptor(n)?this.resolve(n.transform,e).transform(this.resolve(n.token,e),...n.transformArgs):this.resolve(n,e)}catch(s){throw new Error(kq.formatErrorCtor(t,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};qo.instance=new Gv;qo.default=qo.instance});var oD=v(Wv=>{"use strict";Object.defineProperty(Wv,"__esModule",{value:!0});var Uq=ul(),Wo=Qa(),qv=fy(),Bq=Bv();function Vq(){return function(r){let e=Uq.getParamInfo(r);return class extends r{constructor(...t){super(...t.concat(e.slice(t.length).map((n,i)=>{try{return qv.isTokenDescriptor(n)?qv.isTransformDescriptor(n)?n.multiple?Wo.instance.resolve(n.transform).transform(Wo.instance.resolveAll(n.token),...n.transformArgs):Wo.instance.resolve(n.transform).transform(Wo.instance.resolve(n.token),...n.transformArgs):n.multiple?Wo.instance.resolveAll(n.token):Wo.instance.resolve(n.token):qv.isTransformDescriptor(n)?Wo.instance.resolve(n.transform).transform(Wo.instance.resolve(n.token),...n.transformArgs):Wo.instance.resolve(n)}catch(s){let o=i+t.length;throw new Error(Bq.formatErrorCtor(r,o,s))}})))}}}}a(Vq,"autoInjectable");Wv.default=Vq});var aD=v(Hv=>{"use strict";Object.defineProperty(Hv,"__esModule",{value:!0});var Gq=ul();function qq(r,e){let t={token:r,multiple:!1,isOptional:e&&e.isOptional};return Gq.defineInjectionTokenMetadata(t)}a(qq,"inject");Hv.default=qq});var wy=v(zv=>{"use strict";Object.defineProperty(zv,"__esModule",{value:!0});var Wq=ul(),Hq=Qa(),cD=Qa();function zq(r){return function(e){Hq.typeInfo.set(e,Wq.getParamInfo(e)),r&&r.token&&(Array.isArray(r.token)?r.token.forEach(t=>{cD.instance.register(t,e)}):cD.instance.register(r.token,e))}}a(zq,"injectable");zv.default=zq});var lD=v(Kv=>{"use strict";Object.defineProperty(Kv,"__esModule",{value:!0});var Kq=(oy(),Rg(sy)),Yq=Qa();function Qq(r=[]){return function(e){return r.forEach(t=>{var{token:n,options:i}=t,s=Kq.__rest(t,["token","options"]);return Yq.instance.register(n,s,i)}),e}}a(Qq,"registry");Kv.default=Qq});var uD=v(Yv=>{"use strict";Object.defineProperty(Yv,"__esModule",{value:!0});var Xq=wy(),Jq=Qa();function Zq(){return function(r){Xq.default()(r),Jq.instance.registerSingleton(r)}}a(Zq,"singleton");Yv.default=Zq});var fD=v(Qv=>{"use strict";Object.defineProperty(Qv,"__esModule",{value:!0});var eW=ul();function tW(r,e){let t={token:r,multiple:!0,isOptional:e&&e.isOptional};return eW.defineInjectionTokenMetadata(t)}a(tW,"injectAll");Qv.default=tW});var dD=v(Xv=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});var rW=ul();function nW(r,e,...t){let n={token:r,multiple:!0,transform:e,transformArgs:t};return rW.defineInjectionTokenMetadata(n)}a(nW,"injectAllWithTransform");Xv.default=nW});var pD=v(Jv=>{"use strict";Object.defineProperty(Jv,"__esModule",{value:!0});var iW=ul();function sW(r,e,...t){return iW.defineInjectionTokenMetadata(r,{transformToken:e,args:t})}a(sW,"injectWithTransform");Jv.default=sW});var hD=v(Zv=>{"use strict";Object.defineProperty(Zv,"__esModule",{value:!0});var oW=wy(),aW=Qa();function cW(r,e){return function(t){oW.default()(t),aW.instance.register(e||t,t,{lifecycle:r})}}a(cW,"scoped");Zv.default=cW});var mD=v(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});var lW=oD();Object.defineProperty(ds,"autoInjectable",{enumerable:!0,get:a(function(){return lW.default},"get")});var uW=aD();Object.defineProperty(ds,"inject",{enumerable:!0,get:a(function(){return uW.default},"get")});var fW=wy();Object.defineProperty(ds,"injectable",{enumerable:!0,get:a(function(){return fW.default},"get")});var dW=lD();Object.defineProperty(ds,"registry",{enumerable:!0,get:a(function(){return dW.default},"get")});var pW=uD();Object.defineProperty(ds,"singleton",{enumerable:!0,get:a(function(){return pW.default},"get")});var hW=fD();Object.defineProperty(ds,"injectAll",{enumerable:!0,get:a(function(){return hW.default},"get")});var mW=dD();Object.defineProperty(ds,"injectAllWithTransform",{enumerable:!0,get:a(function(){return mW.default},"get")});var gW=pD();Object.defineProperty(ds,"injectWithTransform",{enumerable:!0,get:a(function(){return gW.default},"get")});var yW=hD();Object.defineProperty(ds,"scoped",{enumerable:!0,get:a(function(){return yW.default},"get")})});var gD=v(e1=>{"use strict";Object.defineProperty(e1,"__esModule",{value:!0});function _W(r){let e;return t=>(e==null&&(e=r(t)),e)}a(_W,"instanceCachingFactory");e1.default=_W});var yD=v(t1=>{"use strict";Object.defineProperty(t1,"__esModule",{value:!0});function bW(r){let e=new WeakMap;return t=>{let n=e.get(t);return n==null&&(n=r(t),e.set(t,n)),n}}a(bW,"instancePerContainerCachingFactory");t1.default=bW});var _D=v(r1=>{"use strict";Object.defineProperty(r1,"__esModule",{value:!0});function SW(r,e,t,n=!0){let i,s;return o=>{let c=r(o);return(!n||s!==c)&&((s=c)?i=o.resolve(e):i=o.resolve(t)),i}}a(SW,"predicateAwareClassFactory");r1.default=SW});var bD=v(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});var wW=gD();Object.defineProperty(jp,"instanceCachingFactory",{enumerable:!0,get:a(function(){return wW.default},"get")});var EW=yD();Object.defineProperty(jp,"instancePerContainerCachingFactory",{enumerable:!0,get:a(function(){return EW.default},"get")});var vW=_D();Object.defineProperty(jp,"predicateAwareClassFactory",{enumerable:!0,get:a(function(){return vW.default},"get")})});var lt=v(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var n1=(oy(),Rg(sy));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 TW=Z3();Object.defineProperty(Xa,"Lifecycle",{enumerable:!0,get:a(function(){return TW.Lifecycle},"get")});n1.__exportStar(mD(),Xa);n1.__exportStar(bD(),Xa);n1.__exportStar(Fv(),Xa);var AW=uy();Object.defineProperty(Xa,"delay",{enumerable:!0,get:a(function(){return AW.delay},"get")});var IW=Qa();Object.defineProperty(Xa,"container",{enumerable:!0,get:a(function(){return IW.instance},"get")})});var $p=v(Ey=>{"use strict";Object.defineProperty(Ey,"__esModule",{value:!0});Ey.NullLogger=void 0;Ey.NullLogger={debug(){},info(){},warn(){},error(){}}});var Fu=v(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});pl.STRING_SCALAR_PROPERTIES=void 0;pl.needsYamlQuoting=SD;pl.quoteYamlString=wD;pl.serializeYamlScalar=kW;var RW=/^[-!&*?|>%@`"'#,[\]{}]/,CW=/[\u0000-\u001f\u007f]/,xW=/^(?:true|True|TRUE|false|False|FALSE)$/,OW=/^(?:null|Null|NULL|~)$/,PW=/^[-+]?(?:0b[01_]+|0o[0-7_]+|0x[0-9a-fA-F_]+|[0-9][0-9_]*)$/,DW=/^(?:[-+]?[0-9][0-9_]*(?:\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/,FW=/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;pl.STRING_SCALAR_PROPERTIES=new Set(["exo__Asset_label","aliases"]);function LW(r){if(r.length<2||!r.startsWith('"')||!r.endsWith('"'))return!1;let e=r.slice(1,-1);for(let t=0;t<e.length;t++){if(e[t]==="\\"){if(t+1>=e.length)return!1;t++;continue}if(e[t]==='"')return!1}return!0}a(LW,"isCompleteDoubleQuotedScalar");function NW(r){return xW.test(r)||OW.test(r)||PW.test(r)||DW.test(r)||FW.test(r)}a(NW,"looksLikeNonStringScalar");function SD(r,e=!1){return r===""?!0:LW(r)?!1:!!(r!==r.trim()||/:(\s|$)/.test(r)||/\s#/.test(r)||RW.test(r)||CW.test(r)||e&&NW(r))}a(SD,"needsYamlQuoting");function wD(r){let e="";for(let t=0;t<r.length;t++){let n=r[t],i=r.charCodeAt(t);n==="\\"?e+="\\\\":n==='"'?e+='\\"':n===`
|
|
35
|
-
`?e+="\\n":n==="\r"?e+="\\r":n===" "?e+="\\t":i<32||i===127?e+="\\x"+i.toString(16).toUpperCase().padStart(2,"0"):e+=n}return`"${e}"`}a(wD,"quoteYamlString");function kW(r,e=!1){return typeof r!="string"?String(r):SD(r,e)?wD(r):r}a(kW,"serializeYamlScalar")});var Nu=v(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.bytesToBase64=vD;Lu.base64ToBytes=TD;Lu.base64ToUtf8=MW;Lu.utf8ToBase64=jW;var ED=32768;function vD(r){let e="";for(let t=0;t<r.length;t+=ED)e+=String.fromCharCode(...r.subarray(t,t+ED));return btoa(e)}a(vD,"bytesToBase64");function TD(r){let e=r.replace(/\s/g,""),t=e.length%4,n=t===2||t===3?e+"=".repeat(4-t):e,i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}a(TD,"base64ToBytes");function MW(r){return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(TD(r))}a(MW,"base64ToUtf8");function jW(r){return vD(new TextEncoder().encode(r))}a(jW,"utf8ToBase64")});var Up=v(i1=>{"use strict";Object.defineProperty(i1,"__esModule",{value:!0});i1.iriToObsidianName=UW;var $W=Qt();function UW(r){let e=$W.Namespace.fromTermIRI(r);if(e)return`${e.namespace.prefix}__${e.localName}`;let t=r.match(/\/([^/]+)\.md$/);return t?t[1]:null}a(UW,"iriToObsidianName")});var AD=v(vy=>{"use strict";Object.defineProperty(vy,"__esModule",{value:!0});vy.mergePropertyDefaults=BW;vy.mergeInheritanceRules=VW;function BW(r,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.propertyName);o?(n.push(o),i.add(o.propertyName)):n.push(s)}for(let s of e)i.has(s.propertyName)||n.push(s);return n}a(BW,"mergePropertyDefaults");function VW(r,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.targetPropertyName);o?(n.push(o),i.add(o.targetPropertyName)):n.push(s)}for(let s of e)i.has(s.targetPropertyName)||n.push(s);return n}a(VW,"mergeInheritanceRules")});var s1=v((kwe,ID)=>{var ku=class{static{a(this,"Wildcard")}constructor(){return GW||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(ku.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(ku.prototype,"termType",{enumerable:!0,value:"Wildcard"});var GW=new ku;ID.exports.Wildcard=ku});var CD=v((jwe,RD)=>{var qW=(function(){var r=a(function($,j,B,X){for(B=B||{},X=$.length;X--;B[$[X]]=j);return B},"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],n=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],c=[13,16,45,197,224,229,308],l=[28,29,53],u=[28,53],f=[1,42],d=[1,45],p=[1,41],h=[1,44],m=[123,126],g=[1,67],_=[39,45,87],b=[13,16,45,197,224,308],T=[1,87],I=[2,281],w=[1,86],S=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],R=[6,28,29,53,63,70,73,81,83,85],L=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],P=[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],M=[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],O=[13,16,308],F=[112,132,327,334],Z=[13,16,112,132,308],J=[1,111],U=[1,117],K=[112,132,327,328,334],_e=[13,16,112,132,308,328],le=[28,29,45,53,87],W=[1,138],H=[1,151],oe=[1,128],xe=[1,127],re=[1,129],Q=[1,140],ie=[1,141],Y=[1,142],ae=[1,143],Me=[1,144],N=[1,145],ue=[1,147],de=[1,148],Ie=[2,457],we=[1,158],ve=[1,159],Ae=[1,160],pe=[1,152],V=[1,153],D=[1,156],z=[1,171],se=[1,172],be=[1,173],Re=[1,174],Be=[1,175],De=[1,176],Fe=[1,167],Ve=[1,168],Ce=[1,169],je=[1,170],Ze=[1,157],nt=[1,166],et=[1,161],C=[1,162],x=[1,163],k=[1,164],G=[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],Vt=[1,195],Kt=[6,31,73,81,83,85],tt=[2,285],he=[1,199],me=[1,201],ge=[6,31,70,73,81,83,85],Se=[2,283],Xe=[1,207],Et=[1,218],vt=[1,223],cn=[1,219],di=[1,225],Fi=[1,226],qn=[1,224],eP=[6,63,70,73,81,83,85],tP=[1,236],rP=[2,334],nP=[1,243],iP=[1,241],ln=[6,193],ig=[2,349],sP=[2,339],qa=[28,128],oP=[47,48,193,272],sg=[47,48,193,242,272],yu=[47,48,193,242,246,272],_u=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Hr=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],aP=[1,271],cP=[1,270],Ar=[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],lP=[1,281],uP=[1,280],Wn=[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],ip=[45,89],og=[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],ag=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],cg=[31,89],lg=[48,87],Wc=[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],Qs=[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],fP=[1,313],bu=[6,85],tE=[6,31,81,83,85],dP=[2,361],Fo=[2,353],Hc=[1,343],sp=[31,112,335],Lo=[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],rE=[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],pP=[6,109,193],zc=[31,112],Ir=[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],nE=[1,390],iE=[1,391],Wa=[13,16,87,197,308,314],hP=[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],ug=[1,417],fg=[1,418],mP=[13,16,48,197,229,308],Ha=[6,31,85],gP=[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],sE=[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],Kc=[29,31,85,112,159,160,161,163,164],dg=[1,443],pg=[1,444],yP=[1,449],Yc=[31,112,193,232,318,335],hg=[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],_P=[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],oE=[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],op=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],ap=[31,45],bP=[1,507],SP=[1,508],wP=[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],mg=[29,31,85,112,159,160,161,163,164,335],Qc=[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],EP=[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],vP=[2,352],aE=[13,16,197,308,314],TP=[1,565],Su=[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],AP=[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],No=[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],IP=[13,16,87,308],ko=[2,364],wu=[29,31,85,112,159,160,161,163,164,193,232,318,335],gg=[31,112,193,232,272,318,335],Mo=[2,359],RP=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],yg=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],CP=[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],xP=[2,347],cE={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(j,B,X,Oe,Je,E,zn){var A=E.length-1;switch(Je){case 1:if(E[A-1]=E[A-1]||{},it.base&&(E[A-1].base=it.base),it.base="",E[A-1].prefixes=it.prefixes,it.prefixes=null,it.pathOnly){if(E[A-1].type==="path"||"termType"in E[A-1])return E[A-1];throw new Error("Received full SPARQL query in path only mode")}else if(E[A-1].type==="path"||"termType"in E[A-1])throw new Error("Received only path in full SPARQL mode");if(E[A-1].type==="update"){let Gt={};for(let rr of E[A-1].updates)if(rr.updateType==="insert"){let Tt={};for(let Dt of rr.insert)if(Dt.type==="bgp"||Dt.type==="graph")for(let pi of Dt.triples)pi.subject.termType==="BlankNode"&&(Tt[pi.subject.value]=!0),pi.predicate.termType==="BlankNode"&&(Tt[pi.predicate.value]=!0),pi.object.termType==="BlankNode"&&(Tt[pi.object.value]=!0);for(let Dt of Object.keys(Tt)){if(Gt[Dt])throw new Error("Detected reuse blank node across different INSERT DATA clauses");Gt[Dt]=!0}}}return E[A-1];case 2:this.$={...E[A-1],...E[A],type:"query"};break;case 4:it.base=cp(E[A]);break;case 5:it.prefixes||(it.prefixes={}),E[A-1]=E[A-1].substr(0,E[A-1].length-1),E[A]=cp(E[A]),it.prefixes[E[A-1]]=E[A];break;case 6:this.$={...E[A-3],...Zc(E[A-2]),...E[A-1],...E[A]};break;case 7:if(!it.skipValidation&&(gE(E[A-3].variables.map(rr=>mE(rr.expression))).some(rr=>rr.aggregation==="count"&&!(rr.expression instanceof _g))||E[A].group)){for(let rr of E[A-3].variables)if(rr.termType==="Variable"){if(!E[A].group||!E[A].group.map(Tt=>Au(Tt)).includes(Au(rr)))throw Error("Projection of ungrouped variable (?"+Au(rr)+")")}else if(mE(rr.expression).length===0){let Tt=d8(rr.expression);for(let Dt of Tt)if(!E[A].group||!E[A].group.map||!E[A].group.map(pi=>Au(pi)).includes(Au(Dt)))throw Error("Use of ungrouped variable in projection of operation (?"+Au(Dt)+")")}}let eo=E[A-1].where.filter(Gt=>Gt.type==="query");if(eo.length>0){let Gt=E[A-3].variables.filter(Tt=>Tt.variable&&Tt.variable.value).map(Tt=>Tt.variable.value),rr=gE(eo.map(Tt=>Tt.variables)).map(Tt=>Tt.value||Tt.variable.value);for(let Tt of Gt)if(rr.indexOf(Tt)>=0)throw Error("Target id of 'AS' (?"+Tt+") already used in subquery")}this.$=yr(E[A-3],Zc(E[A-2]),E[A-1],E[A]);break;case 8:this.$=yr({queryType:"CONSTRUCT",template:E[A-3]},Zc(E[A-2]),E[A-1],E[A]);break;case 9:this.$=yr({queryType:"CONSTRUCT",template:E[A-2]=E[A-2]?E[A-2].triples:[]},Zc(E[A-5]),{where:[{type:"bgp",triples:Jc([],E[A-2])}]},E[A]);break;case 10:this.$=yr({queryType:"DESCRIBE",variables:E[A-3]==="*"?[new _g]:E[A-3]},Zc(E[A-2]),E[A-1],E[A]);break;case 11:this.$=yr({queryType:"ASK"},Zc(E[A-2]),E[A-1],E[A]);break;case 12:this.$=yr(E[A-1],{variables:[new _g]});break;case 13:let pp=E[A].map(Gt=>Gt.value||Gt.variable.value),Iu=p8(pp);if(Iu.length>0)throw Error("Two or more of the resulting columns have the same name (?"+Iu[0]+")");this.$=yr(E[A-1],{variables:E[A]});break;case 14:this.$=yr({queryType:"SELECT"},E[A]&&(E[A-1]=Hn(E[A]),E[A]={},E[A][E[A-1]]=!0,E[A]));break;case 16:case 27:this.$=Eu(E[A-3],{variable:E[A-1]});break;case 17:case 18:this.$=yr(E[A-3],E[A-2],E[A-1],E[A],{type:"query"});break;case 19:case 58:this.$={iri:E[A],named:!!E[A-1]};break;case 20:this.$={where:E[A].patterns};break;case 21:this.$=yr(E[A-1],E[A]);break;case 22:this.$=yr(E[A-2],E[A-1],E[A]);break;case 23:this.$={group:E[A]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Eu(E[A]);break;case 26:this.$=Eu(E[A-1]);break;case 29:this.$={having:E[A]};break;case 30:this.$={order:E[A]};break;case 32:this.$=Eu(E[A],{descending:!0});break;case 35:this.$={limit:Tu(E[A])};break;case 36:this.$={offset:Tu(E[A])};break;case 37:this.$={limit:Tu(E[A-2]),offset:Tu(E[A])};break;case 38:this.$={limit:Tu(E[A]),offset:Tu(E[A-2])};break;case 39:case 43:this.$={type:"values",values:E[A]};break;case 40:case 84:this.$=E[A-1].map(Gt=>({[E[A-3]]:Gt}));break;case 41:case 85:this.$=E[A-1].map(()=>({}));break;case 42:case 86:var Zs=E[A-4].length;E[A-4]=E[A-4].map(lE),this.$=E[A-1].map(function(Gt){if(Gt.length!==Zs)throw Error("Inconsistent VALUES length");for(var rr={},Tt=0;Tt<Zs;Tt++)rr["?"+E[A-4][Tt].value]=Gt[Tt];return rr});break;case 44:case 65:case 100:case 126:case 175:this.$=E[A-1];break;case 45:this.$={type:"update",updates:jo(E[A-2],E[A-1])};break;case 46:this.$=yr({type:"load",silent:!!E[A-2],source:E[A-1]},E[A]&&{destination:E[A]});break;case 47:this.$={type:Hn(E[A-2]),silent:!!E[A-1],graph:E[A]};break;case 48:this.$={type:Hn(E[A-4]),silent:!!E[A-3],source:E[A-2],destination:E[A]};break;case 49:this.$={type:"create",silent:!!E[A-2],graph:{type:"graph",name:E[A]}};break;case 50:this.$={updateType:"insert",insert:UP(E[A])};break;case 51:this.$={updateType:"delete",delete:bE(UP(E[A]))};break;case 52:this.$={updateType:"deletewhere",delete:bE(E[A])};break;case 53:this.$={updateType:"insertdelete",...E[A-4],...E[A-3],...Zc(E[A-2],"using"),where:E[A].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=E[A];break;case 55:this.$={delete:bE(E[A-1]),insert:E[A]||[]};break;case 56:this.$={delete:[],insert:E[A]};break;case 59:this.$={graph:E[A]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:E[A]};break;case 64:this.$={[Hn(E[A])]:!0};break;case 66:this.$=E[A-1]?Xs(E[A],[E[A-1]]):Xs(E[A]);break;case 67:var fp=yr(E[A-3]||{triples:[]},{type:"graph",name:E[A-5]});this.$=E[A]?[fp,E[A]]:[fp];break;case 68:case 73:this.$={type:"bgp",triples:Xs(E[A-2],[E[A-1]])};break;case 69:this.$={type:"group",patterns:[E[A-1]]};break;case 70:for(let Gt of E[A-1].filter(rr=>rr.type==="bind")){let rr=E[A-1].indexOf(Gt),Tt=new Set;for(let Dt of E[A-1].slice(0,rr))(Dt.type==="group"||Dt.type==="bgp")&&jP(Dt).forEach(pi=>Tt.add(pi));if(Tt.has(Gt.variable.value))throw Error("Variable used to bind is already bound (?"+Gt.variable.value+")")}this.$={type:"group",patterns:E[A-1]};break;case 71:this.$=E[A-1]?Xs([E[A-1]],E[A]):Xs(E[A]);break;case 72:this.$=E[A]?[E[A-2],E[A]]:E[A-2];break;case 75:this.$=yr(E[A],{type:"optional"});break;case 76:this.$=yr(E[A],{type:"minus"});break;case 77:this.$=yr(E[A],{type:"graph",name:E[A-1]});break;case 78:this.$=yr(E[A],{type:"service",name:E[A-1],silent:!!E[A-2]});break;case 79:this.$={type:"filter",expression:E[A]};break;case 80:this.$={type:"bind",variable:E[A-1],expression:E[A-3]};break;case 89:this.$=up(E[A]);break;case 90:this.$=void 0;break;case 91:this.$=E[A-1].length?{type:"union",patterns:Xs(E[A-1].map(fE),[fE(E[A])])}:E[A];break;case 95:this.$={...E[A],function:E[A-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:jo(E[A-2],E[A-1]),distinct:!!E[A-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.$=jo(E[A-2],E[A-1]);break;case 101:this.$=Xs(E[A-2],[E[A-1]]);break;case 102:case 112:this.$=_E(E[A].map(Gt=>yr($o(E[A-1]),Gt)));break;case 103:this.$=_E(Jc(E[A].map(Gt=>yr($o(E[A-1].entity),Gt)),E[A-1].triples));break;case 105:this.$=Xs([E[A-1]],E[A]);break;case 106:this.$=Xs(E[A]);break;case 107:this.$=hE(E[A-1],E[A]);break;case 109:case 237:this.$=it.factory.namedNode(r8);break;case 110:case 118:this.$=jo(E[A-1],E[A]);break;case 111:this.$=E[A]?{annotation:E[A],object:E[A-1]}:E[A-1];break;case 113:this.$=E[A]?_E(Jc(E[A].map(Gt=>yr($o(E[A-1].entity),Gt)),E[A-1].triples)):E[A-1].triples;break;case 114:this.$=hE(...E[A-1],E[A]);break;case 116:this.$=hE(...E[A]);break;case 117:case 159:case 163:this.$=[E[A-1],E[A]];break;case 119:this.$=E[A]?{object:E[A-1],annotation:E[A]}:E[A-1];break;case 120:this.$=E[A-1].length?vu("|",jo(E[A-1],E[A])):E[A];break;case 121:this.$=E[A-1].length?vu("/",jo(E[A-1],E[A])):E[A];break;case 122:this.$=E[A]?vu(E[A],[E[A-1]]):E[A-1];break;case 123:this.$=E[A-1]?vu(E[A-1],[E[A]]):E[A];break;case 125:case 131:this.$=vu(E[A-1],[E[A]]);break;case 129:this.$=vu("|",jo(E[A-2],E[A-1]));break;case 132:case 134:this.$=u8(E[A-1]);break;case 133:case 135:this.$=f8(E[A-1]);break;case 140:this.$={entity:E[A],triples:[]};break;case 145:this.$=lE(E[A]);break;case 149:this.$=it.factory.namedNode(OP);break;case 151:case 153:case 158:case 162:this.$=uE(E[A-1],E[A]);break;case 152:this.$=["||",E[A]];break;case 154:this.$=["&&",E[A]];break;case 156:this.$=un(E[A-1],[E[A-2],E[A]]);break;case 157:this.$=un(E[A-2]?"notin":"in",[E[A-3],E[A]]);break;case 160:this.$=["+",uE(E[A-1],E[A])];break;case 161:var wg=Js(E[A-1].value.replace("-",""),E[A-1].datatype);this.$=["-",uE(wg,E[A])];break;case 164:this.$=un("UPLUS",[E[A]]);break;case 165:this.$=un(E[A-1],[E[A]]);break;case 166:this.$=un("UMINUS",[E[A]]);break;case 177:this.$=un(Hn(E[A-1]));break;case 178:this.$=un(Hn(E[A-3]),[E[A-1]]);break;case 179:this.$=up(un(Hn(E[A-3]),[E[A-1]]));break;case 180:this.$=un(Hn(E[A-5]),[E[A-3],E[A-1]]);break;case 181:this.$=un(Hn(E[A-7]),[E[A-5],E[A-3],E[A-1]]);break;case 182:this.$=up(un(Hn(E[A-7]),[E[A-5],E[A-3],E[A-1]]));break;case 183:this.$=un(Hn(E[A-1]),E[A]);break;case 184:this.$=un("bound",[lE(E[A-1])]);break;case 185:this.$=un(E[A-1],[]);break;case 186:this.$=un(E[A-3],[E[A-1]]);break;case 187:this.$=un(E[A-2]?"notexists":"exists",[fE(E[A])]);break;case 188:case 189:this.$=Eu(E[A-1],{type:"aggregate",aggregation:Hn(E[A-4]),distinct:!!E[A-2]});break;case 190:this.$=Eu(E[A-2],{type:"aggregate",aggregation:Hn(E[A-5]),distinct:!!E[A-3],separator:typeof E[A-1]=="string"?E[A-1]:" "});break;case 192:this.$=Js(E[A]);break;case 193:this.$=o8(E[A-1],Hn(E[A].substr(1)));break;case 194:this.$=Js(E[A-2],E[A]);break;case 195:case 204:this.$=Js(E[A],PP);break;case 196:case 205:this.$=Js(E[A],DP);break;case 197:case 206:this.$=Js(Hn(E[A]),FP);break;case 200:this.$=Js(E[A].toLowerCase(),s8);break;case 201:this.$=Js(E[A].substr(1),PP);break;case 202:this.$=Js(E[A].substr(1),DP);break;case 203:this.$=Js(E[A].substr(1).toLowerCase(),FP);break;case 207:case 208:this.$=MP(E[A],1);break;case 209:case 210:this.$=MP(E[A],3);break;case 211:this.$=it.factory.namedNode(cp(E[A]));break;case 213:var Eg=E[A].indexOf(":"),dp=E[A].substr(0,Eg),vg=it.prefixes[dp];if(!vg)throw new Error("Unknown prefix: "+dp);var cr=cp(vg+E[A].substr(Eg+1));this.$=it.factory.namedNode(cr);break;case 214:if(E[A]=E[A].substr(0,E[A].length-1),!(E[A]in it.prefixes))throw new Error("Unknown prefix: "+E[A]);var cr=cp(it.prefixes[E[A]]);this.$=it.factory.namedNode(cr);break;case 215:this.$=lp(E[A].replace(/^(_:)/,""));break;case 216:this.$=lp();break;case 217:case 218:case 232:this.$=up(dE(E[A-3],E[A-2],E[A-1]));break;case 230:case 231:this.$=up(E[A-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:E[A-1].push(E[A]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[E[A]];break;case 308:E[A-3].push(E[A-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:E[A-2].push(E[A-1]);break}},"anonymous"),table:[r(e,t,{3:1,4:2,10:3}),{1:[3]},r(n,[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}),r([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]},r(c,[2,411],{216:28,217:29}),r(l,[2,249],{18:30}),r(l,[2,251],{22:31}),r(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:p,139:38,307:43,308:h,323:36},r(l,[2,267],{37:46}),r(m,[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:g,87:p},r(_,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),r(e,[2,248]),r(e,[2,245]),r(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]},r([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]}),r(b,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:T,29:I,52:84,53:w,56:85},{19:88,28:T,29:I,52:89,53:w,56:85},r(l,[2,253],{26:90}),{28:[1,91],52:92,53:w},r(S,[2,385],{181:93,182:94,183:95,31:[2,383]}),r(R,[2,263],{34:96}),r(R,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:p,308:h}),r(R,[2,262]),r(L,[2,259]),r(P,[2,143]),r(P,[2,144]),r([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]),r(M,[2,211]),r(M,[2,212]),r(M,[2,213]),r(M,[2,214]),{19:98,28:T,29:I,52:99,53:w,56:85},{6:[2,309],99:100,193:[1,101]},r(O,[2,311],{101:102,328:[1,103]}),r(F,[2,317],{104:104,328:[1,105]}),r(Z,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:J,114:110},{29:J,114:112},{29:J,114:113},{118:114,123:[1,115],125:116,126:U},r(K,[2,315]),r(K,[2,316]),r(_e,[2,319]),r(_e,[2,320]),r(_e,[2,321]),r(m,[2,327]),{13:f,16:d,55:118,307:43,308:h},r(l,[2,12]),r(l,[2,13],{44:66,43:119,45:g,87:p}),r(le,[2,269]),r(le,[2,15]),{13:f,16:d,44:136,45:W,46:120,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(_,[2,14]),r(_,[2,274]),r(_,[2,271]),r(_,[2,272]),r(e,[2,4]),{13:[1,177]},r(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},r(c,[2,410]),r([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:Vt,219:189,220:190,223:191,224:[1,192],307:43,308:h},r(b,[2,419]),r(Kt,tt,{20:196,59:197,69:198,70:he}),r(l,[2,250]),{29:me,57:200},r(O,[2,279],{54:202,327:[1,203]}),{29:[2,282]},r(ge,Se,{23:204,58:205,62:206,63:Xe}),r(l,[2,252]),{19:208,28:T,29:I,52:209,53:w,56:85},{29:[1,210]},r(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,145:212,172:221,185:213,187:214,231:cn,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(eP,[2,265],{56:85,35:227,52:228,19:229,28:T,29:I,53:w}),r(L,[2,260]),r(ge,Se,{58:205,62:206,23:230,63:Xe}),r(l,[2,268]),{6:[2,45]},r(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:h},r(O,[2,312]),{105:233,112:tP,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},r(F,[2,318]),r(O,rP,{108:240,133:242,112:nP,132:iP}),r(Z,[2,323]),{112:[1,244]},{112:[2,325]},r(ln,[2,50]),r(S,ig,{135:245,136:246,143:247,144:248,31:sP,112:sP}),r(ln,[2,51]),r(ln,[2,52]),r(qa,[2,328],{119:249}),{29:J,114:250},r(qa,[2,56]),{29:J,114:251},r(m,[2,59]),r(le,[2,270]),{47:[1,252]},r(oP,[2,150]),r(sg,[2,428],{240:253}),r(yu,[2,430],{244:254}),r(yu,[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]}),r(_u,[2,440],{252:264}),r(Hr,[2,448],{260:265}),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,255:154,257:155,264:266,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,255:154,257:155,264:267,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,255:154,257:155,264:268,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Hr,[2,167]),r(Hr,[2,168]),r(Hr,[2,169]),r(Hr,[2,170],{176:269,45:aP,89:cP}),r(Hr,[2,171]),r(Hr,[2,172]),r(Hr,[2,173]),r(Hr,[2,174]),{13:f,16:d,44:136,45:W,46:272,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:lP,89:uP,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},r(Wn,[2,192],{292:[1,286],293:[1,287]}),r(Wn,[2,195]),r(Wn,[2,196]),r(Wn,[2,197]),r(Wn,[2,198]),r(Wn,[2,199]),r(Wn,[2,200]),{13:f,16:d,44:39,55:40,82:H,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},r(ip,[2,452]),r(ip,[2,453]),r(ip,[2,454]),r(ip,[2,455]),r(ip,[2,456]),{279:[2,458]},r(og,[2,207]),r(og,[2,208]),r(og,[2,209]),r(og,[2,210]),r(Wn,[2,201]),r(Wn,[2,202]),r(Wn,[2,203]),r(Wn,[2,204]),r(Wn,[2,205]),r(Wn,[2,206]),r(e,[2,5]),r(ag,[2,297],{88:295}),r(cg,[2,299],{90:296}),{48:[1,297],87:[1,298]},r(lg,[2,301]),r(Te,[2,43]),r(Te,[2,82]),r(Te,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},r(c,[2,412]),r(Wc,[2,123]),r(Wc,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),r(Qs,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:Vt,223:312,225:308,226:309,229:fP,307:43,308:h},r(c,i,{215:10,214:314}),r(Qs,[2,236]),r(Qs,[2,237]),r(bu,[2,6]),r(tE,[2,287],{60:315,72:316,73:[1,317]}),r(Kt,[2,286]),{13:f,16:d,45:W,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},r([6,31,63,70,73,81,83,85],[2,20]),r(S,dP,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:Fo,31:Fo,85:Fo,112:Fo,159:Fo,160:Fo,161:Fo,163:Fo,164:Fo,41:s}),{13:f,16:d,55:331,307:43,308:h},r(O,[2,280]),r(bu,[2,7]),r(Kt,tt,{59:197,69:198,20:332,70:he}),r(ge,[2,284]),{64:[1,333]},r(ge,Se,{58:205,62:206,23:334,63:Xe}),r(l,[2,254]),r(S,ig,{144:248,30:335,143:336,31:[2,257]}),r(l,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:p,139:342,186:339,190:340,195:341,197:Hc,307:43,308:h},r(sp,[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:p,197:Hc,308:h}),r(Lo,[2,227]),r(Lo,[2,228]),r(Lo,[2,229]),{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,172:221,185:351,187:350,200:348,230:347,231:cn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},{13:f,16:d,44:39,55:40,87:p,139:342,186:352,190:340,195:341,197:Hc,307:43,308:h},r(Lo,[2,146]),r(Lo,[2,147]),r(Lo,[2,148]),r(Lo,[2,149]),{13:f,16:d,44:354,55:355,82:H,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:358,312:qn,313:353},r(rE,[2,215]),r(rE,[2,216]),r(ge,Se,{58:205,62:206,23:359,63:Xe}),r(R,[2,264]),r(eP,[2,266]),r(bu,[2,11]),r(n,[2,308],{6:[2,310]}),r(ln,[2,313],{102:360,120:361,121:[1,362]}),r(ln,[2,47]),r(ln,[2,63]),r(ln,[2,64]),{13:f,16:d,55:363,307:43,308:h},r(ln,[2,336]),r(ln,[2,337]),r(ln,[2,338]),{109:[1,364]},r(pP,[2,60]),{13:f,16:d,55:365,307:43,308:h},r(O,[2,335]),{13:f,16:d,55:366,307:43,308:h},{31:[1,367]},r(zc,[2,341],{137:368}),r(zc,[2,340]),{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,145:369,172:221,185:213,187:214,231:cn,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},{28:[1,370],127:371,128:[1,372]},r(qa,[2,330],{124:373,125:374,126:U}),r(qa,[2,57]),{44:375,87:p},r(oP,[2,151],{241:376,242:[1,377]}),r(sg,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,247:380,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{250:[1,381]},r(Ir,[2,432]),r(Ir,[2,433]),r(Ir,[2,434]),r(Ir,[2,435]),r(Ir,[2,436]),r(Ir,[2,437]),{250:[2,439]},r([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:z,298:se,299:be,300:Re,301:Be,302:De}),r(_u,[2,162],{261:388,262:389,39:nE,338:iE}),r(Hr,[2,164]),r(Hr,[2,165]),r(Hr,[2,166]),r(Ar,[2,95]),r(Ar,[2,96]),r(Ir,[2,377],{177:392,325:[1,393]}),{48:[1,394]},r(Ar,[2,177]),{13:f,16:d,44:136,45:W,46:395,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:396,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:397,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:398,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:399,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,183]),r(Ar,[2,98]),r(Ir,[2,381],{180:400}),{87:[1,401]},r(Ar,[2,185]),{13:f,16:d,44:136,45:W,46:402,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{29:me,57:403},r(Wn,[2,193]),{13:f,16:d,55:404,307:43,308:h},{13:f,16:d,44:39,55:40,87:p,139:342,195:405,197:Hc,307:43,308:h},r(Wa,[2,233]),r(Wa,[2,234]),r(Wa,[2,235]),r(hP,[2,459],{281:406,325:[1,407]}),r(Ir,[2,463],{284:408,325:[1,409]}),r(Ir,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:H,171:413,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},{31:[1,419],89:[1,420]},{29:[1,421]},r(lg,[2,302]),r(ag,[2,367],{167:422}),r(cg,[2,369],{168:423}),{48:[1,424],87:[1,425]},r(lg,[2,371]),r(Wc,[2,122]),r(Wc,[2,417]),r(Wc,[2,413]),r(Wc,[2,414]),r(Wc,[2,415]),r(Qs,[2,125]),r(Qs,[2,127]),r(Qs,[2,128]),r(mP,[2,420],{227:426}),r(Qs,[2,130]),{13:f,16:d,55:194,197:Vt,223:427,307:43,308:h},{48:[1,428]},r(Ha,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),r(tE,[2,288]),{64:[1,433]},r(Kt,[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:W,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,276:ue,277:de,279:Ie,280:we,283:ve,285:Ae,308:h,346:nt,347:et,348:C,349:x,350:k,351:G}),r(gP,[2,293]),r(sE,[2,92]),r(sE,[2,93]),r(sE,[2,94]),{45:aP,89:cP,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:T,29:I,56:85},{19:438,28:T,29:I,56:85},r(Kc,[2,355],{149:439}),r(Kc,[2,354]),{13:f,16:d,44:215,45:dg,55:220,82:H,87:p,89:vt,156:440,172:221,185:441,203:442,231:pg,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(R,[2,19]),r(Ha,[2,21]),{13:f,16:d,44:450,45:yP,55:323,65:445,66:446,67:447,68:448,87:p,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},r(bu,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},r(S,[2,386],{31:[2,388]}),r(sp,[2,102]),r(Yc,[2,391],{191:452}),r(S,[2,395],{196:453,198:454}),r(S,[2,108]),r(S,[2,109]),r(sp,[2,103]),r(sp,[2,104]),r(sp,[2,390]),{13:f,16:d,44:215,45:Et,48:[1,455],55:220,82:H,87:p,89:vt,172:221,185:351,187:350,200:456,231:cn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(hg,[2,424]),r(_P,[2,136]),r(_P,[2,137]),r(oE,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:p,139:342,195:458,197:Hc,307:43,308:h},r(Wa,[2,219]),r(Wa,[2,220]),r(Wa,[2,221]),r(Wa,[2,222]),r(Wa,[2,223]),r(bu,[2,10]),r(ln,[2,46]),r(ln,[2,314]),{112:tP,122:459},r(ln,[2,62]),r(O,rP,{133:242,108:460,112:nP,132:iP}),r(pP,[2,61]),r(ln,[2,49]),r([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},r(zc,[2,351],{146:463,335:[1,464]}),{29:me,57:465},r(qa,[2,329]),r(O,[2,332],{129:466,327:[1,467]}),r(qa,[2,55]),r(qa,[2,331]),{48:[1,468]},r(sg,[2,429]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(yu,[2,431]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,243:470,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(yu,[2,156]),{45:lP,89:uP,179:471},r(_u,[2,441]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,251:472,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Hr,[2,444],{256:473}),r(Hr,[2,446],{258:474}),r(Ir,[2,442]),r(Ir,[2,443]),r(Hr,[2,449]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,255:154,257:155,259:475,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ir,[2,450]),r(Ir,[2,451]),r(Ir,[2,379],{178:476}),r(Ir,[2,378]),r([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:W,46:482,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{48:[1,483]},{48:[1,484]},r(Ar,[2,187]),r(Wn,[2,194]),{13:f,16:d,44:39,55:40,82:H,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,320:485},{13:f,16:d,39:[1,487],44:136,45:W,46:488,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,282:486,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(hP,[2,460]),{13:f,16:d,44:136,45:W,46:489,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ir,[2,464]),{13:f,16:d,44:136,45:W,46:490,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ir,[2,466]),r(Te,[2,40]),r(ag,[2,298]),r(op,[2,87]),r(op,[2,88]),r(op,[2,89]),r(op,[2,90]),{13:f,16:d,55:492,82:H,172:493,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,311:494,312:qn,315:491},r(Te,[2,41]),r(cg,[2,300]),r(ap,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:H,171:497,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},{31:[1,498],89:[1,499]},{29:[1,500]},r(lg,[2,372]),{13:f,16:d,48:[2,422],55:194,197:Vt,223:312,226:502,228:501,229:fP,307:43,308:h},r(Qs,[2,131]),r(Qs,[2,126]),r(Ha,[2,22]),r(Ha,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:W,55:323,67:321,68:322,74:505,75:506,76:bP,77:320,78:SP,79:509,87:p,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},r(gP,[2,294]),r(wP,[2,69]),r(wP,[2,70]),r(Kt,tt,{59:197,69:198,20:511,70:he}),r(ge,Se,{58:205,62:206,23:512,63:Xe}),{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},r(Kc,[2,363],{157:524,335:[1,525]}),r(c,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:p}),r(mg,[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:p}),{13:f,16:d,44:215,45:dg,55:220,82:H,87:p,89:vt,172:221,185:351,203:536,212:534,231:pg,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(c,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:p}),r(ge,[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:yP,87:p,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,276:ue,277:de,279:Ie,280:we,283:ve,285:Ae,308:h,346:nt,347:et,348:C,349:x,350:k,351:G}),r(Qc,[2,291]),r(Qc,[2,24]),r(Qc,[2,25]),{13:f,16:d,44:136,45:W,46:539,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Qc,[2,28]),r(ge,Se,{58:205,62:206,23:540,63:Xe}),r([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),r(Yc,[2,107]),{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,172:221,185:351,187:350,199:543,200:544,231:cn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(EP,[2,132]),r(hg,[2,425]),r(EP,[2,133]),{13:f,16:d,44:354,55:355,82:H,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:358,312:qn,313:545},r(ln,[2,54]),r(ln,[2,48]),r(zc,[2,342]),{13:f,16:d,44:39,55:40,87:p,139:546,307:43,308:h},r(zc,[2,68]),r(S,[2,350],{31:vP,112:vP}),r(ln,[2,53]),{13:f,16:d,55:547,307:43,308:h},r(O,[2,333]),r(le,[2,16]),r(sg,[2,152]),r(yu,[2,154]),r(yu,[2,157]),r(_u,[2,159]),r(_u,[2,160],{262:389,261:548,39:nE,338:iE}),r(_u,[2,161],{262:389,261:549,39:nE,338:iE}),r(Hr,[2,163]),{13:f,16:d,44:136,45:W,46:550,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,178]),r(Ar,[2,179]),{13:f,16:d,44:136,45:W,46:551,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:552,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:553,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{48:[1,554],272:[1,555]},r(Ar,[2,184]),r(Ar,[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:Vt,223:562,307:43,308:h},r(aE,[2,224]),r(aE,[2,225]),r(aE,[2,226]),{31:[1,563],45:TP,94:564},r(Te,[2,84]),r(ag,[2,368]),r(Te,[2,85]),r(cg,[2,370]),r(ap,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},r(Ha,[2,35],{83:[1,569]}),r(Ha,[2,36],{81:[1,570]}),r(tE,[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:W,76:bP,78:SP,87:p,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,276:ue,277:de,279:Ie,280:we,283:ve,285:Ae,308:h,346:nt,347:et,348:C,349:x,350:k,351:G}),r(Su,[2,295]),{45:W,77:572},{45:W,77:573},r(Su,[2,33]),r(Su,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},r(Kc,[2,356]),r(AP,[2,357],{152:578,335:[1,579]}),r(No,[2,74]),{29:me,57:580},{29:me,57:581},{13:f,16:d,44:39,55:40,87:p,139:582,307:43,308:h},r(IP,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:W,55:323,67:321,68:322,77:320,79:585,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},{45:[1,586]},r(No,[2,81]),{29:me,57:587},r(Kc,[2,73]),r(S,[2,362],{29:ko,31:ko,85:ko,112:ko,159:ko,160:ko,161:ko,163:ko,164:ko}),r(mg,[2,112]),r(wu,[2,401],{206:588}),r(S,[2,405],{209:589,210:590}),r(S,[2,403]),r(S,[2,404]),r(mg,[2,113]),r(mg,[2,400]),{13:f,16:d,44:215,45:dg,48:[1,591],55:220,82:H,87:p,89:vt,172:221,185:351,203:536,212:592,231:pg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(hg,[2,426]),r(oE,[2,138]),r(oE,[2,139]),{232:[1,593]},r(Qc,[2,292]),{47:[1,595],48:[1,594]},r(bu,[2,9]),r(Yc,[2,392]),r(Yc,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:p,197:Hc,308:h}),r(Yc,[2,110],{272:[1,598]}),r(gg,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},r(qa,[2,58]),r(Hr,[2,445]),r(Hr,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},r(Ar,[2,99]),r(Ir,[2,382]),r([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]),r(Ar,[2,188]),r(Ar,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:H,172:493,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,311:494,312:qn,315:611},r(Te,[2,42]),r(ap,[2,304]),{13:f,16:d,55:414,82:H,95:612,171:613,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},{31:[1,614],45:TP,94:615},r(Qs,[2,129]),r(mP,[2,421]),{82:[1,616]},{82:[1,617]},r(Su,[2,296]),r(Su,[2,31]),r(Su,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},r(S,dP,{155:330,153:618,154:619,29:Mo,31:Mo,85:Mo,112:Mo,159:Mo,160:Mo,161:Mo,163:Mo,164:Mo}),r(AP,[2,358]),r(No,[2,75]),r(No,[2,76]),{29:me,57:620},{13:f,16:d,44:39,55:40,87:p,139:621,307:43,308:h},r(IP,[2,366]),r(No,[2,79]),{13:f,16:d,44:136,45:W,46:622,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(No,[2,91],{336:[1,623]}),r([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),r(wu,[2,117]),{13:f,16:d,44:215,45:dg,55:220,82:H,87:p,89:vt,172:221,185:351,203:536,211:626,212:627,231:pg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(Lo,[2,134]),r(hg,[2,427]),r(Lo,[2,135]),r(Qc,[2,26]),{44:628,87:p},r(Yc,[2,106]),r(Yc,[2,394]),r(S,[2,396]),r(gg,[2,111]),r(gg,[2,398]),{13:f,16:d,44:39,55:40,87:p,139:342,186:629,190:340,195:341,197:Hc,307:43,308:h},r(rE,[2,217]),r(S,ig,{144:248,140:630,143:631,31:[2,343]}),r(Ar,[2,97]),r(Ir,[2,380]),r(Ar,[2,180]),{13:f,16:d,44:136,45:W,46:632,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:633,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:de,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:H,171:637,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},r(RP,[2,305]),r(Te,[2,86]),r(ap,[2,374]),r(Ha,[2,37]),r(Ha,[2,38]),r(Kc,[2,72]),r(Kc,[2,360]),r(No,[2,77]),{29:me,57:638},{47:[1,639]},{29:[2,376]},r(wu,[2,402]),r(wu,[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:p}),r(wu,[2,118],{272:[1,641]}),r(yg,[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:Fe,304:Ve,305:Ce,306:je},r(op,[2,218]),r(ap,[2,44]),r(RP,[2,306]),r(No,[2,78]),{44:651,87:p},r(wu,[2,116]),r(S,[2,406]),r(yg,[2,119]),r(yg,[2,408]),r(c,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:p}),r(Qc,[2,27]),r(gg,[2,230]),r(CP,[2,345],{141:653,335:[1,654]}),r(Ar,[2,181]),r(Ar,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},r(S,ig,{144:248,142:657,143:658,31:xP,112:xP}),r(CP,[2,346]),r(No,[2,80]),r(yg,[2,231]),r(zc,[2,67]),r(zc,[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(j,B){if(B.recoverable)this.trace(j);else{var X=new Error(j);throw X.hash=B,X}},"parseError"),parse:a(function(j){var B=this,X=[0],Oe=[],Je=[null],E=[],zn=this.table,A="",Zs=0,fp=0,wg=0,Eg=2,dp=1,vg=E.slice.call(arguments,1),cr=Object.create(this.lexer),eo={yy:{}};for(var pp in this.yy)Object.prototype.hasOwnProperty.call(this.yy,pp)&&(eo.yy[pp]=this.yy[pp]);cr.setInput(j,eo.yy),eo.yy.lexer=cr,eo.yy.parser=this,typeof cr.yylloc>"u"&&(cr.yylloc={});var Iu=cr.yylloc;E.push(Iu);var Gt=cr.options&&cr.options.ranges;typeof eo.yy.parseError=="function"?this.parseError=eo.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function rr(to){X.length=X.length-2*to,Je.length=Je.length-to,E.length=E.length-to}a(rr,"popStack");for(var Tt=a(function(){var to;return to=cr.lex()||dp,typeof to!="number"&&(to=B.symbols_[to]||to),to},"lex"),Dt,pi,el,Yi,U0e,SE,Ru={},Tg,Uo,BP,Ag;;){if(el=X[X.length-1],this.defaultActions[el]?Yi=this.defaultActions[el]:((Dt===null||typeof Dt>"u")&&(Dt=Tt()),Yi=zn[el]&&zn[el][Dt]),typeof Yi>"u"||!Yi.length||!Yi[0]){var wE="";Ag=[];for(Tg in zn[el])this.terminals_[Tg]&&Tg>Eg&&Ag.push("'"+this.terminals_[Tg]+"'");cr.showPosition?wE="Parse error on line "+(Zs+1)+`:
|
|
35
|
+
`?e+="\\n":n==="\r"?e+="\\r":n===" "?e+="\\t":i<32||i===127?e+="\\x"+i.toString(16).toUpperCase().padStart(2,"0"):e+=n}return`"${e}"`}a(wD,"quoteYamlString");function kW(r,e=!1){return typeof r!="string"?String(r):SD(r,e)?wD(r):r}a(kW,"serializeYamlScalar")});var Nu=v(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.bytesToBase64=vD;Lu.base64ToBytes=TD;Lu.base64ToUtf8=MW;Lu.utf8ToBase64=jW;var ED=32768;function vD(r){let e="";for(let t=0;t<r.length;t+=ED)e+=String.fromCharCode(...r.subarray(t,t+ED));return btoa(e)}a(vD,"bytesToBase64");function TD(r){let e=r.replace(/\s/g,""),t=e.length%4,n=t===2||t===3?e+"=".repeat(4-t):e,i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}a(TD,"base64ToBytes");function MW(r){return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(TD(r))}a(MW,"base64ToUtf8");function jW(r){return vD(new TextEncoder().encode(r))}a(jW,"utf8ToBase64")});var Up=v(i1=>{"use strict";Object.defineProperty(i1,"__esModule",{value:!0});i1.iriToObsidianName=UW;var $W=Qt();function UW(r){let e=$W.Namespace.fromTermIRI(r);if(e)return`${e.namespace.prefix}__${e.localName}`;let t=r.match(/\/([^/]+)\.md$/);return t?t[1]:null}a(UW,"iriToObsidianName")});var AD=v(vy=>{"use strict";Object.defineProperty(vy,"__esModule",{value:!0});vy.mergePropertyDefaults=BW;vy.mergeInheritanceRules=VW;function BW(r,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.propertyName);o?(n.push(o),i.add(o.propertyName)):n.push(s)}for(let s of e)i.has(s.propertyName)||n.push(s);return n}a(BW,"mergePropertyDefaults");function VW(r,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.targetPropertyName);o?(n.push(o),i.add(o.targetPropertyName)):n.push(s)}for(let s of e)i.has(s.targetPropertyName)||n.push(s);return n}a(VW,"mergeInheritanceRules")});var s1=v((kwe,ID)=>{var ku=class{static{a(this,"Wildcard")}constructor(){return GW||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(ku.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(ku.prototype,"termType",{enumerable:!0,value:"Wildcard"});var GW=new ku;ID.exports.Wildcard=ku});var CD=v((jwe,RD)=>{var qW=(function(){var r=a(function($,j,B,X){for(B=B||{},X=$.length;X--;B[$[X]]=j);return B},"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],n=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],c=[13,16,45,197,224,229,308],l=[28,29,53],u=[28,53],f=[1,42],d=[1,45],p=[1,41],h=[1,44],m=[123,126],g=[1,67],_=[39,45,87],b=[13,16,45,197,224,308],T=[1,87],I=[2,281],w=[1,86],S=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],R=[6,28,29,53,63,70,73,81,83,85],L=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],P=[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],M=[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],O=[13,16,308],F=[112,132,327,334],Z=[13,16,112,132,308],J=[1,111],U=[1,117],K=[112,132,327,328,334],_e=[13,16,112,132,308,328],le=[28,29,45,53,87],W=[1,138],H=[1,151],oe=[1,128],xe=[1,127],re=[1,129],Q=[1,140],ie=[1,141],Y=[1,142],ae=[1,143],Me=[1,144],N=[1,145],ue=[1,147],fe=[1,148],Ie=[2,457],we=[1,158],ve=[1,159],Ae=[1,160],pe=[1,152],V=[1,153],D=[1,156],z=[1,171],se=[1,172],be=[1,173],Re=[1,174],Be=[1,175],De=[1,176],Fe=[1,167],Ve=[1,168],Ce=[1,169],je=[1,170],Ze=[1,157],nt=[1,166],et=[1,161],C=[1,162],x=[1,163],k=[1,164],G=[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],Vt=[1,195],Kt=[6,31,73,81,83,85],tt=[2,285],he=[1,199],me=[1,201],ge=[6,31,70,73,81,83,85],Se=[2,283],Xe=[1,207],Et=[1,218],vt=[1,223],cn=[1,219],di=[1,225],Fi=[1,226],qn=[1,224],eP=[6,63,70,73,81,83,85],tP=[1,236],rP=[2,334],nP=[1,243],iP=[1,241],ln=[6,193],ig=[2,349],sP=[2,339],qa=[28,128],oP=[47,48,193,272],sg=[47,48,193,242,272],yu=[47,48,193,242,246,272],_u=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Hr=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],aP=[1,271],cP=[1,270],Ar=[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],lP=[1,281],uP=[1,280],Wn=[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],ip=[45,89],og=[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],ag=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],cg=[31,89],lg=[48,87],Wc=[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],Qs=[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],fP=[1,313],bu=[6,85],tE=[6,31,81,83,85],dP=[2,361],Fo=[2,353],Hc=[1,343],sp=[31,112,335],Lo=[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],rE=[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],pP=[6,109,193],zc=[31,112],Ir=[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],nE=[1,390],iE=[1,391],Wa=[13,16,87,197,308,314],hP=[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],ug=[1,417],fg=[1,418],mP=[13,16,48,197,229,308],Ha=[6,31,85],gP=[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],sE=[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],Kc=[29,31,85,112,159,160,161,163,164],dg=[1,443],pg=[1,444],yP=[1,449],Yc=[31,112,193,232,318,335],hg=[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],_P=[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],oE=[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],op=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],ap=[31,45],bP=[1,507],SP=[1,508],wP=[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],mg=[29,31,85,112,159,160,161,163,164,335],Qc=[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],EP=[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],vP=[2,352],aE=[13,16,197,308,314],TP=[1,565],Su=[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],AP=[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],No=[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],IP=[13,16,87,308],ko=[2,364],wu=[29,31,85,112,159,160,161,163,164,193,232,318,335],gg=[31,112,193,232,272,318,335],Mo=[2,359],RP=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],yg=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],CP=[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],xP=[2,347],cE={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(j,B,X,Oe,Je,E,zn){var A=E.length-1;switch(Je){case 1:if(E[A-1]=E[A-1]||{},it.base&&(E[A-1].base=it.base),it.base="",E[A-1].prefixes=it.prefixes,it.prefixes=null,it.pathOnly){if(E[A-1].type==="path"||"termType"in E[A-1])return E[A-1];throw new Error("Received full SPARQL query in path only mode")}else if(E[A-1].type==="path"||"termType"in E[A-1])throw new Error("Received only path in full SPARQL mode");if(E[A-1].type==="update"){let Gt={};for(let rr of E[A-1].updates)if(rr.updateType==="insert"){let Tt={};for(let Dt of rr.insert)if(Dt.type==="bgp"||Dt.type==="graph")for(let pi of Dt.triples)pi.subject.termType==="BlankNode"&&(Tt[pi.subject.value]=!0),pi.predicate.termType==="BlankNode"&&(Tt[pi.predicate.value]=!0),pi.object.termType==="BlankNode"&&(Tt[pi.object.value]=!0);for(let Dt of Object.keys(Tt)){if(Gt[Dt])throw new Error("Detected reuse blank node across different INSERT DATA clauses");Gt[Dt]=!0}}}return E[A-1];case 2:this.$={...E[A-1],...E[A],type:"query"};break;case 4:it.base=cp(E[A]);break;case 5:it.prefixes||(it.prefixes={}),E[A-1]=E[A-1].substr(0,E[A-1].length-1),E[A]=cp(E[A]),it.prefixes[E[A-1]]=E[A];break;case 6:this.$={...E[A-3],...Zc(E[A-2]),...E[A-1],...E[A]};break;case 7:if(!it.skipValidation&&(gE(E[A-3].variables.map(rr=>mE(rr.expression))).some(rr=>rr.aggregation==="count"&&!(rr.expression instanceof _g))||E[A].group)){for(let rr of E[A-3].variables)if(rr.termType==="Variable"){if(!E[A].group||!E[A].group.map(Tt=>Au(Tt)).includes(Au(rr)))throw Error("Projection of ungrouped variable (?"+Au(rr)+")")}else if(mE(rr.expression).length===0){let Tt=d8(rr.expression);for(let Dt of Tt)if(!E[A].group||!E[A].group.map||!E[A].group.map(pi=>Au(pi)).includes(Au(Dt)))throw Error("Use of ungrouped variable in projection of operation (?"+Au(Dt)+")")}}let eo=E[A-1].where.filter(Gt=>Gt.type==="query");if(eo.length>0){let Gt=E[A-3].variables.filter(Tt=>Tt.variable&&Tt.variable.value).map(Tt=>Tt.variable.value),rr=gE(eo.map(Tt=>Tt.variables)).map(Tt=>Tt.value||Tt.variable.value);for(let Tt of Gt)if(rr.indexOf(Tt)>=0)throw Error("Target id of 'AS' (?"+Tt+") already used in subquery")}this.$=yr(E[A-3],Zc(E[A-2]),E[A-1],E[A]);break;case 8:this.$=yr({queryType:"CONSTRUCT",template:E[A-3]},Zc(E[A-2]),E[A-1],E[A]);break;case 9:this.$=yr({queryType:"CONSTRUCT",template:E[A-2]=E[A-2]?E[A-2].triples:[]},Zc(E[A-5]),{where:[{type:"bgp",triples:Jc([],E[A-2])}]},E[A]);break;case 10:this.$=yr({queryType:"DESCRIBE",variables:E[A-3]==="*"?[new _g]:E[A-3]},Zc(E[A-2]),E[A-1],E[A]);break;case 11:this.$=yr({queryType:"ASK"},Zc(E[A-2]),E[A-1],E[A]);break;case 12:this.$=yr(E[A-1],{variables:[new _g]});break;case 13:let pp=E[A].map(Gt=>Gt.value||Gt.variable.value),Iu=p8(pp);if(Iu.length>0)throw Error("Two or more of the resulting columns have the same name (?"+Iu[0]+")");this.$=yr(E[A-1],{variables:E[A]});break;case 14:this.$=yr({queryType:"SELECT"},E[A]&&(E[A-1]=Hn(E[A]),E[A]={},E[A][E[A-1]]=!0,E[A]));break;case 16:case 27:this.$=Eu(E[A-3],{variable:E[A-1]});break;case 17:case 18:this.$=yr(E[A-3],E[A-2],E[A-1],E[A],{type:"query"});break;case 19:case 58:this.$={iri:E[A],named:!!E[A-1]};break;case 20:this.$={where:E[A].patterns};break;case 21:this.$=yr(E[A-1],E[A]);break;case 22:this.$=yr(E[A-2],E[A-1],E[A]);break;case 23:this.$={group:E[A]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Eu(E[A]);break;case 26:this.$=Eu(E[A-1]);break;case 29:this.$={having:E[A]};break;case 30:this.$={order:E[A]};break;case 32:this.$=Eu(E[A],{descending:!0});break;case 35:this.$={limit:Tu(E[A])};break;case 36:this.$={offset:Tu(E[A])};break;case 37:this.$={limit:Tu(E[A-2]),offset:Tu(E[A])};break;case 38:this.$={limit:Tu(E[A]),offset:Tu(E[A-2])};break;case 39:case 43:this.$={type:"values",values:E[A]};break;case 40:case 84:this.$=E[A-1].map(Gt=>({[E[A-3]]:Gt}));break;case 41:case 85:this.$=E[A-1].map(()=>({}));break;case 42:case 86:var Zs=E[A-4].length;E[A-4]=E[A-4].map(lE),this.$=E[A-1].map(function(Gt){if(Gt.length!==Zs)throw Error("Inconsistent VALUES length");for(var rr={},Tt=0;Tt<Zs;Tt++)rr["?"+E[A-4][Tt].value]=Gt[Tt];return rr});break;case 44:case 65:case 100:case 126:case 175:this.$=E[A-1];break;case 45:this.$={type:"update",updates:jo(E[A-2],E[A-1])};break;case 46:this.$=yr({type:"load",silent:!!E[A-2],source:E[A-1]},E[A]&&{destination:E[A]});break;case 47:this.$={type:Hn(E[A-2]),silent:!!E[A-1],graph:E[A]};break;case 48:this.$={type:Hn(E[A-4]),silent:!!E[A-3],source:E[A-2],destination:E[A]};break;case 49:this.$={type:"create",silent:!!E[A-2],graph:{type:"graph",name:E[A]}};break;case 50:this.$={updateType:"insert",insert:UP(E[A])};break;case 51:this.$={updateType:"delete",delete:bE(UP(E[A]))};break;case 52:this.$={updateType:"deletewhere",delete:bE(E[A])};break;case 53:this.$={updateType:"insertdelete",...E[A-4],...E[A-3],...Zc(E[A-2],"using"),where:E[A].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=E[A];break;case 55:this.$={delete:bE(E[A-1]),insert:E[A]||[]};break;case 56:this.$={delete:[],insert:E[A]};break;case 59:this.$={graph:E[A]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:E[A]};break;case 64:this.$={[Hn(E[A])]:!0};break;case 66:this.$=E[A-1]?Xs(E[A],[E[A-1]]):Xs(E[A]);break;case 67:var fp=yr(E[A-3]||{triples:[]},{type:"graph",name:E[A-5]});this.$=E[A]?[fp,E[A]]:[fp];break;case 68:case 73:this.$={type:"bgp",triples:Xs(E[A-2],[E[A-1]])};break;case 69:this.$={type:"group",patterns:[E[A-1]]};break;case 70:for(let Gt of E[A-1].filter(rr=>rr.type==="bind")){let rr=E[A-1].indexOf(Gt),Tt=new Set;for(let Dt of E[A-1].slice(0,rr))(Dt.type==="group"||Dt.type==="bgp")&&jP(Dt).forEach(pi=>Tt.add(pi));if(Tt.has(Gt.variable.value))throw Error("Variable used to bind is already bound (?"+Gt.variable.value+")")}this.$={type:"group",patterns:E[A-1]};break;case 71:this.$=E[A-1]?Xs([E[A-1]],E[A]):Xs(E[A]);break;case 72:this.$=E[A]?[E[A-2],E[A]]:E[A-2];break;case 75:this.$=yr(E[A],{type:"optional"});break;case 76:this.$=yr(E[A],{type:"minus"});break;case 77:this.$=yr(E[A],{type:"graph",name:E[A-1]});break;case 78:this.$=yr(E[A],{type:"service",name:E[A-1],silent:!!E[A-2]});break;case 79:this.$={type:"filter",expression:E[A]};break;case 80:this.$={type:"bind",variable:E[A-1],expression:E[A-3]};break;case 89:this.$=up(E[A]);break;case 90:this.$=void 0;break;case 91:this.$=E[A-1].length?{type:"union",patterns:Xs(E[A-1].map(fE),[fE(E[A])])}:E[A];break;case 95:this.$={...E[A],function:E[A-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:jo(E[A-2],E[A-1]),distinct:!!E[A-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.$=jo(E[A-2],E[A-1]);break;case 101:this.$=Xs(E[A-2],[E[A-1]]);break;case 102:case 112:this.$=_E(E[A].map(Gt=>yr($o(E[A-1]),Gt)));break;case 103:this.$=_E(Jc(E[A].map(Gt=>yr($o(E[A-1].entity),Gt)),E[A-1].triples));break;case 105:this.$=Xs([E[A-1]],E[A]);break;case 106:this.$=Xs(E[A]);break;case 107:this.$=hE(E[A-1],E[A]);break;case 109:case 237:this.$=it.factory.namedNode(r8);break;case 110:case 118:this.$=jo(E[A-1],E[A]);break;case 111:this.$=E[A]?{annotation:E[A],object:E[A-1]}:E[A-1];break;case 113:this.$=E[A]?_E(Jc(E[A].map(Gt=>yr($o(E[A-1].entity),Gt)),E[A-1].triples)):E[A-1].triples;break;case 114:this.$=hE(...E[A-1],E[A]);break;case 116:this.$=hE(...E[A]);break;case 117:case 159:case 163:this.$=[E[A-1],E[A]];break;case 119:this.$=E[A]?{object:E[A-1],annotation:E[A]}:E[A-1];break;case 120:this.$=E[A-1].length?vu("|",jo(E[A-1],E[A])):E[A];break;case 121:this.$=E[A-1].length?vu("/",jo(E[A-1],E[A])):E[A];break;case 122:this.$=E[A]?vu(E[A],[E[A-1]]):E[A-1];break;case 123:this.$=E[A-1]?vu(E[A-1],[E[A]]):E[A];break;case 125:case 131:this.$=vu(E[A-1],[E[A]]);break;case 129:this.$=vu("|",jo(E[A-2],E[A-1]));break;case 132:case 134:this.$=u8(E[A-1]);break;case 133:case 135:this.$=f8(E[A-1]);break;case 140:this.$={entity:E[A],triples:[]};break;case 145:this.$=lE(E[A]);break;case 149:this.$=it.factory.namedNode(OP);break;case 151:case 153:case 158:case 162:this.$=uE(E[A-1],E[A]);break;case 152:this.$=["||",E[A]];break;case 154:this.$=["&&",E[A]];break;case 156:this.$=un(E[A-1],[E[A-2],E[A]]);break;case 157:this.$=un(E[A-2]?"notin":"in",[E[A-3],E[A]]);break;case 160:this.$=["+",uE(E[A-1],E[A])];break;case 161:var wg=Js(E[A-1].value.replace("-",""),E[A-1].datatype);this.$=["-",uE(wg,E[A])];break;case 164:this.$=un("UPLUS",[E[A]]);break;case 165:this.$=un(E[A-1],[E[A]]);break;case 166:this.$=un("UMINUS",[E[A]]);break;case 177:this.$=un(Hn(E[A-1]));break;case 178:this.$=un(Hn(E[A-3]),[E[A-1]]);break;case 179:this.$=up(un(Hn(E[A-3]),[E[A-1]]));break;case 180:this.$=un(Hn(E[A-5]),[E[A-3],E[A-1]]);break;case 181:this.$=un(Hn(E[A-7]),[E[A-5],E[A-3],E[A-1]]);break;case 182:this.$=up(un(Hn(E[A-7]),[E[A-5],E[A-3],E[A-1]]));break;case 183:this.$=un(Hn(E[A-1]),E[A]);break;case 184:this.$=un("bound",[lE(E[A-1])]);break;case 185:this.$=un(E[A-1],[]);break;case 186:this.$=un(E[A-3],[E[A-1]]);break;case 187:this.$=un(E[A-2]?"notexists":"exists",[fE(E[A])]);break;case 188:case 189:this.$=Eu(E[A-1],{type:"aggregate",aggregation:Hn(E[A-4]),distinct:!!E[A-2]});break;case 190:this.$=Eu(E[A-2],{type:"aggregate",aggregation:Hn(E[A-5]),distinct:!!E[A-3],separator:typeof E[A-1]=="string"?E[A-1]:" "});break;case 192:this.$=Js(E[A]);break;case 193:this.$=o8(E[A-1],Hn(E[A].substr(1)));break;case 194:this.$=Js(E[A-2],E[A]);break;case 195:case 204:this.$=Js(E[A],PP);break;case 196:case 205:this.$=Js(E[A],DP);break;case 197:case 206:this.$=Js(Hn(E[A]),FP);break;case 200:this.$=Js(E[A].toLowerCase(),s8);break;case 201:this.$=Js(E[A].substr(1),PP);break;case 202:this.$=Js(E[A].substr(1),DP);break;case 203:this.$=Js(E[A].substr(1).toLowerCase(),FP);break;case 207:case 208:this.$=MP(E[A],1);break;case 209:case 210:this.$=MP(E[A],3);break;case 211:this.$=it.factory.namedNode(cp(E[A]));break;case 213:var Eg=E[A].indexOf(":"),dp=E[A].substr(0,Eg),vg=it.prefixes[dp];if(!vg)throw new Error("Unknown prefix: "+dp);var cr=cp(vg+E[A].substr(Eg+1));this.$=it.factory.namedNode(cr);break;case 214:if(E[A]=E[A].substr(0,E[A].length-1),!(E[A]in it.prefixes))throw new Error("Unknown prefix: "+E[A]);var cr=cp(it.prefixes[E[A]]);this.$=it.factory.namedNode(cr);break;case 215:this.$=lp(E[A].replace(/^(_:)/,""));break;case 216:this.$=lp();break;case 217:case 218:case 232:this.$=up(dE(E[A-3],E[A-2],E[A-1]));break;case 230:case 231:this.$=up(E[A-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:E[A-1].push(E[A]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[E[A]];break;case 308:E[A-3].push(E[A-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:E[A-2].push(E[A-1]);break}},"anonymous"),table:[r(e,t,{3:1,4:2,10:3}),{1:[3]},r(n,[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}),r([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]},r(c,[2,411],{216:28,217:29}),r(l,[2,249],{18:30}),r(l,[2,251],{22:31}),r(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:p,139:38,307:43,308:h,323:36},r(l,[2,267],{37:46}),r(m,[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:g,87:p},r(_,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),r(e,[2,248]),r(e,[2,245]),r(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]},r([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]}),r(b,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:T,29:I,52:84,53:w,56:85},{19:88,28:T,29:I,52:89,53:w,56:85},r(l,[2,253],{26:90}),{28:[1,91],52:92,53:w},r(S,[2,385],{181:93,182:94,183:95,31:[2,383]}),r(R,[2,263],{34:96}),r(R,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:p,308:h}),r(R,[2,262]),r(L,[2,259]),r(P,[2,143]),r(P,[2,144]),r([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]),r(M,[2,211]),r(M,[2,212]),r(M,[2,213]),r(M,[2,214]),{19:98,28:T,29:I,52:99,53:w,56:85},{6:[2,309],99:100,193:[1,101]},r(O,[2,311],{101:102,328:[1,103]}),r(F,[2,317],{104:104,328:[1,105]}),r(Z,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:J,114:110},{29:J,114:112},{29:J,114:113},{118:114,123:[1,115],125:116,126:U},r(K,[2,315]),r(K,[2,316]),r(_e,[2,319]),r(_e,[2,320]),r(_e,[2,321]),r(m,[2,327]),{13:f,16:d,55:118,307:43,308:h},r(l,[2,12]),r(l,[2,13],{44:66,43:119,45:g,87:p}),r(le,[2,269]),r(le,[2,15]),{13:f,16:d,44:136,45:W,46:120,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(_,[2,14]),r(_,[2,274]),r(_,[2,271]),r(_,[2,272]),r(e,[2,4]),{13:[1,177]},r(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},r(c,[2,410]),r([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:Vt,219:189,220:190,223:191,224:[1,192],307:43,308:h},r(b,[2,419]),r(Kt,tt,{20:196,59:197,69:198,70:he}),r(l,[2,250]),{29:me,57:200},r(O,[2,279],{54:202,327:[1,203]}),{29:[2,282]},r(ge,Se,{23:204,58:205,62:206,63:Xe}),r(l,[2,252]),{19:208,28:T,29:I,52:209,53:w,56:85},{29:[1,210]},r(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,145:212,172:221,185:213,187:214,231:cn,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(eP,[2,265],{56:85,35:227,52:228,19:229,28:T,29:I,53:w}),r(L,[2,260]),r(ge,Se,{58:205,62:206,23:230,63:Xe}),r(l,[2,268]),{6:[2,45]},r(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:h},r(O,[2,312]),{105:233,112:tP,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},r(F,[2,318]),r(O,rP,{108:240,133:242,112:nP,132:iP}),r(Z,[2,323]),{112:[1,244]},{112:[2,325]},r(ln,[2,50]),r(S,ig,{135:245,136:246,143:247,144:248,31:sP,112:sP}),r(ln,[2,51]),r(ln,[2,52]),r(qa,[2,328],{119:249}),{29:J,114:250},r(qa,[2,56]),{29:J,114:251},r(m,[2,59]),r(le,[2,270]),{47:[1,252]},r(oP,[2,150]),r(sg,[2,428],{240:253}),r(yu,[2,430],{244:254}),r(yu,[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]}),r(_u,[2,440],{252:264}),r(Hr,[2,448],{260:265}),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,255:154,257:155,264:266,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,255:154,257:155,264:267,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,255:154,257:155,264:268,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Hr,[2,167]),r(Hr,[2,168]),r(Hr,[2,169]),r(Hr,[2,170],{176:269,45:aP,89:cP}),r(Hr,[2,171]),r(Hr,[2,172]),r(Hr,[2,173]),r(Hr,[2,174]),{13:f,16:d,44:136,45:W,46:272,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:lP,89:uP,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},r(Wn,[2,192],{292:[1,286],293:[1,287]}),r(Wn,[2,195]),r(Wn,[2,196]),r(Wn,[2,197]),r(Wn,[2,198]),r(Wn,[2,199]),r(Wn,[2,200]),{13:f,16:d,44:39,55:40,82:H,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},r(ip,[2,452]),r(ip,[2,453]),r(ip,[2,454]),r(ip,[2,455]),r(ip,[2,456]),{279:[2,458]},r(og,[2,207]),r(og,[2,208]),r(og,[2,209]),r(og,[2,210]),r(Wn,[2,201]),r(Wn,[2,202]),r(Wn,[2,203]),r(Wn,[2,204]),r(Wn,[2,205]),r(Wn,[2,206]),r(e,[2,5]),r(ag,[2,297],{88:295}),r(cg,[2,299],{90:296}),{48:[1,297],87:[1,298]},r(lg,[2,301]),r(Te,[2,43]),r(Te,[2,82]),r(Te,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},r(c,[2,412]),r(Wc,[2,123]),r(Wc,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),r(Qs,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:Vt,223:312,225:308,226:309,229:fP,307:43,308:h},r(c,i,{215:10,214:314}),r(Qs,[2,236]),r(Qs,[2,237]),r(bu,[2,6]),r(tE,[2,287],{60:315,72:316,73:[1,317]}),r(Kt,[2,286]),{13:f,16:d,45:W,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},r([6,31,63,70,73,81,83,85],[2,20]),r(S,dP,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:Fo,31:Fo,85:Fo,112:Fo,159:Fo,160:Fo,161:Fo,163:Fo,164:Fo,41:s}),{13:f,16:d,55:331,307:43,308:h},r(O,[2,280]),r(bu,[2,7]),r(Kt,tt,{59:197,69:198,20:332,70:he}),r(ge,[2,284]),{64:[1,333]},r(ge,Se,{58:205,62:206,23:334,63:Xe}),r(l,[2,254]),r(S,ig,{144:248,30:335,143:336,31:[2,257]}),r(l,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:p,139:342,186:339,190:340,195:341,197:Hc,307:43,308:h},r(sp,[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:p,197:Hc,308:h}),r(Lo,[2,227]),r(Lo,[2,228]),r(Lo,[2,229]),{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,172:221,185:351,187:350,200:348,230:347,231:cn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},{13:f,16:d,44:39,55:40,87:p,139:342,186:352,190:340,195:341,197:Hc,307:43,308:h},r(Lo,[2,146]),r(Lo,[2,147]),r(Lo,[2,148]),r(Lo,[2,149]),{13:f,16:d,44:354,55:355,82:H,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:358,312:qn,313:353},r(rE,[2,215]),r(rE,[2,216]),r(ge,Se,{58:205,62:206,23:359,63:Xe}),r(R,[2,264]),r(eP,[2,266]),r(bu,[2,11]),r(n,[2,308],{6:[2,310]}),r(ln,[2,313],{102:360,120:361,121:[1,362]}),r(ln,[2,47]),r(ln,[2,63]),r(ln,[2,64]),{13:f,16:d,55:363,307:43,308:h},r(ln,[2,336]),r(ln,[2,337]),r(ln,[2,338]),{109:[1,364]},r(pP,[2,60]),{13:f,16:d,55:365,307:43,308:h},r(O,[2,335]),{13:f,16:d,55:366,307:43,308:h},{31:[1,367]},r(zc,[2,341],{137:368}),r(zc,[2,340]),{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,145:369,172:221,185:213,187:214,231:cn,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},{28:[1,370],127:371,128:[1,372]},r(qa,[2,330],{124:373,125:374,126:U}),r(qa,[2,57]),{44:375,87:p},r(oP,[2,151],{241:376,242:[1,377]}),r(sg,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,247:380,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{250:[1,381]},r(Ir,[2,432]),r(Ir,[2,433]),r(Ir,[2,434]),r(Ir,[2,435]),r(Ir,[2,436]),r(Ir,[2,437]),{250:[2,439]},r([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:z,298:se,299:be,300:Re,301:Be,302:De}),r(_u,[2,162],{261:388,262:389,39:nE,338:iE}),r(Hr,[2,164]),r(Hr,[2,165]),r(Hr,[2,166]),r(Ar,[2,95]),r(Ar,[2,96]),r(Ir,[2,377],{177:392,325:[1,393]}),{48:[1,394]},r(Ar,[2,177]),{13:f,16:d,44:136,45:W,46:395,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:396,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:397,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:398,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:399,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,183]),r(Ar,[2,98]),r(Ir,[2,381],{180:400}),{87:[1,401]},r(Ar,[2,185]),{13:f,16:d,44:136,45:W,46:402,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{29:me,57:403},r(Wn,[2,193]),{13:f,16:d,55:404,307:43,308:h},{13:f,16:d,44:39,55:40,87:p,139:342,195:405,197:Hc,307:43,308:h},r(Wa,[2,233]),r(Wa,[2,234]),r(Wa,[2,235]),r(hP,[2,459],{281:406,325:[1,407]}),r(Ir,[2,463],{284:408,325:[1,409]}),r(Ir,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:H,171:413,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},{31:[1,419],89:[1,420]},{29:[1,421]},r(lg,[2,302]),r(ag,[2,367],{167:422}),r(cg,[2,369],{168:423}),{48:[1,424],87:[1,425]},r(lg,[2,371]),r(Wc,[2,122]),r(Wc,[2,417]),r(Wc,[2,413]),r(Wc,[2,414]),r(Wc,[2,415]),r(Qs,[2,125]),r(Qs,[2,127]),r(Qs,[2,128]),r(mP,[2,420],{227:426}),r(Qs,[2,130]),{13:f,16:d,55:194,197:Vt,223:427,307:43,308:h},{48:[1,428]},r(Ha,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),r(tE,[2,288]),{64:[1,433]},r(Kt,[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:W,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,276:ue,277:fe,279:Ie,280:we,283:ve,285:Ae,308:h,346:nt,347:et,348:C,349:x,350:k,351:G}),r(gP,[2,293]),r(sE,[2,92]),r(sE,[2,93]),r(sE,[2,94]),{45:aP,89:cP,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:T,29:I,56:85},{19:438,28:T,29:I,56:85},r(Kc,[2,355],{149:439}),r(Kc,[2,354]),{13:f,16:d,44:215,45:dg,55:220,82:H,87:p,89:vt,156:440,172:221,185:441,203:442,231:pg,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(R,[2,19]),r(Ha,[2,21]),{13:f,16:d,44:450,45:yP,55:323,65:445,66:446,67:447,68:448,87:p,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},r(bu,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},r(S,[2,386],{31:[2,388]}),r(sp,[2,102]),r(Yc,[2,391],{191:452}),r(S,[2,395],{196:453,198:454}),r(S,[2,108]),r(S,[2,109]),r(sp,[2,103]),r(sp,[2,104]),r(sp,[2,390]),{13:f,16:d,44:215,45:Et,48:[1,455],55:220,82:H,87:p,89:vt,172:221,185:351,187:350,200:456,231:cn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(hg,[2,424]),r(_P,[2,136]),r(_P,[2,137]),r(oE,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:p,139:342,195:458,197:Hc,307:43,308:h},r(Wa,[2,219]),r(Wa,[2,220]),r(Wa,[2,221]),r(Wa,[2,222]),r(Wa,[2,223]),r(bu,[2,10]),r(ln,[2,46]),r(ln,[2,314]),{112:tP,122:459},r(ln,[2,62]),r(O,rP,{133:242,108:460,112:nP,132:iP}),r(pP,[2,61]),r(ln,[2,49]),r([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},r(zc,[2,351],{146:463,335:[1,464]}),{29:me,57:465},r(qa,[2,329]),r(O,[2,332],{129:466,327:[1,467]}),r(qa,[2,55]),r(qa,[2,331]),{48:[1,468]},r(sg,[2,429]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(yu,[2,431]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,243:470,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(yu,[2,156]),{45:lP,89:uP,179:471},r(_u,[2,441]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,251:472,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Hr,[2,444],{256:473}),r(Hr,[2,446],{258:474}),r(Ir,[2,442]),r(Ir,[2,443]),r(Hr,[2,449]),{13:f,16:d,44:136,45:W,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,255:154,257:155,259:475,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ir,[2,450]),r(Ir,[2,451]),r(Ir,[2,379],{178:476}),r(Ir,[2,378]),r([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:W,46:482,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{48:[1,483]},{48:[1,484]},r(Ar,[2,187]),r(Wn,[2,194]),{13:f,16:d,44:39,55:40,82:H,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,320:485},{13:f,16:d,39:[1,487],44:136,45:W,46:488,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,282:486,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(hP,[2,460]),{13:f,16:d,44:136,45:W,46:489,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ir,[2,464]),{13:f,16:d,44:136,45:W,46:490,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ir,[2,466]),r(Te,[2,40]),r(ag,[2,298]),r(op,[2,87]),r(op,[2,88]),r(op,[2,89]),r(op,[2,90]),{13:f,16:d,55:492,82:H,172:493,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,311:494,312:qn,315:491},r(Te,[2,41]),r(cg,[2,300]),r(ap,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:H,171:497,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},{31:[1,498],89:[1,499]},{29:[1,500]},r(lg,[2,372]),{13:f,16:d,48:[2,422],55:194,197:Vt,223:312,226:502,228:501,229:fP,307:43,308:h},r(Qs,[2,131]),r(Qs,[2,126]),r(Ha,[2,22]),r(Ha,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:W,55:323,67:321,68:322,74:505,75:506,76:bP,77:320,78:SP,79:509,87:p,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},r(gP,[2,294]),r(wP,[2,69]),r(wP,[2,70]),r(Kt,tt,{59:197,69:198,20:511,70:he}),r(ge,Se,{58:205,62:206,23:512,63:Xe}),{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},r(Kc,[2,363],{157:524,335:[1,525]}),r(c,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:p}),r(mg,[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:p}),{13:f,16:d,44:215,45:dg,55:220,82:H,87:p,89:vt,172:221,185:351,203:536,212:534,231:pg,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(c,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:p}),r(ge,[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:yP,87:p,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,276:ue,277:fe,279:Ie,280:we,283:ve,285:Ae,308:h,346:nt,347:et,348:C,349:x,350:k,351:G}),r(Qc,[2,291]),r(Qc,[2,24]),r(Qc,[2,25]),{13:f,16:d,44:136,45:W,46:539,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Qc,[2,28]),r(ge,Se,{58:205,62:206,23:540,63:Xe}),r([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),r(Yc,[2,107]),{13:f,16:d,44:215,45:Et,55:220,82:H,87:p,89:vt,172:221,185:351,187:350,199:543,200:544,231:cn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(EP,[2,132]),r(hg,[2,425]),r(EP,[2,133]),{13:f,16:d,44:354,55:355,82:H,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:358,312:qn,313:545},r(ln,[2,54]),r(ln,[2,48]),r(zc,[2,342]),{13:f,16:d,44:39,55:40,87:p,139:546,307:43,308:h},r(zc,[2,68]),r(S,[2,350],{31:vP,112:vP}),r(ln,[2,53]),{13:f,16:d,55:547,307:43,308:h},r(O,[2,333]),r(le,[2,16]),r(sg,[2,152]),r(yu,[2,154]),r(yu,[2,157]),r(_u,[2,159]),r(_u,[2,160],{262:389,261:548,39:nE,338:iE}),r(_u,[2,161],{262:389,261:549,39:nE,338:iE}),r(Hr,[2,163]),{13:f,16:d,44:136,45:W,46:550,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,178]),r(Ar,[2,179]),{13:f,16:d,44:136,45:W,46:551,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:552,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:553,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{48:[1,554],272:[1,555]},r(Ar,[2,184]),r(Ar,[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:Vt,223:562,307:43,308:h},r(aE,[2,224]),r(aE,[2,225]),r(aE,[2,226]),{31:[1,563],45:TP,94:564},r(Te,[2,84]),r(ag,[2,368]),r(Te,[2,85]),r(cg,[2,370]),r(ap,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},r(Ha,[2,35],{83:[1,569]}),r(Ha,[2,36],{81:[1,570]}),r(tE,[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:W,76:bP,78:SP,87:p,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,276:ue,277:fe,279:Ie,280:we,283:ve,285:Ae,308:h,346:nt,347:et,348:C,349:x,350:k,351:G}),r(Su,[2,295]),{45:W,77:572},{45:W,77:573},r(Su,[2,33]),r(Su,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},r(Kc,[2,356]),r(AP,[2,357],{152:578,335:[1,579]}),r(No,[2,74]),{29:me,57:580},{29:me,57:581},{13:f,16:d,44:39,55:40,87:p,139:582,307:43,308:h},r(IP,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:W,55:323,67:321,68:322,77:320,79:585,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,307:43,308:h,346:nt,347:et,348:C,349:x,350:k,351:G},{45:[1,586]},r(No,[2,81]),{29:me,57:587},r(Kc,[2,73]),r(S,[2,362],{29:ko,31:ko,85:ko,112:ko,159:ko,160:ko,161:ko,163:ko,164:ko}),r(mg,[2,112]),r(wu,[2,401],{206:588}),r(S,[2,405],{209:589,210:590}),r(S,[2,403]),r(S,[2,404]),r(mg,[2,113]),r(mg,[2,400]),{13:f,16:d,44:215,45:dg,48:[1,591],55:220,82:H,87:p,89:vt,172:221,185:351,203:536,212:592,231:pg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(hg,[2,426]),r(oE,[2,138]),r(oE,[2,139]),{232:[1,593]},r(Qc,[2,292]),{47:[1,595],48:[1,594]},r(bu,[2,9]),r(Yc,[2,392]),r(Yc,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:p,197:Hc,308:h}),r(Yc,[2,110],{272:[1,598]}),r(gg,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},r(qa,[2,58]),r(Hr,[2,445]),r(Hr,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},r(Ar,[2,99]),r(Ir,[2,382]),r([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]),r(Ar,[2,188]),r(Ar,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:H,172:493,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,311:494,312:qn,315:611},r(Te,[2,42]),r(ap,[2,304]),{13:f,16:d,55:414,82:H,95:612,171:613,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},{31:[1,614],45:TP,94:615},r(Qs,[2,129]),r(mP,[2,421]),{82:[1,616]},{82:[1,617]},r(Su,[2,296]),r(Su,[2,31]),r(Su,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},r(S,dP,{155:330,153:618,154:619,29:Mo,31:Mo,85:Mo,112:Mo,159:Mo,160:Mo,161:Mo,163:Mo,164:Mo}),r(AP,[2,358]),r(No,[2,75]),r(No,[2,76]),{29:me,57:620},{13:f,16:d,44:39,55:40,87:p,139:621,307:43,308:h},r(IP,[2,366]),r(No,[2,79]),{13:f,16:d,44:136,45:W,46:622,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(No,[2,91],{336:[1,623]}),r([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),r(wu,[2,117]),{13:f,16:d,44:215,45:dg,55:220,82:H,87:p,89:vt,172:221,185:351,203:536,211:626,212:627,231:pg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,309:di,310:Fi,311:217,312:qn},r(Lo,[2,134]),r(hg,[2,427]),r(Lo,[2,135]),r(Qc,[2,26]),{44:628,87:p},r(Yc,[2,106]),r(Yc,[2,394]),r(S,[2,396]),r(gg,[2,111]),r(gg,[2,398]),{13:f,16:d,44:39,55:40,87:p,139:342,186:629,190:340,195:341,197:Hc,307:43,308:h},r(rE,[2,217]),r(S,ig,{144:248,140:630,143:631,31:[2,343]}),r(Ar,[2,97]),r(Ir,[2,380]),r(Ar,[2,180]),{13:f,16:d,44:136,45:W,46:632,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},{13:f,16:d,44:136,45:W,46:633,55:133,67:132,68:134,77:131,82:H,87:p,172:135,224:oe,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:xe,264:130,265:re,266:137,267:139,268:Q,269:ie,270:Y,271:ae,273:Me,274:N,275:146,276:ue,277:fe,278:149,279:Ie,280:we,283:ve,285:Ae,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:x,350:k,351:G},r(Ar,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:H,171:637,172:415,173:416,174:ug,255:154,257:155,291:150,294:pe,295:V,296:D,297:z,298:se,299:be,300:Re,301:Be,302:De,303:Fe,304:Ve,305:Ce,306:je,307:43,308:h,312:fg},r(RP,[2,305]),r(Te,[2,86]),r(ap,[2,374]),r(Ha,[2,37]),r(Ha,[2,38]),r(Kc,[2,72]),r(Kc,[2,360]),r(No,[2,77]),{29:me,57:638},{47:[1,639]},{29:[2,376]},r(wu,[2,402]),r(wu,[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:p}),r(wu,[2,118],{272:[1,641]}),r(yg,[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:Fe,304:Ve,305:Ce,306:je},r(op,[2,218]),r(ap,[2,44]),r(RP,[2,306]),r(No,[2,78]),{44:651,87:p},r(wu,[2,116]),r(S,[2,406]),r(yg,[2,119]),r(yg,[2,408]),r(c,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:p}),r(Qc,[2,27]),r(gg,[2,230]),r(CP,[2,345],{141:653,335:[1,654]}),r(Ar,[2,181]),r(Ar,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},r(S,ig,{144:248,142:657,143:658,31:xP,112:xP}),r(CP,[2,346]),r(No,[2,80]),r(yg,[2,231]),r(zc,[2,67]),r(zc,[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(j,B){if(B.recoverable)this.trace(j);else{var X=new Error(j);throw X.hash=B,X}},"parseError"),parse:a(function(j){var B=this,X=[0],Oe=[],Je=[null],E=[],zn=this.table,A="",Zs=0,fp=0,wg=0,Eg=2,dp=1,vg=E.slice.call(arguments,1),cr=Object.create(this.lexer),eo={yy:{}};for(var pp in this.yy)Object.prototype.hasOwnProperty.call(this.yy,pp)&&(eo.yy[pp]=this.yy[pp]);cr.setInput(j,eo.yy),eo.yy.lexer=cr,eo.yy.parser=this,typeof cr.yylloc>"u"&&(cr.yylloc={});var Iu=cr.yylloc;E.push(Iu);var Gt=cr.options&&cr.options.ranges;typeof eo.yy.parseError=="function"?this.parseError=eo.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function rr(to){X.length=X.length-2*to,Je.length=Je.length-to,E.length=E.length-to}a(rr,"popStack");for(var Tt=a(function(){var to;return to=cr.lex()||dp,typeof to!="number"&&(to=B.symbols_[to]||to),to},"lex"),Dt,pi,el,Yi,U0e,SE,Ru={},Tg,Uo,BP,Ag;;){if(el=X[X.length-1],this.defaultActions[el]?Yi=this.defaultActions[el]:((Dt===null||typeof Dt>"u")&&(Dt=Tt()),Yi=zn[el]&&zn[el][Dt]),typeof Yi>"u"||!Yi.length||!Yi[0]){var wE="";Ag=[];for(Tg in zn[el])this.terminals_[Tg]&&Tg>Eg&&Ag.push("'"+this.terminals_[Tg]+"'");cr.showPosition?wE="Parse error on line "+(Zs+1)+`:
|
|
36
36
|
`+cr.showPosition()+`
|
|
37
37
|
Expecting `+Ag.join(", ")+", got '"+(this.terminals_[Dt]||Dt)+"'":wE="Parse error on line "+(Zs+1)+": Unexpected "+(Dt==dp?"end of input":"'"+(this.terminals_[Dt]||Dt)+"'"),this.parseError(wE,{text:cr.match,token:this.terminals_[Dt]||Dt,line:cr.yylineno,loc:Iu,expected:Ag})}if(Yi[0]instanceof Array&&Yi.length>1)throw new Error("Parse Error: multiple actions possible at state: "+el+", token: "+Dt);switch(Yi[0]){case 1:X.push(Dt),Je.push(cr.yytext),E.push(cr.yylloc),X.push(Yi[1]),Dt=null,pi?(Dt=pi,pi=null):(fp=cr.yyleng,A=cr.yytext,Zs=cr.yylineno,Iu=cr.yylloc,wg>0&&wg--);break;case 2:if(Uo=this.productions_[Yi[1]][1],Ru.$=Je[Je.length-Uo],Ru._$={first_line:E[E.length-(Uo||1)].first_line,last_line:E[E.length-1].last_line,first_column:E[E.length-(Uo||1)].first_column,last_column:E[E.length-1].last_column},Gt&&(Ru._$.range=[E[E.length-(Uo||1)].range[0],E[E.length-1].range[1]]),SE=this.performAction.apply(Ru,[A,fp,Zs,eo.yy,Yi[1],Je,E].concat(vg)),typeof SE<"u")return SE;Uo&&(X=X.slice(0,-1*Uo*2),Je=Je.slice(0,-1*Uo),E=E.slice(0,-1*Uo)),X.push(this.productions_[Yi[1]][0]),Je.push(Ru.$),E.push(Ru._$),BP=zn[X[X.length-2]][X[X.length-1]],X.push(BP);break;case 3:return!0}}return!0},"parse")},_g=s1().Wildcard,bg="http://www.w3.org/1999/02/22-rdf-syntax-ns#",r8=bg+"type",n8=bg+"first",i8=bg+"rest",OP=bg+"nil",Sg="http://www.w3.org/2001/XMLSchema#",PP=Sg+"integer",DP=Sg+"decimal",FP=Sg+"double",s8=Sg+"boolean",Xc="",LP="",NP="";function Hn($){return $.toLowerCase()}a(Hn,"lowercase");function jo($,j){return $.push(j),$}a(jo,"appendTo");function Jc($,j){return $.push.apply($,j),$}a(Jc,"appendAllTo");function yr($){$||($={});for(var j=1,B=arguments.length,X;j<B&&(X=arguments[j]||{});j++)for(var Oe in X)$[Oe]=X[Oe];return $}a(yr,"extend");function Xs(){for(var $=[],j=0,B=arguments.length;j<B;j++)$=$.concat.apply($,arguments[j]);return $}a(Xs,"unionAll");function cp($){if($[0]==="<"&&($=$.substring(1,$.length-1)),/^[a-z][a-z0-9.+-]*:/i.test($))return $;if(!it.base)throw new Error("Cannot resolve relative IRI "+$+" because no base IRI was set.");switch(Xc!==it.base&&(Xc=it.base,LP=Xc.replace(/[^\/:]*$/,""),NP=Xc.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),$[0]){case void 0:return Xc;case"#":return Xc+$;case"?":return Xc.replace(/(?:\?.*)?$/,$);case"/":return NP+$;default:return LP+$}}a(cp,"resolveIRI");function lE($){if($){var j=$[0];if(j==="?"||j==="$")return it.factory.variable($.substr(1))}return $}a(lE,"toVar");function un($,j){return{type:"operation",operator:$,args:j||[]}}a(un,"operation");function Eu($,j){var B={expression:$==="*"?new _g:$};if(j)for(var X in j)B[X]=j[X];return B}a(Eu,"expression");function vu($,j){return{type:"path",pathType:$,items:j}}a(vu,"path");function uE($,j){for(var B=0,X=j.length,Oe;B<X&&(Oe=j[B]);B++)$=un(Oe[0],[$,Oe[1]]);return $}a(uE,"createOperationTree");function Zc($,j){var B=[],X=[],Oe=$.length,Je,E={};if(!Oe)return null;for(var zn=0;zn<Oe&&(Je=$[zn]);zn++)(Je.named?X:B).push(Je.iri);return E[j||"from"]={default:B,named:X},E}a(Zc,"groupDatasets");function Tu($){return parseInt($,10)}a(Tu,"toInt");function fE($){return $.type==="group"&&$.patterns.length===1?$.patterns[0]:$}a(fE,"degroupSingle");function Js($,j){return j&&j.termType!=="NamedNode"&&(j=it.factory.namedNode(j)),it.factory.literal($,j)}a(Js,"createTypedLiteral");function o8($,j){return it.factory.literal($,j)}a(o8,"createLangLiteral");function dE($,j,B){if(!("termType"in j))throw new Error("Nested triples cannot contain paths");return it.factory.quad($,j,B)}a(dE,"nestedTriple");function $o($,j,B,X){var Oe={};return $!=null&&(Oe.subject=$),j!=null&&(Oe.predicate=j),B!=null&&(Oe.object=B),X!=null&&(Oe.annotations=X),Oe}a($o,"triple");function lp($){return typeof $=="string"?$.startsWith("e_")?it.factory.blankNode($):it.factory.blankNode("e_"+$):it.factory.blankNode("g_"+kP++)}a(lp,"blank");var kP=0;it._resetBlanks=function(){kP=0};var a8=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,c8={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
|
|
38
38
|
`,r:"\r",f:"\f"},l8=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,pE=String.fromCharCode;function MP($,j){$=$.substring(j,$.length-j);try{$=$.replace(a8,function(B,X,Oe,Je){var E;if(X){if(E=parseInt(X,16),isNaN(E))throw new Error;return pE(E)}else if(Oe){if(E=parseInt(Oe,16),isNaN(E))throw new Error;return E<65535?pE(E):pE(55296+((E-=65536)>>10),56320+(E&1023))}else{var zn=c8[Je];if(!zn)throw new Error;return zn}})}catch{return""}if(l8.exec($))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+$);return $}a(MP,"unescapeString");function u8($){var j=lp(),B=j,X=[],Oe,Je=[];$.forEach(function(Zs){X.push(Zs.entity),Jc(Je,Zs.triples)});for(var E=0,zn=0,A=X.length,Oe=Array(A*2);E<A;)Oe[zn++]=$o(B,it.factory.namedNode(n8),X[E]),Oe[zn++]=$o(B,it.factory.namedNode(i8),B=++E<A?lp():it.factory.namedNode(OP));return{entity:j,triples:Jc(Oe,Je)}}a(u8,"createList");function f8($){var j=lp();return{entity:j,triples:$.map(function(B){return yr($o(j),B)})}}a(f8,"createAnonymousObject");function hE($,j,B){var X=[],Oe=[];return j.forEach(function(Je){let E=null;Je.annotation&&(E=Je.annotation,Je=Je.object),X.push($o(null,$,Je.entity,E)),Jc(Oe,Je.triples)}),Xs(X,B||[],Oe)}a(hE,"objectListToTriples");function j0e($){for(var j=[],B,X=0,Oe;Oe=$[X];X++)Oe.type==="bgp"?Oe.triples.length&&(B?Jc(B.triples,Oe.triples):jo(j,B=Oe)):(!Oe.patterns||Oe.patterns.length>0)&&(jo(j,Oe),B=null);return j}a(j0e,"mergeAdjacentBGPs");function Au($){return $.variable?$.variable.value:$.value||$.expression.value}a(Au,"getExpressionId");function mE($){if(!$)return[];if($.type==="aggregate")return[$];if($.type==="operation"){let j=[];for(let B of $.args)j.push(...mE(B));return j}return[]}a(mE,"getAggregatesOfExpression");function d8($){let j=new Set,B=a(function(X){X&&(X.termType==="Variable"?j.add(X):X.type==="operation"&&X.args.forEach(B))},"visitExpression");return B($),j}a(d8,"getVariablesFromExpression");function gE($,j=1,B=[]){for(let X of $)j>0&&X instanceof Array?gE(X,j-1,B):B.push(X);return B}a(gE,"flatten");function yE($){return $.termType==="Variable"}a(yE,"isVariable");function jP($){if($.triples){let j=[];for(let B of $.triples)yE(B.subject)&&j.push(B.subject.value),yE(B.predicate)&&j.push(B.predicate.value),yE(B.object)&&j.push(B.object.value);return j}else if($.patterns){let j=[];for(let B of $.patterns)j.push(...jP(B));return j}return[]}a(jP,"getBoundVarsFromGroupGraphPattern");function p8($){let j=$.slice().sort(),B=[];for(let X=0;X<j.length-1;X++)j[X+1]==j[X]&&B.push(j[X]);return B}a(p8,"getDuplicatesInArray");function up($){if(!it.sparqlStar)throw new Error("SPARQL-star support is not enabled");return $}a(up,"ensureSparqlStar");function $P($,j,B){for(let X of j){let Oe=$o("subject"in X?X.subject:$,X.predicate,X.object);B.push(Oe),X.annotations&&$P(dE($,X.predicate,X.object),X.annotations,B)}}a($P,"_applyAnnotations");function _E($){if(it.sparqlStar){let j=[];return $.forEach(B=>{let X=$o(B.subject,B.predicate,B.object);j.push(X),B.annotations&&$P(dE(B.subject,B.predicate,B.object),B.annotations,j)}),j}return $}a(_E,"applyAnnotations");function $0e($){if(!it.sparqlStarNestedQuads)throw new Error("Lenient SPARQL-star support with nested quads is not enabled");return $}a($0e,"ensureSparqlStarNestedQuads");function UP($){for(let j of $){if(j.type==="graph"&&j.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(j.type==="bgp"||j.type==="graph"){for(let B of j.triples)if(B.subject.termType==="Variable"||B.predicate.termType==="Variable"||B.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return $}a(UP,"ensureNoVariables");function bE($){for(let j of $)if(j.type==="bgp"){for(let B of j.triples)if(B.subject.termType==="BlankNode"||B.predicate.termType==="BlankNode"||B.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return $}a(bE,"ensureNoBnodes");var h8=(function(){var $={EOF:1,parseError:a(function(B,X){if(this.yy.parser)this.yy.parser.parseError(B,X);else throw new Error(B)},"parseError"),setInput:a(function(j,B){return this.yy=B||this.yy||{},this._input=j,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 j=this._input[0];this.yytext+=j,this.yyleng++,this.offset++,this.match+=j,this.matched+=j;var B=j.match(/(?:\r\n?|\n).*/g);return B?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),j},"input"),unput:a(function(j){var B=j.length,X=j.split(/(?:\r\n?|\n)/g);this._input=j+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-B),this.offset-=B;var Oe=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),X.length-1&&(this.yylineno-=X.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:X?(X.length===Oe.length?this.yylloc.first_column:0)+Oe[Oe.length-X.length].length-X[0].length:this.yylloc.first_column-B},this.options.ranges&&(this.yylloc.range=[Je[0],Je[0]+this.yyleng-B]),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).
|
|
@@ -69,7 +69,7 @@ ${n}}`}default:throw new hf(`Unsupported operation type for SPARQL generation: $
|
|
|
69
69
|
`)}generateTriple(e){let t=this.generateElement(e.subject),n=this.generatePredicate(e.predicate),i=this.generateElement(e.object);return`${t} ${n} ${i}`}generatePredicate(e){return"pathType"in e?this.generatePropertyPath(e):this.generateElement(e)}generatePropertyPath(e){let t=e.items.map(n=>"pathType"in n?`(${this.generatePropertyPath(n)})`:`<${n.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}generateElement(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":{let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}case"blank":return`_:${e.value}`;default:throw new hf(`Unknown element type: ${e.type}`)}}generateValues(e,t){let n=" ".repeat(t);if(e.variables.length===0||e.bindings.length===0)return"";if(e.variables.length===1){let o=e.variables[0],c=e.bindings.map(l=>{let u=l[o];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ");return`${n}VALUES ?${o} { ${c} }`}let i=e.variables.map(o=>`?${o}`).join(" "),s=e.bindings.map(o=>`(${e.variables.map(l=>{let u=o[l];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ")})`);return`${n}VALUES (${i}) {
|
|
70
70
|
${s.map(o=>`${n} ${o}`).join(`
|
|
71
71
|
`)}
|
|
72
|
-
${n}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(n=>this.generateExpression(n)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),n=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${n})`:`${t} IN (${n})`}default:throw new hf(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let n of e.triples)this.collectVariablesFromTriple(n,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let n of e.variables)t.add(n);break;case"project":for(let n of e.variables)t.add(n);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let n of e.variables)t.add(n);for(let n of e.aggregates)t.add(n.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let n of e.operands)this.collectVariablesFromExpression(n,t);break;case"function":case"functionCall":for(let n of e.args)this.collectVariablesFromExpression(n,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let n of e.list)this.collectVariablesFromExpression(n,t);break}}};mf.SPARQLGenerator=bT});var yf=v(wi=>{"use strict";var qH=wi&&wi.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),WH=wi&&wi.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),NF=wi&&wi.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&qH(t,e,n[i]);return WH(t,e),t}})();Object.defineProperty(wi,"__esModule",{value:!0});wi.QueryExecutor=wi.ExoQLQueryExecutor=wi.QueryExecutorError=void 0;var HH=B1(),zH=g0(),KH=oT(),YH=cT(),QH=SF(),XH=EF(),JH=IF(),ZH=gT(),ez=CF(),tz=OF(),rz=FF(),nz=LF(),iz=$e(),sz=Qe(),oz=l0(),yn="http://www.w3.org/2001/XMLSchema#",az=new Set([`${yn}integer`,`${yn}decimal`,`${yn}float`,`${yn}double`,`${yn}nonPositiveInteger`,`${yn}negativeInteger`,`${yn}long`,`${yn}int`,`${yn}short`,`${yn}byte`,`${yn}nonNegativeInteger`,`${yn}unsignedLong`,`${yn}unsignedInt`,`${yn}unsignedShort`,`${yn}unsignedByte`,`${yn}positiveInteger`]),gf=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};wi.QueryExecutorError=gf;var T0=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let n=t.resolveClassHierarchy===!1?e:new rz.ClassHierarchyResolvingStore(e);this.tripleStore=n,this.bgpExecutor=new HH.BGPExecutor(n),this.filterExecutor=new zH.FilterExecutor,this.optionalExecutor=new KH.OptionalExecutor,this.unionExecutor=new YH.UnionExecutor,this.minusExecutor=new QH.MinusExecutor,this.valuesExecutor=new XH.ValuesExecutor,this.aggregateExecutor=new JH.AggregateExecutor,this.constructExecutor=new ZH.ConstructExecutor,this.serviceExecutor=new ez.ServiceExecutor(t.serviceConfig),this.graphExecutor=new tz.GraphExecutor(n),this.sparqlGenerator=new nz.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(n)}async evaluateExistsPattern(e,t){let n=this.substituteVariables(e,t);for await(let i of this.execute(n))if(t.merge(i)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let n of this.execute(e))t.push(n);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new gf(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let n=new Set;for(let o of t)for(let c of o.variables())n.add(c);let i=this.collectOperationVariables(e.right);if([...n].some(o=>i.has(o)))for(let o of t){let c=this.substituteVariables(e.right,o);for await(let l of this.execute(c)){let u=o.merge(l);u!==null&&(yield u)}}else{let o=[];for await(let c of this.execute(e.right))o.push(c);for(let c of t)for(let l of o){let u=c.merge(l);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>NF(Yo())),n=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(n.has(o)){let c=i.get(o);c!==void 0&&s.set(o,c)}yield s}}async*executeOrderBy(e){let t=[];for await(let n of this.execute(e.input))t.push(n);t.sort((n,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,n),c=this.getExpressionValue(s.expression,i),l=0;if(o===void 0&&c===void 0?l=0:o===void 0?l=1:c===void 0?l=-1:typeof o=="number"&&typeof c=="number"?l=o-c:l=String(o).localeCompare(String(c)),s.descending&&(l=-l),l!==0)return l}return 0});for(let n of t)yield n}async*executeSlice(e){let t=0,n=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=n){if(i!==void 0&&t-n>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeReduced(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let n=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of n)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of n)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let n of this.execute(e.input)){let i=n.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,n):this.evaluateExtendExpression(e.expression,n);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let n of this.execute(e.left))t.push(n);for(let n of t){let i=this.substituteVariables(e.right,n);for await(let s of this.execute(i)){let o=n.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let n=JSON.parse(JSON.stringify(e));return this.substituteInOperation(n,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let n=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(n.input&&(n.input=this.substituteInOperation(n.input,t)),n.left&&(n.left=this.substituteInOperation(n.left,t)),n.right&&(n.right=this.substituteInOperation(n.right,t)),n.pattern&&(n.pattern=this.substituteInOperation(n.pattern,t)),n.query&&(n.query=this.substituteInOperation(n.query,t)),n.where&&(n.where=this.substituteInOperation(n.where,t)),n.expression&&this.substituteInExpression(n.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.type==="variable"&&typeof e.name=="string"){let n=this.termToAlgebraNode(t.get(e.name));if(n!==null){delete e.name;for(let[i,s]of Object.entries(n))e[i]=s}}if(e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let n of e.operands)this.substituteInExpression(n,t);if(e.args)for(let n of e.args)this.substituteInExpression(n,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let n of e.list)this.substituteInExpression(n,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let n=this.termToAlgebraNode(t.get(e.value));if(n!==null)return n}return e}termToAlgebraNode(e){if(e==null)return null;let t=e;return e instanceof iz.IRI||t.termType==="NamedNode"?{type:"iri",value:e.value}:t.termType==="Literal"||typeof t.value=="string"?{type:"literal",value:t.value,datatype:t.datatype?.value??t._datatype?.value,language:t.language??t._language}:null}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(n,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{n.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(n,i):yield*this.execute(n)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:n}=await Promise.resolve().then(()=>NF(Yo()));yield new n;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let n=t.get(e.name);if(!n)return;if(n instanceof sz.Literal){let i=n.datatype?.value;if(i===`${yn}dayTimeDuration`)try{return oz.DateTimeFunctions.parseDayTimeDuration(n.value)}catch{return n.value}if(i&&az.has(i)){let s=parseFloat(n.value);if(!Number.isNaN(s))return s}return n.value}return n.value??n.id??String(n)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="bgp"&&n.triples)for(let i of n.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(n.type==="values"&&n.variables)for(let i of n.variables)t.add(i);n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.type==="extend"&&n.variable&&t.add(n.variable),n.input&&this.collectVarsFromOperation(n.input,t),n.left&&this.collectVarsFromOperation(n.left,t),n.right&&this.collectVarsFromOperation(n.right,t),n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.query&&this.collectVarsFromOperation(n.query,t),n.where&&this.collectVarsFromOperation(n.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let n=e;n.type==="variable"&&t.add(n.value),n.type==="quoted"&&(this.collectVarsFromElement(n.subject,t),this.collectVarsFromElement(n.predicate,t),this.collectVarsFromElement(n.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="variable"&&n.name&&t.add(n.name),n.type==="exists"&&n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.left&&this.collectVarsFromExpressionTree(n.left,t),n.right&&this.collectVarsFromExpressionTree(n.right,t),n.operands)for(let i of n.operands)this.collectVarsFromExpressionTree(i,t);if(n.args)for(let i of n.args)this.collectVarsFromExpressionTree(i,t);if(n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.list)for(let i of n.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new gf("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 gf("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};wi.ExoQLQueryExecutor=T0;wi.QueryExecutor=T0});var WF=v(Qo=>{"use strict";var cz=Qo&&Qo.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},lz=Qo&&Qo.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(Qo,"__esModule",{value:!0});Qo.CommandResolver=void 0;var uz=lt(),fz=$p(),dz=Fu(),dr=$e(),Jt=Qe(),q=Qt(),kF=Ka(),MF=bp(),pz=Nu(),jF=Up(),hz=/^[a-z][a-z0-9+.-]*:\/\//i,_f=xE(),$F=AD(),mz=Wu(),gz=Xu(),yz=yf(),Tl=10,A0="exo__Asset",_z=Tl+1,UF="08cec529-90eb-4d43-88de-ceecccea12b0",bz=q.Namespace.EXOCMD.term("SubstitutionToken").value,BF=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","targetClassSelf"]);function Sz(r,e){return`__SUBSTITUTE__${r}__${e}__`}a(Sz,"buildSubstitutionMarker");function wz(r,e,t){let n=(0,pz.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${r}__${e}__${n}__`}a(wz,"buildParameterisedMarker");var VF="3f28af98-c031-4718-8ba2-44ad0b012c52",Ez=q.Namespace.EXOCMD.term("TokenInvocation").value,GF="29e2c8f8-2d27-4e58-b467-2e85d46f8122",qF="universal-default-template",ST=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null}constructor(e,t=fz.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorDepthCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._fallbackWarnedKeys=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,n){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${n??""}`,o=this.multiCache.get(s);if(o)return o;let c=n?await this.expandPrototypeChain(n):void 0,l=await this.expandClassHierarchy(t),u=new Map;for(let[h,m]of l){let g=await this.resolveForAsset(e,h,c);for(let _ of g){let b=this.getBindingPriority(_.binding)===2?m:0,T=u.get(_.binding.id);(!T||b<T.depth)&&u.set(_.binding.id,{rc:_,depth:b})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let m of h.binding.overrides)f.add(m);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,m)=>{let g=this.getBindingPriority(h.rc.binding),_=this.getBindingPriority(m.rc.binding);return g!==_?g-_:h.depth!==m.depth?h.depth-m.depth:(h.rc.binding.order??100)-(m.rc.binding.order??100)});let p=d.map(h=>h.rc);return this.multiCache.set(s,p),p}async expandClassHierarchy(e){let t=new Map;for(let c of e){if(c===A0){t.set(c,new Set);continue}let l=[];try{l=await this.getClassAncestors(c)}catch{l=[]}t.set(c,new Set(l))}let n=a(c=>{for(let l of e)if(l!==c&&t.get(l)?.has(c)&&!t.get(c)?.has(l))return!0;return!1},"isAncestorOfSibling"),i=e.filter(c=>!n(c)),s=new Map,o=a((c,l)=>{let u=s.get(c);(u===void 0||l<u)&&s.set(c,l)},"setMin");for(let c of i){if(o(c,0),this.looksLikeUUID(c))try{let u=await this.resolveLabelByUID(c);u&&o(u,0)}catch{}if(c===A0)continue;let l=[];try{l=await this.getClassAncestorsWithDepth(c)}catch{l=[]}for(let{ref:u,depth:f}of l)o(u,f)}return s.has(A0)||s.set(A0,_z),s}async resolveForAsset(e,t,n){let i=typeof n=="string"?`s:${n}`:n?`c:${n.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let c=typeof n=="string"?await this.expandPrototypeChain(n):n,l=await this.findBindings(t,c,e),u=[];for(let f of l){let d=await this.loadCommand(f.commandRef,{targetClass:f.targetClass});if(!d)continue;let p=f.precondition?{...d,precondition:f.precondition}:d;u.push({command:p,binding:f})}return u.sort((f,d)=>{let p=this.getBindingPriority(f.binding),h=this.getBindingPriority(d.binding);return p!==h?p-h:(f.binding.order??100)-(d.binding.order??100)}),this.cache.set(s,u),u}async loadCommand(e,t){let n=await this.findSubjectByUID(e);if(!n||(await this.tripleStore.match(n,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_labelTemplate")),c=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_icon")),l=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(n),m=await this.loadLinkedGrounding(n,0,t);return m?{id:e,name:s,labelTemplate:o??void 0,icon:c??void 0,precondition:h??void 0,grounding:m,confirmMessage:l??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,n){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let c of s){let l=c.subject,u=await this.loadBindingDefinition(l);u&&this.bindingMatches(u,e,i,n)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command")),t=[],n=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let l=await this.loadCommand(c);if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command ${c} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_cliName")),d=u??f??c;if(n.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${c}`);continue}n.add(d),t.push({command:l,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear(),this.clearUniversalCache()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let n=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let c=await this.evaluateSelectSnippet(o,t);n=n.replace(s,c)}return n}extractPlaceholders(e){let t=[],n=0;for(;n<e.length;)if(e[n]==="{"){let i=1,s=n+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(n,s),c=e.slice(n+1,s-1);t.push({full:o,body:c})}n=s}else n++;return t}async evaluateSelectSnippet(e,t){try{let n=e.replace(/\$target/g,`<${t}>`),s=new mz.ExoQLParser().parse(n),c=new gz.ExoQLAlgebraTranslator().translate(s),u=await new yz.ExoQLQueryExecutor(this.tripleStore).executeAll(c);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let p=f.get(d[0]);return p?p instanceof Jt.Literal||p instanceof dr.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,q.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),c=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!c)return null;let l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),m=await this.getLinkedUIDs(e,q.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:n,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:c??void 0,position:l??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:m.length>0?m:void 0}}async loadLinkedStyle(e,t){let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(n.length>0){let s=n[0].object,o=null;if(s instanceof dr.IRI)o=s;else if(s instanceof Jt.Literal){let c=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(c)}if(o){let c=await this.loadStyleAsset(o);if(c)return c}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,q.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,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),c=this.coerceBoolean(o),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=l!==null?this.coerceLabelClass(l,t):void 0,f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_source")),m=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:n,variant:s,showIcon:c,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:m,inline:!1}}coerceVariant(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(_f.COMMAND_VARIANT_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${n}" not in whitelist [${_f.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(_f.LABEL_CLASS_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${n}" not in whitelist [${_f.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(_f.STYLE_SOURCE_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle source "${n}" not in whitelist [${_f.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,n,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&n){for(let s of n)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let n=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(n===i)return!0;let s=this.extractPathBasename(i);if(s&&s===n)return!0;let o=this.extractPathBasename(n);if(o&&o===i)return!0;let c=this.extractAlias(t);if(c&&n===c)return!0;let l=this.extractAlias(e);return!!(l&&l===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(n+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=await this.resolvePreconditionRef(n[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof dr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,n){let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid")),s=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(n>=Tl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||c.length>0||l.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||c.length>0){let m=o.length>0?"all":"any",g=o.length>0?o:c,_=[];for(let b of g)_.push(await this.loadChildPrecondition(b.object,p,n+1));return{id:i??"",label:s,composite:{op:m,children:_}}}let h=await this.loadChildPrecondition(l[0].object,p,n+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_hostFunction")),d=await this.loadPreconditionQueryRef(e);return!i||!u&&!f&&!d?null:{id:i,label:s,...u&&{sparqlAsk:u},...f&&{hostFunction:f},...d&&{query:d}}}async loadChildPrecondition(e,t,n){let i=await this.resolvePreconditionRef(e);if(!i){let c=e instanceof Jt.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(c,"")}let s=await this.loadPreconditionSubject(i,t,n);if(s)return s;let o=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let n=t[0].object;if(n instanceof dr.IRI)return await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_uid"))??void 0;if(n instanceof Jt.Literal)return this.normalizeWikilink(n.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,n){if(t>=Tl)return null;let i=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!n?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let c=await this.resolveGroundingRef(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(l&&this.matchesReference(l,n.targetClass))return this.loadGroundingDefinition(c,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${n.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof dr.IRI)return e;if(e instanceof Jt.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>=Tl)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!n)return null;let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let N=await this.resolveLabelByUID(o);if(!N)return this.logger.warn(`Grounding ${n}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=N}if(s===kF.GroundingType.SERVICE_CALL){let N=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceId"));N&&(o=N)}let c=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueRef")),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let N=await this.resolveLabelByUID(u);if(!N)return this.logger.warn(`Grounding ${n}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=N}else u&&(f=u);let d=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),m=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_appendExpression")),g=await this.getObsidianWikilinkValue(e,q.Namespace.EXOCMD.term("Grounding_isDefinedBy")),_=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),b=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetClass"));if(b&&!this.looksLikeUUID(b)){let N=await this.findUidByLabel(b);N&&(b=N)}let T=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetPrototype")),I=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetFolder")),w=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_linkBackProperty")),S=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_inputSchema")),R=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_incrementBy")),L=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_shiftDelta")),P;if(R!=null&&R!==""){let N=Number.parseInt(String(R),10);Number.isFinite(N)&&(P=N)}let M=await this.resolvePropertyDefaults(e,n),O=await this.resolveInheritanceRules(e,n),F=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_propertyDefaults"));F!==null&&F!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(n)&&(this.logger.warn(`Grounding ${n}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(n));let Z;s===kF.GroundingType.COMPOSITE&&(Z=await this.loadCompositeSteps(e,t+1));let J;if(S)try{let N=JSON.parse(S);N?.properties&&(J=Object.entries(N.properties).map(([ue,de])=>{let Ie=de.type,we=Ie==="string"?"text":Ie,ve=de.defaultValue!==void 0?de.defaultValue:de.default,Ae={name:ue,type:we,label:de.title??ue,required:Array.isArray(N.required)&&N.required.includes(ue)};return ve!=null&&(Ae.defaultValue=String(ve)),typeof de.targetClassUid=="string"&&(Ae.targetClassUid=de.targetClassUid),Ae}))}catch{}let U=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),K=U!==null&&String(U).trim().toLowerCase()==="true",_e=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_labelTemplate")),le=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_direction")),W;if(le!=null){let N=String(le).trim().toLowerCase();N==="forward"||N==="rollback"?W=N:N!==""&&this.logger.warn(`Grounding ${n}: exocmd__Grounding_direction value '${le}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let H=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_bodyTemplate")),oe=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_templateRef")),xe=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),re=xe!==null&&String(xe).trim().toLowerCase()==="true",Q=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),ie=Q!==null&&String(Q).trim().toLowerCase()==="true",Y=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_omitLabel")),ae=Y!==null&&String(Y).trim().toLowerCase()==="true",Me={id:n,label:i,type:s,targetProperty:o??void 0,targetValueRef:c??void 0,targetValueLiteral:l??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:m??void 0,sparqlUpdate:_??void 0,steps:Z,targetClass:b??void 0,targetPrototype:T??void 0,targetFolder:I??void 0,linkBackProperty:w??void 0,incrementBy:P,shiftDelta:L??void 0,propertyDefault:M.length>0?M:void 0,inheritanceRule:O.length>0?O:void 0,isDefinedBy:g??void 0,prefillLabelWithDate:K||void 0,labelTemplate:_e??void 0,direction:W,bodyTemplate:H??void 0,templateRef:oe??void 0,cloneTargetBody:re||void 0,targetsCreatedInstance:ie||void 0,omitLabel:ae||void 0};return J&&(Me.inputSchema=J),Me}async loadCompositeSteps(e,t){if(t>=Tl)return[];let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of n){let o=null;if(s.object instanceof dr.IRI)o=s.object;else if(s.object instanceof Jt.Literal){let l=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(l)}if(!o)continue;let c=await this.loadGroundingDefinition(o,t);c&&i.push(c)}return i}async resolvePropertyDefaults(e,t){let n=await this.resolvePropertyDefaultsForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,$F.mergePropertyDefaults)(i.propertyDefaults,n):n}async resolvePropertyDefaultsForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[];for(let o of i){let c=await this.resolveRefTripleObject(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("PropertyDefault_property"));if(!l){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(l)?await this.resolveLabelByUID(l):l;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${l}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(c,q.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 this.findUniversalSingleton();if(!e)return this.logger.debug("[CommandResolver] No exocmd__UniversalDefaultTemplate instance found in the store; universal property-defaults and inheritance-rules will not be applied. This verdict is cached until invalidateCache() is called \u2014 if the store was still warming up, the next invalidation re-resolves it."),this._universalCacheValue=null,null;let t=await this.resolvePropertyDefaultsForSubject(e,qF,q.Namespace.EXOCMD.term("Template_propertyDefault")),n=await this.resolveInheritanceRulesForSubject(e,qF,q.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:t,inheritanceRules:n},this._universalCacheValue}async findUniversalSingleton(){let e=q.Namespace.EXOCMD.term("UniversalDefaultTemplate"),t=e.value,i=(await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),e)).map(c=>c.subject).filter(c=>c instanceof dr.IRI);if(i.length>0)return this.pickUniversalSingleton(i);let s=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),void 0),o=[];for(let c of s){let l=!1;if(c.object instanceof dr.IRI)l=c.object.value===t||c.object.value.includes(GF);else if(c.object instanceof Jt.Literal){let u=this.unwrapWikilink(c.object.value);l=u==="exocmd__UniversalDefaultTemplate"||u===GF}l&&c.subject instanceof dr.IRI&&o.push(c.subject)}return this.pickUniversalSingleton(o)}pickUniversalSingleton(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=[...e].sort((n,i)=>n.value.localeCompare(i.value));return this.logger.warn(`Multiple UniversalDefaultTemplate singletons found (${t.length}); selecting deterministically by lexicographic UID order: ${t[0].value}`),t[0]}async resolveInheritanceRules(e,t){let n=await this.resolveInheritanceRulesForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,$F.mergeInheritanceRules)(i.inheritanceRules,n):n}async resolveInheritanceRulesForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[],o=t;for(let c of i){let l=await this.resolveRefTripleObject(c.object);if(!l)continue;let u=await this.resolveLabelRef(l,q.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(l,q.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(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let w=await this.getObsidianName(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!w||!w.trim()){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}this.looksLikeUUID(w)?(h=w,p=await this.resolveLabelByUID(w)??void 0):p=w}let m=await this.tripleStore.match(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),g=[],_=[],b=!1;for(let w of m){let S=null;if(w.object instanceof dr.IRI?S=this.iriToObsidianName(w.object.value)??w.object.value:w.object instanceof Jt.Literal&&(S=this.unwrapWikilink(w.object.value)),!S){b=!0;continue}if(this.looksLikeUUID(S)){_.push(S);let R=await this.resolveLabelByUID(S);R&&g.push(R)}else g.push(S)}if(b){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 T=await this.getLiteralValue(l,q.Namespace.EXOCMD.term("InheritanceRule_priority")),I=50;if(T!==null&&T!==""){let w=Number.parseInt(String(T),10);Number.isFinite(w)&&(I=w)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:g,targetClassExclusionUids:_,priority:I})}return s}async resolveRefTripleObject(e){if(e instanceof dr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let n=await this.getObsidianName(e,t);return n?this.looksLikeUUID(n)?this.resolveLabelByUID(n):n:null}async resolvePropertyDefaultValue(e,t,n){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let c=`${t}|${e}`;return this._fallbackWarnedKeys.has(c)||(this._fallbackWarnedKeys.add(c),this.logger.warn(this.capWarning(`Grounding ${t}: PropertyDefault '${n}' \u2192 value asset ${e} not in store; SKIPPING the property (the executor's own default applies). Previously this emitted a wikilink, i.e. a link written where a value belongs.`))),dz.STRING_SCALAR_PROPERTIES.has(n)?null:`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,n):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,n,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${n}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,n,i,s){let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let c=o.trim();return BF.has(c)?s!==void 0?wz(c,t,s):Sz(c,t):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${c}' \u2014 falling back to wikilink form. Known ids: ${Array.from(BF).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,n,i){let s=await this.getObsidianName(e,q.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let c=await this.findSubjectByUID(s);return c?this.dispatchSubstitutionToken(c,s,n,i,o):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof dr.IRI){if(i.object.value===Ez||i.object.value.includes(VF))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===VF)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("TokenInvocation_token"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as TokenInvocation via its exocmd__TokenInvocation_token property; exo__Instance_class was absent or unresolved.`),!0):!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof dr.IRI){if(i.object.value===bz||i.object.value.includes(UF))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===UF)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as SubstitutionToken via its resolver property; exo__Instance_class was absent or unresolved.`),!0):!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let n=t[0].object;if(n instanceof dr.IRI)return(0,MF.resolveGroundingTypeFromIRI)(n.value);if(n instanceof Jt.Literal){let i=n.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,MF.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 expandPrototypeChain(e){if(!e||!this.normalizeWikilink(e))return[];let t=[e],n=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Tl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let c=null;try{let u=await this.findSubjectByUID(o);if(!u)break;c=await this.getLinkedValue(u,q.Namespace.EXO.term("Asset_prototype"))}catch(u){this.logger.debug(this.capWarning(`[expandPrototypeChain] store lookup failed at hop ${s} for '${i}': ${String(u)}`));break}if(!c)break;let l=this.normalizeWikilink(c).toLowerCase();if(n.has(l))break;n.add(l),t.push(c),i=c}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let n=this.extractPathBasename(t);return n&&this.looksLikeUUID(n)?n:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let n=await this.tripleStore.findSubjectsByUUID(e);if(n.length>0)return n[0]}let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_uid"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e)return n.subject;return null}async getLiteralValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal||i instanceof dr.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);if(!t)return null;let n=await this.getLiteralValue(t,q.Namespace.EXO.term("Asset_label"));return n===null?null:hz.test(n)?(0,jF.iriToObsidianName)(n)??n:n}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(n=>n.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let n=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));c&&o.add(c);let l=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_label"));l&&o.add(l);let u=a((p,h)=>{if(o.has(p))return;let m=n.get(p);(m===void 0||h<m)&&n.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:m}=p;if(m>=Tl||i.has(h.value))continue;i.add(h.value);let g=await this.tripleStore.match(h,q.Namespace.EXO.term("Class_superClass"),void 0);for(let _ of g){let b=_.object;if(!(b instanceof dr.IRI))continue;let T=m+1,I=b.value.startsWith("obsidian://vault/"),w=this.iriToObsidianName(b.value);w&&u(w,T);let S=null;if(I?S=b:w&&(S=await this.resolveClassFileIRI(w)),!S)continue;let R=await this.getLiteralValue(S,q.Namespace.EXO.term("Asset_uid"));R&&u(R,T),i.has(S.value)||f.push({fileIRI:S,depth:T})}}let d=Array.from(n.entries()).map(([p,h])=>({ref:p,depth:h}));return this._ancestorDepthCache.set(e,d),d}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_label"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e&&n.subject instanceof dr.IRI){let i=await this.tripleStore.match(n.subject,q.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Jt.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof dr.IRI){let s=await this.tripleStore.match(i,q.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Jt.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Jt.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let n=await this.tripleStore.match(e,t,void 0),i=[];for(let s of n){let o=s.object;if(o instanceof dr.IRI){let c=await this.tripleStore.match(o,q.Namespace.EXO.term("Asset_uid"),void 0);if(c.length>0&&c[0].object instanceof Jt.Literal)i.push(c[0].object.value);else{let l=o.value.split("/").pop()?.replace(".md","");l&&i.push(l)}}else if(o instanceof Jt.Literal){let c=this.normalizeWikilink(o.value);c&&i.push(c)}}return i}async getLinkedValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.normalizeWikilink(i.value):i instanceof dr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.unwrapWikilink(i.value):i instanceof dr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let n=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(n)return n[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof Jt.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof dr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let n=t[1],i=await this.findSubjectByUID(n);if(!i)return e;let s=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${n}]]`,`[[${n}|${s}]]`):e}iriToObsidianName(e){return(0,jF.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(0,n):t}};Qo.CommandResolver=ST;Qo.CommandResolver=ST=cz([(0,uz.injectable)(),lz("design:paramtypes",[Object,Object])],ST)});var ET=v(wT=>{"use strict";Object.defineProperty(wT,"__esModule",{value:!0});wT.validateExoQLAllowlist=vz;var I0=Kp();function vz(r){if(!r||typeof r!="object")return;let e=r;if(e.type==="update"){let t=r.updates??[];for(let n of t)if(n?.type==="load")throw new I0.ExoQLForbiddenKeywordError("LOAD");throw new I0.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,n=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||n)throw new I0.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)R0(t);if(Array.isArray(e.template))for(let t of e.template)R0(t)}}a(vz,"validateExoQLAllowlist");function R0(r){if(!r||typeof r!="object")return;if(r.type==="service")throw new I0.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(r.patterns))for(let t of r.patterns)R0(t);let e=r.where;if(Array.isArray(e))for(let t of e)R0(t)}a(R0,"walkPatternForBannedKeywords")});var vT=v(C0=>{"use strict";Object.defineProperty(C0,"__esModule",{value:!0});C0.DEFAULT_EVAL_CONFIG=void 0;C0.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var x0=v(TT=>{"use strict";Object.defineProperty(TT,"__esModule",{value:!0});TT.evaluateWithExoEval=Oz;var Tz=Wu(),Az=Xu(),Iz=yf(),Rz=ET(),Cz=vT(),xz=Kp();async function Oz(r,e={}){if(typeof r!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let n=new Tz.ExoQLParser().parse(r);if((0,Rz.validateExoQLAllowlist)(n),!{...Cz.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new xz.ExoQLEvalDisabledError;let s="queryType"in n&&typeof n.queryType=="string"?n.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let c=new Az.ExoQLAlgebraTranslator().translate(n),l=new Iz.ExoQLQueryExecutor(e.store);return l.isAskQuery(c)?{kind:"ask",result:await l.executeAsk(c)}:l.isConstructQuery(c)?{kind:"construct",triples:await l.executeConstruct(c)}:{kind:"select",rows:await l.executeAll(c)}}a(Oz,"evaluateWithExoEval")});var ms=v(O0=>{"use strict";Object.defineProperty(O0,"__esModule",{value:!0});O0.DateFormatter=void 0;var AT=class r{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${i}T${s}:${o}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${n}-${i}]]"`}static getTodayWikilink(){return r.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}static parseWikilink(e){let n=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return n?n[1]:null}static addDays(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),r.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[n,i,s]=t,o=new Date(n,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return r.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return r.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};O0.DateFormatter=AT});var Qp=v(P0=>{"use strict";Object.defineProperty(P0,"__esModule",{value:!0});P0.liveClock=Pz;P0.frozenClock=Dz;function Pz(){return{now:a(()=>new Date,"now")}}a(Pz,"liveClock");function Dz(r){let e=new Date(r);return{now:a(()=>new Date(e.getTime()),"now")}}a(Dz,"frozenClock")});var zF=v(Xo=>{"use strict";var Fz=Xo&&Xo.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Lz=Xo&&Xo.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Jp;Object.defineProperty(Xo,"__esModule",{value:!0});Xo.PreconditionEvaluator=void 0;var Nz=lt(),kz=Wu(),Mz=Xu(),HF=yf(),jz=x0(),Xp=ms(),$z=Qp(),Zp=Jp=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,n){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=n?.clock??(0,$z.liveClock)()}async evaluate(e,t,n){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,n,i)==="yes"}async evaluateNode(e,t,n,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let c=await Promise.all(o.map(l=>this.evaluateNode(l,t,n,i)));return s==="all"?c.includes("no")?"no":c.includes("unknown")?"unknown":"yes":c.includes("yes")?"yes":c.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,n,i);return s==="unknown"?"unknown":s==="yes"?"no":"yes"}return e.sparqlAsk?await this.evaluateSparqlAskMemoized(e.sparqlAsk,t,i)?"yes":"no":e.query?await this.evaluateQueryRef(e.query,t)?"yes":"no":e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,n)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,n){let i=n.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return n.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return!1;let i=this.substituteVariables(n,t),s=await(0,jz.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,n){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,n):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,Jp.SENTINEL_IRI),i=new kz.ExoQLParser().parse(t),o=new Mz.ExoQLAlgebraTranslator().translate(i);return new HF.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,n){let i=this.hostFunctions.get(e);if(!i)return!0;let s=n?{...n,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let n=Jp.TEMPORAL_TOKEN.test(e),i=n?Xp.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||n&&s.day!==i){let l=this.compileAsk(e);if(!l)return!1;s={day:i,compiled:l},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll(Jp.SENTINEL_IRI,t));return await new HF.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let n=this.clock.now(),i=n.toISOString(),s=n.getFullYear(),o=n.getMonth(),c=n.getDate(),l=n.getDay(),u=Xp.DateFormatter.toDateString(n),f=Xp.DateFormatter.toDateString(new Date(s,o,c-1)),d=(l+6)%7,p=Xp.DateFormatter.toDateString(new Date(s,o,c-d)),h=Xp.DateFormatter.toDateString(new Date(s,o,c-d-7)),m=`${s}-${String(o+1).padStart(2,"0")}-01`,g=o===0?11:o-1,b=`${o===0?s-1:s}-${String(g+1).padStart(2,"0")}-01`,T=`${s}-01-01`;return e.replace(/\$target\b/g,`<${t}>`).replace(/\$now\b/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday\b/g,`"${f}"^^xsd:date`).replace(/\$thisWeekStart\b/g,`"${p}"^^xsd:date`).replace(/\$lastWeekStart\b/g,`"${h}"^^xsd:date`).replace(/\$thisMonthStart\b/g,`"${m}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${b}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${T}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};Xo.PreconditionEvaluator=Zp;Zp.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Zp.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;Xo.PreconditionEvaluator=Zp=Jp=Fz([(0,Nz.injectable)(),Lz("design:paramtypes",[Object,Object,Object])],Zp)});var KF=v(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.hasUidFilename=Jo.hasNonUidFilename=void 0;Jo.registerDefaultHostFunctions=Vz;var Uz=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");Jo.hasNonUidFilename=Uz;var Bz=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");Jo.hasUidFilename=Bz;function Vz(r){r.registerHostFunction("hasNonUidFilename",Jo.hasNonUidFilename),r.registerHostFunction("hasUidFilename",Jo.hasUidFilename)}a(Vz,"registerDefaultHostFunctions")});var F0=v(D0=>{"use strict";Object.defineProperty(D0,"__esModule",{value:!0});D0.liveUidGenerator=Gz;D0.seededUidGenerator=Wz;var IT=al();function Gz(){return{next:a(()=>(0,IT.v4)(),"next")}}a(Gz,"liveUidGenerator");var qz="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function Wz(r){let e=0,t=(0,IT.v5)(r,qz);return{next:a(()=>{let n=`${r}#${e}`;return e+=1,(0,IT.v5)(n,t)},"next")}}a(Wz,"seededUidGenerator")});var k0=v(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.registerResolver=_r;sc.getResolver=zz;sc.isResolverModifierAware=Kz;sc.getRegisteredResolverIds=Yz;sc.clearResolvers=Qz;sc.installDefaultResolvers=oK;var Hz=ms(),N0=new Map,RT=new Set;function _r(r,e,t=!1){N0.set(r,e),t&&RT.add(r)}a(_r,"registerResolver");function zz(r){return N0.get(r)}a(zz,"getResolver");function Kz(r){return RT.has(r)}a(Kz,"isResolverModifierAware");function Yz(){return Array.from(N0.keys())}a(Yz,"getRegisteredResolverIds");function Qz(){N0.clear(),RT.clear()}a(Qz,"clearResolvers");function _n(r){return r<10?`0${r}`:String(r)}a(_n,"pad2");var Xz=["January","February","March","April","May","June","July","August","September","October","November","December"],Jz=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Zz=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],eK=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function tK(r){let e=["th","st","nd","rd"],t=r%100;return`${r}${e[(t-20)%10]||e[t]||e[0]}`}a(tK,"ordinalDay");var rK=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function nK(r,e){let t=(r.getHours()+11)%12+1;return e.replace(rK,n=>{switch(n){case"YYYY":return String(r.getFullYear());case"YY":return _n(r.getFullYear()%100);case"MMMM":return Xz[r.getMonth()];case"MMM":return Jz[r.getMonth()];case"MM":return _n(r.getMonth()+1);case"M":return String(r.getMonth()+1);case"Do":return tK(r.getDate());case"DD":return _n(r.getDate());case"D":return String(r.getDate());case"dddd":return Zz[r.getDay()];case"ddd":return eK[r.getDay()];case"HH":return _n(r.getHours());case"H":return String(r.getHours());case"hh":return _n(t);case"h":return String(t);case"mm":return _n(r.getMinutes());case"m":return String(r.getMinutes());case"ss":return _n(r.getSeconds());case"s":return String(r.getSeconds());case"A":return r.getHours()<12?"AM":"PM";case"a":return r.getHours()<12?"am":"pm";default:return n}})}a(nK,"formatDate");function YF(r,e,t){let n=r.getDate(),i=new Date(r.getTime());i.setDate(1),t==="M"?i.setMonth(i.getMonth()+e):i.setFullYear(i.getFullYear()+e);let s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(n,s)),i}a(YF,"addMonthsClamped");function iK(r,e){if(!e)return r;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return r;let n=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(r.getTime());switch(i){case"d":s.setDate(s.getDate()+n);break;case"w":s.setDate(s.getDate()+n*7);break;case"M":s=YF(s,n,"M");break;case"y":s=YF(s,n,"y");break}return isNaN(s.getTime())?r:s}a(iK,"applyDateOffset");function sK(r){if(!r)return{offset:null,format:null};let e=r.indexOf(":");if(e<0)return{offset:r,format:null};let t=r.slice(0,e),n=r.slice(e+1);return{offset:t||null,format:n||null}}a(sK,"parseDateModifier");function L0(r,e){return(t,n)=>{let{offset:i,format:s}=sK(n),o=new Date;return r!==0&&o.setDate(o.getDate()+r),o=iK(o,i),nK(o,s??e)}}a(L0,"makeDateResolver");function oK(){_r("today",()=>{let r=new Date;return`${r.getFullYear()}-${_n(r.getMonth()+1)}-${_n(r.getDate())}`}),_r("todayStart",()=>Hz.DateFormatter.getTodayStartTimestamp()),_r("date",L0(0,"YYYY-MM-DD"),!0),_r("now",L0(0,"YYYY-MM-DDTHH:mm:ss"),!0),_r("tomorrow",L0(1,"YYYY-MM-DD"),!0),_r("yesterday",L0(-1,"YYYY-MM-DD"),!0),_r("target",r=>r.targetIRI?`"[[${r.targetIRI}]]"`:""),_r("targetFolder",r=>{if(!r.targetFilePath)return"";let e=r.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),_r("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.")}),_r("nowTimestamp",()=>{let r=new Date;return`${r.getFullYear()}-${_n(r.getMonth()+1)}-${_n(r.getDate())}T${_n(r.getHours())}:${_n(r.getMinutes())}:${_n(r.getSeconds())}`}),_r("nowDate",()=>{let r=new Date;return`${r.getFullYear()}-${_n(r.getMonth()+1)}-${_n(r.getDate())}`}),_r("nowYear",()=>String(new Date().getFullYear())),_r("nowMonth",()=>_n(new Date().getMonth()+1)),_r("userInputLabel",r=>{let e=r.userInput?.label;return typeof e=="string"?e:""}),_r("userInput",(r,e)=>{if(!e)return null;let t=r.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),_r("targetProperty",(r,e)=>{if(!e||!r.targetFm)return null;let t=r.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),_r("targetRefProperty",(r,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!n||!i)return null;let s=r.targetRefFm?.[n];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),_r("labelAsArray",r=>{let e=r.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),_r("groundingTargetClass",r=>r.groundingTargetClassUid?`"[[${r.groundingTargetClassUid}]]"`:null),_r("targetClassSelf",r=>{if(!r.targetFilePath)return null;let e=r.targetFilePath.replace(/^\/+/,""),n=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return n.length>0?`"[[${n}]]"`:null})}a(oK,"installDefaultResolvers")});var xT=v(M0=>{"use strict";Object.defineProperty(M0,"__esModule",{value:!0});M0.resolveTemplateBody=cK;M0.stripTemplateFrontmatter=lK;var CT=k0();(0,CT.installDefaultResolvers)();var aK=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function cK(r,e={}){return r.replace(aK,(t,n,i)=>{let s=(0,CT.getResolver)(n);if(s===void 0)return t;let o=s(e,i.length>0?i:void 0);return typeof o!="string"||o.length===0?t:(0,CT.isResolverModifierAware)(n)?o:o+i})}a(cK,"resolveTemplateBody");function lK(r){let e=r.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?r.slice(e[0].length):r}a(lK,"stripTemplateFrontmatter")});var U0=v(bf=>{"use strict";Object.defineProperty(bf,"__esModule",{value:!0});bf.registerOrderSpecLoader=uK;bf.clearOrderSpecLoader=fK;bf.loadDefaultSpec=dK;bf.orderProperties=pK;var j0=null,oc,$0=!1;function uK(r){j0=r,oc=void 0,$0=!1}a(uK,"registerOrderSpecLoader");function fK(){j0=null,oc=void 0,$0=!1}a(fK,"clearOrderSpecLoader");function dK(){if(oc!==void 0)return oc;if(!j0)return oc=null,null;try{oc=j0()}catch(r){$0||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",r),$0=!0),oc=null}return oc}a(dK,"loadDefaultSpec");function pK(r,e){if(!e||e.head.length===0&&e.tail.length===0)return r;let t=Object.keys(r),n=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),c=t.filter(u=>!n.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&c.sort((u,f)=>u.localeCompare(f));let l={};for(let u of s)l[u]=r[u];for(let u of c)l[u]=r[u];for(let u of o)l[u]=r[u];return l}a(pK,"orderProperties")});var Xn=v(B0=>{"use strict";Object.defineProperty(B0,"__esModule",{value:!0});B0.DI_TOKENS=void 0;B0.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),ClassCreationService:Symbol.for("ClassCreationService"),ConceptCreationService:Symbol.for("ConceptCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),RenameToUidService:Symbol.for("RenameToUidService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var PT=v(V0=>{"use strict";Object.defineProperty(V0,"__esModule",{value:!0});V0.RDFVocabularyMapper=void 0;var Cr=gi(),QF=$e(),Ee=Qt(),OT=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 Cr.Triple(Ee.Namespace.EXO.term("Asset"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDFS.term("Resource"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Class"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDFS.term("Class"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDF.term("Property"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Task"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Project"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Area"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Workflow"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("WorkflowState"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("WorkflowTransition"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Command"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Precondition"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Grounding"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("CommandBinding"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Cr.Triple(Ee.Namespace.EXO.term("Instance_class"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDF.term("type"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Asset_isDefinedBy"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("isDefinedBy"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Class_superClass"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("subClassOf"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_range"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("range"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_domain"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("domain"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_superProperty"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,n){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(n instanceof QF.IRI)s=n;else{let o=n.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,c,l]=o;s=(c==="ems"?Ee.Namespace.EMS:c==="exocmd"?Ee.Namespace.EXOCMD:Ee.Namespace.EXO).term(l)}else s=new QF.IRI(n)}return new Cr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};V0.RDFVocabularyMapper=OT});var G0=v(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.OBSIDIAN_VAULT_SCHEME=void 0;Zo.vaultPathToIRI=hK;Zo.iriToVaultPath=mK;Zo.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function hK(r){let e=r.startsWith("./")?r.slice(2):r;return`${Zo.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(hK,"vaultPathToIRI");function mK(r){if(!r.startsWith(Zo.OBSIDIAN_VAULT_SCHEME))return null;let e=r.slice(Zo.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(mK,"iriToVaultPath")});var W0=v(eh=>{"use strict";Object.defineProperty(eh,"__esModule",{value:!0});eh.derivePath=XF;eh.deriveUrl=gK;eh.deriveLegacyFlatPath=yK;var DT="assetspaces",q0=/^[A-Za-z0-9._-]+$/;function XF(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let n=t.split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!q0.test(i)||!q0.test(s)?null:`${DT}/${i}/${s}`}a(XF,"derivePath");function gK(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${DT}/`;if(!e.startsWith(t))return null;let n=e.slice(t.length).split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!q0.test(i)||!q0.test(s)?null:`https://github.com/${i}/${s}`}a(gK,"deriveUrl");function yK(r){let e=XF(r);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let n=t.startsWith("exoas-")?t.slice(6):t;return n.length===0?null:`${DT}/${n}`}a(yK,"deriveLegacyFlatPath")});var H0=v(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.FILE_SPACE_CLASS_UID=void 0;gs.frontmatterDeclaresFileSpace=bK;gs.discoverFileSpaceExclusions=wK;var _K=W0();gs.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var JF=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,FT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function eL(r){let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;JF.lastIndex=0;let i;for(;(i=JF.exec(n))!==null;)t.push(i[1].trim())}return t}a(eL,"wikilinkTargets");function bK(r){return r?eL(r.exo__Instance_class).some(e=>FT.test(e)&&e.toLowerCase()===gs.FILE_SPACE_CLASS_UID):!1}a(bK,"frontmatterDeclaresFileSpace");function ZF(r,e){try{return r.getFrontmatter(e)}catch{return null}}a(ZF,"readFrontmatterSafe");function SK(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(SK,"readSource");function wK(r){let e=[],t=[],n=[],i=new Map,s=a((c,l)=>{if(FT.test(c))return c.toLowerCase()===gs.FILE_SPACE_CLASS_UID;let u=r.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=ZF(r,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===gs.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(c=>c.some(l=>FT.test(l)&&l.toLowerCase()===gs.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of r.getAllFiles()){let l=ZF(r,c);if(!l)continue;let u=eL(l.exo__Instance_class);if(!u.some(h=>s(h,c.path)))continue;t.push(c.path),o(u)||n.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${gs.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=SK(l);if(f===null){n.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,_K.derivePath)(f);if(d===null){n.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;c.path.startsWith(p)&&n.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${p} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(p)}return{prefixes:e,declarationPaths:t,warnings:n}}a(wK,"discoverFileSpaceExclusions")});var Il=v(jt=>{"use strict";var EK=jt&&jt.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},vK=jt&&jt.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},tL=jt&&jt.__param||function(r,e){return function(t,n){e(t,n,r)}},kT;Object.defineProperty(jt,"__esModule",{value:!0});jt.NoteToRDFConverter=jt.LEGACY_YAML_KEYS=jt.LEGACY_UNPREFIXED_ASSET_FIELDS=jt.UNPREFIXED_ASSET_FIELDS=void 0;jt.canonicalYamlKey=CK;jt.normaliseExcludedFolders=iL;jt.isPathExcluded=sL;var LT=lt(),xr=gi(),ys=$e(),xn=Qe(),rL=nr(),pr=Qt(),nL=Xn(),TK=PT(),AK=$p(),NT=G0(),Ei=pv(),IK=H0();jt.UNPREFIXED_ASSET_FIELDS=new Set(["draft","pinned","aliases"]);jt.LEGACY_UNPREFIXED_ASSET_FIELDS=new Set(["archived"]);jt.LEGACY_YAML_KEYS=new Map([...jt.LEGACY_UNPREFIXED_ASSET_FIELDS].map(r=>[`exo__Asset_${r}`,[r]]));var RK=/^exo__Asset_(.+)$/;function CK(r){let e=RK.exec(r);return e&&jt.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(r)?`exo__Asset_${r}`:r}a(CK,"canonicalYamlKey");function iL(r){return Array.isArray(r)?r.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(iL,"normaliseExcludedFolders");function sL(r,e){if(e.length===0)return!1;let t=r.replace(/\\/g,"/");for(let n of e)if(t.startsWith(n))return!0;return!1}a(sL,"isPathExcluded");function xK(r){if(!r)return"";let e=r.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(xK,"normaliseSubjectIriPrefix");var Al=kT=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=AK.NullLogger,n={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.preResolvedTargetFm=new Map,this.vocabularyMapper=new TK.RDFVocabularyMapper,this.subjectIriPrefix=xK(n.subjectIriPrefix),this.emitInstanceClassAsUid=n.emitInstanceClassAsUid??!1}async convertNote(e){let t=this.vault.getFrontmatterWithFallback?await this.vault.getFrontmatterWithFallback(e):this.vault.getFrontmatter(e);return this.convertNoteFromFrontmatter(e,t)}async convertNoteFromFrontmatter(e,t){if(!t)return[];await this.preResolveWikilinkTargets(t);let n=this.notePathToIRI(e.path),i=pr.Namespace.EXO.term("Asset_filename"),s=new xr.Triple(n,i,new xn.Literal(e.basename));if(Ei.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,n){this.pendingExtraTriples=[];let i=[n],s=this.notePathToIRI(e.path),o,c,l,u=!1,f=pr.Namespace.EXO.term("Statement").value;for(let[g,_]of Object.entries(t)){if(jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(g)&&Object.prototype.hasOwnProperty.call(t,`exo__Asset_${g}`))continue;let b=jt.UNPREFIXED_ASSET_FIELDS.has(g)||jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(g)?`exo__Asset_${g}`:g;if(!this.isExocortexProperty(b))continue;let T=this.propertyKeyToIRI(b),I=Array.isArray(_)?_:[_];for(let w of I)if(!((g==="exo__Asset_label"||jt.UNPREFIXED_ASSET_FIELDS.has(g)||jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(g))&&(w==null||typeof w=="string"&&w.trim()==="")))if(g==="exo__Instance_class"){let S=this.valueToClassURI(w);i.push(new xr.Triple(s,T,S))}else{let S=await this.valueToRDFObject(w,e,T);if(b==="exo__Statement_subject"&&o===void 0){let R=S.find(L=>L instanceof ys.IRI);R&&(o=R)}else if(b==="exo__Statement_predicate"&&c===void 0){let R=S.find(L=>L instanceof ys.IRI);R&&(c=R)}else b==="exo__Statement_object"&&l===void 0&&(l=S[0]);for(let R of S)if(i.push(new xr.Triple(s,T,R)),this.vocabularyMapper.hasMappingFor(g)&&R instanceof ys.IRI){let L=this.vocabularyMapper.generateMappedTriple(s,g,R);L&&i.push(L)}}if(g==="exo__Instance_class")for(let w of I){let S=this.valueToClassURI(w);if(S instanceof ys.IRI){let R=pr.Namespace.RDF.term("type");i.push(new xr.Triple(s,R,S)),S.value===f&&(u=!0)}}if(g==="exo__Asset_label"){let w=pr.Namespace.RDFS.term("label");for(let S of I)typeof S=="string"&&S.length>0&&i.push(new xr.Triple(s,w,new xn.Literal(S)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let g=pr.Namespace.RDFS.term("label"),_=pr.Namespace.EXO.term("Asset_label"),b=new xn.Literal(e.basename);i.push(new xr.Triple(s,g,b)),i.push(new xr.Triple(s,_,b))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&c&&l&&i.push(new xr.Triple(o,c,l));let m=await this.convertBodyWikilinks(e,s);return i.push(...m),i}async convertExo003Note(e,t){let n=Ei.Exo003Parser.parse(t);if(!n.success||!n.metadata)return[];let i=n.metadata,s=[];switch(i.metadata){case Ei.Exo003MetadataType.Namespace:break;case Ei.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Ei.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Ei.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Ei.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let n=this.notePathToIRI(e.path),i=new ys.IRI(t.uri);return[new xr.Triple(n,pr.Namespace.OWL.term("sameAs"),i),new xr.Triple(i,pr.Namespace.OWL.term("sameAs"),n)]}convertExo003BlankNode(e,t){let n=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new xr.Triple(n,pr.Namespace.OWL.term("sameAs"),new rL.BlankNode(i))]}convertExo003Statement(e,t){let n=[];try{let i=this.createExo003ReferenceResolver(e),s=Ei.Exo003Parser.toTriple(t,i);n.push(s);let o=this.notePathToIRI(e.path);n.push(new xr.Triple(o,pr.Namespace.RDF.term("value"),s.subject))}catch{}return n}async convertExo003Body(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new ys.IRI(c.value):new rL.BlankNode(c.value),f=new ys.IRI(l.value),d=Ei.Exo003Parser.toLiteral(t,s.trim());n.push(new xr.Triple(u,f,d));let p=this.notePathToIRI(e.path);n.push(new xr.Triple(p,pr.Namespace.RDF.term("value"),u))}catch{}return n}createExo003ReferenceResolver(e){return t=>{let n=this.extractWikilink(t),i=n||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.targetFrontmatter(s);if(o&&Ei.Exo003Parser.isExo003Format(o)){let c=Ei.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Ei.Exo003MetadataType.Anchor||l.metadata===Ei.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Ei.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!n&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),n=[],i=[],s=e.strict??!1,o=0,c=0,l=(0,IK.discoverFileSpaceExclusions)(this.vault);for(let g of l.warnings)this.logger.warn(`FileSpace discovery: ${g}`);let u=[...iL(e.excludedFolders),...l.prefixes],f=u.length===0?t:t.filter(g=>!sL(g.path,u)),d=e.onProgress,p=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:kT.INDEX_PROGRESS_INTERVAL,h=f.length,m=0;for(let g of f){if(m++,d&&m%p===0&&m<h)try{d(m,h)}catch{}try{let _=this.vault.getFrontmatter(g),b=_?this.validateExocortexAsset(_,g.basename):null;if(b){if(s)throw new Error(`Invariant violation in "${g.path}": ${b.message}`);i.push({path:g.path,reason:`Invariant violation: ${b.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${g.path}`,{code:b.code,property:b.property,reason:b.message});continue}let T=await this.convertNote(g);n.push(...T)}catch(_){let b=_ instanceof Error?_.message:String(_);if(s)throw new Error(`Invalid IRI for file "${g.path}": ${b}`);i.push({path:g.path,reason:`Invalid IRI: ${b}`}),c++,this.logger.info(`Skipping file with invalid IRI: ${g.path}`,{reason:b})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),c>0&&this.logger.warn(`Skipped ${c} file${c===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:c}),{triples:n,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length},fileSpaces:l}}static inferLabelFromBasename(e){return pr.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let n=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(n):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(n(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&n(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let p=this.removeQuotes(d),m=(this.extractWikilink(p)??p).trim();/^[a-z][a-zA-Z0-9]*__/.test(m)&&/[\s()]/.test(m)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let n of e){let i=(0,NT.vaultPathToIRI)(n.path);ys.IRI.isValidIRI(i)||t.push({path:n.path,reason:`Path "${n.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new ys.IRI((0,NT.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new ys.IRI((0,NT.vaultPathToIRI)(e))}isExocortexProperty(e){return pr.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=pr.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let n=this.targetFrontmatter(t);if(!n)return;let i=n.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof ys.IRI&&(this.pendingExtraTriples.push(new xr.Triple(e,pr.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new xr.Triple(e,pr.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,n){if(typeof e=="string"){let i=this.removeQuotes(e);if(n?.value.endsWith("#TokenInvocation_parameter"))return[new xn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new xn.Literal(u);if(n?.value.endsWith("#Grounding_targetValueRef")||n?.value.endsWith("#Grounding_targetValueSubstitution")||n?.value.endsWith("#Grounding_targetClass")||n?.value.endsWith("#Grounding_type")||n?.value.endsWith("#PropertyDefault_value"))return[l];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let m=this.targetFrontmatter(o);if(m){let I=m.exo__Asset_label;if(typeof I=="string"){let w=this.expandClassValue(I);if(w)return this.emitTypeTripleForEnumInstance(w,o),[w]}}let g=n?.value.endsWith("#Asset_prototype")||n?.value.endsWith("/Asset_prototype"),b=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(I=>I.trim()).filter(Boolean),T=b.length>0&&b.some(I=>n?.value.endsWith(`#${I}`));return g||T?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new xn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new xn.Literal(i,pr.Namespace.XSD.term("dateTime"))]:[new xn.Literal(i)]}return typeof e=="boolean"?[new xn.Literal(e.toString())]:typeof e=="number"?[new xn.Literal(e.toString(),pr.Namespace.XSD.term("decimal"))]:e instanceof Date?[new xn.Literal(e.toISOString(),pr.Namespace.XSD.term("dateTime"))]:[new xn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1];return n.includes("|")?n.split("|")[0]:n}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1],i=n.indexOf("|");return i>=0?n.substring(i+1).trim():null}targetFrontmatter(e){return this.vault.getFrontmatter(e)??this.preResolvedTargetFm.get(e.path)??null}async preResolveWikilinkTargets(e){let t=this.vault.getFrontmatterWithFallback?.bind(this.vault);if(t)for(let n of Object.values(e)){let i=Array.isArray(n)?n:n==null?[]:[n];for(let s of i){if(typeof s!="string")continue;let o=this.removeQuotes(s),c=this.extractWikilink(o);if(!c||!this.isUUID(c))continue;let l=this.vault.getFirstLinkpathDest(c,"");!l||this.preResolvedTargetFm.has(l.path)||this.vault.getFrontmatter(l)||this.preResolvedTargetFm.set(l.path,await t(l))}}}valueToClassURI(e){if(typeof e!="string")return new xn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):l;let u=this.targetFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):d}}return this.notePathToIRI(c.path)}}return new xn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:pr.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),n=pr.Namespace.fromPropertyKey(t);return!n||/[\s()]/.test(n.localName)?null:n.namespace.term(n.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,n,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(n=i.exec(e))!==null;)n[1]&&t.add(n[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=pr.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);n.push(new xr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?n.push(new xr.Triple(t,c,f)):n.push(new xr.Triple(t,c,new xn.Literal(l)))}else n.push(new xr.Triple(t,c,new xn.Literal(l)))}}catch{}return n}};jt.NoteToRDFConverter=Al;Al.INDEX_PROGRESS_INTERVAL=200;Al.SkippedFileInfo=class{constructor(r,e){this.path=r,this.reason=e}};Al.VaultValidationResult=class{constructor(r,e,t){this.triples=r,this.skippedFiles=e,this.summary=t}};Al.VaultValidationOptions=class{constructor(r=!1){this.strict=r}};jt.NoteToRDFConverter=Al=kT=EK([(0,LT.injectable)(),tL(0,(0,LT.inject)(nL.DI_TOKENS.IVaultAdapter)),tL(1,(0,LT.inject)(nL.DI_TOKENS.ILogger)),vK("design:paramtypes",[Object,Object,Object])],Al)});var Rl=v(z0=>{"use strict";Object.defineProperty(z0,"__esModule",{value:!0});z0.FrontmatterService=void 0;var oL=U0(),MT=Fu(),Sf=Il(),th=class r{static{a(this,"FrontmatterService")}parse(e){let t=e.match(r.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let n={},i=t.content.split(/\r?\n/),s=null,o=null,c=a(()=>{s!==null&&o!==null&&(n[s]=o),s=null,o=null},"flushArray");for(let l of i){let u=/^ {2}- (.*)$/.exec(l);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}c();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(l);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(s=d,o=[]):n[d]=p}return c(),n}updateProperty(e,t,n){t=(0,Sf.canonicalYamlKey)(r.normalizeIRI(t)),typeof n=="string"&&(n=r.normalizeIRIValue(n));let i=this.parse(e),s=this.serializeValue(t,n);if(!i.exists)return`---
|
|
72
|
+
${n}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(n=>this.generateExpression(n)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),n=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${n})`:`${t} IN (${n})`}default:throw new hf(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let n of e.triples)this.collectVariablesFromTriple(n,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let n of e.variables)t.add(n);break;case"project":for(let n of e.variables)t.add(n);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let n of e.variables)t.add(n);for(let n of e.aggregates)t.add(n.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let n of e.operands)this.collectVariablesFromExpression(n,t);break;case"function":case"functionCall":for(let n of e.args)this.collectVariablesFromExpression(n,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let n of e.list)this.collectVariablesFromExpression(n,t);break}}};mf.SPARQLGenerator=bT});var yf=v(wi=>{"use strict";var qH=wi&&wi.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),WH=wi&&wi.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),NF=wi&&wi.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&qH(t,e,n[i]);return WH(t,e),t}})();Object.defineProperty(wi,"__esModule",{value:!0});wi.QueryExecutor=wi.ExoQLQueryExecutor=wi.QueryExecutorError=void 0;var HH=B1(),zH=g0(),KH=oT(),YH=cT(),QH=SF(),XH=EF(),JH=IF(),ZH=gT(),ez=CF(),tz=OF(),rz=FF(),nz=LF(),iz=$e(),sz=Qe(),oz=l0(),yn="http://www.w3.org/2001/XMLSchema#",az=new Set([`${yn}integer`,`${yn}decimal`,`${yn}float`,`${yn}double`,`${yn}nonPositiveInteger`,`${yn}negativeInteger`,`${yn}long`,`${yn}int`,`${yn}short`,`${yn}byte`,`${yn}nonNegativeInteger`,`${yn}unsignedLong`,`${yn}unsignedInt`,`${yn}unsignedShort`,`${yn}unsignedByte`,`${yn}positiveInteger`]),gf=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};wi.QueryExecutorError=gf;var T0=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let n=t.resolveClassHierarchy===!1?e:new rz.ClassHierarchyResolvingStore(e);this.tripleStore=n,this.bgpExecutor=new HH.BGPExecutor(n),this.filterExecutor=new zH.FilterExecutor,this.optionalExecutor=new KH.OptionalExecutor,this.unionExecutor=new YH.UnionExecutor,this.minusExecutor=new QH.MinusExecutor,this.valuesExecutor=new XH.ValuesExecutor,this.aggregateExecutor=new JH.AggregateExecutor,this.constructExecutor=new ZH.ConstructExecutor,this.serviceExecutor=new ez.ServiceExecutor(t.serviceConfig),this.graphExecutor=new tz.GraphExecutor(n),this.sparqlGenerator=new nz.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(n)}async evaluateExistsPattern(e,t){let n=this.substituteVariables(e,t);for await(let i of this.execute(n))if(t.merge(i)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let n of this.execute(e))t.push(n);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new gf(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let n=new Set;for(let o of t)for(let c of o.variables())n.add(c);let i=this.collectOperationVariables(e.right);if([...n].some(o=>i.has(o)))for(let o of t){let c=this.substituteVariables(e.right,o);for await(let l of this.execute(c)){let u=o.merge(l);u!==null&&(yield u)}}else{let o=[];for await(let c of this.execute(e.right))o.push(c);for(let c of t)for(let l of o){let u=c.merge(l);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>NF(Yo())),n=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(n.has(o)){let c=i.get(o);c!==void 0&&s.set(o,c)}yield s}}async*executeOrderBy(e){let t=[];for await(let n of this.execute(e.input))t.push(n);t.sort((n,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,n),c=this.getExpressionValue(s.expression,i),l=0;if(o===void 0&&c===void 0?l=0:o===void 0?l=1:c===void 0?l=-1:typeof o=="number"&&typeof c=="number"?l=o-c:l=String(o).localeCompare(String(c)),s.descending&&(l=-l),l!==0)return l}return 0});for(let n of t)yield n}async*executeSlice(e){let t=0,n=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=n){if(i!==void 0&&t-n>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeReduced(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let n=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of n)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of n)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let n of this.execute(e.input)){let i=n.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,n):this.evaluateExtendExpression(e.expression,n);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let n of this.execute(e.left))t.push(n);for(let n of t){let i=this.substituteVariables(e.right,n);for await(let s of this.execute(i)){let o=n.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let n=JSON.parse(JSON.stringify(e));return this.substituteInOperation(n,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let n=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(n.input&&(n.input=this.substituteInOperation(n.input,t)),n.left&&(n.left=this.substituteInOperation(n.left,t)),n.right&&(n.right=this.substituteInOperation(n.right,t)),n.pattern&&(n.pattern=this.substituteInOperation(n.pattern,t)),n.query&&(n.query=this.substituteInOperation(n.query,t)),n.where&&(n.where=this.substituteInOperation(n.where,t)),n.expression&&this.substituteInExpression(n.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.type==="variable"&&typeof e.name=="string"){let n=this.termToAlgebraNode(t.get(e.name));if(n!==null){delete e.name;for(let[i,s]of Object.entries(n))e[i]=s}}if(e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let n of e.operands)this.substituteInExpression(n,t);if(e.args)for(let n of e.args)this.substituteInExpression(n,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let n of e.list)this.substituteInExpression(n,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let n=this.termToAlgebraNode(t.get(e.value));if(n!==null)return n}return e}termToAlgebraNode(e){if(e==null)return null;let t=e;return e instanceof iz.IRI||t.termType==="NamedNode"?{type:"iri",value:e.value}:t.termType==="Literal"||typeof t.value=="string"?{type:"literal",value:t.value,datatype:t.datatype?.value??t._datatype?.value,language:t.language??t._language}:null}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(n,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{n.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(n,i):yield*this.execute(n)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:n}=await Promise.resolve().then(()=>NF(Yo()));yield new n;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let n=t.get(e.name);if(!n)return;if(n instanceof sz.Literal){let i=n.datatype?.value;if(i===`${yn}dayTimeDuration`)try{return oz.DateTimeFunctions.parseDayTimeDuration(n.value)}catch{return n.value}if(i&&az.has(i)){let s=parseFloat(n.value);if(!Number.isNaN(s))return s}return n.value}return n.value??n.id??String(n)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="bgp"&&n.triples)for(let i of n.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(n.type==="values"&&n.variables)for(let i of n.variables)t.add(i);n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.type==="extend"&&n.variable&&t.add(n.variable),n.input&&this.collectVarsFromOperation(n.input,t),n.left&&this.collectVarsFromOperation(n.left,t),n.right&&this.collectVarsFromOperation(n.right,t),n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.query&&this.collectVarsFromOperation(n.query,t),n.where&&this.collectVarsFromOperation(n.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let n=e;n.type==="variable"&&t.add(n.value),n.type==="quoted"&&(this.collectVarsFromElement(n.subject,t),this.collectVarsFromElement(n.predicate,t),this.collectVarsFromElement(n.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="variable"&&n.name&&t.add(n.name),n.type==="exists"&&n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.left&&this.collectVarsFromExpressionTree(n.left,t),n.right&&this.collectVarsFromExpressionTree(n.right,t),n.operands)for(let i of n.operands)this.collectVarsFromExpressionTree(i,t);if(n.args)for(let i of n.args)this.collectVarsFromExpressionTree(i,t);if(n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.list)for(let i of n.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new gf("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 gf("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};wi.ExoQLQueryExecutor=T0;wi.QueryExecutor=T0});var WF=v(Qo=>{"use strict";var cz=Qo&&Qo.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},lz=Qo&&Qo.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(Qo,"__esModule",{value:!0});Qo.CommandResolver=void 0;var uz=lt(),fz=$p(),dz=Fu(),dr=$e(),Jt=Qe(),q=Qt(),kF=Ka(),MF=bp(),pz=Nu(),jF=Up(),hz=/^[a-z][a-z0-9+.-]*:\/\//i,_f=xE(),$F=AD(),mz=Wu(),gz=Xu(),yz=yf(),Tl=10,A0="exo__Asset",_z=Tl+1,UF="08cec529-90eb-4d43-88de-ceecccea12b0",bz=q.Namespace.EXOCMD.term("SubstitutionToken").value,BF=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","targetClassSelf"]);function Sz(r,e){return`__SUBSTITUTE__${r}__${e}__`}a(Sz,"buildSubstitutionMarker");function wz(r,e,t){let n=(0,pz.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${r}__${e}__${n}__`}a(wz,"buildParameterisedMarker");var VF="3f28af98-c031-4718-8ba2-44ad0b012c52",Ez=q.Namespace.EXOCMD.term("TokenInvocation").value,GF="29e2c8f8-2d27-4e58-b467-2e85d46f8122",qF="universal-default-template",ST=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null}constructor(e,t=fz.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorDepthCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._fallbackWarnedKeys=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,n){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${n??""}`,o=this.multiCache.get(s);if(o)return o;let c=n?await this.expandPrototypeChain(n):void 0,l=await this.expandClassHierarchy(t),u=new Map;for(let[h,m]of l){let g=await this.resolveForAsset(e,h,c);for(let _ of g){let b=this.getBindingPriority(_.binding)===2?m:0,T=u.get(_.binding.id);(!T||b<T.depth)&&u.set(_.binding.id,{rc:_,depth:b})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let m of h.binding.overrides)f.add(m);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,m)=>{let g=this.getBindingPriority(h.rc.binding),_=this.getBindingPriority(m.rc.binding);return g!==_?g-_:h.depth!==m.depth?h.depth-m.depth:(h.rc.binding.order??100)-(m.rc.binding.order??100)});let p=d.map(h=>h.rc);return this.multiCache.set(s,p),p}async expandClassHierarchy(e){let t=new Map;for(let c of e){if(c===A0){t.set(c,new Set);continue}let l=[];try{l=await this.getClassAncestors(c)}catch{l=[]}t.set(c,new Set(l))}let n=a(c=>{for(let l of e)if(l!==c&&t.get(l)?.has(c)&&!t.get(c)?.has(l))return!0;return!1},"isAncestorOfSibling"),i=e.filter(c=>!n(c)),s=new Map,o=a((c,l)=>{let u=s.get(c);(u===void 0||l<u)&&s.set(c,l)},"setMin");for(let c of i){if(o(c,0),this.looksLikeUUID(c))try{let u=await this.resolveLabelByUID(c);u&&o(u,0)}catch{}if(c===A0)continue;let l=[];try{l=await this.getClassAncestorsWithDepth(c)}catch{l=[]}for(let{ref:u,depth:f}of l)o(u,f)}return s.has(A0)||s.set(A0,_z),s}async resolveForAsset(e,t,n){let i=typeof n=="string"?`s:${n}`:n?`c:${n.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let c=typeof n=="string"?await this.expandPrototypeChain(n):n,l=await this.findBindings(t,c,e),u=[];for(let f of l){let d=await this.loadCommand(f.commandRef,{targetClass:f.targetClass});if(!d)continue;let p=f.precondition?{...d,precondition:f.precondition}:d;u.push({command:p,binding:f})}return u.sort((f,d)=>{let p=this.getBindingPriority(f.binding),h=this.getBindingPriority(d.binding);return p!==h?p-h:(f.binding.order??100)-(d.binding.order??100)}),this.cache.set(s,u),u}async loadCommand(e,t){let n=await this.findSubjectByUID(e);if(!n||(await this.tripleStore.match(n,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_labelTemplate")),c=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_icon")),l=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(n),m=await this.loadLinkedGrounding(n,0,t);return m?{id:e,name:s,labelTemplate:o??void 0,icon:c??void 0,precondition:h??void 0,grounding:m,confirmMessage:l??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,n){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let c of s){let l=c.subject,u=await this.loadBindingDefinition(l);u&&this.bindingMatches(u,e,i,n)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command")),t=[],n=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let l=await this.loadCommand(c);if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command ${c} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_cliName")),d=u??f??c;if(n.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${c}`);continue}n.add(d),t.push({command:l,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear(),this.clearUniversalCache()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let n=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let c=await this.evaluateSelectSnippet(o,t);n=n.replace(s,c)}return n}extractPlaceholders(e){let t=[],n=0;for(;n<e.length;)if(e[n]==="{"){let i=1,s=n+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(n,s),c=e.slice(n+1,s-1);t.push({full:o,body:c})}n=s}else n++;return t}async evaluateSelectSnippet(e,t){try{let n=e.replace(/\$target/g,`<${t}>`),s=new mz.ExoQLParser().parse(n),c=new gz.ExoQLAlgebraTranslator().translate(s),u=await new yz.ExoQLQueryExecutor(this.tripleStore).executeAll(c);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let p=f.get(d[0]);return p?p instanceof Jt.Literal||p instanceof dr.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,q.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),c=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!c)return null;let l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),m=await this.getLinkedUIDs(e,q.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:n,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:c??void 0,position:l??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:m.length>0?m:void 0}}async loadLinkedStyle(e,t){let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(n.length>0){let s=n[0].object,o=null;if(s instanceof dr.IRI)o=s;else if(s instanceof Jt.Literal){let c=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(c)}if(o){let c=await this.loadStyleAsset(o);if(c)return c}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,q.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,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),c=this.coerceBoolean(o),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=l!==null?this.coerceLabelClass(l,t):void 0,f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_source")),m=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:n,variant:s,showIcon:c,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:m,inline:!1}}coerceVariant(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(_f.COMMAND_VARIANT_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${n}" not in whitelist [${_f.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(_f.LABEL_CLASS_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${n}" not in whitelist [${_f.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(_f.STYLE_SOURCE_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle source "${n}" not in whitelist [${_f.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,n,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&n){for(let s of n)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let n=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(n===i)return!0;let s=this.extractPathBasename(i);if(s&&s===n)return!0;let o=this.extractPathBasename(n);if(o&&o===i)return!0;let c=this.extractAlias(t);if(c&&n===c)return!0;let l=this.extractAlias(e);return!!(l&&l===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(n+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=await this.resolvePreconditionRef(n[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof dr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,n){let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid")),s=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(n>=Tl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||c.length>0||l.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||c.length>0){let m=o.length>0?"all":"any",g=o.length>0?o:c,_=[];for(let b of g)_.push(await this.loadChildPrecondition(b.object,p,n+1));return{id:i??"",label:s,composite:{op:m,children:_}}}let h=await this.loadChildPrecondition(l[0].object,p,n+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_hostFunction")),d=await this.loadPreconditionQueryRef(e);return!i||!u&&!f&&!d?null:{id:i,label:s,...u&&{sparqlAsk:u},...f&&{hostFunction:f},...d&&{query:d}}}async loadChildPrecondition(e,t,n){let i=await this.resolvePreconditionRef(e);if(!i){let c=e instanceof Jt.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(c,"")}let s=await this.loadPreconditionSubject(i,t,n);if(s)return s;let o=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let n=t[0].object;if(n instanceof dr.IRI)return await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_uid"))??void 0;if(n instanceof Jt.Literal)return this.normalizeWikilink(n.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,n){if(t>=Tl)return null;let i=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!n?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let c=await this.resolveGroundingRef(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(l&&this.matchesReference(l,n.targetClass))return this.loadGroundingDefinition(c,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${n.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof dr.IRI)return e;if(e instanceof Jt.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>=Tl)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!n)return null;let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let N=await this.resolveLabelByUID(o);if(!N)return this.logger.warn(`Grounding ${n}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=N}if(s===kF.GroundingType.SERVICE_CALL){let N=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceId"));N&&(o=N)}let c=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueRef")),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let N=await this.resolveLabelByUID(u);if(!N)return this.logger.warn(`Grounding ${n}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=N}else u&&(f=u);let d=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),m=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_appendExpression")),g=await this.getObsidianWikilinkValue(e,q.Namespace.EXOCMD.term("Grounding_isDefinedBy")),_=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),b=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetClass"));if(b&&!this.looksLikeUUID(b)){let N=await this.findUidByLabel(b);N&&(b=N)}let T=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetPrototype")),I=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetFolder")),w=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_linkBackProperty")),S=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_inputSchema")),R=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_incrementBy")),L=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_shiftDelta")),P;if(R!=null&&R!==""){let N=Number.parseInt(String(R),10);Number.isFinite(N)&&(P=N)}let M=await this.resolvePropertyDefaults(e,n),O=await this.resolveInheritanceRules(e,n),F=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_propertyDefaults"));F!==null&&F!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(n)&&(this.logger.warn(`Grounding ${n}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(n));let Z;s===kF.GroundingType.COMPOSITE&&(Z=await this.loadCompositeSteps(e,t+1));let J;if(S)try{let N=JSON.parse(S);N?.properties&&(J=Object.entries(N.properties).map(([ue,fe])=>{let Ie=fe.type,we=Ie==="string"?fe.format==="asset-reference"?"assetRef":"text":Ie,ve=fe.defaultValue!==void 0?fe.defaultValue:fe.default,Ae={name:ue,type:we,label:fe.title??ue,required:Array.isArray(N.required)&&N.required.includes(ue)};return ve!=null&&(Ae.defaultValue=String(ve)),typeof fe.targetClassUid=="string"&&(Ae.targetClassUid=fe.targetClassUid),Ae}))}catch{}let U=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),K=U!==null&&String(U).trim().toLowerCase()==="true",_e=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_labelTemplate")),le=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_direction")),W;if(le!=null){let N=String(le).trim().toLowerCase();N==="forward"||N==="rollback"?W=N:N!==""&&this.logger.warn(`Grounding ${n}: exocmd__Grounding_direction value '${le}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let H=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_bodyTemplate")),oe=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_templateRef")),xe=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),re=xe!==null&&String(xe).trim().toLowerCase()==="true",Q=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),ie=Q!==null&&String(Q).trim().toLowerCase()==="true",Y=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_omitLabel")),ae=Y!==null&&String(Y).trim().toLowerCase()==="true",Me={id:n,label:i,type:s,targetProperty:o??void 0,targetValueRef:c??void 0,targetValueLiteral:l??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:m??void 0,sparqlUpdate:_??void 0,steps:Z,targetClass:b??void 0,targetPrototype:T??void 0,targetFolder:I??void 0,linkBackProperty:w??void 0,incrementBy:P,shiftDelta:L??void 0,propertyDefault:M.length>0?M:void 0,inheritanceRule:O.length>0?O:void 0,isDefinedBy:g??void 0,prefillLabelWithDate:K||void 0,labelTemplate:_e??void 0,direction:W,bodyTemplate:H??void 0,templateRef:oe??void 0,cloneTargetBody:re||void 0,targetsCreatedInstance:ie||void 0,omitLabel:ae||void 0};return J&&(Me.inputSchema=J),Me}async loadCompositeSteps(e,t){if(t>=Tl)return[];let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of n){let o=null;if(s.object instanceof dr.IRI)o=s.object;else if(s.object instanceof Jt.Literal){let l=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(l)}if(!o)continue;let c=await this.loadGroundingDefinition(o,t);c&&i.push(c)}return i}async resolvePropertyDefaults(e,t){let n=await this.resolvePropertyDefaultsForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,$F.mergePropertyDefaults)(i.propertyDefaults,n):n}async resolvePropertyDefaultsForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[];for(let o of i){let c=await this.resolveRefTripleObject(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("PropertyDefault_property"));if(!l){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(l)?await this.resolveLabelByUID(l):l;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${l}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(c,q.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 this.findUniversalSingleton();if(!e)return this.logger.debug("[CommandResolver] No exocmd__UniversalDefaultTemplate instance found in the store; universal property-defaults and inheritance-rules will not be applied. This verdict is cached until invalidateCache() is called \u2014 if the store was still warming up, the next invalidation re-resolves it."),this._universalCacheValue=null,null;let t=await this.resolvePropertyDefaultsForSubject(e,qF,q.Namespace.EXOCMD.term("Template_propertyDefault")),n=await this.resolveInheritanceRulesForSubject(e,qF,q.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:t,inheritanceRules:n},this._universalCacheValue}async findUniversalSingleton(){let e=q.Namespace.EXOCMD.term("UniversalDefaultTemplate"),t=e.value,i=(await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),e)).map(c=>c.subject).filter(c=>c instanceof dr.IRI);if(i.length>0)return this.pickUniversalSingleton(i);let s=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),void 0),o=[];for(let c of s){let l=!1;if(c.object instanceof dr.IRI)l=c.object.value===t||c.object.value.includes(GF);else if(c.object instanceof Jt.Literal){let u=this.unwrapWikilink(c.object.value);l=u==="exocmd__UniversalDefaultTemplate"||u===GF}l&&c.subject instanceof dr.IRI&&o.push(c.subject)}return this.pickUniversalSingleton(o)}pickUniversalSingleton(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=[...e].sort((n,i)=>n.value.localeCompare(i.value));return this.logger.warn(`Multiple UniversalDefaultTemplate singletons found (${t.length}); selecting deterministically by lexicographic UID order: ${t[0].value}`),t[0]}async resolveInheritanceRules(e,t){let n=await this.resolveInheritanceRulesForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,$F.mergeInheritanceRules)(i.inheritanceRules,n):n}async resolveInheritanceRulesForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[],o=t;for(let c of i){let l=await this.resolveRefTripleObject(c.object);if(!l)continue;let u=await this.resolveLabelRef(l,q.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(l,q.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(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let w=await this.getObsidianName(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!w||!w.trim()){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}this.looksLikeUUID(w)?(h=w,p=await this.resolveLabelByUID(w)??void 0):p=w}let m=await this.tripleStore.match(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),g=[],_=[],b=!1;for(let w of m){let S=null;if(w.object instanceof dr.IRI?S=this.iriToObsidianName(w.object.value)??w.object.value:w.object instanceof Jt.Literal&&(S=this.unwrapWikilink(w.object.value)),!S){b=!0;continue}if(this.looksLikeUUID(S)){_.push(S);let R=await this.resolveLabelByUID(S);R&&g.push(R)}else g.push(S)}if(b){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 T=await this.getLiteralValue(l,q.Namespace.EXOCMD.term("InheritanceRule_priority")),I=50;if(T!==null&&T!==""){let w=Number.parseInt(String(T),10);Number.isFinite(w)&&(I=w)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:g,targetClassExclusionUids:_,priority:I})}return s}async resolveRefTripleObject(e){if(e instanceof dr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let n=await this.getObsidianName(e,t);return n?this.looksLikeUUID(n)?this.resolveLabelByUID(n):n:null}async resolvePropertyDefaultValue(e,t,n){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let c=`${t}|${e}`;return this._fallbackWarnedKeys.has(c)||(this._fallbackWarnedKeys.add(c),this.logger.warn(this.capWarning(`Grounding ${t}: PropertyDefault '${n}' \u2192 value asset ${e} not in store; SKIPPING the property (the executor's own default applies). Previously this emitted a wikilink, i.e. a link written where a value belongs.`))),dz.STRING_SCALAR_PROPERTIES.has(n)?null:`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,n):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,n,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${n}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,n,i,s){let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let c=o.trim();return BF.has(c)?s!==void 0?wz(c,t,s):Sz(c,t):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${c}' \u2014 falling back to wikilink form. Known ids: ${Array.from(BF).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,n,i){let s=await this.getObsidianName(e,q.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let c=await this.findSubjectByUID(s);return c?this.dispatchSubstitutionToken(c,s,n,i,o):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof dr.IRI){if(i.object.value===Ez||i.object.value.includes(VF))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===VF)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("TokenInvocation_token"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as TokenInvocation via its exocmd__TokenInvocation_token property; exo__Instance_class was absent or unresolved.`),!0):!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof dr.IRI){if(i.object.value===bz||i.object.value.includes(UF))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===UF)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as SubstitutionToken via its resolver property; exo__Instance_class was absent or unresolved.`),!0):!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let n=t[0].object;if(n instanceof dr.IRI)return(0,MF.resolveGroundingTypeFromIRI)(n.value);if(n instanceof Jt.Literal){let i=n.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,MF.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 expandPrototypeChain(e){if(!e||!this.normalizeWikilink(e))return[];let t=[e],n=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Tl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let c=null;try{let u=await this.findSubjectByUID(o);if(!u)break;c=await this.getLinkedValue(u,q.Namespace.EXO.term("Asset_prototype"))}catch(u){this.logger.debug(this.capWarning(`[expandPrototypeChain] store lookup failed at hop ${s} for '${i}': ${String(u)}`));break}if(!c)break;let l=this.normalizeWikilink(c).toLowerCase();if(n.has(l))break;n.add(l),t.push(c),i=c}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let n=this.extractPathBasename(t);return n&&this.looksLikeUUID(n)?n:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let n=await this.tripleStore.findSubjectsByUUID(e);if(n.length>0)return n[0]}let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_uid"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e)return n.subject;return null}async getLiteralValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal||i instanceof dr.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);if(!t)return null;let n=await this.getLiteralValue(t,q.Namespace.EXO.term("Asset_label"));return n===null?null:hz.test(n)?(0,jF.iriToObsidianName)(n)??n:n}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(n=>n.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let n=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));c&&o.add(c);let l=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_label"));l&&o.add(l);let u=a((p,h)=>{if(o.has(p))return;let m=n.get(p);(m===void 0||h<m)&&n.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:m}=p;if(m>=Tl||i.has(h.value))continue;i.add(h.value);let g=await this.tripleStore.match(h,q.Namespace.EXO.term("Class_superClass"),void 0);for(let _ of g){let b=_.object;if(!(b instanceof dr.IRI))continue;let T=m+1,I=b.value.startsWith("obsidian://vault/"),w=this.iriToObsidianName(b.value);w&&u(w,T);let S=null;if(I?S=b:w&&(S=await this.resolveClassFileIRI(w)),!S)continue;let R=await this.getLiteralValue(S,q.Namespace.EXO.term("Asset_uid"));R&&u(R,T),i.has(S.value)||f.push({fileIRI:S,depth:T})}}let d=Array.from(n.entries()).map(([p,h])=>({ref:p,depth:h}));return this._ancestorDepthCache.set(e,d),d}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_label"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e&&n.subject instanceof dr.IRI){let i=await this.tripleStore.match(n.subject,q.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Jt.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof dr.IRI){let s=await this.tripleStore.match(i,q.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Jt.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Jt.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let n=await this.tripleStore.match(e,t,void 0),i=[];for(let s of n){let o=s.object;if(o instanceof dr.IRI){let c=await this.tripleStore.match(o,q.Namespace.EXO.term("Asset_uid"),void 0);if(c.length>0&&c[0].object instanceof Jt.Literal)i.push(c[0].object.value);else{let l=o.value.split("/").pop()?.replace(".md","");l&&i.push(l)}}else if(o instanceof Jt.Literal){let c=this.normalizeWikilink(o.value);c&&i.push(c)}}return i}async getLinkedValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.normalizeWikilink(i.value):i instanceof dr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.unwrapWikilink(i.value):i instanceof dr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let n=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(n)return n[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof Jt.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof dr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let n=t[1],i=await this.findSubjectByUID(n);if(!i)return e;let s=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${n}]]`,`[[${n}|${s}]]`):e}iriToObsidianName(e){return(0,jF.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(0,n):t}};Qo.CommandResolver=ST;Qo.CommandResolver=ST=cz([(0,uz.injectable)(),lz("design:paramtypes",[Object,Object])],ST)});var ET=v(wT=>{"use strict";Object.defineProperty(wT,"__esModule",{value:!0});wT.validateExoQLAllowlist=vz;var I0=Kp();function vz(r){if(!r||typeof r!="object")return;let e=r;if(e.type==="update"){let t=r.updates??[];for(let n of t)if(n?.type==="load")throw new I0.ExoQLForbiddenKeywordError("LOAD");throw new I0.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,n=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||n)throw new I0.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)R0(t);if(Array.isArray(e.template))for(let t of e.template)R0(t)}}a(vz,"validateExoQLAllowlist");function R0(r){if(!r||typeof r!="object")return;if(r.type==="service")throw new I0.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(r.patterns))for(let t of r.patterns)R0(t);let e=r.where;if(Array.isArray(e))for(let t of e)R0(t)}a(R0,"walkPatternForBannedKeywords")});var vT=v(C0=>{"use strict";Object.defineProperty(C0,"__esModule",{value:!0});C0.DEFAULT_EVAL_CONFIG=void 0;C0.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var x0=v(TT=>{"use strict";Object.defineProperty(TT,"__esModule",{value:!0});TT.evaluateWithExoEval=Oz;var Tz=Wu(),Az=Xu(),Iz=yf(),Rz=ET(),Cz=vT(),xz=Kp();async function Oz(r,e={}){if(typeof r!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let n=new Tz.ExoQLParser().parse(r);if((0,Rz.validateExoQLAllowlist)(n),!{...Cz.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new xz.ExoQLEvalDisabledError;let s="queryType"in n&&typeof n.queryType=="string"?n.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let c=new Az.ExoQLAlgebraTranslator().translate(n),l=new Iz.ExoQLQueryExecutor(e.store);return l.isAskQuery(c)?{kind:"ask",result:await l.executeAsk(c)}:l.isConstructQuery(c)?{kind:"construct",triples:await l.executeConstruct(c)}:{kind:"select",rows:await l.executeAll(c)}}a(Oz,"evaluateWithExoEval")});var ms=v(O0=>{"use strict";Object.defineProperty(O0,"__esModule",{value:!0});O0.DateFormatter=void 0;var AT=class r{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${i}T${s}:${o}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${n}-${i}]]"`}static getTodayWikilink(){return r.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}static parseWikilink(e){let n=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return n?n[1]:null}static addDays(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),r.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[n,i,s]=t,o=new Date(n,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return r.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return r.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};O0.DateFormatter=AT});var Qp=v(P0=>{"use strict";Object.defineProperty(P0,"__esModule",{value:!0});P0.liveClock=Pz;P0.frozenClock=Dz;function Pz(){return{now:a(()=>new Date,"now")}}a(Pz,"liveClock");function Dz(r){let e=new Date(r);return{now:a(()=>new Date(e.getTime()),"now")}}a(Dz,"frozenClock")});var zF=v(Xo=>{"use strict";var Fz=Xo&&Xo.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Lz=Xo&&Xo.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Jp;Object.defineProperty(Xo,"__esModule",{value:!0});Xo.PreconditionEvaluator=void 0;var Nz=lt(),kz=Wu(),Mz=Xu(),HF=yf(),jz=x0(),Xp=ms(),$z=Qp(),Zp=Jp=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,n){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=n?.clock??(0,$z.liveClock)()}async evaluate(e,t,n){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,n,i)==="yes"}async evaluateNode(e,t,n,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let c=await Promise.all(o.map(l=>this.evaluateNode(l,t,n,i)));return s==="all"?c.includes("no")?"no":c.includes("unknown")?"unknown":"yes":c.includes("yes")?"yes":c.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,n,i);return s==="unknown"?"unknown":s==="yes"?"no":"yes"}return e.sparqlAsk?await this.evaluateSparqlAskMemoized(e.sparqlAsk,t,i)?"yes":"no":e.query?await this.evaluateQueryRef(e.query,t)?"yes":"no":e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,n)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,n){let i=n.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return n.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return!1;let i=this.substituteVariables(n,t),s=await(0,jz.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,n){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,n):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,Jp.SENTINEL_IRI),i=new kz.ExoQLParser().parse(t),o=new Mz.ExoQLAlgebraTranslator().translate(i);return new HF.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,n){let i=this.hostFunctions.get(e);if(!i)return!0;let s=n?{...n,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let n=Jp.TEMPORAL_TOKEN.test(e),i=n?Xp.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||n&&s.day!==i){let l=this.compileAsk(e);if(!l)return!1;s={day:i,compiled:l},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll(Jp.SENTINEL_IRI,t));return await new HF.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let n=this.clock.now(),i=n.toISOString(),s=n.getFullYear(),o=n.getMonth(),c=n.getDate(),l=n.getDay(),u=Xp.DateFormatter.toDateString(n),f=Xp.DateFormatter.toDateString(new Date(s,o,c-1)),d=(l+6)%7,p=Xp.DateFormatter.toDateString(new Date(s,o,c-d)),h=Xp.DateFormatter.toDateString(new Date(s,o,c-d-7)),m=`${s}-${String(o+1).padStart(2,"0")}-01`,g=o===0?11:o-1,b=`${o===0?s-1:s}-${String(g+1).padStart(2,"0")}-01`,T=`${s}-01-01`;return e.replace(/\$target\b/g,`<${t}>`).replace(/\$now\b/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday\b/g,`"${f}"^^xsd:date`).replace(/\$thisWeekStart\b/g,`"${p}"^^xsd:date`).replace(/\$lastWeekStart\b/g,`"${h}"^^xsd:date`).replace(/\$thisMonthStart\b/g,`"${m}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${b}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${T}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};Xo.PreconditionEvaluator=Zp;Zp.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Zp.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;Xo.PreconditionEvaluator=Zp=Jp=Fz([(0,Nz.injectable)(),Lz("design:paramtypes",[Object,Object,Object])],Zp)});var KF=v(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.hasUidFilename=Jo.hasNonUidFilename=void 0;Jo.registerDefaultHostFunctions=Vz;var Uz=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");Jo.hasNonUidFilename=Uz;var Bz=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");Jo.hasUidFilename=Bz;function Vz(r){r.registerHostFunction("hasNonUidFilename",Jo.hasNonUidFilename),r.registerHostFunction("hasUidFilename",Jo.hasUidFilename)}a(Vz,"registerDefaultHostFunctions")});var F0=v(D0=>{"use strict";Object.defineProperty(D0,"__esModule",{value:!0});D0.liveUidGenerator=Gz;D0.seededUidGenerator=Wz;var IT=al();function Gz(){return{next:a(()=>(0,IT.v4)(),"next")}}a(Gz,"liveUidGenerator");var qz="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function Wz(r){let e=0,t=(0,IT.v5)(r,qz);return{next:a(()=>{let n=`${r}#${e}`;return e+=1,(0,IT.v5)(n,t)},"next")}}a(Wz,"seededUidGenerator")});var k0=v(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.registerResolver=_r;sc.getResolver=zz;sc.isResolverModifierAware=Kz;sc.getRegisteredResolverIds=Yz;sc.clearResolvers=Qz;sc.installDefaultResolvers=oK;var Hz=ms(),N0=new Map,RT=new Set;function _r(r,e,t=!1){N0.set(r,e),t&&RT.add(r)}a(_r,"registerResolver");function zz(r){return N0.get(r)}a(zz,"getResolver");function Kz(r){return RT.has(r)}a(Kz,"isResolverModifierAware");function Yz(){return Array.from(N0.keys())}a(Yz,"getRegisteredResolverIds");function Qz(){N0.clear(),RT.clear()}a(Qz,"clearResolvers");function _n(r){return r<10?`0${r}`:String(r)}a(_n,"pad2");var Xz=["January","February","March","April","May","June","July","August","September","October","November","December"],Jz=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Zz=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],eK=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function tK(r){let e=["th","st","nd","rd"],t=r%100;return`${r}${e[(t-20)%10]||e[t]||e[0]}`}a(tK,"ordinalDay");var rK=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function nK(r,e){let t=(r.getHours()+11)%12+1;return e.replace(rK,n=>{switch(n){case"YYYY":return String(r.getFullYear());case"YY":return _n(r.getFullYear()%100);case"MMMM":return Xz[r.getMonth()];case"MMM":return Jz[r.getMonth()];case"MM":return _n(r.getMonth()+1);case"M":return String(r.getMonth()+1);case"Do":return tK(r.getDate());case"DD":return _n(r.getDate());case"D":return String(r.getDate());case"dddd":return Zz[r.getDay()];case"ddd":return eK[r.getDay()];case"HH":return _n(r.getHours());case"H":return String(r.getHours());case"hh":return _n(t);case"h":return String(t);case"mm":return _n(r.getMinutes());case"m":return String(r.getMinutes());case"ss":return _n(r.getSeconds());case"s":return String(r.getSeconds());case"A":return r.getHours()<12?"AM":"PM";case"a":return r.getHours()<12?"am":"pm";default:return n}})}a(nK,"formatDate");function YF(r,e,t){let n=r.getDate(),i=new Date(r.getTime());i.setDate(1),t==="M"?i.setMonth(i.getMonth()+e):i.setFullYear(i.getFullYear()+e);let s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(n,s)),i}a(YF,"addMonthsClamped");function iK(r,e){if(!e)return r;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return r;let n=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(r.getTime());switch(i){case"d":s.setDate(s.getDate()+n);break;case"w":s.setDate(s.getDate()+n*7);break;case"M":s=YF(s,n,"M");break;case"y":s=YF(s,n,"y");break}return isNaN(s.getTime())?r:s}a(iK,"applyDateOffset");function sK(r){if(!r)return{offset:null,format:null};let e=r.indexOf(":");if(e<0)return{offset:r,format:null};let t=r.slice(0,e),n=r.slice(e+1);return{offset:t||null,format:n||null}}a(sK,"parseDateModifier");function L0(r,e){return(t,n)=>{let{offset:i,format:s}=sK(n),o=new Date;return r!==0&&o.setDate(o.getDate()+r),o=iK(o,i),nK(o,s??e)}}a(L0,"makeDateResolver");function oK(){_r("today",()=>{let r=new Date;return`${r.getFullYear()}-${_n(r.getMonth()+1)}-${_n(r.getDate())}`}),_r("todayStart",()=>Hz.DateFormatter.getTodayStartTimestamp()),_r("date",L0(0,"YYYY-MM-DD"),!0),_r("now",L0(0,"YYYY-MM-DDTHH:mm:ss"),!0),_r("tomorrow",L0(1,"YYYY-MM-DD"),!0),_r("yesterday",L0(-1,"YYYY-MM-DD"),!0),_r("target",r=>r.targetIRI?`"[[${r.targetIRI}]]"`:""),_r("targetFolder",r=>{if(!r.targetFilePath)return"";let e=r.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),_r("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.")}),_r("nowTimestamp",()=>{let r=new Date;return`${r.getFullYear()}-${_n(r.getMonth()+1)}-${_n(r.getDate())}T${_n(r.getHours())}:${_n(r.getMinutes())}:${_n(r.getSeconds())}`}),_r("nowDate",()=>{let r=new Date;return`${r.getFullYear()}-${_n(r.getMonth()+1)}-${_n(r.getDate())}`}),_r("nowYear",()=>String(new Date().getFullYear())),_r("nowMonth",()=>_n(new Date().getMonth()+1)),_r("userInputLabel",r=>{let e=r.userInput?.label;return typeof e=="string"?e:""}),_r("userInput",(r,e)=>{if(!e)return null;let t=r.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),_r("targetProperty",(r,e)=>{if(!e||!r.targetFm)return null;let t=r.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),_r("targetRefProperty",(r,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!n||!i)return null;let s=r.targetRefFm?.[n];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),_r("labelAsArray",r=>{let e=r.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),_r("groundingTargetClass",r=>r.groundingTargetClassUid?`"[[${r.groundingTargetClassUid}]]"`:null),_r("targetClassSelf",r=>{if(!r.targetFilePath)return null;let e=r.targetFilePath.replace(/^\/+/,""),n=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return n.length>0?`"[[${n}]]"`:null})}a(oK,"installDefaultResolvers")});var xT=v(M0=>{"use strict";Object.defineProperty(M0,"__esModule",{value:!0});M0.resolveTemplateBody=cK;M0.stripTemplateFrontmatter=lK;var CT=k0();(0,CT.installDefaultResolvers)();var aK=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function cK(r,e={}){return r.replace(aK,(t,n,i)=>{let s=(0,CT.getResolver)(n);if(s===void 0)return t;let o=s(e,i.length>0?i:void 0);return typeof o!="string"||o.length===0?t:(0,CT.isResolverModifierAware)(n)?o:o+i})}a(cK,"resolveTemplateBody");function lK(r){let e=r.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?r.slice(e[0].length):r}a(lK,"stripTemplateFrontmatter")});var U0=v(bf=>{"use strict";Object.defineProperty(bf,"__esModule",{value:!0});bf.registerOrderSpecLoader=uK;bf.clearOrderSpecLoader=fK;bf.loadDefaultSpec=dK;bf.orderProperties=pK;var j0=null,oc,$0=!1;function uK(r){j0=r,oc=void 0,$0=!1}a(uK,"registerOrderSpecLoader");function fK(){j0=null,oc=void 0,$0=!1}a(fK,"clearOrderSpecLoader");function dK(){if(oc!==void 0)return oc;if(!j0)return oc=null,null;try{oc=j0()}catch(r){$0||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",r),$0=!0),oc=null}return oc}a(dK,"loadDefaultSpec");function pK(r,e){if(!e||e.head.length===0&&e.tail.length===0)return r;let t=Object.keys(r),n=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),c=t.filter(u=>!n.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&c.sort((u,f)=>u.localeCompare(f));let l={};for(let u of s)l[u]=r[u];for(let u of c)l[u]=r[u];for(let u of o)l[u]=r[u];return l}a(pK,"orderProperties")});var Xn=v(B0=>{"use strict";Object.defineProperty(B0,"__esModule",{value:!0});B0.DI_TOKENS=void 0;B0.DI_TOKENS={IFileSystemAdapter:Symbol.for("IFileSystemAdapter"),IVaultAdapter:Symbol.for("IVaultAdapter"),IVaultContext:Symbol.for("IVaultContext"),IMultiVaultManager:Symbol.for("IMultiVaultManager"),ILogger:Symbol.for("ILogger"),IEventBus:Symbol.for("IEventBus"),IConfiguration:Symbol.for("IConfiguration"),INotificationService:Symbol.for("INotificationService"),ClassCreationService:Symbol.for("ClassCreationService"),ConceptCreationService:Symbol.for("ConceptCreationService"),GenericAssetCreationService:Symbol.for("GenericAssetCreationService"),TaskStatusService:Symbol.for("TaskStatusService"),EffortStatusWorkflow:Symbol.for("EffortStatusWorkflow"),StatusTimestampService:Symbol.for("StatusTimestampService"),PropertyCleanupService:Symbol.for("PropertyCleanupService"),FolderRepairService:Symbol.for("FolderRepairService"),RenameToUidService:Symbol.for("RenameToUidService"),NoteToRDFConverter:Symbol.for("NoteToRDFConverter"),IVaultSettings:Symbol.for("IVaultSettings"),AreaHierarchyBuilder:Symbol.for("AreaHierarchyBuilder"),ClassHierarchyResolver:Symbol.for("ClassHierarchyResolver")}});var PT=v(V0=>{"use strict";Object.defineProperty(V0,"__esModule",{value:!0});V0.RDFVocabularyMapper=void 0;var Cr=gi(),QF=$e(),Ee=Qt(),OT=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 Cr.Triple(Ee.Namespace.EXO.term("Asset"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDFS.term("Resource"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Class"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDFS.term("Class"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDF.term("Property"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Task"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Project"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Area"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Workflow"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("WorkflowState"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("WorkflowTransition"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Command"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Precondition"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Grounding"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("CommandBinding"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Cr.Triple(Ee.Namespace.EXO.term("Instance_class"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDF.term("type"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Asset_isDefinedBy"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("isDefinedBy"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Class_superClass"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("subClassOf"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_range"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("range"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_domain"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("domain"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_superProperty"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,n){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(n instanceof QF.IRI)s=n;else{let o=n.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,c,l]=o;s=(c==="ems"?Ee.Namespace.EMS:c==="exocmd"?Ee.Namespace.EXOCMD:Ee.Namespace.EXO).term(l)}else s=new QF.IRI(n)}return new Cr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};V0.RDFVocabularyMapper=OT});var G0=v(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.OBSIDIAN_VAULT_SCHEME=void 0;Zo.vaultPathToIRI=hK;Zo.iriToVaultPath=mK;Zo.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function hK(r){let e=r.startsWith("./")?r.slice(2):r;return`${Zo.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(hK,"vaultPathToIRI");function mK(r){if(!r.startsWith(Zo.OBSIDIAN_VAULT_SCHEME))return null;let e=r.slice(Zo.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(mK,"iriToVaultPath")});var W0=v(eh=>{"use strict";Object.defineProperty(eh,"__esModule",{value:!0});eh.derivePath=XF;eh.deriveUrl=gK;eh.deriveLegacyFlatPath=yK;var DT="assetspaces",q0=/^[A-Za-z0-9._-]+$/;function XF(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let n=t.split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!q0.test(i)||!q0.test(s)?null:`${DT}/${i}/${s}`}a(XF,"derivePath");function gK(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${DT}/`;if(!e.startsWith(t))return null;let n=e.slice(t.length).split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!q0.test(i)||!q0.test(s)?null:`https://github.com/${i}/${s}`}a(gK,"deriveUrl");function yK(r){let e=XF(r);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let n=t.startsWith("exoas-")?t.slice(6):t;return n.length===0?null:`${DT}/${n}`}a(yK,"deriveLegacyFlatPath")});var H0=v(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.FILE_SPACE_CLASS_UID=void 0;gs.frontmatterDeclaresFileSpace=bK;gs.discoverFileSpaceExclusions=wK;var _K=W0();gs.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var JF=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,FT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function eL(r){let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;JF.lastIndex=0;let i;for(;(i=JF.exec(n))!==null;)t.push(i[1].trim())}return t}a(eL,"wikilinkTargets");function bK(r){return r?eL(r.exo__Instance_class).some(e=>FT.test(e)&&e.toLowerCase()===gs.FILE_SPACE_CLASS_UID):!1}a(bK,"frontmatterDeclaresFileSpace");function ZF(r,e){try{return r.getFrontmatter(e)}catch{return null}}a(ZF,"readFrontmatterSafe");function SK(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(SK,"readSource");function wK(r){let e=[],t=[],n=[],i=new Map,s=a((c,l)=>{if(FT.test(c))return c.toLowerCase()===gs.FILE_SPACE_CLASS_UID;let u=r.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=ZF(r,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===gs.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(c=>c.some(l=>FT.test(l)&&l.toLowerCase()===gs.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of r.getAllFiles()){let l=ZF(r,c);if(!l)continue;let u=eL(l.exo__Instance_class);if(!u.some(h=>s(h,c.path)))continue;t.push(c.path),o(u)||n.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${gs.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=SK(l);if(f===null){n.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,_K.derivePath)(f);if(d===null){n.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;c.path.startsWith(p)&&n.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${p} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(p)}return{prefixes:e,declarationPaths:t,warnings:n}}a(wK,"discoverFileSpaceExclusions")});var Il=v(jt=>{"use strict";var EK=jt&&jt.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},vK=jt&&jt.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},tL=jt&&jt.__param||function(r,e){return function(t,n){e(t,n,r)}},kT;Object.defineProperty(jt,"__esModule",{value:!0});jt.NoteToRDFConverter=jt.LEGACY_YAML_KEYS=jt.LEGACY_UNPREFIXED_ASSET_FIELDS=jt.UNPREFIXED_ASSET_FIELDS=void 0;jt.canonicalYamlKey=CK;jt.normaliseExcludedFolders=iL;jt.isPathExcluded=sL;var LT=lt(),xr=gi(),ys=$e(),xn=Qe(),rL=nr(),pr=Qt(),nL=Xn(),TK=PT(),AK=$p(),NT=G0(),Ei=pv(),IK=H0();jt.UNPREFIXED_ASSET_FIELDS=new Set(["draft","pinned","aliases"]);jt.LEGACY_UNPREFIXED_ASSET_FIELDS=new Set(["archived"]);jt.LEGACY_YAML_KEYS=new Map([...jt.LEGACY_UNPREFIXED_ASSET_FIELDS].map(r=>[`exo__Asset_${r}`,[r]]));var RK=/^exo__Asset_(.+)$/;function CK(r){let e=RK.exec(r);return e&&jt.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(r)?`exo__Asset_${r}`:r}a(CK,"canonicalYamlKey");function iL(r){return Array.isArray(r)?r.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(iL,"normaliseExcludedFolders");function sL(r,e){if(e.length===0)return!1;let t=r.replace(/\\/g,"/");for(let n of e)if(t.startsWith(n))return!0;return!1}a(sL,"isPathExcluded");function xK(r){if(!r)return"";let e=r.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(xK,"normaliseSubjectIriPrefix");var Al=kT=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=AK.NullLogger,n={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.preResolvedTargetFm=new Map,this.vocabularyMapper=new TK.RDFVocabularyMapper,this.subjectIriPrefix=xK(n.subjectIriPrefix),this.emitInstanceClassAsUid=n.emitInstanceClassAsUid??!1}async convertNote(e){let t=this.vault.getFrontmatterWithFallback?await this.vault.getFrontmatterWithFallback(e):this.vault.getFrontmatter(e);return this.convertNoteFromFrontmatter(e,t)}async convertNoteFromFrontmatter(e,t){if(!t)return[];await this.preResolveWikilinkTargets(t);let n=this.notePathToIRI(e.path),i=pr.Namespace.EXO.term("Asset_filename"),s=new xr.Triple(n,i,new xn.Literal(e.basename));if(Ei.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,n){this.pendingExtraTriples=[];let i=[n],s=this.notePathToIRI(e.path),o,c,l,u=!1,f=pr.Namespace.EXO.term("Statement").value;for(let[g,_]of Object.entries(t)){if(jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(g)&&Object.prototype.hasOwnProperty.call(t,`exo__Asset_${g}`))continue;let b=jt.UNPREFIXED_ASSET_FIELDS.has(g)||jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(g)?`exo__Asset_${g}`:g;if(!this.isExocortexProperty(b))continue;let T=this.propertyKeyToIRI(b),I=Array.isArray(_)?_:[_];for(let w of I)if(!((g==="exo__Asset_label"||jt.UNPREFIXED_ASSET_FIELDS.has(g)||jt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(g))&&(w==null||typeof w=="string"&&w.trim()==="")))if(g==="exo__Instance_class"){let S=this.valueToClassURI(w);i.push(new xr.Triple(s,T,S))}else{let S=await this.valueToRDFObject(w,e,T);if(b==="exo__Statement_subject"&&o===void 0){let R=S.find(L=>L instanceof ys.IRI);R&&(o=R)}else if(b==="exo__Statement_predicate"&&c===void 0){let R=S.find(L=>L instanceof ys.IRI);R&&(c=R)}else b==="exo__Statement_object"&&l===void 0&&(l=S[0]);for(let R of S)if(i.push(new xr.Triple(s,T,R)),this.vocabularyMapper.hasMappingFor(g)&&R instanceof ys.IRI){let L=this.vocabularyMapper.generateMappedTriple(s,g,R);L&&i.push(L)}}if(g==="exo__Instance_class")for(let w of I){let S=this.valueToClassURI(w);if(S instanceof ys.IRI){let R=pr.Namespace.RDF.term("type");i.push(new xr.Triple(s,R,S)),S.value===f&&(u=!0)}}if(g==="exo__Asset_label"){let w=pr.Namespace.RDFS.term("label");for(let S of I)typeof S=="string"&&S.length>0&&i.push(new xr.Triple(s,w,new xn.Literal(S)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let g=pr.Namespace.RDFS.term("label"),_=pr.Namespace.EXO.term("Asset_label"),b=new xn.Literal(e.basename);i.push(new xr.Triple(s,g,b)),i.push(new xr.Triple(s,_,b))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&c&&l&&i.push(new xr.Triple(o,c,l));let m=await this.convertBodyWikilinks(e,s);return i.push(...m),i}async convertExo003Note(e,t){let n=Ei.Exo003Parser.parse(t);if(!n.success||!n.metadata)return[];let i=n.metadata,s=[];switch(i.metadata){case Ei.Exo003MetadataType.Namespace:break;case Ei.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Ei.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Ei.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Ei.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let n=this.notePathToIRI(e.path),i=new ys.IRI(t.uri);return[new xr.Triple(n,pr.Namespace.OWL.term("sameAs"),i),new xr.Triple(i,pr.Namespace.OWL.term("sameAs"),n)]}convertExo003BlankNode(e,t){let n=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new xr.Triple(n,pr.Namespace.OWL.term("sameAs"),new rL.BlankNode(i))]}convertExo003Statement(e,t){let n=[];try{let i=this.createExo003ReferenceResolver(e),s=Ei.Exo003Parser.toTriple(t,i);n.push(s);let o=this.notePathToIRI(e.path);n.push(new xr.Triple(o,pr.Namespace.RDF.term("value"),s.subject))}catch{}return n}async convertExo003Body(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new ys.IRI(c.value):new rL.BlankNode(c.value),f=new ys.IRI(l.value),d=Ei.Exo003Parser.toLiteral(t,s.trim());n.push(new xr.Triple(u,f,d));let p=this.notePathToIRI(e.path);n.push(new xr.Triple(p,pr.Namespace.RDF.term("value"),u))}catch{}return n}createExo003ReferenceResolver(e){return t=>{let n=this.extractWikilink(t),i=n||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.targetFrontmatter(s);if(o&&Ei.Exo003Parser.isExo003Format(o)){let c=Ei.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Ei.Exo003MetadataType.Anchor||l.metadata===Ei.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Ei.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!n&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),n=[],i=[],s=e.strict??!1,o=0,c=0,l=(0,IK.discoverFileSpaceExclusions)(this.vault);for(let g of l.warnings)this.logger.warn(`FileSpace discovery: ${g}`);let u=[...iL(e.excludedFolders),...l.prefixes],f=u.length===0?t:t.filter(g=>!sL(g.path,u)),d=e.onProgress,p=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:kT.INDEX_PROGRESS_INTERVAL,h=f.length,m=0;for(let g of f){if(m++,d&&m%p===0&&m<h)try{d(m,h)}catch{}try{let _=this.vault.getFrontmatter(g),b=_?this.validateExocortexAsset(_,g.basename):null;if(b){if(s)throw new Error(`Invariant violation in "${g.path}": ${b.message}`);i.push({path:g.path,reason:`Invariant violation: ${b.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${g.path}`,{code:b.code,property:b.property,reason:b.message});continue}let T=await this.convertNote(g);n.push(...T)}catch(_){let b=_ instanceof Error?_.message:String(_);if(s)throw new Error(`Invalid IRI for file "${g.path}": ${b}`);i.push({path:g.path,reason:`Invalid IRI: ${b}`}),c++,this.logger.info(`Skipping file with invalid IRI: ${g.path}`,{reason:b})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),c>0&&this.logger.warn(`Skipped ${c} file${c===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:c}),{triples:n,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length},fileSpaces:l}}static inferLabelFromBasename(e){return pr.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let n=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(n):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(n(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&n(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let p=this.removeQuotes(d),m=(this.extractWikilink(p)??p).trim();/^[a-z][a-zA-Z0-9]*__/.test(m)&&/[\s()]/.test(m)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let n of e){let i=(0,NT.vaultPathToIRI)(n.path);ys.IRI.isValidIRI(i)||t.push({path:n.path,reason:`Path "${n.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new ys.IRI((0,NT.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new ys.IRI((0,NT.vaultPathToIRI)(e))}isExocortexProperty(e){return pr.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=pr.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let n=this.targetFrontmatter(t);if(!n)return;let i=n.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof ys.IRI&&(this.pendingExtraTriples.push(new xr.Triple(e,pr.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new xr.Triple(e,pr.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,n){if(typeof e=="string"){let i=this.removeQuotes(e);if(n?.value.endsWith("#TokenInvocation_parameter"))return[new xn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new xn.Literal(u);if(n?.value.endsWith("#Grounding_targetValueRef")||n?.value.endsWith("#Grounding_targetValueSubstitution")||n?.value.endsWith("#Grounding_targetClass")||n?.value.endsWith("#Grounding_type")||n?.value.endsWith("#PropertyDefault_value"))return[l];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let m=this.targetFrontmatter(o);if(m){let I=m.exo__Asset_label;if(typeof I=="string"){let w=this.expandClassValue(I);if(w)return this.emitTypeTripleForEnumInstance(w,o),[w]}}let g=n?.value.endsWith("#Asset_prototype")||n?.value.endsWith("/Asset_prototype"),b=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(I=>I.trim()).filter(Boolean),T=b.length>0&&b.some(I=>n?.value.endsWith(`#${I}`));return g||T?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new xn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new xn.Literal(i,pr.Namespace.XSD.term("dateTime"))]:[new xn.Literal(i)]}return typeof e=="boolean"?[new xn.Literal(e.toString())]:typeof e=="number"?[new xn.Literal(e.toString(),pr.Namespace.XSD.term("decimal"))]:e instanceof Date?[new xn.Literal(e.toISOString(),pr.Namespace.XSD.term("dateTime"))]:[new xn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1];return n.includes("|")?n.split("|")[0]:n}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1],i=n.indexOf("|");return i>=0?n.substring(i+1).trim():null}targetFrontmatter(e){return this.vault.getFrontmatter(e)??this.preResolvedTargetFm.get(e.path)??null}async preResolveWikilinkTargets(e){let t=this.vault.getFrontmatterWithFallback?.bind(this.vault);if(t)for(let n of Object.values(e)){let i=Array.isArray(n)?n:n==null?[]:[n];for(let s of i){if(typeof s!="string")continue;let o=this.removeQuotes(s),c=this.extractWikilink(o);if(!c||!this.isUUID(c))continue;let l=this.vault.getFirstLinkpathDest(c,"");!l||this.preResolvedTargetFm.has(l.path)||this.vault.getFrontmatter(l)||this.preResolvedTargetFm.set(l.path,await t(l))}}}valueToClassURI(e){if(typeof e!="string")return new xn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):l;let u=this.targetFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):d}}return this.notePathToIRI(c.path)}}return new xn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:pr.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),n=pr.Namespace.fromPropertyKey(t);return!n||/[\s()]/.test(n.localName)?null:n.namespace.term(n.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,n,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(n=i.exec(e))!==null;)n[1]&&t.add(n[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=pr.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);n.push(new xr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?n.push(new xr.Triple(t,c,f)):n.push(new xr.Triple(t,c,new xn.Literal(l)))}else n.push(new xr.Triple(t,c,new xn.Literal(l)))}}catch{}return n}};jt.NoteToRDFConverter=Al;Al.INDEX_PROGRESS_INTERVAL=200;Al.SkippedFileInfo=class{constructor(r,e){this.path=r,this.reason=e}};Al.VaultValidationResult=class{constructor(r,e,t){this.triples=r,this.skippedFiles=e,this.summary=t}};Al.VaultValidationOptions=class{constructor(r=!1){this.strict=r}};jt.NoteToRDFConverter=Al=kT=EK([(0,LT.injectable)(),tL(0,(0,LT.inject)(nL.DI_TOKENS.IVaultAdapter)),tL(1,(0,LT.inject)(nL.DI_TOKENS.ILogger)),vK("design:paramtypes",[Object,Object,Object])],Al)});var Rl=v(z0=>{"use strict";Object.defineProperty(z0,"__esModule",{value:!0});z0.FrontmatterService=void 0;var oL=U0(),MT=Fu(),Sf=Il(),th=class r{static{a(this,"FrontmatterService")}parse(e){let t=e.match(r.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let n={},i=t.content.split(/\r?\n/),s=null,o=null,c=a(()=>{s!==null&&o!==null&&(n[s]=o),s=null,o=null},"flushArray");for(let l of i){let u=/^ {2}- (.*)$/.exec(l);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}c();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(l);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(s=d,o=[]):n[d]=p}return c(),n}updateProperty(e,t,n){t=(0,Sf.canonicalYamlKey)(r.normalizeIRI(t)),typeof n=="string"&&(n=r.normalizeIRIValue(n));let i=this.parse(e),s=this.serializeValue(t,n);if(!i.exists)return`---
|
|
73
73
|
${s}
|
|
74
74
|
---
|
|
75
75
|
${e}`;let o=i.content,c=o.split(`
|
|
@@ -332,7 +332,7 @@ To resolve:
|
|
|
332
332
|
path = ${e}
|
|
333
333
|
url = ${t}
|
|
334
334
|
`;return{content:r+i+s,added:!0}}a(une,"appendGitmodulesEntry");function fne(r,e){let t=r.split(/\r?\n/),n=[],i=!1,s=new RegExp(`^\\[submodule\\s+"${UI(e)}"\\]\\s*$`);for(let l of t){if(i){if(/^\[.+\]\s*$/.test(l)){i=!1,n.push(l);continue}continue}if(s.test(l)){i=!0;continue}n.push(l)}let o=[],c=!1;for(let l of n){let u=l.trim().length===0;u&&c||(o.push(l),c=u)}return o.join(`
|
|
335
|
-
`)}a(fne,"stripGitmodulesEntry")});var Qf=v(BI=>{"use strict";Object.defineProperty(BI,"__esModule",{value:!0});BI.gitBlobSha=dne;async function dne(r,e){let t=new TextEncoder,n=typeof r=="string"?t.encode(r):r,i=t.encode(`blob ${n.byteLength}\0`),s=new Uint8Array(i.byteLength+n.byteLength);return s.set(i,0),s.set(n,i.byteLength),e(s)}a(dne,"gitBlobSha")});var Ph=v(Eb=>{"use strict";Object.defineProperty(Eb,"__esModule",{value:!0});Eb.extractAssetUid=VM;Eb.detectChanges=hne;var pne=Qf();function VM(r){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(r);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(VM,"extractAssetUid");async function hne(r){let{localFiles:e,cachedEntries:t,watermark:n,actualBaseTreeSha:i,sha1:s}=r;if(n===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${n.lastSyncedSha} not resolvable on remote`};if(i!==n.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${n.rootTreeSha} != actual ${i} at ${n.lastSyncedSha}`};let o=[],c=new Map;for(let[w,S]of e){let R=await(0,pne.gitBlobSha)(S,s);c.set(w,R),o.push({path:w,blobSha:R,uid:typeof S=="string"?VM(S):void 0})}if(t!==void 0)for(let[w,S]of t)c.set(w,S.blobSha),o.push({path:w,blobSha:S.blobSha,uid:S.uid});let l=[],u=[],f=[],d=[],p=new Map;for(let w of o){if(w.uid===void 0)continue;let S=p.get(w.uid)??[];S.push(w.path),p.set(w.uid,S)}let h=new Map;for(let w of n.files){if(w.uid===void 0)continue;let S=h.get(w.uid)??[];S.push(w.path),h.set(w.uid,S)}let m=new Set;for(let[w,S]of p)S.length>1&&m.add(w);for(let[w,S]of h)S.length>1&&m.add(w);for(let w of[...m].sort()){let S=p.get(w)??[],R=S.length>1?`on disk (${S.join(", ")})`:`in the sync base (${(h.get(w)??[]).join(", ")})`;d.push(`duplicate uid ${w} ${R} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let g=new Map,_=[];for(let w of n.files)w.uid!==void 0&&!m.has(w.uid)?g.set(w.uid,w):_.push(w);let b=[],T=new Set;for(let w of o){let S=w.uid!==void 0&&!m.has(w.uid)?g.get(w.uid):void 0;w.uid!==void 0&&S!==void 0?(T.add(w.uid),(S.blobSha!==w.blobSha||S.path!==w.path)&&u.push({path:w.path,uid:w.uid,blobSha:w.blobSha,...S.path!==w.path?{basePath:S.path}:{}})):b.push(w)}let I=new Map;for(let w of _)I.set(w.path,w);for(let[w,S]of g)T.has(w)||I.set(S.path,S);for(let w of b){let S=I.get(w.path);S!==void 0?(I.delete(w.path),S.blobSha!==w.blobSha&&u.push({path:w.path,uid:w.uid,blobSha:w.blobSha})):l.push({path:w.path,uid:w.uid,blobSha:w.blobSha})}for(let w of I.values())f.push({path:w.path,uid:w.uid,blobSha:w.blobSha});return{kind:"changes",added:l,modified:u,deleted:f,warnings:d,diskBlobShas:c,duplicateUids:m}}a(hne,"detectChanges")});var WM=v(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});Dh.rewriteAssetUid=GM;Dh.findDuplicateUidGroups=qM;Dh.planDuplicateUidFix=gne;var mne=Ph();function GM(r,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(r);if(t===null)return r;let n=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return n===t[2]?r:r.slice(0,t.index)+t[1]+n+t[3]+r.slice(t.index+t[0].length)}a(GM,"rewriteAssetUid");function qM(r){let e=new Map;for(let t of r){let n=(0,mne.extractAssetUid)(t.content);if(n===void 0)continue;let i=e.get(n)??[];i.push(t.path),e.set(n,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>({uid:t,paths:n}))}a(qM,"findDuplicateUidGroups");function gne(r,e){let t=new Map(r.map(i=>[i.path,i.content])),n=[];for(let i of qM(r)){let s=[...i.paths].sort((o,c)=>o.localeCompare(c));for(let o of s.slice(1)){let c=t.get(o);if(c===void 0)continue;let l=e(),u=GM(c,l);u!==c&&n.push({path:o,fromUid:i.uid,toUid:l,content:u})}}return n}a(gne,"planDuplicateUidFix")});var Xf=v(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.getHeadSha=_ne;Gl.getCommitInfo=bne;Gl.getTree=Sne;Gl.getBlobText=wne;Gl.getBlobBytes=Ene;var HM=Nu(),yne="https://api.github.com";function Fh(r){return(r??yne).replace(/\/$/,"")}a(Fh,"api");function Vl(r){return r!==null&&typeof r=="object"?r:void 0}a(Vl,"asRecord");function bo(r,e){let n=Vl(r)?.[e];return typeof n=="string"?n:void 0}a(bo,"readString");async function _ne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(n)}`}),o=bo(Vl(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${n}`);return o}a(_ne,"getHeadSha");async function bne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(n)}`}),o=Vl(s?.json),c=bo(o,"sha"),l=bo(o?.tree,"sha");if(!c||!l)throw new Error(`ExoSync: malformed commit response for ${n}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>bo(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:c,treeSha:l,parents:f}}a(bne,"getCommitInfo");async function Sne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(n)}?recursive=1`}),o=Vl(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${n} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let c=o?.tree;if(!Array.isArray(c))throw new Error(`ExoSync: malformed tree response for ${n}`);let l=[];for(let u of c){let f=Vl(u);if(f?.type!=="blob")continue;let d=bo(f,"path"),p=bo(f,"sha"),h=typeof f.size=="number"?f.size:void 0;d&&p&&l.push({path:d,blobSha:p,...h!==void 0?{size:h}:{}})}return l}a(Sne,"getTree");async function wne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=Vl(s?.json),c=bo(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return bo(o,"encoding")==="utf-8"?c:(0,HM.base64ToUtf8)(c)}a(wne,"getBlobText");async function Ene(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=Vl(s?.json),c=bo(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return bo(o,"encoding")==="utf-8"?new TextEncoder().encode(c):(0,HM.base64ToBytes)(c)}a(Ene,"getBlobBytes")});var KM=v(VI=>{"use strict";Object.defineProperty(VI,"__esModule",{value:!0});VI.checkParkedStaleness=Tne;var vne=Xf();async function Tne(r,e){let t={repoKey:r.repoKey,localPath:r.localPath},n=e.redact??(o=>o),i=null;try{let c=(await e.watermarks.get(r.repoKey))?.lastSyncedSha??"";c.length>0&&(i=c)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:`watermark unreadable: ${n(zM(o))}`}}if(i===null)return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:"never synced on this device (no watermark)"};let s;try{s=await(0,vne.getHeadSha)(e.transport,r.owner,r.repo,r.branch,e.baseURL)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:i,remoteHeadSha:null,reason:`remote unreachable: ${n(zM(o))}`}}return{...t,freshness:s===i?"current":"behind",lastSyncedSha:i,remoteHeadSha:s}}a(Tne,"checkParkedStaleness");function zM(r){return r instanceof Error?r.message:String(r)}a(zM,"errorText")});var WI=v(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.SyncPhaseTimer=hr.SYNC_PHASES=void 0;hr.classifyRestPhase=Ane;hr.emptyTimings=QM;hr.totalMs=vb;hr.addTimings=XM;hr.aggregateTimings=Ine;hr.dominantPhase=Rne;hr.fmtMs=Lh;hr.formatTimingsLine=Cne;hr.formatRepoTimings=xne;hr.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function qI(){let r={};for(let e of hr.SYNC_PHASES)r[e]=0;return r}a(qI,"zeroDurations");function YM(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(YM,"zeroCounts");function Ane(r){if(r.method!=="GET")return"restPush";let e=r.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(Ane,"classifyRestPhase");var GI=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=qI(),this.counts=YM()}async time(e,t){let n=this.now();try{return await t()}finally{this.durations[e]+=this.now()-n}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};hr.SyncPhaseTimer=GI;function QM(){return{durations:qI(),counts:YM()}}a(QM,"emptyTimings");function vb(r){let e=0;for(let t of hr.SYNC_PHASES)e+=r.durations[t];return e}a(vb,"totalMs");function XM(r,e){let t=qI();for(let n of hr.SYNC_PHASES)t[n]=r.durations[n]+e.durations[n];return{durations:t,counts:{filesRead:r.counts.filesRead+e.counts.filesRead,filesHashed:r.counts.filesHashed+e.counts.filesHashed,filesWritten:r.counts.filesWritten+e.counts.filesWritten,restCalls:r.counts.restCalls+e.counts.restCalls}}}a(XM,"addTimings");function Ine(r){let e=QM();for(let t of r)t.timings!==void 0&&(e=XM(e,t.timings));return e}a(Ine,"aggregateTimings");function Rne(r){let e=vb(r);if(e<=0)return null;let t=hr.SYNC_PHASES[0],n=-1;for(let i of hr.SYNC_PHASES)r.durations[i]>n&&(n=r.durations[i],t=i);return{phase:t,ms:n,pct:n/e*100}}a(Rne,"dominantPhase");function Lh(r){return r>=1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`}a(Lh,"fmtMs");function Cne(r){let e=vb(r);if(e<=0)return"";let t=hr.SYNC_PHASES.filter(n=>r.durations[n]>0).sort((n,i)=>r.durations[i]-r.durations[n]).map(n=>`${n} ${Lh(r.durations[n])} ${Math.round(r.durations[n]/e*100)}%`);return`\u23F1 ExoSync ${Lh(e)} \u2014 ${t.join(" \xB7 ")} (${r.counts.filesHashed} hashed, ${r.counts.filesRead} read, ${r.counts.restCalls} REST)`}a(Cne,"formatTimingsLine");function xne(r,e){let t=hr.SYNC_PHASES.map(n=>`${n}=${Lh(e.durations[n])}`);return`[ExoSync timings] ${r}: total ${Lh(vb(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(xne,"formatRepoTimings")});var Tb=v(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.LocalOutboxStore=hc.OUTBOX_REMOTE_ABSENT=hc.OUTBOX_STORE_FILENAME=void 0;hc.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";hc.OUTBOX_REMOTE_ABSENT=" absent";function HI(r,e){return`${r}\0${e}`}a(HI,"outboxKey");function JM(r){if(r===null||typeof r!="object")return!1;let e=r;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(JM,"isEntry");var zI=class{static{a(this,"LocalOutboxStore")}constructor(e){this.writeChain=Promise.resolve(),this.io=e.io,this.now=e.now??(()=>new Date().toISOString())}async enqueue(e){await this.mutate(t=>{t.entries[HI(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(n=>{delete n.entries[HI(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(JM)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[HI(e,t)];return i!==void 0&&JM(i)}async mutate(e){let t=this.writeChain.then(async()=>{let n=await this.read();e(n),await this.io.writeAtomic(JSON.stringify(n,null,2))});return this.writeChain=t.catch(()=>{}),t}async read(){try{let e=await this.io.read();if(e===null)return{version:1,entries:{}};let t=JSON.parse(e);if(t===null||typeof t!="object")return{version:1,entries:{}};let n=t.entries;return n===null||typeof n!="object"?{version:1,entries:{}}:{version:1,entries:{...n}}}catch{return{version:1,entries:{}}}}};hc.LocalOutboxStore=zI});var Ab=v(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.SpaceSpecAccumulator=Nn.SYNC_BRANCH=Nn.ASSET_SPACE_CLASS_UID=void 0;Nn.isAssetSpaceFrontmatter=t4;Nn.isFileSpaceFrontmatter=r4;Nn.readSpaceSource=n4;Nn.parseStrictGitHubRepoURL=i4;Nn.classifySpaceDeclaration=Fne;var One=H0(),Pne=W0();Nn.ASSET_SPACE_CLASS_UID="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb";Nn.SYNC_BRANCH="main";var ZM=/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]/gi;function e4(r,e){let t=r.exo__Instance_class,n=Array.isArray(t)?t:[t];for(let i of n){if(typeof i!="string")continue;ZM.lastIndex=0;let s;for(;(s=ZM.exec(i))!==null;)if(s[1].toLowerCase()===e)return!0}return!1}a(e4,"instanceClassHasUid");function t4(r){return e4(r,Nn.ASSET_SPACE_CLASS_UID)}a(t4,"isAssetSpaceFrontmatter");function r4(r){return e4(r,One.FILE_SPACE_CLASS_UID)}a(r4,"isFileSpaceFrontmatter");function n4(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(n4,"readSpaceSource");var Dne=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/;function i4(r){if(typeof r!="string"||r.length===0||r.length>256||!Dne.test(r))return null;let e=r.slice(19),[t,n,...i]=e.split("/");if(i.length>0||t===".."||n===".."||n.startsWith("."))return null;let s=n.replace(/\.git$/,"");return s.length===0?null:{owner:t,repo:s}}a(i4,"parseStrictGitHubRepoURL");function Fne(r,e){let t=t4(r),n=r4(r);if(!t&&!n)return{kind:"not-space"};let i;t&&n&&(i=`declaration at ${e} carries BOTH exo__AssetSpace and exo__FileSpace classes (disjoint) \u2014 treating as AssetSpace (conservative)`);let s=t?"asset":"file",o=n4(r);if(o===null)return s==="file"?{kind:"skip",warning:`skipped FileSpace at ${e}: no exo__AssetSpace_source/_git \u2014 mount path underivable`}:{kind:"skip"};let c=o.replace(/\.git$/i,""),l=i4(c);if(l===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: source is not a plain https://github.com/<owner>/<repo> URL`};let u=(0,Pne.derivePath)(c);if(u===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: cannot derive mount path from source`};let f=`${l.owner}/${l.repo}#${Nn.SYNC_BRANCH}`,d=r.exo__Asset_uid,p=typeof d=="string"&&d.trim().length>0?d.trim():void 0;return{kind:"candidate",candidate:{spec:{owner:l.owner,repo:l.repo,branch:Nn.SYNC_BRANCH,repoKey:f,localPath:u,...s==="file"?{spaceKind:s}:{}},spaceKind:s,...p!==void 0?{asUid:p}:{}},...i!==void 0?{warning:i}:{}}}a(Fne,"classifySpaceDeclaration");var KI=class{static{a(this,"SpaceSpecAccumulator")}constructor(){this.specs=[],this.warnings=[],this.asUidByRepoKey=new Map,this.seen=new Set,this.kindByRepoKey=new Map}offer(e){let{spec:t,spaceKind:n}=e;if(this.seen.has(t.repoKey)){let i=this.kindByRepoKey.get(t.repoKey);if(i!==void 0&&i!==n&&(this.warnings.push(`repo ${t.repoKey} is declared as BOTH AssetSpace and FileSpace by different assets \u2014 treating as AssetSpace (deterministic, conservative); fix the vault (disjoint subtypes)`),i==="file")){this.kindByRepoKey.set(t.repoKey,"asset");let s=this.specs.find(o=>o.repoKey===t.repoKey);s!==void 0&&delete s.spaceKind}return null}return this.seen.add(t.repoKey),this.kindByRepoKey.set(t.repoKey,n),t}commit(e){this.specs.push(e.spec),e.asUid!==void 0&&this.asUidByRepoKey.set(e.spec.repoKey,e.asUid)}};Nn.SpaceSpecAccumulator=KI});var Ib=v(Jf=>{"use strict";Object.defineProperty(Jf,"__esModule",{value:!0});Jf.REF_NOT_FOUND_HINT=void 0;Jf.isAuthError=Lne;Jf.isRefNotFoundError=Nne;var s4=Ab();function Lne(r){let e=r instanceof Error?r.message:String(r);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(Lne,"isAuthError");function Nne(r){let e=r instanceof Error?r.message:String(r);return/\/git\/refs\/heads\/\S* → HTTP 404\b/.test(e)}a(Nne,"isRefNotFoundError");Jf.REF_NOT_FOUND_HINT=`GitHub answers 404 for a private repo outside a fine-grained PAT's repository allowlist (existence-hiding), for a deleted/renamed repo, and for a visible repo that has no \`${s4.SYNC_BRANCH}\` branch (ExoSync syncs \`${s4.SYNC_BRANCH}\` only) \u2014 check the token's repository allowlist first (R8)`});var YI=v(Rb=>{"use strict";Object.defineProperty(Rb,"__esModule",{value:!0});Rb.scanForSecrets=kne;Rb.redactSecrets=Mne;var o4=[{kind:"github-token",re:/gh[pousr]_[A-Za-z0-9_]{36,}/},{kind:"github-fine-grained-token",re:/github_pat_[A-Za-z0-9_]{22,}_[A-Za-z0-9_]{59,}/},{kind:"private-key",re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/}];function kne(r){let e=[];for(let[t,n]of r)for(let{kind:i,re:s}of o4)s.test(n)&&e.push({path:t,kind:i});return e}a(kne,"scanForSecrets");function Mne(r){let e=r;for(let{kind:t,re:n}of o4)e=e.replace(new RegExp(n.source,"g"),`[REDACTED:${t}]`);return e}a(Mne,"redactSecrets")});var JI=v(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});mc.caseInsensitiveHeaderGetter=jne;mc.parseRetryAfterMs=a4;mc.extractRateLimitFields=c4;mc.getRateLimitFields=$ne;mc.attachRateLimitFields=l4;mc.enrichRateLimitError=Une;function jne(r){let e=new Map;if(r&&typeof r=="object")for(let[t,n]of Object.entries(r))typeof n=="string"&&e.set(t.toLowerCase(),n);return t=>e.get(t.toLowerCase())}a(jne,"caseInsensitiveHeaderGetter");function XI(r){if(r==null)return;let e=r.trim();if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0}a(XI,"parseIntHeader");function a4(r,e=Date.now){if(r==null)return;let t=r.trim();if(t.length===0)return;let n=XI(t);if(n!==void 0)return Math.max(0,n*1e3);let i=Date.parse(t);if(!Number.isNaN(i))return Math.max(0,i-e())}a(a4,"parseRetryAfterMs");function c4(r,e=Date.now){let t={},n=a4(r("retry-after"),e);n!==void 0&&(t.retryAfterMs=n);let i=XI(r("x-ratelimit-reset"));i!==void 0&&(t.rateLimitReset=i);let s=XI(r("x-ratelimit-remaining"));return s!==void 0&&(t.rateLimitRemaining=s),t}a(c4,"extractRateLimitFields");function $ne(r){if(r===null||typeof r!="object")return{};let e=r,t={};return typeof e.retryAfterMs=="number"&&(t.retryAfterMs=e.retryAfterMs),typeof e.rateLimitReset=="number"&&(t.rateLimitReset=e.rateLimitReset),typeof e.rateLimitRemaining=="number"&&(t.rateLimitRemaining=e.rateLimitRemaining),t}a($ne,"getRateLimitFields");function QI(r,e,t){Object.defineProperty(r,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}a(QI,"defineHidden");function l4(r,e){return e.retryAfterMs!==void 0&&QI(r,"retryAfterMs",e.retryAfterMs),e.rateLimitReset!==void 0&&QI(r,"rateLimitReset",e.rateLimitReset),e.rateLimitRemaining!==void 0&&QI(r,"rateLimitRemaining",e.rateLimitRemaining),r}a(l4,"attachRateLimitFields");function Une(r,e,t=Date.now){return l4(r,c4(e,t))}a(Une,"enrichRateLimitError")});var Cb=v(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.DEFAULT_MAX_RETRIES=Zi.MIN_RATE_LIMIT_WAIT_MS=void 0;Zi.isRateLimitError=u4;Zi.createRateLimitBudget=Vne;Zi.withRateLimitBackoff=Wne;var Bne=JI();function u4(r){let e=r instanceof Error?r.message:String(r);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(u4,"isRateLimitError");Zi.MIN_RATE_LIMIT_WAIT_MS=6e4;Zi.DEFAULT_MAX_RETRIES=6;function Vne(r){let e=!(r>0),t=e?Number.POSITIVE_INFINITY:r;return{reset(){t=e?Number.POSITIVE_INFINITY:r},tryReserve(n){return n<=0?!0:n<=t?(t-=n,!0):!1}}}a(Vne,"createRateLimitBudget");var Gne=a(r=>new Promise(e=>setTimeout(e,r)),"defaultSleep");function qne(r,e,t,n,i,s){let o=(0,Bne.getRateLimitFields)(r);if(typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0)return o.retryAfterMs;if(o.rateLimitRemaining===0&&typeof o.rateLimitReset=="number"){let l=o.rateLimitReset*1e3-s();if(l>0)return l}let c=t*2**e*(1+i());return Math.max(n,c)}a(qne,"computeRateLimitDelay");function Wne(r,e={}){let t=e.maxRetries??Zi.DEFAULT_MAX_RETRIES,n=e.baseDelayMs??1e3,i=Math.max(Zi.MIN_RATE_LIMIT_WAIT_MS,e.minRateLimitWaitMs??Zi.MIN_RATE_LIMIT_WAIT_MS),s=e.budget,o=e.sleep??Gne,c=e.random??Math.random,l=e.now??(()=>Date.now());return async u=>{let f=0;for(;;)try{return await r(u)}catch(d){if(!u4(d)||f>=t)throw d;let p=qne(d,f,n,i,c,l);if(s!==void 0&&!s.tryReserve(p))throw d;f++,await o(p)}}}a(Wne,"withRateLimitBackoff")});var xb=v(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.DEFAULT_MAX_FILE_BYTES=Ea.InMemoryQuarantineStore=void 0;Ea.contentEquals=Hne;Ea.isSyncablePath=zne;Ea.isFileSpaceSyncablePath=Kne;function Hne(r,e){if(r===void 0||e===void 0||typeof r=="string"&&typeof e=="string")return r===e;if(typeof r=="string"||typeof e=="string"||r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}a(Hne,"contentEquals");var ZI=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};Ea.InMemoryQuarantineStore=ZI;function zne(r){return r.endsWith(".md")&&!r.includes(".local.")&&!r.includes(".conflict.")}a(zne,"isSyncablePath");function Kne(r){return!r.includes(".local.")&&!r.includes(".conflict.")}a(Kne,"isFileSpaceSyncablePath");Ea.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var S4=v(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.SyncEngine=Sn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=Sn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=Sn.DEFAULT_MAX_PUSH_RETRIES=void 0;Sn.syncProgressPhaseText=Qne;Sn.isNonFastForwardError=b4;Sn.orderChildrenFirst=iie;var f4=Sb(),d4=WI(),dt=Xf(),So=Ph(),Yne=Nu(),ql=Qf(),eR=Tb(),tR=Ib(),p4=YI(),h4=Cb(),wo=xb();Sn.DEFAULT_MAX_PUSH_RETRIES=3;Sn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=3e5;Sn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function Qne(r){switch(r.phase){case"reading-local":return r.detail!==void 0?`reading local files ${r.detail.done}\u2026`:"reading local files\u2026";case"detecting":return"detecting changes\u2026";case"pulling-remote":return"pulling remote tree\u2026";case"fetching-blobs":return r.detail!==void 0?`fetching remote files ${r.detail.done}/${r.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return r.detail!==void 0?`writing files ${r.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return r.phase}}a(Qne,"syncProgressPhaseText");var m4=25,Xne=10,Jne=6,Zne=500,eie=25;function tie(r){try{return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{return null}}a(tie,"decodeUtf8Strict");function rie(r){return typeof r=="string"?r:{base64:(0,Yne.bytesToBase64)(r)}}a(rie,"toCommitContent");async function g4(r,e){if(r.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return r.readBinary(e)}a(g4,"readBinaryStrict");async function nie(r,e,t){if(r.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return r.writeBinary(e,t)}a(nie,"writeBinaryStrict");function y4(r){return r.length===0||r.startsWith("/")||r.includes("\\")?!1:r.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(y4,"isSafeRepoRelativePath");function b4(r){let e=r instanceof Error?r.message:String(r);return/HTTP 422/.test(e)&&/git\/refs/.test(e)||/ref update mismatch/.test(e)||/HTTP 422/.test(e)&&/git\/trees/.test(e)&&/BadObjectState/.test(e)}a(b4,"isNonFastForwardError");function iie(r){let e=a(t=>t.split("/").filter(n=>n.length>0).length,"depth");return[...r].sort((t,n)=>e(n.localPath)-e(t.localPath))}a(iie,"orderChildrenFirst");function _4(r,e){let t=new Map(r.map(o=>[o.path,o])),n=new Set,i=[];for(let o of e){n.add(o.path);let c=t.get(o.path);(c===void 0||c.blobSha!==o.blobSha)&&i.push(o)}let s=r.filter(o=>!n.has(o.path));return{changed:i,deleted:s}}a(_4,"diffTrees");function sie(r){let e=r instanceof Error?r.message:String(r);return/→ HTTP (?:404|422)\b/.test(e)}a(sie,"isCommitUnknownError");function va(r){return r instanceof Error?r.message:String(r)}a(va,"errMsg");function oie(r,e,t){if(t.size===0)return r;let n=new Map(e.files.map(o=>[o.path,o])),i=new Set(r.map(o=>o.path)),s=[];for(let o of r){if(!t.has(o.path)){s.push(o);continue}let c=n.get(o.path);c!==void 0&&s.push(c)}for(let o of t){if(i.has(o))continue;let c=n.get(o);c!==void 0&&s.push(c)}return s}a(oie,"applyWatermarkPins");var rR={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function nR(r){return new Map(r.map(e=>[e.path,e.blobSha]))}a(nR,"treeByPath");function Ob(r){return[...r.quarantineEntries.map(e=>e.path),...r.resolvedQuarantineEntries.map(e=>e.path)]}a(Ob,"quarantinedPathsOf");var iR=class{static{a(this,"SyncEngine")}constructor(e){this.activeTimer=null,this.activeLocalIoProgress=null,this.opInProgress=!1,this.deps=e,this.now=e.now??(()=>Date.now()),this.rateLimitBudget=(0,h4.createRateLimitBudget)(e.backoff?.maxTotalRateLimitWaitMs??Sn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS),this.transport=this.instrumentTransport((0,h4.withRateLimitBackoff)(e.transport,{...e.backoff,budget:this.rateLimitBudget,now:this.now})),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpRest(),n.time((0,d4.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpHashed(),n.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((c,l)=>{let u=this.activeTimer;return u===null?l():u.time(c,l)},"timed"),n={list:a(()=>t("localList",()=>e.list()),"list"),read:a(c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(c))),"read"),write:a((c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(c,l))),"write"),delete:a(c=>e.delete(c),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(n.readBinary=c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(c))));let s=e.writeBinary?.bind(e);s!==void 0&&(n.writeBinary=(c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(c,l))));let o=e.stat?.bind(e);return o!==void 0&&(n.stat=c=>t("localList",()=>o(c))),n}busyResult(e){return{repoKey:e.repoKey,status:"busy",pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:[],deferredDeletes:[],detail:"another sync operation is in progress (D11 guard) \u2014 retry after it finishes"}}modeOps(e){let t=e.spaceKind==="file",n=t?wo.isFileSpaceSyncablePath:wo.isSyncablePath,i=this.deps.maxFileBytes??wo.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:n,treeFilter:a(s=>n(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,dt.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(n.treeFilter),l=[];for(let u of c){let f=t.get(u.path);f!==void 0&&await(0,ql.gitBlobSha)(f,this.sha1)===u.blobSha&&l.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${l.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:l,spaceKind:"file"}}async syncAll(e,t="sync",n){if(this.opInProgress)return e.map(i=>this.busyResult(i));this.opInProgress=!0,this.rateLimitBudget.reset();try{let i=[];for(let s of e)i.push(await this.syncLocked(s,t,n));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",n){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0,this.rateLimitBudget.reset();try{return await this.syncLocked(e,t,n)}finally{this.opInProgress=!1}}emitProgress(e,t,n,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:n}:{repoKey:t,phase:n,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%Zne===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%eie===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",n){let i=new d4.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=n!==void 0?{emit:n,repoKey:e.repoKey,reads:0,writes:0}:null;let c=[],l=[],u=0,f=0,d=[],p=a((h,m={})=>({repoKey:e.repoKey,status:h,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:c,deferredDeletes:l,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),...m}),"result");try{let h=await this.deps.materializationCheck.check(e);if(!h.fullyMaterialized)return c.push(`skipped: repo not fully materialized${h.reason?` (${h.reason})`:""} \u2014 deletes NOT inferred (D19)`),p("skipped-not-materialized");let m=this.modeOps(e),g=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(m.fileMode&&(g.readBinary===void 0||g.writeBinary===void 0))return p("error",{detail:"file-mode repo requires a LocalFilesPort with readBinary/writeBinary \u2014 refusing to sync through the text-only port (binary would corrupt)"});if(m.fileMode&&this.deps.quarantine===void 0)return p("error",{detail:"file-mode repo requires a quarantine sink (D18 remote-wins preserves losing local bytes there) \u2014 configure the quarantine repo before syncing FileSpaces"});let _=this.deps.maxFileBytes??wo.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let V=await this.flushOutbox(e,c);u=V.pushed,f=V.reconflicted}let b=await this.deps.watermarkStore.get(e.repoKey);if(b?.spaceKind==="file"&&!m.fileMode)return p("error",{detail:"watermark was written by a FILE-mode sync but the spec now resolves to asset mode \u2014 refusing (fix the conflicting Space declarations, or clear the watermark to restart)"});b!==null&&m.fileMode&&b.spaceKind!=="file"&&(c.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),b=null);let T=this.deps.localManifestStore!==void 0?g.stat?.bind(g):void 0,I=T!==void 0&&b!==null&&!m.fileMode,w=I&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,S=this.deps.localManifestFullRehashMs??Sn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,R=I&&(w===null||this.now()-w.lastFullRehashMs>=S),L=new Map,P=new Set,M=new Map,O=new Map,F=new Map,Z=!1,J=new Map;if(I&&b!==null)for(let V of b.files)J.set(V.path,V.blobSha);for(let V of(await g.list()).filter(m.syncable)){if(m.fileMode){let se=await g4(g,V);if(se.byteLength>_){P.add(V),c.push(`skipped oversized file ${V} (${se.byteLength} bytes > ${_} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}L.set(V,se);continue}if(!I||T===void 0){L.set(V,await g.read(V));continue}let D=await T(V),z=!R&&D!==null?w?.files[V]:void 0;if(D!==null&&z!==void 0&&z.mtimeMs===D.mtimeMs&&z.size===D.size&&z.blobSha===J.get(V)){M.set(V,{blobSha:z.blobSha,...z.uid!==void 0?{uid:z.uid}:{}}),O.set(V,z.blobSha),F.set(V,D);continue}Z=!0,L.set(V,await g.read(V)),D!==null&&F.set(V,D)}let U=!1;if(b===null)if(m.fileMode)U=!0,b=await this.buildFileModeFirstSyncBase(e,L,m,c);else{let V=await this.bootstrapWatermark(e,L,c,p);if(V.kind==="settled")return V.outcome;U=!0,b=V.base}let K=b;m.fileMode&&P.size>0&&(b={...b,files:b.files.filter(V=>!P.has(V.path))});let _e,le;I&&!R?(_e=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),le=_e===b.lastSyncedSha?b.rootTreeSha:await this.resolveBaseTreeSha(e,b,{headReachable:!0})):le=await this.resolveBaseTreeSha(e,b),this.emitProgress(n,e.repoKey,"detecting");let W=await(0,So.detectChanges)({localFiles:L,...I?{cachedEntries:M}:{},watermark:b,actualBaseTreeSha:le,sha1:this.sha1});if(W.kind==="full-conflict")return p("full-conflict",{detail:`${W.reason}${W.detail?`: ${W.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(c.push(...W.warnings),I&&this.deps.localManifestStore!==void 0){let V={};for(let[D,z]of L){let se=F.get(D),be=W.diskBlobShas.get(D);if(se===void 0||be===void 0)continue;let Re=typeof z=="string"?(0,So.extractAssetUid)(z):void 0;V[D]={mtimeMs:se.mtimeMs,size:se.size,blobSha:be,...Re!==void 0?{uid:Re}:{}}}for(let[D,z]of M){let se=F.get(D);se!==void 0&&(V[D]={mtimeMs:se.mtimeMs,size:se.size,blobSha:z.blobSha,...z.uid!==void 0?{uid:z.uid}:{}})}if(w!==null&&Object.keys(w.files).some(D=>!(D in V))&&(Z=!0),Z||R||w===null){let D={version:1,files:V,lastFullRehashMs:R||w===null?this.now():w.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,D)}}let H=this.pinLocalChanges(W,L,c,l,t);d=[...H.pushDeletionsAll.keys()];let oe=await this.runPushLoop(e,b,H,L,c,m,U,P,t,n,_e);if(d=[],oe.kind!=="done"&&H.pushDeletionsAll.size>0&&l.push(...H.pushDeletionsAll.keys()),oe.kind==="conflict")return p("conflict",{detail:oe.detail});if(oe.kind==="retry-exhausted"){c.push(...oe.merge.warnings);let V=await this.buildTerminalQuarantineEntries(e,b,oe.pushFiles,oe.merge.quarantineEntries,L),D=[...oe.merge.quarantineEntries,...oe.merge.resolvedQuarantineEntries,...V];return await this.flushQuarantine(D,c),p("retry-exhausted",{detail:oe.detail,quarantinedCount:D.length,...D.length>0?{quarantinedPaths:D.map(z=>z.path)}:{}})}let{examinedHead:xe,pushedSha:re,applyWrites:Q,applyDeletes:ie,pushFiles:Y}=oe,ae=oe.merge;c.push(...ae.warnings),c.push(...oe.deferredWarnings),l.push(...oe.withheldDeletions);let Me=oe.deferredPaths.size>0?{deferredPaths:[...oe.deferredPaths]}:{},N=oe.pushedDeletions.length>0?{pushedDeletes:oe.pushedDeletions}:{},ue=await this.flushQuarantine([...ae.quarantineEntries,...ae.resolvedQuarantineEntries],c);oe.secretQuarantineEntries.length>0&&await this.flushQuarantine(oe.secretQuarantineEntries,c);let de=new Set;if(!ue&&ae.resolvedQuarantineEntries.length>0){for(let V of ae.resolvedQuarantineEntries)de.add(V.path);c.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${de.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(re===void 0&&xe===b.lastSyncedSha&&Q.length===0&&ie.length===0&&ae.mergedWrites.length===0&&ae.quarantineEntries.length===0&&ae.resolvedQuarantineEntries.length===0&&(b.pinnedPaths?.length??0)===0&&oe.alreadyInHead.length===0&&oe.deferredPaths.size===0&&!U)return p("synced");let Ie=re??xe,we=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,Ie,this.deps.baseURL);if(re!==void 0&&we.parents[0]!==xe)return await this.checkRaceWindow(e,b,xe,we.parents[0],Y,new Set(oe.pushedDeletions),c,m),c.push(`race-window: watermark NOT advanced (pushed commit's parent ${we.parents[0]} != examined head ${xe}) \u2014 next sync reconciles the concurrent change`),p("synced",{pushedSha:re,pushedCount:Y.size,mergedCount:ae.mergedCount,quarantinedCount:ae.quarantineEntries.length+ae.resolvedQuarantineEntries.length,...ae.mergedPaths.length>0?{mergedPaths:ae.mergedPaths}:{},...Ob(ae).length>0?{quarantinedPaths:Ob(ae)}:{},...Me,...N});let{pulledCount:ve,pinnedPaths:Ae,pulledPaths:pe}=await this.applyRemoteChanges(g,L,[...Q,...ae.mergedWrites].filter(V=>!de.has(V.path)),ie.filter(V=>!de.has(V.path)),c,O);for(let V of ae.quarantineEntries)Ae.add(V.path);for(let V of oe.deferredPaths)Ae.add(V);for(let V of de)Ae.add(V);if(m.fileMode){for(let V of P)Ae.add(V);for(let V of oe.remoteOversized)Ae.add(V)}return await this.advanceWatermark(e,Ie,we.treeSha,L,[...Q,...ae.mergedWrites,...oe.deferredRemoteChanges],K,Ae,W.diskBlobShas,m,P),await this.resolveClearedPins(e,K,Ae,c,new Set(ae.resolvedQuarantineEntries.map(V=>V.path))),p("synced",{pushedSha:re,pulledCount:ve,pushedCount:Y.size,mergedCount:ae.mergedCount,quarantinedCount:ae.quarantineEntries.length+ae.resolvedQuarantineEntries.length,...ae.mergedPaths.length>0?{mergedPaths:ae.mergedPaths}:{},...pe.length>0?{pulledPaths:pe}:{},...Ob(ae).length>0?{quarantinedPaths:Ob(ae)}:{},...Me,...N})}catch(h){let m=this.deps.redact??(g=>g);if(d.length>0&&l.push(...d),(0,tR.isAuthError)(h))return p("auth-required",{detail:m(`authentication failed: ${va(h)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)});if((0,tR.isRefNotFoundError)(h)){let g=m(`${e.owner}/${e.repo}@${e.branch} is not reachable: ${va(h)} \u2014 ${tR.REF_NOT_FOUND_HINT}`);return c.push(`sync failed: ${g}`),p("error",{detail:g})}return c.push(`sync failed: ${m(va(h))}`),p("error",{detail:m(va(h))})}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let n=this.deps.redact??(s=>s);for(let s of e)t.push(n(`quarantined ${s.path}: ${s.reason}`));let i=this.deps.quarantine;if(i===void 0)return!1;try{if(i.quarantineAll!==void 0)await i.quarantineAll(e);else for(let s of e)await i.quarantine(s);return!0}catch(s){let o=this.deps.redact??(c=>c);return t.push(`quarantine sink failed: ${o(va(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let n=this.deps.outbox;if(n===void 0)return{pushed:0,reconflicted:0};let i=await n.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(m=>m),o,c;try{({head:o,shaByPath:c}=await this.outboxHeadTreeShas(e))}catch(m){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(va(m))}`),{pushed:0,reconflicted:0}}let l=0,u=[];for(let m of i){let g=c.get(m.path)??eR.OUTBOX_REMOTE_ABSENT,_=g===eR.OUTBOX_REMOTE_ABSENT&&m.baseRemoteSha!==eR.OUTBOX_REMOTE_ABSENT?[...c].filter(([b,T])=>b!==m.path&&T===m.baseRemoteSha).map(([b])=>b):[];if(g!==m.baseRemoteSha&&_.length===0){await n.remove(m.repoKey,m.path),l++,t.push(s(`outbox: remote moved for ${m.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:m,stalePaths:_})}if(u.length===0)return{pushed:0,reconflicted:l};let f=new Map;for(let{entry:m}of u)f.set(m.path,m.chosenContent);let d=new Set;for(let{stalePaths:m}of u)for(let g of m)f.has(g)||d.add(g);let p=[...d];try{await(0,f4.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:f,...p.length>0?{deletions:p}:{},message:p.length>0?`chore(exosync): resolve ${u.length} keep-local conflict(s) (consolidate ${p.length} stale remote path(s))`:`chore(exosync): push ${u.length} resolved conflict(s)`,expectedHeadSha:o,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}catch(m){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(va(m))}`),{pushed:0,reconflicted:l}}let h=0;for(let{entry:m,stalePaths:g}of u){let _=g.filter(b=>!f.has(b));await this.snapOutboxWatermark(e,m.path,m.chosenContent,_),await this.deps.quarantine?.markResolved?.(m.repoKey,m.path);for(let b of _)await this.deps.quarantine?.markResolved?.(m.repoKey,b);await n.remove(m.repoKey,m.path),h++,_.length>0&&t.push(`consolidated cross-path conflict for ${m.path} \u2014 removed ${_.length} stale remote copy/copies (recoverable in git history)`)}return h>0&&t.push(`pushed ${h} resolved conflict(s)`),{pushed:h,reconflicted:l}}async outboxHeadTreeShas(e){let t=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,dt.getTree)(this.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return{head:t,shaByPath:s}}async snapOutboxWatermark(e,t,n,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),c=(s.pinnedPaths??[]).filter(g=>!o.has(g)),l=await(0,ql.gitBlobSha)(n,this.sha1),u=(0,So.extractAssetUid)(n),f={path:t,blobSha:l,...u!==void 0?{uid:u}:{}},d=new Set(i),p=s.files.filter(g=>!d.has(g.path)),h=p.findIndex(g=>g.path===t),m=h>=0?p.map((g,_)=>_===h?f:g):[...p,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:m,...c.length>0?{pinnedPaths:c}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,n,i,s){let o=new Set(i.map(u=>u.path)),c=new Map;try{let u=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>n.has(d.path));for(let d of f)c.set(d.path,await(0,dt.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let l=[];for(let[u,f]of n){if(o.has(u))continue;let d=s.get(u),p=d??f,h=d!==void 0&&!(0,wo.contentEquals)(d,f),m=typeof p=="string"?(0,So.extractAssetUid)(p):void 0,g=c.get(u);l.push({repoKey:e.repoKey,path:u,...m!==void 0?{uid:m}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??Sn.DEFAULT_MAX_PUSH_RETRIES} retries (D16) \u2014 a concurrent writer keeps moving ${e.branch}; base recoverable from git history at ${t.lastSyncedSha}${h?"; the contended push payload was a merged proposal (never applied to disk) \u2014 the merge re-derives next sync":""}`,...typeof p=="string"?{localContent:p}:{localContentBytes:p},...g!==void 0?{remoteContent:g}:{}})}return l}async resolveClearedPins(e,t,n,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let c=(t.pinnedPaths??[]).filter(l=>!n.has(l)&&!s.has(l));for(let l of c)try{await o.markResolved?.(e.repoKey,l)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${l}: ${f(va(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t,n={}){try{return(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch(i){if(!sie(i))throw i;return n.headReachable===!0||await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),null}}pinLocalChanges(e,t,n,i,s){let o=e.modified.filter(p=>p.basePath!==void 0),c=[...e.added,...e.modified.filter(p=>p.basePath===void 0)],l=new Map;if(s==="pull"){for(let p of o)p.basePath!==void 0&&i.push(p.basePath),n.push(`pull-only: rename (uid ${p.uid??"?"}) ${p.basePath} \u2192 ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`);for(let p of e.deleted)i.push(p.path),n.push(`pull-only: delete of ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`)}else{for(let p of o)p.basePath!==void 0&&l.set(p.basePath,p.path);for(let p of e.deleted)l.set(p.path,p.path)}let u=[...c,...o,...e.deleted.map(p=>({...p}))],f=new Set(e.deleted.map(p=>p.path)),d=new Map;for(let p of[...c,...s==="pull"?[]:o]){let h=t.get(p.path);h!==void 0&&d.set(p.path,h)}return{localChanges:u,localDeletedPaths:f,pushFilesAll:d,pushDeletionsAll:l,dupUids:e.duplicateUids}}async runPushLoop(e,t,n,i,s,o,c=!1,l=new Set,u="sync",f,d){let{localChanges:p,localDeletedPaths:h,pushFilesAll:m,pushDeletionsAll:g,dupUids:_}=n,b=this.deps.maxPushRetries??Sn.DEFAULT_MAX_PUSH_RETRIES,T=0,I="",w,S=[],R=[],L=new Map,P=new Set,M=[],O=rR,F=[],Z=new Set,J=[],U=[],K=new Set,_e=[],le=new Set;for(;;){I=T===0&&d!==void 0&&m.size===0&&g.size===0?d:await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),S=[],R=[],O=rR,F=[],Z=new Set,J=[],U=[];let W,H=new Set,oe=(t.pinnedPaths?.length??0)>0;if(I!==t.lastSyncedSha||oe||c){this.emitProgress(f,e.repoKey,"pulling-remote");let Q=await this.collectRemoteChanges(e,t,I,o,l,s,K,f);W=Q.headTreeByPath;let ie=this.matchLocalVsRemote(p,h,i,Q.changes,H,_,Q.headTreeByPath);if(ie.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let Y of ie.conflicts){Z.add(Y.local.path),Y.local.basePath!==void 0&&Z.add(Y.local.basePath);for(let ae of Y.remotes)Z.add(ae.path),ae.kind==="change"&&J.push(ae)}U.push(`${u}-only: ${ie.conflicts.length} conflict(s) deferred to a full Sync (${ie.conflicts.map(Y=>Y.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)O=this.resolveFileModeConflicts(e,ie.conflicts,i,ie.applyWrites,ie.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${ie.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};O=await this.resolveMergeConflicts(e,t,ie.conflicts,i)}if(u==="sync")for(let Y of ie.conflicts)for(let ae of Y.remotes)ae.path!==Y.local.path&&(Z.add(ae.path),ae.kind==="change"&&J.push(ae),U.push(`conflict group ${Y.desc}: remote change at ${ae.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(S=ie.applyWrites,R=ie.applyDeletes,u==="push"&&(S.length>0||R.length>0)){for(let Y of S)Z.add(Y.path),J.push(Y);for(let Y of R)Z.add(Y.path);U.push(`push-only: ${S.length+R.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),S=[],R=[]}}L=u==="pull"?new Map:new Map([...[...m].filter(([Q])=>!H.has(Q)),...O.mergedFiles]),P=new Set,M=[];for(let[Q,ie]of g){if(H.has(ie)){M.push(Q);continue}L.has(Q)||P.add(Q)}if((L.size>0||P.size>0)&&W===void 0&&(W=nR(await(0,dt.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),L.size>0&&W!==void 0){for(let[Q,ie]of L){let Y=W.get(Q);Y!==void 0&&Y===await(0,ql.gitBlobSha)(ie,this.sha1)&&(L.delete(Q),F.push(Q))}F.length>0&&s.push(`phantom push skipped: ${F.length} file(s) already identical in remote HEAD (${F.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(P.size>0&&W!==void 0){for(let Q of[...P])W.has(Q)||P.delete(Q);L.size===0&&P.size>=W.size&&(M.push(...P),U.push(`deletion of ALL ${P.size} remaining file(s) deferred \u2014 GitHub cannot create an empty tree; the deletes re-derive and propagate once the repo has at least one surviving file`),P.clear())}if(L.size===0&&P.size===0)break;let xe=new Map;for(let[Q,ie]of L)if(typeof ie=="string")xe.set(Q,ie);else{let Y=tie(ie);Y!==null&&xe.set(Q,Y)}let re=(0,p4.scanForSecrets)(xe);if(re.length>0){let Q=new Map;for(let ie of re){let Y=Q.get(ie.path);Y===void 0?Q.set(ie.path,[ie.kind]):Y.includes(ie.kind)||Y.push(ie.kind)}for(let[ie,Y]of Q){if(!le.has(ie)){le.add(ie);let ae=xe.get(ie),Me=ae!==void 0?(0,p4.redactSecrets)(ae):void 0,N=Me!==void 0?(0,So.extractAssetUid)(Me):void 0;_e.push({repoKey:e.repoKey,path:ie,...N!==void 0?{uid:N}:{},reason:`secret-scan (R5): detected ${Y.join(", ")} \u2014 skipped from the push (the secret is NEVER shipped); a redacted copy is quarantined. REVOKE the credential, then re-sync once it is removed.`,...Me!==void 0?{localContent:Me}:{}})}L.delete(ie)}s.push(`secret-scan (R5): skipped ${Q.size} file(s) with a detected secret from the push \u2014 the rest of the changeset shipped; REVOKE the credential(s): ${[...Q].map(([ie,Y])=>`${ie} (${Y.join(", ")})`).join(", ")}`);for(let[ie,Y]of g)le.has(Y)&&P.has(ie)&&(P.delete(ie),M.push(ie));if(L.size===0&&P.size===0)break}try{w=await(0,f4.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...L].map(([Q,ie])=>[Q,rie(ie)])),deletions:[...P],message:this.deps.commitMessage?.(e,L.size,P.size)??`chore(exosync): sync ${L.size} file(s)${P.size>0?`, ${P.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(Q){if(!b4(Q))throw Q;if(T++,T>b)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${b} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:L,merge:O};s.push(`non-fast-forward push (attempt ${T}/${b}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:I,pushedSha:w,applyWrites:S,applyDeletes:R,pushFiles:L,pushedDeletions:w!==void 0?[...P]:[],withheldDeletions:M,merge:O,remoteOversized:K,alreadyInHead:F,deferredPaths:Z,deferredRemoteChanges:J,deferredWarnings:U,secretQuarantineEntries:_e}}async resolveMergeConflicts(e,t,n,i){let s=this.deps.mergeLayer;if(s===void 0)return rR;let o=new Map(t.files.map(g=>[g.path,g])),c=new Map,l=[],u=[],f=[],d=[],p=0,h=a(g=>typeof g=="string"?g:void 0,"asText"),m=a((g,_,b)=>{let T=h(i.get(g.local.path)),I=h(g.remotes[0]?.content);return{repoKey:e.repoKey,path:g.local.path,...g.local.uid!==void 0?{uid:g.local.uid}:{},reason:_,...b!==void 0?{baseContent:b}:{},...T!==void 0?{localContent:T}:{},...I!==void 0?{remoteContent:I}:{}}},"entry");for(let g of n){let _=o.get(g.local.basePath??g.local.path)??o.get(g.remotes[0]?.path??""),b;if(_!==void 0&&(b=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,_.blobSha,this.deps.baseURL)),g.remotes.length>1){u.push(m(g,`ambiguous conflict: local change overlaps ${g.remotes.length} remote changes (${g.remotes.map(R=>R.path).join(", ")})`,b));continue}let T=g.remotes[0],I=h(i.get(g.local.path)),w=await s.resolve({path:g.local.path,...g.local.uid!==void 0?{uid:g.local.uid}:{},...b!==void 0?{base:b}:{},...I!==void 0?{local:I}:{},...T.kind==="change"&&typeof T.content=="string"?{remote:T.content}:{}});if(w.action==="quarantine"){u.push(m(g,w.reason,b));continue}p++,d.push(g.local.path);for(let R of w.warnings??[])f.push(`merge(${g.local.path}): ${R}`);let S=T.kind==="change"?T.content:void 0;if(w.content!==S&&c.set(g.local.path,w.content),w.content!==i.get(g.local.path)){let R=(0,So.extractAssetUid)(w.content)??g.local.uid;l.push({path:g.local.path,kind:"change",content:w.content,blobSha:await(0,ql.gitBlobSha)(w.content,this.sha1),...R!==void 0?{uid:R}:{}})}}return{mergedFiles:c,mergedWrites:l,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:p,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,n,i,s){let o=[],c=[];for(let l of t){l.remotes.length>1&&c.push(`file-mode conflict on ${l.local.path} unexpectedly overlaps ${l.remotes.length} remote changes \u2014 resolving against the first`);let u=l.remotes[0],f=n.get(l.local.path);u.kind==="change"?i.push(u):s.push(u),!(l.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:l.local.path,reason:`file-mode remote-wins (D18): remote ${u.kind==="change"?`version ${u.blobSha}`:"delete"} wins; this is the losing LOCAL version, preserved byte-exact`,...typeof f=="string"?{localContent:f}:{localContentBytes:f}})}return{mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:o,mergedCount:0,mergedPaths:[],warnings:c}}async applyRemoteChanges(e,t,n,i,s,o=new Map){let c=0,l=new Set,u=[],f=a(async(h,m)=>{try{return m?await g4(e,h):await e.read(h)}catch{return}},"tryRead"),d=a(async(h,m)=>{typeof m=="string"?await e.write(h,m):await nie(e,h,m)},"writeContent"),p=a(async h=>{let m=await f(h,!1);return m===void 0?!0:await(0,ql.gitBlobSha)(m,this.sha1)===o.get(h)},"cacheHitUnchanged");for(let h of n){if(h.content===void 0)continue;if(!y4(h.path)){s.push(`unsafe remote path skipped on pull-apply: ${h.path}`),l.add(h.path);continue}let m=t.get(h.path);if(m===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path);continue}let g=await f(h.path,typeof(m??h.content)!="string");if(!(0,wo.contentEquals)(g,m)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path)}for(let h of i){if(!y4(h.path)){s.push(`unsafe remote path skipped on pull-delete: ${h.path}`),l.add(h.path);continue}let m=t.get(h.path);if(m===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path);continue}if(m!==void 0){let g=await f(h.path,typeof m!="string");if(g!==void 0&&!(0,wo.contentEquals)(g,m)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path)}}return{pulledCount:c,pinnedPaths:l,pulledPaths:u}}async advanceWatermark(e,t,n,i,s,o,c,l,u,f=new Set){let d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).filter(h=>u.treeFilter(h)&&!f.has(h.path)),p=oie(await this.buildWatermarkFiles(e,d,i,s,o,l,u),o,c);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:n,files:p,...c.size>0?{pinnedPaths:[...c]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,n,i,s){let o=this.deps.mountBaseStore,c=null;if(o!==void 0)try{c=await o.get(e.repoKey)}catch{return null}let l=!1;if(c===null&&this.deps.localBaseShaProvider!==void 0)try{let _=await this.deps.localBaseShaProvider(e);typeof _=="string"&&_.length>0&&(c=_,l=!0)}catch{}if(c===null||t.startsWith(c))return null;let u=300,f=null;try{let _=t;for(let b=0;b<u;b++){let T=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,_,this.deps.baseURL);if(T.sha===c||T.sha.startsWith(c)){f=T;break}if(T.parents.length===0)break;_=T.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(_=>(0,wo.isSyncablePath)(_.path))}catch{return null}let p;try{let _=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);p=nR((await(0,dt.getTree)(this.transport,e.owner,e.repo,_.treeSha,this.deps.baseURL)).filter(b=>(0,wo.isSyncablePath)(b.path)))}catch{return null}let h=d.filter(_=>!n.has(_.path)&&p.get(_.path)===_.blobSha);if(h.length>0){let _=h.slice(0,3).map(b=>b.path).join(", ")+(h.length>3?", \u2026":"");return i.push(`first-sync (asset mode): base-tree\u2286working-tree sanity guard fired \u2014 ${h.length} base file(s) absent from the working tree but UNCHANGED on remote head (${_}); the verified-ancestor base may not match the working tree's derivation commit (out-of-band submodule manipulation) \u2192 routing to merge/quarantine instead of inferring a silent deletion (#3610)`),{kind:"settled",outcome:s("full-conflict",{detail:`first-sync: base-tree\u2286working-tree sanity guard \u2014 ${h.length} base file(s) absent from the working tree are unchanged on remote head (${_}); refusing to infer a silent deletion from a base that may not match the derivation commit \u2014 divergence must go through merge/quarantine (A2/A3), never a silent delete (#3610)`})}}let m=d.map(_=>({path:_.path,blobSha:_.blobSha})),g={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:m};if(l&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(l?`first-sync (asset mode): BACKFILLED the 3-way base from the locally checked-out commit ${f.sha} (no recorded mount base) \u2014 remote head ${t} advanced since; local edits 3-way merge against it instead of false-conflicting (#3590)`:`first-sync (asset mode): reconciling against the recorded mount base ${f.sha} \u2014 remote head ${t} advanced since mount; local edits 3-way merge against it instead of false-conflicting (#3590)`),{kind:"additive-base",base:g}}async bootstrapWatermark(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,n,i);if(o!==null)return o;let c=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,dt.getTree)(this.transport,e.owner,e.repo,c.treeSha,this.deps.baseURL)).filter(p=>(0,wo.isSyncablePath)(p.path)),u=[],f;for(let p of l){let h=t.get(p.path);if(h===void 0||await(0,ql.gitBlobSha)(h,this.sha1)!==p.blobSha){f===void 0&&(f=p.path);continue}let m=typeof h=="string"?(0,So.extractAssetUid)(h):void 0;u.push({path:p.path,blobSha:p.blobSha,...m?{uid:m}:{}})}let d={lastSyncedSha:s,rootTreeSha:c.treeSha,files:u};return f!==void 0?this.deps.mergeLayer===void 0?{kind:"settled",outcome:i("full-conflict",{detail:`first-sync: no watermark and local content diverges from remote head at ${f} \u2014 A2/A3 scope`})}:(n.push(`first-sync (asset mode): no 3-way merge base and local diverges from remote head (first at ${f}) \u2014 reconciling ZERO-LOSS against ${u.length} byte-identical file(s) as a synthetic base: remote-only files pull, local-only files push, overlapping divergences route to the merge/quarantine layer (both versions preserved), never a silent overwrite or delete`),{kind:"additive-base",base:d}):t.size===l.length?(await this.deps.watermarkStore.set(e.repoKey,d),n.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(n.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${l.length} files) \u2014 ${t.size-l.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,n,i,s=new Set,o=[],c=new Set,l){let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL),f=await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let P of f)i.syncable(P.path)&&!i.treeFilter(P)&&!c.has(P.path)&&(c.add(P.path),o.push(`skipped oversized REMOTE file ${P.path} (${P.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(P=>i.treeFilter(P)&&!s.has(P.path)),p=t.files.filter(P=>!c.has(P.path)&&!s.has(P.path)),{changed:h,deleted:m}=_4(p,d),g=h.length;g>=m4&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:0,total:g});let _=new Array(h.length),b=0,T=0,I,w=a(async P=>{if(i.fileMode){let O=await(0,dt.getBlobBytes)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:O}}let M=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:M,uid:(0,So.extractAssetUid)(M)}},"fetchOne"),S=a(async()=>{for(;;){if(I!==void 0)return;let P=b++;if(P>=h.length)return;try{_[P]=await w(h[P])}catch(M){I===void 0&&(I=M);return}T+=1,g>=m4&&T%Xne===0&&T<g&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:T,total:g})}},"worker"),R=Math.min(Jne,h.length);if(await Promise.all(Array.from({length:R},()=>S())),I!==void 0)throw I instanceof Error?I:new Error(String(I));let L=_;for(let P of m)L.push({path:P.path,kind:"delete",uid:P.uid});return{changes:L,headTreeByPath:nR(f)}}matchLocalVsRemote(e,t,n,i,s,o=new Set,c){let l=new Set,u=[],f=new Map;for(let g of i)g.kind==="change"&&g.uid!==void 0&&f.set(g.uid,(f.get(g.uid)??0)+1);let d=new Set(o);for(let[g,_]of f)_>1&&d.add(g);let p=new Map,h=new Map;for(let g of i){if(g.uid!==void 0&&!d.has(g.uid)){let _=p.get(g.uid)??[];_.push(g),p.set(g.uid,_)}h.set(g.path,g)}for(let g of e){let _=new Set;if(g.uid!==void 0&&!d.has(g.uid))for(let w of p.get(g.uid)??[])w.kind==="change"&&w.path!==g.path&&(c?.has(g.path)===!0||g.basePath!==void 0&&c?.has(g.basePath)===!0)||_.add(w);let b=h.get(g.path);if(b!==void 0&&_.add(b),g.basePath!==void 0){let w=h.get(g.basePath);w!==void 0&&_.add(w)}let T=[],I=!1;for(let w of _){if(I=t.has(g.path)&&!n.has(g.path),I&&w.kind==="delete"){l.add(w);continue}if(!I&&w.kind==="change"&&w.path===g.path&&w.blobSha===g.blobSha){l.add(w),s.add(g.path);continue}if(w.kind==="delete"&&g.basePath!==void 0&&w.path===g.basePath){let S=h.get(g.path);if(S!==void 0&&S.kind==="change"&&(S.blobSha===g.blobSha||S.uid!==void 0&&S.uid===g.uid)){l.add(w);continue}}if(w.kind==="delete"&&w.path!==g.path&&w.path!==g.basePath&&!n.has(w.path)&&c?.has(w.path)!==!0){l.add(w);continue}T.push(w),l.add(w)}T.length>0&&(u.push({local:g,localIsDelete:I,remotes:T,desc:`${g.uid!==void 0&&!d.has(g.uid)?g.uid:g.path} (local ${I?"delete":"change"} vs remote ${T[0].kind} at ${T[0].path})`}),s.add(g.path))}let m=i.filter(g=>!l.has(g));return{conflicts:u,applyWrites:m.filter(g=>g.kind==="change"),applyDeletes:m.filter(g=>g.kind==="delete")}}async checkRaceWindow(e,t,n,i,s,o,c,l){try{let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(l.treeFilter),d=n===t.lastSyncedSha?t.files:(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(l.treeFilter),{changed:p,deleted:h}=_4(d,f);for(let m of p)s.has(m.path)&&c.push(`race-window: concurrent commit ${i} changed ${m.path} between conflict check (head ${n}) and push \u2014 local version won; previous version recoverable from git history`),o.has(m.path)&&c.push(`race-window: concurrent commit ${i} changed ${m.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let m of h)s.has(m.path)&&c.push(`race-window: concurrent commit ${i} deleted ${m.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);c.push(`race-window check failed: ${f(va(u))}`)}}async buildWatermarkFiles(e,t,n,i,s,o,c){if(c.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let l=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&l.set(f.blobSha,f.uid);for(let[f,d]of n){let p=o?.get(f)??await(0,ql.gitBlobSha)(d,this.sha1);l.set(p,typeof d=="string"?(0,So.extractAssetUid)(d):void 0)}for(let f of s.files)l.has(f.blobSha)||l.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(l.has(f.blobSha))d=l.get(f.blobSha);else{let p=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,So.extractAssetUid)(p)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};Sn.SyncEngine=iR});var E4=v(Mh=>{"use strict";Object.defineProperty(Mh,"__esModule",{value:!0});Mh.QuarantineResolver=void 0;Mh.backupPathFor=w4;var aie=Sb(),Pb=Xf(),Nh=Qf(),kh=Ph(),cie=Tb(),Eo="\0absent",sR=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let n of e)t.push(...await this.listRepoConflicts(n));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),n=t?.pinnedPaths??[];if(n.length===0)return[];if(this.deps.outbox!==void 0){let h=await this.deps.outbox.listForRepo(e.repoKey);if(h.length>0){let m=new Set(h.map(g=>g.path));if(n=n.filter(g=>!m.has(g)),n.length===0)return[]}}let i=new Map;for(let h of t?.files??[])i.set(h.path,h.blobSha);let s=this.deps.conflictCache!==void 0,o=await this.cachedRecordsFor(e,n),c=n.some(h=>!o.has(h)),l=new Map,u=!0;if(c)if(s)try{l=await this.remoteTreeShas(e)}catch{u=!1}else l=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),p=[];for(let h of n){let m=o.get(h),g,_;if(m!==void 0)_=m.remoteContent!==void 0?await(0,Nh.gitBlobSha)(m.remoteContent,this.deps.sha1):Eo,g=m.baseContent!==void 0?await(0,Nh.gitBlobSha)(m.baseContent,this.deps.sha1):i.get(h)??Eo;else{if(!u)continue;_=l.get(h)??Eo,g=i.get(h)??Eo}let b=Eo,T;if(d.has(h)&&(T=await f.read(h),b=await(0,Nh.gitBlobSha)(T,this.deps.sha1)),!(b!==_&&b!==g&&_!==g))continue;let w=(T!==void 0?(0,kh.extractAssetUid)(T):void 0)??m?.uid;p.push({repoKey:e.repoKey,path:h,...w!==void 0?{uid:w}:{},hasLocal:b!==Eo,hasRemote:_!==Eo})}return p}async cachedRecordsFor(e,t){let n=new Map,i=this.deps.conflictCache;if(i===void 0)return n;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&n.set(s,o)}return n}async detectDuplicateUids(e){let t=new Map;for(let i of e){let s=this.deps.localFilesFor(i);for(let o of await s.list()){if(!o.endsWith(".md"))continue;let c;try{c=await s.read(o)}catch{continue}let l=(0,kh.extractAssetUid)(c);l!==void 0&&t.set(l,(t.get(l)??0)+1)}}let n=0;for(let i of t.values())i>1&&n++;return n}async loadConflict(e,t){let n=this.deps.localFilesFor(e),s=new Set(await n.list()).has(t)?await n.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,c,l;if(o!==null)c=o.remoteContent,l=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);c=d!==void 0?await this.blobText(e,d):void 0;let h=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(m=>m.path===t)?.blobSha;if(h!==void 0)try{l=await this.blobText(e,h)}catch{l=void 0}}let u=(s!==void 0?(0,kh.extractAssetUid)(s):void 0)??(c!==void 0?(0,kh.extractAssetUid)(c):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:c!==void 0,...l!==void 0?{base:l}:{},...s!==void 0?{local:s}:{},...c!==void 0?{remote:c}:{}}}async resolve(e,t,n){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,c=this.deps.outbox!==void 0,{remote:l,remoteSha:u}=c?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(n,o,l),d;n.take!=="local"&&o!==void 0&&o!==f&&(d=w4(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let h=f===void 0&&l===void 0||f===l;if(c&&this.deps.outbox!==void 0&&!h&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:n.take==="merged"?"merged":"local",baseRemoteSha:u===Eo?cie.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:n.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let m;return h||(m=await this.commitChoice(e,t,f)),await this.snapWatermark(e,t,f),this.deps.quarantine?.markResolved!==void 0&&await this.deps.quarantine.markResolved(e.repoKey,t),{repoKey:e.repoKey,path:t,resolvedTo:n.take,...m!==void 0?{pushedSha:m}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let n=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(n!==null){let i=n.remoteContent,s=i!==void 0?await(0,Nh.gitBlobSha)(i,this.deps.sha1):Eo;return{remote:i,remoteSha:s}}return this.liveRemoteForResolve(e,t)}async liveRemoteForResolve(e,t){let i=(await this.remoteTreeShas(e)).get(t);return{remote:i!==void 0?await this.blobText(e,i):void 0,remoteSha:i??Eo}}chosenContent(e,t,n){switch(e.take){case"local":if(t===void 0)throw new Error("resolve: cannot keep local \u2014 no local version exists on disk");return t;case"remote":return n;case"merged":return e.content}}async commitChoice(e,t,n){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(n===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,aie.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,n]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,n){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(c=>c!==t),o=i.files;if(n===void 0)o=o.filter(c=>c.path!==t);else{let c=await(0,Nh.gitBlobSha)(n,this.deps.sha1),l=(0,kh.extractAssetUid)(n),u={path:t,blobSha:c,...l!==void 0?{uid:l}:{}},f=o.findIndex(d=>d.path===t);o=f>=0?o.map((d,p)=>p===f?u:d):[...o,u]}await this.deps.watermarkStore.set(e.repoKey,{...i,files:o,...s.length>0?{pinnedPaths:s}:{pinnedPaths:void 0}})}async remoteTreeShas(e){let t=await(0,Pb.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,Pb.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,Pb.getTree)(this.deps.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return s}async blobText(e,t){return(0,Pb.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};Mh.QuarantineResolver=sR;function w4(r){return`${r}.conflict.local.txt`}a(w4,"backupPathFor")});var v4=v(Zf=>{"use strict";Object.defineProperty(Zf,"__esModule",{value:!0});Zf.FileLocalManifestStore=Zf.LOCAL_MANIFEST_STORE_FILENAME=void 0;Zf.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function lie(r){if(r===null||typeof r!="object")return!1;let e=r;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(lie,"isLocalManifestRecord");var oR=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let n=(await this.readRepos())[e];return lie(n)?n:null}async set(e,t){let n=this.writeChain.then(async()=>{let i=await this.readRepos();i[e]=t;let s={version:1,repos:i};await this.io.writeAtomic(JSON.stringify(s))});return this.writeChain=n.catch(()=>{}),n}async readRepos(){try{let e=await this.io.read();if(e===null)return{};let t=JSON.parse(e);if(t===null||typeof t!="object")return{};let n=t.repos;return n===null||typeof n!="object"?{}:{...n}}catch{return{}}}};Zf.FileLocalManifestStore=oR});var lR=v(cR=>{"use strict";Object.defineProperty(cR,"__esModule",{value:!0});cR.diff3=uie;function T4(r,e){let t=r.length,n=e.length,i=Array.from({length:t+1},()=>new Int32Array(n+1));for(let l=t-1;l>=0;l--)for(let u=n-1;u>=0;u--)i[l][u]=r[l]===e[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);let s=new Map,o=0,c=0;for(;o<t&&c<n;)r[o]===e[c]?(s.set(o,c),o++,c++):i[o+1][c]>=i[o][c+1]?o++:c++;return s}a(T4,"lcsMatch");function aR(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}a(aR,"sliceEq");function uie(r,e,t){let n=T4(r,e),i=T4(r,t),s=[],o=0,c=0,l=0;for(;;){let u=o;for(;u<r.length&&!(n.has(u)&&i.has(u));)u++;let f=u<r.length?n.get(u):e.length,d=u<r.length?i.get(u):t.length,p=r.slice(o,u),h=e.slice(c,f),m=t.slice(l,d),g=!aR(h,p),_=!aR(m,p);if(!g&&!_)s.push(...p);else if(!g)s.push(...m);else if(!_)s.push(...h);else if(aR(h,m))s.push(...h);else return{ok:!1,conflict:{base:p,local:h,remote:m}};if(u>=r.length)break;s.push(r[u]),o=u+1,c=f+1,l=d+1}return{ok:!0,merged:s}}a(uie,"diff3")});var I4=v(Uh=>{"use strict";Object.defineProperty(Uh,"__esModule",{value:!0});Uh.StructuredMerger=void 0;Uh.splitSections=Db;var A4=lR(),fie=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,jh="exo__Instance_class";function $h(r){if(r===null||typeof r!="object")return!0;if(Array.isArray(r))return r.every($h);let e=Object.getPrototypeOf(r);return e!==Object.prototype&&e!==null?!1:Object.values(r).every($h)}a($h,"isPlainValue");function gc(r,e){if(r===e)return!0;if(r===null||e===null||r===void 0||e===void 0||typeof r!="object"||typeof e!="object"||Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)&&Array.isArray(e))return r.length!==e.length?!1:r.every((s,o)=>gc(s,e[o]));let t=r,n=e,i=Object.keys(t);return i.length!==Object.keys(n).length?!1:i.every(s=>gc(t[s],n[s]))}a(gc,"deepEqual");function Wl(r){return typeof r=="string"?`s:${r}`:`j:${JSON.stringify(r)}`}a(Wl,"setKey");function es(r){return r==null?[]:Array.isArray(r)?r:[r]}a(es,"toElements");function die(r,e,t){let n=new Set(es(r).map(Wl)),i=es(e),s=es(t),o=new Set(i.map(Wl)),c=new Set(s.map(Wl)),l=a(d=>o.has(d)&&c.has(d)||o.has(d)&&!n.has(d)||c.has(d)&&!n.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let p=Wl(d);f.has(p)||!l(p)||(f.add(p),u.push(d))}return u}a(die,"mergeSet");function pie(r,e,t){let n=[],i=[],s=new Set;for(let c of[...Object.keys(r),...Object.keys(e),...Object.keys(t)])s.has(c)||(s.add(c),i.push(c));let o={};for(let c of i){let l=r[c],u=e[c],f=t[c];if(!$h(l)||!$h(u)||!$h(f))return{ok:!1,reason:`frontmatter key "${c}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(l)||Array.isArray(u)||Array.isArray(f)){if(!(c in e)&&!(c in t))continue;let d=die(l,u,f),p=new Set(es(l).map(Wl)),h=es(u).some(g=>!p.has(Wl(g))),m=es(f).some(g=>!p.has(Wl(g)));h&&m&&!gc(es(u),es(f))&&n.push(`both sides added values to multi-valued key "${c}" \u2014 union kept (D20)`),d.length>0&&(o[c]=d);continue}if(gc(u,f)){u!==void 0&&(o[c]=u);continue}if(gc(u,l)){f!==void 0&&(o[c]=f);continue}if(gc(f,l)){u!==void 0&&(o[c]=u);continue}return{ok:!1,reason:`frontmatter key "${c}" changed differently on both sides`}}return{ok:!0,value:o,warnings:n}}a(pie,"mergeFrontmatter");var hie=/^(```|~~~)/,mie=/^#{1,6}\s/;function Db(r){let e=r.split(`
|
|
335
|
+
`)}a(fne,"stripGitmodulesEntry")});var Qf=v(BI=>{"use strict";Object.defineProperty(BI,"__esModule",{value:!0});BI.gitBlobSha=dne;async function dne(r,e){let t=new TextEncoder,n=typeof r=="string"?t.encode(r):r,i=t.encode(`blob ${n.byteLength}\0`),s=new Uint8Array(i.byteLength+n.byteLength);return s.set(i,0),s.set(n,i.byteLength),e(s)}a(dne,"gitBlobSha")});var Ph=v(Eb=>{"use strict";Object.defineProperty(Eb,"__esModule",{value:!0});Eb.extractAssetUid=VM;Eb.detectChanges=hne;var pne=Qf();function VM(r){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(r);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(VM,"extractAssetUid");async function hne(r){let{localFiles:e,cachedEntries:t,watermark:n,actualBaseTreeSha:i,sha1:s}=r;if(n===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${n.lastSyncedSha} not resolvable on remote`};if(i!==n.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${n.rootTreeSha} != actual ${i} at ${n.lastSyncedSha}`};let o=[],c=new Map;for(let[w,S]of e){let R=await(0,pne.gitBlobSha)(S,s);c.set(w,R),o.push({path:w,blobSha:R,uid:typeof S=="string"?VM(S):void 0})}if(t!==void 0)for(let[w,S]of t)c.set(w,S.blobSha),o.push({path:w,blobSha:S.blobSha,uid:S.uid});let l=[],u=[],f=[],d=[],p=new Map;for(let w of o){if(w.uid===void 0)continue;let S=p.get(w.uid)??[];S.push(w.path),p.set(w.uid,S)}let h=new Map;for(let w of n.files){if(w.uid===void 0)continue;let S=h.get(w.uid)??[];S.push(w.path),h.set(w.uid,S)}let m=new Set;for(let[w,S]of p)S.length>1&&m.add(w);for(let[w,S]of h)S.length>1&&m.add(w);for(let w of[...m].sort()){let S=p.get(w)??[],R=S.length>1?`on disk (${S.join(", ")})`:`in the sync base (${(h.get(w)??[]).join(", ")})`;d.push(`duplicate uid ${w} ${R} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let g=new Map,_=[];for(let w of n.files)w.uid!==void 0&&!m.has(w.uid)?g.set(w.uid,w):_.push(w);let b=[],T=new Set;for(let w of o){let S=w.uid!==void 0&&!m.has(w.uid)?g.get(w.uid):void 0;w.uid!==void 0&&S!==void 0?(T.add(w.uid),(S.blobSha!==w.blobSha||S.path!==w.path)&&u.push({path:w.path,uid:w.uid,blobSha:w.blobSha,...S.path!==w.path?{basePath:S.path}:{}})):b.push(w)}let I=new Map;for(let w of _)I.set(w.path,w);for(let[w,S]of g)T.has(w)||I.set(S.path,S);for(let w of b){let S=I.get(w.path);S!==void 0?(I.delete(w.path),S.blobSha!==w.blobSha&&u.push({path:w.path,uid:w.uid,blobSha:w.blobSha})):l.push({path:w.path,uid:w.uid,blobSha:w.blobSha})}for(let w of I.values())f.push({path:w.path,uid:w.uid,blobSha:w.blobSha});return{kind:"changes",added:l,modified:u,deleted:f,warnings:d,diskBlobShas:c,duplicateUids:m}}a(hne,"detectChanges")});var WM=v(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});Dh.rewriteAssetUid=GM;Dh.findDuplicateUidGroups=qM;Dh.planDuplicateUidFix=gne;var mne=Ph();function GM(r,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(r);if(t===null)return r;let n=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return n===t[2]?r:r.slice(0,t.index)+t[1]+n+t[3]+r.slice(t.index+t[0].length)}a(GM,"rewriteAssetUid");function qM(r){let e=new Map;for(let t of r){let n=(0,mne.extractAssetUid)(t.content);if(n===void 0)continue;let i=e.get(n)??[];i.push(t.path),e.set(n,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>({uid:t,paths:n}))}a(qM,"findDuplicateUidGroups");function gne(r,e){let t=new Map(r.map(i=>[i.path,i.content])),n=[];for(let i of qM(r)){let s=[...i.paths].sort((o,c)=>o.localeCompare(c));for(let o of s.slice(1)){let c=t.get(o);if(c===void 0)continue;let l=e(),u=GM(c,l);u!==c&&n.push({path:o,fromUid:i.uid,toUid:l,content:u})}}return n}a(gne,"planDuplicateUidFix")});var Xf=v(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.getHeadSha=_ne;Gl.getCommitInfo=bne;Gl.getTree=Sne;Gl.getBlobText=wne;Gl.getBlobBytes=Ene;var HM=Nu(),yne="https://api.github.com";function Fh(r){return(r??yne).replace(/\/$/,"")}a(Fh,"api");function Vl(r){return r!==null&&typeof r=="object"?r:void 0}a(Vl,"asRecord");function bo(r,e){let n=Vl(r)?.[e];return typeof n=="string"?n:void 0}a(bo,"readString");async function _ne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(n)}`}),o=bo(Vl(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${n}`);return o}a(_ne,"getHeadSha");async function bne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(n)}`}),o=Vl(s?.json),c=bo(o,"sha"),l=bo(o?.tree,"sha");if(!c||!l)throw new Error(`ExoSync: malformed commit response for ${n}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>bo(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:c,treeSha:l,parents:f}}a(bne,"getCommitInfo");async function Sne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(n)}?recursive=1`}),o=Vl(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${n} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let c=o?.tree;if(!Array.isArray(c))throw new Error(`ExoSync: malformed tree response for ${n}`);let l=[];for(let u of c){let f=Vl(u);if(f?.type!=="blob")continue;let d=bo(f,"path"),p=bo(f,"sha"),h=typeof f.size=="number"?f.size:void 0;d&&p&&l.push({path:d,blobSha:p,...h!==void 0?{size:h}:{}})}return l}a(Sne,"getTree");async function wne(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=Vl(s?.json),c=bo(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return bo(o,"encoding")==="utf-8"?c:(0,HM.base64ToUtf8)(c)}a(wne,"getBlobText");async function Ene(r,e,t,n,i){let s=await r({method:"GET",url:`${Fh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=Vl(s?.json),c=bo(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return bo(o,"encoding")==="utf-8"?new TextEncoder().encode(c):(0,HM.base64ToBytes)(c)}a(Ene,"getBlobBytes")});var KM=v(VI=>{"use strict";Object.defineProperty(VI,"__esModule",{value:!0});VI.checkParkedStaleness=Tne;var vne=Xf();async function Tne(r,e){let t={repoKey:r.repoKey,localPath:r.localPath},n=e.redact??(o=>o),i=null;try{let c=(await e.watermarks.get(r.repoKey))?.lastSyncedSha??"";c.length>0&&(i=c)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:`watermark unreadable: ${n(zM(o))}`}}if(i===null)return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:"never synced on this device (no watermark)"};let s;try{s=await(0,vne.getHeadSha)(e.transport,r.owner,r.repo,r.branch,e.baseURL)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:i,remoteHeadSha:null,reason:`remote unreachable: ${n(zM(o))}`}}return{...t,freshness:s===i?"current":"behind",lastSyncedSha:i,remoteHeadSha:s}}a(Tne,"checkParkedStaleness");function zM(r){return r instanceof Error?r.message:String(r)}a(zM,"errorText")});var WI=v(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.SyncPhaseTimer=hr.SYNC_PHASES=void 0;hr.classifyRestPhase=Ane;hr.emptyTimings=QM;hr.totalMs=vb;hr.addTimings=XM;hr.aggregateTimings=Ine;hr.dominantPhase=Rne;hr.fmtMs=Lh;hr.formatTimingsLine=Cne;hr.formatRepoTimings=xne;hr.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function qI(){let r={};for(let e of hr.SYNC_PHASES)r[e]=0;return r}a(qI,"zeroDurations");function YM(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(YM,"zeroCounts");function Ane(r){if(r.method!=="GET")return"restPush";let e=r.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(Ane,"classifyRestPhase");var GI=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=qI(),this.counts=YM()}async time(e,t){let n=this.now();try{return await t()}finally{this.durations[e]+=this.now()-n}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};hr.SyncPhaseTimer=GI;function QM(){return{durations:qI(),counts:YM()}}a(QM,"emptyTimings");function vb(r){let e=0;for(let t of hr.SYNC_PHASES)e+=r.durations[t];return e}a(vb,"totalMs");function XM(r,e){let t=qI();for(let n of hr.SYNC_PHASES)t[n]=r.durations[n]+e.durations[n];return{durations:t,counts:{filesRead:r.counts.filesRead+e.counts.filesRead,filesHashed:r.counts.filesHashed+e.counts.filesHashed,filesWritten:r.counts.filesWritten+e.counts.filesWritten,restCalls:r.counts.restCalls+e.counts.restCalls}}}a(XM,"addTimings");function Ine(r){let e=QM();for(let t of r)t.timings!==void 0&&(e=XM(e,t.timings));return e}a(Ine,"aggregateTimings");function Rne(r){let e=vb(r);if(e<=0)return null;let t=hr.SYNC_PHASES[0],n=-1;for(let i of hr.SYNC_PHASES)r.durations[i]>n&&(n=r.durations[i],t=i);return{phase:t,ms:n,pct:n/e*100}}a(Rne,"dominantPhase");function Lh(r){return r>=1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`}a(Lh,"fmtMs");function Cne(r){let e=vb(r);if(e<=0)return"";let t=hr.SYNC_PHASES.filter(n=>r.durations[n]>0).sort((n,i)=>r.durations[i]-r.durations[n]).map(n=>`${n} ${Lh(r.durations[n])} ${Math.round(r.durations[n]/e*100)}%`);return`\u23F1 ExoSync ${Lh(e)} \u2014 ${t.join(" \xB7 ")} (${r.counts.filesHashed} hashed, ${r.counts.filesRead} read, ${r.counts.restCalls} REST)`}a(Cne,"formatTimingsLine");function xne(r,e){let t=hr.SYNC_PHASES.map(n=>`${n}=${Lh(e.durations[n])}`);return`[ExoSync timings] ${r}: total ${Lh(vb(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(xne,"formatRepoTimings")});var Tb=v(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.LocalOutboxStore=hc.OUTBOX_REMOTE_ABSENT=hc.OUTBOX_STORE_FILENAME=void 0;hc.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";hc.OUTBOX_REMOTE_ABSENT=" absent";function HI(r,e){return`${r}\0${e}`}a(HI,"outboxKey");function JM(r){if(r===null||typeof r!="object")return!1;let e=r;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(JM,"isEntry");var zI=class{static{a(this,"LocalOutboxStore")}constructor(e){this.writeChain=Promise.resolve(),this.io=e.io,this.now=e.now??(()=>new Date().toISOString())}async enqueue(e){await this.mutate(t=>{t.entries[HI(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(n=>{delete n.entries[HI(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(JM)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[HI(e,t)];return i!==void 0&&JM(i)}async mutate(e){let t=this.writeChain.then(async()=>{let n=await this.read();e(n),await this.io.writeAtomic(JSON.stringify(n,null,2))});return this.writeChain=t.catch(()=>{}),t}async read(){try{let e=await this.io.read();if(e===null)return{version:1,entries:{}};let t=JSON.parse(e);if(t===null||typeof t!="object")return{version:1,entries:{}};let n=t.entries;return n===null||typeof n!="object"?{version:1,entries:{}}:{version:1,entries:{...n}}}catch{return{version:1,entries:{}}}}};hc.LocalOutboxStore=zI});var Ab=v(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.SpaceSpecAccumulator=Nn.SYNC_BRANCH=Nn.ASSET_SPACE_CLASS_UID=void 0;Nn.isAssetSpaceFrontmatter=t4;Nn.isFileSpaceFrontmatter=r4;Nn.readSpaceSource=n4;Nn.parseStrictGitHubRepoURL=i4;Nn.classifySpaceDeclaration=Fne;var One=H0(),Pne=W0();Nn.ASSET_SPACE_CLASS_UID="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb";Nn.SYNC_BRANCH="main";var ZM=/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]/gi;function e4(r,e){let t=r.exo__Instance_class,n=Array.isArray(t)?t:[t];for(let i of n){if(typeof i!="string")continue;ZM.lastIndex=0;let s;for(;(s=ZM.exec(i))!==null;)if(s[1].toLowerCase()===e)return!0}return!1}a(e4,"instanceClassHasUid");function t4(r){return e4(r,Nn.ASSET_SPACE_CLASS_UID)}a(t4,"isAssetSpaceFrontmatter");function r4(r){return e4(r,One.FILE_SPACE_CLASS_UID)}a(r4,"isFileSpaceFrontmatter");function n4(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(n4,"readSpaceSource");var Dne=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/;function i4(r){if(typeof r!="string"||r.length===0||r.length>256||!Dne.test(r))return null;let e=r.slice(19),[t,n,...i]=e.split("/");if(i.length>0||t===".."||n===".."||n.startsWith("."))return null;let s=n.replace(/\.git$/,"");return s.length===0?null:{owner:t,repo:s}}a(i4,"parseStrictGitHubRepoURL");function Fne(r,e){let t=t4(r),n=r4(r);if(!t&&!n)return{kind:"not-space"};let i;t&&n&&(i=`declaration at ${e} carries BOTH exo__AssetSpace and exo__FileSpace classes (disjoint) \u2014 treating as AssetSpace (conservative)`);let s=t?"asset":"file",o=n4(r);if(o===null)return s==="file"?{kind:"skip",warning:`skipped FileSpace at ${e}: no exo__AssetSpace_source/_git \u2014 mount path underivable`}:{kind:"skip"};let c=o.replace(/\.git$/i,""),l=i4(c);if(l===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: source is not a plain https://github.com/<owner>/<repo> URL`};let u=(0,Pne.derivePath)(c);if(u===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: cannot derive mount path from source`};let f=`${l.owner}/${l.repo}#${Nn.SYNC_BRANCH}`,d=r.exo__Asset_uid,p=typeof d=="string"&&d.trim().length>0?d.trim():void 0;return{kind:"candidate",candidate:{spec:{owner:l.owner,repo:l.repo,branch:Nn.SYNC_BRANCH,repoKey:f,localPath:u,...s==="file"?{spaceKind:s}:{}},spaceKind:s,...p!==void 0?{asUid:p}:{}},...i!==void 0?{warning:i}:{}}}a(Fne,"classifySpaceDeclaration");var KI=class{static{a(this,"SpaceSpecAccumulator")}constructor(){this.specs=[],this.warnings=[],this.asUidByRepoKey=new Map,this.seen=new Set,this.kindByRepoKey=new Map}offer(e){let{spec:t,spaceKind:n}=e;if(this.seen.has(t.repoKey)){let i=this.kindByRepoKey.get(t.repoKey);if(i!==void 0&&i!==n&&(this.warnings.push(`repo ${t.repoKey} is declared as BOTH AssetSpace and FileSpace by different assets \u2014 treating as AssetSpace (deterministic, conservative); fix the vault (disjoint subtypes)`),i==="file")){this.kindByRepoKey.set(t.repoKey,"asset");let s=this.specs.find(o=>o.repoKey===t.repoKey);s!==void 0&&delete s.spaceKind}return null}return this.seen.add(t.repoKey),this.kindByRepoKey.set(t.repoKey,n),t}commit(e){this.specs.push(e.spec),e.asUid!==void 0&&this.asUidByRepoKey.set(e.spec.repoKey,e.asUid)}};Nn.SpaceSpecAccumulator=KI});var Ib=v(Jf=>{"use strict";Object.defineProperty(Jf,"__esModule",{value:!0});Jf.REF_NOT_FOUND_HINT=void 0;Jf.isAuthError=Lne;Jf.isRefNotFoundError=Nne;var s4=Ab();function Lne(r){let e=r instanceof Error?r.message:String(r);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(Lne,"isAuthError");function Nne(r){let e=r instanceof Error?r.message:String(r);return/\/git\/refs\/heads\/\S* → HTTP 404\b/.test(e)}a(Nne,"isRefNotFoundError");Jf.REF_NOT_FOUND_HINT=`GitHub answers 404 for a private repo outside a fine-grained PAT's repository allowlist (existence-hiding), for a deleted/renamed repo, and for a visible repo that has no \`${s4.SYNC_BRANCH}\` branch (ExoSync syncs \`${s4.SYNC_BRANCH}\` only) \u2014 check the token's repository allowlist first (R8)`});var YI=v(Rb=>{"use strict";Object.defineProperty(Rb,"__esModule",{value:!0});Rb.scanForSecrets=kne;Rb.redactSecrets=Mne;var o4=[{kind:"github-token",re:/gh[pousr]_[A-Za-z0-9_]{36,}/},{kind:"github-fine-grained-token",re:/github_pat_[A-Za-z0-9_]{22,}_[A-Za-z0-9_]{59,}/},{kind:"private-key",re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/}];function kne(r){let e=[];for(let[t,n]of r)for(let{kind:i,re:s}of o4)s.test(n)&&e.push({path:t,kind:i});return e}a(kne,"scanForSecrets");function Mne(r){let e=r;for(let{kind:t,re:n}of o4)e=e.replace(new RegExp(n.source,"g"),`[REDACTED:${t}]`);return e}a(Mne,"redactSecrets")});var JI=v(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});mc.caseInsensitiveHeaderGetter=jne;mc.parseRetryAfterMs=a4;mc.extractRateLimitFields=c4;mc.getRateLimitFields=$ne;mc.attachRateLimitFields=l4;mc.enrichRateLimitError=Une;function jne(r){let e=new Map;if(r&&typeof r=="object")for(let[t,n]of Object.entries(r))typeof n=="string"&&e.set(t.toLowerCase(),n);return t=>e.get(t.toLowerCase())}a(jne,"caseInsensitiveHeaderGetter");function XI(r){if(r==null)return;let e=r.trim();if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0}a(XI,"parseIntHeader");function a4(r,e=Date.now){if(r==null)return;let t=r.trim();if(t.length===0)return;let n=XI(t);if(n!==void 0)return Math.max(0,n*1e3);let i=Date.parse(t);if(!Number.isNaN(i))return Math.max(0,i-e())}a(a4,"parseRetryAfterMs");function c4(r,e=Date.now){let t={},n=a4(r("retry-after"),e);n!==void 0&&(t.retryAfterMs=n);let i=XI(r("x-ratelimit-reset"));i!==void 0&&(t.rateLimitReset=i);let s=XI(r("x-ratelimit-remaining"));return s!==void 0&&(t.rateLimitRemaining=s),t}a(c4,"extractRateLimitFields");function $ne(r){if(r===null||typeof r!="object")return{};let e=r,t={};return typeof e.retryAfterMs=="number"&&(t.retryAfterMs=e.retryAfterMs),typeof e.rateLimitReset=="number"&&(t.rateLimitReset=e.rateLimitReset),typeof e.rateLimitRemaining=="number"&&(t.rateLimitRemaining=e.rateLimitRemaining),t}a($ne,"getRateLimitFields");function QI(r,e,t){Object.defineProperty(r,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}a(QI,"defineHidden");function l4(r,e){return e.retryAfterMs!==void 0&&QI(r,"retryAfterMs",e.retryAfterMs),e.rateLimitReset!==void 0&&QI(r,"rateLimitReset",e.rateLimitReset),e.rateLimitRemaining!==void 0&&QI(r,"rateLimitRemaining",e.rateLimitRemaining),r}a(l4,"attachRateLimitFields");function Une(r,e,t=Date.now){return l4(r,c4(e,t))}a(Une,"enrichRateLimitError")});var Cb=v(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.DEFAULT_MAX_RETRIES=Zi.MIN_RATE_LIMIT_WAIT_MS=void 0;Zi.isRateLimitError=u4;Zi.createRateLimitBudget=Vne;Zi.withRateLimitBackoff=Wne;var Bne=JI();function u4(r){let e=r instanceof Error?r.message:String(r);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(u4,"isRateLimitError");Zi.MIN_RATE_LIMIT_WAIT_MS=6e4;Zi.DEFAULT_MAX_RETRIES=6;function Vne(r){let e=!(r>0),t=e?Number.POSITIVE_INFINITY:r;return{reset(){t=e?Number.POSITIVE_INFINITY:r},tryReserve(n){return n<=0?!0:n<=t?(t-=n,!0):!1}}}a(Vne,"createRateLimitBudget");var Gne=a(r=>new Promise(e=>setTimeout(e,r)),"defaultSleep");function qne(r,e,t,n,i,s){let o=(0,Bne.getRateLimitFields)(r);if(typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0)return o.retryAfterMs;if(o.rateLimitRemaining===0&&typeof o.rateLimitReset=="number"){let l=o.rateLimitReset*1e3-s();if(l>0)return l}let c=t*2**e*(1+i());return Math.max(n,c)}a(qne,"computeRateLimitDelay");function Wne(r,e={}){let t=e.maxRetries??Zi.DEFAULT_MAX_RETRIES,n=e.baseDelayMs??1e3,i=Math.max(Zi.MIN_RATE_LIMIT_WAIT_MS,e.minRateLimitWaitMs??Zi.MIN_RATE_LIMIT_WAIT_MS),s=e.budget,o=e.sleep??Gne,c=e.random??Math.random,l=e.now??(()=>Date.now());return async u=>{let f=0;for(;;)try{return await r(u)}catch(d){if(!u4(d)||f>=t)throw d;let p=qne(d,f,n,i,c,l);if(s!==void 0&&!s.tryReserve(p))throw d;f++,await o(p)}}}a(Wne,"withRateLimitBackoff")});var xb=v(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.DEFAULT_MAX_FILE_BYTES=Ea.InMemoryQuarantineStore=void 0;Ea.contentEquals=Hne;Ea.isSyncablePath=zne;Ea.isFileSpaceSyncablePath=Kne;function Hne(r,e){if(r===void 0||e===void 0||typeof r=="string"&&typeof e=="string")return r===e;if(typeof r=="string"||typeof e=="string"||r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}a(Hne,"contentEquals");var ZI=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};Ea.InMemoryQuarantineStore=ZI;function zne(r){return r.endsWith(".md")&&!r.includes(".local.")&&!r.includes(".conflict.")}a(zne,"isSyncablePath");function Kne(r){return!r.includes(".local.")&&!r.includes(".conflict.")}a(Kne,"isFileSpaceSyncablePath");Ea.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var S4=v(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.SyncEngine=Sn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=Sn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=Sn.DEFAULT_MAX_PUSH_RETRIES=void 0;Sn.syncProgressPhaseText=Qne;Sn.isNonFastForwardError=b4;Sn.orderChildrenFirst=iie;var f4=Sb(),d4=WI(),dt=Xf(),So=Ph(),Yne=Nu(),ql=Qf(),eR=Tb(),tR=Ib(),p4=YI(),h4=Cb(),wo=xb();Sn.DEFAULT_MAX_PUSH_RETRIES=3;Sn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=3e5;Sn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function Qne(r){switch(r.phase){case"reading-local":return r.detail!==void 0?`reading local files ${r.detail.done}\u2026`:"reading local files\u2026";case"detecting":return"detecting changes\u2026";case"pulling-remote":return"pulling remote tree\u2026";case"fetching-blobs":return r.detail!==void 0?`fetching remote files ${r.detail.done}/${r.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return r.detail!==void 0?`writing files ${r.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return r.phase}}a(Qne,"syncProgressPhaseText");var m4=25,Xne=10,Jne=6,Zne=500,eie=25;function tie(r){try{return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{return null}}a(tie,"decodeUtf8Strict");function rie(r){return typeof r=="string"?r:{base64:(0,Yne.bytesToBase64)(r)}}a(rie,"toCommitContent");async function g4(r,e){if(r.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return r.readBinary(e)}a(g4,"readBinaryStrict");async function nie(r,e,t){if(r.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return r.writeBinary(e,t)}a(nie,"writeBinaryStrict");function y4(r){return r.length===0||r.startsWith("/")||r.includes("\\")?!1:r.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(y4,"isSafeRepoRelativePath");function b4(r){let e=r instanceof Error?r.message:String(r);return/HTTP 422/.test(e)&&/git\/refs/.test(e)||/ref update mismatch/.test(e)||/HTTP 422/.test(e)&&/git\/trees/.test(e)&&/BadObjectState/.test(e)}a(b4,"isNonFastForwardError");function iie(r){let e=a(t=>t.split("/").filter(n=>n.length>0).length,"depth");return[...r].sort((t,n)=>e(n.localPath)-e(t.localPath))}a(iie,"orderChildrenFirst");function _4(r,e){let t=new Map(r.map(o=>[o.path,o])),n=new Set,i=[];for(let o of e){n.add(o.path);let c=t.get(o.path);(c===void 0||c.blobSha!==o.blobSha)&&i.push(o)}let s=r.filter(o=>!n.has(o.path));return{changed:i,deleted:s}}a(_4,"diffTrees");function sie(r){let e=r instanceof Error?r.message:String(r);return/→ HTTP (?:404|422)\b/.test(e)}a(sie,"isCommitUnknownError");function va(r){return r instanceof Error?r.message:String(r)}a(va,"errMsg");function oie(r,e,t){if(t.size===0)return r;let n=new Map(e.files.map(o=>[o.path,o])),i=new Set(r.map(o=>o.path)),s=[];for(let o of r){if(!t.has(o.path)){s.push(o);continue}let c=n.get(o.path);c!==void 0&&s.push(c)}for(let o of t){if(i.has(o))continue;let c=n.get(o);c!==void 0&&s.push(c)}return s}a(oie,"applyWatermarkPins");var rR={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function nR(r){return new Map(r.map(e=>[e.path,e.blobSha]))}a(nR,"treeByPath");function Ob(r){return[...r.quarantineEntries.map(e=>e.path),...r.resolvedQuarantineEntries.map(e=>e.path)]}a(Ob,"quarantinedPathsOf");var iR=class{static{a(this,"SyncEngine")}constructor(e){this.activeTimer=null,this.activeLocalIoProgress=null,this.opInProgress=!1,this.deps=e,this.now=e.now??(()=>Date.now()),this.rateLimitBudget=(0,h4.createRateLimitBudget)(e.backoff?.maxTotalRateLimitWaitMs??Sn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS),this.transport=this.instrumentTransport((0,h4.withRateLimitBackoff)(e.transport,{...e.backoff,budget:this.rateLimitBudget,now:this.now})),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpRest(),n.time((0,d4.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpHashed(),n.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((c,l)=>{let u=this.activeTimer;return u===null?l():u.time(c,l)},"timed"),n={list:a(()=>t("localList",()=>e.list()),"list"),read:a(c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(c))),"read"),write:a((c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(c,l))),"write"),delete:a(c=>e.delete(c),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(n.readBinary=c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(c))));let s=e.writeBinary?.bind(e);s!==void 0&&(n.writeBinary=(c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(c,l))));let o=e.stat?.bind(e);return o!==void 0&&(n.stat=c=>t("localList",()=>o(c))),n}busyResult(e){return{repoKey:e.repoKey,status:"busy",pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:[],deferredDeletes:[],detail:"another sync operation is in progress (D11 guard) \u2014 retry after it finishes"}}modeOps(e){let t=e.spaceKind==="file",n=t?wo.isFileSpaceSyncablePath:wo.isSyncablePath,i=this.deps.maxFileBytes??wo.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:n,treeFilter:a(s=>n(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,dt.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(n.treeFilter),l=[];for(let u of c){let f=t.get(u.path);f!==void 0&&await(0,ql.gitBlobSha)(f,this.sha1)===u.blobSha&&l.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${l.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:l,spaceKind:"file"}}async syncAll(e,t="sync",n){if(this.opInProgress)return e.map(i=>this.busyResult(i));this.opInProgress=!0,this.rateLimitBudget.reset();try{let i=[];for(let s of e)i.push(await this.syncLocked(s,t,n));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",n){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0,this.rateLimitBudget.reset();try{return await this.syncLocked(e,t,n)}finally{this.opInProgress=!1}}emitProgress(e,t,n,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:n}:{repoKey:t,phase:n,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%Zne===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%eie===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",n){let i=new d4.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=n!==void 0?{emit:n,repoKey:e.repoKey,reads:0,writes:0}:null;let c=[],l=[],u=0,f=0,d=[],p=a((h,m={})=>({repoKey:e.repoKey,status:h,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:c,deferredDeletes:l,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),...m}),"result");try{let h=await this.deps.materializationCheck.check(e);if(!h.fullyMaterialized)return c.push(`skipped: repo not fully materialized${h.reason?` (${h.reason})`:""} \u2014 deletes NOT inferred (D19)`),p("skipped-not-materialized");let m=this.modeOps(e),g=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(m.fileMode&&(g.readBinary===void 0||g.writeBinary===void 0))return p("error",{detail:"file-mode repo requires a LocalFilesPort with readBinary/writeBinary \u2014 refusing to sync through the text-only port (binary would corrupt)"});if(m.fileMode&&this.deps.quarantine===void 0)return p("error",{detail:"file-mode repo requires a quarantine sink (D18 remote-wins preserves losing local bytes there) \u2014 configure the quarantine repo before syncing FileSpaces"});let _=this.deps.maxFileBytes??wo.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let V=await this.flushOutbox(e,c);u=V.pushed,f=V.reconflicted}let b=await this.deps.watermarkStore.get(e.repoKey);if(b?.spaceKind==="file"&&!m.fileMode)return p("error",{detail:"watermark was written by a FILE-mode sync but the spec now resolves to asset mode \u2014 refusing (fix the conflicting Space declarations, or clear the watermark to restart)"});b!==null&&m.fileMode&&b.spaceKind!=="file"&&(c.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),b=null);let T=this.deps.localManifestStore!==void 0?g.stat?.bind(g):void 0,I=T!==void 0&&b!==null&&!m.fileMode,w=I&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,S=this.deps.localManifestFullRehashMs??Sn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,R=I&&(w===null||this.now()-w.lastFullRehashMs>=S),L=new Map,P=new Set,M=new Map,O=new Map,F=new Map,Z=!1,J=new Map;if(I&&b!==null)for(let V of b.files)J.set(V.path,V.blobSha);for(let V of(await g.list()).filter(m.syncable)){if(m.fileMode){let se=await g4(g,V);if(se.byteLength>_){P.add(V),c.push(`skipped oversized file ${V} (${se.byteLength} bytes > ${_} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}L.set(V,se);continue}if(!I||T===void 0){L.set(V,await g.read(V));continue}let D=await T(V),z=!R&&D!==null?w?.files[V]:void 0;if(D!==null&&z!==void 0&&z.mtimeMs===D.mtimeMs&&z.size===D.size&&z.blobSha===J.get(V)){M.set(V,{blobSha:z.blobSha,...z.uid!==void 0?{uid:z.uid}:{}}),O.set(V,z.blobSha),F.set(V,D);continue}Z=!0,L.set(V,await g.read(V)),D!==null&&F.set(V,D)}let U=!1;if(b===null)if(m.fileMode)U=!0,b=await this.buildFileModeFirstSyncBase(e,L,m,c);else{let V=await this.bootstrapWatermark(e,L,c,p);if(V.kind==="settled")return V.outcome;U=!0,b=V.base}let K=b;m.fileMode&&P.size>0&&(b={...b,files:b.files.filter(V=>!P.has(V.path))});let _e,le;I&&!R?(_e=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),le=_e===b.lastSyncedSha?b.rootTreeSha:await this.resolveBaseTreeSha(e,b,{headReachable:!0})):le=await this.resolveBaseTreeSha(e,b),this.emitProgress(n,e.repoKey,"detecting");let W=await(0,So.detectChanges)({localFiles:L,...I?{cachedEntries:M}:{},watermark:b,actualBaseTreeSha:le,sha1:this.sha1});if(W.kind==="full-conflict")return p("full-conflict",{detail:`${W.reason}${W.detail?`: ${W.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(c.push(...W.warnings),I&&this.deps.localManifestStore!==void 0){let V={};for(let[D,z]of L){let se=F.get(D),be=W.diskBlobShas.get(D);if(se===void 0||be===void 0)continue;let Re=typeof z=="string"?(0,So.extractAssetUid)(z):void 0;V[D]={mtimeMs:se.mtimeMs,size:se.size,blobSha:be,...Re!==void 0?{uid:Re}:{}}}for(let[D,z]of M){let se=F.get(D);se!==void 0&&(V[D]={mtimeMs:se.mtimeMs,size:se.size,blobSha:z.blobSha,...z.uid!==void 0?{uid:z.uid}:{}})}if(w!==null&&Object.keys(w.files).some(D=>!(D in V))&&(Z=!0),Z||R||w===null){let D={version:1,files:V,lastFullRehashMs:R||w===null?this.now():w.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,D)}}let H=this.pinLocalChanges(W,L,c,l,t);d=[...H.pushDeletionsAll.keys()];let oe=await this.runPushLoop(e,b,H,L,c,m,U,P,t,n,_e);if(d=[],oe.kind!=="done"&&H.pushDeletionsAll.size>0&&l.push(...H.pushDeletionsAll.keys()),oe.kind==="conflict")return p("conflict",{detail:oe.detail});if(oe.kind==="retry-exhausted"){c.push(...oe.merge.warnings);let V=await this.buildTerminalQuarantineEntries(e,b,oe.pushFiles,oe.merge.quarantineEntries,L),D=[...oe.merge.quarantineEntries,...oe.merge.resolvedQuarantineEntries,...V];return await this.flushQuarantine(D,c),p("retry-exhausted",{detail:oe.detail,quarantinedCount:D.length,...D.length>0?{quarantinedPaths:D.map(z=>z.path)}:{}})}let{examinedHead:xe,pushedSha:re,applyWrites:Q,applyDeletes:ie,pushFiles:Y}=oe,ae=oe.merge;c.push(...ae.warnings),c.push(...oe.deferredWarnings),l.push(...oe.withheldDeletions);let Me=oe.deferredPaths.size>0?{deferredPaths:[...oe.deferredPaths]}:{},N=oe.pushedDeletions.length>0?{pushedDeletes:oe.pushedDeletions}:{},ue=await this.flushQuarantine([...ae.quarantineEntries,...ae.resolvedQuarantineEntries],c);oe.secretQuarantineEntries.length>0&&await this.flushQuarantine(oe.secretQuarantineEntries,c);let fe=new Set;if(!ue&&ae.resolvedQuarantineEntries.length>0){for(let V of ae.resolvedQuarantineEntries)fe.add(V.path);c.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${fe.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(re===void 0&&xe===b.lastSyncedSha&&Q.length===0&&ie.length===0&&ae.mergedWrites.length===0&&ae.quarantineEntries.length===0&&ae.resolvedQuarantineEntries.length===0&&(b.pinnedPaths?.length??0)===0&&oe.alreadyInHead.length===0&&oe.deferredPaths.size===0&&!U)return p("synced");let Ie=re??xe,we=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,Ie,this.deps.baseURL);if(re!==void 0&&we.parents[0]!==xe)return await this.checkRaceWindow(e,b,xe,we.parents[0],Y,new Set(oe.pushedDeletions),c,m),c.push(`race-window: watermark NOT advanced (pushed commit's parent ${we.parents[0]} != examined head ${xe}) \u2014 next sync reconciles the concurrent change`),p("synced",{pushedSha:re,pushedCount:Y.size,mergedCount:ae.mergedCount,quarantinedCount:ae.quarantineEntries.length+ae.resolvedQuarantineEntries.length,...ae.mergedPaths.length>0?{mergedPaths:ae.mergedPaths}:{},...Ob(ae).length>0?{quarantinedPaths:Ob(ae)}:{},...Me,...N});let{pulledCount:ve,pinnedPaths:Ae,pulledPaths:pe}=await this.applyRemoteChanges(g,L,[...Q,...ae.mergedWrites].filter(V=>!fe.has(V.path)),ie.filter(V=>!fe.has(V.path)),c,O);for(let V of ae.quarantineEntries)Ae.add(V.path);for(let V of oe.deferredPaths)Ae.add(V);for(let V of fe)Ae.add(V);if(m.fileMode){for(let V of P)Ae.add(V);for(let V of oe.remoteOversized)Ae.add(V)}return await this.advanceWatermark(e,Ie,we.treeSha,L,[...Q,...ae.mergedWrites,...oe.deferredRemoteChanges],K,Ae,W.diskBlobShas,m,P),await this.resolveClearedPins(e,K,Ae,c,new Set(ae.resolvedQuarantineEntries.map(V=>V.path))),p("synced",{pushedSha:re,pulledCount:ve,pushedCount:Y.size,mergedCount:ae.mergedCount,quarantinedCount:ae.quarantineEntries.length+ae.resolvedQuarantineEntries.length,...ae.mergedPaths.length>0?{mergedPaths:ae.mergedPaths}:{},...pe.length>0?{pulledPaths:pe}:{},...Ob(ae).length>0?{quarantinedPaths:Ob(ae)}:{},...Me,...N})}catch(h){let m=this.deps.redact??(g=>g);if(d.length>0&&l.push(...d),(0,tR.isAuthError)(h))return p("auth-required",{detail:m(`authentication failed: ${va(h)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)});if((0,tR.isRefNotFoundError)(h)){let g=m(`${e.owner}/${e.repo}@${e.branch} is not reachable: ${va(h)} \u2014 ${tR.REF_NOT_FOUND_HINT}`);return c.push(`sync failed: ${g}`),p("error",{detail:g})}return c.push(`sync failed: ${m(va(h))}`),p("error",{detail:m(va(h))})}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let n=this.deps.redact??(s=>s);for(let s of e)t.push(n(`quarantined ${s.path}: ${s.reason}`));let i=this.deps.quarantine;if(i===void 0)return!1;try{if(i.quarantineAll!==void 0)await i.quarantineAll(e);else for(let s of e)await i.quarantine(s);return!0}catch(s){let o=this.deps.redact??(c=>c);return t.push(`quarantine sink failed: ${o(va(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let n=this.deps.outbox;if(n===void 0)return{pushed:0,reconflicted:0};let i=await n.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(m=>m),o,c;try{({head:o,shaByPath:c}=await this.outboxHeadTreeShas(e))}catch(m){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(va(m))}`),{pushed:0,reconflicted:0}}let l=0,u=[];for(let m of i){let g=c.get(m.path)??eR.OUTBOX_REMOTE_ABSENT,_=g===eR.OUTBOX_REMOTE_ABSENT&&m.baseRemoteSha!==eR.OUTBOX_REMOTE_ABSENT?[...c].filter(([b,T])=>b!==m.path&&T===m.baseRemoteSha).map(([b])=>b):[];if(g!==m.baseRemoteSha&&_.length===0){await n.remove(m.repoKey,m.path),l++,t.push(s(`outbox: remote moved for ${m.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:m,stalePaths:_})}if(u.length===0)return{pushed:0,reconflicted:l};let f=new Map;for(let{entry:m}of u)f.set(m.path,m.chosenContent);let d=new Set;for(let{stalePaths:m}of u)for(let g of m)f.has(g)||d.add(g);let p=[...d];try{await(0,f4.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:f,...p.length>0?{deletions:p}:{},message:p.length>0?`chore(exosync): resolve ${u.length} keep-local conflict(s) (consolidate ${p.length} stale remote path(s))`:`chore(exosync): push ${u.length} resolved conflict(s)`,expectedHeadSha:o,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}catch(m){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(va(m))}`),{pushed:0,reconflicted:l}}let h=0;for(let{entry:m,stalePaths:g}of u){let _=g.filter(b=>!f.has(b));await this.snapOutboxWatermark(e,m.path,m.chosenContent,_),await this.deps.quarantine?.markResolved?.(m.repoKey,m.path);for(let b of _)await this.deps.quarantine?.markResolved?.(m.repoKey,b);await n.remove(m.repoKey,m.path),h++,_.length>0&&t.push(`consolidated cross-path conflict for ${m.path} \u2014 removed ${_.length} stale remote copy/copies (recoverable in git history)`)}return h>0&&t.push(`pushed ${h} resolved conflict(s)`),{pushed:h,reconflicted:l}}async outboxHeadTreeShas(e){let t=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,dt.getTree)(this.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return{head:t,shaByPath:s}}async snapOutboxWatermark(e,t,n,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),c=(s.pinnedPaths??[]).filter(g=>!o.has(g)),l=await(0,ql.gitBlobSha)(n,this.sha1),u=(0,So.extractAssetUid)(n),f={path:t,blobSha:l,...u!==void 0?{uid:u}:{}},d=new Set(i),p=s.files.filter(g=>!d.has(g.path)),h=p.findIndex(g=>g.path===t),m=h>=0?p.map((g,_)=>_===h?f:g):[...p,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:m,...c.length>0?{pinnedPaths:c}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,n,i,s){let o=new Set(i.map(u=>u.path)),c=new Map;try{let u=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>n.has(d.path));for(let d of f)c.set(d.path,await(0,dt.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let l=[];for(let[u,f]of n){if(o.has(u))continue;let d=s.get(u),p=d??f,h=d!==void 0&&!(0,wo.contentEquals)(d,f),m=typeof p=="string"?(0,So.extractAssetUid)(p):void 0,g=c.get(u);l.push({repoKey:e.repoKey,path:u,...m!==void 0?{uid:m}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??Sn.DEFAULT_MAX_PUSH_RETRIES} retries (D16) \u2014 a concurrent writer keeps moving ${e.branch}; base recoverable from git history at ${t.lastSyncedSha}${h?"; the contended push payload was a merged proposal (never applied to disk) \u2014 the merge re-derives next sync":""}`,...typeof p=="string"?{localContent:p}:{localContentBytes:p},...g!==void 0?{remoteContent:g}:{}})}return l}async resolveClearedPins(e,t,n,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let c=(t.pinnedPaths??[]).filter(l=>!n.has(l)&&!s.has(l));for(let l of c)try{await o.markResolved?.(e.repoKey,l)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${l}: ${f(va(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t,n={}){try{return(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch(i){if(!sie(i))throw i;return n.headReachable===!0||await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),null}}pinLocalChanges(e,t,n,i,s){let o=e.modified.filter(p=>p.basePath!==void 0),c=[...e.added,...e.modified.filter(p=>p.basePath===void 0)],l=new Map;if(s==="pull"){for(let p of o)p.basePath!==void 0&&i.push(p.basePath),n.push(`pull-only: rename (uid ${p.uid??"?"}) ${p.basePath} \u2192 ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`);for(let p of e.deleted)i.push(p.path),n.push(`pull-only: delete of ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`)}else{for(let p of o)p.basePath!==void 0&&l.set(p.basePath,p.path);for(let p of e.deleted)l.set(p.path,p.path)}let u=[...c,...o,...e.deleted.map(p=>({...p}))],f=new Set(e.deleted.map(p=>p.path)),d=new Map;for(let p of[...c,...s==="pull"?[]:o]){let h=t.get(p.path);h!==void 0&&d.set(p.path,h)}return{localChanges:u,localDeletedPaths:f,pushFilesAll:d,pushDeletionsAll:l,dupUids:e.duplicateUids}}async runPushLoop(e,t,n,i,s,o,c=!1,l=new Set,u="sync",f,d){let{localChanges:p,localDeletedPaths:h,pushFilesAll:m,pushDeletionsAll:g,dupUids:_}=n,b=this.deps.maxPushRetries??Sn.DEFAULT_MAX_PUSH_RETRIES,T=0,I="",w,S=[],R=[],L=new Map,P=new Set,M=[],O=rR,F=[],Z=new Set,J=[],U=[],K=new Set,_e=[],le=new Set;for(;;){I=T===0&&d!==void 0&&m.size===0&&g.size===0?d:await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),S=[],R=[],O=rR,F=[],Z=new Set,J=[],U=[];let W,H=new Set,oe=(t.pinnedPaths?.length??0)>0;if(I!==t.lastSyncedSha||oe||c){this.emitProgress(f,e.repoKey,"pulling-remote");let Q=await this.collectRemoteChanges(e,t,I,o,l,s,K,f);W=Q.headTreeByPath;let ie=this.matchLocalVsRemote(p,h,i,Q.changes,H,_,Q.headTreeByPath);if(ie.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let Y of ie.conflicts){Z.add(Y.local.path),Y.local.basePath!==void 0&&Z.add(Y.local.basePath);for(let ae of Y.remotes)Z.add(ae.path),ae.kind==="change"&&J.push(ae)}U.push(`${u}-only: ${ie.conflicts.length} conflict(s) deferred to a full Sync (${ie.conflicts.map(Y=>Y.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)O=this.resolveFileModeConflicts(e,ie.conflicts,i,ie.applyWrites,ie.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${ie.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};O=await this.resolveMergeConflicts(e,t,ie.conflicts,i)}if(u==="sync")for(let Y of ie.conflicts)for(let ae of Y.remotes)ae.path!==Y.local.path&&(Z.add(ae.path),ae.kind==="change"&&J.push(ae),U.push(`conflict group ${Y.desc}: remote change at ${ae.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(S=ie.applyWrites,R=ie.applyDeletes,u==="push"&&(S.length>0||R.length>0)){for(let Y of S)Z.add(Y.path),J.push(Y);for(let Y of R)Z.add(Y.path);U.push(`push-only: ${S.length+R.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),S=[],R=[]}}L=u==="pull"?new Map:new Map([...[...m].filter(([Q])=>!H.has(Q)),...O.mergedFiles]),P=new Set,M=[];for(let[Q,ie]of g){if(H.has(ie)){M.push(Q);continue}L.has(Q)||P.add(Q)}if((L.size>0||P.size>0)&&W===void 0&&(W=nR(await(0,dt.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),L.size>0&&W!==void 0){for(let[Q,ie]of L){let Y=W.get(Q);Y!==void 0&&Y===await(0,ql.gitBlobSha)(ie,this.sha1)&&(L.delete(Q),F.push(Q))}F.length>0&&s.push(`phantom push skipped: ${F.length} file(s) already identical in remote HEAD (${F.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(P.size>0&&W!==void 0){for(let Q of[...P])W.has(Q)||P.delete(Q);L.size===0&&P.size>=W.size&&(M.push(...P),U.push(`deletion of ALL ${P.size} remaining file(s) deferred \u2014 GitHub cannot create an empty tree; the deletes re-derive and propagate once the repo has at least one surviving file`),P.clear())}if(L.size===0&&P.size===0)break;let xe=new Map;for(let[Q,ie]of L)if(typeof ie=="string")xe.set(Q,ie);else{let Y=tie(ie);Y!==null&&xe.set(Q,Y)}let re=(0,p4.scanForSecrets)(xe);if(re.length>0){let Q=new Map;for(let ie of re){let Y=Q.get(ie.path);Y===void 0?Q.set(ie.path,[ie.kind]):Y.includes(ie.kind)||Y.push(ie.kind)}for(let[ie,Y]of Q){if(!le.has(ie)){le.add(ie);let ae=xe.get(ie),Me=ae!==void 0?(0,p4.redactSecrets)(ae):void 0,N=Me!==void 0?(0,So.extractAssetUid)(Me):void 0;_e.push({repoKey:e.repoKey,path:ie,...N!==void 0?{uid:N}:{},reason:`secret-scan (R5): detected ${Y.join(", ")} \u2014 skipped from the push (the secret is NEVER shipped); a redacted copy is quarantined. REVOKE the credential, then re-sync once it is removed.`,...Me!==void 0?{localContent:Me}:{}})}L.delete(ie)}s.push(`secret-scan (R5): skipped ${Q.size} file(s) with a detected secret from the push \u2014 the rest of the changeset shipped; REVOKE the credential(s): ${[...Q].map(([ie,Y])=>`${ie} (${Y.join(", ")})`).join(", ")}`);for(let[ie,Y]of g)le.has(Y)&&P.has(ie)&&(P.delete(ie),M.push(ie));if(L.size===0&&P.size===0)break}try{w=await(0,f4.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...L].map(([Q,ie])=>[Q,rie(ie)])),deletions:[...P],message:this.deps.commitMessage?.(e,L.size,P.size)??`chore(exosync): sync ${L.size} file(s)${P.size>0?`, ${P.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(Q){if(!b4(Q))throw Q;if(T++,T>b)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${b} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:L,merge:O};s.push(`non-fast-forward push (attempt ${T}/${b}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:I,pushedSha:w,applyWrites:S,applyDeletes:R,pushFiles:L,pushedDeletions:w!==void 0?[...P]:[],withheldDeletions:M,merge:O,remoteOversized:K,alreadyInHead:F,deferredPaths:Z,deferredRemoteChanges:J,deferredWarnings:U,secretQuarantineEntries:_e}}async resolveMergeConflicts(e,t,n,i){let s=this.deps.mergeLayer;if(s===void 0)return rR;let o=new Map(t.files.map(g=>[g.path,g])),c=new Map,l=[],u=[],f=[],d=[],p=0,h=a(g=>typeof g=="string"?g:void 0,"asText"),m=a((g,_,b)=>{let T=h(i.get(g.local.path)),I=h(g.remotes[0]?.content);return{repoKey:e.repoKey,path:g.local.path,...g.local.uid!==void 0?{uid:g.local.uid}:{},reason:_,...b!==void 0?{baseContent:b}:{},...T!==void 0?{localContent:T}:{},...I!==void 0?{remoteContent:I}:{}}},"entry");for(let g of n){let _=o.get(g.local.basePath??g.local.path)??o.get(g.remotes[0]?.path??""),b;if(_!==void 0&&(b=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,_.blobSha,this.deps.baseURL)),g.remotes.length>1){u.push(m(g,`ambiguous conflict: local change overlaps ${g.remotes.length} remote changes (${g.remotes.map(R=>R.path).join(", ")})`,b));continue}let T=g.remotes[0],I=h(i.get(g.local.path)),w=await s.resolve({path:g.local.path,...g.local.uid!==void 0?{uid:g.local.uid}:{},...b!==void 0?{base:b}:{},...I!==void 0?{local:I}:{},...T.kind==="change"&&typeof T.content=="string"?{remote:T.content}:{}});if(w.action==="quarantine"){u.push(m(g,w.reason,b));continue}p++,d.push(g.local.path);for(let R of w.warnings??[])f.push(`merge(${g.local.path}): ${R}`);let S=T.kind==="change"?T.content:void 0;if(w.content!==S&&c.set(g.local.path,w.content),w.content!==i.get(g.local.path)){let R=(0,So.extractAssetUid)(w.content)??g.local.uid;l.push({path:g.local.path,kind:"change",content:w.content,blobSha:await(0,ql.gitBlobSha)(w.content,this.sha1),...R!==void 0?{uid:R}:{}})}}return{mergedFiles:c,mergedWrites:l,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:p,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,n,i,s){let o=[],c=[];for(let l of t){l.remotes.length>1&&c.push(`file-mode conflict on ${l.local.path} unexpectedly overlaps ${l.remotes.length} remote changes \u2014 resolving against the first`);let u=l.remotes[0],f=n.get(l.local.path);u.kind==="change"?i.push(u):s.push(u),!(l.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:l.local.path,reason:`file-mode remote-wins (D18): remote ${u.kind==="change"?`version ${u.blobSha}`:"delete"} wins; this is the losing LOCAL version, preserved byte-exact`,...typeof f=="string"?{localContent:f}:{localContentBytes:f}})}return{mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:o,mergedCount:0,mergedPaths:[],warnings:c}}async applyRemoteChanges(e,t,n,i,s,o=new Map){let c=0,l=new Set,u=[],f=a(async(h,m)=>{try{return m?await g4(e,h):await e.read(h)}catch{return}},"tryRead"),d=a(async(h,m)=>{typeof m=="string"?await e.write(h,m):await nie(e,h,m)},"writeContent"),p=a(async h=>{let m=await f(h,!1);return m===void 0?!0:await(0,ql.gitBlobSha)(m,this.sha1)===o.get(h)},"cacheHitUnchanged");for(let h of n){if(h.content===void 0)continue;if(!y4(h.path)){s.push(`unsafe remote path skipped on pull-apply: ${h.path}`),l.add(h.path);continue}let m=t.get(h.path);if(m===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path);continue}let g=await f(h.path,typeof(m??h.content)!="string");if(!(0,wo.contentEquals)(g,m)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path)}for(let h of i){if(!y4(h.path)){s.push(`unsafe remote path skipped on pull-delete: ${h.path}`),l.add(h.path);continue}let m=t.get(h.path);if(m===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path);continue}if(m!==void 0){let g=await f(h.path,typeof m!="string");if(g!==void 0&&!(0,wo.contentEquals)(g,m)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path)}}return{pulledCount:c,pinnedPaths:l,pulledPaths:u}}async advanceWatermark(e,t,n,i,s,o,c,l,u,f=new Set){let d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).filter(h=>u.treeFilter(h)&&!f.has(h.path)),p=oie(await this.buildWatermarkFiles(e,d,i,s,o,l,u),o,c);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:n,files:p,...c.size>0?{pinnedPaths:[...c]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,n,i,s){let o=this.deps.mountBaseStore,c=null;if(o!==void 0)try{c=await o.get(e.repoKey)}catch{return null}let l=!1;if(c===null&&this.deps.localBaseShaProvider!==void 0)try{let _=await this.deps.localBaseShaProvider(e);typeof _=="string"&&_.length>0&&(c=_,l=!0)}catch{}if(c===null||t.startsWith(c))return null;let u=300,f=null;try{let _=t;for(let b=0;b<u;b++){let T=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,_,this.deps.baseURL);if(T.sha===c||T.sha.startsWith(c)){f=T;break}if(T.parents.length===0)break;_=T.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(_=>(0,wo.isSyncablePath)(_.path))}catch{return null}let p;try{let _=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);p=nR((await(0,dt.getTree)(this.transport,e.owner,e.repo,_.treeSha,this.deps.baseURL)).filter(b=>(0,wo.isSyncablePath)(b.path)))}catch{return null}let h=d.filter(_=>!n.has(_.path)&&p.get(_.path)===_.blobSha);if(h.length>0){let _=h.slice(0,3).map(b=>b.path).join(", ")+(h.length>3?", \u2026":"");return i.push(`first-sync (asset mode): base-tree\u2286working-tree sanity guard fired \u2014 ${h.length} base file(s) absent from the working tree but UNCHANGED on remote head (${_}); the verified-ancestor base may not match the working tree's derivation commit (out-of-band submodule manipulation) \u2192 routing to merge/quarantine instead of inferring a silent deletion (#3610)`),{kind:"settled",outcome:s("full-conflict",{detail:`first-sync: base-tree\u2286working-tree sanity guard \u2014 ${h.length} base file(s) absent from the working tree are unchanged on remote head (${_}); refusing to infer a silent deletion from a base that may not match the derivation commit \u2014 divergence must go through merge/quarantine (A2/A3), never a silent delete (#3610)`})}}let m=d.map(_=>({path:_.path,blobSha:_.blobSha})),g={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:m};if(l&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(l?`first-sync (asset mode): BACKFILLED the 3-way base from the locally checked-out commit ${f.sha} (no recorded mount base) \u2014 remote head ${t} advanced since; local edits 3-way merge against it instead of false-conflicting (#3590)`:`first-sync (asset mode): reconciling against the recorded mount base ${f.sha} \u2014 remote head ${t} advanced since mount; local edits 3-way merge against it instead of false-conflicting (#3590)`),{kind:"additive-base",base:g}}async bootstrapWatermark(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,n,i);if(o!==null)return o;let c=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,dt.getTree)(this.transport,e.owner,e.repo,c.treeSha,this.deps.baseURL)).filter(p=>(0,wo.isSyncablePath)(p.path)),u=[],f;for(let p of l){let h=t.get(p.path);if(h===void 0||await(0,ql.gitBlobSha)(h,this.sha1)!==p.blobSha){f===void 0&&(f=p.path);continue}let m=typeof h=="string"?(0,So.extractAssetUid)(h):void 0;u.push({path:p.path,blobSha:p.blobSha,...m?{uid:m}:{}})}let d={lastSyncedSha:s,rootTreeSha:c.treeSha,files:u};return f!==void 0?this.deps.mergeLayer===void 0?{kind:"settled",outcome:i("full-conflict",{detail:`first-sync: no watermark and local content diverges from remote head at ${f} \u2014 A2/A3 scope`})}:(n.push(`first-sync (asset mode): no 3-way merge base and local diverges from remote head (first at ${f}) \u2014 reconciling ZERO-LOSS against ${u.length} byte-identical file(s) as a synthetic base: remote-only files pull, local-only files push, overlapping divergences route to the merge/quarantine layer (both versions preserved), never a silent overwrite or delete`),{kind:"additive-base",base:d}):t.size===l.length?(await this.deps.watermarkStore.set(e.repoKey,d),n.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(n.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${l.length} files) \u2014 ${t.size-l.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,n,i,s=new Set,o=[],c=new Set,l){let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL),f=await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let P of f)i.syncable(P.path)&&!i.treeFilter(P)&&!c.has(P.path)&&(c.add(P.path),o.push(`skipped oversized REMOTE file ${P.path} (${P.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(P=>i.treeFilter(P)&&!s.has(P.path)),p=t.files.filter(P=>!c.has(P.path)&&!s.has(P.path)),{changed:h,deleted:m}=_4(p,d),g=h.length;g>=m4&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:0,total:g});let _=new Array(h.length),b=0,T=0,I,w=a(async P=>{if(i.fileMode){let O=await(0,dt.getBlobBytes)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:O}}let M=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:M,uid:(0,So.extractAssetUid)(M)}},"fetchOne"),S=a(async()=>{for(;;){if(I!==void 0)return;let P=b++;if(P>=h.length)return;try{_[P]=await w(h[P])}catch(M){I===void 0&&(I=M);return}T+=1,g>=m4&&T%Xne===0&&T<g&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:T,total:g})}},"worker"),R=Math.min(Jne,h.length);if(await Promise.all(Array.from({length:R},()=>S())),I!==void 0)throw I instanceof Error?I:new Error(String(I));let L=_;for(let P of m)L.push({path:P.path,kind:"delete",uid:P.uid});return{changes:L,headTreeByPath:nR(f)}}matchLocalVsRemote(e,t,n,i,s,o=new Set,c){let l=new Set,u=[],f=new Map;for(let g of i)g.kind==="change"&&g.uid!==void 0&&f.set(g.uid,(f.get(g.uid)??0)+1);let d=new Set(o);for(let[g,_]of f)_>1&&d.add(g);let p=new Map,h=new Map;for(let g of i){if(g.uid!==void 0&&!d.has(g.uid)){let _=p.get(g.uid)??[];_.push(g),p.set(g.uid,_)}h.set(g.path,g)}for(let g of e){let _=new Set;if(g.uid!==void 0&&!d.has(g.uid))for(let w of p.get(g.uid)??[])w.kind==="change"&&w.path!==g.path&&(c?.has(g.path)===!0||g.basePath!==void 0&&c?.has(g.basePath)===!0)||_.add(w);let b=h.get(g.path);if(b!==void 0&&_.add(b),g.basePath!==void 0){let w=h.get(g.basePath);w!==void 0&&_.add(w)}let T=[],I=!1;for(let w of _){if(I=t.has(g.path)&&!n.has(g.path),I&&w.kind==="delete"){l.add(w);continue}if(!I&&w.kind==="change"&&w.path===g.path&&w.blobSha===g.blobSha){l.add(w),s.add(g.path);continue}if(w.kind==="delete"&&g.basePath!==void 0&&w.path===g.basePath){let S=h.get(g.path);if(S!==void 0&&S.kind==="change"&&(S.blobSha===g.blobSha||S.uid!==void 0&&S.uid===g.uid)){l.add(w);continue}}if(w.kind==="delete"&&w.path!==g.path&&w.path!==g.basePath&&!n.has(w.path)&&c?.has(w.path)!==!0){l.add(w);continue}T.push(w),l.add(w)}T.length>0&&(u.push({local:g,localIsDelete:I,remotes:T,desc:`${g.uid!==void 0&&!d.has(g.uid)?g.uid:g.path} (local ${I?"delete":"change"} vs remote ${T[0].kind} at ${T[0].path})`}),s.add(g.path))}let m=i.filter(g=>!l.has(g));return{conflicts:u,applyWrites:m.filter(g=>g.kind==="change"),applyDeletes:m.filter(g=>g.kind==="delete")}}async checkRaceWindow(e,t,n,i,s,o,c,l){try{let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(l.treeFilter),d=n===t.lastSyncedSha?t.files:(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(l.treeFilter),{changed:p,deleted:h}=_4(d,f);for(let m of p)s.has(m.path)&&c.push(`race-window: concurrent commit ${i} changed ${m.path} between conflict check (head ${n}) and push \u2014 local version won; previous version recoverable from git history`),o.has(m.path)&&c.push(`race-window: concurrent commit ${i} changed ${m.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let m of h)s.has(m.path)&&c.push(`race-window: concurrent commit ${i} deleted ${m.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);c.push(`race-window check failed: ${f(va(u))}`)}}async buildWatermarkFiles(e,t,n,i,s,o,c){if(c.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let l=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&l.set(f.blobSha,f.uid);for(let[f,d]of n){let p=o?.get(f)??await(0,ql.gitBlobSha)(d,this.sha1);l.set(p,typeof d=="string"?(0,So.extractAssetUid)(d):void 0)}for(let f of s.files)l.has(f.blobSha)||l.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(l.has(f.blobSha))d=l.get(f.blobSha);else{let p=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,So.extractAssetUid)(p)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};Sn.SyncEngine=iR});var E4=v(Mh=>{"use strict";Object.defineProperty(Mh,"__esModule",{value:!0});Mh.QuarantineResolver=void 0;Mh.backupPathFor=w4;var aie=Sb(),Pb=Xf(),Nh=Qf(),kh=Ph(),cie=Tb(),Eo="\0absent",sR=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let n of e)t.push(...await this.listRepoConflicts(n));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),n=t?.pinnedPaths??[];if(n.length===0)return[];if(this.deps.outbox!==void 0){let h=await this.deps.outbox.listForRepo(e.repoKey);if(h.length>0){let m=new Set(h.map(g=>g.path));if(n=n.filter(g=>!m.has(g)),n.length===0)return[]}}let i=new Map;for(let h of t?.files??[])i.set(h.path,h.blobSha);let s=this.deps.conflictCache!==void 0,o=await this.cachedRecordsFor(e,n),c=n.some(h=>!o.has(h)),l=new Map,u=!0;if(c)if(s)try{l=await this.remoteTreeShas(e)}catch{u=!1}else l=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),p=[];for(let h of n){let m=o.get(h),g,_;if(m!==void 0)_=m.remoteContent!==void 0?await(0,Nh.gitBlobSha)(m.remoteContent,this.deps.sha1):Eo,g=m.baseContent!==void 0?await(0,Nh.gitBlobSha)(m.baseContent,this.deps.sha1):i.get(h)??Eo;else{if(!u)continue;_=l.get(h)??Eo,g=i.get(h)??Eo}let b=Eo,T;if(d.has(h)&&(T=await f.read(h),b=await(0,Nh.gitBlobSha)(T,this.deps.sha1)),!(b!==_&&b!==g&&_!==g))continue;let w=(T!==void 0?(0,kh.extractAssetUid)(T):void 0)??m?.uid;p.push({repoKey:e.repoKey,path:h,...w!==void 0?{uid:w}:{},hasLocal:b!==Eo,hasRemote:_!==Eo})}return p}async cachedRecordsFor(e,t){let n=new Map,i=this.deps.conflictCache;if(i===void 0)return n;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&n.set(s,o)}return n}async detectDuplicateUids(e){let t=new Map;for(let i of e){let s=this.deps.localFilesFor(i);for(let o of await s.list()){if(!o.endsWith(".md"))continue;let c;try{c=await s.read(o)}catch{continue}let l=(0,kh.extractAssetUid)(c);l!==void 0&&t.set(l,(t.get(l)??0)+1)}}let n=0;for(let i of t.values())i>1&&n++;return n}async loadConflict(e,t){let n=this.deps.localFilesFor(e),s=new Set(await n.list()).has(t)?await n.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,c,l;if(o!==null)c=o.remoteContent,l=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);c=d!==void 0?await this.blobText(e,d):void 0;let h=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(m=>m.path===t)?.blobSha;if(h!==void 0)try{l=await this.blobText(e,h)}catch{l=void 0}}let u=(s!==void 0?(0,kh.extractAssetUid)(s):void 0)??(c!==void 0?(0,kh.extractAssetUid)(c):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:c!==void 0,...l!==void 0?{base:l}:{},...s!==void 0?{local:s}:{},...c!==void 0?{remote:c}:{}}}async resolve(e,t,n){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,c=this.deps.outbox!==void 0,{remote:l,remoteSha:u}=c?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(n,o,l),d;n.take!=="local"&&o!==void 0&&o!==f&&(d=w4(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let h=f===void 0&&l===void 0||f===l;if(c&&this.deps.outbox!==void 0&&!h&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:n.take==="merged"?"merged":"local",baseRemoteSha:u===Eo?cie.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:n.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let m;return h||(m=await this.commitChoice(e,t,f)),await this.snapWatermark(e,t,f),this.deps.quarantine?.markResolved!==void 0&&await this.deps.quarantine.markResolved(e.repoKey,t),{repoKey:e.repoKey,path:t,resolvedTo:n.take,...m!==void 0?{pushedSha:m}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let n=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(n!==null){let i=n.remoteContent,s=i!==void 0?await(0,Nh.gitBlobSha)(i,this.deps.sha1):Eo;return{remote:i,remoteSha:s}}return this.liveRemoteForResolve(e,t)}async liveRemoteForResolve(e,t){let i=(await this.remoteTreeShas(e)).get(t);return{remote:i!==void 0?await this.blobText(e,i):void 0,remoteSha:i??Eo}}chosenContent(e,t,n){switch(e.take){case"local":if(t===void 0)throw new Error("resolve: cannot keep local \u2014 no local version exists on disk");return t;case"remote":return n;case"merged":return e.content}}async commitChoice(e,t,n){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(n===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,aie.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,n]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,n){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(c=>c!==t),o=i.files;if(n===void 0)o=o.filter(c=>c.path!==t);else{let c=await(0,Nh.gitBlobSha)(n,this.deps.sha1),l=(0,kh.extractAssetUid)(n),u={path:t,blobSha:c,...l!==void 0?{uid:l}:{}},f=o.findIndex(d=>d.path===t);o=f>=0?o.map((d,p)=>p===f?u:d):[...o,u]}await this.deps.watermarkStore.set(e.repoKey,{...i,files:o,...s.length>0?{pinnedPaths:s}:{pinnedPaths:void 0}})}async remoteTreeShas(e){let t=await(0,Pb.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,Pb.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,Pb.getTree)(this.deps.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return s}async blobText(e,t){return(0,Pb.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};Mh.QuarantineResolver=sR;function w4(r){return`${r}.conflict.local.txt`}a(w4,"backupPathFor")});var v4=v(Zf=>{"use strict";Object.defineProperty(Zf,"__esModule",{value:!0});Zf.FileLocalManifestStore=Zf.LOCAL_MANIFEST_STORE_FILENAME=void 0;Zf.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function lie(r){if(r===null||typeof r!="object")return!1;let e=r;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(lie,"isLocalManifestRecord");var oR=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let n=(await this.readRepos())[e];return lie(n)?n:null}async set(e,t){let n=this.writeChain.then(async()=>{let i=await this.readRepos();i[e]=t;let s={version:1,repos:i};await this.io.writeAtomic(JSON.stringify(s))});return this.writeChain=n.catch(()=>{}),n}async readRepos(){try{let e=await this.io.read();if(e===null)return{};let t=JSON.parse(e);if(t===null||typeof t!="object")return{};let n=t.repos;return n===null||typeof n!="object"?{}:{...n}}catch{return{}}}};Zf.FileLocalManifestStore=oR});var lR=v(cR=>{"use strict";Object.defineProperty(cR,"__esModule",{value:!0});cR.diff3=uie;function T4(r,e){let t=r.length,n=e.length,i=Array.from({length:t+1},()=>new Int32Array(n+1));for(let l=t-1;l>=0;l--)for(let u=n-1;u>=0;u--)i[l][u]=r[l]===e[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);let s=new Map,o=0,c=0;for(;o<t&&c<n;)r[o]===e[c]?(s.set(o,c),o++,c++):i[o+1][c]>=i[o][c+1]?o++:c++;return s}a(T4,"lcsMatch");function aR(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}a(aR,"sliceEq");function uie(r,e,t){let n=T4(r,e),i=T4(r,t),s=[],o=0,c=0,l=0;for(;;){let u=o;for(;u<r.length&&!(n.has(u)&&i.has(u));)u++;let f=u<r.length?n.get(u):e.length,d=u<r.length?i.get(u):t.length,p=r.slice(o,u),h=e.slice(c,f),m=t.slice(l,d),g=!aR(h,p),_=!aR(m,p);if(!g&&!_)s.push(...p);else if(!g)s.push(...m);else if(!_)s.push(...h);else if(aR(h,m))s.push(...h);else return{ok:!1,conflict:{base:p,local:h,remote:m}};if(u>=r.length)break;s.push(r[u]),o=u+1,c=f+1,l=d+1}return{ok:!0,merged:s}}a(uie,"diff3")});var I4=v(Uh=>{"use strict";Object.defineProperty(Uh,"__esModule",{value:!0});Uh.StructuredMerger=void 0;Uh.splitSections=Db;var A4=lR(),fie=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,jh="exo__Instance_class";function $h(r){if(r===null||typeof r!="object")return!0;if(Array.isArray(r))return r.every($h);let e=Object.getPrototypeOf(r);return e!==Object.prototype&&e!==null?!1:Object.values(r).every($h)}a($h,"isPlainValue");function gc(r,e){if(r===e)return!0;if(r===null||e===null||r===void 0||e===void 0||typeof r!="object"||typeof e!="object"||Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)&&Array.isArray(e))return r.length!==e.length?!1:r.every((s,o)=>gc(s,e[o]));let t=r,n=e,i=Object.keys(t);return i.length!==Object.keys(n).length?!1:i.every(s=>gc(t[s],n[s]))}a(gc,"deepEqual");function Wl(r){return typeof r=="string"?`s:${r}`:`j:${JSON.stringify(r)}`}a(Wl,"setKey");function es(r){return r==null?[]:Array.isArray(r)?r:[r]}a(es,"toElements");function die(r,e,t){let n=new Set(es(r).map(Wl)),i=es(e),s=es(t),o=new Set(i.map(Wl)),c=new Set(s.map(Wl)),l=a(d=>o.has(d)&&c.has(d)||o.has(d)&&!n.has(d)||c.has(d)&&!n.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let p=Wl(d);f.has(p)||!l(p)||(f.add(p),u.push(d))}return u}a(die,"mergeSet");function pie(r,e,t){let n=[],i=[],s=new Set;for(let c of[...Object.keys(r),...Object.keys(e),...Object.keys(t)])s.has(c)||(s.add(c),i.push(c));let o={};for(let c of i){let l=r[c],u=e[c],f=t[c];if(!$h(l)||!$h(u)||!$h(f))return{ok:!1,reason:`frontmatter key "${c}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(l)||Array.isArray(u)||Array.isArray(f)){if(!(c in e)&&!(c in t))continue;let d=die(l,u,f),p=new Set(es(l).map(Wl)),h=es(u).some(g=>!p.has(Wl(g))),m=es(f).some(g=>!p.has(Wl(g)));h&&m&&!gc(es(u),es(f))&&n.push(`both sides added values to multi-valued key "${c}" \u2014 union kept (D20)`),d.length>0&&(o[c]=d);continue}if(gc(u,f)){u!==void 0&&(o[c]=u);continue}if(gc(u,l)){f!==void 0&&(o[c]=f);continue}if(gc(f,l)){u!==void 0&&(o[c]=u);continue}return{ok:!1,reason:`frontmatter key "${c}" changed differently on both sides`}}return{ok:!0,value:o,warnings:n}}a(pie,"mergeFrontmatter");var hie=/^(```|~~~)/,mie=/^#{1,6}\s/;function Db(r){let e=r.split(`
|
|
336
336
|
`),t=[],n=null,i="",s=!1,o=a(()=>{n!==null&&t.push({heading:i,text:n.join(`
|
|
337
337
|
`)})},"flush");for(let c of e){if(hie.test(c.trimStart())&&(s=!s),!s&&mie.test(c)){o(),n=[c],i=c.trim();continue}n===null&&(n=[],i=""),n.push(c)}return o(),t}a(Db,"splitSections");function uR(r){return r.split(/\n{2,}/)}a(uR,"splitParagraphs");function gie(r){return r.join(`
|
|
338
338
|
|
|
@@ -451,7 +451,7 @@ ${i}`;super(s,{path:t,violations:n},{message:"Fix the frontmatter so the asset s
|
|
|
451
451
|
}`),i=t.parse(n),o=new at.ExoQLAlgebraTranslator().translate(i);o=new at.AlgebraOptimizer().optimize(o);let u=await new at.ExoQLQueryExecutor(e).executeAll(o),f=new Set;for(let d of u){let p=d.toJSON(),h=p.s;if(typeof h=="string"){let g=bme(h);if(g){let _=zB(g);_&&f.add(_)}}let m=p.label;typeof m=="string"&&m.startsWith("https://exocortex.my/ontology/")&&f.add(m)}return f}function wme(r){let e=r.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!e)return null;try{return Ed(e[1],{schema:qC}),null}catch(t){return t instanceof Error?t.message.split(`
|
|
452
452
|
`)[0]:String(t)}}function Eme(r,e,t){let n=[],i;try{i=(0,xo.readFileSync)(r,"utf-8")}catch{return[]}let s=wme(i);s&&n.push({file:e,property:"(frontmatter)",reason:`Unparseable YAML frontmatter (${s}) \u2014 invisible to SPARQL/preconditions; repair with: exocortex repair-frontmatter "${e}"`});let o=WB(i);if(!o)return n;let c=Object.keys(o),{toValidate:l,unknownPrefix:u}=yme(c);for(let f of u)n.push({file:e,property:f,reason:`Unknown namespace prefix in "${f}"`});for(let f of l){let d=zB(f);d&&!t.has(d)&&n.push({file:e,property:f,reason:`Property "${f}" is not declared in the ontology`})}return n}function YB(r){let e=r.indexOf("__");if(e===-1)return null;let t=r.slice(0,e+2),n=r.slice(0,e),i=r.slice(e+2);if(!i)return null;let s=fO.get(t);return s?s+i:/^[a-z][a-zA-Z0-9]*$/.test(n)&&!/[\s()]/.test(i)?`https://exocortex.my/ontology/${n}#${i}`:null}function Ime(r){let e=decodeURIComponent(r),t=e.lastIndexOf("/");if(t===-1)return null;let n=e.slice(t+1),i=n.endsWith(".md")?n.slice(0,-3):n;return YB(i)}function Rme(r){let e=a(n=>{if(n instanceof at.DomainIRI)return{type:"iri",value:n.value};if(n instanceof at.DomainLiteral){let i={type:"literal",value:n.value};return n.datatype&&(i.datatype=n.datatype.value),n.language&&(i.language=n.language),i}return null},"mapNode"),t=[];for(let n of r){let i=e(n.subject),s=e(n.predicate),o=e(n.object);i&&s&&o&&t.push({subject:i,predicate:s,object:o})}return t}function xme(r){return Cme.has(r)?"earl:cantTell":"earl:failed"}function QB(r,e){let t=`file://${r}`,n="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":n,"dc:title":"Exocortex CLI SHACL-lite Validator"},{"@type":"earl:TestSubject","@id":t,"dc:title":r}];if(e.violations.length===0)s.push({"@type":"earl:Assertion","earl:assertedBy":{"@id":n},"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":n},"earl:subject":{"@id":t},"earl:test":{"@id":o.propertyPath},"earl:result":{"@type":"earl:TestResult","earl:outcome":{"@id":xme(o.severity)},"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}}function dO(r,e){let t=new Set(r.filter(i=>i.predicate instanceof at.DomainIRI&&i.predicate.value===Ome).map(i=>i.subject instanceof at.DomainIRI?i.subject.value:null).filter(i=>i!==null));if(t.size===0)return e;let n=e.violations.filter(i=>!t.has(i.focusNode));return{conforms:n.every(i=>i.severity!=="sh:Violation"),violations:n}}async function pO(r,e){let t=new at.InMemoryTripleStore;await t.addAll(e);let n=new at.ShaclShapeRegistry((await at.ShapeLoader.loadFromRDFGraph(t)).getAll()),i=new uO(e),s=Rme(e);return(0,at.shaclValidate)(s,n,i)}function hO(r,e){let t="obsidian://vault/",n=r.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:n.every(i=>i.severity!=="sh:Violation"),violations:n}}function Pme(r,e){if(e==="earl"){let t=QB(r,{conforms:!0,violations:[]});console.log(JSON.stringify(t,null,2))}else if(e==="json"){let t=pt.success({vaultPath:r,conforms:!0,violationCount:0,violations:[]});console.log(JSON.stringify(t,null,2))}else console.log("\u2705 No staged .md files to validate.")}async function Dme(r,e={}){let t=r.format||"text",n=e.getStagedMdFiles??KB;try{let i=(0,La.resolve)(r.vault);if(!(0,xo.existsSync)(i))throw new ke(i);let s=null;if(r.staged){let _=n(i);if(_.length===0){Pme(i,t);return}s=new Set(_)}t==="text"&&console.log(`\u{1F4E6} Loading vault (shapes-mode): ${i}...`);let{triples:o,cacheHit:c}=await qB(i,!!r.useCache);t==="text"&&c&&console.log("\u{1F680} Cache hit! Loading from persistent cache..."),t==="text"&&(console.log(`\u2705 Loaded ${o.length} triples`),console.log("\u{1F50D} Running SHACL-lite validation..."));let l=await pO(i,o),u=Fme(l,o,s),f=a(_=>_,"qualifyNode"),d=u.violations.filter(_=>_.severity==="sh:Violation"),p=u.violations.filter(_=>_.severity!=="sh:Violation"),h=p.filter(_=>_.constraint==="class").length,m=p.filter(_=>_.constraint==="term-iri-collision").length,g=new Set(p.filter(_=>_.constraint==="term-iri-collision").map(_=>_.actualValue??""));if(t==="earl"){let _=QB(i,u);console.log(JSON.stringify(_,null,2))}else if(t==="json"){let _=a(T=>({...T,vaultQualifiedPath:f(T.focusNode)}),"annotate"),b=pt.success({vaultPath:i,conforms:u.conforms,violationCount:d.length,warningCount:p.length,crossVaultRefWarnings:h,termIriCollisionWarnings:m,violations:d.map(_),warnings:p.map(_)});console.log(JSON.stringify(b,null,2))}else{if(d.length>0){let _=new Map;for(let b of d){let T=_.get(b.focusNode)??[];T.push(b),_.set(b.focusNode,T)}console.log(`\u26A0\uFE0F Found ${d.length} SHACL violation(s) in ${_.size} node(s):
|
|
453
453
|
`);for(let[b,T]of _){console.log(` \u274C ${b}`);for(let I of T){let w=I.severity.replace("sh:","");console.log(` [${w}] ${I.message}`)}}}else console.log("\u2705 Vault conforms to all shapes (no violations).");if(p.length>0&&(console.log(`
|
|
454
|
-
\u2139\uFE0F ${p.length} warning(s)`+(h>0?` (${h} unresolvable class/symbolic ref(s) \u2014 not validated)`:"")+" \u2014 these do not affect the exit code."),m>0)){console.log(` \u26A0\uFE0F ${g.size} term-IRI collision(s) \u2014 one IRI emitted by several assets (${m} entr${m===1?"y":"ies"}):`);for(let _ of[...g].sort())console.log(` \u2022 ${_}`);console.log(" Run with --format json for the emitting assets.")}}u.conforms||(process.exitCode=1)}catch(i){ce.handle(i)}}function Fme(r,e,t){let n=BB(e),i=n.length>0?{...r,violations:[...r.violations,...n]}:r,s=dO(e,i);return t&&(s=hO(s,t)),s}function XB(){return new
|
|
454
|
+
\u2139\uFE0F ${p.length} warning(s)`+(h>0?` (${h} unresolvable class/symbolic ref(s) \u2014 not validated)`:"")+" \u2014 these do not affect the exit code."),m>0)){console.log(` \u26A0\uFE0F ${g.size} term-IRI collision(s) \u2014 one IRI emitted by several assets (${m} entr${m===1?"y":"ies"}):`);for(let _ of[...g].sort())console.log(` \u2022 ${_}`);console.log(" Run with --format json for the emitting assets.")}}u.conforms||(process.exitCode=1)}catch(i){ce.handle(i)}}function Fme(r,e,t){let n=BB(e),i=n.length>0?{...r,violations:[...r.violations,...n]}:r,s=dO(e,i);return t&&(s=hO(s,t)),s}function XB(){return new de("schema").description("Check frontmatter properties against ontology (Issue #2713)").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)").option("--use-cache","Use persistent triple cache (faster vault loading)").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 r=>{let e=r.output||"text";if(ce.setFormat(e),r.shapesMode){await Dme(r);return}try{let t=(0,La.resolve)(r.vault);if(!(0,xo.existsSync)(t))throw new ke(t);let n;if(r.staged){if(n=KB(t),n.length===0){if(e==="json"){let f=pt.success({vaultPath:t,filesChecked:0,violations:[],healthy:!0});console.log(JSON.stringify(f,null,2))}else console.log("\u2705 No staged .md files to validate.");return}}else n=_me(t);if(r.class){let f=r.class;n=n.filter(d=>{try{let p=(0,xo.readFileSync)((0,La.resolve)(t,d),"utf-8"),h=WB(p);return mme(h,f)}catch{return!1}})}e==="text"&&console.log(`\u{1F4E6} Loading vault: ${t}...`);let{triples:i,cacheHit:s}=await qB(t,!!r.useCache),o=i;e==="text"&&s&&console.log("\u{1F680} Cache hit! Loading from persistent cache..."),e==="text"&&(console.log(`\u2705 Loaded ${o.length} triples`),console.log("\u{1F50D} Querying ontology for declared properties..."));let c=await Sme(o);e==="text"&&(console.log(`\u{1F4CB} Found ${c.size} declared properties in ontology`),console.log(`\u{1F50D} Validating ${n.length} file(s)...
|
|
455
455
|
`));let l=[];for(let f of n){let d=(0,La.resolve)(t,f),p=Eme(d,f,c);l.push(...p)}let u={vaultPath:t,filesChecked:n.length,violations:l,healthy:l.length===0};if(e==="json"){let f=pt.success(u);console.log(JSON.stringify(f,null,2))}else if(l.length===0)console.log(`\u2705 All ${n.length} file(s) pass schema validation.`);else{let f=new Map;for(let d of l){let p=f.get(d.file)||[];p.push(d),f.set(d.file,p)}console.log(`\u26A0\uFE0F Found ${l.length} schema violation(s) in ${f.size} file(s):
|
|
456
456
|
`);for(let[d,p]of f){console.log(` \u274C ${d}`);for(let h of p)console.log(` \u2022 ${h.reason}`)}console.log(`
|
|
457
457
|
\u{1F4DD} To fix these issues:`),console.log(" - Remove undeclared properties from frontmatter"),console.log(" - Or declare them in the ontology as Property instances")}l.length>0&&(process.exitCode=1)}catch(t){ce.handle(t)}})}var xo,La,GB,at,hme,fO,gme,vme,Tme,Ame,uO,Cme,Ome,mO=qe(()=>{"use strict";ct();xo=require("fs"),La=require("path"),GB=require("child_process");bm();at=ne(We());Vi();Rt();VB();Bt();wr();Nd();lw();hme=new Set(["aliases","archived","tags","cssclasses","publish","permalink","description","image","cover","banner","title","share","share_link","share_updated","metadata","uri"]),fO=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#"],["exoql__","https://exocortex.my/ontology/exoql#"],["query__","https://exocortex.my/ontology/query#"],["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#"],["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#"],["xsd__","http://www.w3.org/2001/XMLSchema#"],["sh__","http://www.w3.org/ns/shacl#"]]);a(mme,"frontmatterMatchesClass");a(qB,"loadTriplesFromAllVaults");gme="http://www.w3.org/1999/02/22-rdf-syntax-ns#type";a(WB,"extractFrontmatter");a(HB,"hasKnownPrefix");a(zB,"keyToURI");a(yme,"classifyKeys");a(KB,"getStagedMdFiles");a(_me,"collectMdFiles");a(bme,"extractPropertyNameFromURI");a(Sme,"loadDeclaredProperties");a(wme,"detectUnparseableFrontmatter");a(Eme,"validateFile");vme="http://www.w3.org/2000/01/rdf-schema#subClassOf",Tme="https://exocortex.my/ontology/exo#Class_superClass",Ame="http://www.w3.org/2000/01/rdf-schema#label";a(YB,"labelToOntologyIRI");a(Ime,"fileIriToOntologyURIFromFilename");a(Rme,"domainToAlgebraTriples");uO=class{constructor(e){this.subClassMap=new Map;let t=new Map,n=new Set,i=a(o=>o===vme||o===Tme,"isSubClassPredicate");for(let o of e)o.predicate instanceof at.DomainIRI&&i(o.predicate.value)&&o.subject instanceof at.DomainIRI&&o.object instanceof at.DomainIRI&&(n.add(o.subject.value),n.add(o.object.value));for(let o of e)if(o.predicate instanceof at.DomainIRI&&o.predicate.value===Ame&&o.subject instanceof at.DomainIRI&&o.object instanceof at.DomainLiteral){let c=YB(o.object.value);c&&t.set(o.subject.value,c)}for(let o of n)if(!t.has(o)){let c=Ime(o);c&&t.set(o,c)}for(let[o,c]of t){let l=this.subClassMap.get(o)??new Set;l.add(c),this.subClassMap.set(o,l)}for(let o of e)if(o.predicate instanceof at.DomainIRI&&i(o.predicate.value)&&o.subject instanceof at.DomainIRI&&o.object instanceof at.DomainIRI){let c=o.subject.value,l=o.object.value,u=this.subClassMap.get(c)??new Set;u.add(l),this.subClassMap.set(c,u);let f=t.get(c),d=l.startsWith("obsidian://")?t.get(l):l;if(f&&d){let p=this.subClassMap.get(f)??new Set;p.add(d),this.subClassMap.set(f,p)}}let s=e.filter(o=>o.predicate instanceof at.DomainIRI&&o.predicate.value===gme&&o.subject instanceof at.DomainIRI&&o.object instanceof at.DomainIRI);for(let o of s){let c=o.subject.value,l=o.object.value,u=this.collectAncestors(l);for(let d of u){if(c===d)continue;let p=this.subClassMap.get(c)??new Set;p.add(d),this.subClassMap.set(c,p)}let f=t.get(c);if(f)for(let d of u){let p=d.startsWith("obsidian://")?t.get(d):d;if(!p||f===p)continue;let h=this.subClassMap.get(f)??new Set;h.add(p),this.subClassMap.set(f,h)}}}static{a(this,"TripleClassHierarchy")}collectAncestors(e){let t=new Set,n=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(n.has(s))continue;n.add(s);let o=this.subClassMap.get(s);if(o)for(let c of o)c!==e&&(t.add(c),n.has(c)||i.push(c))}return t}isSubClassOf(e,t){let n=new Set,i=[e];for(;i.length>0;){let s=i.shift();if(s===t)return!0;if(n.has(s))continue;n.add(s);let o=this.subClassMap.get(s);if(o)for(let c of o)i.push(c)}return!1}},Cme=new Set(["sh:Warning","sh:Info"]);a(xme,"earlOutcomeFor");a(QB,"buildEARLReport");Ome="https://exocortex.my/ontology/exo#Asset_legacyValidationException";a(dO,"applyLegacyExceptionFilter");a(pO,"runShapesValidation");a(hO,"filterReportToStagedFocusNodes");a(Pme,"emitEmptyStagedShapesResult");a(Dme,"runShapesModeAction");a(Fme,"assembleShapesReport");a(XB,"validateSchemaCommand")});var b6={};Ig(b6,{CandidateShaclValidator:()=>TO});function zme(r){let e=r.match(/^https:\/\/exocortex\.my\/ontology\/([A-Za-z][A-Za-z0-9_]*)#(.+)$/);return e?`${e[1]}__${e[2]}`:r}function Kme(r){let e=(0,Qm.basename)(r);return{path:r,basename:(0,Qm.basename)(r,(0,Qm.extname)(r)),name:e,parent:null}}function Yme(r){let e=r.match(Hme);return e?(0,Tw.parseYamlFrontmatterTolerant)(e[1]):null}var Qm,Tw,Hme,TO,S6=qe(()=>{"use strict";Qm=require("path"),Tw=ne(We());Vi();mO();Hme=/^---\n([\s\S]*?)\n---/,TO=class{constructor(e){this.vaultPath=e}static{a(this,"CandidateShaclValidator")}async validateCandidate(e,t){let n=new Ut(this.vaultPath),i=new Tw.NoteToRDFConverter(n),s=Kme(e),o=Yme(t),c=o?i.validateExocortexAsset(o,s.basename):null;if(c)return{violations:[{propertyPath:c.property,propertyIri:c.property,constraint:c.code,message:`${c.message} \u2014 the asset would be SKIPPED by the indexer (no triples emitted), making it invisible to every query, layout and graph relation.`}],warnings:[]};let l=await i.convertVault(),u;try{u=await i.convertNoteFromFrontmatter(s,o)}catch(_){return{violations:[{propertyPath:e,propertyIri:e,constraint:"indexability",message:`The asset could not be converted to RDF (${_ instanceof Error?_.message:String(_)}) \u2014 the indexer would SKIP it, making it invisible to every query, layout and graph relation.`}],warnings:[]}}let f=[...l,...u],d=await pO(this.vaultPath,f),p=dO(f,d),h=hO(p,new Set([e])),m=[],g=[];for(let _ of h.violations){let b={propertyPath:zme(_.propertyPath),propertyIri:_.propertyPath,constraint:String(_.constraint),message:_.message,..._.actualValue!==void 0?{actualValue:_.actualValue}:{},..._.expectedRange!==void 0?{expectedRange:_.expectedRange}:{}};_.severity==="sh:Violation"?m.push(b):g.push(b)}return{violations:m,warnings:g}}};a(zme,"iriToFrontmatterKey");a(Kme,"syntheticFile");a(Yme,"extractFrontmatter")});var k6=v(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.createPathBasedTargetResolver=Ks;An.createCreateRelatedTaskService=vge;An.createCreateRelatedProjectService=Tge;An.createCreateAssetService=Age;An.createArchiveAssetService=Ige;An.createCleanPropertiesService=Rge;An.createFixMissingLabelService=Cge;An.createRenameToUidService=xge;An.createRepairFolderService=Pge;An.createPlanForEveningService=Dge;An.createUpdatePropertyService=Fge;An.createRemovePropertyService=Lge;An.createSetStatusService=Nge;An.createDuplicateAssetService=kge;An.rewriteFrontmatterScalars=N6;var tg=We();function Ks(r){return{resolveFile(e){let t=(0,tg.iriToVaultPath)(e)??e,n=t.endsWith(".md")?t:`${t}.md`,i=r.getAbstractFileByPath(n);if(!i||!("basename"in i))throw new Error(`Cannot resolve target file for IRI: ${e}`);return i}}}a(Ks,"createPathBasedTargetResolver");var xO=a(()=>null,"NULL_CLASS_RESOLVER");function Ow(r){return r.startsWith('"[[')&&r.endsWith(']]"')?r:r.startsWith("[[")&&r.endsWith("]]")?`"${r}"`:`"[[${r}]]"`}a(Ow,"toQuotedWikilink");function vge(r,e,t=Ks(r),n,i=xO){return{async execute(s,o){let c=o?.label;if(!c)throw new Error("createRelatedTask requires userInput.label");let l=t.resolveFile(s),u=r.getFrontmatter(l)??{},f=l.parent?.path||"",d={ems__Effort_status:'"[[c42245d0-01de-4c35-bfcf-d910445ea28e]]"'},p=o?.parentProperty;p&&l.basename&&(d[p]=`"[[${l.basename}]]"`);let h=await e.createAsset({className:"ems__Task",label:c,folderPath:f,propertyValues:d,parentFile:l,parentMetadata:u,classResolver:i});n&&await n(h)}}}a(vge,"createCreateRelatedTaskService");function Tge(r,e,t=Ks(r),n,i=xO){return{async execute(s,o){let c=o?.label;if(!c)throw new Error("createRelatedProject requires userInput.label");let l=t.resolveFile(s),u=r.getFrontmatter(l)??{},f=l.parent?.path||"",d={ems__Effort_status:'"[[c42245d0-01de-4c35-bfcf-d910445ea28e]]"'},p=o?.parentProperty;p&&l.basename&&(d[p]=`"[[${l.basename}]]"`);let h=await e.createAsset({className:"ems__Project",label:c,folderPath:f,propertyValues:d,parentFile:l,parentMetadata:u,classResolver:i});n&&await n(h)}}}a(Tge,"createCreateRelatedProjectService");function Age(r,e,t=xO,n=Ks(r)){return{async execute(i,s){let o=s?.prototypeUID??s?.prototype,c=s?.label,l=s?.folder,u=s?.ownerIdentity,f=s?.isDefinedBy;if(!o)throw new Error("createAsset requires userInput.prototypeUID");if(!c)throw new Error("createAsset requires userInput.label");let d,p;if(i)try{let S=n.resolveFile(i);d=S.path,p=r.getFrontmatter(S)??void 0}catch{}if(!l&&d){let S=d.lastIndexOf("/");l=S>=0?d.substring(0,S):""}if(l===void 0)throw new Error("createAsset requires userInput.folder");let h=o.endsWith("Prototype")?o.slice(0,-9):o,m=crypto.randomUUID(),g=tg.DateFormatter.toISOTimestamp(new Date),_=`${m}.md`,b=l?`${l}/${_}`:_,T=["---",`exo__Asset_uid: ${m}`,`exo__Asset_createdAt: ${g}`,`exo__Asset_label: ${c}`,`exo__Asset_prototype: "[[${o}]]"`,"exo__Instance_class:",` - "[[${h}]]"`],I=!1;if(f&&(T.push(`exo__Asset_isDefinedBy: ${Ow(f)}`),I=!0),p){let S=p.exo__Instance_class,L=(Array.isArray(S)?S:S!=null?[S]:[]).some(M=>tg.WikiLinkHelpers.resolveSymbolic(String(M),t).includes("Area")),P=d?d.substring(d.lastIndexOf("/")+1).replace(/\.md$/,""):void 0;if(P){let M=L?"ems__Effort_area":"ems__Effort_parent";T.push(`${M}: "[[${P}]]"`)}!L&&p.ems__Effort_area&&T.push(`ems__Effort_area: ${Ow(String(p.ems__Effort_area))}`),T.push('ems__Effort_status: "[[753a44d5-846c-4b82-9196-4fd9a4d48777]]"'),!I&&p.exo__Asset_isDefinedBy&&(T.push(`exo__Asset_isDefinedBy: ${Ow(String(p.exo__Asset_isDefinedBy))}`),I=!0)}!I&&u&&T.push(`exo__Asset_isDefinedBy: ${Ow(u)}`),T.push("---","");let w=T.join(`
|
|
@@ -541,7 +541,7 @@ LIMIT 30`,parameters:[],examples:{}}],nw=class{static{a(this,"TemplateRegistry")
|
|
|
541
541
|
`),s=i.length,o=Math.max(1,e-t),c=Math.min(s,e+t),l=[];for(let u=o;u<=c;u++)l.push({number:u,content:i[u-1],isError:u===e});return{startLine:o,endLine:c,errorLine:e,errorColumn:n,lines:l}}a(Dhe,"getQueryContext");function Fhe(r){let e=/PREFIX\s+(\w+):\s*</gi,t=[],n;for(;(n=e.exec(r))!==null;)t.push(n[1]);return t}a(Fhe,"extractDeclaredPrefixes");function Lhe(r){let e=[/unknown prefix[:\s]+['"]?(\w+)['"]?/i,/prefix\s+['"]?(\w+)['"]?\s+not\s+defined/i,/undefined\s+prefix[:\s]+['"]?(\w+)['"]?/i];for(let t of e){let n=r.match(t);if(n)return n[1]}return null}a(Lhe,"extractUnknownPrefix");function Nhe(r){let e=[/line\s+(\d+),?\s*column\s+(\d+)/i,/line\s+(\d+):(\d+)/i,/at\s+(\d+):(\d+)/i,/\((\d+),\s*(\d+)\)/];for(let n of e){let i=r.match(n);if(i)return{line:parseInt(i[1],10),column:parseInt(i[2],10)}}let t=r.match(/line\s+(\d+)/i);return t?{line:parseInt(t[1],10)}:{}}a(Nhe,"extractPosition");function khe(r){let e=[/timeout[^\d]*(\d+)\s*ms/i,/timeout[^\d]*(\d+)\s*milliseconds/i,/(\d+)\s*ms\s*timeout/i,/exceeded[^\d]*(\d+)\s*ms/i];for(let t of e){let n=r.match(t);if(n)return parseInt(n[1],10)}return null}a(khe,"extractTimeoutDuration");var iw=class{constructor(){this.wellKnownPrefixes={rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",xsd:"http://www.w3.org/2001/XMLSchema#",owl:"http://www.w3.org/2002/07/owl#",ems:"http://exocortex.local/ems#",exo:"http://exocortex.local/exo#",ims:"http://exocortex.local/ims#"}}static{a(this,"SPARQLErrorEnhancer")}classifyError(e){let t=e.message.toLowerCase();return t.includes("unknown prefix")||t.includes("prefix")&&(t.includes("not defined")||t.includes("undefined"))?"unknown_prefix":t.includes("parse error")||t.includes("syntax error")||t.includes("unexpected")||t.includes("expected")?"syntax":t.includes("timeout")||t.includes("timed out")||t.includes("exceeded")?"timeout":t.includes("econnrefused")||t.includes("connection refused")||t.includes("network")||t.includes("connect")?"connection":"unknown"}enhanceError(e,t){switch(this.classifyError(e)){case"unknown_prefix":return this.enhanceUnknownPrefixError(e,t);case"syntax":return this.enhanceSyntaxError(e,t);case"timeout":return this.enhanceTimeoutError(e,t);case"connection":return this.enhanceConnectionError(e,t);default:return this.enhanceUnknownError(e,t)}}enhanceUnknownPrefixError(e,t){let n=Lhe(e.message),i=Fhe(t),s=[...new Set([...i,...Object.keys(this.wellKnownPrefixes)])],o,c=[];if(n){let l=Phe(n,s);l.length>0?(o=`Unknown prefix '${n}'. Did you mean: ${l.join(", ")}?`,c.push(`Replace '${n}:' with '${l[0]}:'`)):o=`Unknown prefix '${n}'.`;let u=i.length>0?i.join(", "):Object.keys(this.wellKnownPrefixes).join(", ");o+=`
|
|
542
542
|
|
|
543
543
|
Available prefixes: ${u}`,this.wellKnownPrefixes[n]&&c.push(`Add: PREFIX ${n}: <${this.wellKnownPrefixes[n]}>`)}else o=e.message;return{type:"unknown_prefix",message:o,originalMessage:e.message,originalStack:e.stack,suggestions:c.length>0?c:void 0}}enhanceSyntaxError(e,t){let n=e,i=n.line!==void 0?{line:n.line,column:n.column}:Nhe(e.message),s,o;i.line?(s=`Syntax error at line ${i.line}`,i.column&&(s+=`, column ${i.column}`),s+=`: ${e.message.replace(/.*line\s+\d+.*?:\s*/i,"")}`,o=Dhe(t,i.line,2,i.column)):s=`Syntax error: ${e.message}`;let c=this.generateSyntaxSuggestions(e.message);return{type:"syntax",message:s,originalMessage:e.message,originalStack:e.stack,suggestions:c.length>0?c:void 0,context:o,line:i.line,column:i.column}}generateSyntaxSuggestions(e){let t=[],n=e.toLowerCase();return(n.includes("where")||n.includes("expected"))&&t.push("Ensure your query has a WHERE clause: SELECT ?s WHERE { ... }"),(n.includes("{")||n.includes("}")||n.includes("brace")||n.includes("bracket"))&&t.push("Check that all braces { } are properly balanced"),(n.includes("variable")||n.includes("?"))&&t.push("Variables must start with '?' (e.g., ?subject, ?predicate, ?object)"),(n.includes("end of input")||n.includes("eof"))&&t.push("Query may be incomplete - check for missing closing braces or statements"),n.includes("prefix")&&t.push("Add PREFIX declarations at the start of your query"),t.length===0&&t.push("Check SPARQL syntax reference: https://www.w3.org/TR/sparql11-query/"),t}enhanceTimeoutError(e,t){let n=khe(e.message),i=n?Math.round(n/1e3):null,s;i?s=`Query timed out after ${i} second${i!==1?"s":""}`:s="Query timed out";let o=["Try limiting results with LIMIT (e.g., LIMIT 100)","Add more specific FILTER conditions to reduce result set","Use more selective triple patterns","Consider using OPTIONAL sparingly (it can be expensive)"];return/\bLIMIT\b/i.test(t)||o.unshift("Add LIMIT clause to restrict result count"),/SELECT\s+\*/i.test(t)&&o.push("Replace SELECT * with specific variables to reduce data transfer"),{type:"timeout",message:s,originalMessage:e.message,originalStack:e.stack,suggestions:o}}enhanceConnectionError(e,t){let n="Connection failed to SPARQL endpoint",i=["Check that the SPARQL endpoint is running","Verify network connectivity","Check firewall settings"];return{type:"connection",message:n,originalMessage:e.message,originalStack:e.stack,suggestions:i}}enhanceUnknownError(e,t){return{type:"unknown",message:e.message,originalMessage:e.message,originalStack:e.stack,suggestions:["Check query syntax and try again"]}}formatForText(e){let t=[];if(t.push(`\u274C ${e.message}`),e.context){t.push(""),t.push("Context:");for(let n of e.context.lines){let i=n.isError?">>> ":" ";if(t.push(`${i}${n.number.toString().padStart(3)}: ${n.content}`),n.isError&&e.context.errorColumn){let s=" ".repeat(8+n.number.toString().length+e.context.errorColumn-1)+"^";t.push(s)}}}if(e.suggestions&&e.suggestions.length>0){t.push(""),t.push("Suggestions:");for(let n of e.suggestions)t.push(` \u2022 ${n}`)}return t.join(`
|
|
544
|
-
`)}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 sw=class r{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}>`:`"${r.escapeString(e)}"`}};var uu=require("fs"),sO=require("path");function ow(r){let e=new Map,t="obsidian://vault/",n;try{n=(0,uu.readdirSync)(r)}catch{return e}for(let i of n){let s=(0,sO.join)(r,i);if(i.startsWith("."))continue;let o;try{o=(0,uu.statSync)(s)}catch{continue}if(!o.isDirectory())continue;let c;try{c=(0,uu.readdirSync)(s)}catch{continue}for(let l of c){let u=(0,sO.join)(s,l);if(l.startsWith("."))continue;let f;try{f=(0,uu.statSync)(u)}catch{continue}if(!f.isDirectory())continue;let d=!1;try{d=(0,uu.readdirSync)(u).some(h=>h.endsWith(".md"))}catch{continue}if(d){let p=`${i}/${l}`,h=encodeURI(p),m=`${t}${h}/`;/^[a-zA-Z][a-zA-Z0-9_]*$/.test(l)&&e.set(l,m)}}}return e}a(ow,"scanVaultNamespaces");lw();var Uhe=300,IB=3e4,Bhe="EXOCORTEX_SPARQL_TIMEOUT";function Vhe(){let r=process.env[Bhe];if(!r)return IB;try{let e=Ghe(r);if(e!==null&&e>0)return e}catch{}return IB}a(Vhe,"getDefaultTimeout");function Ghe(r){let e=r.trim().toLowerCase();if(!e)return null;if(e.endsWith("ms")){let n=parseInt(e.slice(0,-2),10);return isNaN(n)||n<=0?null:n}if(e.endsWith("s")){let n=parseInt(e.slice(0,-1),10);return isNaN(n)||n<=0?null:n*1e3}let t=parseInt(e,10);return isNaN(t)||t<=0?null:t*1e3}a(Ghe,"parseTimeoutSafe");function qhe(r){if(!r)return Uhe;let e=parseInt(r.trim(),10);if(isNaN(e)||e<=0)throw new Ke(`Invalid cache TTL: "${r}". Must be a positive number (seconds).`,'exocortex query --cache-ttl 600 "SELECT * WHERE { ?s ?p ?o }"');return e}a(qhe,"parseCacheTtl");function Whe(r){let e=r.trim().toLowerCase();if(e.endsWith("ms")){let n=parseInt(e.slice(0,-2),10);if(isNaN(n)||n<=0)throw new Ke(`Invalid timeout format: "${r}". Value must be a positive number.`,'exocortex query --timeout "30s" or --timeout "5000ms"');return n}if(e.endsWith("s")){let n=parseInt(e.slice(0,-1),10);if(isNaN(n)||n<=0)throw new Ke(`Invalid timeout format: "${r}". Value must be a positive number.`,'exocortex query --timeout "30s" or --timeout "5000ms"');return n*1e3}let t=parseInt(e,10);if(isNaN(t)||t<=0)throw new Ke(`Invalid timeout format: "${r}". Use formats like "30s", "5000ms", or just a number (seconds).`,'exocortex query --timeout "30s" or --timeout "5000ms"');return t*1e3}a(Whe,"parseTimeout");async function oO(r,e,t=Date.now()){let n,i=new Promise((s,o)=>{n=setTimeout(()=>{let c=Date.now()-t;o(new jm(e,c))},e),n&&typeof n=="object"&&"unref"in n&&n.unref()});return Promise.race([r,i])}a(oO,"executeWithTimeout");function CB(){return new
|
|
544
|
+
`)}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 sw=class r{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}>`:`"${r.escapeString(e)}"`}};var uu=require("fs"),sO=require("path");function ow(r){let e=new Map,t="obsidian://vault/",n;try{n=(0,uu.readdirSync)(r)}catch{return e}for(let i of n){let s=(0,sO.join)(r,i);if(i.startsWith("."))continue;let o;try{o=(0,uu.statSync)(s)}catch{continue}if(!o.isDirectory())continue;let c;try{c=(0,uu.readdirSync)(s)}catch{continue}for(let l of c){let u=(0,sO.join)(s,l);if(l.startsWith("."))continue;let f;try{f=(0,uu.statSync)(u)}catch{continue}if(!f.isDirectory())continue;let d=!1;try{d=(0,uu.readdirSync)(u).some(h=>h.endsWith(".md"))}catch{continue}if(d){let p=`${i}/${l}`,h=encodeURI(p),m=`${t}${h}/`;/^[a-zA-Z][a-zA-Z0-9_]*$/.test(l)&&e.set(l,m)}}}return e}a(ow,"scanVaultNamespaces");lw();var Uhe=300,IB=3e4,Bhe="EXOCORTEX_SPARQL_TIMEOUT";function Vhe(){let r=process.env[Bhe];if(!r)return IB;try{let e=Ghe(r);if(e!==null&&e>0)return e}catch{}return IB}a(Vhe,"getDefaultTimeout");function Ghe(r){let e=r.trim().toLowerCase();if(!e)return null;if(e.endsWith("ms")){let n=parseInt(e.slice(0,-2),10);return isNaN(n)||n<=0?null:n}if(e.endsWith("s")){let n=parseInt(e.slice(0,-1),10);return isNaN(n)||n<=0?null:n*1e3}let t=parseInt(e,10);return isNaN(t)||t<=0?null:t*1e3}a(Ghe,"parseTimeoutSafe");function qhe(r){if(!r)return Uhe;let e=parseInt(r.trim(),10);if(isNaN(e)||e<=0)throw new Ke(`Invalid cache TTL: "${r}". Must be a positive number (seconds).`,'exocortex query --cache-ttl 600 "SELECT * WHERE { ?s ?p ?o }"');return e}a(qhe,"parseCacheTtl");function Whe(r){let e=r.trim().toLowerCase();if(e.endsWith("ms")){let n=parseInt(e.slice(0,-2),10);if(isNaN(n)||n<=0)throw new Ke(`Invalid timeout format: "${r}". Value must be a positive number.`,'exocortex query --timeout "30s" or --timeout "5000ms"');return n}if(e.endsWith("s")){let n=parseInt(e.slice(0,-1),10);if(isNaN(n)||n<=0)throw new Ke(`Invalid timeout format: "${r}". Value must be a positive number.`,'exocortex query --timeout "30s" or --timeout "5000ms"');return n*1e3}let t=parseInt(e,10);if(isNaN(t)||t<=0)throw new Ke(`Invalid timeout format: "${r}". Use formats like "30s", "5000ms", or just a number (seconds).`,'exocortex query --timeout "30s" or --timeout "5000ms"');return t*1e3}a(Whe,"parseTimeout");async function oO(r,e,t=Date.now()){let n,i=new Promise((s,o)=>{n=setTimeout(()=>{let c=Date.now()-t;o(new jm(e,c))},e),n&&typeof n=="object"&&"unref"in n&&n.unref()});return Promise.race([r,i])}a(oO,"executeWithTimeout");function CB(){return new de("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("--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("--strict","Fail on unresolved label-form wikilinks in property paths (sets EXOCORTEX_SPARQL_STRICT=1, Issue #3282)").action(async(r,e)=>{let t=e.output||"text";ce.setFormat(t);let n=process.env.EXOCORTEX_SPARQL_STRICT;e.strict&&(process.env.EXOCORTEX_SPARQL_STRICT="1");let i="";try{let s=Date.now(),o=e.timeout?Whe(e.timeout):Vhe(),c=qhe(e.cacheTtl),l=e.cache!==!1;if(e.template){let O=new nw,F=e.param?O.parseParamString(e.param):{};if(i=O.applyTemplate(e.template,F),t==="text"){let Z=O.getTemplate(e.template);console.log(`\u{1F4CB} Using template: ${e.template}`),Object.keys(F).length>0&&console.log(` Parameters: ${Object.entries(F).map(([J,U])=>`${J}=${U}`).join(", ")}`),console.log()}}else if(r)i=Hhe(r);else throw new Ke("Either a query argument or --template flag is required.",'exocortex query "SELECT * WHERE { ?s ?p ?o }" or exocortex query --template tasks-by-date --param date=2024-01-15');let u=i;if(e.dryRun){await zhe(i,e,t);return}let f=(0,aO.resolve)(e.vault),d=l?await XU(f):null;if(l){let F=await new Fa().get(u,c,d);if(F!==null){let Z=Date.now()-s;if(t==="json"){let J=pt.success(F,{durationMs:Z,itemCount:F.count||0,queryResultCacheHit:!0});console.log(JSON.stringify(J,null,2))}else{console.log(`\u{1F4E6} (cached) Query result loaded from cache in ${Z}ms
|
|
545
545
|
`);let J=F;J.type==="select"&&J.bindings?(console.log(`\u2705 Found ${J.bindings.length} result(s)
|
|
546
546
|
`),Qhe(J.bindings,e.format)):J.type==="construct"&&J.triples&&(console.log(`\u2705 Generated ${J.triples.length} triple(s)
|
|
547
547
|
`),Xhe(J.triples,e.format))}return}}if(!(0,Ym.existsSync)(f))throw new ke(f);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${f}...`);let p=Date.now(),h=e.useCache??!1,m=[],g=!1;if(h){let F=await new is(f).loadOrBuild();m=F.triples,g=F.cacheHit,t==="text"&&g&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let O=new Ut(f);m=await new Er.NoteToRDFConverter(O).convertVault()}let _=new Er.InMemoryTripleStore;await _.addAll(m);let b=Date.now()-p;if(t==="text"){let O=g?" (from cache)":"";console.log(`\u2705 Loaded ${m.length} triples in ${b}ms${O}
|
|
@@ -551,20 +551,20 @@ Available prefixes: ${u}`,this.wellKnownPrefixes[n]&&c.push(`Add: PREFIX ${n}: <
|
|
|
551
551
|
\u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${b}ms${g?" (from cache)":""}`),console.log(` Query execution: ${F}ms`),console.log(` Total time: ${Z}ms`),console.log(` Triples scanned: ${m.length}`),console.log(` Triples generated: ${O.length}`),e.useCache&&console.log(` Triple cache: ${g?"HIT":"MISS (rebuilt)"}`),l&&console.log(" Query result cache: MISS (cached for next run)"))}else{M?.start();let O=await oO(P.executeAll(R),o,L),F=Date.now()-L;M?.stop();let Z=Date.now()-s,J=O.map(U=>U.toJSON());if(l){let U={type:"select",count:O.length,bindings:J};await new Fa().set(u,U,c,d)}if(t==="json"){let U={query:i,count:O.length,bindings:J},K=pt.success(U,{durationMs:Z,itemCount:O.length,loadDurationMs:b,execDurationMs:F,triplesScanned:m.length,cacheHit:g,queryResultCacheHit:!1});console.log(JSON.stringify(K,null,2))}else console.log(`\u2705 Found ${O.length} result(s) in ${F}ms
|
|
552
552
|
`),O.length>0?Khe(O,e.format):console.log("No results found."),e.stats&&(console.log(`
|
|
553
553
|
\u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${b}ms${g?" (from cache)":""}`),console.log(` Query execution: ${F}ms`),console.log(` Total time: ${Z}ms`),console.log(` Triples scanned: ${m.length}`),console.log(` Results returned: ${O.length}`),e.useCache&&console.log(` Triple cache: ${g?"HIT":"MISS (rebuilt)"}`),l&&console.log(" Query result cache: MISS (cached for next run)"))}}catch(s){xB(s,i,t)}finally{e.strict&&(n===void 0?delete process.env.EXOCORTEX_SPARQL_STRICT:process.env.EXOCORTEX_SPARQL_STRICT=n)}})}a(CB,"sparqlQueryCommand");function xB(r,e,t){let n=new iw;if(n.classifyError(r)!=="unknown"){let s=n.enhanceError(r,e);if(t==="json"){let o=pt.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(n.formatForText(s)),process.exit(2)}ce.handle(r)}a(xB,"handleSparqlError");function Hhe(r){if(r.includes("SELECT")||r.includes("CONSTRUCT")||r.includes("INSERT")||r.includes("DELETE"))return r;let e=(0,aO.resolve)(r);return(0,Ym.existsSync)(e)?(0,Ym.readFileSync)(e,"utf-8"):r}a(Hhe,"loadQuery");async function zhe(r,e,t){if(e.explain){let i=new tw,s=await i.analyze(r,{includeAlgebraPlan:!0,optimize:!e.noOptimize});if(t==="json"){let o=pt.success(s);console.log(JSON.stringify(o,null,2))}else s.valid?(console.log(`\u2705 Query syntax is valid
|
|
554
|
-
`),console.log(i.formatAnalysis(s,"text"))):(console.log(i.formatAnalysis(s,"text")),process.exit(2));return}let n=new Er.ExoQLParser;try{let i=n.parse(r);if(i.type!=="update"){let o=new Er.ExoQLAlgebraTranslator().translate(i);if(!e.noOptimize&&o.type!=="construct")o=new Er.AlgebraOptimizer().optimize(o);else if(!e.noOptimize&&o.type==="construct"){let c=new Er.AlgebraOptimizer,l=o;o={...l,where:c.optimize(l.where)}}}if(t==="json"){let s=pt.success({valid:!0,queryType:RB(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: ${RB(i)}`)}catch(i){xB(i,r,t)}}a(zhe,"executeDryRun");function RB(r){return r.type==="update"?"UPDATE":"queryType"in r?r.queryType:"UNKNOWN"}a(RB,"getQueryType");function Khe(r,e){switch(e){case"json":let t=new BS;console.log(t.format(r));break;case"csv":let n=new VS;console.log(n.format(r));break;default:let i=new Fd;console.log(i.format(r));break}}a(Khe,"formatSelectResults");function Yhe(r,e){let t=new Ld;switch(e){case"json":console.log(t.formatJson(r));break;case"ntriples":console.log(t.formatNTriples(r));break;default:console.log(t.formatTable(r));break}}a(Yhe,"formatConstructResults");function Qhe(r,e){switch(e){case"json":console.log(JSON.stringify(r,null,2));break;case"csv":if(r.length===0){console.log("");return}let t=Object.keys(r[0]);console.log(t.join(","));for(let i of r){let s=t.map(o=>{let c=i[o];return c==null?"":String(c).includes(",")?`"${c}"`:String(c)});console.log(s.join(","))}break;default:if(r.length===0){console.log("No results.");return}let n=Object.keys(r[0]);console.log(n.join(" ")),console.log(n.map(()=>"---").join(" "));for(let i of r){let s=n.map(o=>String(i[o]??""));console.log(s.join(" "))}break}}a(Qhe,"formatCachedSelectResults");function Xhe(r,e){switch(e){case"json":console.log(JSON.stringify(r,null,2));break;case"ntriples":for(let t of r)console.log(`<${t.subject}> <${t.predicate}> ${Jhe(t.object)} .`);break;default:console.log("Subject Predicate Object"),console.log("--- --- ---");for(let t of r)console.log(`${t.subject} ${t.predicate} ${t.object}`);break}}a(Xhe,"formatCachedConstructResults");function Jhe(r){return sw.formatObject(r)}a(Jhe,"formatNTriplesObject");function Zhe(r,e){for(let t of r){let n=[`${t.type.toUpperCase()}`];switch(t.inserted!==void 0&&n.push(`inserted: ${t.inserted}`),t.deleted!==void 0&&n.push(`deleted: ${t.deleted}`),n.push(t.success?"OK":"FAILED"),e){case"json":console.log(JSON.stringify(t,null,2));break;case"csv":r.indexOf(t)===0&&console.log("type,inserted,deleted,success"),console.log(`${t.type},${t.inserted??""},${t.deleted??""},${t.success}`);break;default:console.log(`\u2705 ${n.join(" | ")}`);break}}}a(Zhe,"formatUpdateResults");ct();var OB=require("fs"),PB=require("path"),Co=ne(We());Nd();Rt();Bt();wr();function DB(){return new
|
|
554
|
+
`),console.log(i.formatAnalysis(s,"text"))):(console.log(i.formatAnalysis(s,"text")),process.exit(2));return}let n=new Er.ExoQLParser;try{let i=n.parse(r);if(i.type!=="update"){let o=new Er.ExoQLAlgebraTranslator().translate(i);if(!e.noOptimize&&o.type!=="construct")o=new Er.AlgebraOptimizer().optimize(o);else if(!e.noOptimize&&o.type==="construct"){let c=new Er.AlgebraOptimizer,l=o;o={...l,where:c.optimize(l.where)}}}if(t==="json"){let s=pt.success({valid:!0,queryType:RB(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: ${RB(i)}`)}catch(i){xB(i,r,t)}}a(zhe,"executeDryRun");function RB(r){return r.type==="update"?"UPDATE":"queryType"in r?r.queryType:"UNKNOWN"}a(RB,"getQueryType");function Khe(r,e){switch(e){case"json":let t=new BS;console.log(t.format(r));break;case"csv":let n=new VS;console.log(n.format(r));break;default:let i=new Fd;console.log(i.format(r));break}}a(Khe,"formatSelectResults");function Yhe(r,e){let t=new Ld;switch(e){case"json":console.log(t.formatJson(r));break;case"ntriples":console.log(t.formatNTriples(r));break;default:console.log(t.formatTable(r));break}}a(Yhe,"formatConstructResults");function Qhe(r,e){switch(e){case"json":console.log(JSON.stringify(r,null,2));break;case"csv":if(r.length===0){console.log("");return}let t=Object.keys(r[0]);console.log(t.join(","));for(let i of r){let s=t.map(o=>{let c=i[o];return c==null?"":String(c).includes(",")?`"${c}"`:String(c)});console.log(s.join(","))}break;default:if(r.length===0){console.log("No results.");return}let n=Object.keys(r[0]);console.log(n.join(" ")),console.log(n.map(()=>"---").join(" "));for(let i of r){let s=n.map(o=>String(i[o]??""));console.log(s.join(" "))}break}}a(Qhe,"formatCachedSelectResults");function Xhe(r,e){switch(e){case"json":console.log(JSON.stringify(r,null,2));break;case"ntriples":for(let t of r)console.log(`<${t.subject}> <${t.predicate}> ${Jhe(t.object)} .`);break;default:console.log("Subject Predicate Object"),console.log("--- --- ---");for(let t of r)console.log(`${t.subject} ${t.predicate} ${t.object}`);break}}a(Xhe,"formatCachedConstructResults");function Jhe(r){return sw.formatObject(r)}a(Jhe,"formatNTriplesObject");function Zhe(r,e){for(let t of r){let n=[`${t.type.toUpperCase()}`];switch(t.inserted!==void 0&&n.push(`inserted: ${t.inserted}`),t.deleted!==void 0&&n.push(`deleted: ${t.deleted}`),n.push(t.success?"OK":"FAILED"),e){case"json":console.log(JSON.stringify(t,null,2));break;case"csv":r.indexOf(t)===0&&console.log("type,inserted,deleted,success"),console.log(`${t.type},${t.inserted??""},${t.deleted??""},${t.success}`);break;default:console.log(`\u2705 ${n.join(" | ")}`);break}}}a(Zhe,"formatUpdateResults");ct();var OB=require("fs"),PB=require("path"),Co=ne(We());Nd();Rt();Bt();wr();function DB(){return new de("index").description("Build or refresh the triple cache for faster SPARQL queries").option("--vault <path>","Path to Obsidian vault",process.cwd()).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 r=>{let e=r.output||"text";ce.setFormat(e);try{let t=(0,PB.resolve)(r.vault);if(!(0,OB.existsSync)(t))throw new ke(t);let n=new is(t),i=n.getCachePath();r.force&&(e==="text"&&console.log("\u{1F5D1}\uFE0F Invalidating existing cache..."),await n.invalidate()),e==="text"&&console.log(`\u{1F4E6} Building triple cache for: ${t}...`);let s=Date.now(),o=await n.buildCacheWithValidation({strict:r.strict??!1}),c=0;if(r.inference!==!1){let{triples:u}=await n.loadOrBuild(),f=new Co.InMemoryTripleStore;await f.addAll(u),c=await new Co.RDFSInferenceEngine().materialize(f);let p=new Co.NonInheritablePropertyRegistry;await p.initialize(f);let h=new Co.PropertyCardinalityRegistry;await h.initialize(f);let g=await new Co.PrototypeChainMaterializer(p,h).materialize(f);if(c+=g,c>0){let _=await f.match();await n.saveTriples(_),o.tripleCount+=c}e==="text"&&c>0&&console.log(`\u{1F9E0} Materialized ${c} inferred triples (RDFS + prototype chain)`)}let l=Date.now()-s;if(e==="json"){let u={action:"build",cachePath:i,tripleCount:o.tripleCount,durationMs:o.durationMs},f={summary:o.summary,skippedFiles:o.skippedFiles};if(r.stats){let d=await n.getCacheStats();if(d){let p={tripleCount:d.tripleCount,createdAt:d.createdAt.toISOString(),isValid:d.isValid,sizeBytes:d.sizeBytes,cachePath:i},h=pt.success({cache:u,stats:p,validation:f},{durationMs:l});console.log(JSON.stringify(h,null,2))}}else{let d=pt.success({cache:u,validation:f},{durationMs:l});console.log(JSON.stringify(d,null,2))}}else{if(o.skippedFiles.length>0){console.log(`
|
|
555
555
|
\u26A0\uFE0F Files skipped due to IRI issues:`);for(let u of o.skippedFiles)console.log(` - ${u.path}`),console.log(` ${u.reason}`);console.log("")}if(console.log(`\u2705 Indexed ${o.summary.indexed} files, skipped ${o.summary.skipped} (total: ${o.summary.total})`),console.log(`\u{1F4CA} Created cache with ${o.tripleCount.toLocaleString()} triples at ${i}`),console.log(`\u23F1\uFE0F Build time: ${o.durationMs}ms`),r.stats){let u=await n.getCacheStats();u&&(console.log(`
|
|
556
|
-
\u{1F4CA} Cache Statistics:`),console.log(` Triples: ${u.tripleCount.toLocaleString()}`),console.log(` Created: ${u.createdAt.toISOString()}`),console.log(` Valid: ${u.isValid?"\u2705 Yes":"\u274C No"}`),console.log(` Size: ${eme(u.sizeBytes)}`))}}}catch(t){ce.handle(t)}})}a(DB,"sparqlIndexCommand");function eme(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}a(eme,"formatBytes");ct();var uw=require("fs"),qs=require("path");Rt();Bt();wr();gr();function FB(){return new
|
|
556
|
+
\u{1F4CA} Cache Statistics:`),console.log(` Triples: ${u.tripleCount.toLocaleString()}`),console.log(` Created: ${u.createdAt.toISOString()}`),console.log(` Valid: ${u.isValid?"\u2705 Yes":"\u274C No"}`),console.log(` Size: ${eme(u.sizeBytes)}`))}}}catch(t){ce.handle(t)}})}a(DB,"sparqlIndexCommand");function eme(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}a(eme,"formatBytes");ct();var uw=require("fs"),qs=require("path");Rt();Bt();wr();gr();function FB(){return new de("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(r,e)=>{let t=e.output||"text";ce.setFormat(t);try{let n=Date.now();if(!tme(r))throw new Ke(`Invalid UUID format: ${r}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:r});let i=(0,qs.resolve)(e.vault);if(!(0,uw.existsSync)(i))throw new ke(i);let s=rme(i,r,e.partial??!1),o=Date.now()-n;if(s.length===0){if(t==="json"){let c=pt.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${r}`,3,{context:{uuid:r}});console.log(JSON.stringify(c,null,2))}else console.error(`UUID not found: ${r}`);process.exit(1)}e.partial||s.length>1?ime(s,i,e.format,t,r,o):nme(s[0],i,e.format,t,r,o)}catch(n){ce.handle(n)}})}a(FB,"resolveCommand");function tme(r){if(r.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(r)||t.test(r)}a(tme,"isValidUuidFormat");function rme(r,e,t){let n=[],i=e.toLowerCase();function s(o){let c=(0,uw.readdirSync)(o,{withFileTypes:!0});for(let l of c){let u=(0,qs.join)(o,l.name);if(l.isDirectory())!l.name.startsWith(".")&&l.name!=="node_modules"&&s(u);else if(l.isFile()&&l.name.endsWith(".md")){let f=l.name.toLowerCase();t?f.includes(i)&&n.push(u):(f.startsWith(i+".md")||f.startsWith(i+" ")||f.startsWith(i+"-"))&&n.push(u)}}}return a(s,"walk"),s(r),n}a(rme,"findFilesWithUuid");function LB(r){return`obsidian://vault/${encodeURI(r)}`}a(LB,"pathToObsidianUri");function NB(r){let e=r.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,qs.basename)(r,".md")}a(NB,"extractUuidFromFilename");function nme(r,e,t,n,i,s){let o=(0,qs.relative)(e,r),c=LB(o),l=NB((0,qs.basename)(r));if(n==="json"){let u={uuid:l,path:o,absolutePath:r,uri:c},f=pt.success(u,{durationMs:s,searchUuid:i});console.log(JSON.stringify(f,null,2))}else switch(t){case"path":console.log(r);break;case"json":console.log(JSON.stringify({uuid:l,path:o,absolutePath:r,uri:c},null,2));break;default:console.log(c);break}}a(nme,"outputSingleResult");function ime(r,e,t,n,i,s){let o=r.map(c=>{let l=(0,qs.relative)(e,c),u=LB(l);return{uuid:NB((0,qs.basename)(c)),path:l,absolutePath:c,uri:u}});if(n==="json"){let c=pt.success({matches:o,count:o.length},{durationMs:s,searchUuid:i,itemCount:o.length});console.log(JSON.stringify(c,null,2))}else switch(t){case"path":for(let c of o)console.log(c.absolutePath);break;case"json":console.log(JSON.stringify(o,null,2));break;default:for(let c of o)console.log(c.uri);break}}a(ime,"outputMultipleResults");ct();var cO=require("fs"),Ws=require("path"),vr=ne(We());Rt();Bt();gr();Vi();var kB=ne(We());function fw(r,e){return t=>{let n=typeof t.filePath=="string"&&t.filePath.length>0?t.filePath:null;if(n===null||n.split("/").includes("09 Templates"))return!1;let i=r.getAbstractFileByPath(n);if(i===null||!("basename"in i))return!1;let s=i,o=r.getFrontmatter(s)??{},c=e.getExpectedFolderSync(s,o),l=typeof t.currentFolder=="string"?t.currentFolder:s.parent?.path??"";return(0,kB.needsFolderRepair)(l,c)}}a(fw,"createIsInWrongFolderHostFunction");var MB=ne(We());function dw(r){return e=>{let t=typeof e.filePath=="string"&&e.filePath.length>0?e.filePath:null;if(t===null||t.split("/").includes("09 Templates"))return!1;let n=r.getAbstractFileByPath(t);if(n===null||!("basename"in n))return!1;let i=n,s=r.getFrontmatter(i)??{};return(0,MB.hasEmptyProperties)(s)}}a(dw,"createHasEmptyPropertiesHostFunction");var hw={debug(r,e){process.env.EXOCORTEX_DEBUG&&pw("debug",r,e)},info(r,e){pw("info",r,e)},warn(r,e){pw("warn",r,e)},error(r,e,t){pw("error",e?`${r} \u2014 ${e.message}`:r,t)}};function pw(r,e,t){let n=t&&Object.keys(t).length>0?` ${sme(t)}`:"";process.stderr.write(`[${r}] ${e}${n}
|
|
557
557
|
`)}a(pw,"write");function sme(r){try{return JSON.stringify(r)}catch{return"[uninspectable context]"}}a(sme,"safeJson");var ome=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function jB(r){let e=Array.isArray(r)?r[0]:r;if(typeof e!="string")return null;let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n!==-1&&(t=t.slice(0,n).trim()),t.length>0?t:null}a(jB,"cleanRef");function ame(r){if(!r)return[];let e=r.exo__Instance_class,t=[],n=a(i=>{let s=jB(i);s&&!t.includes(s)&&t.push(s)},"collect");if(typeof e=="string")n(e);else if(Array.isArray(e))for(let i of e)n(i);return t}a(ame,"extractClasses");function cme(r){let e=r.match(/\/ontology\/([^#/]+)#(.+)$/);return e?`${e[1]}__${e[2]}`:null}a(cme,"ontologyIriToSymbolic");async function lme(r,e){let t=await r.match(new vr.IRI(e),vr.Namespace.EXO.term("Instance_class"),void 0),n=[];for(let i of t){let s=typeof i.object.value=="string"?i.object.value:String(i.object),o=cme(s);o&&!n.includes(o)&&n.push(o)}return n}a(lme,"deriveStoreSymbolicClasses");async function ume(r){let e=new vr.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),t=await r.match(void 0,e,void 0),n=new Map;for(let i of t){let s=typeof i.subject.value=="string"?i.subject.value:String(i.subject),o=typeof i.object.value=="string"?i.object.value:String(i.object),c=s.match(ome);c&&o.length>0&&n.set(c[1],o)}return n}a(ume,"buildCliNameMap");async function fme(r,e,t=(0,vr.liveClock)()){let n=(0,Ws.resolve)(r);if(!(0,cO.existsSync)(n))throw new ke(n);let i=(0,Ws.resolve)(n,e);if(!(0,cO.existsSync)(i))throw new Error(`Target file not found: ${e}`);let s=(0,Ws.relative)(n,i);if(s===".."||s.startsWith(`..${Ws.sep}`)||(0,Ws.isAbsolute)(s))throw new Error(`Target is outside the vault: ${e} (vault: ${n})`);let o=new Ut(n),l=await new vr.NoteToRDFConverter(o).convertVault(),u=new vr.InMemoryTripleStore;await u.addAll(l);let f=(0,vr.vaultPathToIRI)(s),d=o.getAbstractFileByPath(s),p=d!==null&&"basename"in d?d:null,h=p?o.getFrontmatter(p):null,m=ame(h),g=await lme(u,f),_=[...new Set([...m,...g])],b=jB(h?.exo__Asset_prototype),T=h?.exo__Asset_uid,I=typeof T=="string"?T:void 0,S=await new vr.CommandResolver(u,hw).resolveForAssetMulti(f,_,b??void 0),R=new vr.FolderRepairService(o),L=new vr.PreconditionEvaluator(u,void 0,{clock:t});(0,vr.registerDefaultHostFunctions)(L),L.registerHostFunction("isInWrongFolder",fw(o,R)),L.registerHostFunction("hasObsoleteProperties",dw(o));let P=(0,Ws.dirname)(s),M={targetIRI:f,filePath:s,fileBasename:p?.basename,currentFolder:P==="."?"":P,assetUid:I},O=await ume(u),F=await Promise.all(S.map(async K=>{let _e;try{_e=await L.evaluate(K.command.precondition,f,M)}catch{_e=!1}return{rc:K,available:_e}})),Z=a(K=>({id:K.command.id,label:K.command.name,cliName:O.get(K.command.id)??null,category:K.command.category??null}),"toEntry"),J=F.filter(K=>K.available).map(K=>Z(K.rc)),U=F.filter(K=>!K.available).map(K=>({...Z(K.rc),reason:"precondition-false"}));return{target:s,classes:_,prototype:b,visible:J,hidden:U}}a(fme,"resolveButtons");function dme(r,e){let t=a(n=>`${n.label}${n.cliName?` (${n.cliName})`:""}`,"fmt");if(console.log(`Command buttons on "${r.target}" (${r.visible.length} visible):`),r.visible.length===0)console.log(" (none)");else for(let n of r.visible)console.log(` \u2713 ${t(n)}`);if(e)if(console.log(`
|
|
558
|
-
Hidden by precondition (${r.hidden.length}):`),r.hidden.length===0)console.log(" (none)");else for(let n of r.hidden)console.log(` \u2717 ${t(n)} \u2014 precondition not satisfied`)}a(dme,"printHuman");function $B(){return new fe("resolve-inline-buttons").alias("resolve-buttons").description("Print the actual command button-set for an asset \u2014 binding-match \u2229 precondition-eval (Issue #3833). The authoritative button-visibility oracle; strictly more complete than `apply --dry-run` (precondition-only).").argument("<target>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--json","Emit structured JSON instead of human-readable text").option("--show-hidden","Also list commands that bind but are hidden by their precondition").action(async(r,e)=>{ce.setFormat(e.json?"json":"text");try{let t=await fme(e.vault,r);if(e.json){let n=e.showHidden?t:{...t,hidden:[]};console.log(JSON.stringify(n,null,2))}else dme(t,e.showHidden??!1)}catch(t){ce.handle(t),process.exit(5)}})}a($B,"resolveButtonsCommand");ct();var lO=require("fs"),Hs=require("path"),Lc=ne(We());Rt();Bt();gr();Vi();var mw=class{constructor(e){this.vault=e}static{a(this,"FsVaultMetadataAdapter")}*listFrontmatter(){for(let e of this.vault.getAllFiles()){let t=this.vault.getFrontmatter(e);t&&(yield t)}}resolveLinkpathFrontmatter(e){let t={allowAliasFallback:!1},n=this.vault.getFirstLinkpathDest(e,"",t);return!n&&!e.endsWith(".md")&&(n=this.vault.getFirstLinkpathDest(`${e}.md`,"",t)),n?this.vault.getFrontmatter(n)??{}:null}};async function pme(r,e){let t=(0,Hs.resolve)(r);if(!(0,lO.existsSync)(t))throw new ke(t);let n=(0,Hs.resolve)(t,e);if(!(0,lO.existsSync)(n))throw new Error(`Target file not found: ${e}`);let i=(0,Hs.relative)(t,n);if(i===".."||i.startsWith(`..${Hs.sep}`)||(0,Hs.isAbsolute)(i))throw new Error(`Target is outside the vault: ${e} (vault: ${t})`);let s=new Ut(t),o=new mw(s),c=new Lc.PrintNameRuleService(o,(0,Lc.createDisplayMatcherHostFunctions)(o));c.initialize();let l=new Lc.DisplayNameResolver(Lc.DEFAULT_DISPLAY_NAME_SETTINGS,c,c.createMetadataResolver()),u=s.getAbstractFileByPath(i),f=u!==null&&"basename"in u?u:null,d=(f?s.getFrontmatter(f):null)??{},p=(0,Hs.basename)(i).replace(/\.md$/,""),h=l.resolveWithProvenance({metadata:d,basename:p}),m=h.displayName??p,g=d.exo__Asset_label,_=typeof g=="string"&&g.trim().length>0,b=h.displayName===null?"basename":h.provenance==="default"?_?"label":"basename":h.provenance,T=d.exo__Asset_uid;return{target:i,uid:typeof T=="string"&&T.trim()?T.trim():null,basename:p,displayName:m,source:b}}a(pme,"resolveDisplayName");function UB(){return new fe("resolve-display-name").description("Print the composed display name an asset renders as \u2014 the same engine the plugin runs, over the same vault exo__DisplayNameSpec assets (req f17f7c57). The authoritative naming oracle outside Obsidian; --json adds `source`, which distinguishes a spec-composed name from a raw exo__Asset_label.").argument("<target>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--json","Emit structured JSON instead of the bare name").action(async(r,e)=>{ce.setFormat(e.json?"json":"text");try{let t=await pme(e.vault,r);e.json?console.log(JSON.stringify(t,null,2)):console.log(t.displayName)}catch(t){ce.handle(t),process.exit(5)}})}a(UB,"resolveDisplayNameCommand");ct();mO();ct();var gw=require("fs"),JB=require("path"),Nc=ne(We());var Tr=ne(Ca()),Oi=ne(require("path"));Rx();var Na=ne(We());var li=class{constructor(e){this.rootPath=e}static{a(this,"NodeFsAdapter")}async readFile(e){let t=this.resolvePath(e);if(!await Tr.default.pathExists(t))throw new Na.FileNotFoundError(e);return Tr.default.readFile(t,"utf-8")}async fileExists(e){let t=this.resolvePath(e);return Tr.default.pathExists(t)}async getFileMetadata(e){let t=await this.readFile(e);return this.extractFrontmatter(t)}async createFile(e,t){let n=this.resolvePath(e);if(await Tr.default.pathExists(n))throw new Na.FileAlreadyExistsError(e);return await Tr.default.ensureDir(Oi.default.dirname(n)),await Tr.default.writeFile(n,t,"utf-8"),e}async updateFile(e,t){let n=this.resolvePath(e);if(!await Tr.default.pathExists(n))throw new Na.FileNotFoundError(e);await Tr.default.writeFile(n,t,"utf-8")}async writeFile(e,t){let n=this.resolvePath(e);await Tr.default.ensureDir(Oi.default.dirname(n)),await Tr.default.writeFile(n,t,"utf-8")}async deleteFile(e){let t=this.resolvePath(e);if(!await Tr.default.pathExists(t))throw new Na.FileNotFoundError(e);await Tr.default.remove(t)}async renameFile(e,t){let n=this.resolvePath(e),i=this.resolvePath(t);if(!await Tr.default.pathExists(n))throw new Na.FileNotFoundError(e);await Tr.default.ensureDir(Oi.default.dirname(i)),await Tr.default.move(n,i)}async createDirectory(e){let t=this.resolvePath(e);await Tr.default.ensureDir(t)}async directoryExists(e){let t=this.resolvePath(e);return await Tr.default.pathExists(t)?(await Tr.default.stat(t)).isDirectory():!1}async getMarkdownFiles(e){let t=e?this.resolvePath(e):this.rootPath,n=Oi.default.join(t,"**/*.md");return(await Dd(n,{nodir:!0})).map(o=>Oi.default.relative(this.rootPath,o))}async findFilesByMetadata(e){let t=await this.getMarkdownFiles(),n=[];for(let i of t)try{let s=await this.getFileMetadata(i);this.matchesQuery(s,e)&&n.push(i)}catch{continue}return n}async findFileByUID(e){let t=await this.findFilesByMetadata({exo__Asset_uid:e});return t.length>0?t[0]:null}async findFileByLinkpath(e){let t=e.trim();if(t.length===0)return null;let n=await this.findFileByBasename(`${t}.md`);if(n)return n;let i=await this.getMarkdownFiles();for(let s of i){let o;try{o=await this.getFileMetadata(s)}catch{continue}if(o.exo__Asset_label===t)return s;let c=o.aliases;if(Array.isArray(c)&&c.some(l=>l===t)||typeof c=="string"&&c===t)return s}return null}async findFileByBasename(e){let t=a(async n=>{let i;try{i=await Tr.default.readdir(n,{withFileTypes:!0})}catch{return null}for(let s of i){let o=Oi.default.join(n,s.name);if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;let c=await t(o);if(c)return c}else if(s.isFile()&&s.name===e)return Oi.default.relative(this.rootPath,o)}return null},"walk");return t(this.rootPath)}async findFileByUidFilename(e){let t=e.toLowerCase(),n=a(async i=>{let s;try{s=await Tr.default.readdir(i,{withFileTypes:!0})}catch{return null}for(let o of s){let c=Oi.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules")continue;let l=await n(c);if(l)return l}else if(o.isFile()&&o.name.endsWith(".md")){let l=o.name.toLowerCase();if(l.startsWith(t+".md")||l.startsWith(t+" ")||l.startsWith(t+"-"))return Oi.default.relative(this.rootPath,c)}}return null},"walk");return n(this.rootPath)}resolvePath(e){if(Oi.default.isAbsolute(e))return e;let t=this.rootPath.replace(/[/\\]+$/,""),n=Oi.default.sep+e;return n===t||n.startsWith(t+Oi.default.sep)?n:Oi.default.join(this.rootPath,e)}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,n=e.match(t);return n?(0,Na.parseYamlFrontmatterTolerant)(n[1])??{}:{}}matchesQuery(e,t){for(let[n,i]of Object.entries(t)){let s=e[n];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 Tn=class r extends li{constructor(t,n){super(t);this.indexed=!1;this.uidToPath=new Map;this.basenameToPaths=new Map;this.allPaths=[];this.pathSet=new Set;this.assets=[];this.cacheContent=n?.cacheContent??!1}static{a(this,"CachingNodeFsAdapter")}async buildIndex(){if(this.indexed)return;let t=await super.getMarkdownFiles();for(let n of t){this.allPaths.push(n),this.pathSet.add(n);let i={},s;try{this.cacheContent?(s=await super.readFile(n),i=this.extractFrontmatter(s)):i=await super.getFileMetadata(n)}catch{i={}}let o=i?.exo__Asset_uid,c=Array.isArray(o)?o:[o];for(let f of c){let d=r.normalizeUid(f);d.length>0&&!this.uidToPath.has(d)&&this.uidToPath.set(d,n)}let l=r.basenameOf(n),u=this.basenameToPaths.get(l);u?u.push(n):this.basenameToPaths.set(l,[n]),this.assets.push(this.cacheContent?{path:n,metadata:i,content:s}:{path:n,metadata:i})}this.indexed=!0}async findPathsByBasename(t){return await this.buildIndex(),this.basenameToPaths.get(t)??[]}async hasIndexedPath(t){await this.buildIndex();let n=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(n)}static basenameOf(t){let n=t.lastIndexOf("/"),i=n===-1?t:t.slice(n+1);return i.endsWith(".md")?i.slice(0,-3):i}async indexedAssets(){return await this.buildIndex(),this.assets}async getMarkdownFiles(t){return t?super.getMarkdownFiles(t):(await this.buildIndex(),this.allPaths)}async findFileByUID(t){return await this.buildIndex(),this.uidToPath.get(r.normalizeUid(t))??null}static normalizeUid(t){return t==null?"":String(t).replace(/["'[\]]/g,"").trim()}async fileExists(t){await this.buildIndex();let n=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(n)?!0:super.fileExists(t)}};Rt();Bt();var gO=class{constructor(e){this.vaultPath=e}static{a(this,"CliFsCheckReader")}async read(){return{assets:(await new Tn(this.vaultPath).indexedAssets()).map(i=>({path:i.path,frontmatter:i.metadata}))}}};function ZB(){return new fe("vault").description("Run the homoiconic vault-integrity check-runner (enabled-set from validation-check setting__Setting instances; --all runs every check)").requiredOption("--vault <path>","Vault root directory").option("--all","Run ALL known checks, ignoring the vault enabled-set").option("--output <type>","Response format: text|json","text").action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=(0,JB.resolve)(r.vault);if(!(0,gw.existsSync)(t)||!(0,gw.statSync)(t).isDirectory())throw new ke(t);let i=await new gO(t).read(),s=r.all?[...Nc.KNOWN_CHECK_IDS]:(0,Nc.readEnabledCheckIds)(i.assets),o=await new Nc.VaultCheckRunner((0,Nc.createDefaultCheckRegistry)()).runWithContext(i,s);if(e==="json")console.log(JSON.stringify({vaultPath:t,...o},null,2));else{s.length===0&&console.log(`OK ${t}: no validation checks enabled (scaffold validation-settings to enable some, or pass --all)`);for(let c of o.results){let l=`${c.status==="pass"?"OK":c.status==="fail"?"FAIL":"ERROR"} ${c.label}`;if(c.status==="pass")console.log(`${l} (${i.assets.length} assets)`);else if(c.status==="error")console.error(`${l}: ${c.errorMessage}`);else{console.error(`${l}: ${c.findings.length} violation(s)`);for(let u of c.findings.slice(0,50))console.error(` ${u.path?u.path+" \u2014 ":""}${u.message}`);c.findings.length>50&&console.error(` \u2026and ${c.findings.length-50} more`)}}console.error(o.ok?`
|
|
558
|
+
Hidden by precondition (${r.hidden.length}):`),r.hidden.length===0)console.log(" (none)");else for(let n of r.hidden)console.log(` \u2717 ${t(n)} \u2014 precondition not satisfied`)}a(dme,"printHuman");function $B(){return new de("resolve-inline-buttons").alias("resolve-buttons").description("Print the actual command button-set for an asset \u2014 binding-match \u2229 precondition-eval (Issue #3833). The authoritative button-visibility oracle; strictly more complete than `apply --dry-run` (precondition-only).").argument("<target>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--json","Emit structured JSON instead of human-readable text").option("--show-hidden","Also list commands that bind but are hidden by their precondition").action(async(r,e)=>{ce.setFormat(e.json?"json":"text");try{let t=await fme(e.vault,r);if(e.json){let n=e.showHidden?t:{...t,hidden:[]};console.log(JSON.stringify(n,null,2))}else dme(t,e.showHidden??!1)}catch(t){ce.handle(t),process.exit(5)}})}a($B,"resolveButtonsCommand");ct();var lO=require("fs"),Hs=require("path"),Lc=ne(We());Rt();Bt();gr();Vi();var mw=class{constructor(e){this.vault=e}static{a(this,"FsVaultMetadataAdapter")}*listFrontmatter(){for(let e of this.vault.getAllFiles()){let t=this.vault.getFrontmatter(e);t&&(yield t)}}resolveLinkpathFrontmatter(e){let t={allowAliasFallback:!1},n=this.vault.getFirstLinkpathDest(e,"",t);return!n&&!e.endsWith(".md")&&(n=this.vault.getFirstLinkpathDest(`${e}.md`,"",t)),n?this.vault.getFrontmatter(n)??{}:null}};async function pme(r,e){let t=(0,Hs.resolve)(r);if(!(0,lO.existsSync)(t))throw new ke(t);let n=(0,Hs.resolve)(t,e);if(!(0,lO.existsSync)(n))throw new Error(`Target file not found: ${e}`);let i=(0,Hs.relative)(t,n);if(i===".."||i.startsWith(`..${Hs.sep}`)||(0,Hs.isAbsolute)(i))throw new Error(`Target is outside the vault: ${e} (vault: ${t})`);let s=new Ut(t),o=new mw(s),c=new Lc.PrintNameRuleService(o,(0,Lc.createDisplayMatcherHostFunctions)(o));c.initialize();let l=new Lc.DisplayNameResolver(Lc.DEFAULT_DISPLAY_NAME_SETTINGS,c,c.createMetadataResolver()),u=s.getAbstractFileByPath(i),f=u!==null&&"basename"in u?u:null,d=(f?s.getFrontmatter(f):null)??{},p=(0,Hs.basename)(i).replace(/\.md$/,""),h=l.resolveWithProvenance({metadata:d,basename:p}),m=h.displayName??p,g=d.exo__Asset_label,_=typeof g=="string"&&g.trim().length>0,b=h.displayName===null?"basename":h.provenance==="default"?_?"label":"basename":h.provenance,T=d.exo__Asset_uid;return{target:i,uid:typeof T=="string"&&T.trim()?T.trim():null,basename:p,displayName:m,source:b}}a(pme,"resolveDisplayName");function UB(){return new de("resolve-display-name").description("Print the composed display name an asset renders as \u2014 the same engine the plugin runs, over the same vault exo__DisplayNameSpec assets (req f17f7c57). The authoritative naming oracle outside Obsidian; --json adds `source`, which distinguishes a spec-composed name from a raw exo__Asset_label.").argument("<target>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--json","Emit structured JSON instead of the bare name").action(async(r,e)=>{ce.setFormat(e.json?"json":"text");try{let t=await pme(e.vault,r);e.json?console.log(JSON.stringify(t,null,2)):console.log(t.displayName)}catch(t){ce.handle(t),process.exit(5)}})}a(UB,"resolveDisplayNameCommand");ct();mO();ct();var gw=require("fs"),JB=require("path"),Nc=ne(We());var Tr=ne(Ca()),Oi=ne(require("path"));Rx();var Na=ne(We());var li=class{constructor(e){this.rootPath=e}static{a(this,"NodeFsAdapter")}async readFile(e){let t=this.resolvePath(e);if(!await Tr.default.pathExists(t))throw new Na.FileNotFoundError(e);return Tr.default.readFile(t,"utf-8")}async fileExists(e){let t=this.resolvePath(e);return Tr.default.pathExists(t)}async getFileMetadata(e){let t=await this.readFile(e);return this.extractFrontmatter(t)}async createFile(e,t){let n=this.resolvePath(e);if(await Tr.default.pathExists(n))throw new Na.FileAlreadyExistsError(e);return await Tr.default.ensureDir(Oi.default.dirname(n)),await Tr.default.writeFile(n,t,"utf-8"),e}async updateFile(e,t){let n=this.resolvePath(e);if(!await Tr.default.pathExists(n))throw new Na.FileNotFoundError(e);await Tr.default.writeFile(n,t,"utf-8")}async writeFile(e,t){let n=this.resolvePath(e);await Tr.default.ensureDir(Oi.default.dirname(n)),await Tr.default.writeFile(n,t,"utf-8")}async deleteFile(e){let t=this.resolvePath(e);if(!await Tr.default.pathExists(t))throw new Na.FileNotFoundError(e);await Tr.default.remove(t)}async renameFile(e,t){let n=this.resolvePath(e),i=this.resolvePath(t);if(!await Tr.default.pathExists(n))throw new Na.FileNotFoundError(e);await Tr.default.ensureDir(Oi.default.dirname(i)),await Tr.default.move(n,i)}async createDirectory(e){let t=this.resolvePath(e);await Tr.default.ensureDir(t)}async directoryExists(e){let t=this.resolvePath(e);return await Tr.default.pathExists(t)?(await Tr.default.stat(t)).isDirectory():!1}async getMarkdownFiles(e){let t=e?this.resolvePath(e):this.rootPath,n=Oi.default.join(t,"**/*.md");return(await Dd(n,{nodir:!0})).map(o=>Oi.default.relative(this.rootPath,o))}async findFilesByMetadata(e){let t=await this.getMarkdownFiles(),n=[];for(let i of t)try{let s=await this.getFileMetadata(i);this.matchesQuery(s,e)&&n.push(i)}catch{continue}return n}async findFileByUID(e){let t=await this.findFilesByMetadata({exo__Asset_uid:e});return t.length>0?t[0]:null}async findFileByLinkpath(e){let t=e.trim();if(t.length===0)return null;let n=await this.findFileByBasename(`${t}.md`);if(n)return n;let i=await this.getMarkdownFiles();for(let s of i){let o;try{o=await this.getFileMetadata(s)}catch{continue}if(o.exo__Asset_label===t)return s;let c=o.aliases;if(Array.isArray(c)&&c.some(l=>l===t)||typeof c=="string"&&c===t)return s}return null}async findFileByBasename(e){let t=a(async n=>{let i;try{i=await Tr.default.readdir(n,{withFileTypes:!0})}catch{return null}for(let s of i){let o=Oi.default.join(n,s.name);if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;let c=await t(o);if(c)return c}else if(s.isFile()&&s.name===e)return Oi.default.relative(this.rootPath,o)}return null},"walk");return t(this.rootPath)}async findFileByUidFilename(e){let t=e.toLowerCase(),n=a(async i=>{let s;try{s=await Tr.default.readdir(i,{withFileTypes:!0})}catch{return null}for(let o of s){let c=Oi.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules")continue;let l=await n(c);if(l)return l}else if(o.isFile()&&o.name.endsWith(".md")){let l=o.name.toLowerCase();if(l.startsWith(t+".md")||l.startsWith(t+" ")||l.startsWith(t+"-"))return Oi.default.relative(this.rootPath,c)}}return null},"walk");return n(this.rootPath)}resolvePath(e){if(Oi.default.isAbsolute(e))return e;let t=this.rootPath.replace(/[/\\]+$/,""),n=Oi.default.sep+e;return n===t||n.startsWith(t+Oi.default.sep)?n:Oi.default.join(this.rootPath,e)}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,n=e.match(t);return n?(0,Na.parseYamlFrontmatterTolerant)(n[1])??{}:{}}matchesQuery(e,t){for(let[n,i]of Object.entries(t)){let s=e[n];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 Tn=class r extends li{constructor(t,n){super(t);this.indexed=!1;this.uidToPath=new Map;this.basenameToPaths=new Map;this.allPaths=[];this.pathSet=new Set;this.assets=[];this.cacheContent=n?.cacheContent??!1}static{a(this,"CachingNodeFsAdapter")}async buildIndex(){if(this.indexed)return;let t=await super.getMarkdownFiles();for(let n of t){this.allPaths.push(n),this.pathSet.add(n);let i={},s;try{this.cacheContent?(s=await super.readFile(n),i=this.extractFrontmatter(s)):i=await super.getFileMetadata(n)}catch{i={}}let o=i?.exo__Asset_uid,c=Array.isArray(o)?o:[o];for(let f of c){let d=r.normalizeUid(f);d.length>0&&!this.uidToPath.has(d)&&this.uidToPath.set(d,n)}let l=r.basenameOf(n),u=this.basenameToPaths.get(l);u?u.push(n):this.basenameToPaths.set(l,[n]),this.assets.push(this.cacheContent?{path:n,metadata:i,content:s}:{path:n,metadata:i})}this.indexed=!0}async findPathsByBasename(t){return await this.buildIndex(),this.basenameToPaths.get(t)??[]}async hasIndexedPath(t){await this.buildIndex();let n=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(n)}static basenameOf(t){let n=t.lastIndexOf("/"),i=n===-1?t:t.slice(n+1);return i.endsWith(".md")?i.slice(0,-3):i}async indexedAssets(){return await this.buildIndex(),this.assets}async getMarkdownFiles(t){return t?super.getMarkdownFiles(t):(await this.buildIndex(),this.allPaths)}async findFileByUID(t){return await this.buildIndex(),this.uidToPath.get(r.normalizeUid(t))??null}static normalizeUid(t){return t==null?"":String(t).replace(/["'[\]]/g,"").trim()}async fileExists(t){await this.buildIndex();let n=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(n)?!0:super.fileExists(t)}};Rt();Bt();var gO=class{constructor(e){this.vaultPath=e}static{a(this,"CliFsCheckReader")}async read(){return{assets:(await new Tn(this.vaultPath).indexedAssets()).map(i=>({path:i.path,frontmatter:i.metadata}))}}};function ZB(){return new de("vault").description("Run the homoiconic vault-integrity check-runner (enabled-set from validation-check setting__Setting instances; --all runs every check)").requiredOption("--vault <path>","Vault root directory").option("--all","Run ALL known checks, ignoring the vault enabled-set").option("--output <type>","Response format: text|json","text").action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=(0,JB.resolve)(r.vault);if(!(0,gw.existsSync)(t)||!(0,gw.statSync)(t).isDirectory())throw new ke(t);let i=await new gO(t).read(),s=r.all?[...Nc.KNOWN_CHECK_IDS]:(0,Nc.readEnabledCheckIds)(i.assets),o=await new Nc.VaultCheckRunner((0,Nc.createDefaultCheckRegistry)()).runWithContext(i,s);if(e==="json")console.log(JSON.stringify({vaultPath:t,...o},null,2));else{s.length===0&&console.log(`OK ${t}: no validation checks enabled (scaffold validation-settings to enable some, or pass --all)`);for(let c of o.results){let l=`${c.status==="pass"?"OK":c.status==="fail"?"FAIL":"ERROR"} ${c.label}`;if(c.status==="pass")console.log(`${l} (${i.assets.length} assets)`);else if(c.status==="error")console.error(`${l}: ${c.errorMessage}`);else{console.error(`${l}: ${c.findings.length} violation(s)`);for(let u of c.findings.slice(0,50))console.error(` ${u.path?u.path+" \u2014 ":""}${u.message}`);c.findings.length>50&&console.error(` \u2026and ${c.findings.length-50} more`)}}console.error(o.ok?`
|
|
559
559
|
\u2705 ${t}: all ${s.length} enabled check(s) passed`:`
|
|
560
|
-
\u274C ${t}: validation failed`)}o.ok||(process.exitCode=1)}catch(t){ce.handle(t)}})}a(ZB,"validateVaultCommand");function e6(){let r=new
|
|
560
|
+
\u274C ${t}: validation failed`)}o.ok||(process.exitCode=1)}catch(t){ce.handle(t)}})}a(ZB,"validateVaultCommand");function e6(){let r=new de("validate").description("Validate vault files (schema linting, homoiconic vault-integrity checks)");return r.addCommand(XB()),r.addCommand(ZB()),r}a(e6,"validateCommand");ct();var s6=require("fs"),o6=require("path"),_w=ne(We());Vi();Rt();gr();wr();Bt();wr();Nd();var t6=ne(We());var os=ne(We());var Vd=class{constructor(e,t){this.tripleStore=e;this.reader=t}static{a(this,"FsQueryBodyResolver")}async resolveSparql(e){if(!e)return null;let n=(await this.tripleStore.match(void 0,os.Namespace.EXO.term("Asset_uid"),new os.Literal(e)))[0]?.subject;if(!(n instanceof os.IRI))return null;let i=(0,os.iriToVaultPath)(n.value);if(!i)return null;let s;try{s=await this.reader.readFile(i)}catch{return null}return(0,os.extractSparqlBlock)((0,os.stripFrontmatter)(s))}};function yw(r,e){let t=new li(e);return new t6.NamedQueryRunner(new Vd(r,t),r)}a(yw,"buildNamedQueryRunner");var r6="b6aa1da9-96b9-4066-99a9-f81cc8b316aa",n6="5ba1031d-2c6e-4528-ab81-fb768d8e061a",i6="efb7bb79-6378-44b0-b1ca-9a27e3eeb684";function a6(){return new de("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). Introspection SPARQL is read from vault query__NamedQuery assets (req 2678df55).").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)").action(async(r,e)=>{let t=e.output||"text";ce.setFormat(t);try{let n=Date.now(),i=(0,o6.resolve)(e.vault);if(!(0,s6.existsSync)(i))throw new ke(i);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let s=e.useCache??!1,o,c=!1;if(s){let p=await new is(i).loadOrBuild();o=p.triples,c=p.cacheHit,t==="text"&&c&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let d=new Ut(i);o=await new _w.NoteToRDFConverter(d).convertVault()}let l=new _w.InMemoryTripleStore;await l.addAll(o);let u=Date.now()-n;if(t==="text"){let d=c?" (from cache)":"";console.log(`\u2705 Loaded ${o.length} triples in ${u}ms${d}
|
|
561
561
|
`)}let f=yw(l,i);r?await Nme(f,r,e,t):await Lme(f,e,t)}catch(n){ce.handle(n)}})}a(a6,"classesCommand");function yO(r,e){return r===null&&ce.handleWithMessage(`Introspection query__NamedQuery asset "${e}" not found in the vault (no asset with that UID, or it has no \`\`\`sparql code-block). The \`classes\` command reads its SPARQL from vault query assets (req 2678df55).`,3,"VALIDATION_FILE_NOT_FOUND"),r.kind!=="select"&&ce.handleWithMessage(`Introspection query "${e}" is an ${r.kind} query; expected SELECT.`,2,"VALIDATION_INVALID_ARGUMENTS"),r.rows}a(yO,"requireSelectRows");function _O(r){let e=r?.value,t=typeof e=="string"?parseInt(e,10):NaN;return Number.isNaN(t)?0:t}a(_O,"parseCount");async function Lme(r,e,t){let n=await r.run(r6),s=yO(n,r6).map(o=>{let c=o.get("class"),l=o.get("count");return{name:c?c6(c.toString()):"unknown",count:_O(l)}});if(t==="json"||e.format==="json"){let o=pt.success({classes:s,totalClasses:s.length});console.log(JSON.stringify(o,null,2))}else{if(console.log(`\u{1F4CA} Found ${s.length} RDF class(es):
|
|
562
562
|
`),s.length===0){console.log("No classes found in vault.");return}let o=Math.max(...s.map(c=>c.name.length),10);console.log("\u250C"+"\u2500".repeat(o+2)+"\u252C"+"\u2500".repeat(12)+"\u2510"),console.log("\u2502 "+"Class".padEnd(o)+" \u2502 "+"Instances".padEnd(10)+" \u2502"),console.log("\u251C"+"\u2500".repeat(o+2)+"\u253C"+"\u2500".repeat(12)+"\u2524");for(let c of s)console.log("\u2502 "+c.name.padEnd(o)+" \u2502 "+c.count.toString().padStart(10)+" \u2502");console.log("\u2514"+"\u2500".repeat(o+2)+"\u2534"+"\u2500".repeat(12)+"\u2518")}}a(Lme,"listAllClasses");async function Nme(r,e,t,n){let i={params:{className:{value:e,kind:"literal"}}},s=await r.run(n6,i),o=yO(s,n6),c=o.length>0?_O(o[0].get("count")):0,l=await r.run(i6,i),f=yO(l,i6).map(p=>{let h=p.get("property"),m=p.get("usageCount");return{name:h?c6(h.toString()):"unknown",usageCount:_O(m)}}),d={name:e,instanceCount:c,properties:f};if(n==="json"||t.format==="json"){let p=pt.success(d);console.log(JSON.stringify(p,null,2))}else{if(console.log(`\u{1F4CB} Class: ${e}
|
|
563
563
|
`),console.log(` Instances: ${c}`),console.log(` Properties: ${f.length}
|
|
564
|
-
`),f.length===0){console.log(" No properties found.");return}let p=Math.max(...f.map(h=>h.name.length),10);console.log(" \u250C"+"\u2500".repeat(p+2)+"\u252C"+"\u2500".repeat(10)+"\u2510"),console.log(" \u2502 "+"Property".padEnd(p)+" \u2502 "+"Usage".padEnd(8)+" \u2502"),console.log(" \u251C"+"\u2500".repeat(p+2)+"\u253C"+"\u2500".repeat(10)+"\u2524");for(let h of f)console.log(" \u2502 "+h.name.padEnd(p)+" \u2502 "+h.usageCount.toString().padStart(8)+" \u2502");console.log(" \u2514"+"\u2500".repeat(p+2)+"\u2534"+"\u2500".repeat(10)+"\u2518")}}a(Nme,"showClassDetails");function c6(r){let e=r.replace(/^<|>$/g,""),t=e.lastIndexOf("#");if(t!==-1)return e.substring(t+1);let n=e.lastIndexOf("/");return n!==-1?e.substring(n+1):e}a(c6,"extractLocalName");ct();var u6=require("fs"),f6=require("path"),fu=ne(We());Vi();Rt();gr();wr();Bt();wr();Nd();function l6(r,e){return e.concat([r])}a(l6,"collect");function kme(r,e){let t={},n=a((i,s)=>{let o=i.indexOf("=");if(o<=0)throw new Error(`Invalid --param "${i}" \u2014 expected name=value.`);let c=i.slice(0,o),l=i.slice(o+1);t[c]={value:s==="iri"?(0,fu.vaultPathToIRI)(l):l,kind:s}},"add");for(let i of r)n(i,"literal");for(let i of e)n(i,"iri");return Object.keys(t).length>0?t:void 0}a(kme,"buildParams");function d6(){return new
|
|
564
|
+
`),f.length===0){console.log(" No properties found.");return}let p=Math.max(...f.map(h=>h.name.length),10);console.log(" \u250C"+"\u2500".repeat(p+2)+"\u252C"+"\u2500".repeat(10)+"\u2510"),console.log(" \u2502 "+"Property".padEnd(p)+" \u2502 "+"Usage".padEnd(8)+" \u2502"),console.log(" \u251C"+"\u2500".repeat(p+2)+"\u253C"+"\u2500".repeat(10)+"\u2524");for(let h of f)console.log(" \u2502 "+h.name.padEnd(p)+" \u2502 "+h.usageCount.toString().padStart(8)+" \u2502");console.log(" \u2514"+"\u2500".repeat(p+2)+"\u2534"+"\u2500".repeat(10)+"\u2518")}}a(Nme,"showClassDetails");function c6(r){let e=r.replace(/^<|>$/g,""),t=e.lastIndexOf("#");if(t!==-1)return e.substring(t+1);let n=e.lastIndexOf("/");return n!==-1?e.substring(n+1):e}a(c6,"extractLocalName");ct();var u6=require("fs"),f6=require("path"),fu=ne(We());Vi();Rt();gr();wr();Bt();wr();Nd();function l6(r,e){return e.concat([r])}a(l6,"collect");function kme(r,e){let t={},n=a((i,s)=>{let o=i.indexOf("=");if(o<=0)throw new Error(`Invalid --param "${i}" \u2014 expected name=value.`);let c=i.slice(0,o),l=i.slice(o+1);t[c]={value:s==="iri"?(0,fu.vaultPathToIRI)(l):l,kind:s}},"add");for(let i of r)n(i,"literal");for(let i of e)n(i,"iri");return Object.keys(t).length>0?t:void 0}a(kme,"buildParams");function d6(){return new de("run-query").description("Execute a query__NamedQuery asset (read-only SELECT / ASK / CONSTRUCT) by UID and print its result.").argument("<uid>","UID of the query__NamedQuery asset to run").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("--current-asset <path>","Vault-relative path injected as $currentAsset (an IRI) into the query body").option("--param <name=value>","Literal parameter $<name> substituted as an escaped string. Repeatable.",l6,[]).option("--param-iri <name=path>","IRI parameter $<name>; value is a vault-relative path resolved to an IRI. Repeatable.",l6,[]).action(async(r,e)=>{let t=e.output||"text",n=t==="json"||e.format==="json";ce.setFormat(t);try{let i=(0,f6.resolve)(e.vault);if(!(0,u6.existsSync)(i))throw new ke(i);n||console.log(`\u{1F4E6} Loading vault: ${i}...`);let s;e.useCache??!1?s=(await new is(i).loadOrBuild()).triples:s=await new fu.NoteToRDFConverter(new Ut(i)).convertVault();let o=new fu.InMemoryTripleStore;await o.addAll(s);let c=yw(o,i),l={};e.currentAsset&&(l.currentAsset=(0,fu.vaultPathToIRI)(e.currentAsset));let u=kme(e.param,e.paramIri);u&&(l.params=u);let f=await c.run(r,l);f===null&&ce.handleWithMessage(`No resolvable query__NamedQuery for UID "${r}" (asset not found, or it has no \`\`\`sparql code-block).`,3,"VALIDATION_FILE_NOT_FOUND"),Mme(f,n)}catch(i){ce.handle(i)}})}a(d6,"runQueryCommand");function Mme(r,e){if(r.kind==="ask"){console.log(e?JSON.stringify(pt.success({kind:"ask",result:r.result}),null,2):String(r.result));return}if(r.kind==="construct"){let t=r.triples.map(n=>({subject:n.subject.toString(),predicate:n.predicate.toString(),object:n.object.toString()}));if(e)console.log(JSON.stringify(pt.success({kind:"construct",triples:t,count:t.length}),null,2));else{console.log(`\u{1F4CA} CONSTRUCT \u2014 ${t.length} triple(s):
|
|
565
565
|
`);for(let n of t)console.log(`${n.subject} ${n.predicate} ${n.object} .`)}return}if(e){let t=r.rows.map(n=>{let i={};for(let s of n.variables()){let o=n.get(s);i[s]=o?o.toString():null}return i});console.log(JSON.stringify(pt.success({kind:"select",rows:t,count:t.length}),null,2))}else console.log(new Fd().format(r.rows))}a(Mme,"printResult");ct();var E6=require("path"),AO=require("fs"),v6=require("fs"),as=ne(We());Vi();var bO=class extends Error{static{a(this,"ClassNotFoundError")}constructor(e,t){let n=`Class '${e}' not found in vault`;t&&t.length>0&&(n+=`
|
|
566
566
|
Available classes: ${t.join(", ")}`),super(n),this.name="ClassNotFoundError"}},bw=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 n=await this.getOrBuildIndex(e),i=n.get(t);if(!i){let s=Array.from(n.keys()).filter(o=>!this.isUUID(o));throw new bO(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,n=await this.fsAdapter.getMarkdownFiles(),i=[],s=new Set;for(let o of n)try{let c=await this.fsAdapter.getFileMetadata(o),l=this.getBasename(o),u=c.exo__Asset_uid;!u&&this.isUUID(l)&&(u=l);let f=u?String(u):void 0,d=c.exo__Asset_label,p=typeof d=="string"?d:void 0,h=c.exo__Instance_class,m=h?(Array.isArray(h)?h:[h]).map(g=>String(g)):[];i.push({basename:l,uid:f,label:p,classValues:m}),f&&(p==="exo__Class"||p==="ims__Class")&&s.add(f)}catch{continue}for(let o of i)o.uid&&this.isClassDefinition(o.classValues,s)&&(o.basename&&t.set(o.basename,o.uid),o.label&&o.label!==o.basename&&t.set(o.label,o.uid));return t}isClassDefinition(e,t){return e.some(n=>{if(n.includes("ims__Class")||n.includes("exo__Class"))return!0;for(let i of t)if(i&&n.includes(i))return!0;return!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 Sw=class extends Error{static{a(this,"WikilinkNotFoundError")}constructor(e,t){let n=t?`|${t}`:"";super(`Wikilink [[${e}${n}]] \u2014 file not found in vault`),this.name="WikilinkNotFoundError"}},kc=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)){let n=Array.isArray(t)?t:[t];for(let i of n)await this.validateValue(i)}}async validateValue(e){let t=this.extractWikilinks(e);for(let n of t)await this.validateWikilink(n.uuid,n.label)}extractWikilinks(e){let t=[],n=/\[\[([^\]|]+)(?:\|([^\]]*))?\]\]/g,i;for(;(i=n.exec(e))!==null;)t.push({uuid:i[1].trim(),label:i[2]?.trim()});return t}async validateWikilink(e,t){if(!this.looksLikeUUID(e)){if(!await this.fsAdapter.findFileByLinkpath(e))throw new Sw(e,t);return}if(await this.fsAdapter.findFileByUidFilename(e))return;if(!await this.fsAdapter.findFileByUID(e))throw new Sw(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)}};xx();var Mc=class r{constructor(e){this.vaultPath=e;this.cache=null}static{a(this,"PropertyNameValidator")}static{this.KEY_SHAPE=/^([A-Za-z][A-Za-z0-9]*)__.+$/}static{this.PROPERTY_METACLASS_UIDS=["38277bfa-d7f9-4a75-b856-b23276ab0db3","9a1cf31c-9d41-4ef3-9023-584a8d087d16","ae56ca4c-b610-42a4-a25d-058c23673296"]}static{this.PROPERTY_METACLASS_LABELS=["exo__Property","exo__ObjectProperty","exo__DatatypeProperty"]}static{this.CLASS_METACLASS_UID="8619c4fc-64f1-4869-b17e-e34186cacca9"}static{this.CLASS_METACLASS_LABEL="exo__Class"}async validate(e){let{names:t,prefixes:n}=await this.collect();if(t.size!==0)for(let i of e){let s=r.KEY_SHAPE.exec(i);if(!s||t.has(i))continue;let o=s[1],c=n.has(o)?o:void 0,l=r.suggest(i,t,c);throw new $m(i,l)}}async isUnknownName(e){let{names:t}=await this.collect();return t.size===0||!r.KEY_SHAPE.test(e)?!1:!t.has(e)}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),n=[],i=[],s=a(async u=>{let f;try{f=await e(u,{withFileTypes:!0})}catch{return}for(let d of f){let p=`${u}/${d.name}`;if(d.isDirectory())await s(p);else if(d.isFile()&&d.name.endsWith(".md")){let h;try{h=await t(p,"utf-8")}catch{continue}r.scan(h,n,i)}}},"walk");await s(this.vaultPath);let o=r.buildPropertyMetaclassClosure(n),c=new Set,l=new Set;for(let u of i){if(!u.classRefs.some(d=>o.has(d)))continue;c.add(u.name);let f=r.KEY_SHAPE.exec(u.name);f&&l.add(f[1])}return this.cache={names:c,prefixes:l},this.cache}static scan(e,t,n){let i=r.parseFrontmatter(e);if(!i)return;let s=r.asArray(i.exo__Instance_class).flatMap(c=>r.refHalves(c));if(s.length===0)return;let o=r.cleanLabel(i.exo__Asset_label);if(s.some(c=>r.isClassMetaclass(c))){let c=i.exo__Asset_uid,l=typeof c=="string"?c.trim():null,u=r.asArray(i.exo__Class_superClass).flatMap(f=>r.refHalves(f));t.push({uid:l,label:o,superRefs:u});return}o===null||!r.KEY_SHAPE.test(o)||n.push({classRefs:s,name:o})}static buildPropertyMetaclassClosure(e){let t=new Set([...r.PROPERTY_METACLASS_UIDS,...r.PROPERTY_METACLASS_LABELS]),n=!0;for(;n;){n=!1;for(let i of e)i.uid!==null&&t.has(i.uid)||i.label!==null&&t.has(i.label)||i.superRefs.some(o=>t.has(o))&&(i.uid!==null&&t.add(i.uid),i.label!==null&&t.add(i.label),n=!0)}return t}static isClassMetaclass(e){return e===r.CLASS_METACLASS_UID||e===r.CLASS_METACLASS_LABEL}static refHalves(e){let t=String(e).replace(/^["']|["']$/g,"").trim(),n=/\[\[([^\]]+)\]\]/.exec(t);return(n?n[1]:t).split("|").map(s=>s.trim()).filter(s=>s.length>0)}static cleanLabel(e){if(typeof e!="string")return null;let t=e.replace(/^["']|["']$/g,"").trim();return t.length>0?t:null}static asArray(e){return Array.isArray(e)?e.map(String):typeof e=="string"?[e]:[]}static parseFrontmatter(e){let t=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!t)return null;let n={},i=t[1].split(/\r?\n/),s=null,o=null;for(let c of i){let l=/^ {2}- (.*)$/.exec(c);if(l){s&&o&&o.push(l[1].trim());continue}s&&o&&(n[s]=o,s=null,o=null);let u=/^([^:]+):\s*(.*)$/.exec(c);if(!u)continue;let f=u[1].trim(),d=u[2].trim();d===""?(s=f,o=[]):n[f]=d}return s&&o&&(n[s]=o),n}static suggest(e,t,n){let i=n?[...t].filter(o=>o.startsWith(`${n}__`)):[...t],s=Math.max(3,Math.floor(e.length*.4));return i.map(o=>({name:o,distance:r.levenshtein(e,o)})).filter(o=>o.distance<=s).sort((o,c)=>o.distance-c.distance||o.name.localeCompare(c.name)).slice(0,3).map(o=>o.name)}static levenshtein(e,t){let n=e.length,i=t.length;if(n===0)return i;if(i===0)return n;let s=Array.from({length:i+1},(c,l)=>l),o=new Array(i+1);for(let c=1;c<=n;c++){o[0]=c;for(let l=1;l<=i;l++){let u=e[c-1]===t[l-1]?0:1;o[l]=Math.min(s[l]+1,o[l-1]+1,s[l-1]+u)}[s,o]=[o,s]}return s[i]}};var p6="ems__Effort",jme="ems__EffortStatus",ww=class{constructor(e){this.fsAdapter=e;this.statusUidCache=new Map}static{a(this,"EffortStatusResolver")}async isStatusBearing(e){let t=new Set,n=[e];for(;n.length>0;){let i=n.shift();if(i===void 0)break;if(t.has(i))continue;if(t.add(i),i===p6)return!0;let s=await this.resolveClassFile(i);if(!s)continue;let o;try{o=await this.fsAdapter.getFileMetadata(s)}catch{continue}if(o.exo__Asset_label===p6)return!0;let c=o.exo__Class_superClass,l=Array.isArray(c)?c:c!=null?[c]:[];for(let u of l){let f=Ume(String(u));f&&!t.has(f)&&n.push(f)}}return!1}async resolveStatusUid(e){let t=$me(e),n=this.statusUidCache.get(t);if(n!==void 0)return n;let i=null,s=await this.fsAdapter.findFilesByMetadata({exo__Asset_label:t});for(let o of s)try{let c=await this.fsAdapter.getFileMetadata(o);if(c.exo__Asset_uid){i=String(c.exo__Asset_uid);break}}catch{continue}return this.statusUidCache.set(t,i),i}async resolveClassFile(e){if(Bme(e))return this.fsAdapter.findFileByUidFilename(e);let t=await this.fsAdapter.findFilesByMetadata({exo__Asset_label:e});return t.length>0?t[0]:null}};function $me(r){let e=r.trim();if(e.startsWith("ems__"))return e;let t=e.charAt(0).toUpperCase()+e.slice(1);return`${jme}${t}`}a($me,"toStatusEnumLabel");function Ume(r){return r.trim().replace(/^["']|["']$/g,"").replace(/^\[\[|\]\]$/g,"").split("|")[0].trim()||null}a(Ume,"extractRef");function Bme(r){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)}a(Bme,"isUuid");Rt();Bt();var Gd=require("fs"),SO=require("path"),m6=ne(We());function Ew(r){(0,m6.registerOrderSpecLoader)(()=>{let e=Vme(r);for(let t of e){let n=Gme(t);if(n)return n}return null})}a(Ew,"registerOrderSpecFromVault");function Vme(r){return[(0,SO.join)(r,"assetspaces","exo")]}a(Vme,"collectCandidateDirs");function Gme(r){if(!(0,Gd.existsSync)(r))return null;let e;try{e=(0,Gd.readdirSync)(r)}catch{return null}for(let t of e){if(!t.endsWith(".md"))continue;let n=(0,SO.join)(r,t),i;try{i=(0,Gd.readFileSync)(n,"utf-8")}catch{continue}let s=qme(i);if(s&&/^exo__FrontmatterOrderSpec_default:\s*true\b/m.test(s))return{head:h6(s,"exo__FrontmatterOrderSpec_head"),tail:h6(s,"exo__FrontmatterOrderSpec_tail"),middleStrategy:Wme(s,"exo__FrontmatterOrderSpec_middleStrategy")??"alphabetical"}}return null}a(Gme,"scanDirForDefault");function qme(r){let e=r.match(/^---\n([\s\S]*?)\n---/);return e?e[1]:null}a(qme,"extractFrontmatter");function Wme(r,e){let t=new RegExp(`^${g6(e)}:\\s*(.+)$`,"m"),n=r.match(t);return n?n[1].trim():null}a(Wme,"extractScalar");function h6(r,e){let t=new RegExp(`^${g6(e)}:\\s*\\n((?: -.*\\n?)+)`,"m"),n=r.match(t);return n?n[1].split(`
|
|
567
|
-
`).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>i.slice(2).trim()):[]}a(h6,"extractList");function g6(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(g6,"escapeRegex");var qd=ne(require("path")),EO=ne(We());async function jc(r,e,t){let n=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await r.fileExists(n))return n;let i=qd.default.dirname(t),s=i!=="."?`${i}/${n}`:n;if(await r.fileExists(s))return s;let c=await r.findFileByUID(e);return c||(await r.getMarkdownFiles()).find(f=>{let d=qd.default.basename(f,".md"),p=qd.default.basename(n,".md");return d===p})||null}a(jc,"findReferencedFile");function vO(r){return r.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}a(vO,"normalizePath");async function vw(r,e){let t=(0,EO.extractAssetReference)(e);if(!t||t.startsWith("!"))return null;let n=await jc(r,t,"");if(!n)return null;let i=qd.default.dirname(n);return i==="."?"":i}a(vw,"resolveCoLocationFolder");function wO(r){let e=r;for(;Array.isArray(e);){if(e.length===0)return null;e=e[0]}return(0,EO.extractAssetReference)(e)}a(wO,"wikilinkTarget");async function y6(r,e,t,n){let i={sameAnchor:new Map,anyAnchor:new Map},s=new Set;if(e&&s.add(e),t&&s.add(t),s.size===0)return i;let o=wO(n),c=await r.getMarkdownFiles(),l=new Map,u=new Map;for(let f of c){let d;try{d=await r.getFileMetadata(f)}catch{continue}let p=d.exo__Instance_class;if(!(Array.isArray(p)?p:[p]).some(b=>{let T=wO(b);return T!==null&&s.has(T)}))continue;let g=qd.default.dirname(f),_=g==="."?"":g;u.set(_,(u.get(_)??0)+1),wO(d.exo__Asset_isDefinedBy)===o&&l.set(_,(l.get(_)??0)+1)}return{sameAnchor:l,anyAnchor:u}}a(y6,"scanClassNeighbours");function _6(r){if(r.size===0)return null;let e=null,t=-1,n=Array.from(r.entries()).sort((i,s)=>i[0]<s[0]?-1:i[0]>s[0]?1:0);for(let[i,s]of n)s>t&&(e=i,t=s);return e}a(_6,"pickCanonicalHome");var Aw="01 Inbox",Qme="Asia/Almaty",Xme="4ef3962d-b8a7-42b5-bd28-88ec846f1d13",w6="Backlog",Xm="ems__Effort_status",Jme={aliases:"--aliases <a,b>"};function Zme(r){if(!r||r.length===0)return{};let e={};for(let t of r){let n=t.indexOf("=");if(n===-1)throw new Error(`Invalid property format: "${t}". Expected "key=value" format.`);let i=t.substring(0,n).trim(),s=t.substring(n+1);if(!i)throw new Error(`Invalid property format: "${t}". Key cannot be empty.`);let o=Jme[(0,as.canonicalYamlKey)(i)];if(o!==void 0)throw new Error(`Refusing to set "${i}" via --property \u2014 create manages this field itself. Use: ${o}`);let c=e[i];c===void 0?e[i]=s:Array.isArray(c)?c.push(s):e[i]=[c,s]}return e}a(Zme,"parseProperties");async function ege(r){if(r.bodyFile){if(!(0,AO.existsSync)(r.bodyFile))throw new Error(`Body file not found: ${r.bodyFile}`);return{text:(0,v6.readFileSync)(r.bodyFile,"utf-8"),source:"file"}}if(r.body==="-")return{text:await tge(3e4),source:"stdin"};if(r.body)return{text:r.body,source:"inline"}}a(ege,"resolveBody");function tge(r){return new Promise((e,t)=>{let n=[],i=setTimeout(()=>{process.stdin.removeAllListeners(),process.stdin.destroy(),t(new Error(`Stdin read timed out after ${r}ms. Ensure you pipe content to stdin or close the pipe.`))},r);process.stdin.on("data",s=>{n.push(s)}),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(n).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)}),process.stdin.isTTY&&(clearTimeout(i),e("")),process.stdin.resume()})}a(tge,"readStdin");function T6(){return new
|
|
567
|
+
`).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>i.slice(2).trim()):[]}a(h6,"extractList");function g6(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(g6,"escapeRegex");var qd=ne(require("path")),EO=ne(We());async function jc(r,e,t){let n=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await r.fileExists(n))return n;let i=qd.default.dirname(t),s=i!=="."?`${i}/${n}`:n;if(await r.fileExists(s))return s;let c=await r.findFileByUID(e);return c||(await r.getMarkdownFiles()).find(f=>{let d=qd.default.basename(f,".md"),p=qd.default.basename(n,".md");return d===p})||null}a(jc,"findReferencedFile");function vO(r){return r.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}a(vO,"normalizePath");async function vw(r,e){let t=(0,EO.extractAssetReference)(e);if(!t||t.startsWith("!"))return null;let n=await jc(r,t,"");if(!n)return null;let i=qd.default.dirname(n);return i==="."?"":i}a(vw,"resolveCoLocationFolder");function wO(r){let e=r;for(;Array.isArray(e);){if(e.length===0)return null;e=e[0]}return(0,EO.extractAssetReference)(e)}a(wO,"wikilinkTarget");async function y6(r,e,t,n){let i={sameAnchor:new Map,anyAnchor:new Map},s=new Set;if(e&&s.add(e),t&&s.add(t),s.size===0)return i;let o=wO(n),c=await r.getMarkdownFiles(),l=new Map,u=new Map;for(let f of c){let d;try{d=await r.getFileMetadata(f)}catch{continue}let p=d.exo__Instance_class;if(!(Array.isArray(p)?p:[p]).some(b=>{let T=wO(b);return T!==null&&s.has(T)}))continue;let g=qd.default.dirname(f),_=g==="."?"":g;u.set(_,(u.get(_)??0)+1),wO(d.exo__Asset_isDefinedBy)===o&&l.set(_,(l.get(_)??0)+1)}return{sameAnchor:l,anyAnchor:u}}a(y6,"scanClassNeighbours");function _6(r){if(r.size===0)return null;let e=null,t=-1,n=Array.from(r.entries()).sort((i,s)=>i[0]<s[0]?-1:i[0]>s[0]?1:0);for(let[i,s]of n)s>t&&(e=i,t=s);return e}a(_6,"pickCanonicalHome");var Aw="01 Inbox",Qme="Asia/Almaty",Xme="4ef3962d-b8a7-42b5-bd28-88ec846f1d13",w6="Backlog",Xm="ems__Effort_status",Jme={aliases:"--aliases <a,b>"};function Zme(r){if(!r||r.length===0)return{};let e={};for(let t of r){let n=t.indexOf("=");if(n===-1)throw new Error(`Invalid property format: "${t}". Expected "key=value" format.`);let i=t.substring(0,n).trim(),s=t.substring(n+1);if(!i)throw new Error(`Invalid property format: "${t}". Key cannot be empty.`);let o=Jme[(0,as.canonicalYamlKey)(i)];if(o!==void 0)throw new Error(`Refusing to set "${i}" via --property \u2014 create manages this field itself. Use: ${o}`);let c=e[i];c===void 0?e[i]=s:Array.isArray(c)?c.push(s):e[i]=[c,s]}return e}a(Zme,"parseProperties");async function ege(r){if(r.bodyFile){if(!(0,AO.existsSync)(r.bodyFile))throw new Error(`Body file not found: ${r.bodyFile}`);return{text:(0,v6.readFileSync)(r.bodyFile,"utf-8"),source:"file"}}if(r.body==="-")return{text:await tge(3e4),source:"stdin"};if(r.body)return{text:r.body,source:"inline"}}a(ege,"resolveBody");function tge(r){return new Promise((e,t)=>{let n=[],i=setTimeout(()=>{process.stdin.removeAllListeners(),process.stdin.destroy(),t(new Error(`Stdin read timed out after ${r}ms. Ensure you pipe content to stdin or close the pipe.`))},r);process.stdin.on("data",s=>{n.push(s)}),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(n).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)}),process.stdin.isTTY&&(clearTimeout(i),e("")),process.stdin.resume()})}a(tge,"readStdin");function T6(){return new de("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; the SAME key passed more than once accumulates into a YAML array)",rge,[]).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("--status <name>","ems__Effort_status for status-bearing classes (default: Backlog; e.g. Draft, Doing, Done). Errors for non-status-bearing classes.").option("--no-status","For a status-bearing class, do NOT inject the default ems__Effort_status \u2014 create a status-less prototype/template (issue #3928). No-op for a non-status-bearing class. Mutually exclusive with --status / --property ems__Effort_status.").option("--yes","Accepted for symmetry with the apply subcommands (create is non-interactive; no-op)").option("--timezone <tz>","Timezone for timestamps (defaults to Asia/Almaty)").option("--skip-wikilink-validation","Skip wikilink existence validation").option("--validate","Run SHACL-lite conformance validation on the new asset BEFORE writing it; a non-conformant asset is refused and no file is created (same shapes as `validate schema --shapes-mode`). Opt-in: omit the flag and create behaves exactly as before.").action(async r=>{try{let e=(0,E6.resolve)(r.vault);if(!(0,AO.existsSync)(e))throw new ke(e);if(Ew(e),!r.label||r.label.trim().length===0)throw new Error("Label cannot be empty");let t=r.label.trim(),n=Zme(r.property);await new Mc(e).validate(Object.keys(n));let s=await ege(r),o=s?.text;o!==void 0&&s?.source==="inline"&&(o=o.replace(/\\n/g,`
|
|
568
568
|
`));let c=new li(e),l=new bw(c),u=new kc(c),f=await l.resolve(e,r.class),d=new ww(c),p=r.status===!1,h=typeof r.status=="string"?r.status:void 0,m=Xm in n;if(p&&m)throw new Error(`Cannot pass both --no-status and --property ${Xm}=... (ambiguous \u2014 cannot both suppress and set the status). Use one.`);if(h&&m)throw new Error(`Cannot pass both --status and --property ${Xm}=... (ambiguous). Use one.`);if(!m&&!p){let O=await d.isStatusBearing(f);if(h){if(!O)throw new Error(`--status only applies to status-bearing classes (ems__Effort subclasses); '${r.class}' is not one.`);let F=await d.resolveStatusUid(h);if(!F)throw new Error(`Unknown status '${h}' \u2014 no matching ems__EffortStatus<Name> enum asset found in the vault.`);n[Xm]=`[[${F}]]`}else if(O){let F=await d.resolveStatusUid(w6);F?n[Xm]=`[[${F}]]`:process.stderr.write(`\u26A0 status-bearing class but no ${w6} status enum found in the vault \u2014 created without ems__Effort_status.
|
|
569
569
|
`)}}let g=Object.keys(n).length>0?n:void 0;g&&!r.skipWikilinkValidation&&await u.validatePropertyValues(g);let _=Aw,b=g?.exo__Asset_isDefinedBy,T=Array.isArray(b)?b[0]:b;if(T){let O=await vw(c,T);O&&(_=O)}if(_===Aw){let O=await y6(c,f,r.class,T),F=_6(O.sameAnchor);if(F)_=F;else{let Z=Array.from(O.anyAnchor.entries()).filter(([J])=>J!==""&&J!==Aw).sort((J,U)=>U[1]-J[1]||(J[0]<U[0]?-1:1));if(Z.length>0){let J=Z.slice(0,3).map(([_e,le])=>`${_e} (${le})`).join(", "),U=Z.length>3?`, +${Z.length-3} more`:"",K=T==null?"exo__Asset_isDefinedBy is absent":String(T).length===0?"exo__Asset_isDefinedBy is empty":`exo__Asset_isDefinedBy=${String(T)} resolved no folder and no sibling shares that anchor`;process.stderr.write(`\u26A0 co-location fail-open: this asset would land in \`${Aw}/\` \u2014 ${K}.
|
|
570
570
|
Existing homes of class ${r.class}: ${J}${U}.
|
|
@@ -573,17 +573,17 @@ Available classes: ${t.join(", ")}`),super(n),this.name="ClassNotFoundError"}},b
|
|
|
573
573
|
`);if(K.length>0)throw new Um(Z.path,K)}let L,P;if(r.dryRun){let O=S.buildAsset(R);L=O.uid,P=O.path,process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
574
574
|
${O.content}--- END PREVIEW ---
|
|
575
575
|
`)}else{let O=await S.createAsset(R);L=O.basename,P=O.path}let M={uuid:L,path:P,label:t};process.stdout.write(JSON.stringify(M)+`
|
|
576
|
-
`),process.exit(0)}catch(e){ce.handle(e)}})}a(T6,"createCommand");function rge(r,e){return e.concat([r])}a(rge,"collect");ct();var zs=require("path"),Hd=require("fs"),Bc=ne(We());Rt();Bt();var Jm=ne(We());var $c="Asia/Almaty",ka="exo__Asset_updatedAt";var IO={ems__Effort_status:{commands:["mark-done","move-to-backlog","rollback-to-backlog","start-effort","set-draft-status"]},ems__Task_zone:{commands:["set-criticality-high","set-criticality-medium","set-criticality-low"]},ems__Effort_parent:{commands:["set-parent"],argSuffix:`--input '{"parent":"<uid>"}'`},exo__Asset_label:{commands:["set-label"],argSuffix:`--input '{"label":"<text>"}'`},exo__Instance_class:{commands:["convert-to-task","convert-to-project"],note:"reclassing is a semantic operation with a precondition"},ems__Effort_startTimestamp:{commands:["start-effort","rollback-to-backlog","park-waiting"],clearedBy:["rollback-to-backlog","park-waiting"],note:"start-effort sets it; the others clear it as a side effect of the status change"},ems__Effort_endTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_resolutionTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_plannedStartTimestamp:{commands:["set-planned-start","plan-on-today","plan-for-evening","shift-day-forward","shift-day-backward"]},ems__Effort_plannedEndTimestamp:{commands:["set-planned-end"]},ems__Effort_scheduledDate:{commands:["set-scheduled-date"]},ems__Effort_votes:{commands:["vote-on-effort"]},archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]},exo__Asset_archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]}};function Zm(r){return Object.prototype.hasOwnProperty.call(IO,r)?IO[r]:void 0}a(Zm,"guardedRouteFor");function Iw(r,e){if(e.size===0)return RO(r);let t=r.commands.filter(n=>e.has(n));return t.length===0?`apply ${r.commands.join("|")} <path> (\u26D4 none of these resolve in this vault \u2014 the owning assetspace looks unmounted)`:RO({...r,commands:t})}a(Iw,"renderGuardedRouteResolved");function RO(r){let e=`apply ${r.commands.join("|")} <path>`,t=r.argSuffix?`${e} ${r.argSuffix}`:e;return r.note?`${t} (${r.note})`:t}a(RO,"renderGuardedRoute");var qMe=Object.fromEntries(Object.entries(IO).map(([r,e])=>[r,RO(e)])),Rw={exo__Asset_uid:"the asset identity \u2014 changing it breaks UID-canon filenames and every inbound [[uid]] wikilink",[ka]:"auto-managed (bumped on every mutation)"};function A6(r){let e=Zm(r);if(e===void 0)return;let t=e.clearedBy??[];if(t.length===0)return;let{note:n,...i}=e;return{...i,commands:t}}a(A6,"clearingRouteFor");function I6(r){return`Refusing to remove "${r}" via remove-property \u2014 it is guarded, and no dedicated command clears it (the ones that own it assign a value). If dropping the facet is intended, say so explicitly: --force --reason "<why>"`}a(I6,"renderNoClearingPathRefusal");function Cw(r,e,t,n){return`Refusing to ${r} "${t}" via ${e} \u2014 it has a dedicated guarded command so the state machine / precondition is not bypassed. Use: exocortex ${n} --vault <v>`}a(Cw,"renderGuardRefusal");function xw(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}a(xw,"guardedReason");function Uc(r,e){let n=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),i=a(s=>n.find(o=>o.type===s)?.value??"00","get");return`${i("year")}-${i("month")}-${i("day")}T${i("hour")}:${i("minute")}:${i("second")}`}a(Uc,"stampTimestamp");var nge=/^\s*exocmd__Command_cliName:\s*(.+?)\s*$/gm;function ige(r){let e=r.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1).trim():e}a(ige,"unquote");var Wd=class{constructor(e){this.vaultPath=e}static{a(this,"CommandNameRegistry")}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),n=new Set,i=a(async s=>{let o;try{o=await e(s,{withFileTypes:!0})}catch{return}for(let c of o){let l=`${s}/${c.name}`;if(c.isDirectory()){if(c.name===".git"||c.name==="node_modules")continue;await i(l)}else if(c.isFile()&&c.name.endsWith(".md")){let u;try{u=await t(l,"utf-8")}catch{continue}for(let f of u.matchAll(nge)){let d=ige(f[1]);d&&n.add(d)}}}},"walk");return await i(this.vaultPath),this.cache=n,n}};var sge="exo__Asset_isDefinedBy";function oge(r){let e=a(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean","isScalar");if(e(r)||Array.isArray(r)&&r.every(e))return;let t=r===null?"null":Array.isArray(r)?"an array with non-scalar elements":typeof r;throw new Error(`--input.value must be a scalar (string/number/boolean) or an array of scalars, not ${t}`)}a(oge,"assertScalarOrScalarArray");function age(r,e){if(e==="")throw new Error(`Refusing to set "${r}" to an EMPTY value \u2014 an empty string writes a junk key (${r}: "") rather than clearing the property. To delete it use: exocortex remove-property <path> --property ${r} --vault <v>`)}a(age,"assertNonEmptyValue");function cge(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ke("Pass --input OR --property/--value, not both.",`set-property <path> --input '{"property":"<name>","value":<v>}'`);if(e){let n;try{n=JSON.parse(r.input)}catch(o){let c=o instanceof Error?o.message:String(o);throw new Error(`--input: invalid JSON (${c})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>","value":<v>}');let i=n,s=i.property;if(typeof s!="string"||s.trim().length===0)throw new Error("--input.property must be a non-empty string");if(!("value"in i))throw new Error("--input.value is required");return{property:s.trim(),value:i.value}}if(t){if(r.value===void 0)throw new Error("--property requires --value (or use --input for a typed/array value)");return{property:r.property.trim(),value:r.value}}throw new Ke("No property provided.",`set-property <path> --input '{"property":"<name>","value":<v>}' OR set-property <path> --property <name> --value <string>`)}a(cge,"resolvePropertyAndValue");function lge(r,e){let t=Bc.STRING_SCALAR_PROPERTIES.has(e);return Array.isArray(r)?r.map(n=>(0,Bc.serializeYamlScalar)(n,t)):(0,Bc.serializeYamlScalar)(r,t)}a(lge,"serializeForWrite");function R6(){return new
|
|
576
|
+
`),process.exit(0)}catch(e){ce.handle(e)}})}a(T6,"createCommand");function rge(r,e){return e.concat([r])}a(rge,"collect");ct();var zs=require("path"),Hd=require("fs"),Bc=ne(We());Rt();Bt();var Jm=ne(We());var $c="Asia/Almaty",ka="exo__Asset_updatedAt";var IO={ems__Effort_status:{commands:["mark-done","move-to-backlog","rollback-to-backlog","start-effort","set-draft-status"]},ems__Task_zone:{commands:["set-criticality-high","set-criticality-medium","set-criticality-low"]},ems__Effort_parent:{commands:["set-parent"],argSuffix:`--input '{"parent":"<uid>"}'`},exo__Asset_label:{commands:["set-label"],argSuffix:`--input '{"label":"<text>"}'`},exo__Instance_class:{commands:["convert-to-task","convert-to-project"],note:"reclassing is a semantic operation with a precondition"},ems__Effort_startTimestamp:{commands:["start-effort","rollback-to-backlog","park-waiting"],clearedBy:["rollback-to-backlog","park-waiting"],note:"start-effort sets it; the others clear it as a side effect of the status change"},ems__Effort_endTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_resolutionTimestamp:{commands:["mark-done","re-open"],clearedBy:["re-open"],note:"mark-done sets it; re-open clears it as a side effect of the status change"},ems__Effort_plannedStartTimestamp:{commands:["set-planned-start","plan-on-today","plan-for-evening","shift-day-forward","shift-day-backward"]},ems__Effort_plannedEndTimestamp:{commands:["set-planned-end"]},ems__Effort_scheduledDate:{commands:["set-scheduled-date"]},ems__Effort_votes:{commands:["vote-on-effort"]},archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]},exo__Asset_archived:{commands:["archive","archive-ontologically","un-archive"],clearedBy:["un-archive"]}};function Zm(r){return Object.prototype.hasOwnProperty.call(IO,r)?IO[r]:void 0}a(Zm,"guardedRouteFor");function Iw(r,e){if(e.size===0)return RO(r);let t=r.commands.filter(n=>e.has(n));return t.length===0?`apply ${r.commands.join("|")} <path> (\u26D4 none of these resolve in this vault \u2014 the owning assetspace looks unmounted)`:RO({...r,commands:t})}a(Iw,"renderGuardedRouteResolved");function RO(r){let e=`apply ${r.commands.join("|")} <path>`,t=r.argSuffix?`${e} ${r.argSuffix}`:e;return r.note?`${t} (${r.note})`:t}a(RO,"renderGuardedRoute");var qMe=Object.fromEntries(Object.entries(IO).map(([r,e])=>[r,RO(e)])),Rw={exo__Asset_uid:"the asset identity \u2014 changing it breaks UID-canon filenames and every inbound [[uid]] wikilink",[ka]:"auto-managed (bumped on every mutation)"};function A6(r){let e=Zm(r);if(e===void 0)return;let t=e.clearedBy??[];if(t.length===0)return;let{note:n,...i}=e;return{...i,commands:t}}a(A6,"clearingRouteFor");function I6(r){return`Refusing to remove "${r}" via remove-property \u2014 it is guarded, and no dedicated command clears it (the ones that own it assign a value). If dropping the facet is intended, say so explicitly: --force --reason "<why>"`}a(I6,"renderNoClearingPathRefusal");function Cw(r,e,t,n){return`Refusing to ${r} "${t}" via ${e} \u2014 it has a dedicated guarded command so the state machine / precondition is not bypassed. Use: exocortex ${n} --vault <v>`}a(Cw,"renderGuardRefusal");function xw(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}a(xw,"guardedReason");function Uc(r,e){let n=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(r),i=a(s=>n.find(o=>o.type===s)?.value??"00","get");return`${i("year")}-${i("month")}-${i("day")}T${i("hour")}:${i("minute")}:${i("second")}`}a(Uc,"stampTimestamp");var nge=/^\s*exocmd__Command_cliName:\s*(.+?)\s*$/gm;function ige(r){let e=r.trim();return e.length>=2&&(e[0]==='"'||e[0]==="'")&&e[e.length-1]===e[0]?e.slice(1,-1).trim():e}a(ige,"unquote");var Wd=class{constructor(e){this.vaultPath=e}static{a(this,"CommandNameRegistry")}async collect(){if(this.cache)return this.cache;let{readdir:e,readFile:t}=await import("fs/promises"),n=new Set,i=a(async s=>{let o;try{o=await e(s,{withFileTypes:!0})}catch{return}for(let c of o){let l=`${s}/${c.name}`;if(c.isDirectory()){if(c.name===".git"||c.name==="node_modules")continue;await i(l)}else if(c.isFile()&&c.name.endsWith(".md")){let u;try{u=await t(l,"utf-8")}catch{continue}for(let f of u.matchAll(nge)){let d=ige(f[1]);d&&n.add(d)}}}},"walk");return await i(this.vaultPath),this.cache=n,n}};var sge="exo__Asset_isDefinedBy";function oge(r){let e=a(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean","isScalar");if(e(r)||Array.isArray(r)&&r.every(e))return;let t=r===null?"null":Array.isArray(r)?"an array with non-scalar elements":typeof r;throw new Error(`--input.value must be a scalar (string/number/boolean) or an array of scalars, not ${t}`)}a(oge,"assertScalarOrScalarArray");function age(r,e){if(e==="")throw new Error(`Refusing to set "${r}" to an EMPTY value \u2014 an empty string writes a junk key (${r}: "") rather than clearing the property. To delete it use: exocortex remove-property <path> --property ${r} --vault <v>`)}a(age,"assertNonEmptyValue");function cge(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ke("Pass --input OR --property/--value, not both.",`set-property <path> --input '{"property":"<name>","value":<v>}'`);if(e){let n;try{n=JSON.parse(r.input)}catch(o){let c=o instanceof Error?o.message:String(o);throw new Error(`--input: invalid JSON (${c})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>","value":<v>}');let i=n,s=i.property;if(typeof s!="string"||s.trim().length===0)throw new Error("--input.property must be a non-empty string");if(!("value"in i))throw new Error("--input.value is required");return{property:s.trim(),value:i.value}}if(t){if(r.value===void 0)throw new Error("--property requires --value (or use --input for a typed/array value)");return{property:r.property.trim(),value:r.value}}throw new Ke("No property provided.",`set-property <path> --input '{"property":"<name>","value":<v>}' OR set-property <path> --property <name> --value <string>`)}a(cge,"resolvePropertyAndValue");function lge(r,e){let t=Bc.STRING_SCALAR_PROPERTIES.has(e);return Array.isArray(r)?r.map(n=>(0,Bc.serializeYamlScalar)(n,t)):(0,Bc.serializeYamlScalar)(r,t)}a(lge,"serializeForWrite");function R6(){return new de("set-property").description("Set an arbitrary non-guarded frontmatter property on an existing vault asset (bumps exo__Asset_updatedAt). Refuses state-machine-guarded properties (status/zone/parent/label/fact-timestamps) \u2014 those keep their dedicated `apply` commands. Issues #3795 / #3848.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>",'JSON {"property":"<name>","value":<v>} \u2014 value is JSON-typed (boolean/number/string/array). Primary form.').option("--property <name>","Property name (string-value convenience form; pair with --value; use --input for boolean/number/array values)").option("--value <value>","Property value as a string (pair with --property; use --input for typed/array values)").option("--skip-wikilink-validation","Skip [[...]] wikilink existence validation").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting frontmatter without writing").option("--yes","Accepted for symmetry with the apply/create subcommands (set-property is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,zs.resolve)(e.vault);if(!(0,Hd.existsSync)(t))throw new ke(t);let n=(0,zs.resolve)(t,r),i=(0,zs.relative)(t,n);if(i===".."||i.startsWith(`..${zs.sep}`)||(0,zs.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,Hd.readFileSync)(n,"utf-8")}catch(w){throw w.code==="ENOENT"?new Error(`Target file not found: ${r}`):w}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. set-property only mutates existing assets.`);let{property:o,value:c}=cge(e),l=Bc.FrontmatterService.normalizeIRI(o),u=xw(Rw,l);if(u!==void 0)throw new Error(`Refusing to set "${l}" \u2014 ${u}.`);let f=Zm(l);if(f!==void 0){let w=await new Wd(t).collect();throw new Error(Cw("set","set-property",l,Iw(f,w)))}if(await new Mc(t).validate([l]),oge(c),age(o,c),!e.skipWikilinkValidation){let w=new kc(new li(t)),S=Array.isArray(c)?c:[c];for(let R of S)typeof R=="string"&&await w.validateValue(R)}let p=new Bc.FrontmatterService,h=e.frozenClock?new Date(e.frozenClock):new Date,m=e.timezone??$c,g=Uc(h,m),_=(0,Jm.canonicalYamlKey)(l),b=p.updateProperty(s,_,lge(c,_));b=p.updateProperty(b,ka,g);let T;if(l===sge){let w=Array.isArray(c)?c[0]:c,S=await vw(new li(t),w);if(S!==null){let R=(0,zs.dirname)(i),L=R==="."?"":R;L!==S&&(T=`\u26A0 co-location: exo__Asset_isDefinedBy now points at "${S||"<vault root>"}" but the file is in "${L||"<vault root>"}". Move it to match: exocortex apply repair-folder ${i} --vault <v>`)}}e.dryRun?process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
577
577
|
${b}
|
|
578
578
|
--- END PREVIEW ---
|
|
579
579
|
`):(0,Hd.writeFileSync)(n,b,"utf-8"),T&&process.stderr.write(T+`
|
|
580
580
|
`);let I={path:i,property:l,value:c,updatedAt:g,...T?{coLocationWarning:!0}:{}};process.stdout.write(JSON.stringify(I)+`
|
|
581
|
-
`),process.exit(0)}catch(t){ce.handle(t)}})}a(R6,"setPropertyCommand");ct();var Ma=require("path"),zd=require("fs"),CO=ne(We());Rt();Bt();function uge(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ke("Pass --input OR --property, not both.","remove-property <path> --property <name>");if(e){let n;try{n=JSON.parse(r.input)}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`--input: invalid JSON (${o})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>"}');let i=n.property;if(typeof i!="string"||i.trim().length===0)throw new Error("--input.property must be a non-empty string");return i.trim()}if(t){let n=r.property.trim();if(n.length===0)throw new Error("--property must be a non-empty name");return n}throw new Ke("No property provided.",`remove-property <path> --property <name> OR remove-property <path> --input '{"property":"<name>"}'`)}a(uge,"resolveProperty");function C6(){return new
|
|
581
|
+
`),process.exit(0)}catch(t){ce.handle(t)}})}a(R6,"setPropertyCommand");ct();var Ma=require("path"),zd=require("fs"),CO=ne(We());Rt();Bt();function uge(r){let e=r.input!==void 0,t=r.property!==void 0;if(e&&t)throw new Ke("Pass --input OR --property, not both.","remove-property <path> --property <name>");if(e){let n;try{n=JSON.parse(r.input)}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`--input: invalid JSON (${o})`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error('--input must be a JSON object of the form {"property":"<name>"}');let i=n.property;if(typeof i!="string"||i.trim().length===0)throw new Error("--input.property must be a non-empty string");return i.trim()}if(t){let n=r.property.trim();if(n.length===0)throw new Error("--property must be a non-empty name");return n}throw new Ke("No property provided.",`remove-property <path> --property <name> OR remove-property <path> --input '{"property":"<name>"}'`)}a(uge,"resolveProperty");function C6(){return new de("remove-property").description("Delete a non-guarded frontmatter property from an existing vault asset (bumps exo__Asset_updatedAt when a change occurs). The delete-side counterpart of set-property; refuses state-machine-guarded properties (status/zone/parent/label/fact-timestamps) \u2014 those keep their dedicated `apply` commands. Issue #3926.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--input <json>",`JSON {"property":"<name>"} \u2014 the property to remove (symmetric with set-property's --input).`).option("--property <name>","Property name to remove (convenience form; use --input for scripting)").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--force","Remove a guarded property that has NO clearing command (requires --reason). Refused when a clearing command exists \u2014 see req 148ce5a4.").option("--reason <text>","Why the guarded property is being dropped; recorded on stderr as the audit trail of a deliberate bypass").option("--dry-run","Preview the resulting frontmatter without writing").option("--yes","Accepted for symmetry with the apply/create subcommands (remove-property is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,Ma.resolve)(e.vault);if(!(0,zd.existsSync)(t))throw new ke(t);let n=(0,Ma.resolve)(t,r),i=(0,Ma.relative)(t,n);if(i===".."||i.startsWith(`..${Ma.sep}`)||(0,Ma.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,zd.readFileSync)(n,"utf-8")}catch(_){throw _.code==="ENOENT"?new Error(`Target file not found: ${r}`):_}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. remove-property only mutates existing assets.`);let o=uge(e),c=CO.FrontmatterService.normalizeIRI(o),l=xw(Rw,c);if(l!==void 0)throw new Error(`Refusing to remove "${c}" \u2014 ${l}.`);if(Zm(c)!==void 0){let _=A6(c);if(_!==void 0){let T=await new Wd(t).collect();throw new Error(Cw("remove","remove-property",c,Iw(_,T)))}let b=typeof e.reason=="string"?e.reason.trim():"";if(e.force!==!0||b.length===0)throw new Error(I6(c));console.error(`[guard-bypass] remove-property "${c}" on ${i} \u2014 reason: ${b}`)}let f=new CO.FrontmatterService,d=f.removeProperty(s,(0,Jm.canonicalYamlKey)(c)),p=d!==s,h=d,m;if(p){let _=e.frozenClock?new Date(e.frozenClock):new Date,b=e.timezone??$c;m=Uc(_,b),h=f.updateProperty(d,ka,m)}p||await new Mc(t).isUnknownName(c)&&process.stderr.write(`\u26A0\uFE0F Nothing was removed, and "${c}" is not a property in the mounted TBox \u2014 check the spelling (an undeclared property is removable, so this is a hint, not a refusal).
|
|
582
582
|
`),e.dryRun?process.stderr.write(`--- DRY RUN PREVIEW ---
|
|
583
583
|
${h}
|
|
584
584
|
--- END PREVIEW ---
|
|
585
585
|
`):p&&(0,zd.writeFileSync)(n,h,"utf-8");let g={path:i,property:c,removed:p,...m?{updatedAt:m}:{}};process.stdout.write(JSON.stringify(g)+`
|
|
586
|
-
`),process.exit(0)}catch(t){ce.handle(t)}})}a(C6,"removePropertyCommand");ct();var ja=require("path"),Vc=require("fs"),x6=ne(We());Rt();Bt();function fge(r){return new Promise((e,t)=>{let n=[],i=setTimeout(()=>{t(new Error(`Timed out reading body from stdin after ${r}ms`))},r);process.stdin.on("data",s=>n.push(Buffer.from(s))),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(n).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)})})}a(fge,"readStdin");async function dge(r){if(r.bodyFile){if(!(0,Vc.existsSync)(r.bodyFile))throw new Error(`Body file not found: ${r.bodyFile}`);return{text:(0,Vc.readFileSync)(r.bodyFile,"utf-8"),source:"file"}}if(r.body==="-")return{text:await fge(3e4),source:"stdin"};if(r.body!==void 0)return{text:r.body,source:"inline"}}a(dge,"resolveNewBody");function O6(){return new
|
|
586
|
+
`),process.exit(0)}catch(t){ce.handle(t)}})}a(C6,"removePropertyCommand");ct();var ja=require("path"),Vc=require("fs"),x6=ne(We());Rt();Bt();function fge(r){return new Promise((e,t)=>{let n=[],i=setTimeout(()=>{t(new Error(`Timed out reading body from stdin after ${r}ms`))},r);process.stdin.on("data",s=>n.push(Buffer.from(s))),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(n).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)})})}a(fge,"readStdin");async function dge(r){if(r.bodyFile){if(!(0,Vc.existsSync)(r.bodyFile))throw new Error(`Body file not found: ${r.bodyFile}`);return{text:(0,Vc.readFileSync)(r.bodyFile,"utf-8"),source:"file"}}if(r.body==="-")return{text:await fge(3e4),source:"stdin"};if(r.body!==void 0)return{text:r.body,source:"inline"}}a(dge,"resolveNewBody");function O6(){return new de("set-body").description("Overwrite the markdown BODY of an existing vault asset (frontmatter untouched, exo__Asset_updatedAt bumped, new-body wikilinks validated). The dogfood body-rewrite path \u2014 no raw backup\u2192rm\u2192Write. Issue #3943.").argument("<path>","Vault-relative path to the asset to rewrite").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--body-file <path>","Read the new body from a file").option("--body <text>","New body text ('-' reads from stdin)").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--dry-run","Preview the resulting content without writing").option("--skip-wikilink-validation","Skip wikilink existence validation for the new body").action(async(r,e)=>{try{let t=(0,ja.resolve)(e.vault);if(!(0,Vc.existsSync)(t))throw new ke(t);let n=(0,ja.resolve)(t,r),i=(0,ja.relative)(t,n);if(i===".."||i.startsWith(`..${ja.sep}`)||(0,ja.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);if(e.bodyFile===void 0&&e.body===void 0)throw new Error("Provide the new body via --body-file <path>, --body <text>, or --body - (stdin).");let s;try{s=(0,Vc.readFileSync)(n,"utf-8")}catch(T){throw T.code==="ENOENT"?new Error(`Target file not found: ${r}`):T}if(!/^\s*exo__Asset_uid:/m.test(s))throw new Error(`Not a vault asset (no exo__Asset_uid): ${i}. set-body only rewrites existing assets.`);let o=new x6.FrontmatterService,c=o.parse(s);if(!c.exists)throw new Error(`No frontmatter block found in ${i}; set-body preserves the frontmatter and only rewrites the body.`);let l=`---
|
|
587
587
|
${c.content}
|
|
588
588
|
---`,u=await dge(e),f=u?.text??"";u?.source==="inline"&&(f=f.replace(/\\n/g,`
|
|
589
589
|
`)),e.skipWikilinkValidation||await new kc(new li(t)).validateValue(f);let d=f.length>0?f.endsWith(`
|
|
@@ -596,24 +596,24 @@ ${_}
|
|
|
596
596
|
`),process.exit(0)}catch(t){ce.handle(t)}})}a(O6,"setBodyCommand");ct();var $a=require("path"),Kd=require("fs"),eg=ne(We());Rt();Bt();function pge(r){let e=new eg.FrontmatterService,t=e.parseObject(r);if(!t)return{changed:!1,content:r,canonicalized:[]};let n=r,i=[];for(let[s,o]of eg.LEGACY_YAML_KEYS){let c=o.find(u=>Object.prototype.hasOwnProperty.call(t,u));if(c===void 0)continue;let l=Object.prototype.hasOwnProperty.call(t,s)?t[s]:t[c];n=e.updateProperty(n,s,l),i.push({from:c,to:s})}return{changed:i.length>0,content:n,canonicalized:i}}a(pge,"canonicalizeLegacyKeys");var hge=/^([^\s#][^:]*):(?:\s.*)?$/;function mge(r){let e=r.match(/^(---\r?\n)([\s\S]*?)(\r?\n---)/);if(!e)return{changed:!1,content:r,removed:[]};let[,t,n,i]=e,s=t.includes(`\r
|
|
597
597
|
`)?`\r
|
|
598
598
|
`:`
|
|
599
|
-
`,o=n.split(/\r?\n/),c=[];for(let m of o){let g=hge.exec(m);g?c.push({key:g[1],lines:[m]}):c.length>0?c[c.length-1].lines.push(m):c.push({key:null,lines:[m]})}let l=new Map,u=new Map;c.forEach((m,g)=>{m.key!==null&&(l.set(m.key,(l.get(m.key)??0)+1),u.set(m.key,g))});let f=new Map,d=c.filter((m,g)=>m.key===null||(l.get(m.key)??0)<=1||g===u.get(m.key)?!0:(f.set(m.key,(f.get(m.key)??0)+1),!1));if(f.size===0)return{changed:!1,content:r,removed:[]};let p=d.map(m=>m.lines.join(s)).join(s);return{changed:!0,content:`${t}${p}${i}`+r.slice(e[0].length),removed:[...f.entries()].map(([m,g])=>({key:m,removedOccurrences:g}))}}a(mge,"dedupeFrontmatterKeys");function gge(r,e){let t=a(c=>{let l=c.match(/^---\r?\n([\s\S]*?)\r?\n---/);return l?l[1].split(/\r?\n/):[]},"block"),n=t(r),i=t(e),s=new Set(i),o=new Set(n);return[...n.filter(c=>!s.has(c)).map(c=>`- ${c}`),...i.filter(c=>!o.has(c)).map(c=>`+ ${c}`)]}a(gge,"frontmatterLineDiff");function P6(){return new
|
|
599
|
+
`,o=n.split(/\r?\n/),c=[];for(let m of o){let g=hge.exec(m);g?c.push({key:g[1],lines:[m]}):c.length>0?c[c.length-1].lines.push(m):c.push({key:null,lines:[m]})}let l=new Map,u=new Map;c.forEach((m,g)=>{m.key!==null&&(l.set(m.key,(l.get(m.key)??0)+1),u.set(m.key,g))});let f=new Map,d=c.filter((m,g)=>m.key===null||(l.get(m.key)??0)<=1||g===u.get(m.key)?!0:(f.set(m.key,(f.get(m.key)??0)+1),!1));if(f.size===0)return{changed:!1,content:r,removed:[]};let p=d.map(m=>m.lines.join(s)).join(s);return{changed:!0,content:`${t}${p}${i}`+r.slice(e[0].length),removed:[...f.entries()].map(([m,g])=>({key:m,removedOccurrences:g}))}}a(mge,"dedupeFrontmatterKeys");function gge(r,e){let t=a(c=>{let l=c.match(/^---\r?\n([\s\S]*?)\r?\n---/);return l?l[1].split(/\r?\n/):[]},"block"),n=t(r),i=t(e),s=new Set(i),o=new Set(n);return[...n.filter(c=>!s.has(c)).map(c=>`- ${c}`),...i.filter(c=>!o.has(c)).map(c=>`+ ${c}`)]}a(gge,"frontmatterLineDiff");function P6(){return new de("repair-frontmatter").description("Remove duplicated top-level YAML frontmatter keys (keep-last) \u2014 the dogfood-clean repair for the invisible/unrepairable duplicate-key class (#3800). Operates on raw text, so it fixes a file the parser itself cannot read. With --canonicalize-keys also rewrites legacy physical keys to their TBox-declared spelling (bare `archived:` \u2192 `exo__Asset_archived:`, req 960d7a3f) and bumps exo__Asset_updatedAt.").argument("<path>","Vault-relative path to the target asset").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--dry-run","Preview the dedupe diff without writing").option("--canonicalize-keys","Rewrite legacy physical keys to their canonical spelling (bare `archived:` \u2192 `exo__Asset_archived:`); value preserved, exo__Asset_updatedAt bumped; idempotent").option("--timezone <tz>","Timezone for the exo__Asset_updatedAt bump (defaults to Asia/Almaty)").option("--frozen-clock <iso>","Freeze the updatedAt clock to an ISO timestamp for test/replay").option("--yes","Accepted for symmetry with the apply/create subcommands (repair-frontmatter is non-interactive; no-op)").action(async(r,e)=>{try{let t=(0,$a.resolve)(e.vault);if(!(0,Kd.existsSync)(t))throw new ke(t);let n=(0,$a.resolve)(t,r),i=(0,$a.relative)(t,n);if(i===".."||i.startsWith(`..${$a.sep}`)||(0,$a.isAbsolute)(i))throw new Error(`Target is outside the vault: ${r} (vault: ${t})`);let s;try{s=(0,Kd.readFileSync)(n,"utf-8")}catch(d){throw d.code==="ENOENT"?new Error(`Target file not found: ${r}`):d}let o=mge(s),c=o.content,l=[],u;if(e.canonicalizeKeys){let d=pge(c);if(l=d.canonicalized,d.changed){let p=e.frozenClock?new Date(e.frozenClock):new Date;u=Uc(p,e.timezone??$c),c=new eg.FrontmatterService().updateProperty(d.content,ka,u)}}if(!(o.changed||l.length>0)){process.stdout.write(JSON.stringify({path:i,changed:!1,dryRun:!!e.dryRun,removed:[],...e.canonicalizeKeys?{canonicalized:[]}:{}})+`
|
|
600
600
|
`);return}e.dryRun||(0,Kd.writeFileSync)(n,c,"utf-8"),process.stdout.write(JSON.stringify({path:i,changed:!0,dryRun:!!e.dryRun,removed:o.removed,...e.canonicalizeKeys?{canonicalized:l}:{},...u?{updatedAt:u}:{},...e.dryRun?{diff:gge(s,c)}:{}})+`
|
|
601
|
-
`)}catch(t){ce.handle(t)}})}a(P6,"repairFrontmatterCommand");ct();var D6=require("fs"),F6=require("path"),cs=ne(We());Vi();Rt();Bt();gr();lw();var yge="https://exocortex.my/ontology/find#Alias_sparql",_ge="https://exocortex.my/ontology/exo#Asset_label";function Yd(r){if(r&&typeof r=="object"&&"value"in r){let e=r.value;return typeof e=="string"?e:String(e)}return String(r)}a(Yd,"nodeValue");async function bge(r,e){let t=await r.match(void 0,void 0,void 0),n=[];for(let s of t)Yd(s.predicate)!==_ge||Yd(s.object)!==e||n.push(Yd(s.subject));if(n.length===0)return null;let i=[];for(let s of n)for(let o of t)Yd(o.predicate)===yge&&Yd(o.subject)===s&&i.push(Yd(o.object));if(i.length===0)return null;if(i.length>1)throw new Ke(`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(bge,"resolveAliasFragment");var Sge=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,wge="https://exocortex.my/ontology/";function Ege(r,e){let t=Sge.exec(e);if(t){let i=`<${wge}${t[1]}#${t[2]}>`;return r.replace(/\?value\b/g,i)}let n=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return r.replace(/\?value\b/g,`"${n}"`)}a(Ege,"bindValueLiteral");function L6(){return new
|
|
601
|
+
`)}catch(t){ce.handle(t)}})}a(P6,"repairFrontmatterCommand");ct();var D6=require("fs"),F6=require("path"),cs=ne(We());Vi();Rt();Bt();gr();lw();var yge="https://exocortex.my/ontology/find#Alias_sparql",_ge="https://exocortex.my/ontology/exo#Asset_label";function Yd(r){if(r&&typeof r=="object"&&"value"in r){let e=r.value;return typeof e=="string"?e:String(e)}return String(r)}a(Yd,"nodeValue");async function bge(r,e){let t=await r.match(void 0,void 0,void 0),n=[];for(let s of t)Yd(s.predicate)!==_ge||Yd(s.object)!==e||n.push(Yd(s.subject));if(n.length===0)return null;let i=[];for(let s of n)for(let o of t)Yd(o.predicate)===yge&&Yd(o.subject)===s&&i.push(Yd(o.object));if(i.length===0)return null;if(i.length>1)throw new Ke(`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(bge,"resolveAliasFragment");var Sge=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,wge="https://exocortex.my/ontology/";function Ege(r,e){let t=Sge.exec(e);if(t){let i=`<${wge}${t[1]}#${t[2]}>`;return r.replace(/\?value\b/g,i)}let n=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return r.replace(/\?value\b/g,`"${n}"`)}a(Ege,"bindValueLiteral");function L6(){return new de("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("--sparql <query>","SPARQL SELECT query (must bind ?path)").option("--class <value>","Filter by class label via find__Alias 'class' (e.g. ems__Task)").action(async r=>{ce.setFormat("text");try{if(r.sparql&&r.class)throw new Ke("--sparql and --class are mutually exclusive","Pass either a raw --sparql query or a find__Alias-backed flag like --class");if(!r.sparql&&!r.class)throw new Ke("one of --sparql <query> or --class <value> is required",'exocortex find --class ems__Task OR exocortex find --sparql "SELECT ?path WHERE { ... }"');let e=(0,F6.resolve)(r.vault);if(!(0,D6.existsSync)(e))throw new ke(e);let t=new Ut(e),i=await new cs.NoteToRDFConverter(t).convertVault(),s=new cs.InMemoryTripleStore;await s.addAll(i);let o;if(r.class){let _=await bge(s,"class");if(_===null)throw new Ke('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");o=`SELECT ?path WHERE { ${Ege(_,r.class)} }`}else o=r.sparql;let c=aw(o);c=Ud(c);let l=new cs.ExoQLParser,u=cw(ow(e));u.size>0&&l.setVaultPrefixes(u);let f=l.parse(c),p=new cs.ExoQLAlgebraTranslator().translate(f);p.type!=="construct"&&(p=new cs.AlgebraOptimizer().optimize(p));let m=await new cs.ExoQLQueryExecutor(s).executeAll(p),g="obsidian://vault/";for(let _ of m){let T=_.toJSON().path;if(typeof T!="string"||!T.startsWith(g))continue;let I=T.slice(g.length),w;try{w=decodeURIComponent(I)}catch{w=I}process.stdout.write(w+`
|
|
602
602
|
`)}}catch(e){ce.handle(e),process.exit(5)}})}a(L6,"findCommand");ct();var DO=require("fs"),Va=require("path"),Pe=ne(We());Rt();Bt();gr();Vi();var B6=ne(We()),zt=ne(j6());var $6="obsidian://vault/";function qge(r){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 n=t;if(n.startsWith($6))n=decodeURI(n.slice($6.length));else if(e.test(n)){let i=await r.findFileByUID(n);if(!i)throw new Error(`No vault file found for UID: ${n}`);n=i}if(n.endsWith(".md")||(n=`${n}.md`),!await r.fileExists(n))throw new Error(`Cannot resolve target file for IRI "${t}" (tried "${n}")`);return n}}}a(qge,"createCliPathResolver");var Wge=["openFile","sparqlSelect","getActiveFileIRI","getActiveFilePath","trashFile","duplicateFile"],PO=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 U6(r){return{async execute(){throw new PO(r)}}}a(U6,"notImplementedService");function Hge(r){return e=>{let t=r.getFirstLinkpathDest(e,"");if(!t||!("basename"in t))return null;let i=r.getFrontmatter(t)?.exo__Asset_label;return typeof i=="string"&&i.length>0?i:null}}a(Hge,"createCliClassResolver");function V6(r,e){for(let t of Wge)r.register(t,U6(t));for(let t of["updateProperty","removeProperty","setStatus","createAsset"])r.register(t,U6(t));if(e){if(e.fsAdapter){let t=new B6.FrontmatterService,n=qge(e.fsAdapter);r.register("updateProperty",(0,zt.createUpdatePropertyService)(e.fsAdapter,t,n)),r.register("removeProperty",(0,zt.createRemovePropertyService)(e.fsAdapter,t,n)),r.register("setStatus",(0,zt.createSetStatusService)(e.fsAdapter,t,n)),r.register("createAsset",(0,zt.createCreateAssetService)(e.vaultAdapter,e.fsAdapter,Hge(e.vaultAdapter))),r.register("instantiatePrototypeSubtree",(0,zt.createInstantiatePrototypeSubtreeService)(e.vaultAdapter,e.fsAdapter))}r.register("createRelatedTask",(0,zt.createCreateRelatedTaskService)(e.vaultAdapter,e.genericAssetCreationService)),r.register("createRelatedProject",(0,zt.createCreateRelatedProjectService)(e.vaultAdapter,e.genericAssetCreationService)),r.register("archiveAsset",(0,zt.createArchiveAssetService)(e.vaultAdapter,e.archiveAssetService)),r.register("planForEvening",(0,zt.createPlanForEveningService)(e.vaultAdapter,e.taskStatusService)),r.register("cleanProperties",(0,zt.createCleanPropertiesService)(e.vaultAdapter,e.propertyCleanupService)),r.register("renameToUid",(0,zt.createRenameToUidService)(e.vaultAdapter,e.renameToUidService)),r.register("repairFolder",(0,zt.createRepairFolderService)(e.vaultAdapter,e.folderRepairService)),r.register("fixMissingLabel",(0,zt.createFixMissingLabelService)(e.vaultAdapter,e.fixMissingLabelService))}}a(V6,"populateCliServiceRegistry");function zge(r,e){let t=r.getAbstractFileByPath(e),n=t!==null&&"basename"in t?t:null,i=n?r.getFrontmatter(n):null,s=i&&typeof i=="object"?i.exo__Asset_label:void 0;return{uuid:n?.basename??e.replace(/^.*\//,"").replace(/\.md$/,""),path:e,label:typeof s=="string"?s:""}}a(zge,"buildCreatedAsset");var Kge=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function Yge(){if(process.stdin.isTTY)return[];let r=[];for await(let t of process.stdin)r.push(t);return Buffer.concat(r).toString("utf-8").split(`
|
|
603
|
-
`).map(t=>t.trim()).filter(t=>t.length>0)}a(Yge,"readStdinLines");function Dw(r){if(r&&typeof r=="object"&&"value"in r){let e=r.value;return typeof e=="string"?e:String(e)}return String(r)}a(Dw,"nodeValue");async function Qge(r,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),n=await r.match(void 0,t,void 0),i=[];for(let s of n)if(Dw(s.object)===e){let l=Dw(s.subject).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i);l&&i.push(l[1])}if(i.length===0)return null;if(i.length>1)throw new Ke(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}a(Qge,"resolveSlugToUuid");async function Xge(r,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),n=await r.match(void 0,t,void 0);for(let i of n)if(Dw(i.subject).includes(e)){let o=Dw(i.object);if(o==="true"||o==="True")return!0}return!1}a(Xge,"isDestructive");async function Jge(r,e,t,n,i,s,o,c){let l={ok:!1,created:[]},u=(0,Va.resolve)(r,i);if(!(0,DO.existsSync)(u))return console.error(`\u274C Target file not found: ${i}`),l;let f=(0,Va.relative)(r,u);if(f===".."||f.startsWith(`..${Va.sep}`)||(0,Va.isAbsolute)(f))return console.error(`\u274C Target is outside the vault: ${i} (vault: ${r})`),l;let d=new Pe.CommandResolver(e,hw),p=await d.loadCommand(n);if(!p)return console.error(`\u274C Command with UID "${n}" not found.`),l;if(await Xge(e,n)&&!s.dryRun&&!s.yes)return console.error(`\u274C Command "${p.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),l;let m=(0,Pe.vaultPathToIRI)(f),g=new Ut(r),_=new Pe.FolderRepairService(g),b=new Pe.PreconditionEvaluator(e,void 0,{clock:o});(0,Pe.registerDefaultHostFunctions)(b),b.registerHostFunction("isInWrongFolder",fw(g,_)),b.registerHostFunction("hasObsoleteProperties",dw(g));let T=g.getAbstractFileByPath(f),I=T!==null&&"basename"in T?T:null,w=I?g.getFrontmatter(I):null,S=w&&typeof w=="object"?w.exo__Asset_uid:void 0,R={targetIRI:m,filePath:f,fileBasename:I?.basename,assetUid:typeof S=="string"?S:void 0};if(!await b.evaluate(p.precondition,m,R))return console.error(`\u274C Precondition not satisfied for "${p.name}" on "${f}".`),l;if(s.dryRun)return s.json||console.log(`\u{1F50D} Dry-run: would apply "${p.name}" to "${f}" (precondition passed).`),{ok:!0,created:[]};let P=new Pe.ServiceRegistry,M=new Pe.GenericAssetCreationService(g).withDeterminism({clock:o,uidGenerator:c}),O=new Pe.ArchiveAssetService(g),F=new Pe.PropertyCleanupService(g),Z=new Pe.FixMissingLabelService(g),J=new Pe.RenameToUidService(g),U=new Pe.TaskStatusService(g,new Pe.EffortStatusWorkflow,new Pe.StatusTimestampService(g)),K=new li(r);V6(P,{vaultAdapter:g,fsAdapter:K,genericAssetCreationService:M,archiveAssetService:O,taskStatusService:U,propertyCleanupService:F,fixMissingLabelService:Z,renameToUidService:J,folderRepairService:_});let _e=new Pe.NamedQueryRunner(new Vd(e,K),e),le=new Pe.GroundingExecutor(K,K,P,(0,Pe.createVaultFrontmatterClassLabelResolver)(K),{clock:o,uidGenerator:c,workflowResolver:t,groundingLoader:a(oe=>d.loadGroundingByUid(oe),"groundingLoader"),templateLoader:a(async oe=>{let xe=await K.findFileByUID(oe);return xe?(0,Pe.stripTemplateFrontmatter)(await K.readFile(xe)):null},"templateLoader"),namedQueryRunner:_e,refToFolder:(0,Pe.createVaultFrontmatterRefToFolderResolver)(K),refToFrontmatter:(0,Pe.createVaultFrontmatterRefToFrontmatterResolver)(K)}),W;if(s.input)try{let oe=JSON.parse(s.input);if(typeof oe!="object"||oe===null||Array.isArray(oe))throw new Error("must be a JSON object");W=oe}catch(oe){let xe=oe instanceof Error?oe.message:String(oe);return console.error(`\u274C --input: invalid JSON object (${xe})`),l}let H=await le.execute(p.grounding,m,f,W);if(H.success){let oe=[];H.openPath&&oe.push(H.openPath),H.createdPaths&&oe.push(...H.createdPaths);let xe=[],re=new Set;for(let Q of oe)re.has(Q)||(re.add(Q),xe.push(zge(g,Q)));if(!s.json){let Q=p.successMessage??`Applied "${p.name}" to "${f}".`,ie=H.openPath??H.createdPaths?.[0],Y=ie?` \u2192 ${ie}`:"";console.log(`\u2705 ${Q}${Y}`)}return{ok:!0,created:xe}}else return console.error(`\u274C "${p.name}" failed on "${f}": ${H.error}`),l}a(Jge,"executeOnTarget");function G6(){return new
|
|
603
|
+
`).map(t=>t.trim()).filter(t=>t.length>0)}a(Yge,"readStdinLines");function Dw(r){if(r&&typeof r=="object"&&"value"in r){let e=r.value;return typeof e=="string"?e:String(e)}return String(r)}a(Dw,"nodeValue");async function Qge(r,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),n=await r.match(void 0,t,void 0),i=[];for(let s of n)if(Dw(s.object)===e){let l=Dw(s.subject).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i);l&&i.push(l[1])}if(i.length===0)return null;if(i.length>1)throw new Ke(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}a(Qge,"resolveSlugToUuid");async function Xge(r,e){let t=new Pe.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),n=await r.match(void 0,t,void 0);for(let i of n)if(Dw(i.subject).includes(e)){let o=Dw(i.object);if(o==="true"||o==="True")return!0}return!1}a(Xge,"isDestructive");async function Jge(r,e,t,n,i,s,o,c){let l={ok:!1,created:[]},u=(0,Va.resolve)(r,i);if(!(0,DO.existsSync)(u))return console.error(`\u274C Target file not found: ${i}`),l;let f=(0,Va.relative)(r,u);if(f===".."||f.startsWith(`..${Va.sep}`)||(0,Va.isAbsolute)(f))return console.error(`\u274C Target is outside the vault: ${i} (vault: ${r})`),l;let d=new Pe.CommandResolver(e,hw),p=await d.loadCommand(n);if(!p)return console.error(`\u274C Command with UID "${n}" not found.`),l;if(await Xge(e,n)&&!s.dryRun&&!s.yes)return console.error(`\u274C Command "${p.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),l;let m=(0,Pe.vaultPathToIRI)(f),g=new Ut(r),_=new Pe.FolderRepairService(g),b=new Pe.PreconditionEvaluator(e,void 0,{clock:o});(0,Pe.registerDefaultHostFunctions)(b),b.registerHostFunction("isInWrongFolder",fw(g,_)),b.registerHostFunction("hasObsoleteProperties",dw(g));let T=g.getAbstractFileByPath(f),I=T!==null&&"basename"in T?T:null,w=I?g.getFrontmatter(I):null,S=w&&typeof w=="object"?w.exo__Asset_uid:void 0,R={targetIRI:m,filePath:f,fileBasename:I?.basename,assetUid:typeof S=="string"?S:void 0};if(!await b.evaluate(p.precondition,m,R))return console.error(`\u274C Precondition not satisfied for "${p.name}" on "${f}".`),l;if(s.dryRun)return s.json||console.log(`\u{1F50D} Dry-run: would apply "${p.name}" to "${f}" (precondition passed).`),{ok:!0,created:[]};let P=new Pe.ServiceRegistry,M=new Pe.GenericAssetCreationService(g).withDeterminism({clock:o,uidGenerator:c}),O=new Pe.ArchiveAssetService(g),F=new Pe.PropertyCleanupService(g),Z=new Pe.FixMissingLabelService(g),J=new Pe.RenameToUidService(g),U=new Pe.TaskStatusService(g,new Pe.EffortStatusWorkflow,new Pe.StatusTimestampService(g)),K=new li(r);V6(P,{vaultAdapter:g,fsAdapter:K,genericAssetCreationService:M,archiveAssetService:O,taskStatusService:U,propertyCleanupService:F,fixMissingLabelService:Z,renameToUidService:J,folderRepairService:_});let _e=new Pe.NamedQueryRunner(new Vd(e,K),e),le=new Pe.GroundingExecutor(K,K,P,(0,Pe.createVaultFrontmatterClassLabelResolver)(K),{clock:o,uidGenerator:c,workflowResolver:t,groundingLoader:a(oe=>d.loadGroundingByUid(oe),"groundingLoader"),templateLoader:a(async oe=>{let xe=await K.findFileByUID(oe);return xe?(0,Pe.stripTemplateFrontmatter)(await K.readFile(xe)):null},"templateLoader"),namedQueryRunner:_e,refToFolder:(0,Pe.createVaultFrontmatterRefToFolderResolver)(K),refToFrontmatter:(0,Pe.createVaultFrontmatterRefToFrontmatterResolver)(K)}),W;if(s.input)try{let oe=JSON.parse(s.input);if(typeof oe!="object"||oe===null||Array.isArray(oe))throw new Error("must be a JSON object");W=oe}catch(oe){let xe=oe instanceof Error?oe.message:String(oe);return console.error(`\u274C --input: invalid JSON object (${xe})`),l}let H=await le.execute(p.grounding,m,f,W);if(H.success){let oe=[];H.openPath&&oe.push(H.openPath),H.createdPaths&&oe.push(...H.createdPaths);let xe=[],re=new Set;for(let Q of oe)re.has(Q)||(re.add(Q),xe.push(zge(g,Q)));if(!s.json){let Q=p.successMessage??`Applied "${p.name}" to "${f}".`,ie=H.openPath??H.createdPaths?.[0],Y=ie?` \u2192 ${ie}`:"";console.log(`\u2705 ${Q}${Y}`)}return{ok:!0,created:xe}}else return console.error(`\u274C "${p.name}" failed on "${f}": ${H.error}`),l}a(Jge,"executeOnTarget");function G6(){return new de("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 a grounding. Value-setting commands need a value key, e.g. set-planned-start / set-scheduled-date: --input '{"value":"<ISO>"}'; set-label: --input '{"value":"New label"}'. Asset-reference inputs (set-parent: --input '{"parent":"<uid>"}'; set-blocker: --input '{"blocker":"<uid>"}') take a BARE uid; a copied [[uid]] or [[uid|alias]] is accepted and unwrapped, anything else that still looks like a link is refused. The required key is named in the error if omitted.`).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)").option("--json","Emit a machine-readable JSON result ({command,target,created:[{uuid,path,label}]}) instead of human-readable output").action(async(r,e,t)=>{ce.setFormat("text");try{let n=(0,Va.resolve)(t.vault);if(!(0,DO.existsSync)(n))throw new ke(n);Ew(n);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 Ut(n),l=await new Pe.NoteToRDFConverter(o).convertVault(),u=new Pe.InMemoryTripleStore;await u.addAll(l);let f=new Pe.WorkflowResolver(u),d;if(Kge.test(r))d=r;else{let _=await Qge(u,r);_||(console.error(`\u274C No command found with UUID or cliName "${r}".`),process.exit(3)),d=_}let p;if(e)p=[e];else if(p=await Yge(),p.length===0)throw new Ke("No target path provided and stdin is empty.","exocortex apply <uuid> <path> OR exocortex find ... | exocortex apply <uuid>");let h=0,m=0,g=[];for(let _ of p){let b=await Jge(n,u,f,d,_,t,i,s);b.ok?h++:m++,g.push(...b.created)}if(p.length>1&&!t.json&&console.log(`
|
|
604
604
|
\u{1F4CA} Applied to ${h}/${p.length} target(s) (${m} failed).`),t.json){let _={command:r,created:g};e?_.target=e:_.targets=p,process.stdout.write(JSON.stringify(_)+`
|
|
605
|
-
`)}m>0&&process.exit(5)}catch(n){ce.handle(n),process.exit(5)}})}a(G6,"applyCommand");ct();ct();var Jd=require("fs"),jO=require("path"),Uw=ne(We());var Fw=ne(Ca()),Lw=ne(require("path")),Gc=ne(We()),kw=ne(We());var Zge=Gc.SDK_FLOOR_ASSETSPACE_UIDS,du="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb",FO="3de846cd-1f0e-4f98-8613-b8587aa15174",eye=5,Nw=class{static{a(this,"CliProfileResolver")}constructor(e){this.vaultPaths=[Lw.default.resolve(e.vaultPath)],this.maxExtendsDepth=e.maxExtendsDepth??eye,this.warn=e.warn??(()=>{})}async resolveFilter(e){if(e==null||e==="")return{outcome:"no-profile"};let t;try{t=await this.scanAllVaults()}catch(f){let d=`[CliProfileResolver] vault scan threw \u2014 ${String(f)}`;return this.warn(d),{outcome:"error",reason:d}}if(t.profiles.get(e)===void 0)return this.warn(`[CliProfileResolver] 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(f){let d=`[CliProfileResolver] profile chain walk threw \u2014 ${String(f)}`;return this.warn(d),{outcome:"error",reason:d}}let s=(0,Gc.transitiveDependsOnClosure)(i,t.dependsOn),o=new Set(t.folderMap.values()),c=new Set,l=[];for(let f of s){if(o.has(f)){c.add(f);continue}l.push(f)}for(let f of Zge)c.add(f);if(!Array.from(c).some(f=>o.has(f))){let f=`[CliProfileResolver] profileUid=${e} produced effective set with zero AssetSpace folder overlap (${c.size} AS UIDs incl. floor; ${t.folderMap.size} folders known). Likely cause: profile declares AssetSpace UIDs not present as descriptors, or vault has no scanned AssetSpaces. Falling back to no-filter (full vault indexed).`;return this.warn(f),{outcome:"degraded",reason:f}}return{outcome:"engaged",result:{effective:c,folderMap:t.folderMap,declaredOntologies:s,untranslated:l}}}walkProfileChain(e,t,n,i,s){if(s>this.maxExtendsDepth)throw new Error(`Profile 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 c of o.includes)n.add(c);typeof o.extends=="string"&&o.extends.length>0&&this.walkProfileChain(o.extends,t,n,i,s+1)}}async scanAllVaults(){let e=new Map,t=new Map,n=new Map;for(let i of this.vaultPaths){if(!await Fw.default.pathExists(i)){this.warn(`[CliProfileResolver] vault path does not exist: ${i} \u2014 skipping.`);continue}let s=await this.walkVault(i);for(let o of s){let c=Wi(o.frontmatter.exo__Instance_class);if(c.some(l=>l===du)){let l=rye(o.filePath,o.vaultRoot);l.length>0&&!e.has(l)&&e.set(l,o.uid);let u=typeof o.frontmatter.exo__AssetSpace_source=="string"?o.frontmatter.exo__AssetSpace_source:typeof o.frontmatter.exo__AssetSpace_git=="string"?o.frontmatter.exo__AssetSpace_git:"";if(u.length>0){let d=(0,Gc.derivePath)(u);d!==null&&e.set(d,o.uid)}let f=Wi(o.frontmatter.exo__AssetSpace_dependsOn);f.length>0&&n.set(o.uid,f)}if(c.some(l=>l===FO)){let l={uid:o.uid,label:typeof o.frontmatter.exo__Asset_label=="string"?o.frontmatter.exo__Asset_label:void 0,includes:Wi(o.frontmatter.exo__Profile_includes),extends:Wi(o.frontmatter.exo__Profile_imports)[0]??null};t.set(o.uid,l)}}}return{folderMap:e,profiles:t,dependsOn:n}}async walkVault(e){let t=[],n=[e];for(;n.length>0;){let i=n.pop(),s;try{s=await Fw.default.readdir(i,{withFileTypes:!0})}catch{continue}for(let o of s){let c=Lw.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules"||o.name===".obsidian"||o.name===".exocortex")continue;n.push(c);continue}if(!o.isFile()||!o.name.endsWith(".md"))continue;let l=await this.tryReadFrontmatter(c);if(l===null)continue;let u=l.exo__Asset_uid;typeof u!="string"||u.length===0||t.push({uid:u,filePath:c,vaultRoot:e,frontmatter:l})}}return t}async tryReadFrontmatter(e){let t;try{t=await Fw.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,Gc.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Wi(r){if(r==null)return[];let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=tye(n);i!==null&&t.push(i)}return t}a(Wi,"parseWikilinkArray");function tye(r){let e=r.trim().replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0].trim();return e.length===0?null:e}a(tye,"extractUidFromWikilink");function rye(r,e){let t=Lw.default.relative(e,r).replace(/\\/g,"/");if(!t.startsWith("assetspaces/"))return"";let n=t.slice(12),i=n.indexOf("/");return i<0?"":`assetspaces/${n.slice(0,i)}`}a(rye,"parentFolderRelative");var Mw=ne(Ca()),LO=ne(require("path")),Xd=ne(We());var jw=class{static{a(this,"RegistryDependencyResolver")}constructor(e={}){this.warn=e.warn??(()=>{})}async resolve(e,t){let n=await this.scanRegistry(e),i=this.matchSelf(n,t);if(i===null)return{outcome:"self-not-found",selfIdentifier:t,descriptorCount:n.size};let s=new Map;for(let g of n.values())g.dependsOn.length>0&&s.set(g.uid,g.dependsOn);let o=(0,Xd.transitiveDependsOnClosure)([i.uid],s);o.delete(i.uid);let c=[],l=new Set,u=new Set([i.uid]),f=[...i.dependsOn];for(;f.length>0;){let g=f.shift();if(g===void 0||u.has(g))continue;u.add(g),o.has(g)&&!l.has(g)&&(c.push(g),l.add(g));let _=n.get(g);if(_!==void 0)for(let b of _.dependsOn)u.has(b)||f.push(b)}for(let g of o)l.has(g)||(c.push(g),l.add(g));let d=[],p=[];for(let g of c){let _=n.get(g);_===void 0?p.push(g):d.push(_)}let h=d.filter(g=>g.source===null||g.source.length===0),m=d.filter(g=>g.source!==null&&g.source.length>0&&!nye(g.source));return{outcome:"resolved",self:i,dependencies:d,missingDescriptors:p,sourceless:h,unsafeSources:m}}matchSelf(e,t){let n=Qd(t);if(n!==null)for(let i of e.values()){if(i.source===null)continue;let s=Qd(i.source);if(s!==null&&s===n)return i}for(let i of e.values())if(i.namespace!==null&&i.namespace===t)return i;return null}async scanRegistry(e){let t=new Map,n=LO.default.resolve(e);if(!await Mw.default.pathExists(n))return this.warn(`[RegistryDependencyResolver] registry path does not exist: ${n}`),t;let i=[n];for(;i.length>0;){let s=i.pop(),o;try{o=await Mw.default.readdir(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=LO.default.join(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||c.name==="node_modules"||c.name===".obsidian"||c.name===".exocortex")continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=await this.tryReadFrontmatter(l);if(u===null||!Wi(u.exo__Instance_class).some(g=>g===du))continue;let d=u.exo__Asset_uid;if(typeof d!="string"||d.length===0)continue;let p=typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:null,h=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:null,m=Wi(u.exo__AssetSpace_dependsOn);t.has(d)&&this.warn(`[RegistryDependencyResolver] duplicate AssetSpace descriptor for uid=${d} \u2014 last wins (${l})`),t.set(d,{uid:d,namespace:h,source:p,dependsOn:m})}}return t}async tryReadFrontmatter(e){let t;try{t=await Mw.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,Xd.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Qd(r){let e=r.trim();if(e.length===0)return null;let t=(0,Xd.derivePath)(e);if(t!==null)return t.replace(/^assetspaces\//,"").toLowerCase();if(!e.includes("://")&&!e.includes("@")){let i=e.replace(/\.git$/i,"").replace(/\/+$/,"").split("/").filter(s=>s.length>0);if(i.length===2)return`${i[0]}/${i[1]}`.toLowerCase()}return null}a(Qd,"ownerRepoSlug");function nye(r){return typeof r!="string"||r.length===0||/[\s\x00-\x1f]/.test(r)||r.startsWith("-")||/^(ext|file|fd|ftp|ftps)::/i.test(r)?!1:!!(/^https?:\/\/[^\s]+$/i.test(r)||/^ssh:\/\/[^\s]+$/i.test(r)||/^git:\/\/[^\s]+$/i.test(r)||/^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+:[^\s]+$/.test(r))}a(nye,"isSafeCloneUrl");var iye=new Set(["templates","09 templates"]);function fi(r){return r.split("/").some(e=>iye.has(e.toLowerCase()))}a(fi,"isTemplatesPath");function Hi(r){return r.split("/").includes("node_modules")}a(Hi,"isNodeModulesPath");Rt();Bt();var H6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,sye=/^[A-Za-z][A-Za-z0-9-]*__[A-Za-z0-9_-]+$/,oye=/^assetspaces\/([^/]+)\/([^/]+)\//,z6=["exo__Ontology_imports","exo__Ontology_admits","exo__Property_range","exo__Property_domain","exo__Class_superClass","exo__Property_superProperty","exo__Property_cardinality","exo__Property_minCount"],aye="e1d7fb5c-d334-448d-935b-953b7b033e78",cye="fe529085-5370-4ac0-bbe4-1c7351242dee",lye=5,NO=200;function $w(r){let e=oye.exec(r.replace(/\\/g,"/"));return e?`${e[1]}/${e[2]}`.toLowerCase():null}a($w,"assetspaceOfPath");var MO=class{constructor(){this.assets=[];this.uidToPath=new Map;this.pathSet=new Set;this.labelToPaths=new Map;this.basenameToPaths=new Map}static{a(this,"VaultIndex")}add(e){let t=e.path.replace(/\\/g,"/");this.assets.push({...e,path:t}),this.pathSet.add(t);let n=e.metadata.exo__Asset_uid;for(let c of Array.isArray(n)?n:[n])if(typeof c=="string"){let l=c.trim().toLowerCase();l.length>0&&!this.uidToPath.has(l)&&this.uidToPath.set(l,t)}let i=t.slice(t.lastIndexOf("/")+1).replace(/\.md$/,"");kO(this.basenameToPaths,i,t);let s=e.metadata.exo__Asset_label;typeof s=="string"&&s.trim().length>0&&kO(this.labelToPaths,s.trim(),t);let o=e.metadata.aliases;for(let c of Array.isArray(o)?o:[o])typeof c=="string"&&c.trim().length>0&&kO(this.labelToPaths,c.trim(),t)}resolve(e){let t=this.candidates(e);return t.length===0?null:t.length===1?t[0]:"ambiguous"}candidates(e){let t=e;if(H6.test(t)){let i=this.uidToPath.get(t.toLowerCase());return i===void 0?[]:[i]}if(t.includes("/")){let i=t.replace(/^\//,""),s=i.endsWith(".md")?i:`${i}.md`;if(this.pathSet.has(s))return[s];t=i.slice(i.lastIndexOf("/")+1)}t.endsWith(".md")&&(t=t.slice(0,-3));let n=this.distinctByUid(this.labelToPaths.get(t));return n.length>0?n:this.distinctByUid(this.basenameToPaths.get(t))}distinctByUid(e){if(!e||e.size===0)return[];let t=new Set,n=[];for(let i of e){let s=this.assets.find(l=>l.path===i),o=s?s.metadata.exo__Asset_uid:void 0,c=typeof o=="string"?o.trim().toLowerCase():`path:${i}`;t.has(c)||(t.add(c),n.push(i))}return n}};function kO(r,e,t){let n=r.get(e);n?n.add(t):r.set(e,new Set([t]))}a(kO,"addTo");function rg(r){if(Array.isArray(r)){let e=r.find(t=>typeof t=="string");return typeof e=="string"?e:null}return typeof r=="string"?r:null}a(rg,"firstString");function uye(r){let e=Wi(r);if(e.length===0)return"unkinded";let t=e[0].toLowerCase();return t===aye?"TBox":t===cye?"Reference":"unknown"}a(uye,"kindOf");function fye(r){return r==null?0:(Array.isArray(r)?r:[r]).filter(t=>typeof t=="object"&&t!==null).length}a(fye,"countStructuredItems");function dye(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=n.trim().replace(/^["']|["']$/g,""),s=i.startsWith("[[")&&i.endsWith("]]"),o=(0,Uw.extractAssetReference)(i);if(!o)continue;let c=o.split("#")[0].trim();c.length!==0&&(s||H6.test(c)||sye.test(c))&&t.push(c)}return t}a(dye,"referencesOf");function q6(r){let e=new Map;for(let t of r){if(Hi(t.path)||fi(t.path)||!Wi(t.metadata.exo__Instance_class).some(c=>c.toLowerCase()===du))continue;let i=rg(t.metadata.exo__Asset_uid);if(!i)continue;let s=i.trim().toLowerCase();if(e.has(s))continue;let o=rg(t.metadata.exo__AssetSpace_source)??rg(t.metadata.exo__AssetSpace_git);e.set(s,{uid:s,slug:o?Qd(o):null,label:rg(t.metadata.exo__Asset_label)??t.path,path:t.path,dependsOn:Wi(t.metadata.exo__AssetSpace_dependsOn).map(c=>c.toLowerCase()),kind:uye(t.metadata.exo__AssetSpace_dependsOnKind)})}return e}a(q6,"collectDescriptors");async function pye(r){let e=new MO,t=new Set,n=new Tn(r.vault,{cacheContent:!1});for(let D of await n.indexedAssets()){if(Hi(D.path)||fi(D.path))continue;let z=rg(D.metadata.exo__Asset_uid),se=z?z.trim().toLowerCase():`path:${D.path}`;t.has(se)||(t.add(se),e.add(D))}let i,s;if(r.registry){let D=new Tn(r.registry,{cacheContent:!1});s=q6(await D.indexedAssets()),i=r.registry}else s=q6(e.assets),i="vault";let o=new Map,c=[],l=new Map;for(let D of s.values()){if(D.slug===null){c.push(D.label);continue}o.set(D.uid,D.slug);let z=l.get(D.slug);z?z.push(D.uid):l.set(D.slug,[D.uid])}let u=[...l.entries()].filter(([,D])=>D.length>1).map(([D,z])=>({slug:D,uids:z})),f=new Map;for(let D of s.values())D.slug&&f.set(D.slug,D.kind);let d=new Map,p=[],h=0,m=new Set;for(let D of s.values())if(D.slug!==null)for(let z of D.dependsOn){let se=o.get(z);if(se===void 0){p.push({source:D.slug,ref:z});continue}if(se===D.slug)continue;let be=d.get(D.slug);be||(be=[],d.set(D.slug,be)),be.includes(se)||(be.push(se),h++,m.add(se))}let g=null;r.self!==void 0&&(g=Qd(r.self),g===null&&(g=r.self.trim().toLowerCase()));let _=new Map,b=a(D=>{let z=_.get(D);if(z!==void 0)return z;let se=(0,Uw.transitiveDependsOnClosure)([D],d);return _.set(D,se),se},"closureOf"),T=r.missingDeps??[];if(T.length>0&&g===null)throw new Ke("--missing-dep / --missing-deps-file require --self: in vault mode unresolved refs are already fail-open, so the inputs would be a silent no-op","Pass --self <owner/repo> (the per-repo CI mode) together with the missing deps");let I=[...new Set(T.map(D=>Qd(D)??D.trim().toLowerCase()).filter(D=>D.length>0&&D!==g))].sort(),w=g!==null?b(g):new Set,S=new Set;for(let D of e.assets){let z=$w(D.path);z!==null&&S.add(z)}let R=I.filter(D=>S.has(D)),L=I.filter(D=>w.has(D)&&!S.has(D)),P=I.filter(D=>!w.has(D)&&!S.has(D)),M=r.strictUnresolved===!0,O=g!==null&&!M&&L.length>0,F=new Map,Z=[],J=0,U=[],K=0,_e=0,le=0,W=[],H=0,oe=0,xe=0,re=0;for(let D of e.assets){let z=$w(D.path);if(z!==null&&!(g!==null&&z!==g)){xe++;for(let se of z6){let be=D.metadata[se],Re=fye(be);Re>0&&(H+=Re,W.length<NO&&W.push({sourcePath:D.path,predicate:se}));let Be=dye(be);for(let De of Be){let Fe=e.candidates(De);if(Fe.length===0){J++,Z.length<NO&&Z.push({source:z,sourcePath:D.path,predicate:se,ref:De,reason:"not-found"});continue}if(Fe.length>1){let nt=[...new Set(Fe.map(x=>$w(x)??"<outside assetspaces/>"))].sort(),et=b(z),C=nt.every(x=>x===z||et.has(x));K++,C?_e++:le++,U.length<NO&&U.push({source:z,sourcePath:D.path,predicate:se,ref:De,candidates:nt,coveredByClosure:C});continue}let Ve=Fe[0],Ce=$w(Ve);if(Ce===null){oe++;continue}if(Ce===z)continue;re++;let je=`${z} ${Ce}`,Ze=F.get(je);Ze||(Ze={source:z,target:Ce,occurrences:0,predicates:{},examples:[],coveredDirect:d.get(z)?.includes(Ce)??!1,coveredByClosure:b(z).has(Ce)},F.set(je,Ze)),Ze.occurrences++,Ze.predicates[se]=(Ze.predicates[se]??0)+1,Ze.examples.length<lye&&Ze.examples.push(`${D.path} --${se}--> ${De}`)}}}}let Q=[...F.values()].sort((D,z)=>Number(D.coveredByClosure)-Number(z.coveredByClosure)||Number(D.coveredDirect)-Number(z.coveredDirect)||D.source.localeCompare(z.source)||D.target.localeCompare(z.target)),ie=Q.filter(D=>D.coveredByClosure).length,Y=Q.filter(D=>!D.coveredDirect).length,ae=g!==null,Me=g!==null&&!O,N=O?J:0,ue=Q.filter(D=>!D.coveredByClosure).length+(ae?le:0)+(Me?J:0),de=new Set(Q.map(D=>`${D.source} ${D.target}`)),Ie=[],we={TBox:0,unkinded:0,unknown:0},ve=0;for(let[D,z]of d)if(!(g!==null&&D!==g))for(let se of z){let be=f.get(se)??"unknown";if(be==="Reference"){ve++;continue}let Re=de.has(`${D} ${se}`);Re||(Ie.push({source:D,target:se,targetKind:be,hasFact:Re}),we[be]++)}Ie.sort((D,z)=>D.source.localeCompare(z.source)||D.target.localeCompare(z.target));let Ae=[...m].filter(D=>(f.get(D)??"unknown")==="unkinded").sort(),pe,V=null;return s.size===0?(pe="BROKEN",V=`no exo__AssetSpace descriptor found (registry: ${i}) \u2014 nothing to judge against`):g!==null&&!l.has(g)?(pe="BROKEN",V=`--self '${r.self}' (${g}) is not a registered AssetSpace (${s.size} descriptor(s) scanned)`):g!==null&&xe===0?(pe="BROKEN",V=`--self '${g}': no asset under assetspaces/${g}/ in the vault \u2014 the self content was not merged`):g===null&&Q.length===0?(pe="BROKEN",V="zero definition-tier cross-AssetSpace fact edges \u2014 an empty population cannot be declared covered"):pe=ue===0?"OK":"FAIL",{vaultPath:r.vault,registrySource:i,self:g,verdict:pe,brokenReason:V,descriptors:{count:s.size,sourceless:c,duplicateSlugs:u,declaredEdgeCount:h,carriers:d.size,targets:m.size,danglingDeclarations:p},facts:{edgeCount:Q.length,occurrences:re,sources:new Set(Q.map(D=>D.source)).size,targets:new Set(Q.map(D=>D.target)).size,coveredByClosure:ie,uncoveredDirect:Y,uncoveredByClosure:ue,edges:Q},unresolved:{count:J,countedAsUncovered:Me,excusedWhileDepsMissing:N,refs:Z},degraded:{active:O,strict:M,missingDeps:I,missingDepsInClosure:L,missingDepsOutsideClosure:P,missingDepsPresentInVault:R,unresolvedExcused:N},ambiguous:{count:K,coveredByClosure:_e,uncovered:le,countedAsUncovered:ae,refs:U},nonStringValues:{count:H,sites:W},targetsOutsideAssetspaces:oe,scannedSources:xe,declaredWithoutFact:{total:Ie.length,byKind:we,edges:Ie},packaging:ve,targetsWithoutKind:Ae,clean:pe==="OK"}}a(pye,"scanAssetSpaceDepends");function hye(r){return Object.entries(r).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>`${e.replace(/^exo__/,"")}\xD7${t}`).join(", ")}a(hye,"formatPredicates");function mye(r){let e=r.verdict==="OK"?console.log:console.error,n=`[${r.vaultPath.replace(/\/+$/,"").split("/").pop()??r.vaultPath}${r.self?`, self=${r.self}`:""}, tier=definitions]`,i=r.degraded.active?` (DEGRADED: declared deps absent from merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:"";e(`${r.verdict}${i} ${r.vaultPath}: assetspace-depends audit ${n} \u2014 uncovered by CLOSURE: ${r.facts.uncoveredByClosure} (verdict), uncovered DIRECTLY: ${r.facts.uncoveredDirect} (informational, not a criterion), ambiguous refs: ${r.ambiguous.count} (covered ${r.ambiguous.coveredByClosure} / uncovered ${r.ambiguous.uncovered}${r.ambiguous.countedAsUncovered?", counted in the verdict":", listed only"}), non-string values under definition-tier predicates: ${r.nonStringValues.count} (skipped, not judged)`),r.brokenReason&&e(`\u26D4 BROKEN: ${r.brokenReason}`),e(`Registry (${r.registrySource}): ${r.descriptors.count} descriptor(s), declared dependsOn edges: ${r.descriptors.declaredEdgeCount} (carriers ${r.descriptors.carriers} \u2192 targets ${r.descriptors.targets}), dangling: ${r.descriptors.danglingDeclarations.length}, sourceless: ${r.descriptors.sourceless.length}, duplicate owner/repo: ${r.descriptors.duplicateSlugs.length}`),e(`Facts (definition tier, ${z6.length} predicates): ${r.facts.edgeCount} cross-AssetSpace edge(s) / ${r.facts.occurrences} occurrence(s) (sources ${r.facts.sources} \u2192 targets ${r.facts.targets}, scanned ${r.scannedSources} source asset(s)); canary covered-by-closure = ${r.facts.coveredByClosure}`);let s=r.degraded.active?`(--self, DEGRADED: NOT counted \u2014 declared deps absent from the merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:r.unresolved.countedAsUncovered?r.degraded.strict&&r.degraded.missingDeps.length>0?`(--self --strict-unresolved: counted as uncovered despite declared missing deps ${r.degraded.missingDeps.join(", ")})`:"(--self: counted as uncovered \u2014 target absent from the merged vault)":"(fail-open, listed, NOT counted \u2014 validate-wikilinks territory)";e(`Unresolved definition-tier refs: ${r.unresolved.count} ${s}; targets outside assetspaces/: ${r.targetsOutsideAssetspaces}`),r.degraded.active&&e(`\u26A0 unresolved refs excused: ${r.degraded.unresolvedExcused} \u2014 may include refs into undeclared absent AssetSpaces; coverage NOT proven for them (DEGRADED \u2260 proven coverage)`),r.degraded.missingDepsOutsideClosure.length>0&&e(`\u26A0 --missing-dep outside closure(self) \u2014 excuses nothing: ${r.degraded.missingDepsOutsideClosure.join(", ")}`),r.degraded.missingDepsPresentInVault.length>0&&e(`\u26A0 --missing-dep named but PRESENT in the vault (assets found under its assetspaces/ folder) \u2014 ignored, excuses nothing: ${r.degraded.missingDepsPresentInVault.join(", ")}`),e(`Declared without a definition-tier fact (one-sided, never a violation; Reference-kind targets excluded): ${r.declaredWithoutFact.total} \u2014 TBox: ${r.declaredWithoutFact.byKind.TBox}, unkinded: ${r.declaredWithoutFact.byKind.unkinded}, unknown-kind: ${r.declaredWithoutFact.byKind.unknown}; packaging declarations (Reference-kind targets, frame p.4): ${r.packaging}`),e(`Declared targets without exo__AssetSpace_dependsOnKind: ${r.targetsWithoutKind.length}`+(r.targetsWithoutKind.length>0?` \u2014 ${r.targetsWithoutKind.join(", ")}`:"")),e("Declared-graph cycles are NOT judged by this verb (dependsOn = packaging, RFC 306dcb5c frame p.1); facts-graph acyclicity is the scheduled detector's job.");let o=r.facts.edges.filter(l=>!l.coveredByClosure);if(o.length>0){console.error(`
|
|
605
|
+
`)}m>0&&process.exit(5)}catch(n){ce.handle(n),process.exit(5)}})}a(G6,"applyCommand");ct();ct();var Jd=require("fs"),jO=require("path"),Uw=ne(We());var Fw=ne(Ca()),Lw=ne(require("path")),Gc=ne(We()),kw=ne(We());var Zge=Gc.SDK_FLOOR_ASSETSPACE_UIDS,du="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb",FO="3de846cd-1f0e-4f98-8613-b8587aa15174",eye=5,Nw=class{static{a(this,"CliProfileResolver")}constructor(e){this.vaultPaths=[Lw.default.resolve(e.vaultPath)],this.maxExtendsDepth=e.maxExtendsDepth??eye,this.warn=e.warn??(()=>{})}async resolveFilter(e){if(e==null||e==="")return{outcome:"no-profile"};let t;try{t=await this.scanAllVaults()}catch(f){let d=`[CliProfileResolver] vault scan threw \u2014 ${String(f)}`;return this.warn(d),{outcome:"error",reason:d}}if(t.profiles.get(e)===void 0)return this.warn(`[CliProfileResolver] 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(f){let d=`[CliProfileResolver] profile chain walk threw \u2014 ${String(f)}`;return this.warn(d),{outcome:"error",reason:d}}let s=(0,Gc.transitiveDependsOnClosure)(i,t.dependsOn),o=new Set(t.folderMap.values()),c=new Set,l=[];for(let f of s){if(o.has(f)){c.add(f);continue}l.push(f)}for(let f of Zge)c.add(f);if(!Array.from(c).some(f=>o.has(f))){let f=`[CliProfileResolver] profileUid=${e} produced effective set with zero AssetSpace folder overlap (${c.size} AS UIDs incl. floor; ${t.folderMap.size} folders known). Likely cause: profile declares AssetSpace UIDs not present as descriptors, or vault has no scanned AssetSpaces. Falling back to no-filter (full vault indexed).`;return this.warn(f),{outcome:"degraded",reason:f}}return{outcome:"engaged",result:{effective:c,folderMap:t.folderMap,declaredOntologies:s,untranslated:l}}}walkProfileChain(e,t,n,i,s){if(s>this.maxExtendsDepth)throw new Error(`Profile 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 c of o.includes)n.add(c);typeof o.extends=="string"&&o.extends.length>0&&this.walkProfileChain(o.extends,t,n,i,s+1)}}async scanAllVaults(){let e=new Map,t=new Map,n=new Map;for(let i of this.vaultPaths){if(!await Fw.default.pathExists(i)){this.warn(`[CliProfileResolver] vault path does not exist: ${i} \u2014 skipping.`);continue}let s=await this.walkVault(i);for(let o of s){let c=Wi(o.frontmatter.exo__Instance_class);if(c.some(l=>l===du)){let l=rye(o.filePath,o.vaultRoot);l.length>0&&!e.has(l)&&e.set(l,o.uid);let u=typeof o.frontmatter.exo__AssetSpace_source=="string"?o.frontmatter.exo__AssetSpace_source:typeof o.frontmatter.exo__AssetSpace_git=="string"?o.frontmatter.exo__AssetSpace_git:"";if(u.length>0){let d=(0,Gc.derivePath)(u);d!==null&&e.set(d,o.uid)}let f=Wi(o.frontmatter.exo__AssetSpace_dependsOn);f.length>0&&n.set(o.uid,f)}if(c.some(l=>l===FO)){let l={uid:o.uid,label:typeof o.frontmatter.exo__Asset_label=="string"?o.frontmatter.exo__Asset_label:void 0,includes:Wi(o.frontmatter.exo__Profile_includes),extends:Wi(o.frontmatter.exo__Profile_imports)[0]??null};t.set(o.uid,l)}}}return{folderMap:e,profiles:t,dependsOn:n}}async walkVault(e){let t=[],n=[e];for(;n.length>0;){let i=n.pop(),s;try{s=await Fw.default.readdir(i,{withFileTypes:!0})}catch{continue}for(let o of s){let c=Lw.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules"||o.name===".obsidian"||o.name===".exocortex")continue;n.push(c);continue}if(!o.isFile()||!o.name.endsWith(".md"))continue;let l=await this.tryReadFrontmatter(c);if(l===null)continue;let u=l.exo__Asset_uid;typeof u!="string"||u.length===0||t.push({uid:u,filePath:c,vaultRoot:e,frontmatter:l})}}return t}async tryReadFrontmatter(e){let t;try{t=await Fw.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,Gc.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Wi(r){if(r==null)return[];let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=tye(n);i!==null&&t.push(i)}return t}a(Wi,"parseWikilinkArray");function tye(r){let e=r.trim().replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0].trim();return e.length===0?null:e}a(tye,"extractUidFromWikilink");function rye(r,e){let t=Lw.default.relative(e,r).replace(/\\/g,"/");if(!t.startsWith("assetspaces/"))return"";let n=t.slice(12),i=n.indexOf("/");return i<0?"":`assetspaces/${n.slice(0,i)}`}a(rye,"parentFolderRelative");var Mw=ne(Ca()),LO=ne(require("path")),Xd=ne(We());var jw=class{static{a(this,"RegistryDependencyResolver")}constructor(e={}){this.warn=e.warn??(()=>{})}async resolve(e,t){let n=await this.scanRegistry(e),i=this.matchSelf(n,t);if(i===null)return{outcome:"self-not-found",selfIdentifier:t,descriptorCount:n.size};let s=new Map;for(let g of n.values())g.dependsOn.length>0&&s.set(g.uid,g.dependsOn);let o=(0,Xd.transitiveDependsOnClosure)([i.uid],s);o.delete(i.uid);let c=[],l=new Set,u=new Set([i.uid]),f=[...i.dependsOn];for(;f.length>0;){let g=f.shift();if(g===void 0||u.has(g))continue;u.add(g),o.has(g)&&!l.has(g)&&(c.push(g),l.add(g));let _=n.get(g);if(_!==void 0)for(let b of _.dependsOn)u.has(b)||f.push(b)}for(let g of o)l.has(g)||(c.push(g),l.add(g));let d=[],p=[];for(let g of c){let _=n.get(g);_===void 0?p.push(g):d.push(_)}let h=d.filter(g=>g.source===null||g.source.length===0),m=d.filter(g=>g.source!==null&&g.source.length>0&&!nye(g.source));return{outcome:"resolved",self:i,dependencies:d,missingDescriptors:p,sourceless:h,unsafeSources:m}}matchSelf(e,t){let n=Qd(t);if(n!==null)for(let i of e.values()){if(i.source===null)continue;let s=Qd(i.source);if(s!==null&&s===n)return i}for(let i of e.values())if(i.namespace!==null&&i.namespace===t)return i;return null}async scanRegistry(e){let t=new Map,n=LO.default.resolve(e);if(!await Mw.default.pathExists(n))return this.warn(`[RegistryDependencyResolver] registry path does not exist: ${n}`),t;let i=[n];for(;i.length>0;){let s=i.pop(),o;try{o=await Mw.default.readdir(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=LO.default.join(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||c.name==="node_modules"||c.name===".obsidian"||c.name===".exocortex")continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=await this.tryReadFrontmatter(l);if(u===null||!Wi(u.exo__Instance_class).some(g=>g===du))continue;let d=u.exo__Asset_uid;if(typeof d!="string"||d.length===0)continue;let p=typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:null,h=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:null,m=Wi(u.exo__AssetSpace_dependsOn);t.has(d)&&this.warn(`[RegistryDependencyResolver] duplicate AssetSpace descriptor for uid=${d} \u2014 last wins (${l})`),t.set(d,{uid:d,namespace:h,source:p,dependsOn:m})}}return t}async tryReadFrontmatter(e){let t;try{t=await Mw.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,Xd.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Qd(r){let e=r.trim();if(e.length===0)return null;let t=(0,Xd.derivePath)(e);if(t!==null)return t.replace(/^assetspaces\//,"").toLowerCase();if(!e.includes("://")&&!e.includes("@")){let i=e.replace(/\.git$/i,"").replace(/\/+$/,"").split("/").filter(s=>s.length>0);if(i.length===2)return`${i[0]}/${i[1]}`.toLowerCase()}return null}a(Qd,"ownerRepoSlug");function nye(r){return typeof r!="string"||r.length===0||/[\s\x00-\x1f]/.test(r)||r.startsWith("-")||/^(ext|file|fd|ftp|ftps)::/i.test(r)?!1:!!(/^https?:\/\/[^\s]+$/i.test(r)||/^ssh:\/\/[^\s]+$/i.test(r)||/^git:\/\/[^\s]+$/i.test(r)||/^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+:[^\s]+$/.test(r))}a(nye,"isSafeCloneUrl");var iye=new Set(["templates","09 templates"]);function fi(r){return r.split("/").some(e=>iye.has(e.toLowerCase()))}a(fi,"isTemplatesPath");function Hi(r){return r.split("/").includes("node_modules")}a(Hi,"isNodeModulesPath");Rt();Bt();var H6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,sye=/^[A-Za-z][A-Za-z0-9-]*__[A-Za-z0-9_-]+$/,oye=/^assetspaces\/([^/]+)\/([^/]+)\//,z6=["exo__Ontology_imports","exo__Ontology_admits","exo__Property_range","exo__Property_domain","exo__Class_superClass","exo__Property_superProperty","exo__Property_cardinality","exo__Property_minCount"],aye="e1d7fb5c-d334-448d-935b-953b7b033e78",cye="fe529085-5370-4ac0-bbe4-1c7351242dee",lye=5,NO=200;function $w(r){let e=oye.exec(r.replace(/\\/g,"/"));return e?`${e[1]}/${e[2]}`.toLowerCase():null}a($w,"assetspaceOfPath");var MO=class{constructor(){this.assets=[];this.uidToPath=new Map;this.pathSet=new Set;this.labelToPaths=new Map;this.basenameToPaths=new Map}static{a(this,"VaultIndex")}add(e){let t=e.path.replace(/\\/g,"/");this.assets.push({...e,path:t}),this.pathSet.add(t);let n=e.metadata.exo__Asset_uid;for(let c of Array.isArray(n)?n:[n])if(typeof c=="string"){let l=c.trim().toLowerCase();l.length>0&&!this.uidToPath.has(l)&&this.uidToPath.set(l,t)}let i=t.slice(t.lastIndexOf("/")+1).replace(/\.md$/,"");kO(this.basenameToPaths,i,t);let s=e.metadata.exo__Asset_label;typeof s=="string"&&s.trim().length>0&&kO(this.labelToPaths,s.trim(),t);let o=e.metadata.aliases;for(let c of Array.isArray(o)?o:[o])typeof c=="string"&&c.trim().length>0&&kO(this.labelToPaths,c.trim(),t)}resolve(e){let t=this.candidates(e);return t.length===0?null:t.length===1?t[0]:"ambiguous"}candidates(e){let t=e;if(H6.test(t)){let i=this.uidToPath.get(t.toLowerCase());return i===void 0?[]:[i]}if(t.includes("/")){let i=t.replace(/^\//,""),s=i.endsWith(".md")?i:`${i}.md`;if(this.pathSet.has(s))return[s];t=i.slice(i.lastIndexOf("/")+1)}t.endsWith(".md")&&(t=t.slice(0,-3));let n=this.distinctByUid(this.labelToPaths.get(t));return n.length>0?n:this.distinctByUid(this.basenameToPaths.get(t))}distinctByUid(e){if(!e||e.size===0)return[];let t=new Set,n=[];for(let i of e){let s=this.assets.find(l=>l.path===i),o=s?s.metadata.exo__Asset_uid:void 0,c=typeof o=="string"?o.trim().toLowerCase():`path:${i}`;t.has(c)||(t.add(c),n.push(i))}return n}};function kO(r,e,t){let n=r.get(e);n?n.add(t):r.set(e,new Set([t]))}a(kO,"addTo");function rg(r){if(Array.isArray(r)){let e=r.find(t=>typeof t=="string");return typeof e=="string"?e:null}return typeof r=="string"?r:null}a(rg,"firstString");function uye(r){let e=Wi(r);if(e.length===0)return"unkinded";let t=e[0].toLowerCase();return t===aye?"TBox":t===cye?"Reference":"unknown"}a(uye,"kindOf");function fye(r){return r==null?0:(Array.isArray(r)?r:[r]).filter(t=>typeof t=="object"&&t!==null).length}a(fye,"countStructuredItems");function dye(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=n.trim().replace(/^["']|["']$/g,""),s=i.startsWith("[[")&&i.endsWith("]]"),o=(0,Uw.extractAssetReference)(i);if(!o)continue;let c=o.split("#")[0].trim();c.length!==0&&(s||H6.test(c)||sye.test(c))&&t.push(c)}return t}a(dye,"referencesOf");function q6(r){let e=new Map;for(let t of r){if(Hi(t.path)||fi(t.path)||!Wi(t.metadata.exo__Instance_class).some(c=>c.toLowerCase()===du))continue;let i=rg(t.metadata.exo__Asset_uid);if(!i)continue;let s=i.trim().toLowerCase();if(e.has(s))continue;let o=rg(t.metadata.exo__AssetSpace_source)??rg(t.metadata.exo__AssetSpace_git);e.set(s,{uid:s,slug:o?Qd(o):null,label:rg(t.metadata.exo__Asset_label)??t.path,path:t.path,dependsOn:Wi(t.metadata.exo__AssetSpace_dependsOn).map(c=>c.toLowerCase()),kind:uye(t.metadata.exo__AssetSpace_dependsOnKind)})}return e}a(q6,"collectDescriptors");async function pye(r){let e=new MO,t=new Set,n=new Tn(r.vault,{cacheContent:!1});for(let D of await n.indexedAssets()){if(Hi(D.path)||fi(D.path))continue;let z=rg(D.metadata.exo__Asset_uid),se=z?z.trim().toLowerCase():`path:${D.path}`;t.has(se)||(t.add(se),e.add(D))}let i,s;if(r.registry){let D=new Tn(r.registry,{cacheContent:!1});s=q6(await D.indexedAssets()),i=r.registry}else s=q6(e.assets),i="vault";let o=new Map,c=[],l=new Map;for(let D of s.values()){if(D.slug===null){c.push(D.label);continue}o.set(D.uid,D.slug);let z=l.get(D.slug);z?z.push(D.uid):l.set(D.slug,[D.uid])}let u=[...l.entries()].filter(([,D])=>D.length>1).map(([D,z])=>({slug:D,uids:z})),f=new Map;for(let D of s.values())D.slug&&f.set(D.slug,D.kind);let d=new Map,p=[],h=0,m=new Set;for(let D of s.values())if(D.slug!==null)for(let z of D.dependsOn){let se=o.get(z);if(se===void 0){p.push({source:D.slug,ref:z});continue}if(se===D.slug)continue;let be=d.get(D.slug);be||(be=[],d.set(D.slug,be)),be.includes(se)||(be.push(se),h++,m.add(se))}let g=null;r.self!==void 0&&(g=Qd(r.self),g===null&&(g=r.self.trim().toLowerCase()));let _=new Map,b=a(D=>{let z=_.get(D);if(z!==void 0)return z;let se=(0,Uw.transitiveDependsOnClosure)([D],d);return _.set(D,se),se},"closureOf"),T=r.missingDeps??[];if(T.length>0&&g===null)throw new Ke("--missing-dep / --missing-deps-file require --self: in vault mode unresolved refs are already fail-open, so the inputs would be a silent no-op","Pass --self <owner/repo> (the per-repo CI mode) together with the missing deps");let I=[...new Set(T.map(D=>Qd(D)??D.trim().toLowerCase()).filter(D=>D.length>0&&D!==g))].sort(),w=g!==null?b(g):new Set,S=new Set;for(let D of e.assets){let z=$w(D.path);z!==null&&S.add(z)}let R=I.filter(D=>S.has(D)),L=I.filter(D=>w.has(D)&&!S.has(D)),P=I.filter(D=>!w.has(D)&&!S.has(D)),M=r.strictUnresolved===!0,O=g!==null&&!M&&L.length>0,F=new Map,Z=[],J=0,U=[],K=0,_e=0,le=0,W=[],H=0,oe=0,xe=0,re=0;for(let D of e.assets){let z=$w(D.path);if(z!==null&&!(g!==null&&z!==g)){xe++;for(let se of z6){let be=D.metadata[se],Re=fye(be);Re>0&&(H+=Re,W.length<NO&&W.push({sourcePath:D.path,predicate:se}));let Be=dye(be);for(let De of Be){let Fe=e.candidates(De);if(Fe.length===0){J++,Z.length<NO&&Z.push({source:z,sourcePath:D.path,predicate:se,ref:De,reason:"not-found"});continue}if(Fe.length>1){let nt=[...new Set(Fe.map(x=>$w(x)??"<outside assetspaces/>"))].sort(),et=b(z),C=nt.every(x=>x===z||et.has(x));K++,C?_e++:le++,U.length<NO&&U.push({source:z,sourcePath:D.path,predicate:se,ref:De,candidates:nt,coveredByClosure:C});continue}let Ve=Fe[0],Ce=$w(Ve);if(Ce===null){oe++;continue}if(Ce===z)continue;re++;let je=`${z} ${Ce}`,Ze=F.get(je);Ze||(Ze={source:z,target:Ce,occurrences:0,predicates:{},examples:[],coveredDirect:d.get(z)?.includes(Ce)??!1,coveredByClosure:b(z).has(Ce)},F.set(je,Ze)),Ze.occurrences++,Ze.predicates[se]=(Ze.predicates[se]??0)+1,Ze.examples.length<lye&&Ze.examples.push(`${D.path} --${se}--> ${De}`)}}}}let Q=[...F.values()].sort((D,z)=>Number(D.coveredByClosure)-Number(z.coveredByClosure)||Number(D.coveredDirect)-Number(z.coveredDirect)||D.source.localeCompare(z.source)||D.target.localeCompare(z.target)),ie=Q.filter(D=>D.coveredByClosure).length,Y=Q.filter(D=>!D.coveredDirect).length,ae=g!==null,Me=g!==null&&!O,N=O?J:0,ue=Q.filter(D=>!D.coveredByClosure).length+(ae?le:0)+(Me?J:0),fe=new Set(Q.map(D=>`${D.source} ${D.target}`)),Ie=[],we={TBox:0,unkinded:0,unknown:0},ve=0;for(let[D,z]of d)if(!(g!==null&&D!==g))for(let se of z){let be=f.get(se)??"unknown";if(be==="Reference"){ve++;continue}let Re=fe.has(`${D} ${se}`);Re||(Ie.push({source:D,target:se,targetKind:be,hasFact:Re}),we[be]++)}Ie.sort((D,z)=>D.source.localeCompare(z.source)||D.target.localeCompare(z.target));let Ae=[...m].filter(D=>(f.get(D)??"unknown")==="unkinded").sort(),pe,V=null;return s.size===0?(pe="BROKEN",V=`no exo__AssetSpace descriptor found (registry: ${i}) \u2014 nothing to judge against`):g!==null&&!l.has(g)?(pe="BROKEN",V=`--self '${r.self}' (${g}) is not a registered AssetSpace (${s.size} descriptor(s) scanned)`):g!==null&&xe===0?(pe="BROKEN",V=`--self '${g}': no asset under assetspaces/${g}/ in the vault \u2014 the self content was not merged`):g===null&&Q.length===0?(pe="BROKEN",V="zero definition-tier cross-AssetSpace fact edges \u2014 an empty population cannot be declared covered"):pe=ue===0?"OK":"FAIL",{vaultPath:r.vault,registrySource:i,self:g,verdict:pe,brokenReason:V,descriptors:{count:s.size,sourceless:c,duplicateSlugs:u,declaredEdgeCount:h,carriers:d.size,targets:m.size,danglingDeclarations:p},facts:{edgeCount:Q.length,occurrences:re,sources:new Set(Q.map(D=>D.source)).size,targets:new Set(Q.map(D=>D.target)).size,coveredByClosure:ie,uncoveredDirect:Y,uncoveredByClosure:ue,edges:Q},unresolved:{count:J,countedAsUncovered:Me,excusedWhileDepsMissing:N,refs:Z},degraded:{active:O,strict:M,missingDeps:I,missingDepsInClosure:L,missingDepsOutsideClosure:P,missingDepsPresentInVault:R,unresolvedExcused:N},ambiguous:{count:K,coveredByClosure:_e,uncovered:le,countedAsUncovered:ae,refs:U},nonStringValues:{count:H,sites:W},targetsOutsideAssetspaces:oe,scannedSources:xe,declaredWithoutFact:{total:Ie.length,byKind:we,edges:Ie},packaging:ve,targetsWithoutKind:Ae,clean:pe==="OK"}}a(pye,"scanAssetSpaceDepends");function hye(r){return Object.entries(r).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>`${e.replace(/^exo__/,"")}\xD7${t}`).join(", ")}a(hye,"formatPredicates");function mye(r){let e=r.verdict==="OK"?console.log:console.error,n=`[${r.vaultPath.replace(/\/+$/,"").split("/").pop()??r.vaultPath}${r.self?`, self=${r.self}`:""}, tier=definitions]`,i=r.degraded.active?` (DEGRADED: declared deps absent from merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:"";e(`${r.verdict}${i} ${r.vaultPath}: assetspace-depends audit ${n} \u2014 uncovered by CLOSURE: ${r.facts.uncoveredByClosure} (verdict), uncovered DIRECTLY: ${r.facts.uncoveredDirect} (informational, not a criterion), ambiguous refs: ${r.ambiguous.count} (covered ${r.ambiguous.coveredByClosure} / uncovered ${r.ambiguous.uncovered}${r.ambiguous.countedAsUncovered?", counted in the verdict":", listed only"}), non-string values under definition-tier predicates: ${r.nonStringValues.count} (skipped, not judged)`),r.brokenReason&&e(`\u26D4 BROKEN: ${r.brokenReason}`),e(`Registry (${r.registrySource}): ${r.descriptors.count} descriptor(s), declared dependsOn edges: ${r.descriptors.declaredEdgeCount} (carriers ${r.descriptors.carriers} \u2192 targets ${r.descriptors.targets}), dangling: ${r.descriptors.danglingDeclarations.length}, sourceless: ${r.descriptors.sourceless.length}, duplicate owner/repo: ${r.descriptors.duplicateSlugs.length}`),e(`Facts (definition tier, ${z6.length} predicates): ${r.facts.edgeCount} cross-AssetSpace edge(s) / ${r.facts.occurrences} occurrence(s) (sources ${r.facts.sources} \u2192 targets ${r.facts.targets}, scanned ${r.scannedSources} source asset(s)); canary covered-by-closure = ${r.facts.coveredByClosure}`);let s=r.degraded.active?`(--self, DEGRADED: NOT counted \u2014 declared deps absent from the merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:r.unresolved.countedAsUncovered?r.degraded.strict&&r.degraded.missingDeps.length>0?`(--self --strict-unresolved: counted as uncovered despite declared missing deps ${r.degraded.missingDeps.join(", ")})`:"(--self: counted as uncovered \u2014 target absent from the merged vault)":"(fail-open, listed, NOT counted \u2014 validate-wikilinks territory)";e(`Unresolved definition-tier refs: ${r.unresolved.count} ${s}; targets outside assetspaces/: ${r.targetsOutsideAssetspaces}`),r.degraded.active&&e(`\u26A0 unresolved refs excused: ${r.degraded.unresolvedExcused} \u2014 may include refs into undeclared absent AssetSpaces; coverage NOT proven for them (DEGRADED \u2260 proven coverage)`),r.degraded.missingDepsOutsideClosure.length>0&&e(`\u26A0 --missing-dep outside closure(self) \u2014 excuses nothing: ${r.degraded.missingDepsOutsideClosure.join(", ")}`),r.degraded.missingDepsPresentInVault.length>0&&e(`\u26A0 --missing-dep named but PRESENT in the vault (assets found under its assetspaces/ folder) \u2014 ignored, excuses nothing: ${r.degraded.missingDepsPresentInVault.join(", ")}`),e(`Declared without a definition-tier fact (one-sided, never a violation; Reference-kind targets excluded): ${r.declaredWithoutFact.total} \u2014 TBox: ${r.declaredWithoutFact.byKind.TBox}, unkinded: ${r.declaredWithoutFact.byKind.unkinded}, unknown-kind: ${r.declaredWithoutFact.byKind.unknown}; packaging declarations (Reference-kind targets, frame p.4): ${r.packaging}`),e(`Declared targets without exo__AssetSpace_dependsOnKind: ${r.targetsWithoutKind.length}`+(r.targetsWithoutKind.length>0?` \u2014 ${r.targetsWithoutKind.join(", ")}`:"")),e("Declared-graph cycles are NOT judged by this verb (dependsOn = packaging, RFC 306dcb5c frame p.1); facts-graph acyclicity is the scheduled detector's job.");let o=r.facts.edges.filter(l=>!l.coveredByClosure);if(o.length>0){console.error(`
|
|
606
606
|
UNCOVERED by closure (src \u2192 tgt, occurrences, predicates):`);for(let l of o){console.error(` ${l.source} \u2192 ${l.target}: ${l.occurrences} [${hye(l.predicates)}]`);for(let u of l.examples)console.error(` ${u}`)}}if(r.unresolved.refs.length>0){let l=r.unresolved.countedAsUncovered?console.error:e;l(`
|
|
607
607
|
Unresolved definition-tier references (${r.unresolved.count}${r.degraded.active?"; excused \u2014 DEGRADED, coverage NOT proven":""}):`);for(let u of r.unresolved.refs.slice(0,50))l(` ${u.source}: ${u.sourcePath} --${u.predicate}--> ${u.ref} (${u.reason})`);r.unresolved.count>50&&l(` \u2026 ${r.unresolved.count-50} more`)}if(r.ambiguous.refs.length>0){let l=r.ambiguous.countedAsUncovered?console.error:e;l(`
|
|
608
608
|
Ambiguous definition-tier references (${r.ambiguous.count}; \u22652 distinct UIDs under one label \u2014 covered only when EVERY candidate's AssetSpace is in the source's closure):`);for(let u of r.ambiguous.refs.slice(0,50))l(` ${u.coveredByClosure?"covered ":"UNCOVERED"} ${u.source}: ${u.sourcePath} --${u.predicate}--> ${u.ref} \u2192 {${u.candidates.join(", ")}}`);r.ambiguous.count>50&&l(` \u2026 ${r.ambiguous.count-50} more`)}if(r.nonStringValues.sites.length>0){e(`
|
|
609
609
|
Non-string values under definition-tier predicates (${r.nonStringValues.count}; unquoted [[uid]] parses to a nested array \u2014 not readable, not judged):`);for(let l of r.nonStringValues.sites.slice(0,50))e(` ${l.sourcePath} --${l.predicate}`)}let c=r.facts.edges.filter(l=>l.coveredByClosure&&!l.coveredDirect);if(c.length>0){e(`
|
|
610
610
|
Covered transitively only (informational \u2014 not required, not forbidden):`);for(let l of c)e(` ${l.source} \u2192 ${l.target}: ${l.occurrences}`)}if(r.declaredWithoutFact.edges.length>0){e(`
|
|
611
611
|
Declared without a definition-tier fact (informational):`);for(let l of r.declaredWithoutFact.edges)e(` ${l.source} \u2192 ${l.target} [${l.targetKind}]`)}if(r.descriptors.danglingDeclarations.length>0){e(`
|
|
612
|
-
Dangling dependsOn declarations (no descriptor for the target UID):`);for(let l of r.descriptors.danglingDeclarations)e(` ${l.source} \u2192 ${l.ref}`)}}a(mye,"printText");function gye(r){let e=(0,jO.resolve)(r),t;try{t=(0,Jd.readFileSync)(e,"utf-8")}catch(i){let s=i.code;throw s==="ENOENT"||s==="EISDIR"||s==="ENOTDIR"?new Ke(`--missing-deps-file: not found or not a readable file: ${e}`,"The CI step writes it to $RUNNER_TEMP/missing-deps.txt from its failed clones; pass an existing file (one owner/repo per line) or omit the flag",{path:e,code:s}):i}let n=[];for(let i of t.split(/\r?\n/)){let s=i.replace(/#.*$/,"").trim();s.length>0&&n.push(s)}return n}a(gye,"readMissingDepsFile");function W6(r){let e=(0,jO.resolve)(r);if(!(0,Jd.existsSync)(e)||!(0,Jd.statSync)(e).isDirectory())throw new ke(e);return e}a(W6,"assertDirectory");function K6(){return new
|
|
612
|
+
Dangling dependsOn declarations (no descriptor for the target UID):`);for(let l of r.descriptors.danglingDeclarations)e(` ${l.source} \u2192 ${l.ref}`)}}a(mye,"printText");function gye(r){let e=(0,jO.resolve)(r),t;try{t=(0,Jd.readFileSync)(e,"utf-8")}catch(i){let s=i.code;throw s==="ENOENT"||s==="EISDIR"||s==="ENOTDIR"?new Ke(`--missing-deps-file: not found or not a readable file: ${e}`,"The CI step writes it to $RUNNER_TEMP/missing-deps.txt from its failed clones; pass an existing file (one owner/repo per line) or omit the flag",{path:e,code:s}):i}let n=[];for(let i of t.split(/\r?\n/)){let s=i.replace(/#.*$/,"").trim();s.length>0&&n.push(s)}return n}a(gye,"readMissingDepsFile");function W6(r){let e=(0,jO.resolve)(r);if(!(0,Jd.existsSync)(e)||!(0,Jd.statSync)(e).isDirectory())throw new ke(e);return e}a(W6,"assertDirectory");function K6(){return new de("assetspace-depends").description("Coverage gate for exo__AssetSpace_dependsOn (RFC 306dcb5c): every definition-tier cross-AssetSpace reference must have its target in the source AssetSpace's declared transitive closure. Prints uncovered-by-closure (verdict) AND uncovered-directly (informational); one-sided (declarations without facts are never violations); no cycle check on the declared graph; BROKEN (exit 2) on an empty population. --self <owner/repo> = per-repo CI mode (unresolvable targets count as uncovered \u2014 unless --missing-dep / --missing-deps-file name a declared dep absent from the merged vault, then they are EXCUSED into an OK (DEGRADED \u2026) verdict with the blind spot printed; req 8d432214).").requiredOption("--vault <path>","The ONE vault root measured (a canonical vault, or the CI merged vault) \u2014 every number carries it as its scope label").option("--registry <path>","Registry checkout holding the exo__AssetSpace descriptors (default: descriptors found in the vault(s))").option("--self <owner/repo>","Per-repo mode: judge only fact edges whose source is this AssetSpace (github.repository form); unresolvable definition-tier refs count as uncovered (unless a missing dep is named)").option("--missing-dep <owner/repo>","Declared dependsOn target that could NOT be materialised into the merged vault (repeatable; owner/repo or clone URL, keyed exactly like --self). With --self and the dep inside self's closure: unresolved refs are EXCUSED into an OK (DEGRADED \u2026) verdict, exit 0, and the blind spot is printed. Requires --self.",(r,e)=>[...e,r],[]).option("--missing-deps-file <path>","File with one missing dep per line (# comments and blank lines ignored) \u2014 same semantics as --missing-dep; the CI step writes it from its failed clones. Requires --self.").option("--strict-unresolved","Count unresolved refs as uncovered even when missing deps are named (the strict --self behaviour of req 04208713)").option("--output <type>","Response format: text|json","text").action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=W6(r.vault),n=r.registry?W6(r.registry):void 0;if(((r.missingDep?.length??0)>0||r.missingDepsFile!==void 0)&&r.self===void 0)throw new Ke("--missing-dep / --missing-deps-file require --self: in vault mode unresolved refs are already fail-open, so the inputs would be a silent no-op","Pass --self <owner/repo> (the per-repo CI mode) together with the missing deps");let s=[...r.missingDep??[],...r.missingDepsFile?gye(r.missingDepsFile):[]],o=await pye({vault:t,registry:n,self:r.self,missingDeps:s,strictUnresolved:r.strictUnresolved===!0});e==="json"?console.log(JSON.stringify(o,null,2)):mye(o),o.verdict==="BROKEN"?process.exitCode=2:o.verdict==="FAIL"&&(process.exitCode=1)}catch(t){ce.handle(t)}})}a(K6,"auditAssetSpaceDependsCommand");ct();var Bw=require("fs"),UO=ne(require("path")),Y6=require("path"),Q6=ne(We());Rt();Bt();var yye=5;function $O(r,e,t){r[e].length<yye&&r[e].push(t)}a($O,"addExample");async function _ye(r){let e=new Tn(r),t=await e.indexedAssets(),n=[],i={"empty-isDefinedBy":0,"bang-prefix":0,unresolvable:0},s={"empty-isDefinedBy":[],"bang-prefix":[],unresolvable:[]},o=0;for(let{path:c,metadata:l}of t){if(c.split("/").includes("node_modules")||fi(c))continue;let u=l.exo__Asset_isDefinedBy,f=(0,Q6.extractAssetReference)(u);if(!f){i["empty-isDefinedBy"]++,$O(s,"empty-isDefinedBy",c);continue}if(f.startsWith("!")){i["bang-prefix"]++,$O(s,"bang-prefix",c);continue}let d=await jc(e,f,c);if(!d){i.unresolvable++,$O(s,"unresolvable",c);continue}o++;let p=vO(UO.default.dirname(d)),h=vO(UO.default.dirname(c));p!==h&&n.push({path:c,isDefinedBy:f,expectedFolder:p,actualFolder:h})}return{vaultPath:r,totalFiles:t.length,checked:o,violations:n,skips:i,skipExamples:s}}a(_ye,"scanVaultForCoLocation");function X6(){return new de("co-location").description("Detect asset\u2013ontology co-location violations: any asset not in the folder of its exo__Asset_isDefinedBy ontology file (fail-open, skip-accounted)").requiredOption("--vault <path>","Vault root directory").option("--output <type>","Response format: text|json","text").action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=(0,Y6.resolve)(r.vault);if(!(0,Bw.existsSync)(t)||!(0,Bw.statSync)(t).isDirectory())throw new ke(t);let n=await _ye(t),i=n.skips["empty-isDefinedBy"]+n.skips["bang-prefix"]+n.skips.unresolvable;if(e==="json")console.log(JSON.stringify({vaultPath:n.vaultPath,totalFiles:n.totalFiles,checked:n.checked,violationCount:n.violations.length,violations:n.violations,skips:n.skips,skipTotal:i,skipExamples:n.skipExamples,clean:n.violations.length===0},null,2));else{if(n.violations.length===0)console.log(`OK ${t}: 0 co-location violations (${n.checked}/${n.totalFiles} checked)`);else{console.error(`FAIL ${t}: ${n.violations.length} co-location violation(s) (${n.checked}/${n.totalFiles} checked):`);for(let s of n.violations)console.error(` ${s.path}
|
|
613
613
|
isDefinedBy=${s.isDefinedBy} expected=${s.expectedFolder}/ actual=${s.actualFolder}/`)}console.error(`
|
|
614
614
|
Skipped (fail-open, NOT verified): ${i} \u2014 empty-isDefinedBy=${n.skips["empty-isDefinedBy"]}, bang-prefix=${n.skips["bang-prefix"]}, unresolvable(cross-vault/missing)=${n.skips.unresolvable}`)}n.violations.length>0&&(process.exitCode=1)}catch(t){ce.handle(t)}})}a(X6,"auditCoLocationCommand");ct();var Gw=require("fs"),c7=require("path"),GO=ne(We());function J6(r,e){let t=new Map,n=new Map,i=new Set,s=[],o=[],c=0;for(let l of r){if(t.has(l))continue;let u=[],f=a(d=>{t.set(d,c),n.set(d,c),c++,s.push(d),i.add(d),u.push([d,(e.get(d)??new Set).values()])},"pushNode");for(f(l);u.length>0;){let[d,p]=u[u.length-1],h=p.next();if(h.done){if(u.pop(),u.length>0){let m=u[u.length-1][0];n.set(m,Math.min(n.get(m),n.get(d)))}if(n.get(d)===t.get(d)){let m=[],g;do g=s.pop(),i.delete(g),m.push(g);while(g!==d);o.push(m)}}else{let m=h.value;t.has(m)?i.has(m)&&n.set(d,Math.min(n.get(d),t.get(m))):f(m)}}}return o}a(J6,"stronglyConnectedComponents");function Z6(r,e){return J6(r,e).filter(t=>t.length>=2)}a(Z6,"tarjanSCC");function Vw(r,e){let t=new Map;for(let n of r){let i=new Set,s=[...e.get(n)??[]];for(;s.length>0;){let o=s.shift();if(!i.has(o)){i.add(o);for(let c of e.get(o)??[])i.has(c)||s.push(c)}}t.set(n,i)}return t}a(Vw,"transitiveClosure");function e7(r,e){let t=J6(r,e),n=new Map;t.forEach((s,o)=>{for(let c of s)n.set(c,o)});let i=new Map;for(let[s,o]of e){let c=n.get(s);if(c!==void 0)for(let l of o){let u=n.get(l);if(u===void 0||c===u)continue;let f=i.get(c);f||(f=new Set,i.set(c,f)),f.add(u)}}return{components:t,componentOf:n,condensedEdges:i}}a(e7,"condense");function t7(r,e){let t=Vw(r,e),n=new Map;for(let[i,s]of e)for(let o of s){let c=!1;for(let l of s)if(l!==o&&t.get(l)?.has(o)){c=!0;break}if(!c){let l=n.get(i);l||(l=new Set,n.set(i,l)),l.add(o)}}return n}a(t7,"transitiveReduction");function r7(r,e){let t=new Map,n=new Map;for(let p of r)t.set(p,new Map),n.set(p,new Map);for(let p of e){if(p.source===p.target)continue;let h=t.get(p.source),m=n.get(p.target);!h||!m||(h.set(p.target,(h.get(p.target)??0)+p.weight),m.set(p.source,(m.get(p.source)??0)+p.weight))}let i=new Set(r),s=[],o=[],c=a(p=>{i.delete(p);for(let h of t.get(p).keys())n.get(h)?.delete(p);for(let h of n.get(p).keys())t.get(h)?.delete(p);t.get(p).clear(),n.get(p).clear()},"removeNode"),l=a(p=>{let h=0;for(let m of p.values())h+=m;return h},"sumWeights"),u=a(()=>[...i].sort(),"sortedRemaining");for(;i.size>0;){let p=!0;for(;p;){p=!1;for(let h of u())i.has(h)&&t.get(h).size===0&&(o.unshift(h),c(h),p=!0);for(let h of u())i.has(h)&&n.get(h).size===0&&(s.push(h),c(h),p=!0)}if(i.size>0){let h=null,m=-1/0;for(let g of u()){let _=l(t.get(g))-l(n.get(g));_>m&&(m=_,h=g)}h!==null&&(s.push(h),c(h))}}let f=[...s,...o],d=new Map(f.map((p,h)=>[p,h]));return e.filter(p=>{if(p.source===p.target)return!1;let h=d.get(p.source),m=d.get(p.target);return h===void 0||m===void 0?!1:h>m})}a(r7,"greedyFeedbackArcSet");var n7=/\[\[([^\]]+)\]\]/g;function bye(r){let e=r.split(`
|
|
615
615
|
`),t=[],n=null;for(let i of e){let s=i.match(/^[ \t]*(`{3,}|~{3,})/),o=s&&(s[1][0]==="~"||!i.slice(i.indexOf(s[1])+s[1].length).includes("`"));n===null?o?n=s[1]:t.push(i):s&&s[1][0]===n[0]&&s[1].length>=n.length&&/^[ \t]*(?:`{3,}|~{3,})[ \t]*$/.test(i)&&(n=null)}return t.join(`
|
|
616
|
-
`)}a(bye,"stripFencedCodeBlocks");function i7(r){let e=[],t;for(n7.lastIndex=0;(t=n7.exec(r))!==null;){let n=t[1],i=n.indexOf("|");i!==-1&&(n=n.slice(0,i));let s=n.indexOf("#");s!==-1&&(n=n.slice(0,s));let o=n.trim();o.length>0&&e.push(o)}return e}a(i7,"extractWikilinkTargets");function BO(r){return typeof r=="string"?[r]:Array.isArray(r)?r.flatMap(BO):r!==null&&typeof r=="object"?Object.values(r).flatMap(BO):[]}a(BO,"collectFrontmatterStrings");function Sye(r){let e=r.match(/^---\n[\s\S]*?\n---/);return e?r.slice(e[0].length):r}a(Sye,"bodyOf");function s7(r,e,t){let n=[];for(let[s,o]of Object.entries(r))if(!t?.has(s))for(let c of BO(o))for(let l of i7(c))n.push(l);let i=i7(bye(Sye(e)));return[...n,...i]}a(s7,"extractFileWikilinkTargets");var wye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function o7(r,e){if(e.includes("/")){let n=e.replace(/^\//,""),i=n.endsWith(".md")?n:`${n}.md`;if(await r.hasIndexedPath(i))return i;e=n.slice(n.lastIndexOf("/")+1)}if(e.endsWith(".md")&&(e=e.slice(0,-3)),wye.test(e)){let n=await r.findFileByUID(e);if(n)return n}let t=await r.findPathsByBasename(e);return t.length===1?t[0]:t.length>1?new Set(t).size===1?t[0]:"ambiguous":null}a(o7,"resolveTargetPath");Rt();Bt();var Eye="\0",vye="829b9b3b-6fc3-4276-be6a-27d3398c012e",Tye=["exo__Asset_relates","concept__Concept_related","concept__Concept_broader","concept__Concept_synonym","exo__Asset_createdBy"],Aye=5,Iye=10,Rye=new Set(["png","jpg","jpeg","gif","svg","webp","bmp","ico","avif","pdf","mp3","wav","m4a","ogg","flac","mp4","mov","webm","avi","mkv","zip","gz","tar","canvas","base","json","css","js","ts","html"]);function Cye(r){let e=r.lastIndexOf(".");if(e===-1||e===r.length-1)return!1;let t=r.slice(e+1).toLowerCase();return Rye.has(t)}a(Cye,"nonMarkdownExtension");function VO(r){if(Array.isArray(r)){let e=r.filter(t=>typeof t=="string");return{value:e[0]??null,multiple:e.length>1}}return{value:typeof r=="string"?r:null,multiple:!1}}a(VO,"firstString");function a7(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){let i=(0,GO.extractAssetReference)(n);i&&t.push(i)}return t}a(a7,"asRefList");function ng(r,e,t=Aye){r.length<t&&r.push(e)}a(ng,"pushExample");async function xye(r,e={}){let t=new Tn(r,{cacheContent:!0}),n=await t.indexedAssets(),i=new Set(e.excludePredicates??[]),s=new Map,o=new Map,c=new Map,l=[];for(let N of n){if(Hi(N.path)||fi(N.path)||!a7(N.metadata.exo__Instance_class).includes(vye))continue;let{value:
|
|
616
|
+
`)}a(bye,"stripFencedCodeBlocks");function i7(r){let e=[],t;for(n7.lastIndex=0;(t=n7.exec(r))!==null;){let n=t[1],i=n.indexOf("|");i!==-1&&(n=n.slice(0,i));let s=n.indexOf("#");s!==-1&&(n=n.slice(0,s));let o=n.trim();o.length>0&&e.push(o)}return e}a(i7,"extractWikilinkTargets");function BO(r){return typeof r=="string"?[r]:Array.isArray(r)?r.flatMap(BO):r!==null&&typeof r=="object"?Object.values(r).flatMap(BO):[]}a(BO,"collectFrontmatterStrings");function Sye(r){let e=r.match(/^---\n[\s\S]*?\n---/);return e?r.slice(e[0].length):r}a(Sye,"bodyOf");function s7(r,e,t){let n=[];for(let[s,o]of Object.entries(r))if(!t?.has(s))for(let c of BO(o))for(let l of i7(c))n.push(l);let i=i7(bye(Sye(e)));return[...n,...i]}a(s7,"extractFileWikilinkTargets");var wye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function o7(r,e){if(e.includes("/")){let n=e.replace(/^\//,""),i=n.endsWith(".md")?n:`${n}.md`;if(await r.hasIndexedPath(i))return i;e=n.slice(n.lastIndexOf("/")+1)}if(e.endsWith(".md")&&(e=e.slice(0,-3)),wye.test(e)){let n=await r.findFileByUID(e);if(n)return n}let t=await r.findPathsByBasename(e);return t.length===1?t[0]:t.length>1?new Set(t).size===1?t[0]:"ambiguous":null}a(o7,"resolveTargetPath");Rt();Bt();var Eye="\0",vye="829b9b3b-6fc3-4276-be6a-27d3398c012e",Tye=["exo__Asset_relates","concept__Concept_related","concept__Concept_broader","concept__Concept_synonym","exo__Asset_createdBy"],Aye=5,Iye=10,Rye=new Set(["png","jpg","jpeg","gif","svg","webp","bmp","ico","avif","pdf","mp3","wav","m4a","ogg","flac","mp4","mov","webm","avi","mkv","zip","gz","tar","canvas","base","json","css","js","ts","html"]);function Cye(r){let e=r.lastIndexOf(".");if(e===-1||e===r.length-1)return!1;let t=r.slice(e+1).toLowerCase();return Rye.has(t)}a(Cye,"nonMarkdownExtension");function VO(r){if(Array.isArray(r)){let e=r.filter(t=>typeof t=="string");return{value:e[0]??null,multiple:e.length>1}}return{value:typeof r=="string"?r:null,multiple:!1}}a(VO,"firstString");function a7(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){let i=(0,GO.extractAssetReference)(n);i&&t.push(i)}return t}a(a7,"asRefList");function ng(r,e,t=Aye){r.length<t&&r.push(e)}a(ng,"pushExample");async function xye(r,e={}){let t=new Tn(r,{cacheContent:!0}),n=await t.indexedAssets(),i=new Set(e.excludePredicates??[]),s=new Map,o=new Map,c=new Map,l=[];for(let N of n){if(Hi(N.path)||fi(N.path)||!a7(N.metadata.exo__Instance_class).includes(vye))continue;let{value:fe}=VO(N.metadata.exo__Asset_uid);if(!fe){l.push(N.path);continue}let{value:Ie}=VO(N.metadata.exo__Asset_label),we=Ie??N.path,ve=c.get(fe);ve?ve.push(N.path):c.set(fe,[N.path]),s.set(N.path,fe),o.has(fe)||o.set(fe,{uid:fe,label:we,path:N.path,metadata:N.metadata})}let u=[...c.entries()].filter(([,N])=>N.length>1).map(([N,ue])=>({uid:N,paths:ue})),f=new Map,d={"empty-isDefinedBy":0,"bang-prefix":0,unresolvable:0,"not-an-ontology":0},p=[],h=0,m=0,g=new Map,_=0,b=a((N,ue)=>{f.set(N,null),d[ue]++,h++,ng(p,`${N} (${ue})`,Iye)},"markNoOntology");for(let N of n){if(Hi(N.path)||fi(N.path))continue;_++;let ue=N.metadata.exo__Asset_isDefinedBy,{value:fe,multiple:Ie}=VO(ue);Ie&&m++;let we=(0,GO.extractAssetReference)(fe);if(!we){b(N.path,"empty-isDefinedBy");continue}if(we.startsWith("!")){b(N.path,"bang-prefix");continue}let ve=await jc(t,we,N.path);if(!ve){b(N.path,"unresolvable");continue}let Ae=s.get(ve);if(!Ae){b(N.path,"not-an-ontology");continue}f.set(N.path,Ae),g.set(Ae,(g.get(Ae)??0)+1)}let T=[...o.keys()],I=new Map,w=[],S=new Map,R=new Map,L=0;for(let N of T){let ue=o.get(N),fe=a7(ue.metadata.exo__Ontology_imports),Ie=[],we=[],ve=!1;for(let Ae of fe){let pe=null;if(o.has(Ae))pe=Ae;else{let V=await jc(t,Ae,ue.path);pe=V?s.get(V)??null:null}if(pe===null)we.push(Ae);else if(pe===N)ve=!0;else{Ie.push(pe);let V=I.get(N);V||(V=new Set,I.set(N,V)),V.has(pe)||(V.add(pe),L++)}}S.set(N,Ie),R.set(N,we),ve&&w.push(N)}let P=Z6(T,I),M=Vw(T,I),O={total:0,internal:0,crossOntologyValid:0,crossOntologyViolation:0,crossVault:0,noOntology:0},F={broken:0,"dup-basename":0,"non-markdown":0},Z={broken:[],"dup-basename":[],"non-markdown":[]},J=new Map,U=new Map,K=new Map,_e=new Map,le=new Map,W=new Map,H=a(N=>{let ue=o.get(N);return ue?{uid:ue.uid,label:ue.label,path:ue.path}:{uid:N,label:N,path:""}},"toRef");for(let N of n){if(Hi(N.path)||fi(N.path))continue;let ue=f.get(N.path)??null,fe=s7(N.metadata,N.content??"",i);for(let Ie of fe){if(O.total++,Cye(Ie)){F["non-markdown"]++,ng(Z["non-markdown"],`${N.path} \u2192 ${Ie}`);continue}let we=await o7(t,Ie);if(we==="ambiguous"){F["dup-basename"]++,ng(Z["dup-basename"],`${N.path} \u2192 ${Ie}`);continue}if(we===null){F.broken++,ng(Z.broken,`${N.path} \u2192 ${Ie}`);continue}let ve=f.get(we)??s.get(we)??null;if(ue===null||ve===null){O.noOntology++;continue}if(ue===ve){O.internal++,K.set(ue,(K.get(ue)??0)+1);continue}let Ae=M.get(ue)?.has(ve)??!1,pe=`${ue}${Eye}${ve}`,V=J.get(pe);if(V?V.occurrences++:J.set(pe,{source:ue,target:ve,occurrences:1,valid:Ae}),_e.set(ue,(_e.get(ue)??0)+1),le.set(ve,(le.get(ve)??0)+1),Ae)O.crossOntologyValid++;else{O.crossOntologyViolation++,W.set(ue,(W.get(ue)??0)+1);let D=U.get(pe);D?(D.occurrences++,ng(D.examples,N.path)):U.set(pe,{source:ue,target:ve,occurrences:1,examples:[N.path]})}}}let oe=[...J.values()].sort((N,ue)=>ue.occurrences-N.occurrences),xe=new Map,re=new Map;for(let N of oe)re.set(N.source,(re.get(N.source)??0)+1),xe.set(N.target,(xe.get(N.target)??0)+1);let Q=T.map(N=>({...H(N),declaredImports:S.get(N)??[],unresolvedImports:R.get(N)??[],selfImport:w.includes(N),assetCount:g.get(N)??0,inDegree:xe.get(N)??0,outDegree:re.get(N)??0,internalLinks:K.get(N)??0,externalLinksOut:_e.get(N)??0,externalLinksIn:le.get(N)??0,violatingOut:W.get(N)??0})).sort((N,ue)=>N.label.localeCompare(ue.label)),ie=[...U.values()].map(N=>({source:H(N.source),target:H(N.target),occurrences:N.occurrences,examples:N.examples})).sort((N,ue)=>ue.occurrences-N.occurrences),Y=[],ae=P.length===0,Me=ie.length===0&&O.crossVault===0&&ae&&u.length===0;return{vaultPath:r,totalFiles:n.length,scannedFiles:_,ontologies:Q,duplicateOntologyUids:u,declared:{edgeCount:L,sccs:P,acyclic:ae},derivedEdges:oe,violations:ie,crossVault:Y,linkCounts:O,skips:F,skipExamples:Z,noOntologyAssets:{count:h,byReason:d,examples:p},warnings:{selfImports:w,multipleIsDefinedBy:m,ontologiesWithoutUid:l},clean:Me,...i.size>0?{excludedPredicates:[...i]}:{}}}a(xye,"scanVaultForOntologyImports");function Oye(r){let e=r.ontologies.map(S=>S.uid),t=new Map;for(let S of r.ontologies)t.set(S.uid,{uid:S.uid,label:S.label,path:S.path});let n=a(S=>t.get(S)??{uid:S,label:S,path:""},"refOf"),i=new Map;for(let S of r.ontologies)S.declaredImports.length>0&&i.set(S.uid,new Set(S.declaredImports));let s=new Map,o=new Map;for(let S of r.derivedEdges){let R=s.get(S.source);R||(R=new Set,s.set(S.source,R)),R.add(S.target),o.set(`${S.source} ${S.target}`,S.occurrences)}let{components:c,componentOf:l}=e7(e,s),u=[],f=new Map,d=0;for(let S of r.derivedEdges){let R=l.get(S.source),L=l.get(S.target);if(R!==void 0&&L!==void 0&&R===L){let M=f.get(R);M||(M=[],f.set(R,M)),M.push({source:S.source,target:S.target,weight:S.occurrences})}else u.push({source:S.source,target:S.target,occurrences:S.occurrences}),S.valid&&d++}let p=a((S,R,L)=>{if(S===R)return!0;let P=[...L.get(S)??[]],M=new Set;for(;P.length>0;){let O=P.shift();if(O===R)return!0;if(!M.has(O)){M.add(O);for(let F of L.get(O)??[])P.push(F)}}return!1},"reaches"),h=new Map;for(let[S,R]of i)h.set(S,new Set(R));let m=[],g=[...u].sort((S,R)=>S.source===R.source?S.target.localeCompare(R.target):S.source.localeCompare(R.source));for(let S of g)if(p(S.target,S.source,h))m.push({source:n(S.source),target:n(S.target),occurrences:S.occurrences});else{let R=h.get(S.source);R||(R=new Set,h.set(S.source,R)),R.add(S.target)}let _=t7(e,h),b=[];for(let[S,R]of _)for(let L of R)i.get(S)?.has(L)||b.push({source:n(S),target:n(L),occurrences:o.get(`${S} ${L}`)??0});b.sort((S,R)=>R.occurrences-S.occurrences||S.source.uid.localeCompare(R.source.uid)||S.target.uid.localeCompare(R.target.uid));let T=[];for(let[S,R]of f){let L=c[S],M=r7(L,R).map(O=>({source:n(O.source),target:n(O.target),occurrences:O.weight})).sort((O,F)=>O.occurrences-F.occurrences||O.source.uid.localeCompare(F.source.uid)||O.target.uid.localeCompare(F.target.uid));T.push({ontologies:L.map(n).sort((O,F)=>O.label.localeCompare(F.label)),edgeCount:R.length,occurrenceCount:R.reduce((O,F)=>O+F.weight,0),suggestedCuts:M})}T.sort((S,R)=>R.ontologies.length-S.ontologies.length||R.occurrenceCount-S.occurrenceCount);let I=Vw(e,i),w=[];for(let[S,R]of i)for(let L of R){let P=!1;for(let M of R)if(M!==L&&I.get(M)?.has(L)){P=!0;break}P&&w.push({source:n(S),target:n(L),occurrences:o.get(`${S} ${L}`)??0})}return{additions:b,acyclicEdgeCount:u.length,alreadyCovered:d,conflicts:m,intraScc:T,redundantDeclared:w}}a(Oye,"computeImportProposal");function Ys(r){return`${r.uid}|${r.label}|${r.path}`}a(Ys,"formatRef");function Pye(r){let e=r.ontologies.filter(i=>i.declaredImports.length>0||i.unresolvedImports.length>0).length,t=r.clean?console.log:console.error;if(t(`${r.clean?"OK":"FAIL"} ${r.vaultPath}: ontology-imports audit \u2014 ${r.linkCounts.crossOntologyViolation} violating occurrence(s) in ${r.violations.length} pair(s)`),t(`Ontologies: ${r.ontologies.length} (${e} with imports declared), declared graph: ${r.declared.edgeCount} edge(s), `+(r.declared.acyclic?"acyclic":`NOT ACYCLIC \u2014 ${r.declared.sccs.length} SCC(s)`)),r.excludedPredicates&&r.excludedPredicates.length>0&&t(`Structural-only mode (VL#30): excluded ${r.excludedPredicates.length} associative predicate(s) from edge extraction \u2014 ${r.excludedPredicates.join(", ")}`),r.duplicateOntologyUids.length>0){console.error(`
|
|
617
617
|
HARD ERRORS \u2014 duplicate ontology UIDs (R7):`);for(let i of r.duplicateOntologyUids)console.error(` ${i.uid}: ${i.paths.join(", ")}`)}if(!r.declared.acyclic){console.error(`
|
|
618
618
|
Declared-graph cycles (must be a DAG):`);for(let i of r.declared.sccs)console.error(` SCC[${i.length}]: ${i.map(s=>Ys(Dye(r,s))).join(" \u21C4 ")}`)}if(r.violations.length>0){console.error(`
|
|
619
619
|
Violating pairs (src \u2192 tgt, occurrences desc):`);for(let i of r.violations)console.error(` ${Ys(i.source)} \u2192 ${Ys(i.target)}: ${i.occurrences}`)}let n=r.ontologies.reduce((i,s)=>i+s.unresolvedImports.length,0);t(`
|
|
@@ -623,11 +623,11 @@ Acyclic part: ${r.acyclicEdgeCount} cross-SCC derived edge(s), ${r.alreadyCovere
|
|
|
623
623
|
Additions (minimal \u2014 transitive reduction of the condensation), ${r.additions.length} edge(s):`),r.additions.length===0)console.log(" (none \u2014 acyclic part already covered)");else for(let e of r.additions)console.log(` + ${Ys(e.source)} imports ${Ys(e.target)} (${e.occurrences} occ)`);if(r.conflicts.length>0){console.log(`
|
|
624
624
|
Conflicts \u2014 derived edges that would create a declared-graph cycle (need Phase-3 re-home, not an import), ${r.conflicts.length}:`);for(let e of r.conflicts)console.log(` ! ${Ys(e.source)} \u2192 ${Ys(e.target)} (${e.occurrences} occ)`)}if(r.intraScc.length>0){console.log(`
|
|
625
625
|
Intra-SCC cycles (require Phase 3 \u2014 imports cannot legitimize a cycle), ${r.intraScc.length} component(s):`);for(let e of r.intraScc){console.log(` SCC[${e.ontologies.length}] ${e.edgeCount} edge(s) / ${e.occurrenceCount} occ \u2014 members: ${e.ontologies.map(t=>t.label).join(", ")}`),console.log(` suggested feedback-arc-set to cut (cheapest first), ${e.suggestedCuts.length} edge(s):`);for(let t of e.suggestedCuts)console.log(` \u2702 ${Ys(t.source)} \u2192 ${Ys(t.target)} (${t.occurrences} occ)`)}}if(r.redundantDeclared.length>0){console.log(`
|
|
626
|
-
Redundant declared imports (informational, R8 \u2014 never auto-removed), ${r.redundantDeclared.length}:`);for(let e of r.redundantDeclared)console.log(` ~ ${Ys(e.source)} imports ${Ys(e.target)} (reachable without the direct edge)`)}}a(Fye,"printProposal");function l7(){return new
|
|
626
|
+
Redundant declared imports (informational, R8 \u2014 never auto-removed), ${r.redundantDeclared.length}:`);for(let e of r.redundantDeclared)console.log(` ~ ${Ys(e.source)} imports ${Ys(e.target)} (reachable without the direct edge)`)}}a(Fye,"printProposal");function l7(){return new de("ontology-imports").description("Detect cross-ontology wikilinks not covered by the declared exo__Ontology_imports transitive closure (DAG check, per-pair grouping, fail-open skip-accounting); --propose-imports suggests minimal import additions").requiredOption("--vault <path>","Vault root directory").option("--output <type>","Response format: text|json","text").option("--propose-imports","Emit a minimal additions-only import proposal (SCC condensation + transitive reduction + suggested feedback-arc-set)").option("--structural-only","Exclude curated associative predicates (exo__Asset_relates, concept__Concept_related/broader/synonym, exo__Asset_createdBy) from edge extraction to measure the structural backbone import-DAG (EKA Phase B, Vision VL#30). Default: every wikilink counts.").option("--exclude-predicate <name>","Additional frontmatter predicate (top-level key) to exclude from edge extraction (repeatable; combines with --structural-only)",Lye,[]).action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=(0,c7.resolve)(r.vault);if(!(0,Gw.existsSync)(t)||!(0,Gw.statSync)(t).isDirectory())throw new ke(t);let n=[...r.structuralOnly?Tye:[],...r.excludePredicate??[]],i=await xye(t,{excludePredicates:n});r.proposeImports&&(i.proposal=Oye(i)),e==="json"?console.log(JSON.stringify(i,null,2)):(Pye(i),i.proposal&&Fye(i.proposal)),i.clean||(process.exitCode=1)}catch(t){ce.handle(t)}})}a(l7,"auditOntologyImportsCommand");function Lye(r,e){return e.concat([r])}a(Lye,"collectExcludePredicate");ct();var Ww=require("fs"),u7=require("path"),WO=ne(We());Rt();Bt();var Nye="829b9b3b-6fc3-4276-be6a-27d3398c012e",kye=5;function qO(r){return Array.isArray(r)?r.find(t=>typeof t=="string")??null:typeof r=="string"?r:null}a(qO,"firstString");function qw(r){let e=r==null?[]:Array.isArray(r)?r:[r],t=[];for(let n of e){let i=n;for(;Array.isArray(i);)i=i[0];let s=(0,WO.extractAssetReference)(i);s&&t.push(s)}return t}a(qw,"asRefList");var Mye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function jye(r){let e=new Tn(r),t=await e.indexedAssets(),n=new Map,i=new Map,s=new Map,o=new Map,c=new Map,l=new Map;for(let b of t){if(Hi(b.path)||fi(b.path))continue;let T=qO(b.metadata.exo__Asset_uid);if(T){n.has(T)||n.set(T,b.metadata);let w=qO(b.metadata.exo__Asset_label);w&&!i.has(w)&&i.set(w,T)}let I=qw(b.metadata.exo__Instance_class);if(T&&I.includes(Nye)){s.set(b.path,T);let w=qO(b.metadata.exo__Asset_label)??b.path;o.has(T)||o.set(T,w)}}let u=a(b=>Mye.test(b)?b:i.get(b)??null,"resolveClassRefToUid");for(let b of t){if(Hi(b.path)||fi(b.path))continue;let T=s.get(b.path);if(!T)continue;let I=qw(b.metadata.exo__Ontology_admits);if(I.length===0)continue;let w=new Set;for(let S of I){let R=u(S);R&&w.add(R)}w.size>0&&(c.set(T,w),l.set(T,[...w]))}let f=new Map,d=a(b=>{let T=f.get(b);if(T)return T;let I=new Set,w=[b];for(;w.length>0;){let S=w.shift();if(I.has(S))continue;I.add(S);let R=n.get(S);if(R)for(let L of qw(R.exo__Class_superClass)){let P=u(L);P&&!I.has(P)&&w.push(P)}}return f.set(b,I),I},"classClosure"),p=[],h={"no-isDefinedBy":0,"ontology-unresolvable":0,"ontology-no-admits":0,"no-instance-class":0,"unresolvable-class":0},m={"no-isDefinedBy":[],"ontology-unresolvable":[],"ontology-no-admits":[],"no-instance-class":[],"unresolvable-class":[]},g=0,_=a((b,T)=>{h[b]++,m[b].length<kye&&m[b].push(T)},"skip");for(let b of t){if(Hi(b.path)||fi(b.path))continue;let T=(0,WO.extractAssetReference)(b.metadata.exo__Asset_isDefinedBy);if(!T||T.startsWith("!")){_("no-isDefinedBy",b.path);continue}let I=await jc(e,T,b.path),w=I?s.get(I):void 0;if(!w){_("ontology-unresolvable",b.path);continue}let S=c.get(w);if(!S){_("ontology-no-admits",b.path);continue}let R=qw(b.metadata.exo__Instance_class);if(R.length===0){_("no-instance-class",b.path);continue}let L=R.map(u).filter(M=>M!==null);if(L.length===0){_("unresolvable-class",b.path);continue}g++,L.some(M=>{for(let O of d(M))if(S.has(O))return!0;return!1})||p.push({path:b.path,ontologyUid:w,ontologyLabel:o.get(w)??w,classUids:L,admits:l.get(w)??[...S]})}return{vaultPath:r,totalFiles:t.length,ontologies:s.size,ontologiesWithAdmits:c.size,checked:g,violations:p,skips:h,skipExamples:m}}a(jye,"scanVaultForOntologyMembership");function f7(){return new de("ontology-membership").description("Detect ontology-membership violations: any asset whose exo__Instance_class (or a superClass ancestor) is not in its isDefinedBy ontology's exo__Ontology_admits allow-list (subsumption-aware superClass walk, dual-IRI-safe, fail-open when no allow-list is declared, skip-accounted)").requiredOption("--vault <path>","Vault root directory").option("--output <type>","Response format: text|json","text").action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=(0,u7.resolve)(r.vault);if(!(0,Ww.existsSync)(t)||!(0,Ww.statSync)(t).isDirectory())throw new ke(t);let n=await jye(t),i=Object.values(n.skips).reduce((s,o)=>s+o,0);if(e==="json")console.log(JSON.stringify({vaultPath:n.vaultPath,totalFiles:n.totalFiles,ontologies:n.ontologies,ontologiesWithAdmits:n.ontologiesWithAdmits,checked:n.checked,violationCount:n.violations.length,violations:n.violations,skips:n.skips,skipTotal:i,skipExamples:n.skipExamples,clean:n.violations.length===0},null,2));else{if(n.violations.length===0)console.log(`OK ${t}: 0 ontology-membership violations (${n.checked} checked; ${n.ontologiesWithAdmits}/${n.ontologies} ontologies declare exo__Ontology_admits)`);else{console.error(`FAIL ${t}: ${n.violations.length} ontology-membership violation(s) (${n.checked} checked; ${n.ontologiesWithAdmits}/${n.ontologies} ontologies declare exo__Ontology_admits):`);for(let s of n.violations)console.error(` ${s.path}
|
|
627
627
|
isDefinedBy=${s.ontologyUid} (${s.ontologyLabel}) instance_class=[${s.classUids.join(", ")}] not in admits=[${s.admits.join(", ")}]`)}console.error(`
|
|
628
|
-
Skipped (fail-open, NOT verified): ${i} \u2014 no-isDefinedBy=${n.skips["no-isDefinedBy"]}, ontology-unresolvable=${n.skips["ontology-unresolvable"]}, ontology-no-admits=${n.skips["ontology-no-admits"]}, no-instance-class=${n.skips["no-instance-class"]}, unresolvable-class=${n.skips["unresolvable-class"]}`)}n.violations.length>0&&(process.exitCode=1)}catch(t){ce.handle(t)}})}a(f7,"auditOntologyMembershipCommand");ct();var Hw=require("fs"),d7=require("path");Rt();Bt();var $ye="exocortex.my",Uye=5;function Bye(r){return Array.isArray(r)?r.find(t=>typeof t=="string")??null:typeof r=="string"?r:null}a(Bye,"firstString");function Vye(r){try{return new URL(r).host}catch{return null}}a(Vye,"urlHost");function Gye(r){return`${r.replace(/\/+$/,"")}#`}a(Gye,"expectedCanonicalForm");async function qye(r){let t=await new Tn(r).indexedAssets(),n=[],i={"foreign-vocab":0,"unparseable-url":0},s={"foreign-vocab":[],"unparseable-url":[]},o=0,c=0,l=a((u,f)=>{s[u].length<Uye&&s[u].push(f)},"addExample");for(let{path:u,metadata:f}of t){if(Hi(u)||fi(u))continue;let d=Bye(f.exo__Ontology_url);if(!d)continue;o++;let p=Vye(d);if(p===null){i["unparseable-url"]++,l("unparseable-url",u);continue}if(p!==$ye){i["foreign-vocab"]++,l("foreign-vocab",u);continue}c++,d.endsWith("#")||n.push({path:u,url:d,expected:Gye(d)})}return{vaultPath:r,totalFiles:t.length,ontologiesFound:o,checked:c,violations:n,skips:i,skipExamples:s}}a(qye,"scanVaultForOntologyUrl");function p7(){return new
|
|
628
|
+
Skipped (fail-open, NOT verified): ${i} \u2014 no-isDefinedBy=${n.skips["no-isDefinedBy"]}, ontology-unresolvable=${n.skips["ontology-unresolvable"]}, ontology-no-admits=${n.skips["ontology-no-admits"]}, no-instance-class=${n.skips["no-instance-class"]}, unresolvable-class=${n.skips["unresolvable-class"]}`)}n.violations.length>0&&(process.exitCode=1)}catch(t){ce.handle(t)}})}a(f7,"auditOntologyMembershipCommand");ct();var Hw=require("fs"),d7=require("path");Rt();Bt();var $ye="exocortex.my",Uye=5;function Bye(r){return Array.isArray(r)?r.find(t=>typeof t=="string")??null:typeof r=="string"?r:null}a(Bye,"firstString");function Vye(r){try{return new URL(r).host}catch{return null}}a(Vye,"urlHost");function Gye(r){return`${r.replace(/\/+$/,"")}#`}a(Gye,"expectedCanonicalForm");async function qye(r){let t=await new Tn(r).indexedAssets(),n=[],i={"foreign-vocab":0,"unparseable-url":0},s={"foreign-vocab":[],"unparseable-url":[]},o=0,c=0,l=a((u,f)=>{s[u].length<Uye&&s[u].push(f)},"addExample");for(let{path:u,metadata:f}of t){if(Hi(u)||fi(u))continue;let d=Bye(f.exo__Ontology_url);if(!d)continue;o++;let p=Vye(d);if(p===null){i["unparseable-url"]++,l("unparseable-url",u);continue}if(p!==$ye){i["foreign-vocab"]++,l("foreign-vocab",u);continue}c++,d.endsWith("#")||n.push({path:u,url:d,expected:Gye(d)})}return{vaultPath:r,totalFiles:t.length,ontologiesFound:o,checked:c,violations:n,skips:i,skipExamples:s}}a(qye,"scanVaultForOntologyUrl");function p7(){return new de("ontology-url").description("Detect exocortex.my ontologies whose exo__Ontology_url lacks the canonical trailing '#' separator (foreign vocabularies skipped, path hierarchy preserved, fail-open + skip-accounted)").requiredOption("--vault <path>","Vault root directory").option("--output <type>","Response format: text|json","text").action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=(0,d7.resolve)(r.vault);if(!(0,Hw.existsSync)(t)||!(0,Hw.statSync)(t).isDirectory())throw new ke(t);let n=await qye(t),i=n.skips["foreign-vocab"]+n.skips["unparseable-url"];if(e==="json")console.log(JSON.stringify({vaultPath:n.vaultPath,totalFiles:n.totalFiles,ontologiesFound:n.ontologiesFound,checked:n.checked,violationCount:n.violations.length,violations:n.violations,skips:n.skips,skipTotal:i,skipExamples:n.skipExamples,clean:n.violations.length===0},null,2));else{if(n.violations.length===0)console.log(`OK ${t}: 0 ontology-url violations (${n.checked}/${n.ontologiesFound} exocortex.my ontologies checked)`);else{console.error(`FAIL ${t}: ${n.violations.length} ontology-url violation(s) (${n.checked}/${n.ontologiesFound} exocortex.my ontologies checked):`);for(let s of n.violations)console.error(` ${s.path}
|
|
629
629
|
url=${s.url} expected=${s.expected}`)}console.error(`
|
|
630
|
-
Skipped (fail-open, NOT verified): ${i} \u2014 foreign-vocab=${n.skips["foreign-vocab"]}, unparseable-url=${n.skips["unparseable-url"]}`)}n.violations.length>0&&(process.exitCode=1)}catch(t){ce.handle(t)}})}a(p7,"auditOntologyUrlCommand");function h7(){let r=new
|
|
630
|
+
Skipped (fail-open, NOT verified): ${i} \u2014 foreign-vocab=${n.skips["foreign-vocab"]}, unparseable-url=${n.skips["unparseable-url"]}`)}n.violations.length>0&&(process.exitCode=1)}catch(t){ce.handle(t)}})}a(p7,"auditOntologyUrlCommand");function h7(){let r=new de("audit").description("Audit vault for regression patterns (RFC cutover detectors)");return r.addCommand(K6()),r.addCommand(X6()),r.addCommand(l7()),r.addCommand(f7()),r.addCommand(p7()),r}a(h7,"auditCommand");ct();var zw=require("fs"),m7=require("fs/promises"),g7=require("crypto"),pu=require("path"),Oo=ne(We());Rt();Bt();var Wye="35cf35fb-935f-4d35-a150-939f29109aec",Hye=[{checkId:Oo.CHECK_ID_UID_UNIQUENESS,label:"uid-uniqueness",value:!0},{checkId:Oo.CHECK_ID_CO_LOCATION,label:"co-location",value:!1},{checkId:Oo.CHECK_ID_SHACL,label:"shacl",value:!1},{checkId:Oo.CHECK_ID_DAG_ONTOLOGY_IMPORTS,label:"dag-ontology-imports",value:!1}];function zye(r,e,t,n,i,s){return`---
|
|
631
631
|
exo__Asset_uid: ${r}
|
|
632
632
|
exo__Asset_isDefinedBy: "[[${e}]]"
|
|
633
633
|
exo__Asset_createdAt: ${s}
|
|
@@ -641,12 +641,12 @@ setting__Setting_value: ${i}
|
|
|
641
641
|
# Validation check: ${n}
|
|
642
642
|
|
|
643
643
|
Homoiconic validation-check setting (RFC f402002b, M1.5). \`Exocortex: Validate vault\` reads this instance's \`setting__Setting_value\` to decide whether to run the **${n}** check (key \`[[${t}]]\`). Scaffolded default \u2014 edit \`setting__Setting_value\` to toggle.
|
|
644
|
-
`}a(zye,"settingAsset");function y7(){return new
|
|
645
|
-
Defaults: uid-uniqueness=true, co-location/shacl/dag=false. Run 'exocortex validate vault --vault <path>'.`)}}catch(t){ce.handle(t)}})}a(Kye,"scaffoldValidationCommand");ct();var O7=require("fs"),P7=require("path");var qc=require("node:fs"),hu=require("node:path"),kr=ne(We());var mt=require("node:fs"),b7=require("node:fs/promises"),S7=require("node:os"),an=require("node:path"),ls=ne(We());var Yye=/^https:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+?)(?:\.git)?$/,_7=50*1024*1024,Pi=class r{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??"",this.mountBaseStore=e.mountBaseStore}redact(e){return(typeof e=="string"?e:String(e)).replace(r.PAT_REGEX,"***REDACTED***")}static parseGitHubURL(e){let t=e.match(Yye);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}=r.parseGitHubURL(e);return t.startsWith("exoas-")?t.slice(6):t}async pullAssetSpace(e,t,n){let{owner:i,repo:s}=r.parseGitHubURL(e);if((0,mt.existsSync)(n)&&(0,mt.readdirSync)(n).length>0)throw new Error(`pullAssetSpace: target ${n} exists \u0438 not empty \u2014 refusing \u043A overwrite`);let o=await(0,ls.mountAssetSpaceFiles)({http:this.httpPort(),fs:this.fsPort(),owner:i,repo:s,ref:t,targetPath:n});if(this.mountBaseStore!==void 0)try{await this.mountBaseStore.set(`${i}/${s}#${ls.SYNC_BRANCH}`,o.sha)}catch{}return o}httpPort(){let e=this.fetchImpl,t=this.token,n=a(i=>this.redact(i),"redact");return{async fetchTarball(i,s,o){let c=`https://api.github.com/repos/${i}/${s}/tarball/${o}`,l={signal:AbortSignal.timeout(6e4)};t.length>0&&(l.headers={Authorization:`Bearer ${t}`,"User-Agent":"exocortex-cli","X-GitHub-Api-Version":"2022-11-28"});let u;try{u=await e(c,l)}catch(d){throw new Error(n(`pullAssetSpace: fetch error for ${c}: ${d instanceof Error?d.message:String(d)}`))}if(!u.ok){if(u.status===403){let d=u.headers?.get?.("x-ratelimit-remaining"),p=u.headers?.get?.("x-ratelimit-reset");if(d==="0"||p!=null){let h=p!=null?new Date(Number(p)*1e3).toISOString():"unknown";throw new Error(`pullAssetSpace: GitHub anonymous API rate-limit exceeded (60 req/hour). Reset at ${h}. Wait or use authenticated CLI.`)}}if(u.status===404){let d=t.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(n(`pullAssetSpace: fetch failed (404 Not Found) for ${c} \u2014 ${d}`))}throw new Error(n(`pullAssetSpace: fetch failed (${u.status} ${u.statusText}) for ${c}`))}let f=await u.arrayBuffer();if(f.byteLength>_7)throw new Error(`pullAssetSpace: tarball too large (${f.byteLength} bytes > ${_7})`);return new Uint8Array(f)}}}fsPort(){return{async exists(e){return(0,mt.existsSync)(e)},async read(e){return(0,mt.readFileSync)(e,"utf8")},async write(e,t){(0,mt.writeFileSync)(e,t,{encoding:"utf8"})},async removeDir(e){(0,mt.rmSync)(e,{recursive:!0,force:!0})},async materialize(e,t,n){let i=await(0,b7.mkdtemp)((0,an.join)((0,S7.tmpdir)(),`exo-bootstrap-${(0,an.basename)(e)}-`)),s=0;try{for(let o of t){let c=o.relPath;if(c.split("/").some(u=>u===".."))throw new Error(`pullAssetSpace: path traversal detected for entry "${c}"`);let l=(0,an.resolve)(i,c);if(l!==i&&!l.startsWith(i+an.sep))throw new Error(`pullAssetSpace: zip-slip detected for entry "${c}"`);(0,mt.mkdirSync)((0,an.dirname)(l),{recursive:!0}),(0,mt.writeFileSync)(l,o.content),s++,n?.(s)}(0,mt.mkdirSync)((0,an.dirname)(e),{recursive:!0});try{(0,mt.renameSync)(i,e)}catch(o){if(o.code==="EXDEV"){let{cpSync:c}=await import("node:fs");c(i,e,{recursive:!0}),(0,mt.rmSync)(i,{recursive:!0,force:!0})}else throw o}}catch(o){throw(0,mt.rmSync)(i,{recursive:!0,force:!0}),o}return s}}}ensureGitmodulesEntry(e,t,n){let i=(0,an.join)(e,".gitmodules"),s="";try{s=(0,mt.readFileSync)(i,"utf8")}catch(l){if(l.code!=="ENOENT")throw l}let{content:o,added:c}=(0,ls.appendGitmodulesEntry)(s,t,n);return c?((0,mt.appendFileSync)(i,o.slice(s.length),{encoding:"utf8"}),{added:!0}):{added:!1}}removeGitmodulesEntry(e,t){let n=(0,an.join)(e,".gitmodules"),i;try{i=(0,mt.readFileSync)(n,"utf8")}catch(o){if(o.code==="ENOENT")return{removed:!1};throw o}let s=(0,ls.stripGitmodulesEntry)(i,t);return s===i?{removed:!1}:((0,mt.writeFileSync)(n,s,{encoding:"utf8"}),{removed:!0})}static stripGitmodulesEntry(e,t){return(0,ls.stripGitmodulesEntry)(e,t)}unmountAssetSpace(e,t){let n=this.assertSafeVaultTarget(e,t,"unmountAssetSpace");this.removeGitmodulesEntry(e,t),(0,mt.existsSync)(n)&&(0,mt.rmSync)(n,{recursive:!0,force:!0})}parkAssetSpace(e,t){let n=this.assertSafeVaultTarget(e,t,"parkAssetSpace"),i=(0,ls.parkedPathFor)(t),s=this.assertSafeVaultTarget(e,i,"parkAssetSpace",{requireAssetspacesRoot:!1});if((0,mt.existsSync)(n)){if((0,mt.existsSync)(s))throw new Error(`parkAssetSpace: refusing to park "${t}" \u2014 a parked copy already exists at "${i}". Resolve by hand: one of the two holds work the other does not.`);this.removeGitmodulesEntry(e,t),(0,mt.mkdirSync)((0,an.dirname)(s),{recursive:!0}),(0,mt.renameSync)(n,s)}}unparkAssetSpace(e,t){let n=this.assertSafeVaultTarget(e,t,"unparkAssetSpace"),i=(0,ls.parkedPathFor)(t),s=this.assertSafeVaultTarget(e,i,"unparkAssetSpace",{requireAssetspacesRoot:!1});if(!(0,mt.existsSync)(s))throw new Error(`unparkAssetSpace: nothing parked at "${i}" for "${t}"`);if((0,mt.existsSync)(n))throw new Error(`unparkAssetSpace: refusing to unpark onto existing mount "${t}"`);(0,mt.mkdirSync)((0,an.dirname)(n),{recursive:!0}),(0,mt.renameSync)(s,n)}assertSafeVaultTarget(e,t,n,i={}){let s=i.requireAssetspacesRoot??!0,o=t.split("/");if(t.length===0||s&&!t.startsWith("assetspaces/")||o.some(u=>u.length===0||u==="."||u===".."))throw new Error(`${n}: refusing unsafe submodulePath "${t}"`);let c=(0,an.resolve)(e),l=(0,an.resolve)(c,t);if(l===c||!l.startsWith(c+an.sep))throw new Error(`${n}: target "${l}" escapes vault root "${c}"`);return l}};function Qye(r){let e=(0,kr.derivePath)(r);return e===null?r:(0,kr.deriveUrl)(e)??r}a(Qye,"toHttpsGitHubUrl");var Xye=new Set(["node_modules",".obsidian",".exocortex",".git"]),Zd=class{static{a(this,"CliApplyProfileService")}constructor(e){this.vaultPath=e.vaultPath,this.mount=e.mount??new Pi,this.ref=e.ref??"main"}scanVault(){let e=[],t=new Map,n=new Set,i=[this.vaultPath];for(;i.length>0;){let s=i.pop(),o;try{o=(0,qc.readdirSync)(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=(0,hu.join)(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||Xye.has(c.name))continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=this.readFrontmatter(l);if(u===null)continue;let f=u.exo__Asset_uid;if(typeof f!="string"||f.length===0)continue;let d=Wi(u.exo__Instance_class);if(d.includes(du)){if(n.has(f))continue;let h=(typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:"")||(typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:"");if(h.length===0)continue;let m=(0,kr.derivePath)(h);if(m===null)continue;let g=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:"",_=g||Zye(m)||f.slice(0,8),b=u.exo__AssetSpace_dependsOnKind,T=typeof b=="string"?b:Array.isArray(b)&&typeof b[0]=="string"?b[0]:void 0;n.add(f),e.push({uid:f,git:h,folderName:m,label:_,namespace:g,dependsOnKind:T})}if(d.includes(FO)){let p=u.exo__Asset_label;typeof p=="string"&&p.length>0&&t.set(f,p)}}}return{infos:e,profileLabels:t}}assertTsFloor(e,t){(0,kr.assertTsFloorReconciled)(e,t,kr.SDK_FLOOR)}buildDiff(e){let{targetProfileUid:t,targetProfileLabel:n,sourceProfileUid:i,sourceProfileLabel:s,result:o,infos:c}=e,l=new Map;for(let S of c)l.set(S.uid,S);let u=new Set(l.keys()),f=new Set,d=new Set;for(let S of o.declaredOntologies)if(u.has(S)){f.add(S);let R=l.get(S)?.namespace;R!==void 0&&R.length>0&&d.add(R)}this.assertTsFloor(f,d);let p=new Set([...o.effective,...f]),h=new Map;for(let S of c){let R=(0,qc.existsSync)((0,hu.join)(this.vaultPath,S.folderName))?"active":(0,qc.existsSync)((0,hu.join)(this.vaultPath,(0,kr.parkedPathFor)(S.folderName)))?"parked":"absent";h.set(S.uid,R)}let m=new Set([...h].filter(([,S])=>S==="active").map(([S])=>S));for(let S of c)kr.CATALOG_KEEP_NAMESPACES.has(S.namespace)&&m.has(S.uid)&&p.add(S.uid);let g=[],_=[],b=[];for(let S of c){let R=(0,kr.classifyMountTransition)({state:h.get(S.uid)??"absent",inEffectiveSet:p.has(S.uid),dependsOnKind:S.dependsOnKind});switch(R){case"none":break;case"destroy":g.push({asUid:S.uid,folderName:S.folderName,label:S.label,files:this.enumerateFilesUnder(S.folderName)});break;case"park":_.push({asUid:S.uid,folderName:S.folderName,label:S.label,files:this.enumerateFilesUnder(S.folderName)});break;case"unpark":case"materialize":b.push({asUid:S.uid,folderName:S.folderName,httpsUrl:Qye(S.git),label:S.label,source:R==="unpark"?"unpark":"pull"});break}}let T=new Map;for(let S of g)T.set(S.asUid,S.files);let I=new Set(b.filter(S=>S.source==="unpark").map(S=>S.asUid)),w={targetProfileUid:t,targetProfileLabel:n,sourceProfileUid:i,sourceProfileLabel:s,filesToDestroy:T,assetSpacesBeingTornDown:g.map(S=>({asUid:S.asUid,asLabel:S.label,fileCount:S.files.length})),assetSpacesBeingParked:_.map(S=>({asUid:S.asUid,asLabel:S.label,fileCount:S.files.length})),assetSpacesBeingMaterialized:b.map(S=>({asUid:S.asUid,asLabel:S.label})),assetSpacesBeingUnparked:b.filter(S=>I.has(S.asUid)).map(S=>({asUid:S.asUid,asLabel:S.label}))};return{toDestroy:g,toPark:_,toMaterialize:b,plan:w}}async execute(e){let t=[],n=[],i=[];for(let s of e.toDestroy)this.mount.unmountAssetSpace(this.vaultPath,s.folderName),t.push(s.asUid);for(let s of e.toPark)this.mount.parkAssetSpace(this.vaultPath,s.folderName),n.push(s.asUid);for(let s of e.toMaterialize){if(s.source==="unpark")this.mount.unparkAssetSpace(this.vaultPath,s.folderName);else{let o=(0,hu.join)(this.vaultPath,s.folderName);await this.mount.pullAssetSpace(s.httpsUrl,this.ref,o)}this.mount.ensureGitmodulesEntry(this.vaultPath,s.folderName,s.httpsUrl),i.push(s.asUid)}return{destroyed:t,parked:n,materialized:i}}enumerateFilesUnder(e){let t=[],i=[(0,hu.join)(this.vaultPath,e)];for(;i.length>0;){let s=i.pop(),o;try{o=(0,qc.readdirSync)(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=(0,hu.join)(s,c.name);if(c.isDirectory()){if(c.name.startsWith("."))continue;i.push(l);continue}c.isFile()&&t.push(Jye(l,this.vaultPath))}}return t}readFrontmatter(e){let t;try{t=(0,qc.readFileSync)(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,kr.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Jye(r,e){let t=e.endsWith("/")?e:e+"/";return(r.startsWith(t)?r.slice(t.length):r).split("\\").join("/")}a(Jye,"relativeVaultPath");function Zye(r){let e=r.split("/").filter(t=>t.length>0);return e.length>0?e[e.length-1]:""}a(Zye,"lastSegment");ct();var qr=require("node:fs"),I7=require("node:crypto"),R7=require("node:child_process"),C7=require("node:util"),Wr=ne(require("node:path"));bm();var ot=ne(We());ct();var Do=require("node:fs"),E7=require("node:crypto"),zi=ne(require("node:path"));bm();var Gn=ne(We());Vi();var w7=require("node:child_process"),Kw=ne(We());var e0e=6e4,Po=class r{static{a(this,"RestPushService")}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??"",this.apiBase=(e.apiBase??"https://api.github.com").replace(/\/$/,"")}static resolveGhToken(e){let t=e??(()=>(0,w7.execFileSync)("gh",["auth","token"],{encoding:"utf8",timeout:15e3})),n;try{n=t()}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`RestPushService: \`gh auth token\` failed \u2014 is GitHub CLI installed and authenticated? (run \`gh auth login\`). Underlying: ${o}`.replace(r.PAT_REGEX,"***REDACTED***"))}let i=n.trim();if(i.length===0)throw new Error("RestPushService: `gh auth token` returned empty output \u2014 not authenticated. Run `gh auth login`.");return i}redact(e){return(typeof e=="string"?e:String(e)).replace(r.PAT_REGEX,"***REDACTED***")}async push(e,t,n,i,s){return(0,Kw.restCreateCommit)(this.buildTransport(),{owner:e,repo:t,branch:n,files:i,message:s,baseURL:this.apiBase,redact:a(o=>this.redact(o),"redact")})}transport(){return this.buildTransport()}buildTransport(){let e=this.token,t=this.fetchImpl,n=a(i=>this.redact(i),"redact");return async i=>{let s={Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"exocortex-cli"};e.length>0&&(s.Authorization=`Bearer ${e}`),i.contentType&&(s["Content-Type"]=i.contentType);let o;try{o=await t(i.url,{method:i.method,headers:s,body:i.body,signal:AbortSignal.timeout(e0e)})}catch(u){throw new Error(n(`GitHub request failed: ${t0e(u)}`))}let c=await o.text().catch(()=>"");if(o.status<200||o.status>=300){let u=a(f=>o.headers?.get?.(f)??void 0,"get");throw(0,Kw.enrichRateLimitError)(new Error(r0e(n(`GitHub request ${i.method} ${i.url} \u2192 HTTP ${o.status}: ${c}`),512)),u)}let l;try{l=c.length>0?JSON.parse(c):void 0}catch{l=void 0}return{status:o.status,json:l,text:c}}}};function t0e(r){if(r instanceof Error)return r.message;if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}a(t0e,"errMsg");function r0e(r,e){return r.length>e?r.slice(0,e)+"...":r}a(r0e,"truncate");Rt();var n0e=a(async r=>{let e=await E7.webcrypto.subtle.digest("SHA-1",r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),i0e={parse:a(r=>Ed(r,{schema:ru}),"parse"),stringify:a(r=>vd(r,{schema:ru,lineWidth:-1}),"stringify")};function s0e(r,e){if(r.tokenFromGh===!0)return Po.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,n=r.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(n.length===0)throw new Error("A GitHub token is required (private sync units read as 404 without one). Use --token-from-gh, --token <pat>, or set GITHUB_TOKEN / GH_TOKEN.");return n}a(s0e,"resolveToken");function o0e(r){let e=a(n=>zi.join(r,n),"abs"),t=a(async(n,i)=>{let s;try{s=await Do.promises.readdir(n,{withFileTypes:!0})}catch{return}for(let o of s){let c=zi.join(n,o.name);if(o.isDirectory()){if(o.name===".git")continue;await t(c,i)}else o.isFile()&&i.push(zi.relative(r,c).split(zi.sep).join("/"))}},"walk");return{async list(){let n=[];return(0,Do.existsSync)(r)&&await t(r,n),n},read:a(n=>Do.promises.readFile(e(n),"utf-8"),"read"),async readBinary(n){return new Uint8Array(await Do.promises.readFile(e(n)))},async write(){throw new Error("exosync-parity is read-only \u2014 write refused")},async delete(){throw new Error("exosync-parity is read-only \u2014 delete refused")}}}a(o0e,"nodeLocalFilesPort");function a0e(r,e){let t;try{t=(0,Gn.parkedPathFor)(e)}catch{return!1}return(0,Do.existsSync)(zi.join(r,t))}a(a0e,"isParked");function ep(r){let e=new Ut(r),t=new Gn.SpaceSpecAccumulator,n=[];for(let i of e.getAllFiles()){let s=e.getFrontmatter(i);if(!s)continue;let o=(0,Gn.classifySpaceDeclaration)(s,i.path);if(o.kind==="not-space"||(o.warning!==void 0&&t.warnings.push(o.warning),o.kind==="skip"))continue;let c=t.offer(o.candidate);if(c!==null){if(!(0,Do.existsSync)(zi.join(r,c.localPath))){a0e(r,c.localPath)&&n.push(c);continue}t.commit(o.candidate)}}return{specs:t.specs,parked:n,warnings:t.warnings}}a(ep,"collectVaultSpecs");function c0e(r,e){for(let t of r.repos){let n=t.headSha!==void 0?` @${t.headSha.slice(0,7)}`:"";e(`${t.repoKey}${n}: ${t.status} \u2014 ${t.inParity}/${t.filesChecked} in parity, M2 diffs ${t.m2SemanticDiffs}, accounted ${t.accountedCount}, M1 violations ${t.m1Violations.length}${t.attachmentHashSetIdentical!==void 0?`, attachment hash-set ${t.attachmentHashSetIdentical?"identical":"DIFFERS"}`:""}`),t.detail!==void 0&&e(` ${t.detail}`);for(let i of t.warnings)e(` warn: ${i}`);for(let i of t.discrepancies)e(` ${i.cls}: ${i.path}${i.detail!==void 0?` (${i.detail})`:""}`);for(let i of t.m1Violations)e(` M1 VIOLATION: ${i.path} \u2014 ${i.detail}`)}e((0,Gn.summarizeParityRound)(r))}a(c0e,"printHumanReport");function l0e(r,e){if(r.length!==0){e(`Parked AssetSpaces (frozen on this device, not synced): ${r.length}`);for(let t of r){let n=t.lastSyncedSha!==null?t.lastSyncedSha.slice(0,7):"never",i=t.remoteHeadSha!==null?t.remoteHeadSha.slice(0,7):"unread";switch(t.freshness){case"behind":e(` ${t.repoKey}: BEHIND \u2014 parked at ${n}, remote head is ${i}`);break;case"current":e(` ${t.repoKey}: current \u2014 parked at ${n}, matches the remote head`);break;case"unknown":e(` ${t.repoKey}: unknown \u2014 ${t.reason??"no verdict"}`);break}}}}a(l0e,"printParkedSection");async function u0e(r,e={}){let t=e.out??(_=>console.log(_)),n=zi.resolve(r.vault);if(!(0,Do.existsSync)(n))throw new Error(`Vault path does not exist: ${n}`);let i=s0e(r,e),s=new Po({token:i,...r.apiBase!==void 0?{apiBase:r.apiBase}:{}}),o=e.transportFactory?.(i,r.apiBase)??s.transport(),{specs:c,parked:l,warnings:u}=ep(n);for(let _ of u)t(`warn: ${_}`);let f=r.configDir??".obsidian",d=zi.join(n,f,"plugins","exocortex",Gn.WATERMARK_STORE_FILENAME),p=new Gn.FileWatermarkStore({read:a(async()=>{try{return await Do.promises.readFile(d,"utf-8")}catch{return null}},"read"),writeAtomic:a(async()=>{throw new Error("exosync-parity: watermark access is read-only by contract")},"writeAtomic")}),h=[];for(let _ of l)h.push(await(0,Gn.checkParkedStaleness)(_,{transport:o,watermarks:{get:a(b=>p.get(b),"get")},redact:a(b=>s.redact(b),"redact"),...r.apiBase!==void 0?{baseURL:r.apiBase}:{}}));if(r.json!==!0&&l0e(h,t),c.length===0)return r.json===!0&&h.length>0&&t(JSON.stringify({parked:h},null,2)),t("Nothing to check \u2014 no materialized AssetSpaces with a GitHub source found in this vault."),2;let m=new Gn.ParityValidator({transport:o,sha1:n0e,localFilesFor:a(_=>o0e(zi.join(n,_.localPath)),"localFilesFor"),watermarks:{get:a(_=>p.get(_),"get")},yaml:i0e,redact:a(_=>s.redact(_),"redact"),...r.apiBase!==void 0?{baseURL:r.apiBase}:{}});t(`ExoSync parity check: ${c.length} repo(s), vault ${n}`);let g=await m.runRound(c,{trigger:"standalone"});return r.json===!0?t(JSON.stringify({...g,parked:h},null,2)):c0e(g,t),g.vacuous?2:g.ok?0:1}a(u0e,"runExosyncParity");function v7(){return new fe("exosync-parity").description("ExoSync M1/M2 parity report: compare materialized sync units against their remote heads (read-only; RFC 4e4dc453 Phase E)").requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--json","Print the full round record as JSON").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--api-base <url>","GitHub API base (testing)").action(async r=>{try{process.exitCode=await u0e(r)}catch(e){ce.handle(e,{command:"exosync-parity"}),process.exitCode=1}})}a(v7,"exosyncParityCommand");ct();var Ki=require("node:fs"),zO=require("node:crypto"),Di=ne(require("node:path")),Mr=ne(We());Rt();var f0e="exosync-watermarks.local.json";function T7(r,e,t){let n=QO(e,t),i=new Po({token:n,...e.apiBase!==void 0?{apiBase:e.apiBase}:{}}),s=t.transportFactory?.(n,e.apiBase)??i.transport(),{specs:o,warnings:c}=ep(r),l=e.configDir??".obsidian",u=Di.join(r,l,"plugins","exocortex",f0e),f=Di.join(r,l,"plugins","exocortex",Mr.CONFLICT_CACHE_STORE_FILENAME),d=new Mr.LocalConflictCacheStore({io:Ga(f)}),p=Di.join(r,l,"plugins","exocortex",Mr.OUTBOX_STORE_FILENAME),h=new Mr.LocalOutboxStore({io:Ga(p)});return{resolver:new Mr.QuarantineResolver({transport:s,watermarkStore:new Mr.FileWatermarkStore(Ga(u)),localFilesFor:a(g=>Yw(Di.join(r,g.localPath)),"localFilesFor"),sha1:YO,...e.apiBase!==void 0?{baseURL:e.apiBase}:{},redact:a(g=>i.redact(g),"redact"),conflictCache:d,outbox:h}),specs:o,warnings:c}}a(T7,"buildResolver");async function d0e(r,e={}){let t=e.out??(l=>console.log(l)),n=Di.resolve(r.vault);if(!(0,Ki.existsSync)(n))throw new Error(`Vault path does not exist: ${n}`);let{resolver:i,specs:s,warnings:o}=T7(n,r,e);for(let l of o)t(`warn: ${l}`);if(s.length===0)return t("No materialized AssetSpaces with a GitHub source found in this vault."),0;let c=await i.listOpenConflicts(s);if(r.json===!0)return t(JSON.stringify(c,null,2)),0;if(c.length===0)return t("No open conflicts \u2014 nothing to resolve. \u2705"),0;t(`${c.length} open conflict(s):`);for(let l of c){let u=`${l.hasLocal?"local":"(no local)"} vs ${l.hasRemote?"remote":"(no remote)"}`;t(` ${l.repoKey} ${l.path} [${u}]${l.uid?` uid=${l.uid}`:""}`)}return t(""),t("Resolve with: exosync quarantine resolve <path> --take local|remote|file --vault <vault> --token-from-gh"),t(" (--take file also needs --file <merged-content-path>)"),0}a(d0e,"runQuarantineList");async function p0e(r,e,t={}){let n=t.out??(_=>console.log(_)),i=Di.resolve(e.vault);if(!(0,Ki.existsSync)(i))throw new Error(`Vault path does not exist: ${i}`);let s=(e.take??"").trim();if(s!=="local"&&s!=="remote"&&s!=="file")throw new Error("resolve requires --take local | remote | file (with --file <path> for the merged content)");let o;if(s==="file"){if(e.file===void 0||e.file.length===0)throw new Error("--take file requires --file <path> to the merged content");o={take:"merged",content:await Ki.promises.readFile(Di.resolve(e.file),"utf-8")}}else o={take:s};let{resolver:c,specs:l,warnings:u}=T7(i,e,t);for(let _ of u)n(`warn: ${_}`);let d=(await c.listOpenConflicts(l)).filter(_=>_.path===r&&(e.repo===void 0||_.repoKey===e.repo));if(d.length===0)return n(`No open conflict for "${r}"${e.repo?` in ${e.repo}`:""} \u2014 run \`exosync quarantine list\` to see the current set.`),1;if(d.length>1){n(`"${r}" conflicts in ${d.length} repos \u2014 disambiguate with --repo <repoKey>:`);for(let _ of d)n(` --repo ${_.repoKey}`);return 1}let p=d[0],h=l.find(_=>_.repoKey===p.repoKey),m=await c.resolve(h,p.path,o),g=m.awaitingPush===!0?" \u2014 awaiting push (run `exosync sync` to push it)":m.pushedSha!==void 0?` \u2014 pushed @${m.pushedSha.slice(0,7)}`:" \u2014 remote already matched";return n(`Resolved ${p.path} (${m.resolvedTo}) in ${p.repoKey}${g}.`),m.discardedLocalBackupPath!==void 0&&n(` \u21B3 your discarded local version is preserved at ${h.localPath}/${m.discardedLocalBackupPath}`),0}a(p0e,"runQuarantineResolve");function KO(r){return r.replace(/\r\n?/g,`
|
|
646
|
-
`).replace(/\n+$/,"")}a(KO,"normalizeForCompare");function h0e(r,e,t){let n=[...e].sort((o,c)=>o.path.localeCompare(c.path)),i=[],s=[];for(let o of n){let c=KO(o.content),l=i.find(u=>u.norm===c);if(l!==void 0){s.push({action:"delete",path:o.path,identicalTo:l.path});continue}i.push({path:o.path,norm:c}),i.length===1?s.push({action:"keep",path:o.path,uid:r}):s.push({action:"reuuid",path:o.path,fromUid:r,toUid:t()})}return s}a(h0e,"planDedupGroup");async function m0e(r,e={}){let t=e.out??(f=>console.log(f)),n=Di.resolve(r.vault);if(!(0,Ki.existsSync)(n))throw new Error(`Vault path does not exist: ${n}`);let{specs:i,warnings:s}=ep(n);for(let f of s)t(`warn: ${f}`);let o=[];for(let f of i){let d=Di.join(n,f.localPath);if(!(0,Ki.existsSync)(d))continue;let p=Yw(d);for(let h of await p.list())if(h.endsWith(".md"))try{o.push({path:Di.join(d,h),content:await p.read(h)})}catch{continue}}let c=(0,Mr.findDuplicateUidGroups)(o).map(f=>[f.uid,[...f.paths]]);if(c.length===0)return t("No duplicate uids on disk. \u2705"),0;let l=a(f=>Di.relative(n,f),"rel");if(r.auto===!0){let f=[];for(let[_,b]of c){let T=[],I=new Map;for(let w of b){let S=await Ki.promises.readFile(w,"utf-8");T.push({path:w,content:S}),I.set(w,S)}f.push({uid:_,decisions:h0e(_,T,zO.randomUUID),snap:I})}let d=0,p=0;t(`${c.length} duplicate uid(s) on disk \u2014 zero-loss plan:`);for(let{uid:_,decisions:b}of f){t(` ${_}:`);for(let T of b)T.action==="keep"?t(` KEEP ${l(T.path)} (keeps uid ${_})`):T.action==="reuuid"?(p++,t(` RE-UUID ${l(T.path)} (content differs \u2192 fresh uid; both survive, zero-loss)`)):(d++,t(` DELETE ${l(T.path)} (identical content \u2192 ${l(T.identicalTo)}; zero-loss)`))}if(r.apply!==!0)return t(""),t(`Plan: delete ${d} identical copy(ies), re-uuid ${p} differing variant(s).`),t("DRY-RUN \u2014 nothing changed. Re-run with `--auto --apply` to execute (a deleted copy's content always survives in the kept file; if previously synced it is also recoverable from the git remote)."),1;let h=0,m=0,g=0;for(let{decisions:_,snap:b}of f){for(let T of _){if(T.action!=="delete")continue;let I;try{I=await Ki.promises.readFile(T.path,"utf-8")}catch{continue}if(KO(I)!==KO(b.get(T.path)??"")){t(` ! skipped delete ${l(T.path)} (changed since scan \u2014 re-run dedup-uids)`),g++;continue}await Ki.promises.rm(T.path,{force:!0}),t(` deleted ${l(T.path)} (identical to ${l(T.identicalTo)})`),h++}for(let T of _){if(T.action!=="reuuid")continue;let I;try{I=await Ki.promises.readFile(T.path,"utf-8")}catch{continue}if((0,Mr.extractAssetUid)(I)!==T.fromUid){t(` ! skipped re-uuid ${l(T.path)} (uid changed since scan \u2014 re-run dedup-uids)`),g++;continue}let w=(0,Mr.rewriteAssetUid)(I,T.toUid);w!==I&&(await Ki.promises.writeFile(T.path,w,"utf-8"),t(` re-uuid ${l(T.path)} \u2192 uid=${T.toUid} (content differs from kept copy)`),m++)}}return t(`Resolved: deleted ${h} identical copy(ies), re-uuid ${m} differing variant(s).${g>0?` ${g} skipped (re-run).`:""} Run \`exosync sync\` to propagate.`),g>0?1:0}r.apply===!0&&t("Note: --apply only applies with --auto; running in report mode."),t(`${c.length} duplicate uid(s) on disk:`);for(let[f,d]of c){t(` ${f} \u2014 ${d.length} files:`);for(let p of d)t(` ${l(p)}`)}if(r.fix!==!0)return t(""),t("Re-run with --fix to assign a fresh uuid to every duplicate but the first (frontmatter rewrite only \u2014 never renames the file)."),1;let u=0;for(let f of(0,Mr.planDuplicateUidFix)(o,zO.randomUUID))await Ki.promises.writeFile(f.path,f.content,"utf-8"),t(` fixed ${l(f.path)} \u2192 uid=${f.toUid}`),u++;return t(`Reassigned ${u} uid(s). Run \`exosync sync\` to propagate.`),0}a(m0e,"runDedupUids");function HO(r){return r.requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--json","Machine-readable output").option("--api-base <url>","GitHub API base (testing)")}a(HO,"withQuarantineOptions");function A7(r){let e=new fe("quarantine").description("Inspect and resolve ExoSync conflicts (quarantine resolver; RFC 4e4dc453, finding a0a3d1d6)");HO(e.command("list").description("List open conflicts that need a manual choice")).action(async t=>{try{process.exitCode=await d0e(t)}catch(n){ce.handle(n,{command:"exosync quarantine list"}),process.exitCode=1}}),HO(e.command("resolve <path>").description("Resolve one conflict: --take local | remote | file <path> (merged)").option("--take <choice>","local | remote | file").option("--file <path>","Merged content file (with --take file)").option("--repo <repoKey>","Disambiguate a cross-repo path collision")).action(async(t,n)=>{try{process.exitCode=await p0e(t,n)}catch(i){ce.handle(i,{command:"exosync quarantine resolve"}),process.exitCode=1}}),r.addCommand(e),HO(r.command("dedup-uids").description("Report duplicate exo__Asset_uid on disk (#3477); --fix re-uuids all but the first; --auto zero-loss auto-resolve (identical\u2192delete, differing\u2192re-uuid; dry-run unless --apply)").option("--fix","Assign a fresh uuid to every duplicate but the first").option("--auto","Zero-loss auto-resolve: delete identical copies, re-uuid distinct variants (DRY-RUN unless --apply). Supersedes --fix.").option("--apply","Execute the --auto plan (without it --auto is a dry-run; a deleted copy's content always survives in the kept file, and if previously synced is recoverable from the git remote)")).action(async t=>{try{process.exitCode=await m0e(t)}catch(n){ce.handle(n,{command:"exosync dedup-uids"}),process.exitCode=1}})}a(A7,"registerQuarantineCommands");Rt();var YO=a(async r=>{let e=await I7.webcrypto.subtle.digest("SHA-1",r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),g0e={parse:a(r=>Ed(r,{schema:ru}),"parse"),stringify:a(r=>vd(r,{schema:ru,lineWidth:-1}),"stringify")};function QO(r,e){if(r.tokenFromGh===!0)return Po.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,n=r.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(n.length===0)throw new Error("A GitHub token is required (private sync units read as 404 and push needs write scope). Use --token-from-gh, --token <pat>, or set GITHUB_TOKEN / GH_TOKEN.");return n}a(QO,"resolveToken");function Yw(r){let e=a(i=>Wr.join(r,i),"abs"),t=a(async(i,s)=>{let o;try{o=await qr.promises.readdir(i,{withFileTypes:!0})}catch{return}for(let c of o){let l=Wr.join(i,c.name);if(c.isDirectory()){if(c.name===".git")continue;await t(l,s)}else c.isFile()&&s.push(Wr.relative(r,l).split(Wr.sep).join("/"))}},"walk"),n=a(async(i,s)=>{let o=Wr.dirname(i);await qr.promises.mkdir(o,{recursive:!0});let c=`${i}.local.tmp`;await s(c),await qr.promises.rename(c,i)},"writeAtomic");return{async list(){let i=[];return(0,qr.existsSync)(r)&&await t(r,i),i},read:a(i=>qr.promises.readFile(e(i),"utf-8"),"read"),async write(i,s){await n(e(i),o=>qr.promises.writeFile(o,s,"utf-8"))},async delete(i){await qr.promises.rm(e(i),{force:!0})},async readBinary(i){return new Uint8Array(await qr.promises.readFile(e(i)))},async writeBinary(i,s){let o=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);await n(e(i),c=>qr.promises.writeFile(c,Buffer.from(o)))},async stat(i){try{let s=await qr.promises.stat(e(i));return{mtimeMs:s.mtimeMs,size:s.size}}catch{return null}}}}a(Yw,"nodeLocalFilesPort");function Ga(r){return{async read(){try{return await qr.promises.readFile(r,"utf-8")}catch{return null}},async writeAtomic(e){await qr.promises.mkdir(Wr.dirname(r),{recursive:!0});let t=`${r}.local.tmp`;await qr.promises.writeFile(t,e,"utf-8"),await qr.promises.rename(t,r)}}}a(Ga,"nodeWatermarkFileIO");function mu(r,e=".obsidian"){let t=Wr.join(r,e,"plugins","exocortex",ot.MOUNT_BASE_STORE_FILENAME);return new ot.FileMountBaseStore(Ga(t))}a(mu,"nodeMountBaseStore");var y0e=(0,C7.promisify)(R7.execFile);function _0e(r){return async e=>{if(e.localPath.length===0||e.localPath.startsWith("-"))return null;try{let{stdout:t}=await y0e("git",["-C",r,"submodule","status",e.localPath],{timeout:3e4,maxBuffer:4194304}),n=t.match(/^[ +\-U]?([0-9a-f]{40})\b/m);return n?n[1]:null}catch{return null}}}a(_0e,"nodeLocalBaseShaProvider");function b0e(r){return{async check(e){let t=Wr.join(r,e.localPath);if(!(0,qr.existsSync)(t))return{fullyMaterialized:!1,reason:`mount folder ${e.localPath} does not exist`};let n=0;try{n=(await qr.promises.readdir(t)).length}catch{return{fullyMaterialized:!1,reason:`mount folder ${e.localPath} is not readable`}}return n===0&&e.spaceKind!=="file"?{fullyMaterialized:!1,reason:`mount folder ${e.localPath} is empty (mid-mount?)`}:{fullyMaterialized:!0}}}}a(b0e,"nodeMaterializationCheck");function S0e(r,e){let t=r.pushedSha!==void 0?` \u2192@${r.pushedSha.slice(0,7)}`:"",n=(r.outboxPushedCount??0)>0?`, pushed ${r.outboxPushedCount} resolved`:"",i=(r.outboxReconflictedCount??0)>0?`, ${r.outboxReconflictedCount} re-conflicted (remote moved)`:"";e(`${r.repoKey}${t}: ${r.status} \u2014 pulled ${r.pulledCount}, pushed ${r.pushedCount}, merged ${r.mergedCount}, quarantined ${r.quarantinedCount}${(r.pushedDeletes?.length??0)>0?`, deleted ${r.pushedDeletes.length}`:""}${n}${i}`),r.detail!==void 0&&e(` ${r.detail}`);for(let s of r.warnings)e(` warn: ${s}`);(r.quarantinedPaths?.length??0)>0&&e(` quarantined (\u2192 exosync quarantine resolve): ${r.quarantinedPaths.join(", ")}`),(r.deferredPaths?.length??0)>0&&e(` deferred (\u2192 full sync): ${r.deferredPaths.join(", ")}`),(r.deferredDeletes?.length??0)>0&&e(` deferred deletes: ${r.deferredDeletes.join(", ")}`),r.timings!==void 0&&(0,ot.totalMs)(r.timings)>0&&e(` ${(0,ot.formatRepoTimings)(r.repoKey,r.timings)}`)}a(S0e,"printRepoResult");function w0e(r){return r==="conflict"||r==="full-conflict"||r==="retry-exhausted"||r==="busy"||r==="auth-required"||r==="error"}a(w0e,"isFailureStatus");async function E0e(r,e,t={}){let n=t.out??(R=>console.log(R)),i=Wr.resolve(e.vault);if(!(0,qr.existsSync)(i))throw new Error(`Vault path does not exist: ${i}`);let s=QO(e,t),o=new Po({token:s,...e.apiBase!==void 0?{apiBase:e.apiBase}:{}}),c=t.transportFactory?.(s,e.apiBase)??o.transport(),{specs:l,warnings:u}=ep(i);for(let R of u)n(`warn: ${R}`);if(l.length===0)return n("Nothing to sync \u2014 no materialized AssetSpaces with a GitHub source found in this vault."),2;let f=e.configDir??".obsidian",d=Wr.join(i,f,"plugins","exocortex",ot.WATERMARK_STORE_FILENAME),p=Wr.join(i,f,"plugins","exocortex",ot.LOCAL_MANIFEST_STORE_FILENAME),h=Wr.join(i,f,"plugins","exocortex",ot.CONFLICT_CACHE_STORE_FILENAME),m=new ot.LocalConflictCacheStore({io:Ga(h)}),g=Wr.join(i,f,"plugins","exocortex",ot.OUTBOX_STORE_FILENAME),_=new ot.LocalOutboxStore({io:Ga(g)}),b=m,T=new ot.SyncEngine({transport:c,watermarkStore:new ot.FileWatermarkStore(Ga(d)),localManifestStore:new ot.FileLocalManifestStore(Ga(p)),mountBaseStore:mu(i,f),localBaseShaProvider:_0e(i),materializationCheck:b0e(i),localFilesFor:a(R=>Yw(Wr.join(i,R.localPath)),"localFilesFor"),sha1:YO,redact:a(R=>o.redact(R),"redact"),commitMessage:a((R,L,P=0)=>`exosync: ${L} change(s)${P>0?`, ${P} deletion(s)`:""} (CLI)`,"commitMessage"),mergeLayer:new ot.GatedStructuredMerger(new ot.StructuredMerger(g0e)),quarantine:b,outbox:_,...e.apiBase!==void 0?{baseURL:e.apiBase}:{}});n(`ExoSync ${r}: ${l.length} repo(s), vault ${i}`);let I=(0,ot.orderChildrenFirst)(l),w=e.json===!0?void 0:R=>{n(`[ExoSync] ${R.repoKey}: ${(0,ot.syncProgressPhaseText)(R)}`)},S=await T.syncAll(I,r,w);if(e.json===!0)n(JSON.stringify(S,null,2));else{for(let P of S)S0e(P,n);let R=S.reduce((P,M)=>({pulled:P.pulled+M.pulledCount,pushed:P.pushed+M.pushedCount,merged:P.merged+M.mergedCount,quarantined:P.quarantined+M.quarantinedCount}),{pulled:0,pushed:0,merged:0,quarantined:0});n(`Summary: ${S.length} repo(s) \u2014 pulled ${R.pulled}, pushed ${R.pushed}, merged ${R.merged}, quarantined ${R.quarantined}`);let L=(0,ot.aggregateTimings)(S);(0,ot.totalMs)(L)>0&&n((0,ot.formatTimingsLine)(L))}return S.some(R=>w0e(R.status))?1:0}a(E0e,"runExosyncSync");function XO(r){return r.requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--json","Print the full per-repo result array as JSON").option("--api-base <url>","GitHub API base (testing)")}a(XO,"withSyncOptions");function JO(r){return async e=>{try{process.exitCode=await E0e(r,e)}catch(t){ce.handle(t,{command:`exosync ${r}`}),process.exitCode=1}}}a(JO,"makeDirectionAction");function x7(){let r=new fe("exosync").description("ExoSync over the GitHub REST API: sync/pull/push the materialized AssetSpace set (CLI parity with the plugin; RFC 4e4dc453 Phase B). Read-only divergence check: `exosync-parity`.");return XO(r.command("sync").description("Full pull\u2192merge\u2192push cycle for every materialized repo")).action(JO("sync")),XO(r.command("pull").description("Apply remote changes only (nothing leaves the device; local changes re-derive)")).action(JO("pull")),XO(r.command("push").description("Send the local delta only (remote changes are pinned to re-derive on the next pull/sync)")).action(JO("push")),A7(r),r}a(x7,"exosyncCommand");var v0e=a(r=>{process.stderr.write(`${r}
|
|
644
|
+
`}a(zye,"settingAsset");function y7(){return new de("scaffold").description("Scaffold homoiconic configuration assets").addCommand(Kye())}a(y7,"scaffoldCommand");function Kye(){return new de("validation-settings").description("Scaffold the 4 validation-check setting__Setting instances (uid-uniqueness=true, rest=false) co-located in the chosen ontology").requiredOption("--vault <path>","Vault root directory").requiredOption("--ontology <uid>","UID of the ontology whose folder the check settings are co-located in").option("--output <type>","Response format: text|json","text").action(async r=>{let e=r.output??"text";ce.setFormat(e);try{let t=(0,pu.resolve)(r.vault);if(!(0,zw.existsSync)(t)||!(0,zw.statSync)(t).isDirectory())throw new ke(t);let s=(await new Tn(t).indexedAssets()).find(u=>(0,Oo.readUid)(u.metadata)===r.ontology);if(!s)throw new Error(`Ontology UID "${r.ontology}" not found in vault ${t} (its folder is where the check settings co-locate).`);let o=(0,pu.join)(t,(0,pu.dirname)(s.path)),c=new Date().toISOString().slice(0,19),l=[];for(let u of Hye){let f=(0,g7.randomUUID)(),d=(0,pu.join)(o,`${f}.md`);await(0,m7.writeFile)(d,zye(f,r.ontology,u.checkId,u.label,u.value,c),"utf-8"),l.push(d)}if(e==="json")console.log(JSON.stringify({vaultPath:t,ontology:r.ontology,targetDir:o,created:l},null,2));else{console.log(`OK: scaffolded ${l.length} validation-check setting(s) in ${o}`);for(let u of l)console.log(` ${u}`);console.log(`
|
|
645
|
+
Defaults: uid-uniqueness=true, co-location/shacl/dag=false. Run 'exocortex validate vault --vault <path>'.`)}}catch(t){ce.handle(t)}})}a(Kye,"scaffoldValidationCommand");ct();var O7=require("fs"),P7=require("path");var qc=require("node:fs"),hu=require("node:path"),kr=ne(We());var mt=require("node:fs"),b7=require("node:fs/promises"),S7=require("node:os"),an=require("node:path"),ls=ne(We());var Yye=/^https:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+?)(?:\.git)?$/,_7=50*1024*1024,Pi=class r{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??"",this.mountBaseStore=e.mountBaseStore}redact(e){return(typeof e=="string"?e:String(e)).replace(r.PAT_REGEX,"***REDACTED***")}static parseGitHubURL(e){let t=e.match(Yye);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}=r.parseGitHubURL(e);return t.startsWith("exoas-")?t.slice(6):t}async pullAssetSpace(e,t,n){let{owner:i,repo:s}=r.parseGitHubURL(e);if((0,mt.existsSync)(n)&&(0,mt.readdirSync)(n).length>0)throw new Error(`pullAssetSpace: target ${n} exists \u0438 not empty \u2014 refusing \u043A overwrite`);let o=await(0,ls.mountAssetSpaceFiles)({http:this.httpPort(),fs:this.fsPort(),owner:i,repo:s,ref:t,targetPath:n});if(this.mountBaseStore!==void 0)try{await this.mountBaseStore.set(`${i}/${s}#${ls.SYNC_BRANCH}`,o.sha)}catch{}return o}httpPort(){let e=this.fetchImpl,t=this.token,n=a(i=>this.redact(i),"redact");return{async fetchTarball(i,s,o){let c=`https://api.github.com/repos/${i}/${s}/tarball/${o}`,l={signal:AbortSignal.timeout(6e4)};t.length>0&&(l.headers={Authorization:`Bearer ${t}`,"User-Agent":"exocortex-cli","X-GitHub-Api-Version":"2022-11-28"});let u;try{u=await e(c,l)}catch(d){throw new Error(n(`pullAssetSpace: fetch error for ${c}: ${d instanceof Error?d.message:String(d)}`))}if(!u.ok){if(u.status===403){let d=u.headers?.get?.("x-ratelimit-remaining"),p=u.headers?.get?.("x-ratelimit-reset");if(d==="0"||p!=null){let h=p!=null?new Date(Number(p)*1e3).toISOString():"unknown";throw new Error(`pullAssetSpace: GitHub anonymous API rate-limit exceeded (60 req/hour). Reset at ${h}. Wait or use authenticated CLI.`)}}if(u.status===404){let d=t.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(n(`pullAssetSpace: fetch failed (404 Not Found) for ${c} \u2014 ${d}`))}throw new Error(n(`pullAssetSpace: fetch failed (${u.status} ${u.statusText}) for ${c}`))}let f=await u.arrayBuffer();if(f.byteLength>_7)throw new Error(`pullAssetSpace: tarball too large (${f.byteLength} bytes > ${_7})`);return new Uint8Array(f)}}}fsPort(){return{async exists(e){return(0,mt.existsSync)(e)},async read(e){return(0,mt.readFileSync)(e,"utf8")},async write(e,t){(0,mt.writeFileSync)(e,t,{encoding:"utf8"})},async removeDir(e){(0,mt.rmSync)(e,{recursive:!0,force:!0})},async materialize(e,t,n){let i=await(0,b7.mkdtemp)((0,an.join)((0,S7.tmpdir)(),`exo-bootstrap-${(0,an.basename)(e)}-`)),s=0;try{for(let o of t){let c=o.relPath;if(c.split("/").some(u=>u===".."))throw new Error(`pullAssetSpace: path traversal detected for entry "${c}"`);let l=(0,an.resolve)(i,c);if(l!==i&&!l.startsWith(i+an.sep))throw new Error(`pullAssetSpace: zip-slip detected for entry "${c}"`);(0,mt.mkdirSync)((0,an.dirname)(l),{recursive:!0}),(0,mt.writeFileSync)(l,o.content),s++,n?.(s)}(0,mt.mkdirSync)((0,an.dirname)(e),{recursive:!0});try{(0,mt.renameSync)(i,e)}catch(o){if(o.code==="EXDEV"){let{cpSync:c}=await import("node:fs");c(i,e,{recursive:!0}),(0,mt.rmSync)(i,{recursive:!0,force:!0})}else throw o}}catch(o){throw(0,mt.rmSync)(i,{recursive:!0,force:!0}),o}return s}}}ensureGitmodulesEntry(e,t,n){let i=(0,an.join)(e,".gitmodules"),s="";try{s=(0,mt.readFileSync)(i,"utf8")}catch(l){if(l.code!=="ENOENT")throw l}let{content:o,added:c}=(0,ls.appendGitmodulesEntry)(s,t,n);return c?((0,mt.appendFileSync)(i,o.slice(s.length),{encoding:"utf8"}),{added:!0}):{added:!1}}removeGitmodulesEntry(e,t){let n=(0,an.join)(e,".gitmodules"),i;try{i=(0,mt.readFileSync)(n,"utf8")}catch(o){if(o.code==="ENOENT")return{removed:!1};throw o}let s=(0,ls.stripGitmodulesEntry)(i,t);return s===i?{removed:!1}:((0,mt.writeFileSync)(n,s,{encoding:"utf8"}),{removed:!0})}static stripGitmodulesEntry(e,t){return(0,ls.stripGitmodulesEntry)(e,t)}unmountAssetSpace(e,t){let n=this.assertSafeVaultTarget(e,t,"unmountAssetSpace");this.removeGitmodulesEntry(e,t),(0,mt.existsSync)(n)&&(0,mt.rmSync)(n,{recursive:!0,force:!0})}parkAssetSpace(e,t){let n=this.assertSafeVaultTarget(e,t,"parkAssetSpace"),i=(0,ls.parkedPathFor)(t),s=this.assertSafeVaultTarget(e,i,"parkAssetSpace",{requireAssetspacesRoot:!1});if((0,mt.existsSync)(n)){if((0,mt.existsSync)(s))throw new Error(`parkAssetSpace: refusing to park "${t}" \u2014 a parked copy already exists at "${i}". Resolve by hand: one of the two holds work the other does not.`);this.removeGitmodulesEntry(e,t),(0,mt.mkdirSync)((0,an.dirname)(s),{recursive:!0}),(0,mt.renameSync)(n,s)}}unparkAssetSpace(e,t){let n=this.assertSafeVaultTarget(e,t,"unparkAssetSpace"),i=(0,ls.parkedPathFor)(t),s=this.assertSafeVaultTarget(e,i,"unparkAssetSpace",{requireAssetspacesRoot:!1});if(!(0,mt.existsSync)(s))throw new Error(`unparkAssetSpace: nothing parked at "${i}" for "${t}"`);if((0,mt.existsSync)(n))throw new Error(`unparkAssetSpace: refusing to unpark onto existing mount "${t}"`);(0,mt.mkdirSync)((0,an.dirname)(n),{recursive:!0}),(0,mt.renameSync)(s,n)}assertSafeVaultTarget(e,t,n,i={}){let s=i.requireAssetspacesRoot??!0,o=t.split("/");if(t.length===0||s&&!t.startsWith("assetspaces/")||o.some(u=>u.length===0||u==="."||u===".."))throw new Error(`${n}: refusing unsafe submodulePath "${t}"`);let c=(0,an.resolve)(e),l=(0,an.resolve)(c,t);if(l===c||!l.startsWith(c+an.sep))throw new Error(`${n}: target "${l}" escapes vault root "${c}"`);return l}};function Qye(r){let e=(0,kr.derivePath)(r);return e===null?r:(0,kr.deriveUrl)(e)??r}a(Qye,"toHttpsGitHubUrl");var Xye=new Set(["node_modules",".obsidian",".exocortex",".git"]),Zd=class{static{a(this,"CliApplyProfileService")}constructor(e){this.vaultPath=e.vaultPath,this.mount=e.mount??new Pi,this.ref=e.ref??"main"}scanVault(){let e=[],t=new Map,n=new Set,i=[this.vaultPath];for(;i.length>0;){let s=i.pop(),o;try{o=(0,qc.readdirSync)(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=(0,hu.join)(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||Xye.has(c.name))continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=this.readFrontmatter(l);if(u===null)continue;let f=u.exo__Asset_uid;if(typeof f!="string"||f.length===0)continue;let d=Wi(u.exo__Instance_class);if(d.includes(du)){if(n.has(f))continue;let h=(typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:"")||(typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:"");if(h.length===0)continue;let m=(0,kr.derivePath)(h);if(m===null)continue;let g=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:"",_=g||Zye(m)||f.slice(0,8),b=u.exo__AssetSpace_dependsOnKind,T=typeof b=="string"?b:Array.isArray(b)&&typeof b[0]=="string"?b[0]:void 0;n.add(f),e.push({uid:f,git:h,folderName:m,label:_,namespace:g,dependsOnKind:T})}if(d.includes(FO)){let p=u.exo__Asset_label;typeof p=="string"&&p.length>0&&t.set(f,p)}}}return{infos:e,profileLabels:t}}assertTsFloor(e,t){(0,kr.assertTsFloorReconciled)(e,t,kr.SDK_FLOOR)}buildDiff(e){let{targetProfileUid:t,targetProfileLabel:n,sourceProfileUid:i,sourceProfileLabel:s,result:o,infos:c}=e,l=new Map;for(let S of c)l.set(S.uid,S);let u=new Set(l.keys()),f=new Set,d=new Set;for(let S of o.declaredOntologies)if(u.has(S)){f.add(S);let R=l.get(S)?.namespace;R!==void 0&&R.length>0&&d.add(R)}this.assertTsFloor(f,d);let p=new Set([...o.effective,...f]),h=new Map;for(let S of c){let R=(0,qc.existsSync)((0,hu.join)(this.vaultPath,S.folderName))?"active":(0,qc.existsSync)((0,hu.join)(this.vaultPath,(0,kr.parkedPathFor)(S.folderName)))?"parked":"absent";h.set(S.uid,R)}let m=new Set([...h].filter(([,S])=>S==="active").map(([S])=>S));for(let S of c)kr.CATALOG_KEEP_NAMESPACES.has(S.namespace)&&m.has(S.uid)&&p.add(S.uid);let g=[],_=[],b=[];for(let S of c){let R=(0,kr.classifyMountTransition)({state:h.get(S.uid)??"absent",inEffectiveSet:p.has(S.uid),dependsOnKind:S.dependsOnKind});switch(R){case"none":break;case"destroy":g.push({asUid:S.uid,folderName:S.folderName,label:S.label,files:this.enumerateFilesUnder(S.folderName)});break;case"park":_.push({asUid:S.uid,folderName:S.folderName,label:S.label,files:this.enumerateFilesUnder(S.folderName)});break;case"unpark":case"materialize":b.push({asUid:S.uid,folderName:S.folderName,httpsUrl:Qye(S.git),label:S.label,source:R==="unpark"?"unpark":"pull"});break}}let T=new Map;for(let S of g)T.set(S.asUid,S.files);let I=new Set(b.filter(S=>S.source==="unpark").map(S=>S.asUid)),w={targetProfileUid:t,targetProfileLabel:n,sourceProfileUid:i,sourceProfileLabel:s,filesToDestroy:T,assetSpacesBeingTornDown:g.map(S=>({asUid:S.asUid,asLabel:S.label,fileCount:S.files.length})),assetSpacesBeingParked:_.map(S=>({asUid:S.asUid,asLabel:S.label,fileCount:S.files.length})),assetSpacesBeingMaterialized:b.map(S=>({asUid:S.asUid,asLabel:S.label})),assetSpacesBeingUnparked:b.filter(S=>I.has(S.asUid)).map(S=>({asUid:S.asUid,asLabel:S.label}))};return{toDestroy:g,toPark:_,toMaterialize:b,plan:w}}async execute(e){let t=[],n=[],i=[];for(let s of e.toDestroy)this.mount.unmountAssetSpace(this.vaultPath,s.folderName),t.push(s.asUid);for(let s of e.toPark)this.mount.parkAssetSpace(this.vaultPath,s.folderName),n.push(s.asUid);for(let s of e.toMaterialize){if(s.source==="unpark")this.mount.unparkAssetSpace(this.vaultPath,s.folderName);else{let o=(0,hu.join)(this.vaultPath,s.folderName);await this.mount.pullAssetSpace(s.httpsUrl,this.ref,o)}this.mount.ensureGitmodulesEntry(this.vaultPath,s.folderName,s.httpsUrl),i.push(s.asUid)}return{destroyed:t,parked:n,materialized:i}}enumerateFilesUnder(e){let t=[],i=[(0,hu.join)(this.vaultPath,e)];for(;i.length>0;){let s=i.pop(),o;try{o=(0,qc.readdirSync)(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=(0,hu.join)(s,c.name);if(c.isDirectory()){if(c.name.startsWith("."))continue;i.push(l);continue}c.isFile()&&t.push(Jye(l,this.vaultPath))}}return t}readFrontmatter(e){let t;try{t=(0,qc.readFileSync)(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,kr.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Jye(r,e){let t=e.endsWith("/")?e:e+"/";return(r.startsWith(t)?r.slice(t.length):r).split("\\").join("/")}a(Jye,"relativeVaultPath");function Zye(r){let e=r.split("/").filter(t=>t.length>0);return e.length>0?e[e.length-1]:""}a(Zye,"lastSegment");ct();var qr=require("node:fs"),I7=require("node:crypto"),R7=require("node:child_process"),C7=require("node:util"),Wr=ne(require("node:path"));bm();var ot=ne(We());ct();var Do=require("node:fs"),E7=require("node:crypto"),zi=ne(require("node:path"));bm();var Gn=ne(We());Vi();var w7=require("node:child_process"),Kw=ne(We());var e0e=6e4,Po=class r{static{a(this,"RestPushService")}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??"",this.apiBase=(e.apiBase??"https://api.github.com").replace(/\/$/,"")}static resolveGhToken(e){let t=e??(()=>(0,w7.execFileSync)("gh",["auth","token"],{encoding:"utf8",timeout:15e3})),n;try{n=t()}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`RestPushService: \`gh auth token\` failed \u2014 is GitHub CLI installed and authenticated? (run \`gh auth login\`). Underlying: ${o}`.replace(r.PAT_REGEX,"***REDACTED***"))}let i=n.trim();if(i.length===0)throw new Error("RestPushService: `gh auth token` returned empty output \u2014 not authenticated. Run `gh auth login`.");return i}redact(e){return(typeof e=="string"?e:String(e)).replace(r.PAT_REGEX,"***REDACTED***")}async push(e,t,n,i,s){return(0,Kw.restCreateCommit)(this.buildTransport(),{owner:e,repo:t,branch:n,files:i,message:s,baseURL:this.apiBase,redact:a(o=>this.redact(o),"redact")})}transport(){return this.buildTransport()}buildTransport(){let e=this.token,t=this.fetchImpl,n=a(i=>this.redact(i),"redact");return async i=>{let s={Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"exocortex-cli"};e.length>0&&(s.Authorization=`Bearer ${e}`),i.contentType&&(s["Content-Type"]=i.contentType);let o;try{o=await t(i.url,{method:i.method,headers:s,body:i.body,signal:AbortSignal.timeout(e0e)})}catch(u){throw new Error(n(`GitHub request failed: ${t0e(u)}`))}let c=await o.text().catch(()=>"");if(o.status<200||o.status>=300){let u=a(f=>o.headers?.get?.(f)??void 0,"get");throw(0,Kw.enrichRateLimitError)(new Error(r0e(n(`GitHub request ${i.method} ${i.url} \u2192 HTTP ${o.status}: ${c}`),512)),u)}let l;try{l=c.length>0?JSON.parse(c):void 0}catch{l=void 0}return{status:o.status,json:l,text:c}}}};function t0e(r){if(r instanceof Error)return r.message;if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}a(t0e,"errMsg");function r0e(r,e){return r.length>e?r.slice(0,e)+"...":r}a(r0e,"truncate");Rt();var n0e=a(async r=>{let e=await E7.webcrypto.subtle.digest("SHA-1",r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),i0e={parse:a(r=>Ed(r,{schema:ru}),"parse"),stringify:a(r=>vd(r,{schema:ru,lineWidth:-1}),"stringify")};function s0e(r,e){if(r.tokenFromGh===!0)return Po.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,n=r.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(n.length===0)throw new Error("A GitHub token is required (private sync units read as 404 without one). Use --token-from-gh, --token <pat>, or set GITHUB_TOKEN / GH_TOKEN.");return n}a(s0e,"resolveToken");function o0e(r){let e=a(n=>zi.join(r,n),"abs"),t=a(async(n,i)=>{let s;try{s=await Do.promises.readdir(n,{withFileTypes:!0})}catch{return}for(let o of s){let c=zi.join(n,o.name);if(o.isDirectory()){if(o.name===".git")continue;await t(c,i)}else o.isFile()&&i.push(zi.relative(r,c).split(zi.sep).join("/"))}},"walk");return{async list(){let n=[];return(0,Do.existsSync)(r)&&await t(r,n),n},read:a(n=>Do.promises.readFile(e(n),"utf-8"),"read"),async readBinary(n){return new Uint8Array(await Do.promises.readFile(e(n)))},async write(){throw new Error("exosync-parity is read-only \u2014 write refused")},async delete(){throw new Error("exosync-parity is read-only \u2014 delete refused")}}}a(o0e,"nodeLocalFilesPort");function a0e(r,e){let t;try{t=(0,Gn.parkedPathFor)(e)}catch{return!1}return(0,Do.existsSync)(zi.join(r,t))}a(a0e,"isParked");function ep(r){let e=new Ut(r),t=new Gn.SpaceSpecAccumulator,n=[];for(let i of e.getAllFiles()){let s=e.getFrontmatter(i);if(!s)continue;let o=(0,Gn.classifySpaceDeclaration)(s,i.path);if(o.kind==="not-space"||(o.warning!==void 0&&t.warnings.push(o.warning),o.kind==="skip"))continue;let c=t.offer(o.candidate);if(c!==null){if(!(0,Do.existsSync)(zi.join(r,c.localPath))){a0e(r,c.localPath)&&n.push(c);continue}t.commit(o.candidate)}}return{specs:t.specs,parked:n,warnings:t.warnings}}a(ep,"collectVaultSpecs");function c0e(r,e){for(let t of r.repos){let n=t.headSha!==void 0?` @${t.headSha.slice(0,7)}`:"";e(`${t.repoKey}${n}: ${t.status} \u2014 ${t.inParity}/${t.filesChecked} in parity, M2 diffs ${t.m2SemanticDiffs}, accounted ${t.accountedCount}, M1 violations ${t.m1Violations.length}${t.attachmentHashSetIdentical!==void 0?`, attachment hash-set ${t.attachmentHashSetIdentical?"identical":"DIFFERS"}`:""}`),t.detail!==void 0&&e(` ${t.detail}`);for(let i of t.warnings)e(` warn: ${i}`);for(let i of t.discrepancies)e(` ${i.cls}: ${i.path}${i.detail!==void 0?` (${i.detail})`:""}`);for(let i of t.m1Violations)e(` M1 VIOLATION: ${i.path} \u2014 ${i.detail}`)}e((0,Gn.summarizeParityRound)(r))}a(c0e,"printHumanReport");function l0e(r,e){if(r.length!==0){e(`Parked AssetSpaces (frozen on this device, not synced): ${r.length}`);for(let t of r){let n=t.lastSyncedSha!==null?t.lastSyncedSha.slice(0,7):"never",i=t.remoteHeadSha!==null?t.remoteHeadSha.slice(0,7):"unread";switch(t.freshness){case"behind":e(` ${t.repoKey}: BEHIND \u2014 parked at ${n}, remote head is ${i}`);break;case"current":e(` ${t.repoKey}: current \u2014 parked at ${n}, matches the remote head`);break;case"unknown":e(` ${t.repoKey}: unknown \u2014 ${t.reason??"no verdict"}`);break}}}}a(l0e,"printParkedSection");async function u0e(r,e={}){let t=e.out??(_=>console.log(_)),n=zi.resolve(r.vault);if(!(0,Do.existsSync)(n))throw new Error(`Vault path does not exist: ${n}`);let i=s0e(r,e),s=new Po({token:i,...r.apiBase!==void 0?{apiBase:r.apiBase}:{}}),o=e.transportFactory?.(i,r.apiBase)??s.transport(),{specs:c,parked:l,warnings:u}=ep(n);for(let _ of u)t(`warn: ${_}`);let f=r.configDir??".obsidian",d=zi.join(n,f,"plugins","exocortex",Gn.WATERMARK_STORE_FILENAME),p=new Gn.FileWatermarkStore({read:a(async()=>{try{return await Do.promises.readFile(d,"utf-8")}catch{return null}},"read"),writeAtomic:a(async()=>{throw new Error("exosync-parity: watermark access is read-only by contract")},"writeAtomic")}),h=[];for(let _ of l)h.push(await(0,Gn.checkParkedStaleness)(_,{transport:o,watermarks:{get:a(b=>p.get(b),"get")},redact:a(b=>s.redact(b),"redact"),...r.apiBase!==void 0?{baseURL:r.apiBase}:{}}));if(r.json!==!0&&l0e(h,t),c.length===0)return r.json===!0&&h.length>0&&t(JSON.stringify({parked:h},null,2)),t("Nothing to check \u2014 no materialized AssetSpaces with a GitHub source found in this vault."),2;let m=new Gn.ParityValidator({transport:o,sha1:n0e,localFilesFor:a(_=>o0e(zi.join(n,_.localPath)),"localFilesFor"),watermarks:{get:a(_=>p.get(_),"get")},yaml:i0e,redact:a(_=>s.redact(_),"redact"),...r.apiBase!==void 0?{baseURL:r.apiBase}:{}});t(`ExoSync parity check: ${c.length} repo(s), vault ${n}`);let g=await m.runRound(c,{trigger:"standalone"});return r.json===!0?t(JSON.stringify({...g,parked:h},null,2)):c0e(g,t),g.vacuous?2:g.ok?0:1}a(u0e,"runExosyncParity");function v7(){return new de("exosync-parity").description("ExoSync M1/M2 parity report: compare materialized sync units against their remote heads (read-only; RFC 4e4dc453 Phase E)").requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--json","Print the full round record as JSON").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--api-base <url>","GitHub API base (testing)").action(async r=>{try{process.exitCode=await u0e(r)}catch(e){ce.handle(e,{command:"exosync-parity"}),process.exitCode=1}})}a(v7,"exosyncParityCommand");ct();var Ki=require("node:fs"),zO=require("node:crypto"),Di=ne(require("node:path")),Mr=ne(We());Rt();var f0e="exosync-watermarks.local.json";function T7(r,e,t){let n=QO(e,t),i=new Po({token:n,...e.apiBase!==void 0?{apiBase:e.apiBase}:{}}),s=t.transportFactory?.(n,e.apiBase)??i.transport(),{specs:o,warnings:c}=ep(r),l=e.configDir??".obsidian",u=Di.join(r,l,"plugins","exocortex",f0e),f=Di.join(r,l,"plugins","exocortex",Mr.CONFLICT_CACHE_STORE_FILENAME),d=new Mr.LocalConflictCacheStore({io:Ga(f)}),p=Di.join(r,l,"plugins","exocortex",Mr.OUTBOX_STORE_FILENAME),h=new Mr.LocalOutboxStore({io:Ga(p)});return{resolver:new Mr.QuarantineResolver({transport:s,watermarkStore:new Mr.FileWatermarkStore(Ga(u)),localFilesFor:a(g=>Yw(Di.join(r,g.localPath)),"localFilesFor"),sha1:YO,...e.apiBase!==void 0?{baseURL:e.apiBase}:{},redact:a(g=>i.redact(g),"redact"),conflictCache:d,outbox:h}),specs:o,warnings:c}}a(T7,"buildResolver");async function d0e(r,e={}){let t=e.out??(l=>console.log(l)),n=Di.resolve(r.vault);if(!(0,Ki.existsSync)(n))throw new Error(`Vault path does not exist: ${n}`);let{resolver:i,specs:s,warnings:o}=T7(n,r,e);for(let l of o)t(`warn: ${l}`);if(s.length===0)return t("No materialized AssetSpaces with a GitHub source found in this vault."),0;let c=await i.listOpenConflicts(s);if(r.json===!0)return t(JSON.stringify(c,null,2)),0;if(c.length===0)return t("No open conflicts \u2014 nothing to resolve. \u2705"),0;t(`${c.length} open conflict(s):`);for(let l of c){let u=`${l.hasLocal?"local":"(no local)"} vs ${l.hasRemote?"remote":"(no remote)"}`;t(` ${l.repoKey} ${l.path} [${u}]${l.uid?` uid=${l.uid}`:""}`)}return t(""),t("Resolve with: exosync quarantine resolve <path> --take local|remote|file --vault <vault> --token-from-gh"),t(" (--take file also needs --file <merged-content-path>)"),0}a(d0e,"runQuarantineList");async function p0e(r,e,t={}){let n=t.out??(_=>console.log(_)),i=Di.resolve(e.vault);if(!(0,Ki.existsSync)(i))throw new Error(`Vault path does not exist: ${i}`);let s=(e.take??"").trim();if(s!=="local"&&s!=="remote"&&s!=="file")throw new Error("resolve requires --take local | remote | file (with --file <path> for the merged content)");let o;if(s==="file"){if(e.file===void 0||e.file.length===0)throw new Error("--take file requires --file <path> to the merged content");o={take:"merged",content:await Ki.promises.readFile(Di.resolve(e.file),"utf-8")}}else o={take:s};let{resolver:c,specs:l,warnings:u}=T7(i,e,t);for(let _ of u)n(`warn: ${_}`);let d=(await c.listOpenConflicts(l)).filter(_=>_.path===r&&(e.repo===void 0||_.repoKey===e.repo));if(d.length===0)return n(`No open conflict for "${r}"${e.repo?` in ${e.repo}`:""} \u2014 run \`exosync quarantine list\` to see the current set.`),1;if(d.length>1){n(`"${r}" conflicts in ${d.length} repos \u2014 disambiguate with --repo <repoKey>:`);for(let _ of d)n(` --repo ${_.repoKey}`);return 1}let p=d[0],h=l.find(_=>_.repoKey===p.repoKey),m=await c.resolve(h,p.path,o),g=m.awaitingPush===!0?" \u2014 awaiting push (run `exosync sync` to push it)":m.pushedSha!==void 0?` \u2014 pushed @${m.pushedSha.slice(0,7)}`:" \u2014 remote already matched";return n(`Resolved ${p.path} (${m.resolvedTo}) in ${p.repoKey}${g}.`),m.discardedLocalBackupPath!==void 0&&n(` \u21B3 your discarded local version is preserved at ${h.localPath}/${m.discardedLocalBackupPath}`),0}a(p0e,"runQuarantineResolve");function KO(r){return r.replace(/\r\n?/g,`
|
|
646
|
+
`).replace(/\n+$/,"")}a(KO,"normalizeForCompare");function h0e(r,e,t){let n=[...e].sort((o,c)=>o.path.localeCompare(c.path)),i=[],s=[];for(let o of n){let c=KO(o.content),l=i.find(u=>u.norm===c);if(l!==void 0){s.push({action:"delete",path:o.path,identicalTo:l.path});continue}i.push({path:o.path,norm:c}),i.length===1?s.push({action:"keep",path:o.path,uid:r}):s.push({action:"reuuid",path:o.path,fromUid:r,toUid:t()})}return s}a(h0e,"planDedupGroup");async function m0e(r,e={}){let t=e.out??(f=>console.log(f)),n=Di.resolve(r.vault);if(!(0,Ki.existsSync)(n))throw new Error(`Vault path does not exist: ${n}`);let{specs:i,warnings:s}=ep(n);for(let f of s)t(`warn: ${f}`);let o=[];for(let f of i){let d=Di.join(n,f.localPath);if(!(0,Ki.existsSync)(d))continue;let p=Yw(d);for(let h of await p.list())if(h.endsWith(".md"))try{o.push({path:Di.join(d,h),content:await p.read(h)})}catch{continue}}let c=(0,Mr.findDuplicateUidGroups)(o).map(f=>[f.uid,[...f.paths]]);if(c.length===0)return t("No duplicate uids on disk. \u2705"),0;let l=a(f=>Di.relative(n,f),"rel");if(r.auto===!0){let f=[];for(let[_,b]of c){let T=[],I=new Map;for(let w of b){let S=await Ki.promises.readFile(w,"utf-8");T.push({path:w,content:S}),I.set(w,S)}f.push({uid:_,decisions:h0e(_,T,zO.randomUUID),snap:I})}let d=0,p=0;t(`${c.length} duplicate uid(s) on disk \u2014 zero-loss plan:`);for(let{uid:_,decisions:b}of f){t(` ${_}:`);for(let T of b)T.action==="keep"?t(` KEEP ${l(T.path)} (keeps uid ${_})`):T.action==="reuuid"?(p++,t(` RE-UUID ${l(T.path)} (content differs \u2192 fresh uid; both survive, zero-loss)`)):(d++,t(` DELETE ${l(T.path)} (identical content \u2192 ${l(T.identicalTo)}; zero-loss)`))}if(r.apply!==!0)return t(""),t(`Plan: delete ${d} identical copy(ies), re-uuid ${p} differing variant(s).`),t("DRY-RUN \u2014 nothing changed. Re-run with `--auto --apply` to execute (a deleted copy's content always survives in the kept file; if previously synced it is also recoverable from the git remote)."),1;let h=0,m=0,g=0;for(let{decisions:_,snap:b}of f){for(let T of _){if(T.action!=="delete")continue;let I;try{I=await Ki.promises.readFile(T.path,"utf-8")}catch{continue}if(KO(I)!==KO(b.get(T.path)??"")){t(` ! skipped delete ${l(T.path)} (changed since scan \u2014 re-run dedup-uids)`),g++;continue}await Ki.promises.rm(T.path,{force:!0}),t(` deleted ${l(T.path)} (identical to ${l(T.identicalTo)})`),h++}for(let T of _){if(T.action!=="reuuid")continue;let I;try{I=await Ki.promises.readFile(T.path,"utf-8")}catch{continue}if((0,Mr.extractAssetUid)(I)!==T.fromUid){t(` ! skipped re-uuid ${l(T.path)} (uid changed since scan \u2014 re-run dedup-uids)`),g++;continue}let w=(0,Mr.rewriteAssetUid)(I,T.toUid);w!==I&&(await Ki.promises.writeFile(T.path,w,"utf-8"),t(` re-uuid ${l(T.path)} \u2192 uid=${T.toUid} (content differs from kept copy)`),m++)}}return t(`Resolved: deleted ${h} identical copy(ies), re-uuid ${m} differing variant(s).${g>0?` ${g} skipped (re-run).`:""} Run \`exosync sync\` to propagate.`),g>0?1:0}r.apply===!0&&t("Note: --apply only applies with --auto; running in report mode."),t(`${c.length} duplicate uid(s) on disk:`);for(let[f,d]of c){t(` ${f} \u2014 ${d.length} files:`);for(let p of d)t(` ${l(p)}`)}if(r.fix!==!0)return t(""),t("Re-run with --fix to assign a fresh uuid to every duplicate but the first (frontmatter rewrite only \u2014 never renames the file)."),1;let u=0;for(let f of(0,Mr.planDuplicateUidFix)(o,zO.randomUUID))await Ki.promises.writeFile(f.path,f.content,"utf-8"),t(` fixed ${l(f.path)} \u2192 uid=${f.toUid}`),u++;return t(`Reassigned ${u} uid(s). Run \`exosync sync\` to propagate.`),0}a(m0e,"runDedupUids");function HO(r){return r.requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--json","Machine-readable output").option("--api-base <url>","GitHub API base (testing)")}a(HO,"withQuarantineOptions");function A7(r){let e=new de("quarantine").description("Inspect and resolve ExoSync conflicts (quarantine resolver; RFC 4e4dc453, finding a0a3d1d6)");HO(e.command("list").description("List open conflicts that need a manual choice")).action(async t=>{try{process.exitCode=await d0e(t)}catch(n){ce.handle(n,{command:"exosync quarantine list"}),process.exitCode=1}}),HO(e.command("resolve <path>").description("Resolve one conflict: --take local | remote | file <path> (merged)").option("--take <choice>","local | remote | file").option("--file <path>","Merged content file (with --take file)").option("--repo <repoKey>","Disambiguate a cross-repo path collision")).action(async(t,n)=>{try{process.exitCode=await p0e(t,n)}catch(i){ce.handle(i,{command:"exosync quarantine resolve"}),process.exitCode=1}}),r.addCommand(e),HO(r.command("dedup-uids").description("Report duplicate exo__Asset_uid on disk (#3477); --fix re-uuids all but the first; --auto zero-loss auto-resolve (identical\u2192delete, differing\u2192re-uuid; dry-run unless --apply)").option("--fix","Assign a fresh uuid to every duplicate but the first").option("--auto","Zero-loss auto-resolve: delete identical copies, re-uuid distinct variants (DRY-RUN unless --apply). Supersedes --fix.").option("--apply","Execute the --auto plan (without it --auto is a dry-run; a deleted copy's content always survives in the kept file, and if previously synced is recoverable from the git remote)")).action(async t=>{try{process.exitCode=await m0e(t)}catch(n){ce.handle(n,{command:"exosync dedup-uids"}),process.exitCode=1}})}a(A7,"registerQuarantineCommands");Rt();var YO=a(async r=>{let e=await I7.webcrypto.subtle.digest("SHA-1",r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),g0e={parse:a(r=>Ed(r,{schema:ru}),"parse"),stringify:a(r=>vd(r,{schema:ru,lineWidth:-1}),"stringify")};function QO(r,e){if(r.tokenFromGh===!0)return Po.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,n=r.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(n.length===0)throw new Error("A GitHub token is required (private sync units read as 404 and push needs write scope). Use --token-from-gh, --token <pat>, or set GITHUB_TOKEN / GH_TOKEN.");return n}a(QO,"resolveToken");function Yw(r){let e=a(i=>Wr.join(r,i),"abs"),t=a(async(i,s)=>{let o;try{o=await qr.promises.readdir(i,{withFileTypes:!0})}catch{return}for(let c of o){let l=Wr.join(i,c.name);if(c.isDirectory()){if(c.name===".git")continue;await t(l,s)}else c.isFile()&&s.push(Wr.relative(r,l).split(Wr.sep).join("/"))}},"walk"),n=a(async(i,s)=>{let o=Wr.dirname(i);await qr.promises.mkdir(o,{recursive:!0});let c=`${i}.local.tmp`;await s(c),await qr.promises.rename(c,i)},"writeAtomic");return{async list(){let i=[];return(0,qr.existsSync)(r)&&await t(r,i),i},read:a(i=>qr.promises.readFile(e(i),"utf-8"),"read"),async write(i,s){await n(e(i),o=>qr.promises.writeFile(o,s,"utf-8"))},async delete(i){await qr.promises.rm(e(i),{force:!0})},async readBinary(i){return new Uint8Array(await qr.promises.readFile(e(i)))},async writeBinary(i,s){let o=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);await n(e(i),c=>qr.promises.writeFile(c,Buffer.from(o)))},async stat(i){try{let s=await qr.promises.stat(e(i));return{mtimeMs:s.mtimeMs,size:s.size}}catch{return null}}}}a(Yw,"nodeLocalFilesPort");function Ga(r){return{async read(){try{return await qr.promises.readFile(r,"utf-8")}catch{return null}},async writeAtomic(e){await qr.promises.mkdir(Wr.dirname(r),{recursive:!0});let t=`${r}.local.tmp`;await qr.promises.writeFile(t,e,"utf-8"),await qr.promises.rename(t,r)}}}a(Ga,"nodeWatermarkFileIO");function mu(r,e=".obsidian"){let t=Wr.join(r,e,"plugins","exocortex",ot.MOUNT_BASE_STORE_FILENAME);return new ot.FileMountBaseStore(Ga(t))}a(mu,"nodeMountBaseStore");var y0e=(0,C7.promisify)(R7.execFile);function _0e(r){return async e=>{if(e.localPath.length===0||e.localPath.startsWith("-"))return null;try{let{stdout:t}=await y0e("git",["-C",r,"submodule","status",e.localPath],{timeout:3e4,maxBuffer:4194304}),n=t.match(/^[ +\-U]?([0-9a-f]{40})\b/m);return n?n[1]:null}catch{return null}}}a(_0e,"nodeLocalBaseShaProvider");function b0e(r){return{async check(e){let t=Wr.join(r,e.localPath);if(!(0,qr.existsSync)(t))return{fullyMaterialized:!1,reason:`mount folder ${e.localPath} does not exist`};let n=0;try{n=(await qr.promises.readdir(t)).length}catch{return{fullyMaterialized:!1,reason:`mount folder ${e.localPath} is not readable`}}return n===0&&e.spaceKind!=="file"?{fullyMaterialized:!1,reason:`mount folder ${e.localPath} is empty (mid-mount?)`}:{fullyMaterialized:!0}}}}a(b0e,"nodeMaterializationCheck");function S0e(r,e){let t=r.pushedSha!==void 0?` \u2192@${r.pushedSha.slice(0,7)}`:"",n=(r.outboxPushedCount??0)>0?`, pushed ${r.outboxPushedCount} resolved`:"",i=(r.outboxReconflictedCount??0)>0?`, ${r.outboxReconflictedCount} re-conflicted (remote moved)`:"";e(`${r.repoKey}${t}: ${r.status} \u2014 pulled ${r.pulledCount}, pushed ${r.pushedCount}, merged ${r.mergedCount}, quarantined ${r.quarantinedCount}${(r.pushedDeletes?.length??0)>0?`, deleted ${r.pushedDeletes.length}`:""}${n}${i}`),r.detail!==void 0&&e(` ${r.detail}`);for(let s of r.warnings)e(` warn: ${s}`);(r.quarantinedPaths?.length??0)>0&&e(` quarantined (\u2192 exosync quarantine resolve): ${r.quarantinedPaths.join(", ")}`),(r.deferredPaths?.length??0)>0&&e(` deferred (\u2192 full sync): ${r.deferredPaths.join(", ")}`),(r.deferredDeletes?.length??0)>0&&e(` deferred deletes: ${r.deferredDeletes.join(", ")}`),r.timings!==void 0&&(0,ot.totalMs)(r.timings)>0&&e(` ${(0,ot.formatRepoTimings)(r.repoKey,r.timings)}`)}a(S0e,"printRepoResult");function w0e(r){return r==="conflict"||r==="full-conflict"||r==="retry-exhausted"||r==="busy"||r==="auth-required"||r==="error"}a(w0e,"isFailureStatus");async function E0e(r,e,t={}){let n=t.out??(R=>console.log(R)),i=Wr.resolve(e.vault);if(!(0,qr.existsSync)(i))throw new Error(`Vault path does not exist: ${i}`);let s=QO(e,t),o=new Po({token:s,...e.apiBase!==void 0?{apiBase:e.apiBase}:{}}),c=t.transportFactory?.(s,e.apiBase)??o.transport(),{specs:l,warnings:u}=ep(i);for(let R of u)n(`warn: ${R}`);if(l.length===0)return n("Nothing to sync \u2014 no materialized AssetSpaces with a GitHub source found in this vault."),2;let f=e.configDir??".obsidian",d=Wr.join(i,f,"plugins","exocortex",ot.WATERMARK_STORE_FILENAME),p=Wr.join(i,f,"plugins","exocortex",ot.LOCAL_MANIFEST_STORE_FILENAME),h=Wr.join(i,f,"plugins","exocortex",ot.CONFLICT_CACHE_STORE_FILENAME),m=new ot.LocalConflictCacheStore({io:Ga(h)}),g=Wr.join(i,f,"plugins","exocortex",ot.OUTBOX_STORE_FILENAME),_=new ot.LocalOutboxStore({io:Ga(g)}),b=m,T=new ot.SyncEngine({transport:c,watermarkStore:new ot.FileWatermarkStore(Ga(d)),localManifestStore:new ot.FileLocalManifestStore(Ga(p)),mountBaseStore:mu(i,f),localBaseShaProvider:_0e(i),materializationCheck:b0e(i),localFilesFor:a(R=>Yw(Wr.join(i,R.localPath)),"localFilesFor"),sha1:YO,redact:a(R=>o.redact(R),"redact"),commitMessage:a((R,L,P=0)=>`exosync: ${L} change(s)${P>0?`, ${P} deletion(s)`:""} (CLI)`,"commitMessage"),mergeLayer:new ot.GatedStructuredMerger(new ot.StructuredMerger(g0e)),quarantine:b,outbox:_,...e.apiBase!==void 0?{baseURL:e.apiBase}:{}});n(`ExoSync ${r}: ${l.length} repo(s), vault ${i}`);let I=(0,ot.orderChildrenFirst)(l),w=e.json===!0?void 0:R=>{n(`[ExoSync] ${R.repoKey}: ${(0,ot.syncProgressPhaseText)(R)}`)},S=await T.syncAll(I,r,w);if(e.json===!0)n(JSON.stringify(S,null,2));else{for(let P of S)S0e(P,n);let R=S.reduce((P,M)=>({pulled:P.pulled+M.pulledCount,pushed:P.pushed+M.pushedCount,merged:P.merged+M.mergedCount,quarantined:P.quarantined+M.quarantinedCount}),{pulled:0,pushed:0,merged:0,quarantined:0});n(`Summary: ${S.length} repo(s) \u2014 pulled ${R.pulled}, pushed ${R.pushed}, merged ${R.merged}, quarantined ${R.quarantined}`);let L=(0,ot.aggregateTimings)(S);(0,ot.totalMs)(L)>0&&n((0,ot.formatTimingsLine)(L))}return S.some(R=>w0e(R.status))?1:0}a(E0e,"runExosyncSync");function XO(r){return r.requiredOption("--vault <path>","Vault root path").option("--config-dir <name>","Obsidian config dir name (watermark location)",".obsidian").option("--token <pat>","GitHub PAT (or env GITHUB_TOKEN / GH_TOKEN). Prefer --token-from-gh.").option("--token-from-gh","Resolve the PAT via `gh auth token`").option("--json","Print the full per-repo result array as JSON").option("--api-base <url>","GitHub API base (testing)")}a(XO,"withSyncOptions");function JO(r){return async e=>{try{process.exitCode=await E0e(r,e)}catch(t){ce.handle(t,{command:`exosync ${r}`}),process.exitCode=1}}}a(JO,"makeDirectionAction");function x7(){let r=new de("exosync").description("ExoSync over the GitHub REST API: sync/pull/push the materialized AssetSpace set (CLI parity with the plugin; RFC 4e4dc453 Phase B). Read-only divergence check: `exosync-parity`.");return XO(r.command("sync").description("Full pull\u2192merge\u2192push cycle for every materialized repo")).action(JO("sync")),XO(r.command("pull").description("Apply remote changes only (nothing leaves the device; local changes re-derive)")).action(JO("pull")),XO(r.command("push").description("Send the local delta only (remote changes are pinned to re-derive on the next pull/sync)")).action(JO("push")),A7(r),r}a(x7,"exosyncCommand");var v0e=a(r=>{process.stderr.write(`${r}
|
|
647
647
|
`)},"DEFAULT_LOG"),Qw=class{static{a(this,"HeadlessConfirmGate")}constructor(e){this.yes=e.yes,this.verbose=e.verbose??!1,this.log=e.log??v0e}async confirmApply(e){if(this.verbose){let t=Array.from(e.filesToDestroy.values()).reduce((n,i)=>n+i.length,0);if(this.log(`[apply-profile] Target: ${e.targetProfileLabel} (${e.targetProfileUid})`),this.log(`[apply-profile] Source: ${e.sourceProfileLabel}`),this.log(`[apply-profile] ${t} files to remove, ${e.assetSpacesBeingTornDown.length} AS to tear down, ${e.assetSpacesBeingMaterialized.length} AS to materialize`),e.assetSpacesBeingParked.length>0){let n=e.assetSpacesBeingParked.reduce((i,s)=>i+s.fileCount,0);this.log(`[apply-profile] ${n} files to park (moved to .exocortex/parked, NOT removed), ${e.assetSpacesBeingParked.length} AS to park`)}e.assetSpacesBeingUnparked.length>0&&this.log(`[apply-profile] ${e.assetSpacesBeingUnparked.length} AS to unpark (restored from .exocortex/parked, no download)`)}return this.yes?!0:(this.log("[apply-profile] Refused: --yes flag required for headless mode (Decision #2 safety)."),!1)}};Rt();Bt();gr();async function T0e(r,e,t={}){let n=[],i=[],s=t.out??(R=>process.stdout.write(`${R}
|
|
648
648
|
`)),o=t.err??(R=>process.stderr.write(`${R}
|
|
649
|
-
`)),c=a(R=>{n.push(R),s(R)},"out"),l=a(R=>{i.push(R),o(R)},"err");if(!e.vault)throw new Ke("--vault is required");let u=(0,P7.resolve)(e.vault);if(!(0,O7.existsSync)(u))throw new ke(u);if(!r||r.length===0)throw new Ke("profile-uid argument is required","exocortex apply-profile <profile-uid> --vault <path>");let d=await(t.resolverFactory?.(e)??new Nw({vaultPath:u,warn:a(R=>l(R),"warn")})).resolveFilter(r);if(d.outcome==="missing-profile")throw new Ke(`Profile not found: ${r}`,"Run `exocortex find --class exo__Profile` to list available profiles");if(d.outcome==="error")return l(`[apply-profile] Resolver error: ${d.reason}`),{exitCode:5,stdout:n,stderr:i};if(d.outcome==="degraded")return l(`[apply-profile] Refused: profile resolution degraded \u2014 ${d.reason}. Apply aborted to prevent vault corruption.`),{exitCode:5,stdout:n,stderr:i};if(d.outcome!=="engaged")return l(`[apply-profile] Unexpected resolver outcome: ${d.outcome}`),{exitCode:5,stdout:n,stderr:i};let p=d.result,h=e.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,m=t.applyServiceFactory?.(e,u)??new Zd({vaultPath:u,ref:e.ref??"main",mount:new Pi({token:h,mountBaseStore:mu(u)})}),{infos:g,profileLabels:_}=m.scanVault(),b=_.get(r)??r,T;try{T=m.buildDiff({targetProfileUid:r,targetProfileLabel:b,sourceProfileUid:null,sourceProfileLabel:"<unknown>",result:p,infos:g})}catch(R){if(R instanceof kr.TsFloorViolationError)return l(`[apply-profile] Refused: ${R.message}`),{exitCode:5,stdout:n,stderr:i};throw R}if(!await(t.confirmGate??new Qw({yes:e.yes??!1,verbose:e.verbose??!1,log:a(R=>l(R),"log")})).confirmApply(T.plan))return{exitCode:0,stdout:n,stderr:i};if(T.toDestroy.length===0&&T.toMaterialize.length===0)return c(`[apply-profile] Already in target mount-state for ${b} \u2014 no-op.`),{exitCode:0,stdout:n,stderr:i};let S;try{S=await m.execute(T)}catch(R){return l(`[apply-profile] Execution failed: ${R instanceof Error?R.message:String(R)}`),{exitCode:5,stdout:n,stderr:i}}return c(`[apply-profile] Switched to ${b}: ${S.destroyed.length} AssetSpace(s) torn down, ${S.materialized.length} materialized.`),{exitCode:0,stdout:n,stderr:i}}a(T0e,"runApplyProfile");function D7(){return new
|
|
649
|
+
`)),c=a(R=>{n.push(R),s(R)},"out"),l=a(R=>{i.push(R),o(R)},"err");if(!e.vault)throw new Ke("--vault is required");let u=(0,P7.resolve)(e.vault);if(!(0,O7.existsSync)(u))throw new ke(u);if(!r||r.length===0)throw new Ke("profile-uid argument is required","exocortex apply-profile <profile-uid> --vault <path>");let d=await(t.resolverFactory?.(e)??new Nw({vaultPath:u,warn:a(R=>l(R),"warn")})).resolveFilter(r);if(d.outcome==="missing-profile")throw new Ke(`Profile not found: ${r}`,"Run `exocortex find --class exo__Profile` to list available profiles");if(d.outcome==="error")return l(`[apply-profile] Resolver error: ${d.reason}`),{exitCode:5,stdout:n,stderr:i};if(d.outcome==="degraded")return l(`[apply-profile] Refused: profile resolution degraded \u2014 ${d.reason}. Apply aborted to prevent vault corruption.`),{exitCode:5,stdout:n,stderr:i};if(d.outcome!=="engaged")return l(`[apply-profile] Unexpected resolver outcome: ${d.outcome}`),{exitCode:5,stdout:n,stderr:i};let p=d.result,h=e.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,m=t.applyServiceFactory?.(e,u)??new Zd({vaultPath:u,ref:e.ref??"main",mount:new Pi({token:h,mountBaseStore:mu(u)})}),{infos:g,profileLabels:_}=m.scanVault(),b=_.get(r)??r,T;try{T=m.buildDiff({targetProfileUid:r,targetProfileLabel:b,sourceProfileUid:null,sourceProfileLabel:"<unknown>",result:p,infos:g})}catch(R){if(R instanceof kr.TsFloorViolationError)return l(`[apply-profile] Refused: ${R.message}`),{exitCode:5,stdout:n,stderr:i};throw R}if(!await(t.confirmGate??new Qw({yes:e.yes??!1,verbose:e.verbose??!1,log:a(R=>l(R),"log")})).confirmApply(T.plan))return{exitCode:0,stdout:n,stderr:i};if(T.toDestroy.length===0&&T.toMaterialize.length===0)return c(`[apply-profile] Already in target mount-state for ${b} \u2014 no-op.`),{exitCode:0,stdout:n,stderr:i};let S;try{S=await m.execute(T)}catch(R){return l(`[apply-profile] Execution failed: ${R instanceof Error?R.message:String(R)}`),{exitCode:5,stdout:n,stderr:i}}return c(`[apply-profile] Switched to ${b}: ${S.destroyed.length} AssetSpace(s) torn down, ${S.materialized.length} materialized.`),{exitCode:0,stdout:n,stderr:i}}a(T0e,"runApplyProfile");function D7(){return new de("apply-profile").description("Apply the specified Profile (mount-state filesystem mutation). Requires --yes for headless mode.").argument("<profile-uid>","Target Profile UID").requiredOption("--vault <path>","Path to Obsidian vault").option("--yes","Confirm apply (headless mode safety override per RFC 22b50a17 Decision #2)",!1).option("--verbose","Print plan summary to stderr before deciding",!1).option("--ref <branch>","Git ref to pull when materialising AssetSpaces","main").option("--token <pat>","GitHub PAT for private-repo materialisation (or env GITHUB_TOKEN / GH_TOKEN)").action(async(e,t)=>{try{let n=await T0e(e,t);process.exit(n.exitCode)}catch(n){ce.handle(n)}})}a(D7,"applyProfileCommand");ct();var tp=require("node:path"),gu=require("node:fs"),F7=ne(We());Rt();Bt();function L7(){return new de("bootstrap").description("Bootstrap a vault with the SDK floor AssetSpace (exo). Pulls a tarball from a public GitHub repo, extracts \u043A assetspaces/, writes .gitmodules. Only --exo is required \u2014 bootstrap installs only the SDK platform. exocmd (the optional UI-command library) and any other AssetSpace are added afterwards via `exocortex assetspace add`. Example URL: https://github.com/kitelev/exoas-exo.").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)").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 r=>{try{if(!r.vault)throw new Ke("--vault is required");let e=(0,tp.resolve)(r.vault);(0,gu.mkdirSync)(e,{recursive:!0});let t=(0,tp.join)(e,".gitmodules"),n=(0,tp.join)(e,"assetspaces");if((0,gu.existsSync)(t))throw new Ke(`Vault ${e} already has .gitmodules \u2014 refusing \u043A re-bootstrap. Use \`assetspace add\` \u0434\u043B\u044F individual AS.`);if((0,gu.existsSync)(n)&&(0,gu.readdirSync)(n).length>0)throw new Ke(`Vault ${e}/assetspaces/ already has content \u2014 refusing \u043A re-bootstrap.`);let i=r.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,s=new Pi({token:i,mountBaseStore:mu(e)}),o=r.ref??"main",c=[],l=(0,F7.derivePath)(r.exo)??"assetspaces/exo",u=(0,tp.join)(e,l);process.stderr.write(`[bootstrap] Pulling ${r.exo}@${o} \u2192 ${l}/...
|
|
650
650
|
`);let f=await s.pullAssetSpace(r.exo,o,u);if(s.ensureGitmodulesEntry(e,l,r.exo),c.push({folder:l,url:r.exo,sha:f.sha,fileCount:f.fileCount}),r.json)process.stdout.write(JSON.stringify({vault:e,materialized:c},null,2)+`
|
|
651
651
|
`);else{process.stdout.write(`
|
|
652
652
|
\u2713 Bootstrap complete
|
|
@@ -658,7 +658,7 @@ Next steps:
|
|
|
658
658
|
`),process.stdout.write(` 2. git add . && git commit -m "feat: bootstrap vault"
|
|
659
659
|
`),process.stdout.write(` 3. (optional) Add the exocmd UI-command library: \`exocortex assetspace add --vault ${e} --url https://github.com/kitelev/exoas-exocmd\`
|
|
660
660
|
`),process.stdout.write(` 4. Add additional AssetSpaces via \`exocortex assetspace add --vault ${e} --url <github-url>\`
|
|
661
|
-
`)}process.exit(0)}catch(e){ce.handle(e)}})}a(L7,"bootstrapCommand");ct();var Xw=require("node:path"),N7=require("node:fs"),k7=ne(We());Rt();Bt();function A0e(r,e){return e!==void 0&&e.length>0?`assetspaces/${e}`:(0,k7.derivePath)(r)??`assetspaces/${Pi.deriveFolderName(r)}`}a(A0e,"resolveAddAssetSpacePath");function M7(){return new
|
|
661
|
+
`)}process.exit(0)}catch(e){ce.handle(e)}})}a(L7,"bootstrapCommand");ct();var Xw=require("node:path"),N7=require("node:fs"),k7=ne(We());Rt();Bt();function A0e(r,e){return e!==void 0&&e.length>0?`assetspaces/${e}`:(0,k7.derivePath)(r)??`assetspaces/${Pi.deriveFolderName(r)}`}a(A0e,"resolveAddAssetSpacePath");function M7(){return new de("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 r=>{try{if(!r.vault)throw new Ke("--vault is required");if(!r.url)throw new Ke("--url is required");let e=(0,Xw.resolve)(r.vault);if(!(0,N7.existsSync)(e))throw new ke(e);let t=r.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,n=new Pi({token:t,mountBaseStore:mu(e)}),i=r.ref??"main",s=A0e(r.url,r.folder),o=(0,Xw.join)(e,s);process.stderr.write(`[assetspace-add] Pulling ${r.url}@${i} \u2192 ${s}/...
|
|
662
662
|
`);let c=await n.pullAssetSpace(r.url,i,o),l=n.ensureGitmodulesEntry(e,s,r.url);r.json?process.stdout.write(JSON.stringify({vault:e,folder:s,url:r.url,sha:c.sha,fileCount:c.fileCount,gitmodulesEntryAdded:l.added},null,2)+`
|
|
663
663
|
`):(process.stdout.write(`
|
|
664
664
|
\u2713 AssetSpace added
|
|
@@ -670,13 +670,13 @@ Next steps:
|
|
|
670
670
|
`)))(h)},"out"),s=a(h=>{n.push(h),(e.err??(m=>process.stderr.write(`${m}
|
|
671
671
|
`)))(h)},"err");if(!r.vault)throw new Ke("--vault is required");let o=(0,Jw.resolve)(r.vault);if(!(0,ZO.existsSync)(o))throw new ke(o);let c=I0e(r),u=(e.scanInfos?.(o)??new Zd({vaultPath:o}).scanVault().infos).find(h=>h.folderName===c);if(u!==void 0&&(0,rp.isTsFloorAssetSpace)(u.uid,u.namespace)||(0,rp.isTsFloorMountPath)(c)){let h=u?.label??c,m=u?`${u.namespace||u.uid}`:"path resolves to a floor namespace";return s(`[assetspace-remove] Refused: \xAB${h}\xBB (${m}) is a TS-floor AssetSpace \u2014 unmounting it would self-brick the runtime (R24). Aborted, no changes made.`),{exitCode:5,stdout:t,stderr:n,removed:!1,folder:c}}let d=(0,ZO.existsSync)((0,Jw.join)(o,c)),p=e.unmount??((h,m)=>new Pi().unmountAssetSpace(h,m));try{p(o,c)}catch(h){return s(`[assetspace-remove] Unmount failed: ${h instanceof Error?h.message:String(h)}`),{exitCode:5,stdout:t,stderr:n,removed:!1,folder:c}}return r.json?i(JSON.stringify({vault:o,folder:c,existedBefore:d,unmounted:!0},null,2)):d?(i(`
|
|
672
672
|
\u2713 AssetSpace unmounted`),i(` Folder: ${c} (removed from vault + .gitmodules)`)):(i(`
|
|
673
|
-
\u2713 AssetSpace already absent \u2014 .gitmodules stanza stripped (no-op)`),i(` Folder: ${c}`)),{exitCode:0,stdout:t,stderr:n,removed:!0,folder:c}}a(R0e,"runAssetSpaceRemove");function j7(){return new
|
|
673
|
+
\u2713 AssetSpace already absent \u2014 .gitmodules stanza stripped (no-op)`),i(` Folder: ${c}`)),{exitCode:0,stdout:t,stderr:n,removed:!0,folder:c}}a(R0e,"runAssetSpaceRemove");function j7(){return new de("assetspace-remove").description("Unmount a single AssetSpace (inverse of assetspace-add). Strips its .gitmodules stanza and deletes the mount folder. TS-floor AssetSpaces ({exo}) are refused.").requiredOption("--vault <path>","Path to target vault").option("--folder <path>","Vault-relative mount path to unmount (e.g. assetspaces/kitelev/exoas-pmbok-ontology). Takes precedence over --url.").option("--url <url>","Public GitHub URL of the AssetSpace \u2014 derives the canonical mount path (parity with assetspace-add).").option("--json","Emit result as JSON",!1).action(async r=>{try{let e=await R0e(r);process.exit(e.exitCode)}catch(e){ce.handle(e)}})}a(j7,"assetSpaceRemoveCommand");ct();var $7=require("node:path"),U7=require("node:fs");Rt();Bt();async function C0e(r,e={}){let t=e.out??(l=>process.stdout.write(`${l}
|
|
674
674
|
`)),n=e.err??(l=>process.stderr.write(`${l}
|
|
675
|
-
`));if(!r.registry)throw new Ke("--registry <path> is required");if(!r.self)throw new Ke("--self <owner/repo | git-url | namespace> is required");let i=(0,$7.resolve)(r.registry);if(!(0,U7.existsSync)(i))throw new Ke(`Registry path does not exist: ${i}`,"Clone kitelev/exoas-registry first, then pass --registry <path>");let o=await new jw({warn:a(l=>n(l),"warn")}).resolve(i,r.self),c=r.format??"urls";if(o.outcome==="self-not-found"){let l=`[resolve-deps] self '${r.self}' not found among ${o.descriptorCount} registry descriptor(s) \u2014 validating standalone (no dependencies to materialise).`;return r.strict?(n(`[resolve-deps] STRICT: self '${r.self}' not registered. Add an exo__AssetSpace descriptor to kitelev/exoas-registry.`),c==="json"&&t(JSON.stringify(o,null,2)),{exitCode:2,outcome:o}):(n(l),c==="json"&&t(JSON.stringify(o,null,2)),{exitCode:0,outcome:o})}if(o.missingDescriptors.length>0&&n(`[resolve-deps] \u26A0\uFE0F ${o.missingDescriptors.length} dangling dependsOn edge(s) (no descriptor in registry): `+o.missingDescriptors.join(", ")),o.sourceless.length>0&&n(`[resolve-deps] \u26A0\uFE0F ${o.sourceless.length} dependency descriptor(s) have no source URL (cannot clone): `+o.sourceless.map(l=>l.namespace??l.uid).join(", ")),o.unsafeSources.length>0&&n(`[resolve-deps] \u26A0\uFE0F ${o.unsafeSources.length} dependency source(s) rejected as unsafe git-clone targets (option/transport injection) \u2014 NOT emitted: `+o.unsafeSources.map(l=>`${l.namespace??l.uid}=${l.source}`).join(", ")),c==="json")t(JSON.stringify(o,null,2));else{let l=new Set(o.unsafeSources.map(u=>u.uid));for(let u of o.dependencies)u.source&&u.source.length>0&&!l.has(u.uid)&&t(u.source)}return{exitCode:0,outcome:o}}a(C0e,"runResolveDeps");function B7(){return new
|
|
675
|
+
`));if(!r.registry)throw new Ke("--registry <path> is required");if(!r.self)throw new Ke("--self <owner/repo | git-url | namespace> is required");let i=(0,$7.resolve)(r.registry);if(!(0,U7.existsSync)(i))throw new Ke(`Registry path does not exist: ${i}`,"Clone kitelev/exoas-registry first, then pass --registry <path>");let o=await new jw({warn:a(l=>n(l),"warn")}).resolve(i,r.self),c=r.format??"urls";if(o.outcome==="self-not-found"){let l=`[resolve-deps] self '${r.self}' not found among ${o.descriptorCount} registry descriptor(s) \u2014 validating standalone (no dependencies to materialise).`;return r.strict?(n(`[resolve-deps] STRICT: self '${r.self}' not registered. Add an exo__AssetSpace descriptor to kitelev/exoas-registry.`),c==="json"&&t(JSON.stringify(o,null,2)),{exitCode:2,outcome:o}):(n(l),c==="json"&&t(JSON.stringify(o,null,2)),{exitCode:0,outcome:o})}if(o.missingDescriptors.length>0&&n(`[resolve-deps] \u26A0\uFE0F ${o.missingDescriptors.length} dangling dependsOn edge(s) (no descriptor in registry): `+o.missingDescriptors.join(", ")),o.sourceless.length>0&&n(`[resolve-deps] \u26A0\uFE0F ${o.sourceless.length} dependency descriptor(s) have no source URL (cannot clone): `+o.sourceless.map(l=>l.namespace??l.uid).join(", ")),o.unsafeSources.length>0&&n(`[resolve-deps] \u26A0\uFE0F ${o.unsafeSources.length} dependency source(s) rejected as unsafe git-clone targets (option/transport injection) \u2014 NOT emitted: `+o.unsafeSources.map(l=>`${l.namespace??l.uid}=${l.source}`).join(", ")),c==="json")t(JSON.stringify(o,null,2));else{let l=new Set(o.unsafeSources.map(u=>u.uid));for(let u of o.dependencies)u.source&&u.source.length>0&&!l.has(u.uid)&&t(u.source)}return{exitCode:0,outcome:o}}a(C0e,"runResolveDeps");function B7(){return new de("resolve-deps").description("Resolve an AssetSpace repo's transitive dependsOn closure from the central registry and print dependency clone URLs (issue #3513). Used by the per-AssetSpace SHACL CI gate to materialise dependent TBox.").requiredOption("--registry <path>","Path to a checked-out central registry (kitelev/exoas-registry)").requiredOption("--self <id>","Identity of the calling repo: an owner/repo slug (e.g. kitelev/exoas-exo, matches GitHub's github.repository), a full git URL, or a bare namespace").option("--format <type>","Output format: urls (one clone URL per line) | json (full diagnostics)","urls").option("--strict","Exit non-zero (2) when self is not registered, instead of validating standalone",!1).action(async r=>{try{let{exitCode:e}=await C0e(r);process.exit(e)}catch(e){ce.handle(e)}})}a(B7,"resolveDepsCommand");ct();function V7(){let r=new de("cache").description("SPARQL query-result cache maintenance (clear / stats). For read-after-write, prefer `query --no-cache` or a short `--cache-ttl`.");return r.addCommand(x0e()),r.addCommand(O0e()),r}a(V7,"cacheCommand");function x0e(){return new de("clear").description("Remove all cached SPARQL query results from disk").option("--output <format>","Output format: text | json","text").action(async r=>{let e=new Fa,t=await e.getCacheStats();if(await e.clear(),r.output==="json"){console.log(JSON.stringify({success:!0,data:{action:"clear",cacheDir:e.getCacheDir(),clearedEntries:t.entryCount,freedBytes:t.totalSizeBytes}}));return}console.log(`\u{1F5D1}\uFE0F Cleared ${t.entryCount} cached query result(s) (${G7(t.totalSizeBytes)} freed) from ${e.getCacheDir()}`)})}a(x0e,"cacheClearCommand");function O0e(){return new de("stats").description("Show query-result cache entry count and total size").option("--output <format>","Output format: text | json","text").action(async r=>{let e=new Fa,t=await e.getCacheStats();if(r.output==="json"){console.log(JSON.stringify({success:!0,data:{cacheDir:e.getCacheDir(),entryCount:t.entryCount,totalSizeBytes:t.totalSizeBytes}}));return}console.log(`\u{1F4CA} SPARQL query-result cache: ${e.getCacheDir()}`),console.log(` Entries: ${t.entryCount.toLocaleString()}`),console.log(` Size: ${G7(t.totalSizeBytes)}`)})}a(O0e,"cacheStatsCommand");function G7(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}a(G7,"formatBytes");ct();var e8=require("readline");function q7(r){let e=r.aliases;if(e!==void 0&&(!Array.isArray(e)||e.some(n=>typeof n!="string")))return"`aliases` must be an array of strings";if(r.body!==void 0&&typeof r.body!="string")return"`body` must be a string";if(r.status!==void 0&&typeof r.status!="string"&&r.status!==!1)return"`status` must be a status name or false";let t=r.properties;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t))return"`properties` must be an object";for(let[n,i]of Object.entries(t))if((Array.isArray(i)?i:[i]).some(o=>typeof o!="string"))return`property \`${n}\` must be a string or an array of strings`}return null}a(q7,"invalidCreateAssetShape");function W7(r){let e=["create","--vault",r.vault,"--class",r.class,"--label",r.label];for(let t of r.aliases??[])e.push("--aliases",t);for(let[t,n]of Object.entries(r.properties??{})){let i=Array.isArray(n)?n:[n];for(let s of i)e.push("--property",`${t}=${s}`)}return r.body!==void 0&&e.push("--body",r.body),r.status===!1?e.push("--no-status"):typeof r.status=="string"&&e.push("--status",r.status),r.validate!==!1&&e.push("--validate"),r.dryRun&&e.push("--dry-run"),e}a(W7,"buildCreateAssetArgs");function H7(r){let e=["apply",r.command,r.target,"--vault",r.vault,"--json","--yes"];return r.input!==void 0&&e.push("--input",JSON.stringify(r.input)),r.dryRun&&e.push("--dry-run"),e}a(H7,"buildCreateEffortArgs");var P0e={oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},z7=[{name:"create_asset",description:"Create a vault asset through the Exocortex creation pipeline (co-location by exo__Asset_isDefinedBy, dangling-wikilink rejection, unknown-property-name rejection and \u2014 by default \u2014 SHACL-lite conformance validation before the file is written). Values are passed as an argument vector, so labels, bodies and property values containing $, backticks, quotes, parentheses or newlines are preserved byte-identically.",inputSchema:{type:"object",properties:{vault:{type:"string",description:"Path to the Obsidian vault."},class:{type:"string",description:"Class UUID or short name (e.g. ems__Task)."},label:{type:"string",description:"exo__Asset_label for the new asset."},properties:{type:"object",description:"Frontmatter properties. A string sets one value; an array of strings sets a multi-value (YAML array) property.",additionalProperties:P0e},aliases:{type:"array",items:{type:"string"},description:"Additional aliases."},body:{type:"string",description:"Markdown body of the asset."},status:{type:["string","boolean"],description:"ems__Effort_status name for a status-bearing class (e.g. Backlog, Doing). Pass false to create a status-less asset. Omit for the CLI default."},validate:{type:"boolean",default:!0,description:"Run the pre-write SHACL-lite conformance gate. Defaults to true; pass false to skip it."},dryRun:{type:"boolean",description:"Preview without writing the file."}},required:["vault","class","label"],additionalProperties:!1}},{name:"create_effort",description:"Create an effort (Task / Project / Area / \u2026) by applying a homoiconic Exocortex command to a target asset \u2014 the canonical effort-creation path. Returns the {command,target,created:[{uuid,path,label}]} envelope.",inputSchema:{type:"object",properties:{vault:{type:"string",description:"Path to the Obsidian vault."},command:{type:"string",description:"Command cliName slug (e.g. create-task) or command UUID."},target:{type:"string",description:"Vault-relative path to the target asset the command is applied to."},input:{type:"object",description:`userInput for the command's grounding (serialised as JSON), e.g. {"value":"New label"}.`},dryRun:{type:"boolean",description:"Preview without writing."}},required:["vault","command","target"],additionalProperties:!1}}];var D0e="2024-11-05",Q7=-32700,K7=-32600,F0e=-32601,X7=-32603;function np(r,e=!1){return e?{content:[{type:"text",text:r}],isError:!0}:{content:[{type:"text",text:r}]}}a(np,"textResult");function L0e(r){let e=r.split(`
|
|
676
676
|
`).map(n=>n.trim()).filter(n=>n.length>0),t=e[e.length-1];if(t!==void 0)try{return JSON.parse(t)}catch{return}}a(L0e,"parseLastJsonLine");function Y7(r,e){return e.filter(t=>{let n=r[t];return typeof n!="string"||n.trim().length===0})}a(Y7,"missingStringFields");var Zw=class{constructor(e){this.deps=e}static{a(this,"McpServer")}async handle(e){if(typeof e!="object"||e===null||Array.isArray(e))return{jsonrpc:"2.0",id:null,error:{code:K7,message:"Invalid request: expected a JSON-RPC object"}};let t=e.id,n=t===void 0;if(typeof e.method!="string")return n?null:{jsonrpc:"2.0",id:t??null,error:{code:K7,message:"Invalid request: missing method"}};if(n)return null;let i=t??null;switch(e.method){case"initialize":return{jsonrpc:"2.0",id:i,result:{protocolVersion:D0e,capabilities:{tools:{}},serverInfo:{name:"exocortex",version:this.deps.version}}};case"ping":return{jsonrpc:"2.0",id:i,result:{}};case"tools/list":return{jsonrpc:"2.0",id:i,result:{tools:z7}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:F0e,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,n=e.arguments??{},i;if(t==="create_asset"){let c=Y7(n,["vault","class","label"]);if(c.length>0)return np(`create_asset: missing required argument(s): ${c.join(", ")}`,!0);let l=q7(n);if(l!==null)return np(`create_asset: ${l}`,!0);i=W7(n)}else if(t==="create_effort"){let c=Y7(n,["vault","command","target"]);if(c.length>0)return np(`create_effort: missing required argument(s): ${c.join(", ")}`,!0);i=H7(n)}else return np(`Unknown tool: ${String(t)}`,!0);let s=await this.deps.runCli(i);if(s.exitCode!==0){let c=s.stderr.trim()||s.stdout.trim()||"(no diagnostic output)";return np(`exocortex-cli exited ${s.exitCode}
|
|
677
677
|
${c}`,!0)}let o=L0e(s.stdout);return np(o===void 0?s.stdout.trim():JSON.stringify(o))}};var J7=require("child_process");var N0e=32*1024*1024;function Z7(r){return e=>new Promise(t=>{(0,J7.execFile)(process.execPath,[r,...e],{maxBuffer:N0e},(n,i,s)=>{let o=0;if(n){let c=n.code;o=typeof c=="number"?c:1}t({stdout:i,stderr:s,exitCode:o})})})}a(Z7,"createSelfCliRunner");async function k0e(r,e,t){let n=(0,e8.createInterface)({input:e,crlfDelay:1/0});for await(let i of n){let s=i.trim();if(s.length===0)continue;let o;try{o=JSON.parse(s)}catch{t(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:Q7,message:"Parse error: invalid JSON"}})+`
|
|
678
678
|
`);continue}let c;try{c=await r.handle(o)}catch(l){c={jsonrpc:"2.0",id:typeof o?.id=="string"||typeof o?.id=="number"?o.id:null,error:{code:X7,message:`Internal error: ${l instanceof Error?l.message:String(l)}`}}}c!==null&&t(JSON.stringify(c)+`
|
|
679
|
-
`)}}a(k0e,"runStdioServer");function t8(r){return new
|
|
679
|
+
`)}}a(k0e,"runStdioServer");function t8(r){return new de("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new Zw({runCli:Z7(t),version:r??"unknown"});await k0e(n,process.stdin,i=>process.stdout.write(i))})}a(t8,"mcpCommand");function eE(r){let e=new de;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"16.240.0"),e.addCommand(L6()),e.addCommand(G6()),e.addCommand(CB()),e.addCommand(DB()),e.addCommand(e6()),e.addCommand(FB()),e.addCommand($B()),e.addCommand(UB()),e.addCommand(a6()),e.addCommand(d6()),e.addCommand(T6()),e.addCommand(R6()),e.addCommand(C6()),e.addCommand(O6()),e.addCommand(P6()),e.addCommand(h7()),e.addCommand(y7()),e.addCommand(D7()),e.addCommand(L7()),e.addCommand(M7()),e.addCommand(j7()),e.addCommand(B7()),e.addCommand(v7()),e.addCommand(x7()),e.addCommand(V7()),e.addCommand(t8(r??"16.240.0")),e}a(eE,"createProgram");eE().parse();0&&(module.exports={createProgram});
|
|
680
680
|
/*! Bundled license information:
|
|
681
681
|
|
|
682
682
|
reflect-metadata/Reflect.js:
|