@kitelev/exocortex-cli 16.224.5 → 16.224.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +25 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- // @kitelev/exocortex-cli v16.224.5
2
+ // @kitelev/exocortex-cli v16.224.6
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 AB=Object.create;var fd=Object.defineProperty;var IB=Object.getOwnPropertyDescriptor;var xB=Object.getOwnPropertyNames;var RB=Object.getPrototypeOf,CB=Object.prototype.hasOwnProperty;var a=(n,e)=>fd(n,"name",{value:e,configurable:!0});var et=(n,e)=>()=>(n&&(e=n(n=0)),e);var v=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),pm=(n,e)=>{for(var t in e)fd(n,t,{get:e[t],enumerable:!0})},YC=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xB(e))!CB.call(n,i)&&i!==t&&fd(n,i,{get:()=>e[i],enumerable:!(r=IB(e,i))||r.enumerable});return n};var be=(n,e,t)=>(t=n!=null?AB(RB(n)):{},YC(e||!n||!n.__esModule?fd(t,"default",{value:n,enumerable:!0}):t,n)),hm=n=>YC(fd({},"__esModule",{value:!0}),n);var US=v(()=>{var QC;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:l(),r=i(n);typeof t.Reflect<"u"&&(r=i(t.Reflect,r)),e(r,t),typeof t.Reflect>"u"&&(t.Reflect=n);function i(c,u){return function(f,d){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}a(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}a(s,"functionThis");function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}a(o,"indirectEvalThis");function l(){return s()||o()}a(l,"sloppyModeThis")})(function(e,t){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",l=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!l&&!c,f={create:l?function(){return U(Object.create(null))}:c?function(){return U({__proto__:null})}:function(){return U({})},has:u?function(R,C){return r.call(R,C)}:function(R,C){return C in R},get:u?function(R,C){return r.call(R,C)?R[C]:void 0}:function(R,C){return R[C]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:He(),h=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:m(),_=typeof WeakMap=="function"?WeakMap:L(),y=i?Symbol.for("@reflect-metadata:registry"):void 0,b=ke(),S=We(b);function I(R,C,D,w){if(ce(D)){if(!Ce(R))throw new TypeError;if(!Oe(C))throw new TypeError;return ge(R,C)}else{if(!Ce(R))throw new TypeError;if(!ne(C))throw new TypeError;if(!ne(w)&&!ce(w)&&!ue(w))throw new TypeError;return ue(w)&&(w=void 0),D=Ee(D),ye(R,C,D,w)}}a(I,"decorate"),e("decorate",I);function O(R,C){function D(w,F){if(!ne(w))throw new TypeError;if(!ce(F)&&!Re(F))throw new TypeError;re(R,C,w,F)}return a(D,"decorator"),D}a(O,"metadata"),e("metadata",O);function T(R,C,D,w){if(!ne(D))throw new TypeError;return ce(w)||(w=Ee(w)),re(R,C,D,w)}a(T,"defineMetadata"),e("defineMetadata",T);function E(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),Q(R,C,D)}a(E,"hasMetadata"),e("hasMetadata",E);function P(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),se(R,C,D)}a(P,"hasOwnMetadata"),e("hasOwnMetadata",P);function V(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),J(R,C,D)}a(V,"getMetadata"),e("getMetadata",V);function M(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),ve(R,C,D)}a(M,"getOwnMetadata"),e("getOwnMetadata",M);function j(R,C){if(!ne(R))throw new TypeError;return ce(C)||(C=Ee(C)),ie(R,C)}a(j,"getMetadataKeys"),e("getMetadataKeys",j);function $(R,C){if(!ne(R))throw new TypeError;return ce(C)||(C=Ee(C)),he(R,C)}a($,"getOwnMetadataKeys"),e("getOwnMetadataKeys",$);function G(R,C,D){if(!ne(C))throw new TypeError;if(ce(D)||(D=Ee(D)),!ne(C))throw new TypeError;ce(D)||(D=Ee(D));var w=je(C,D,!1);return ce(w)?!1:w.OrdinaryDeleteMetadata(R,C,D)}a(G,"deleteMetadata"),e("deleteMetadata",G);function ge(R,C){for(var D=R.length-1;D>=0;--D){var w=R[D],F=w(C);if(!ce(F)&&!ue(F)){if(!Oe(F))throw new TypeError;C=F}}return C}a(ge,"DecorateConstructor");function ye(R,C,D,w){for(var F=R.length-1;F>=0;--F){var X=R[F],H=X(C,D,w);if(!ce(H)&&!ue(H)){if(!ne(H))throw new TypeError;w=H}}return w}a(ye,"DecorateProperty");function Q(R,C,D){var w=se(R,C,D);if(w)return!0;var F=Ne(C);return ue(F)?!1:Q(R,F,D)}a(Q,"OrdinaryHasMetadata");function se(R,C,D){var w=je(C,D,!1);return ce(w)?!1:B(w.OrdinaryHasOwnMetadata(R,C,D))}a(se,"OrdinaryHasOwnMetadata");function J(R,C,D){var w=se(R,C,D);if(w)return ve(R,C,D);var F=Ne(C);if(!ue(F))return J(R,F,D)}a(J,"OrdinaryGetMetadata");function ve(R,C,D){var w=je(C,D,!1);if(!ce(w))return w.OrdinaryGetOwnMetadata(R,C,D)}a(ve,"OrdinaryGetOwnMetadata");function re(R,C,D,w){var F=je(D,w,!0);F.OrdinaryDefineOwnMetadata(R,C,D,w)}a(re,"OrdinaryDefineOwnMetadata");function ie(R,C){var D=he(R,C),w=Ne(R);if(w===null)return D;var F=ie(w,C);if(F.length<=0)return D;if(D.length<=0)return F;for(var X=new h,H=[],q=0,k=D;q<k.length;q++){var N=k[q],z=X.has(N);z||(X.add(N),H.push(N))}for(var K=0,ae=F;K<ae.length;K++){var N=ae[K],z=X.has(N);z||(X.add(N),H.push(N))}return H}a(ie,"OrdinaryMetadataKeys");function he(R,C){var D=je(R,C,!1);return D?D.OrdinaryOwnMetadataKeys(R,C):[]}a(he,"OrdinaryOwnMetadataKeys");function Ue(R){if(R===null)return 1;switch(typeof R){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return R===null?1:6;default:return 6}}a(Ue,"Type");function ce(R){return R===void 0}a(ce,"IsUndefined");function ue(R){return R===null}a(ue,"IsNull");function fe(R){return typeof R=="symbol"}a(fe,"IsSymbol");function ne(R){return typeof R=="object"?R!==null:typeof R=="function"}a(ne,"IsObject");function me(R,C){switch(Ue(R)){case 0:return R;case 1:return R;case 2:return R;case 3:return R;case 4:return R;case 5:return R}var D=C===3?"string":C===5?"number":"default",w=ee(R,s);if(w!==void 0){var F=w.call(R,D);if(ne(F))throw new TypeError;return F}return Le(R,D==="default"?"number":D)}a(me,"ToPrimitive");function Le(R,C){if(C==="string"){var D=R.toString;if(xe(D)){var w=D.call(R);if(!ne(w))return w}var F=R.valueOf;if(xe(F)){var w=F.call(R);if(!ne(w))return w}}else{var F=R.valueOf;if(xe(F)){var w=F.call(R);if(!ne(w))return w}var X=R.toString;if(xe(X)){var w=X.call(R);if(!ne(w))return w}}throw new TypeError}a(Le,"OrdinaryToPrimitive");function B(R){return!!R}a(B,"ToBoolean");function oe(R){return""+R}a(oe,"ToString");function Ee(R){var C=me(R,3);return fe(C)?C:oe(C)}a(Ee,"ToPropertyKey");function Ce(R){return Array.isArray?Array.isArray(R):R instanceof Object?R instanceof Array:Object.prototype.toString.call(R)==="[object Array]"}a(Ce,"IsArray");function xe(R){return typeof R=="function"}a(xe,"IsCallable");function Oe(R){return typeof R=="function"}a(Oe,"IsConstructor");function Re(R){switch(Ue(R)){case 3:return!0;case 4:return!0;default:return!1}}a(Re,"IsPropertyKey");function Ae(R,C){return R===C||R!==R&&C!==C}a(Ae,"SameValueZero");function ee(R,C){var D=R[C];if(D!=null){if(!xe(D))throw new TypeError;return D}}a(ee,"GetMethod");function _e(R){var C=ee(R,o);if(!xe(C))throw new TypeError;var D=C.call(R);if(!ne(D))throw new TypeError;return D}a(_e,"GetIterator");function Te(R){return R.value}a(Te,"IteratorValue");function Pe(R){var C=R.next();return C.done?!1:C}a(Pe,"IteratorStep");function Me(R){var C=R.return;C&&C.call(R)}a(Me,"IteratorClose");function Ne(R){var C=Object.getPrototypeOf(R);if(typeof R!="function"||R===d||C!==d)return C;var D=R.prototype,w=D&&Object.getPrototypeOf(D);if(w==null||w===Object.prototype)return C;var F=w.constructor;return typeof F!="function"||F===R?C:F}a(Ne,"OrdinaryGetPrototypeOf");function Ge(){var R;!ce(y)&&typeof t.Reflect<"u"&&!(y in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(R=qe(t.Reflect));var C,D,w,F=new _,X={registerProvider:H,getProvider:k,setProvider:z};return X;function H(K){if(!Object.isExtensible(X))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case R===K:break;case ce(C):C=K;break;case C===K:break;case ce(D):D=K;break;case D===K:break;default:w===void 0&&(w=new h),w.add(K);break}}function q(K,ae){if(!ce(C)){if(C.isProviderFor(K,ae))return C;if(!ce(D)){if(D.isProviderFor(K,ae))return C;if(!ce(w))for(var Se=_e(w);;){var De=Pe(Se);if(!De)return;var rt=Te(De);if(rt.isProviderFor(K,ae))return Me(Se),rt}}}if(!ce(R)&&R.isProviderFor(K,ae))return R}function k(K,ae){var Se=F.get(K),De;return ce(Se)||(De=Se.get(ae)),ce(De)&&(De=q(K,ae),ce(De)||(ce(Se)&&(Se=new p,F.set(K,Se)),Se.set(ae,De))),De}function N(K){if(ce(K))throw new TypeError;return C===K||D===K||!ce(w)&&w.has(K)}function z(K,ae,Se){if(!N(Se))throw new Error("Metadata provider not registered.");var De=k(K,ae);if(De!==Se){if(!ce(De))return!1;var rt=F.get(K);ce(rt)&&(rt=new p,F.set(K,rt)),rt.set(ae,Se)}return!0}}a(Ge,"CreateMetadataRegistry");function ke(){var R;return!ce(y)&&ne(t.Reflect)&&Object.isExtensible(t.Reflect)&&(R=t.Reflect[y]),ce(R)&&(R=Ge()),!ce(y)&&ne(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:R}),R}a(ke,"GetOrCreateMetadataRegistry");function We(R){var C=new _,D={isProviderFor:a(function(N,z){var K=C.get(N);return ce(K)?!1:K.has(z)},"isProviderFor"),OrdinaryDefineOwnMetadata:H,OrdinaryHasOwnMetadata:F,OrdinaryGetOwnMetadata:X,OrdinaryOwnMetadataKeys:q,OrdinaryDeleteMetadata:k};return b.registerProvider(D),D;function w(N,z,K){var ae=C.get(N),Se=!1;if(ce(ae)){if(!K)return;ae=new p,C.set(N,ae),Se=!0}var De=ae.get(z);if(ce(De)){if(!K)return;if(De=new p,ae.set(z,De),!R.setProvider(N,z,D))throw ae.delete(z),Se&&C.delete(N),new Error("Wrong provider for target.")}return De}a(w,"GetOrCreateMetadataMap");function F(N,z,K){var ae=w(z,K,!1);return ce(ae)?!1:B(ae.has(N))}a(F,"OrdinaryHasOwnMetadata");function X(N,z,K){var ae=w(z,K,!1);if(!ce(ae))return ae.get(N)}a(X,"OrdinaryGetOwnMetadata");function H(N,z,K,ae){var Se=w(K,ae,!0);Se.set(N,z)}a(H,"OrdinaryDefineOwnMetadata");function q(N,z){var K=[],ae=w(N,z,!1);if(ce(ae))return K;for(var Se=ae.keys(),De=_e(Se),rt=0;;){var Jr=Pe(De);if(!Jr)return K.length=rt,K;var Cr=Te(Jr);try{K[rt]=Cr}catch(sr){try{Me(De)}finally{throw sr}}rt++}}a(q,"OrdinaryOwnMetadataKeys");function k(N,z,K){var ae=w(z,K,!1);if(ce(ae)||!ae.delete(N))return!1;if(ae.size===0){var Se=C.get(z);ce(Se)||(Se.delete(K),Se.size===0&&C.delete(Se))}return!0}a(k,"OrdinaryDeleteMetadata")}a(We,"CreateMetadataProvider");function qe(R){var C=R.defineMetadata,D=R.hasOwnMetadata,w=R.getOwnMetadata,F=R.getOwnMetadataKeys,X=R.deleteMetadata,H=new _,q={isProviderFor:a(function(k,N){var z=H.get(k);return!ce(z)&&z.has(N)?!0:F(k,N).length?(ce(z)&&(z=new h,H.set(k,z)),z.add(N),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:C,OrdinaryHasOwnMetadata:D,OrdinaryGetOwnMetadata:w,OrdinaryOwnMetadataKeys:F,OrdinaryDeleteMetadata:X};return q}a(qe,"CreateFallbackProvider");function je(R,C,D){var w=b.getProvider(R,C);if(!ce(w))return w;if(D){if(b.setProvider(R,C,S))return S;throw new Error("Illegal state.")}}a(je,"GetMetadataProvider");function He(){var R={},C=[],D=(function(){function q(k,N,z){this._index=0,this._keys=k,this._values=N,this._selector=z}return a(q,"MapIterator"),q.prototype["@@iterator"]=function(){return this},q.prototype[o]=function(){return this},q.prototype.next=function(){var k=this._index;if(k>=0&&k<this._keys.length){var N=this._selector(this._keys[k],this._values[k]);return k+1>=this._keys.length?(this._index=-1,this._keys=C,this._values=C):this._index++,{value:N,done:!1}}return{value:void 0,done:!0}},q.prototype.throw=function(k){throw this._index>=0&&(this._index=-1,this._keys=C,this._values=C),k},q.prototype.return=function(k){return this._index>=0&&(this._index=-1,this._keys=C,this._values=C),{value:k,done:!0}},q})(),w=(function(){function q(){this._keys=[],this._values=[],this._cacheKey=R,this._cacheIndex=-2}return a(q,"Map"),Object.defineProperty(q.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),q.prototype.has=function(k){return this._find(k,!1)>=0},q.prototype.get=function(k){var N=this._find(k,!1);return N>=0?this._values[N]:void 0},q.prototype.set=function(k,N){var z=this._find(k,!0);return this._values[z]=N,this},q.prototype.delete=function(k){var N=this._find(k,!1);if(N>=0){for(var z=this._keys.length,K=N+1;K<z;K++)this._keys[K-1]=this._keys[K],this._values[K-1]=this._values[K];return this._keys.length--,this._values.length--,Ae(k,this._cacheKey)&&(this._cacheKey=R,this._cacheIndex=-2),!0}return!1},q.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=R,this._cacheIndex=-2},q.prototype.keys=function(){return new D(this._keys,this._values,F)},q.prototype.values=function(){return new D(this._keys,this._values,X)},q.prototype.entries=function(){return new D(this._keys,this._values,H)},q.prototype["@@iterator"]=function(){return this.entries()},q.prototype[o]=function(){return this.entries()},q.prototype._find=function(k,N){if(!Ae(this._cacheKey,k)){this._cacheIndex=-1;for(var z=0;z<this._keys.length;z++)if(Ae(this._keys[z],k)){this._cacheIndex=z;break}}return this._cacheIndex<0&&N&&(this._cacheIndex=this._keys.length,this._keys.push(k),this._values.push(void 0)),this._cacheIndex},q})();return w;function F(q,k){return q}function X(q,k){return k}function H(q,k){return[q,k]}}a(He,"CreateMapPolyfill");function m(){var R=(function(){function C(){this._map=new p}return a(C,"Set"),Object.defineProperty(C.prototype,"size",{get:a(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),C.prototype.has=function(D){return this._map.has(D)},C.prototype.add=function(D){return this._map.set(D,D),this},C.prototype.delete=function(D){return this._map.delete(D)},C.prototype.clear=function(){this._map.clear()},C.prototype.keys=function(){return this._map.keys()},C.prototype.values=function(){return this._map.keys()},C.prototype.entries=function(){return this._map.entries()},C.prototype["@@iterator"]=function(){return this.keys()},C.prototype[o]=function(){return this.keys()},C})();return R}a(m,"CreateSetPolyfill");function L(){var R=16,C=f.create(),D=w();return(function(){function k(){this._key=w()}return a(k,"WeakMap"),k.prototype.has=function(N){var z=F(N,!1);return z!==void 0?f.has(z,this._key):!1},k.prototype.get=function(N){var z=F(N,!1);return z!==void 0?f.get(z,this._key):void 0},k.prototype.set=function(N,z){var K=F(N,!0);return K[this._key]=z,this},k.prototype.delete=function(N){var z=F(N,!1);return z!==void 0?delete z[this._key]:!1},k.prototype.clear=function(){this._key=w()},k})();function w(){var k;do k="@@WeakMap@@"+q();while(f.has(C,k));return C[k]=!0,k}function F(k,N){if(!r.call(k,D)){if(!N)return;Object.defineProperty(k,D,{value:f.create()})}return k[D]}function X(k,N){for(var z=0;z<N;++z)k[z]=Math.random()*255|0;return k}function H(k){if(typeof Uint8Array=="function"){var N=new Uint8Array(k);return typeof crypto<"u"?crypto.getRandomValues(N):typeof msCrypto<"u"?msCrypto.getRandomValues(N):X(N,k),N}return X(new Array(k),k)}function q(){var k=H(R);k[6]=k[6]&79|64,k[8]=k[8]&191|128;for(var N="",z=0;z<R;++z){var K=k[z];(z===4||z===6||z===8)&&(N+="-"),K<16&&(N+="0"),N+=K.toString(16).toLowerCase()}return N}}a(L,"CreateWeakMapPolyfill");function U(R){return R.__=void 0,delete R.__,R}a(U,"MakeDictionary")})})(QC||(QC={}))});var dd=v(VS=>{var mm=class extends Error{static{a(this,"CommanderError")}constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},BS=class extends mm{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};VS.CommanderError=mm;VS.InvalidArgumentError=BS});var gm=v(GS=>{var{InvalidArgumentError:OB}=dd(),qS=class{static{a(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new OB(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function PB(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}a(PB,"humanReadableArgName");GS.Argument=qS;GS.humanReadableArgName=PB});var zS=v(HS=>{var{humanReadableArgName:DB}=gm(),WS=class{static{a(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>DB(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatItemList(e,t,r){return t.length===0?[]:[r.styleTitle(e),...t,""]}groupItems(e,t,r){let i=new Map;return e.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth??80;function s(d,p){return t.formatItem(d,r,p,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],l=t.commandDescription(e);l.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(l),i),""]));let c=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",c,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let h=d.map(_=>s(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));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(_=>s(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,h,t))}),o.join(`
6
+ "use strict";var AB=Object.create;var fd=Object.defineProperty;var IB=Object.getOwnPropertyDescriptor;var xB=Object.getOwnPropertyNames;var RB=Object.getPrototypeOf,CB=Object.prototype.hasOwnProperty;var a=(n,e)=>fd(n,"name",{value:e,configurable:!0});var et=(n,e)=>()=>(n&&(e=n(n=0)),e);var v=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),pm=(n,e)=>{for(var t in e)fd(n,t,{get:e[t],enumerable:!0})},YC=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xB(e))!CB.call(n,i)&&i!==t&&fd(n,i,{get:()=>e[i],enumerable:!(r=IB(e,i))||r.enumerable});return n};var be=(n,e,t)=>(t=n!=null?AB(RB(n)):{},YC(e||!n||!n.__esModule?fd(t,"default",{value:n,enumerable:!0}):t,n)),hm=n=>YC(fd({},"__esModule",{value:!0}),n);var US=v(()=>{var QC;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:l(),r=i(n);typeof t.Reflect<"u"&&(r=i(t.Reflect,r)),e(r,t),typeof t.Reflect>"u"&&(t.Reflect=n);function i(c,u){return function(f,d){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}a(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}a(s,"functionThis");function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}a(o,"indirectEvalThis");function l(){return s()||o()}a(l,"sloppyModeThis")})(function(e,t){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",l=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!l&&!c,f={create:l?function(){return U(Object.create(null))}:c?function(){return U({__proto__:null})}:function(){return U({})},has:u?function(R,C){return r.call(R,C)}:function(R,C){return C in R},get:u?function(R,C){return r.call(R,C)?R[C]:void 0}:function(R,C){return R[C]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:He(),h=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:m(),_=typeof WeakMap=="function"?WeakMap:L(),y=i?Symbol.for("@reflect-metadata:registry"):void 0,b=ke(),S=We(b);function I(R,C,D,w){if(ce(D)){if(!Ce(R))throw new TypeError;if(!Oe(C))throw new TypeError;return ge(R,C)}else{if(!Ce(R))throw new TypeError;if(!ne(C))throw new TypeError;if(!ne(w)&&!ce(w)&&!ue(w))throw new TypeError;return ue(w)&&(w=void 0),D=Ee(D),ye(R,C,D,w)}}a(I,"decorate"),e("decorate",I);function O(R,C){function D(w,F){if(!ne(w))throw new TypeError;if(!ce(F)&&!Re(F))throw new TypeError;re(R,C,w,F)}return a(D,"decorator"),D}a(O,"metadata"),e("metadata",O);function T(R,C,D,w){if(!ne(D))throw new TypeError;return ce(w)||(w=Ee(w)),re(R,C,D,w)}a(T,"defineMetadata"),e("defineMetadata",T);function E(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),Q(R,C,D)}a(E,"hasMetadata"),e("hasMetadata",E);function P(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),se(R,C,D)}a(P,"hasOwnMetadata"),e("hasOwnMetadata",P);function V(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),J(R,C,D)}a(V,"getMetadata"),e("getMetadata",V);function M(R,C,D){if(!ne(C))throw new TypeError;return ce(D)||(D=Ee(D)),ve(R,C,D)}a(M,"getOwnMetadata"),e("getOwnMetadata",M);function j(R,C){if(!ne(R))throw new TypeError;return ce(C)||(C=Ee(C)),ie(R,C)}a(j,"getMetadataKeys"),e("getMetadataKeys",j);function $(R,C){if(!ne(R))throw new TypeError;return ce(C)||(C=Ee(C)),he(R,C)}a($,"getOwnMetadataKeys"),e("getOwnMetadataKeys",$);function G(R,C,D){if(!ne(C))throw new TypeError;if(ce(D)||(D=Ee(D)),!ne(C))throw new TypeError;ce(D)||(D=Ee(D));var w=je(C,D,!1);return ce(w)?!1:w.OrdinaryDeleteMetadata(R,C,D)}a(G,"deleteMetadata"),e("deleteMetadata",G);function ge(R,C){for(var D=R.length-1;D>=0;--D){var w=R[D],F=w(C);if(!ce(F)&&!ue(F)){if(!Oe(F))throw new TypeError;C=F}}return C}a(ge,"DecorateConstructor");function ye(R,C,D,w){for(var F=R.length-1;F>=0;--F){var X=R[F],H=X(C,D,w);if(!ce(H)&&!ue(H)){if(!ne(H))throw new TypeError;w=H}}return w}a(ye,"DecorateProperty");function Q(R,C,D){var w=se(R,C,D);if(w)return!0;var F=Ne(C);return ue(F)?!1:Q(R,F,D)}a(Q,"OrdinaryHasMetadata");function se(R,C,D){var w=je(C,D,!1);return ce(w)?!1:B(w.OrdinaryHasOwnMetadata(R,C,D))}a(se,"OrdinaryHasOwnMetadata");function J(R,C,D){var w=se(R,C,D);if(w)return ve(R,C,D);var F=Ne(C);if(!ue(F))return J(R,F,D)}a(J,"OrdinaryGetMetadata");function ve(R,C,D){var w=je(C,D,!1);if(!ce(w))return w.OrdinaryGetOwnMetadata(R,C,D)}a(ve,"OrdinaryGetOwnMetadata");function re(R,C,D,w){var F=je(D,w,!0);F.OrdinaryDefineOwnMetadata(R,C,D,w)}a(re,"OrdinaryDefineOwnMetadata");function ie(R,C){var D=he(R,C),w=Ne(R);if(w===null)return D;var F=ie(w,C);if(F.length<=0)return D;if(D.length<=0)return F;for(var X=new h,H=[],q=0,k=D;q<k.length;q++){var N=k[q],z=X.has(N);z||(X.add(N),H.push(N))}for(var K=0,ae=F;K<ae.length;K++){var N=ae[K],z=X.has(N);z||(X.add(N),H.push(N))}return H}a(ie,"OrdinaryMetadataKeys");function he(R,C){var D=je(R,C,!1);return D?D.OrdinaryOwnMetadataKeys(R,C):[]}a(he,"OrdinaryOwnMetadataKeys");function Ue(R){if(R===null)return 1;switch(typeof R){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return R===null?1:6;default:return 6}}a(Ue,"Type");function ce(R){return R===void 0}a(ce,"IsUndefined");function ue(R){return R===null}a(ue,"IsNull");function fe(R){return typeof R=="symbol"}a(fe,"IsSymbol");function ne(R){return typeof R=="object"?R!==null:typeof R=="function"}a(ne,"IsObject");function me(R,C){switch(Ue(R)){case 0:return R;case 1:return R;case 2:return R;case 3:return R;case 4:return R;case 5:return R}var D=C===3?"string":C===5?"number":"default",w=ee(R,s);if(w!==void 0){var F=w.call(R,D);if(ne(F))throw new TypeError;return F}return Le(R,D==="default"?"number":D)}a(me,"ToPrimitive");function Le(R,C){if(C==="string"){var D=R.toString;if(xe(D)){var w=D.call(R);if(!ne(w))return w}var F=R.valueOf;if(xe(F)){var w=F.call(R);if(!ne(w))return w}}else{var F=R.valueOf;if(xe(F)){var w=F.call(R);if(!ne(w))return w}var X=R.toString;if(xe(X)){var w=X.call(R);if(!ne(w))return w}}throw new TypeError}a(Le,"OrdinaryToPrimitive");function B(R){return!!R}a(B,"ToBoolean");function oe(R){return""+R}a(oe,"ToString");function Ee(R){var C=me(R,3);return fe(C)?C:oe(C)}a(Ee,"ToPropertyKey");function Ce(R){return Array.isArray?Array.isArray(R):R instanceof Object?R instanceof Array:Object.prototype.toString.call(R)==="[object Array]"}a(Ce,"IsArray");function xe(R){return typeof R=="function"}a(xe,"IsCallable");function Oe(R){return typeof R=="function"}a(Oe,"IsConstructor");function Re(R){switch(Ue(R)){case 3:return!0;case 4:return!0;default:return!1}}a(Re,"IsPropertyKey");function Ae(R,C){return R===C||R!==R&&C!==C}a(Ae,"SameValueZero");function ee(R,C){var D=R[C];if(D!=null){if(!xe(D))throw new TypeError;return D}}a(ee,"GetMethod");function _e(R){var C=ee(R,o);if(!xe(C))throw new TypeError;var D=C.call(R);if(!ne(D))throw new TypeError;return D}a(_e,"GetIterator");function Te(R){return R.value}a(Te,"IteratorValue");function Pe(R){var C=R.next();return C.done?!1:C}a(Pe,"IteratorStep");function Me(R){var C=R.return;C&&C.call(R)}a(Me,"IteratorClose");function Ne(R){var C=Object.getPrototypeOf(R);if(typeof R!="function"||R===d||C!==d)return C;var D=R.prototype,w=D&&Object.getPrototypeOf(D);if(w==null||w===Object.prototype)return C;var F=w.constructor;return typeof F!="function"||F===R?C:F}a(Ne,"OrdinaryGetPrototypeOf");function Ge(){var R;!ce(y)&&typeof t.Reflect<"u"&&!(y in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(R=qe(t.Reflect));var C,D,w,F=new _,X={registerProvider:H,getProvider:k,setProvider:z};return X;function H(K){if(!Object.isExtensible(X))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case R===K:break;case ce(C):C=K;break;case C===K:break;case ce(D):D=K;break;case D===K:break;default:w===void 0&&(w=new h),w.add(K);break}}function q(K,ae){if(!ce(C)){if(C.isProviderFor(K,ae))return C;if(!ce(D)){if(D.isProviderFor(K,ae))return C;if(!ce(w))for(var Se=_e(w);;){var De=Pe(Se);if(!De)return;var rt=Te(De);if(rt.isProviderFor(K,ae))return Me(Se),rt}}}if(!ce(R)&&R.isProviderFor(K,ae))return R}function k(K,ae){var Se=F.get(K),De;return ce(Se)||(De=Se.get(ae)),ce(De)&&(De=q(K,ae),ce(De)||(ce(Se)&&(Se=new p,F.set(K,Se)),Se.set(ae,De))),De}function N(K){if(ce(K))throw new TypeError;return C===K||D===K||!ce(w)&&w.has(K)}function z(K,ae,Se){if(!N(Se))throw new Error("Metadata provider not registered.");var De=k(K,ae);if(De!==Se){if(!ce(De))return!1;var rt=F.get(K);ce(rt)&&(rt=new p,F.set(K,rt)),rt.set(ae,Se)}return!0}}a(Ge,"CreateMetadataRegistry");function ke(){var R;return!ce(y)&&ne(t.Reflect)&&Object.isExtensible(t.Reflect)&&(R=t.Reflect[y]),ce(R)&&(R=Ge()),!ce(y)&&ne(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:R}),R}a(ke,"GetOrCreateMetadataRegistry");function We(R){var C=new _,D={isProviderFor:a(function(N,z){var K=C.get(N);return ce(K)?!1:K.has(z)},"isProviderFor"),OrdinaryDefineOwnMetadata:H,OrdinaryHasOwnMetadata:F,OrdinaryGetOwnMetadata:X,OrdinaryOwnMetadataKeys:q,OrdinaryDeleteMetadata:k};return b.registerProvider(D),D;function w(N,z,K){var ae=C.get(N),Se=!1;if(ce(ae)){if(!K)return;ae=new p,C.set(N,ae),Se=!0}var De=ae.get(z);if(ce(De)){if(!K)return;if(De=new p,ae.set(z,De),!R.setProvider(N,z,D))throw ae.delete(z),Se&&C.delete(N),new Error("Wrong provider for target.")}return De}a(w,"GetOrCreateMetadataMap");function F(N,z,K){var ae=w(z,K,!1);return ce(ae)?!1:B(ae.has(N))}a(F,"OrdinaryHasOwnMetadata");function X(N,z,K){var ae=w(z,K,!1);if(!ce(ae))return ae.get(N)}a(X,"OrdinaryGetOwnMetadata");function H(N,z,K,ae){var Se=w(K,ae,!0);Se.set(N,z)}a(H,"OrdinaryDefineOwnMetadata");function q(N,z){var K=[],ae=w(N,z,!1);if(ce(ae))return K;for(var Se=ae.keys(),De=_e(Se),rt=0;;){var Jr=Pe(De);if(!Jr)return K.length=rt,K;var Cr=Te(Jr);try{K[rt]=Cr}catch(or){try{Me(De)}finally{throw or}}rt++}}a(q,"OrdinaryOwnMetadataKeys");function k(N,z,K){var ae=w(z,K,!1);if(ce(ae)||!ae.delete(N))return!1;if(ae.size===0){var Se=C.get(z);ce(Se)||(Se.delete(K),Se.size===0&&C.delete(Se))}return!0}a(k,"OrdinaryDeleteMetadata")}a(We,"CreateMetadataProvider");function qe(R){var C=R.defineMetadata,D=R.hasOwnMetadata,w=R.getOwnMetadata,F=R.getOwnMetadataKeys,X=R.deleteMetadata,H=new _,q={isProviderFor:a(function(k,N){var z=H.get(k);return!ce(z)&&z.has(N)?!0:F(k,N).length?(ce(z)&&(z=new h,H.set(k,z)),z.add(N),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:C,OrdinaryHasOwnMetadata:D,OrdinaryGetOwnMetadata:w,OrdinaryOwnMetadataKeys:F,OrdinaryDeleteMetadata:X};return q}a(qe,"CreateFallbackProvider");function je(R,C,D){var w=b.getProvider(R,C);if(!ce(w))return w;if(D){if(b.setProvider(R,C,S))return S;throw new Error("Illegal state.")}}a(je,"GetMetadataProvider");function He(){var R={},C=[],D=(function(){function q(k,N,z){this._index=0,this._keys=k,this._values=N,this._selector=z}return a(q,"MapIterator"),q.prototype["@@iterator"]=function(){return this},q.prototype[o]=function(){return this},q.prototype.next=function(){var k=this._index;if(k>=0&&k<this._keys.length){var N=this._selector(this._keys[k],this._values[k]);return k+1>=this._keys.length?(this._index=-1,this._keys=C,this._values=C):this._index++,{value:N,done:!1}}return{value:void 0,done:!0}},q.prototype.throw=function(k){throw this._index>=0&&(this._index=-1,this._keys=C,this._values=C),k},q.prototype.return=function(k){return this._index>=0&&(this._index=-1,this._keys=C,this._values=C),{value:k,done:!0}},q})(),w=(function(){function q(){this._keys=[],this._values=[],this._cacheKey=R,this._cacheIndex=-2}return a(q,"Map"),Object.defineProperty(q.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),q.prototype.has=function(k){return this._find(k,!1)>=0},q.prototype.get=function(k){var N=this._find(k,!1);return N>=0?this._values[N]:void 0},q.prototype.set=function(k,N){var z=this._find(k,!0);return this._values[z]=N,this},q.prototype.delete=function(k){var N=this._find(k,!1);if(N>=0){for(var z=this._keys.length,K=N+1;K<z;K++)this._keys[K-1]=this._keys[K],this._values[K-1]=this._values[K];return this._keys.length--,this._values.length--,Ae(k,this._cacheKey)&&(this._cacheKey=R,this._cacheIndex=-2),!0}return!1},q.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=R,this._cacheIndex=-2},q.prototype.keys=function(){return new D(this._keys,this._values,F)},q.prototype.values=function(){return new D(this._keys,this._values,X)},q.prototype.entries=function(){return new D(this._keys,this._values,H)},q.prototype["@@iterator"]=function(){return this.entries()},q.prototype[o]=function(){return this.entries()},q.prototype._find=function(k,N){if(!Ae(this._cacheKey,k)){this._cacheIndex=-1;for(var z=0;z<this._keys.length;z++)if(Ae(this._keys[z],k)){this._cacheIndex=z;break}}return this._cacheIndex<0&&N&&(this._cacheIndex=this._keys.length,this._keys.push(k),this._values.push(void 0)),this._cacheIndex},q})();return w;function F(q,k){return q}function X(q,k){return k}function H(q,k){return[q,k]}}a(He,"CreateMapPolyfill");function m(){var R=(function(){function C(){this._map=new p}return a(C,"Set"),Object.defineProperty(C.prototype,"size",{get:a(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),C.prototype.has=function(D){return this._map.has(D)},C.prototype.add=function(D){return this._map.set(D,D),this},C.prototype.delete=function(D){return this._map.delete(D)},C.prototype.clear=function(){this._map.clear()},C.prototype.keys=function(){return this._map.keys()},C.prototype.values=function(){return this._map.keys()},C.prototype.entries=function(){return this._map.entries()},C.prototype["@@iterator"]=function(){return this.keys()},C.prototype[o]=function(){return this.keys()},C})();return R}a(m,"CreateSetPolyfill");function L(){var R=16,C=f.create(),D=w();return(function(){function k(){this._key=w()}return a(k,"WeakMap"),k.prototype.has=function(N){var z=F(N,!1);return z!==void 0?f.has(z,this._key):!1},k.prototype.get=function(N){var z=F(N,!1);return z!==void 0?f.get(z,this._key):void 0},k.prototype.set=function(N,z){var K=F(N,!0);return K[this._key]=z,this},k.prototype.delete=function(N){var z=F(N,!1);return z!==void 0?delete z[this._key]:!1},k.prototype.clear=function(){this._key=w()},k})();function w(){var k;do k="@@WeakMap@@"+q();while(f.has(C,k));return C[k]=!0,k}function F(k,N){if(!r.call(k,D)){if(!N)return;Object.defineProperty(k,D,{value:f.create()})}return k[D]}function X(k,N){for(var z=0;z<N;++z)k[z]=Math.random()*255|0;return k}function H(k){if(typeof Uint8Array=="function"){var N=new Uint8Array(k);return typeof crypto<"u"?crypto.getRandomValues(N):typeof msCrypto<"u"?msCrypto.getRandomValues(N):X(N,k),N}return X(new Array(k),k)}function q(){var k=H(R);k[6]=k[6]&79|64,k[8]=k[8]&191|128;for(var N="",z=0;z<R;++z){var K=k[z];(z===4||z===6||z===8)&&(N+="-"),K<16&&(N+="0"),N+=K.toString(16).toLowerCase()}return N}}a(L,"CreateWeakMapPolyfill");function U(R){return R.__=void 0,delete R.__,R}a(U,"MakeDictionary")})})(QC||(QC={}))});var dd=v(VS=>{var mm=class extends Error{static{a(this,"CommanderError")}constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},BS=class extends mm{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};VS.CommanderError=mm;VS.InvalidArgumentError=BS});var gm=v(GS=>{var{InvalidArgumentError:OB}=dd(),qS=class{static{a(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new OB(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function PB(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}a(PB,"humanReadableArgName");GS.Argument=qS;GS.humanReadableArgName=PB});var zS=v(HS=>{var{humanReadableArgName:DB}=gm(),WS=class{static{a(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>DB(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatItemList(e,t,r){return t.length===0?[]:[r.styleTitle(e),...t,""]}groupItems(e,t,r){let i=new Map;return e.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=r(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth??80;function s(d,p){return t.formatItem(d,r,p,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],l=t.commandDescription(e);l.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(l),i),""]));let c=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",c,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let h=d.map(_=>s(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));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(_=>s(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,h,t))}),o.join(`
7
7
  `)}displayWidth(e){return XC(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,i){let o=" ".repeat(2);if(!r)return o+e;let l=e.padEnd(t+e.length-i.displayWidth(e)),c=2,f=(this.helpWidth??80)-t-c-2,d;return f<this.minWidthToWrap||i.preformatted(r)?d=r:d=i.boxWrap(r,f).replace(/\n/g,`
8
8
  `+" ".repeat(t+c)),o+l+" ".repeat(c)+d.replace(/\n/g,`
9
9
  ${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return r.forEach(o=>{let l=o.match(i);if(l===null){s.push("");return}let c=[l.shift()],u=this.displayWidth(c[0]);l.forEach(f=>{let d=this.displayWidth(f);if(u+d<=t){c.push(f),u+=d;return}s.push(c.join(""));let p=f.trimStart();c=[p],u=this.displayWidth(p)}),s.push(c.join(""))}),s.join(`
@@ -31,10 +31,10 @@ Expecting one of '${r.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let
31
31
  `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function nO(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],i=s[4]),t&&i!=="0"?`${t}=${r}:${parseInt(i)+1}`:e})}a(nO,"incrementNodeInspectorPort");function tw(){if(St.env.NO_COLOR||St.env.FORCE_COLOR==="0"||St.env.FORCE_COLOR==="false")return!1;if(St.env.FORCE_COLOR||St.env.CLICOLOR_FORCE!==void 0)return!0}a(tw,"useColor");rw.Command=ew;rw.useColor=tw});var lO=v(Ai=>{var{Argument:sO}=gm(),{Command:nw}=iO(),{CommanderError:qB,InvalidArgumentError:oO}=dd(),{Help:GB}=zS(),{Option:aO}=XS();Ai.program=new nw;Ai.createCommand=n=>new nw(n);Ai.createOption=(n,e)=>new aO(n,e);Ai.createArgument=(n,e)=>new sO(n,e);Ai.Command=nw;Ai.Option=aO;Ai.Argument=sO;Ai.Help=GB;Ai.CommanderError=qB;Ai.InvalidArgumentError=oO;Ai.InvalidOptionArgumentError=oO});var cO,hhe,mhe,ghe,yhe,_he,bhe,She,Ie,whe,Ehe,vhe,ft=et(()=>{cO=be(lO(),1),{program:hhe,createCommand:mhe,createArgument:ghe,createOption:yhe,CommanderError:_he,InvalidArgumentError:bhe,InvalidOptionArgumentError:She,Command:Ie,Argument:whe,Option:Ehe,Help:vhe}=cO.default});var Al=v(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});_m.AssetClass=void 0;var uO;(function(n){n.AREA="ems__Area",n.TASK="ems__Task",n.PROJECT="ems__Project",n.ACTION="ems__Action",n.MEETING="ems__Meeting",n.INITIATIVE="ems__Initiative",n.TASK_PROTOTYPE="ems__TaskPrototype",n.MEETING_PROTOTYPE="ems__MeetingPrototype",n.EVENT_PROTOTYPE="exo__EventPrototype",n.PROJECT_PROTOTYPE="ems__ProjectPrototype",n.EVENT="exo__Event",n.DAILY_NOTE="pn__DailyNote",n.CONCEPT="ims__Concept",n.SESSION_START_EVENT="ems__SessionStartEvent",n.SESSION_END_EVENT="ems__SessionEndEvent",n.PROTOTYPE="exo__Prototype",n.CLASS="exo__Class",n.FLEETING_NOTE="ztlk__FleetingNote",n.WORKFLOW="ems__Workflow",n.WORKFLOW_STATE="ems__WorkflowState",n.WORKFLOW_TRANSITION="ems__WorkflowTransition",n.COMMAND="exocmd__Command",n.PRECONDITION="exocmd__Precondition",n.GROUNDING="exocmd__Grounding",n.COMMAND_BINDING="exocmd__CommandBinding"})(uO||(_m.AssetClass=uO={}))});var Il=v(bm=>{"use strict";Object.defineProperty(bm,"__esModule",{value:!0});bm.EffortStatus=void 0;var fO;(function(n){n.DRAFT="ems__EffortStatusDraft",n.BACKLOG="ems__EffortStatusBacklog",n.DOING="ems__EffortStatusDoing",n.WAITING="ems__EffortStatusWaiting",n.DONE="ems__EffortStatusDone",n.TRASHED="ems__EffortStatusTrashed"})(fO||(bm.EffortStatus=fO={}))});var iw=v(Sm=>{"use strict";Object.defineProperty(Sm,"__esModule",{value:!0});Sm.EFFORT_STATUS_OPTIONS=void 0;Sm.EFFORT_STATUS_OPTIONS=[{value:"[[ems__EffortStatusDraft]]",label:"Draft"},{value:"[[ems__EffortStatusBacklog]]",label:"Backlog"},{value:"[[ems__EffortStatusDoing]]",label:"Doing"},{value:"[[ems__EffortStatusWaiting]]",label:"Waiting"},{value:"[[ems__EffortStatusDone]]",label:"Done"},{value:"[[ems__EffortStatusTrashed]]",label:"Trashed"}]});var Sa=v(wm=>{"use strict";Object.defineProperty(wm,"__esModule",{value:!0});wm.GroundingType=void 0;var dO;(function(n){n.SPARQL_UPDATE="sparql_update",n.PROPERTY_DELETE="property_delete",n.PROPERTY_SET="property_set",n.COMPOSITE="composite",n.SERVICE_CALL="service_call",n.CREATE_INSTANCE="create_instance",n.PROPERTY_APPEND="property_append",n.PROPERTY_INCREMENT="property_increment",n.PROPERTY_SHIFT="property_shift",n.WORKFLOW_TRANSITION="workflow_transition",n.BODY_TEMPLATE="body_template"})(dO||(wm.GroundingType=dO={}))});var pd=v(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.GROUNDING_TYPE_IRI_TO_ENUM=Kn.GROUNDING_TYPE_UID_TO_ENUM=Kn.GROUNDING_TYPE_UIDS=void 0;Kn.resolveGroundingTypeFromIRI=HB;Kn.resolveGroundingTypeFromWikilinkLiteral=zB;var er=Sa();Kn.GROUNDING_TYPE_UIDS={[er.GroundingType.PROPERTY_SET]:"cf3bb923-f1f1-40be-b728-782844402426",[er.GroundingType.PROPERTY_DELETE]:"4bdf1d0b-e9da-4d96-bafe-c5aaef8c2bd5",[er.GroundingType.COMPOSITE]:"8f9a57db-3865-4886-92fb-c5ab7f3c3fa3",[er.GroundingType.SERVICE_CALL]:"9bf9fc99-ac37-4e51-b9f5-bd920099947c",[er.GroundingType.CREATE_INSTANCE]:"4367e2d6-6c92-450a-becb-abce1fb07682",[er.GroundingType.PROPERTY_APPEND]:"572f7e69-a8a1-42f6-8113-5aa65cc4b552",[er.GroundingType.PROPERTY_INCREMENT]:"afc29f90-45eb-4f94-9fe2-2ce738759161",[er.GroundingType.PROPERTY_SHIFT]:"f4e5266f-f3cc-49fd-a5a5-ce1e8b7847a4",[er.GroundingType.SPARQL_UPDATE]:"79c3e709-8d1d-4694-bcc6-b9ff07d59b86",[er.GroundingType.WORKFLOW_TRANSITION]:"5c1a2552-d576-496d-8823-563573dd1e2f",[er.GroundingType.BODY_TEMPLATE]:"6093bfcb-cf9b-4565-86c3-ff74d8bc11c0"};Kn.GROUNDING_TYPE_UID_TO_ENUM=Object.freeze(Object.fromEntries(Object.entries(Kn.GROUNDING_TYPE_UIDS).map(([n,e])=>[e,n])));var Vi="https://exocortex.my/ontology/exocmd#";Kn.GROUNDING_TYPE_IRI_TO_ENUM=Object.freeze({[`${Vi}GroundingTypePropertySet`]:er.GroundingType.PROPERTY_SET,[`${Vi}GroundingTypePropertyDelete`]:er.GroundingType.PROPERTY_DELETE,[`${Vi}GroundingTypeComposite`]:er.GroundingType.COMPOSITE,[`${Vi}GroundingTypeServiceCall`]:er.GroundingType.SERVICE_CALL,[`${Vi}GroundingTypeCreateInstance`]:er.GroundingType.CREATE_INSTANCE,[`${Vi}GroundingTypePropertyAppend`]:er.GroundingType.PROPERTY_APPEND,[`${Vi}GroundingTypePropertyIncrement`]:er.GroundingType.PROPERTY_INCREMENT,[`${Vi}GroundingTypePropertyShift`]:er.GroundingType.PROPERTY_SHIFT,[`${Vi}GroundingTypeSparqlUpdate`]:er.GroundingType.SPARQL_UPDATE,[`${Vi}GroundingTypeWorkflowTransition`]:er.GroundingType.WORKFLOW_TRANSITION,[`${Vi}GroundingTypeBodyTemplate`]:er.GroundingType.BODY_TEMPLATE});var WB=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;function HB(n){let e=Kn.GROUNDING_TYPE_IRI_TO_ENUM[n];if(e!==void 0)return e;let t=n.match(WB);return t?Kn.GROUNDING_TYPE_UID_TO_ENUM[t[1].toLowerCase()]??null:null}a(HB,"resolveGroundingTypeFromIRI");function zB(n){let e=n.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return e?Kn.GROUNDING_TYPE_UID_TO_ENUM[e[1].toLowerCase()]??null:null}a(zB,"resolveGroundingTypeFromWikilinkLiteral")});var sw=v(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.CommandBindingStyleProperty=Ii.CommandBindingProperty=Ii.GroundingProperty=Ii.PreconditionProperty=Ii.CommandProperty=void 0;Ii.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"};Ii.PreconditionProperty={SPARQL_ASK:"exocmd__Precondition_sparqlAsk",QUERY:"exocmd__Precondition_query"};Ii.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"};Ii.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"};Ii.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 ow=v(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.STYLE_SOURCE_VALUES=Yn.LABEL_CLASS_VALUES=Yn.COMMAND_VARIANT_VALUES=void 0;Yn.isCommandVariant=KB;Yn.isLabelClass=YB;Yn.isStyleSource=QB;Yn.COMMAND_VARIANT_VALUES=Object.freeze(["primary","secondary","success","warning","danger","muted"]);Yn.LABEL_CLASS_VALUES=Object.freeze(["muted","bold","uppercase","compact"]);Yn.STYLE_SOURCE_VALUES=Object.freeze(["vendor","user"]);function KB(n){return typeof n=="string"&&Yn.COMMAND_VARIANT_VALUES.includes(n)}a(KB,"isCommandVariant");function YB(n){return typeof n=="string"&&Yn.LABEL_CLASS_VALUES.includes(n)}a(YB,"isLabelClass");function QB(n){return typeof n=="string"&&Yn.STYLE_SOURCE_VALUES.includes(n)}a(QB,"isStyleSource")});var pO=v($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.isCommandFrontmatter=XB;$c.isPreconditionFrontmatter=JB;$c.isGroundingFrontmatter=ZB;$c.isCommandBindingFrontmatter=e7;function XB(n){return Em(n,"exocmd__Command")}a(XB,"isCommandFrontmatter");function JB(n){return Em(n,"exocmd__Precondition")}a(JB,"isPreconditionFrontmatter");function ZB(n){return Em(n,"exocmd__Grounding")}a(ZB,"isGroundingFrontmatter");function e7(n){return Em(n,"exocmd__CommandBinding")}a(e7,"isCommandBindingFrontmatter");function Em(n,e){let t=n.exo__Instance_class;if(t==null)return!1;let r=Array.isArray(t)?t:[t];for(let i of r){if(typeof i!="string")continue;let s=i.match(/\[\[([^|\]]+)/);if((s?s[1]:i)===e)return!0}return!1}a(Em,"hasInstanceClass")});var hO=v(aw=>{"use strict";Object.defineProperty(aw,"__esModule",{value:!0});aw.parseGroundingDefinitionFromFrontmatter=r7;var t7=pd();function vm(n){if(typeof n!="string")return"";let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t>=0?e.slice(0,t).trim():e}a(vm,"normalizeGroundingRef");function r7(n,e,t){let r=e.exocmd__Grounding_type,i=(()=>{if(typeof r!="string")return r;let E=(0,t7.resolveGroundingTypeFromWikilinkLiteral)(r);if(E!==null)return E;throw new Error(`[exocmd-grounding-type-literal-form] legacy literal-string '${r}' for exocmd__Grounding_type in fixture ${n}. Migrate to wikilink form per RFC 9d20c91f Phase 3.`)})(),s=i==="service_call"?e.exocmd__Grounding_serviceId??e.exocmd__Grounding_targetProperty:e.exocmd__Grounding_targetProperty,o;if(i==="composite"){let E=e.exocmd__Grounding_steps;Array.isArray(E)&&(o=E.map(P=>t(vm(P))))}let l=e.exocmd__Grounding_incrementBy,c;if(l!=null&&l!==""){let E=Number.parseInt(String(l),10);Number.isFinite(E)&&(c=E)}let u=e.exocmd__Grounding_targetValueRef,f=u?vm(u):void 0,d=e.exocmd__Grounding_templateRef,p=d?vm(d):void 0,h=e.exocmd__Grounding_cloneTargetBody,_=h===!0||h==="true",y=e.exocmd__Grounding_targetsCreatedInstance,b=y===!0||y==="true",S=e.exocmd__Grounding_omitLabel,I=S===!0||S==="true",O=e.exocmd__Grounding_targetQuery,T=O?vm(O):void 0;return{id:n,label:e.exo__Asset_label??"",type:i,targetProperty:s,targetValueRef:f,targetValueLiteral:e.exocmd__Grounding_targetValueLiteral,targetValueSubstitution:e.exocmd__Grounding_targetValueSubstitution,serviceCallPayload:e.exocmd__Grounding_serviceCallPayload,appendExpression:e.exocmd__Grounding_appendExpression,targetClass:e.exocmd__Grounding_targetClass,targetPrototype:e.exocmd__Grounding_targetPrototype,targetFolder:e.exocmd__Grounding_targetFolder,shiftDelta:e.exocmd__Grounding_shiftDelta,incrementBy:c,linkBackProperty:e.exocmd__Grounding_linkBackProperty,bodyTemplate:e.exocmd__Grounding_bodyTemplate,templateRef:p,cloneTargetBody:_,targetsCreatedInstance:b,omitLabel:I,targetQuery:T,steps:o}}a(r7,"parseGroundingDefinitionFromFrontmatter")});var mO=v(Tm=>{"use strict";Object.defineProperty(Tm,"__esModule",{value:!0});Tm.hasPosition=n7;Tm.isFixed=i7;function n7(n){return typeof n.x=="number"&&typeof n.y=="number"}a(n7,"hasPosition");function i7(n){return n.fx!==null&&n.fx!==void 0&&n.fy!==null&&n.fy!==void 0}a(i7,"isFixed")});var gO=v(Am=>{"use strict";Object.defineProperty(Am,"__esModule",{value:!0});Am.createEmptyGraphData=s7;Am.mergeGraphData=o7;function s7(){return{nodes:[],edges:[],lastUpdated:Date.now(),version:0}}a(s7,"createEmptyGraphData");function o7(n,e){let t=new Map,r=new Set,i=[];for(let s of n.nodes)t.set(s.id,s);for(let s of e.nodes)t.set(s.id,s);for(let s of n.edges){let o=`${s.source}->${s.target}:${s.type}`;r.has(o)||(r.add(o),i.push(s))}for(let s of e.edges){let o=`${s.source}->${s.target}:${s.type}`;r.has(o)||(r.add(o),i.push(s))}return{nodes:Array.from(t.values()),edges:i,lastUpdated:Date.now(),version:Math.max(n.version??0,e.version??0)+1}}a(o7,"mergeGraphData")});var lw=v(Im=>{"use strict";Object.defineProperty(Im,"__esModule",{value:!0});Im.createEdgeId=a7;Im.edgesEqual=l7;function a7(n,e,t,r){let i=r?`|${r}`:"";return`${n}->${e}:${t}${i}`}a(a7,"createEdgeId");function l7(n,e){return n.source===e.source&&n.target===e.target&&n.type===e.type&&n.predicate===e.predicate}a(l7,"edgesEqual")});var cw=v(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.BUILT_IN_EDGE_STYLES=tr.BUILT_IN_NODE_STYLES=tr.DEFAULT_EDGE_STYLE=tr.DEFAULT_NODE_STYLE=tr.RDF_TYPE_PREDICATES=void 0;tr.mergeNodeStyles=c7;tr.mergeEdgeStyles=u7;tr.extractLocalName=f7;tr.isClassType=d7;tr.isTypePredicate=p7;tr.isSubClassPredicate=h7;tr.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"};tr.DEFAULT_NODE_STYLE={color:"#6366f1",borderColor:"#4f46e5",borderWidth:2,size:30,shape:"circle",icon:"",opacity:1,shadow:!1,animation:"none"};tr.DEFAULT_EDGE_STYLE={color:"#9ca3af",width:1,lineStyle:"solid",arrow:"standard",curvature:0,opacity:.6,showLabel:!1,labelPosition:.5};tr.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"}};tr.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 c7(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(c7,"mergeNodeStyles");function u7(n,e){return{...n,...Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}}a(u7,"mergeEdgeStyles");function f7(n){let e=n.lastIndexOf("#"),t=n.lastIndexOf("/"),r=Math.max(e,t);return r>=0?n.substring(r+1):n}a(f7,"extractLocalName");function d7(n){return n===tr.RDF_TYPE_PREDICATES.RDFS_CLASS||n===tr.RDF_TYPE_PREDICATES.OWL_CLASS}a(d7,"isClassType");function p7(n){return n===tr.RDF_TYPE_PREDICATES.RDF_TYPE}a(p7,"isTypePredicate");function h7(n){return n===tr.RDF_TYPE_PREDICATES.RDFS_SUBCLASS_OF}a(h7,"isSubClassPredicate")});var _O=v(yO=>{"use strict";Object.defineProperty(yO,"__esModule",{value:!0})});var ze=v(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0});xm.IRI=void 0;var uw=class n{static{a(this,"IRI")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("IRI cannot be empty");if(!n.isValidIRI(t))throw new Error("Invalid IRI format");this._value=t}get value(){return this._value}equals(e){return this._value===e._value}toString(){return this._value}static isValidIRI(e){if(!e||e.trim().length===0||/\s/.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e))return!1;let r=["http","https","ftp","ftps","file","mailto","tel","data","ws","wss","urn","obsidian"],i=e.match(/^([a-z][a-z0-9+.-]*?):/i);if(i){let s=i[1].toLowerCase();if(!r.includes(s))return!1}try{return new URL(e),!0}catch{return/^urn:[a-z0-9][a-z0-9-]{0,31}:[^\s]+$/i.test(e)}}};xm.IRI=uw});var tt=v(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});xl.Literal=void 0;xl.parseLanguageTag=bO;xl.createDirectionalLiteral=g7;xl.createLiteralFromLanguageTag=y7;var m7="http://www.w3.org/2001/XMLSchema#string",hd=class{static{a(this,"Literal")}constructor(e,t,r,i){if(e.length===0)throw new Error("Literal value cannot be empty");if(t&&r)throw new Error("Literal cannot have both datatype and language tag");if(i&&!r)throw new Error("Literal cannot have direction without language tag");if(i&&i!=="ltr"&&i!=="rtl")throw new Error('Direction must be "ltr" or "rtl"');this._value=e,this._datatype=t,this._language=r?r.toLowerCase():void 0,this._direction=i}get value(){return this._value}get datatype(){return this._datatype}get language(){return this._language}get direction(){return this._direction}hasDirection(){return this._direction!==void 0}equals(e){if(this._value!==e._value||this._language!==e._language||this._direction!==e._direction)return!1;let t=this.normalizedDatatype(),r=e.normalizedDatatype();return t===r}normalizedDatatype(){return!this._datatype||this._datatype.value===m7?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}};xl.Literal=hd;function bO(n){let t=n.lastIndexOf("--");if(t===-1)return{language:n.toLowerCase()};let r=n.substring(t+2),i=n.substring(0,t);return r==="ltr"||r==="rtl"?{language:i.toLowerCase(),direction:r}:{language:n.toLowerCase()}}a(bO,"parseLanguageTag");function g7(n,e,t){return new hd(n,void 0,e,t)}a(g7,"createDirectionalLiteral");function y7(n,e){let{language:t,direction:r}=bO(e);return new hd(n,void 0,t,r)}a(y7,"createLiteralFromLanguageTag")});var Yt=v(Cm=>{"use strict";Object.defineProperty(Cm,"__esModule",{value:!0});Cm.BlankNode=void 0;var Rm=class n{static{a(this,"BlankNode")}constructor(e){let t=e.trim();if(t.length===0)throw new Error("BlankNode id cannot be empty");this._id=t}get id(){return this._id}equals(e){return this._id===e._id}toString(){return`_:${this._id}`}static generateId(){return`b${++n.counter}`}static create(){return new n(n.generateId())}};Cm.BlankNode=Rm;Rm.counter=0});var Vt=v(Om=>{"use strict";Object.defineProperty(Om,"__esModule",{value:!0});Om.Namespace=void 0;var SO=ze(),Je=class n{static{a(this,"Namespace")}constructor(e,t){if(e.trim().length===0)throw new Error("Namespace prefix cannot be empty");this._prefix=e,this._iri=new SO.IRI(t)}get prefix(){return this._prefix}get iri(){return this._iri}term(e){return new SO.IRI(`${this._iri.value}${e}`)}expand(e){let t=e.split(":");if(t.length!==2)return null;let[r,i]=t;return r!==this._prefix?null:this.term(i)}static forPrefix(e){if(!/^[a-z][a-zA-Z0-9]*$/.test(e))return null;let t=n.KNOWN_NAMESPACES.find(r=>r.prefix===e);return t||new n(e,`${n.EXOCORTEX_ONTOLOGY_BASE}${e}#`)}static fromPropertyKey(e){let t=/^([a-z][a-zA-Z0-9]*)__(.+)$/.exec(e);if(!t)return null;let r=n.forPrefix(t[1]);return r?{namespace:r,localName:t[2]}:null}static fromTermIRI(e){if(typeof e!="string"||e.length===0)return null;let t=a(c=>c.length>0&&!c.includes("#")&&!c.includes("/")?c:null,"cleanLocal");for(let c of n.KNOWN_NAMESPACES){let u=c.iri.value;if(e.startsWith(u)){let f=t(e.slice(u.length));return f===null?null:{namespace:c,localName:f}}}if(!e.startsWith(n.EXOCORTEX_ONTOLOGY_BASE))return null;let r=e.slice(n.EXOCORTEX_ONTOLOGY_BASE.length),i=r.indexOf("#");if(i<=0)return null;let s=r.slice(0,i);if(!/^[a-z][a-zA-Z0-9]*$/.test(s))return null;let o=t(r.slice(i+1));if(o===null)return null;let l=n.forPrefix(s);return l?{namespace:l,localName:o}:null}static knownNamespaces(){return n.KNOWN_NAMESPACES}};Om.Namespace=Je;Je.RDF=new Je("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");Je.RDFS=new Je("rdfs","http://www.w3.org/2000/01/rdf-schema#");Je.OWL=new Je("owl","http://www.w3.org/2002/07/owl#");Je.XSD=new Je("xsd","http://www.w3.org/2001/XMLSchema#");Je.SHACL=new Je("sh","http://www.w3.org/ns/shacl#");Je.EXO=new Je("exo","https://exocortex.my/ontology/exo#");Je.EMS=new Je("ems","https://exocortex.my/ontology/ems#");Je.EXOCMD=new Je("exocmd","https://exocortex.my/ontology/exocmd#");Je.IMS=new Je("ims","https://exocortex.my/ontology/ims#");Je.ZTLK=new Je("ztlk","https://exocortex.my/ontology/ztlk#");Je.PTMS=new Je("ptms","https://exocortex.my/ontology/ptms#");Je.LIT=new Je("lit","https://exocortex.my/ontology/lit#");Je.INBOX=new Je("inbox","https://exocortex.my/ontology/inbox#");Je.PMBOK=new Je("pmbok","https://exocortex.my/ontology/pmbok#");Je.EXOCORTEX_ONTOLOGY_BASE="https://exocortex.my/ontology/";Je.KNOWN_NAMESPACES=[Je.EXO,Je.EMS,Je.EXOCMD,Je.IMS,Je.ZTLK,Je.PTMS,Je.LIT,Je.INBOX,Je.PMBOK,Je.RDF,Je.RDFS,Je.OWL,Je.XSD,Je.SHACL]});var Qn=v(Pm=>{"use strict";Object.defineProperty(Pm,"__esModule",{value:!0});Pm.Triple=void 0;var fw=ze(),dw=tt(),pw=Yt(),hw=class{static{a(this,"Triple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof fw.IRI&&t instanceof fw.IRI||e instanceof pw.BlankNode&&t instanceof pw.BlankNode||e instanceof dw.Literal&&t instanceof dw.Literal||this.isQuotedTriple(e)&&this.isQuotedTriple(t)?e.equals(t):!1}isQuotedTriple(e){return typeof e=="object"&&e!==null&&"termType"in e&&e.termType==="QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`${e} ${t} ${r} .`}nodeToString(e){return e instanceof fw.IRI?`<${e.value}>`:e instanceof pw.BlankNode||e instanceof dw.Literal||this.isQuotedTriple(e)?e.toString():""}};Pm.Triple=hw});var md=v(Dm=>{"use strict";Object.defineProperty(Dm,"__esModule",{value:!0});Dm.QuotedTriple=void 0;var mw=ze(),gw=tt(),yw=Yt(),_w=class n{static{a(this,"QuotedTriple")}constructor(e,t,r){this._subject=e,this._predicate=t,this._object=r}get subject(){return this._subject}get predicate(){return this._predicate}get object(){return this._object}equals(e){return!(!this.equalsNode(this._subject,e._subject)||!this._predicate.equals(e._predicate)||!this.equalsNode(this._object,e._object))}equalsNode(e,t){return e instanceof mw.IRI&&t instanceof mw.IRI||e instanceof yw.BlankNode&&t instanceof yw.BlankNode||e instanceof gw.Literal&&t instanceof gw.Literal||e instanceof n&&t instanceof n?e.equals(t):!1}get termType(){return"QuotedTriple"}toString(){let e=this.nodeToString(this._subject),t=`<${this._predicate.value}>`,r=this.nodeToString(this._object);return`<< ${e} ${t} ${r} >>`}nodeToString(e){return e instanceof mw.IRI?`<${e.value}>`:e instanceof yw.BlankNode||e instanceof gw.Literal||e instanceof n?e.toString():""}};Dm.QuotedTriple=_w});var wO=v(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.QuotedTriple=gr.Triple=gr.Namespace=gr.BlankNode=gr.createLiteralFromLanguageTag=gr.createDirectionalLiteral=gr.parseLanguageTag=gr.Literal=gr.IRI=void 0;var _7=ze();Object.defineProperty(gr,"IRI",{enumerable:!0,get:a(function(){return _7.IRI},"get")});var Fm=tt();Object.defineProperty(gr,"Literal",{enumerable:!0,get:a(function(){return Fm.Literal},"get")});Object.defineProperty(gr,"parseLanguageTag",{enumerable:!0,get:a(function(){return Fm.parseLanguageTag},"get")});Object.defineProperty(gr,"createDirectionalLiteral",{enumerable:!0,get:a(function(){return Fm.createDirectionalLiteral},"get")});Object.defineProperty(gr,"createLiteralFromLanguageTag",{enumerable:!0,get:a(function(){return Fm.createLiteralFromLanguageTag},"get")});var b7=Yt();Object.defineProperty(gr,"BlankNode",{enumerable:!0,get:a(function(){return b7.BlankNode},"get")});var S7=Vt();Object.defineProperty(gr,"Namespace",{enumerable:!0,get:a(function(){return S7.Namespace},"get")});var w7=Qn();Object.defineProperty(gr,"Triple",{enumerable:!0,get:a(function(){return w7.Triple},"get")});var E7=md();Object.defineProperty(gr,"QuotedTriple",{enumerable:!0,get:a(function(){return E7.QuotedTriple},"get")})});var Lm=v(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.UUID_URL_NAMESPACE=Ri.DEFAULT_LANGUAGE_TAG=Ri.REQUIRED_PROPERTIES=Ri.ALLOWED_PROPERTIES=Ri.Exo003MetadataType=void 0;var xi;(function(n){n.Namespace="namespace",n.Anchor="anchor",n.BlankNode="blank_node",n.Statement="statement",n.Body="body"})(xi||(Ri.Exo003MetadataType=xi={}));Ri.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"]};Ri.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"]};Ri.DEFAULT_LANGUAGE_TAG="ru";Ri.UUID_URL_NAMESPACE="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});var EO=v(bw=>{"use strict";Object.defineProperty(bw,"__esModule",{value:!0});bw.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var vO=v(Sw=>{"use strict";Object.defineProperty(Sw,"__esModule",{value:!0});Sw.default="00000000-0000-0000-0000-000000000000"});var TO=v(ww=>{"use strict";Object.defineProperty(ww,"__esModule",{value:!0});ww.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 gd=v(Ew=>{"use strict";Object.defineProperty(Ew,"__esModule",{value:!0});var v7=TO();function T7(n){return typeof n=="string"&&v7.default.test(n)}a(T7,"validate");Ew.default=T7});var yd=v(vw=>{"use strict";Object.defineProperty(vw,"__esModule",{value:!0});var A7=gd();function I7(n){if(!(0,A7.default)(n))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(n.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(n.slice(9,13),16))>>>8,e&255,(e=parseInt(n.slice(14,18),16))>>>8,e&255,(e=parseInt(n.slice(19,23),16))>>>8,e&255,(e=parseInt(n.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}a(I7,"parse");vw.default=I7});var wo=v(_d=>{"use strict";Object.defineProperty(_d,"__esModule",{value:!0});_d.unsafeStringify=void 0;var x7=gd(),tn=[];for(let n=0;n<256;++n)tn.push((n+256).toString(16).slice(1));function AO(n,e=0){return(tn[n[e+0]]+tn[n[e+1]]+tn[n[e+2]]+tn[n[e+3]]+"-"+tn[n[e+4]]+tn[n[e+5]]+"-"+tn[n[e+6]]+tn[n[e+7]]+"-"+tn[n[e+8]]+tn[n[e+9]]+"-"+tn[n[e+10]]+tn[n[e+11]]+tn[n[e+12]]+tn[n[e+13]]+tn[n[e+14]]+tn[n[e+15]]).toLowerCase()}a(AO,"unsafeStringify");_d.unsafeStringify=AO;function R7(n,e=0){let t=AO(n,e);if(!(0,x7.default)(t))throw TypeError("Stringified UUID is invalid");return t}a(R7,"stringify");_d.default=R7});var Mm=v(Tw=>{"use strict";Object.defineProperty(Tw,"__esModule",{value:!0});var C7=require("crypto"),km=new Uint8Array(256),Nm=km.length;function O7(){return Nm>km.length-16&&((0,C7.randomFillSync)(km),Nm=0),km.slice(Nm,Nm+=16)}a(O7,"rng");Tw.default=O7});var Aw=v(Sd=>{"use strict";Object.defineProperty(Sd,"__esModule",{value:!0});Sd.updateV1State=void 0;var IO=Mm(),P7=wo(),bd={};function D7(n,e,t){let r,i=n?._v6??!1;if(n){let s=Object.keys(n);s.length===1&&s[0]==="_v6"&&(n=void 0)}if(n)r=xO(n.random??n.rng?.()??(0,IO.default)(),n.msecs,n.nsecs,n.clockseq,n.node,e,t);else{let s=Date.now(),o=(0,IO.default)();RO(bd,s,o),r=xO(o,bd.msecs,bd.nsecs,i?void 0:bd.clockseq,i?void 0:bd.node,e,t)}return e??(0,P7.unsafeStringify)(r)}a(D7,"v1");function RO(n,e,t){return n.msecs??=-1/0,n.nsecs??=0,e===n.msecs?(n.nsecs++,n.nsecs>=1e4&&(n.node=void 0,n.nsecs=0)):e>n.msecs?n.nsecs=0:e<n.msecs&&(n.node=void 0),n.node||(n.node=t.slice(10,16),n.node[0]|=1,n.clockseq=(t[8]<<8|t[9])&16383),n.msecs=e,n}a(RO,"updateV1State");Sd.updateV1State=RO;function xO(n,e,t,r,i,s,o=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!s)s=new Uint8Array(16),o=0;else if(o<0||o+16>s.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);e??=Date.now(),t??=0,r??=(n[8]<<8|n[9])&16383,i??=n.slice(10,16),e+=122192928e5;let l=((e&268435455)*1e4+t)%4294967296;s[o++]=l>>>24&255,s[o++]=l>>>16&255,s[o++]=l>>>8&255,s[o++]=l&255;let c=e/4294967296*1e4&268435455;s[o++]=c>>>8&255,s[o++]=c&255,s[o++]=c>>>24&15|16,s[o++]=c>>>16&255,s[o++]=r>>>8|128,s[o++]=r&255;for(let u=0;u<6;++u)s[o++]=i[u];return s}a(xO,"v1Bytes");Sd.default=D7});var xw=v(Iw=>{"use strict";Object.defineProperty(Iw,"__esModule",{value:!0});var F7=yd(),L7=wo();function N7(n){let e=typeof n=="string"?(0,F7.default)(n):n,t=k7(e);return typeof n=="string"?(0,L7.unsafeStringify)(t):t}a(N7,"v1ToV6");Iw.default=N7;function k7(n){return Uint8Array.of((n[6]&15)<<4|n[7]>>4&15,(n[7]&15)<<4|(n[4]&240)>>4,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,(n[1]&15)<<4|(n[2]&240)>>4,96|n[2]&15,n[3],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}a(k7,"_v1ToV6")});var CO=v(Rw=>{"use strict";Object.defineProperty(Rw,"__esModule",{value:!0});var M7=require("crypto");function j7(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,M7.createHash)("md5").update(n).digest()}a(j7,"md5");Rw.default=j7});var wd=v(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.URL=Eo.DNS=Eo.stringToBytes=void 0;var OO=yd(),$7=wo();function PO(n){n=unescape(encodeURIComponent(n));let e=new Uint8Array(n.length);for(let t=0;t<n.length;++t)e[t]=n.charCodeAt(t);return e}a(PO,"stringToBytes");Eo.stringToBytes=PO;Eo.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Eo.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function U7(n,e,t,r,i,s){let o=typeof t=="string"?PO(t):t,l=typeof r=="string"?(0,OO.default)(r):r;if(typeof r=="string"&&(r=(0,OO.default)(r)),r?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(l),c.set(o,l.length),c=e(c),c[6]=c[6]&15|n,c[8]=c[8]&63|128,i){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]=c[u];return i}return(0,$7.unsafeStringify)(c)}a(U7,"v35");Eo.default=U7});var FO=v(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.URL=Rl.DNS=void 0;var B7=CO(),Cw=wd(),DO=wd();Object.defineProperty(Rl,"DNS",{enumerable:!0,get:a(function(){return DO.DNS},"get")});Object.defineProperty(Rl,"URL",{enumerable:!0,get:a(function(){return DO.URL},"get")});function Ow(n,e,t,r){return(0,Cw.default)(48,B7.default,n,e,t,r)}a(Ow,"v3");Ow.DNS=Cw.DNS;Ow.URL=Cw.URL;Rl.default=Ow});var LO=v(Pw=>{"use strict";Object.defineProperty(Pw,"__esModule",{value:!0});var V7=require("crypto");Pw.default={randomUUID:V7.randomUUID}});var kO=v(Dw=>{"use strict";Object.defineProperty(Dw,"__esModule",{value:!0});var NO=LO(),q7=Mm(),G7=wo();function W7(n,e,t){if(NO.default.randomUUID&&!e&&!n)return NO.default.randomUUID();n=n||{};let r=n.random??n.rng?.()??(0,q7.default)();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=r[i];return e}return(0,G7.unsafeStringify)(r)}a(W7,"v4");Dw.default=W7});var MO=v(Fw=>{"use strict";Object.defineProperty(Fw,"__esModule",{value:!0});var H7=require("crypto");function z7(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),(0,H7.createHash)("sha1").update(n).digest()}a(z7,"sha1");Fw.default=z7});var $O=v(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});Cl.URL=Cl.DNS=void 0;var K7=MO(),Lw=wd(),jO=wd();Object.defineProperty(Cl,"DNS",{enumerable:!0,get:a(function(){return jO.DNS},"get")});Object.defineProperty(Cl,"URL",{enumerable:!0,get:a(function(){return jO.URL},"get")});function Nw(n,e,t,r){return(0,Lw.default)(80,K7.default,n,e,t,r)}a(Nw,"v5");Nw.DNS=Lw.DNS;Nw.URL=Lw.URL;Cl.default=Nw});var UO=v(kw=>{"use strict";Object.defineProperty(kw,"__esModule",{value:!0});var Y7=wo(),Q7=Aw(),X7=xw();function J7(n,e,t){n??={},t??=0;let r=(0,Q7.default)({...n,_v6:!0},new Uint8Array(16));if(r=(0,X7.default)(r),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]=r[i];return e}return(0,Y7.unsafeStringify)(r)}a(J7,"v6");kw.default=J7});var BO=v(Mw=>{"use strict";Object.defineProperty(Mw,"__esModule",{value:!0});var Z7=yd(),e8=wo();function t8(n){let e=typeof n=="string"?(0,Z7.default)(n):n,t=r8(e);return typeof n=="string"?(0,e8.unsafeStringify)(t):t}a(t8,"v6ToV1");Mw.default=t8;function r8(n){return Uint8Array.of((n[3]&15)<<4|n[4]>>4&15,(n[4]&15)<<4|(n[5]&240)>>4,(n[5]&15)<<4|n[6]&15,n[7],(n[1]&15)<<4|(n[2]&240)>>4,(n[2]&15)<<4|(n[3]&240)>>4,16|(n[0]&240)>>4,(n[0]&15)<<4|(n[1]&240)>>4,n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}a(r8,"_v6ToV1")});var WO=v(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});Ed.updateV7State=void 0;var VO=Mm(),n8=wo(),jw={};function i8(n,e,t){let r;if(n)r=qO(n.random??n.rng?.()??(0,VO.default)(),n.msecs,n.seq,e,t);else{let i=Date.now(),s=(0,VO.default)();GO(jw,i,s),r=qO(s,jw.msecs,jw.seq,e,t)}return e??(0,n8.unsafeStringify)(r)}a(i8,"v7");function GO(n,e,t){return n.msecs??=-1/0,n.seq??=0,e>n.msecs?(n.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],n.msecs=e):(n.seq=n.seq+1|0,n.seq===0&&n.msecs++),n}a(GO,"updateV7State");Ed.updateV7State=GO;function qO(n,e,t,r,i=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return e??=Date.now(),t??=n[6]*127<<24|n[7]<<16|n[8]<<8|n[9],r[i++]=e/1099511627776&255,r[i++]=e/4294967296&255,r[i++]=e/16777216&255,r[i++]=e/65536&255,r[i++]=e/256&255,r[i++]=e&255,r[i++]=112|t>>>28&15,r[i++]=t>>>20&255,r[i++]=128|t>>>14&63,r[i++]=t>>>6&255,r[i++]=t<<2&255|n[10]&3,r[i++]=n[11],r[i++]=n[12],r[i++]=n[13],r[i++]=n[14],r[i++]=n[15],r}a(qO,"v7Bytes");Ed.default=i8});var HO=v($w=>{"use strict";Object.defineProperty($w,"__esModule",{value:!0});var s8=gd();function o8(n){if(!(0,s8.default)(n))throw TypeError("Invalid UUID");return parseInt(n.slice(14,15),16)}a(o8,"version");$w.default=o8});var Ol=v(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.version=vt.validate=vt.v7=vt.v6ToV1=vt.v6=vt.v5=vt.v4=vt.v3=vt.v1ToV6=vt.v1=vt.stringify=vt.parse=vt.NIL=vt.MAX=void 0;var a8=EO();Object.defineProperty(vt,"MAX",{enumerable:!0,get:a(function(){return a8.default},"get")});var l8=vO();Object.defineProperty(vt,"NIL",{enumerable:!0,get:a(function(){return l8.default},"get")});var c8=yd();Object.defineProperty(vt,"parse",{enumerable:!0,get:a(function(){return c8.default},"get")});var u8=wo();Object.defineProperty(vt,"stringify",{enumerable:!0,get:a(function(){return u8.default},"get")});var f8=Aw();Object.defineProperty(vt,"v1",{enumerable:!0,get:a(function(){return f8.default},"get")});var d8=xw();Object.defineProperty(vt,"v1ToV6",{enumerable:!0,get:a(function(){return d8.default},"get")});var p8=FO();Object.defineProperty(vt,"v3",{enumerable:!0,get:a(function(){return p8.default},"get")});var h8=kO();Object.defineProperty(vt,"v4",{enumerable:!0,get:a(function(){return h8.default},"get")});var m8=$O();Object.defineProperty(vt,"v5",{enumerable:!0,get:a(function(){return m8.default},"get")});var g8=UO();Object.defineProperty(vt,"v6",{enumerable:!0,get:a(function(){return g8.default},"get")});var y8=BO();Object.defineProperty(vt,"v6ToV1",{enumerable:!0,get:a(function(){return y8.default},"get")});var _8=WO();Object.defineProperty(vt,"v7",{enumerable:!0,get:a(function(){return _8.default},"get")});var b8=gd();Object.defineProperty(vt,"validate",{enumerable:!0,get:a(function(){return b8.default},"get")});var S8=HO();Object.defineProperty(vt,"version",{enumerable:!0,get:a(function(){return S8.default},"get")})});var Vw=v(jm=>{"use strict";Object.defineProperty(jm,"__esModule",{value:!0});jm.Exo003UUIDGenerator=void 0;var Uw=Ol(),zO=Lm(),Bw=class{static{a(this,"Exo003UUIDGenerator")}static generateNamespaceUUID(e){if(!e||e.trim().length===0)throw new Error("Namespace URI cannot be empty");return(0,Uw.v5)(e,zO.UUID_URL_NAMESPACE)}static generateAssetUUID(e,t){if(!t||t.trim().length===0)throw new Error("Local identifier cannot be empty");let r=this.generateNamespaceUUID(e);return(0,Uw.v5)(t,r)}static generateFromIRI(e){if(!e||e.trim().length===0)throw new Error("IRI cannot be empty");let{namespace:t,localName:r}=this.splitIRI(e);return r?this.generateAssetUUID(t,r):(0,Uw.v5)(e,zO.UUID_URL_NAMESPACE)}static generateBlankNodeUUID(e,t){if(!e||e.trim().length===0)throw new Error("Blank node ID cannot be empty");let r="urn:exocortex:blank-node:",i=t?`${t}#${e}`:e;return this.generateAssetUUID(r,i)}static generateStatementUUID(e,t,r){if(!e||!t||!r)throw new Error("Subject, predicate, and object cannot be empty");let i="urn:exocortex:statement:",s=`${e} ${t} ${r}`;return this.generateAssetUUID(i,s)}static generateBodyUUID(e,t){let r="urn:exocortex:body:",i=e;return t?.datatype?i+=`^^${t.datatype}`:t?.language&&(i+=`@${t.language}`,t.direction&&(i+=`--${t.direction}`)),this.generateAssetUUID(r,i)}static splitIRI(e){let t=e.lastIndexOf("#");if(t!==-1&&t<e.length-1)return{namespace:e.substring(0,t+1),localName:e.substring(t+1)};let r=e.lastIndexOf("/"),i=e.indexOf("://");return r!==-1&&r>i+2&&r<e.length-1?{namespace:e.substring(0,r+1),localName:e.substring(r+1)}:{namespace:e,localName:""}}static isValidUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}};jm.Exo003UUIDGenerator=Bw});var YO=v(Um=>{"use strict";Object.defineProperty(Um,"__esModule",{value:!0});Um.Exo003Parser=void 0;var Ot=Lm(),vd=Vw(),wa=ze(),$m=tt(),KO=Yt(),w8=Qn(),qw=class{static{a(this,"Exo003Parser")}static parse(e,t){let r=this.validate(e);if(!r.valid)return{success:!1,errors:r.errors};let i=e.metadata;try{return{success:!0,metadata:this.parseByType(e,i),bodyContent:i===Ot.Exo003MetadataType.Body?t:void 0}}catch(s){return{success:!1,errors:[s instanceof Error?s.message:String(s)]}}}static validate(e){let t=[],r=[];if(!e.metadata)return t.push("Missing required property: metadata"),{valid:!1,errors:t,warnings:r};let i=e.metadata;if(!Object.values(Ot.Exo003MetadataType).includes(i))return t.push(`Invalid metadata: ${i}. Valid types: ${Object.values(Ot.Exo003MetadataType).join(", ")}`),{valid:!1,errors:t,warnings:r};let s=i,o=Ot.ALLOWED_PROPERTIES[s],l=Ot.REQUIRED_PROPERTIES[s];for(let c of l)(e[c]===void 0||e[c]===null)&&t.push(`Missing required property: ${c}`);for(let c of Object.keys(e))o.includes(c)||t.push(`Forbidden property for ${s}: ${c}`);switch(s){case Ot.Exo003MetadataType.Namespace:this.validateNamespaceMetadata(e,t);break;case Ot.Exo003MetadataType.Anchor:this.validateAnchorMetadata(e,t);break;case Ot.Exo003MetadataType.BlankNode:this.validateBlankNodeMetadata(e,t);break;case Ot.Exo003MetadataType.Statement:this.validateStatementMetadata(e,t);break;case Ot.Exo003MetadataType.Body:this.validateBodyMetadata(e,t,r);break}return{valid:t.length===0,errors:t,warnings:r}}static parseByType(e,t){let r={metadata:t,aliases:e.aliases};switch(t){case Ot.Exo003MetadataType.Namespace:return{...r,metadata:Ot.Exo003MetadataType.Namespace,uri:e.uri};case Ot.Exo003MetadataType.Anchor:return{...r,metadata:Ot.Exo003MetadataType.Anchor,uri:e.uri};case Ot.Exo003MetadataType.BlankNode:return{...r,metadata:Ot.Exo003MetadataType.BlankNode,uri:e.uri};case Ot.Exo003MetadataType.Statement:return{...r,metadata:Ot.Exo003MetadataType.Statement,subject:e.subject,predicate:e.predicate,object:e.object};case Ot.Exo003MetadataType.Body:return{...r,metadata:Ot.Exo003MetadataType.Body,subject:e.subject,predicate:e.predicate}}}static validateNamespaceMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new wa.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateAnchorMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r)try{new wa.IRI(r)}catch{t.push(`uri is not a valid IRI: ${String(r)}`)}}static validateBlankNodeMetadata(e,t){let r=e.uri;if(r&&typeof r!="string")t.push("uri must be a string");else if(r){let i=r;if(!i.startsWith("_:"))try{new wa.IRI(i)}catch{t.push(`uri is not a valid IRI or blank node identifier: ${String(r)}`)}}}static validateStatementMetadata(e,t){let r=e.subject,i=e.predicate,s=e.object,o=[["subject",r],["predicate",i],["object",s]];for(let[l,c]of o)c&&typeof c!="string"&&t.push(`${l} must be a string`)}static validateBodyMetadata(e,t,r){let i=e.subject,s=e.predicate;i&&typeof i!="string"&&t.push("subject must be a string"),s&&typeof s!="string"&&t.push("predicate must be a string")}static toTriple(e,t,r){let i=t(e.subject),s;if(i.type==="iri")s=new wa.IRI(i.value);else if(i.type==="blank")s=new KO.BlankNode(i.value);else throw new Error("Statement subject cannot be a literal");let o=t(e.predicate);if(o.type!=="iri")throw new Error("Statement predicate must be an IRI");let l=new wa.IRI(o.value),c=t(e.object),u;if(c.type==="iri")u=new wa.IRI(c.value);else if(c.type==="blank")u=new KO.BlankNode(c.value);else{let f=r||c.value;if(c.datatype)u=new $m.Literal(f,new wa.IRI(c.datatype));else{let d=c.language||Ot.DEFAULT_LANGUAGE_TAG;u=(0,$m.createDirectionalLiteral)(f,d,c.direction)}}return new w8.Triple(s,l,u)}static toLiteral(e,t,r){if(r?.datatype)return new $m.Literal(t,new wa.IRI(r.datatype));let i=r?.language||Ot.DEFAULT_LANGUAGE_TAG;return(0,$m.createDirectionalLiteral)(t,i,r?.direction)}static isExo003Format(e){let t=e.metadata;return typeof t=="string"&&Object.values(Ot.Exo003MetadataType).includes(t)}static generateUUID(e,t){switch(e.metadata){case Ot.Exo003MetadataType.Namespace:return vd.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Ot.Exo003MetadataType.Anchor:return vd.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Ot.Exo003MetadataType.BlankNode:return vd.Exo003UUIDGenerator.generateNamespaceUUID(e.uri);case Ot.Exo003MetadataType.Statement:{let r=e;return vd.Exo003UUIDGenerator.generateStatementUUID(r.subject,r.predicate,r.object)}case Ot.Exo003MetadataType.Body:{let r=e;return vd.Exo003UUIDGenerator.generateBodyUUID(r.subject+"|"+r.predicate)}}}};Um.Exo003Parser=qw});var Gw=v(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.Exo003Parser=mn.Exo003UUIDGenerator=mn.UUID_URL_NAMESPACE=mn.DEFAULT_LANGUAGE_TAG=mn.REQUIRED_PROPERTIES=mn.ALLOWED_PROPERTIES=mn.Exo003MetadataType=void 0;var Td=Lm();Object.defineProperty(mn,"Exo003MetadataType",{enumerable:!0,get:a(function(){return Td.Exo003MetadataType},"get")});Object.defineProperty(mn,"ALLOWED_PROPERTIES",{enumerable:!0,get:a(function(){return Td.ALLOWED_PROPERTIES},"get")});Object.defineProperty(mn,"REQUIRED_PROPERTIES",{enumerable:!0,get:a(function(){return Td.REQUIRED_PROPERTIES},"get")});Object.defineProperty(mn,"DEFAULT_LANGUAGE_TAG",{enumerable:!0,get:a(function(){return Td.DEFAULT_LANGUAGE_TAG},"get")});Object.defineProperty(mn,"UUID_URL_NAMESPACE",{enumerable:!0,get:a(function(){return Td.UUID_URL_NAMESPACE},"get")});var E8=Vw();Object.defineProperty(mn,"Exo003UUIDGenerator",{enumerable:!0,get:a(function(){return E8.Exo003UUIDGenerator},"get")});var v8=YO();Object.defineProperty(mn,"Exo003Parser",{enumerable:!0,get:a(function(){return v8.Exo003Parser},"get")})});var Fs=v(Bm=>{"use strict";Object.defineProperty(Bm,"__esModule",{value:!0});Bm.WikiLinkHelpers=void 0;var Ad=class{static{a(this,"WikiLinkHelpers")}static normalize(e){if(!e)return"";let t=e.replace(this.WIKI_LINK_PATTERN,"").trim();if(!t)return"";let r=t.indexOf("|");if(r===-1)return t;let i=t.substring(0,r).trim(),s=t.substring(r+1).trim();return this.UUID_PATTERN.test(i)&&s||i}static normalizeArray(e){return e?(Array.isArray(e)?e:[e]).map(r=>this.normalize(r)).filter(r=>r.length>0):[]}static equals(e,t){return this.normalize(e)===this.normalize(t)}static includes(e,t){let r=this.normalizeArray(e),i=this.normalize(t);return r.includes(i)}static resolveSymbolic(e,t){let r=this.normalize(e);if(!r)return"";if(this.UUID_PATTERN.test(r)){let i=t(r);return i&&i.length>0?i:r}return r}static resolveSymbolicArray(e,t){return e?(Array.isArray(e)?e:[e]).map(i=>this.resolveSymbolic(i,t)).filter(i=>i.length>0):[]}};Bm.WikiLinkHelpers=Ad;Ad.WIKI_LINK_PATTERN=/\[\[|\]\]/g;Ad.UUID_PATTERN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});var xd=v(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.CommandBindingProperty=Pt.GroundingProperty=Pt.PreconditionProperty=Pt.CommandProperty=Pt.resolveGroundingTypeFromWikilinkLiteral=Pt.resolveGroundingTypeFromIRI=Pt.GROUNDING_TYPE_IRI_TO_ENUM=Pt.GROUNDING_TYPE_UID_TO_ENUM=Pt.GROUNDING_TYPE_UIDS=Pt.GroundingType=Pt.EFFORT_STATUS_OPTIONS=Pt.EffortStatus=Pt.AssetClass=void 0;var T8=Al();Object.defineProperty(Pt,"AssetClass",{enumerable:!0,get:a(function(){return T8.AssetClass},"get")});var A8=Il();Object.defineProperty(Pt,"EffortStatus",{enumerable:!0,get:a(function(){return A8.EffortStatus},"get")});var I8=iw();Object.defineProperty(Pt,"EFFORT_STATUS_OPTIONS",{enumerable:!0,get:a(function(){return I8.EFFORT_STATUS_OPTIONS},"get")});var x8=Sa();Object.defineProperty(Pt,"GroundingType",{enumerable:!0,get:a(function(){return x8.GroundingType},"get")});var Id=pd();Object.defineProperty(Pt,"GROUNDING_TYPE_UIDS",{enumerable:!0,get:a(function(){return Id.GROUNDING_TYPE_UIDS},"get")});Object.defineProperty(Pt,"GROUNDING_TYPE_UID_TO_ENUM",{enumerable:!0,get:a(function(){return Id.GROUNDING_TYPE_UID_TO_ENUM},"get")});Object.defineProperty(Pt,"GROUNDING_TYPE_IRI_TO_ENUM",{enumerable:!0,get:a(function(){return Id.GROUNDING_TYPE_IRI_TO_ENUM},"get")});Object.defineProperty(Pt,"resolveGroundingTypeFromIRI",{enumerable:!0,get:a(function(){return Id.resolveGroundingTypeFromIRI},"get")});Object.defineProperty(Pt,"resolveGroundingTypeFromWikilinkLiteral",{enumerable:!0,get:a(function(){return Id.resolveGroundingTypeFromWikilinkLiteral},"get")});var Vm=sw();Object.defineProperty(Pt,"CommandProperty",{enumerable:!0,get:a(function(){return Vm.CommandProperty},"get")});Object.defineProperty(Pt,"PreconditionProperty",{enumerable:!0,get:a(function(){return Vm.PreconditionProperty},"get")});Object.defineProperty(Pt,"GroundingProperty",{enumerable:!0,get:a(function(){return Vm.GroundingProperty},"get")});Object.defineProperty(Pt,"CommandBindingProperty",{enumerable:!0,get:a(function(){return Vm.CommandBindingProperty},"get")})});var ZO=v(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.hasClass=Dl;gn.isAreaOrProject=R8;gn.isEffort=C8;gn.hasStatus=O8;gn.isAssetArchived=P8;gn.hasEmptyProperties=D8;gn.needsFolderRepair=F8;gn.getTodayDateString=Ww;gn.isPlannedForToday=L8;gn.hasPlannedStartTimestamp=N8;gn.extractDailyNoteDate=k8;gn.isCurrentDateGteDay=M8;gn.inheritsFromPrototype=JO;gn.isPrototypeClass=$8;var XO=Fs(),Pl=xd();function Dl(n,e){return n?(Array.isArray(n)?n:[n]).some(r=>XO.WikiLinkHelpers.normalize(r)===e):!1}a(Dl,"hasClass");function R8(n){return Dl(n,Pl.AssetClass.AREA)||Dl(n,Pl.AssetClass.PROJECT)}a(R8,"isAreaOrProject");function C8(n){return Dl(n,Pl.AssetClass.TASK)||Dl(n,Pl.AssetClass.PROJECT)||Dl(n,Pl.AssetClass.MEETING)}a(C8,"isEffort");function O8(n,e){if(!n)return!1;let t=Array.isArray(n)?n[0]:n;return t?XO.WikiLinkHelpers.normalize(t)===e:!1}a(O8,"hasStatus");function P8(n){if(n===!0||n===1)return!0;if(typeof n=="string"){let e=n.toLowerCase();return e==="true"||e==="yes"}return!1}a(P8,"isAssetArchived");function D8(n){if(!n||Object.keys(n).length===0)return!1;let e=a(t=>t==null||t==="","isEmptyArrayItem");return Object.values(n).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(D8,"hasEmptyProperties");function F8(n,e){if(!e)return!1;let t=n.replace(/\/$/,""),r=e.replace(/\/$/,"");return t!==r}a(F8,"needsFolderRepair");function Ww(){let n=new Date,e=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0");return`${e}-${t}-${r}`}a(Ww,"getTodayDateString");function L8(n){let e=n.ems__Effort_plannedStartTimestamp;if(!e)return!1;let t=Ww();return typeof e=="string"?e.split("T")[0]===t:Array.isArray(e)&&e.length>0?String(e[0]).split("T")[0]===t:!1}a(L8,"isPlannedForToday");function N8(n){let e=n.ems__Effort_plannedStartTimestamp;return e?typeof e=="string"?e.trim().length>0:Array.isArray(e)&&e.length>0?String(e[0]).trim().length>0:!1:!1}a(N8,"hasPlannedStartTimestamp");function k8(n){let e=n.pn__DailyNote_day;if(!e)return null;if(typeof e=="string"){let t=e.match(/\[\[([^\[\]]+)\]\]/);return t?t[1]:e}if(Array.isArray(e)&&e.length>0){let t=String(e[0]),r=t.match(/\[\[([^\[\]]+)\]\]/);return r?r[1]:t}return null}a(k8,"extractDailyNoteDate");function M8(n){return Ww()>=n}a(M8,"isCurrentDateGteDay");function QO(n){return n?n.replace(/^["']|["']$/g,"").replace(/\[\[|\]\]/g,"").trim():""}a(QO,"normalizeWithQuotes");var j8=10;function JO(n,e=j8){let t=n.exo__Class_superClass;if(!t)return!1;let r=new Set,i=[],s=Array.isArray(t)?t:[t];for(let o of s){let l=QO(o);l&&i.push({className:l,depth:0})}for(;i.length>0;){let o=i.shift();if(!o)continue;let{className:l,depth:c}=o;if(c>e)continue;if(l===Pl.AssetClass.PROTOTYPE)return!0;if(r.has(l))continue;r.add(l);let u=`${l}__exo__Class_superClass`,f=n[u];if(f){let d=Array.isArray(f)?f:[f];for(let p of d){let h=QO(p);h&&!r.has(h)&&i.push({className:h,depth:c+1})}}}return!1}a(JO,"inheritsFromPrototype");function $8(n,e){return Dl(n,Pl.AssetClass.CLASS)?JO(e):!1}a($8,"isPrototypeClass")});var eP=v(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.isPrototypeClass=Tt.inheritsFromPrototype=Tt.isCurrentDateGteDay=Tt.extractDailyNoteDate=Tt.hasPlannedStartTimestamp=Tt.isPlannedForToday=Tt.getTodayDateString=Tt.needsFolderRepair=Tt.hasEmptyProperties=Tt.isAssetArchived=Tt.hasStatus=Tt.isEffort=Tt.isAreaOrProject=Tt.hasClass=void 0;var Xn=ZO();Object.defineProperty(Tt,"hasClass",{enumerable:!0,get:a(function(){return Xn.hasClass},"get")});Object.defineProperty(Tt,"isAreaOrProject",{enumerable:!0,get:a(function(){return Xn.isAreaOrProject},"get")});Object.defineProperty(Tt,"isEffort",{enumerable:!0,get:a(function(){return Xn.isEffort},"get")});Object.defineProperty(Tt,"hasStatus",{enumerable:!0,get:a(function(){return Xn.hasStatus},"get")});Object.defineProperty(Tt,"isAssetArchived",{enumerable:!0,get:a(function(){return Xn.isAssetArchived},"get")});Object.defineProperty(Tt,"hasEmptyProperties",{enumerable:!0,get:a(function(){return Xn.hasEmptyProperties},"get")});Object.defineProperty(Tt,"needsFolderRepair",{enumerable:!0,get:a(function(){return Xn.needsFolderRepair},"get")});Object.defineProperty(Tt,"getTodayDateString",{enumerable:!0,get:a(function(){return Xn.getTodayDateString},"get")});Object.defineProperty(Tt,"isPlannedForToday",{enumerable:!0,get:a(function(){return Xn.isPlannedForToday},"get")});Object.defineProperty(Tt,"hasPlannedStartTimestamp",{enumerable:!0,get:a(function(){return Xn.hasPlannedStartTimestamp},"get")});Object.defineProperty(Tt,"extractDailyNoteDate",{enumerable:!0,get:a(function(){return Xn.extractDailyNoteDate},"get")});Object.defineProperty(Tt,"isCurrentDateGteDay",{enumerable:!0,get:a(function(){return Xn.isCurrentDateGteDay},"get")});Object.defineProperty(Tt,"inheritsFromPrototype",{enumerable:!0,get:a(function(){return Xn.inheritsFromPrototype},"get")});Object.defineProperty(Tt,"isPrototypeClass",{enumerable:!0,get:a(function(){return Xn.isPrototypeClass},"get")})});var tP=v(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.TsFloorViolationError=At.CATALOG_KEEP_NAMESPACES=At.PLUGIN_UI_FLOOR=At.SDK_FLOOR=At.PLUGIN_UI_FLOOR_ASSETSPACE_UIDS=At.SDK_FLOOR_ASSETSPACE_UIDS=At.TS_FLOOR_AS_UID_SHARED_IDENTITIES=At.TS_FLOOR_AS_UID_EXOCMD=At.TS_FLOOR_AS_UID_EXO=void 0;At.assertTsFloor=U8;At.assertTsFloorReconciled=B8;At.isTsFloorAssetSpace=V8;At.isTsFloorMountPath=q8;At.TS_FLOOR_AS_UID_EXO="49fd2e56-4656-4ca7-a789-f472b16ea260";At.TS_FLOOR_AS_UID_EXOCMD="c9c65b0f-1e01-47c1-a1f9-1bf70b11df6a";At.TS_FLOOR_AS_UID_SHARED_IDENTITIES="0cde1557-6320-4bd0-a7c4-8b72afc38720";At.SDK_FLOOR_ASSETSPACE_UIDS=new Set([At.TS_FLOOR_AS_UID_EXO]);At.PLUGIN_UI_FLOOR_ASSETSPACE_UIDS=new Set([At.TS_FLOOR_AS_UID_EXO]);At.SDK_FLOOR=[{uid:At.TS_FLOOR_AS_UID_EXO,namespace:"exo"}];At.PLUGIN_UI_FLOOR=At.SDK_FLOOR;At.CATALOG_KEEP_NAMESPACES=new Set(["registry","profiles"]);var Rd=class extends Error{static{a(this,"TsFloorViolationError")}constructor(e){super(e),this.name="TsFloorViolationError"}};At.TsFloorViolationError=Rd;function U8(n,e){let t=[];for(let r of e)n.has(r)||t.push(r);if(t.length>0)throw new Rd(`Target profile's declared set excludes TS-floor AssetSpace UID(s): ${t.join(", ")}. Profile switch aborted to prevent runtime self-brick (R24).`)}a(U8,"assertTsFloor");function B8(n,e,t){let r=[];for(let i of t)n.has(i.uid)||e.has(i.namespace)||r.push(`${i.namespace} (${i.uid})`);if(r.length>0)throw new Rd(`Target profile's declared set excludes TS-floor AssetSpace(s): ${r.join(", ")}. Profile switch aborted to prevent runtime self-brick (R24).`)}a(B8,"assertTsFloorReconciled");function V8(n,e,t=At.SDK_FLOOR){return t.some(r=>n.length>0&&r.uid===n||e.length>0&&r.namespace===e)}a(V8,"isTsFloorAssetSpace");function q8(n,e=At.SDK_FLOOR){let t=n.replace(/\/+$/,""),r=t.slice(t.lastIndexOf("/")+1),i=r.startsWith("exoas-")?r.slice(6):r;return i.length===0?!1:e.some(s=>s.namespace===i)}a(q8,"isTsFloorMountPath")});var rP=v(Hw=>{"use strict";Object.defineProperty(Hw,"__esModule",{value:!0});Hw.transitiveDependsOnClosure=G8;function G8(n,e){let t=new Set,r=[];for(let i of n)t.has(i)||(t.add(i),r.push(i));for(;r.length>0;){let i=r.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),r.push(o))}return t}a(G8,"transitiveDependsOnClosure")});var zw=v(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.PARKED_ROOT=Jn.DEPENDENCY_KIND_REFERENCE_UID=Jn.DEPENDENCY_KIND_TBOX_UID=void 0;Jn.resolveDependencyKind=iP;Jn.parkedPathFor=H8;Jn.classifyMountTransition=z8;Jn.DEPENDENCY_KIND_TBOX_UID="e1d7fb5c-d334-448d-935b-953b7b033e78";Jn.DEPENDENCY_KIND_REFERENCE_UID="fe529085-5370-4ac0-bbe4-1c7351242dee";var W8="dependencykindreference";function iP(n){let e=Array.isArray(n)?n[0]:n;if(typeof e!="string")return"tbox";let t=e.toLowerCase();return t.includes(Jn.DEPENDENCY_KIND_TBOX_UID)?"tbox":t.includes(Jn.DEPENDENCY_KIND_REFERENCE_UID)||t.includes(W8)?"reference":"tbox"}a(iP,"resolveDependencyKind");Jn.PARKED_ROOT=".exocortex/parked";var nP="assetspaces/";function H8(n){let e=n.split("/");if(n.length===0||!n.startsWith(nP)||e.some(t=>t.length===0||t==="."||t===".."))throw new Error(`parkedPathFor: refusing unsafe mount folder "${n}"`);return`${Jn.PARKED_ROOT}/${n.slice(nP.length)}`}a(H8,"parkedPathFor");function z8(n){let{state:e,inEffectiveSet:t,dependsOnKind:r,canPark:i=!0}=n;switch(e){case"active":return t?"none":i&&iP(r)==="reference"?"park":"destroy";case"parked":return t?"unpark":"none";case"absent":return t?"materialize":"none"}}a(z8,"classifyMountTransition")});var aP=v(qm=>{"use strict";Object.defineProperty(qm,"__esModule",{value:!0});qm.ParkedAssetIndex=void 0;var sP=zw();function K8(n){let t=n.replace(/^\[\[|\]\]$/g,"").replace(/^"|"$/g,"").trim().split("#")[0].trim();return(t.split("/").pop()??t).replace(/\.md$/i,"")}a(K8,"normalizeLinkTarget");function oP(n){let e=n.match(/^---\r?\n([\s\S]*?)\r?\n---/);return e===null?null:e[1]}a(oP,"frontmatterOf");function Y8(n){let e=oP(n);if(e===null)return!1;let t=e.match(/^exo__Asset_uid:[ \t]*(.+)$/m);return t!==null&&t[1].trim().length>0}a(Y8,"hasAssetUid");function Q8(n){let e=oP(n);if(e===null)return null;let t=e.match(/^exo__Asset_label:[ \t]*(.+)$/m);if(t===null)return null;let r=t[1].trim();return r.length<1?null:r.length>=2&&r.startsWith('"')&&r.endsWith('"')?Kw(r.slice(1,-1).replace(/\\(["\\ntr])/g,(i,s)=>s==="n"?`
32
32
  `:s==="t"?" ":s==="r"?"\r":s)):r.length>=2&&r.startsWith("'")&&r.endsWith("'")?Kw(r.slice(1,-1).replace(/''/g,"'")):Kw(r)}a(Q8,"extractLabel");function Kw(n){return n.length===0?null:n}a(Kw,"orNull");var Yw=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=K8(e);if(t.length===0)return null;let i=(await this.ensureIndex()).get(t);if(i===void 0)return null;let s=X8(i);if(s===null)return null;let o;try{o=await this.reader.read(i)}catch{return null}return Y8(o)?{path:i,assetSpace:s,label:Q8(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,r=await t;return e!==this.generation?(this.building===t&&(this.building=null),this.ensureIndex()):(this.index=r,this.building===t&&(this.building=null),r)}async buildIndex(){let e=new Map;return await this.walk(sP.PARKED_ROOT,e),e}async walk(e,t){let r;try{if(!await this.reader.exists(e))return;r=await this.reader.list(e)}catch{return}for(let i of r.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 r.folders)(i.split("/").pop()??i).startsWith(".")||await this.walk(i,t)}};qm.ParkedAssetIndex=Yw;function X8(n){let e=`${sP.PARKED_ROOT}/`;if(!n.startsWith(e))return null;let t=n.slice(e.length).split("/");if(t.length<3)return null;let[r,i]=t;return r.length===0||i.length===0?null:`${r}/${i}`}a(X8,"assetSpaceOf")});var Gm=v(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});Cd.PropertyFieldType=void 0;Cd.rangeToFieldType=eV;var rn;(function(n){n.Text="text",n.Number="number",n.Date="date",n.DateTime="datetime",n.Boolean="boolean",n.Reference="reference",n.Enum="enum",n.StatusSelect="status-select",n.SizeSelect="size-select",n.Wikilink="wikilink",n.Timestamp="timestamp",n.Unknown="unknown"})(rn||(Cd.PropertyFieldType=rn={}));var lP="http://www.w3.org/2001/XMLSchema#",J8="https://exocortex.my/ontology/exo#",Z8="https://exocortex.my/ontology/ems#";function eV(n){if(!n)return rn.Unknown;let e=n.trim();if(!e)return rn.Unknown;if(e.startsWith(lP)){let t=e.substring(lP.length);return Qw(t)}if(e.startsWith("xsd:")){let t=e.substring(4);return Qw(t)}if(e.includes("XMLSchema#")){let t=e.indexOf("XMLSchema#"),r=e.substring(t+10);return Qw(r)}return e.startsWith(Z8)||e.startsWith("ems:")?tV(e):e.startsWith(J8)||e.startsWith("exo:")||rV(e)?rn.Reference:rn.Text}a(eV,"rangeToFieldType");function Qw(n){switch(n.toLowerCase()){case"string":case"normalizedstring":case"token":case"language":case"nmtoken":case"name":case"ncname":case"anyuri":return rn.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 rn.Number;case"date":return rn.Date;case"datetime":case"datetimestamp":return rn.DateTime;case"boolean":return rn.Boolean;case"time":return rn.Timestamp;default:return rn.Text}}a(Qw,"xsdTypeToFieldType");function tV(n){let e=n.toLowerCase();return e.includes("effortstatus")?rn.StatusSelect:e.includes("tasksize")?rn.SizeSelect:rn.Reference}a(tV,"emsTypeToFieldType");function rV(n){let e=n.toLowerCase();return e.includes("exocortex.my/ontology")?!0:["asset","task","project","area","effort","class","property","concept"].some(r=>e.includes(r))}a(rV,"isClassReference")});var Xw=v(Od=>{"use strict";Object.defineProperty(Od,"__esModule",{value:!0});Od.propertyNameToUri=nV;Od.uriToPropertyName=cP;Od.extractPropertyLabel=iV;function nV(n){return n.replace(/^([a-z]+)__/,"$1:")}a(nV,"propertyNameToUri");function cP(n){if(n.startsWith("http://")||n.startsWith("https://")){let e=n.match(/\/([a-z]+)#([A-Za-z0-9_]+)$/);if(e)return`${e[1]}__${e[2]}`;let t=n.lastIndexOf("#"),r=n.lastIndexOf("/"),i=Math.max(t,r);return i>=0?n.substring(i+1):n}return n.replace(/^([a-z]+):/,"$1__")}a(cP,"uriToPropertyName");function iV(n){let r=(n.includes(":")?cP(n):n).replace(/^[a-z]+__/,"").split("_");return(r.length>1?r.slice(1).join(" "):r[0]).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,s=>s.toUpperCase())}a(iV,"extractPropertyLabel")});var Wm={};pm(Wm,{__assign:()=>Zw,__asyncDelegator:()=>yV,__asyncGenerator:()=>gV,__asyncValues:()=>_V,__await:()=>Pd,__awaiter:()=>uV,__classPrivateFieldGet:()=>EV,__classPrivateFieldSet:()=>vV,__createBinding:()=>dV,__decorate:()=>aV,__exportStar:()=>pV,__extends:()=>sV,__generator:()=>fV,__importDefault:()=>wV,__importStar:()=>SV,__makeTemplateObject:()=>bV,__metadata:()=>cV,__param:()=>lV,__read:()=>uP,__rest:()=>oV,__spread:()=>hV,__spreadArrays:()=>mV,__values:()=>e1});function sV(n,e){Jw(n,e);function t(){this.constructor=n}a(t,"__"),n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function oV(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function aV(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}function lV(n,e){return function(t,r){e(t,r,n)}}function cV(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}function uV(n,e,t,r){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return a(i,"adopt"),new(t||(t=Promise))(function(s,o){function l(f){try{u(r.next(f))}catch(d){o(d)}}a(l,"fulfilled");function c(f){try{u(r.throw(f))}catch(d){o(d)}}a(c,"rejected");function u(f){f.done?s(f.value):i(f.value).then(l,c)}a(u,"step"),u((r=r.apply(n,e||[])).next())})}function fV(n,e){var t={label:0,sent:a(function(){if(s[0]&1)throw s[1];return s[1]},"sent"),trys:[],ops:[]},r,i,s,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(u){return function(f){return c([u,f])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;t;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){t.label=u[1];break}if(u[0]===6&&t.label<s[1]){t.label=s[1],s=u;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(u);break}s[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(n,t)}catch(f){u=[6,f],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function dV(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}function pV(n,e){for(var t in n)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=n[t])}function e1(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:a(function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}},"next")};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function uP(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(l){o={error:l}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}return s}function hV(){for(var n=[],e=0;e<arguments.length;e++)n=n.concat(uP(arguments[e]));return n}function mV(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),i=0,e=0;e<t;e++)for(var s=arguments[e],o=0,l=s.length;o<l;o++,i++)r[i]=s[o];return r}function Pd(n){return this instanceof Pd?(this.v=n,this):new Pd(n)}function gV(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(p){r[p]&&(i[p]=function(h){return new Promise(function(_,y){s.push([p,h,_,y])>1||l(p,h)})})}function l(p,h){try{c(r[p](h))}catch(_){d(s[0][3],_)}}function c(p){p.value instanceof Pd?Promise.resolve(p.value.v).then(u,f):d(s[0][2],p)}function u(p){l("next",p)}function f(p){l("throw",p)}function d(p,h){p(h),s.shift(),s.length&&l(s[0][0],s[0][1])}}function yV(n){var e,t;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=n[i]?function(o){return(t=!t)?{value:Pd(n[i](o)),done:i==="return"}:s?s(o):o}:s}}function _V(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof e1=="function"?e1(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(l,c){o=n[s](o),i(l,c,o.done,o.value)})}}function i(s,o,l,c){Promise.resolve(c).then(function(u){s({value:u,done:l})},o)}}function bV(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}function SV(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)Object.hasOwnProperty.call(n,t)&&(e[t]=n[t]);return e.default=n,e}function wV(n){return n&&n.__esModule?n:{default:n}}function EV(n,e){if(!e.has(n))throw new TypeError("attempted to get private field on non-instance");return e.get(n)}function vV(n,e,t){if(!e.has(n))throw new TypeError("attempted to set private field on non-instance");return e.set(n,t),t}var Jw,Zw,Hm=et(()=>{Jw=a(function(n,e){return Jw=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)r.hasOwnProperty(i)&&(t[i]=r[i])},Jw(n,e)},"extendStatics");a(sV,"__extends");Zw=a(function(){return Zw=Object.assign||a(function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},"__assign"),Zw.apply(this,arguments)},"__assign");a(oV,"__rest");a(aV,"__decorate");a(lV,"__param");a(cV,"__metadata");a(uV,"__awaiter");a(fV,"__generator");a(dV,"__createBinding");a(pV,"__exportStar");a(e1,"__values");a(uP,"__read");a(hV,"__spread");a(mV,"__spreadArrays");a(Pd,"__await");a(gV,"__asyncGenerator");a(yV,"__asyncDelegator");a(_V,"__asyncValues");a(bV,"__makeTemplateObject");a(SV,"__importStar");a(wV,"__importDefault");a(EV,"__classPrivateFieldGet");a(vV,"__classPrivateFieldSet")});var n1=v(r1=>{"use strict";Object.defineProperty(r1,"__esModule",{value:!0});var t1;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(t1||(t1={}));r1.default=t1});var fP=v(i1=>{"use strict";Object.defineProperty(i1,"__esModule",{value:!0});var TV=n1();Object.defineProperty(i1,"Lifecycle",{enumerable:!0,get:a(function(){return TV.default},"get")})});var Fl=v(qi=>{"use strict";Object.defineProperty(qi,"__esModule",{value:!0});qi.defineInjectionTokenMetadata=qi.getParamInfo=qi.INJECTION_TOKEN_METADATA_KEY=void 0;qi.INJECTION_TOKEN_METADATA_KEY="injectionTokens";function AV(n){let e=Reflect.getMetadata("design:paramtypes",n)||[],t=Reflect.getOwnMetadata(qi.INJECTION_TOKEN_METADATA_KEY,n)||{};return Object.keys(t).forEach(r=>{e[+r]=t[r]}),e}a(AV,"getParamInfo");qi.getParamInfo=AV;function IV(n,e){return function(t,r,i){let s=Reflect.getOwnMetadata(qi.INJECTION_TOKEN_METADATA_KEY,t)||{};s[i]=e?{token:n,transform:e.transformToken,transformArgs:e.args||[]}:n,Reflect.defineMetadata(qi.INJECTION_TOKEN_METADATA_KEY,s,t)}}a(IV,"defineInjectionTokenMetadata");qi.defineInjectionTokenMetadata=IV});var s1=v(zm=>{"use strict";Object.defineProperty(zm,"__esModule",{value:!0});zm.isClassProvider=void 0;function xV(n){return!!n.useClass}a(xV,"isClassProvider");zm.isClassProvider=xV});var o1=v(Km=>{"use strict";Object.defineProperty(Km,"__esModule",{value:!0});Km.isFactoryProvider=void 0;function RV(n){return!!n.useFactory}a(RV,"isFactoryProvider");Km.isFactoryProvider=RV});var Qm=v(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.delay=Uc.DelayedConstructor=void 0;var Ym=class{static{a(this,"DelayedConstructor")}constructor(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}createProxy(e){let t={},r=!1,i,s=a(()=>(r||(i=e(this.wrap()),r=!0),i),"delayedObject");return new Proxy(t,this.createHandler(s))}createHandler(e){let t={},r=a(i=>{t[i]=(...s)=>{s[0]=e();let o=Reflect[i];return o(...s)}},"install");return this.reflectMethods.forEach(r),t}};Uc.DelayedConstructor=Ym;function CV(n){if(typeof n>"u")throw new Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new Ym(n)}a(CV,"delay");Uc.delay=CV});var Xm=v(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.isConstructorToken=Ls.isTransformDescriptor=Ls.isTokenDescriptor=Ls.isNormalToken=void 0;var OV=Qm();function PV(n){return typeof n=="string"||typeof n=="symbol"}a(PV,"isNormalToken");Ls.isNormalToken=PV;function DV(n){return typeof n=="object"&&"token"in n&&"multiple"in n}a(DV,"isTokenDescriptor");Ls.isTokenDescriptor=DV;function FV(n){return typeof n=="object"&&"token"in n&&"transform"in n}a(FV,"isTransformDescriptor");Ls.isTransformDescriptor=FV;function LV(n){return typeof n=="function"||n instanceof OV.DelayedConstructor}a(LV,"isConstructorToken");Ls.isConstructorToken=LV});var a1=v(Jm=>{"use strict";Object.defineProperty(Jm,"__esModule",{value:!0});Jm.isTokenProvider=void 0;function NV(n){return!!n.useToken}a(NV,"isTokenProvider");Jm.isTokenProvider=NV});var l1=v(Zm=>{"use strict";Object.defineProperty(Zm,"__esModule",{value:!0});Zm.isValueProvider=void 0;function kV(n){return n.useValue!=null}a(kV,"isValueProvider");Zm.isValueProvider=kV});var c1=v(Ll=>{"use strict";Object.defineProperty(Ll,"__esModule",{value:!0});var MV=s1();Object.defineProperty(Ll,"isClassProvider",{enumerable:!0,get:a(function(){return MV.isClassProvider},"get")});var jV=o1();Object.defineProperty(Ll,"isFactoryProvider",{enumerable:!0,get:a(function(){return jV.isFactoryProvider},"get")});var $V=Xm();Object.defineProperty(Ll,"isNormalToken",{enumerable:!0,get:a(function(){return $V.isNormalToken},"get")});var UV=a1();Object.defineProperty(Ll,"isTokenProvider",{enumerable:!0,get:a(function(){return UV.isTokenProvider},"get")});var BV=l1();Object.defineProperty(Ll,"isValueProvider",{enumerable:!0,get:a(function(){return BV.isValueProvider},"get")})});var dP=v(eg=>{"use strict";Object.defineProperty(eg,"__esModule",{value:!0});eg.isProvider=void 0;var VV=s1(),qV=l1(),GV=a1(),WV=o1();function HV(n){return VV.isClassProvider(n)||qV.isValueProvider(n)||GV.isTokenProvider(n)||WV.isFactoryProvider(n)}a(HV,"isProvider");eg.isProvider=HV});var d1=v(f1=>{"use strict";Object.defineProperty(f1,"__esModule",{value:!0});var u1=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,[])}};f1.default=u1});var pP=v(h1=>{"use strict";Object.defineProperty(h1,"__esModule",{value:!0});var zV=d1(),p1=class extends zV.default{static{a(this,"Registry")}};h1.default=p1});var hP=v(g1=>{"use strict";Object.defineProperty(g1,"__esModule",{value:!0});var m1=class{static{a(this,"ResolutionContext")}constructor(){this.scopedResolutions=new Map}};g1.default=m1});var y1=v(tg=>{"use strict";Object.defineProperty(tg,"__esModule",{value:!0});tg.formatErrorCtor=void 0;function KV(n,e){return n===null?`at position #${e}`:`"${n.split(",")[e].trim()}" at position #${e}`}a(KV,"formatDependency");function YV(n,e,t=" "){return[n,...e.message.split(`
33
33
  `).map(r=>t+r)].join(`
34
- `)}a(YV,"composeErrorMessage");function QV(n,e,t){let[,r=null]=n.toString().match(/constructor\(([\w, ]+)\)/)||[],i=KV(r,e);return YV(`Cannot inject the dependency ${i} of "${n.name}" constructor. Reason:`,t)}a(QV,"formatErrorCtor");tg.formatErrorCtor=QV});var mP=v(rg=>{"use strict";Object.defineProperty(rg,"__esModule",{value:!0});rg.isDisposable=void 0;function XV(n){return!(typeof n.dispose!="function"||n.dispose.length>0)}a(XV,"isDisposable");rg.isDisposable=XV});var yP=v(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.PostResolutionInterceptors=Nl.PreResolutionInterceptors=void 0;var gP=d1(),ng=class extends gP.default{static{a(this,"PreResolutionInterceptors")}};Nl.PreResolutionInterceptors=ng;var ig=class extends gP.default{static{a(this,"PostResolutionInterceptors")}};Nl.PostResolutionInterceptors=ig;var _1=class{static{a(this,"Interceptors")}constructor(){this.preResolution=new ng,this.postResolution=new ig}};Nl.default=_1});var Ea=v(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.instance=vo.typeInfo=void 0;var JV=(Hm(),hm(Wm)),Dn=c1(),ZV=dP(),sg=Xm(),eq=pP(),Zn=n1(),og=hP(),tq=y1(),rq=Qm(),nq=mP(),iq=yP();vo.typeInfo=new Map;var b1=class n{static{a(this,"InternalDependencyContainer")}constructor(e){this.parent=e,this._registry=new eq.default,this.interceptors=new iq.default,this.disposed=!1,this.disposables=new Set}register(e,t,r={lifecycle:Zn.default.Transient}){this.ensureNotDisposed();let i;if(ZV.isProvider(t)?i=t:i={useClass:t},Dn.isTokenProvider(i)){let s=[e],o=i;for(;o!=null;){let l=o.useToken;if(s.includes(l))throw new Error(`Token registration cycle detected! ${[...s,l].join(" -> ")}`);s.push(l);let c=this._registry.get(l);c&&Dn.isTokenProvider(c.provider)?o=c.provider:o=null}}if((r.lifecycle===Zn.default.Singleton||r.lifecycle==Zn.default.ContainerScoped||r.lifecycle==Zn.default.ResolutionScoped)&&(Dn.isValueProvider(i)||Dn.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Zn.default[r.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:r}),this}registerType(e,t){return this.ensureNotDisposed(),Dn.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(),Dn.isNormalToken(e)){if(Dn.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:Zn.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Zn.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let r=e;return t&&!Dn.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:Zn.default.Singleton})}resolve(e,t=new og.default,r=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&Dn.isNormalToken(e)){if(r)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(sg.isConstructorToken(e)){let s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let r=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&r.push(i),i.callback(e,t);this.interceptors.preResolution.setAll(e,r)}}executePostResolutionInterceptor(e,t,r){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,t,r);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Zn.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===Zn.default.Singleton,i=e.options.lifecycle===Zn.default.ContainerScoped,s=r||i,o;return Dn.isValueProvider(e.provider)?o=e.provider.useValue:Dn.isTokenProvider(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Dn.isClassProvider(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Dn.isFactoryProvider(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===Zn.default.ResolutionScoped&&t.scopedResolutions.set(e,o),o}resolveAll(e,t=new og.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&Dn.isNormalToken(e)){if(r)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let o=i.map(l=>this.resolveRegistration(l,t));return this.executePostResolutionInterceptor(e,o,"All"),o}let s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(r=>!Dn.isValueProvider(r.provider)).map(r=>(r.instance=void 0,r)))}createChildContainer(){this.ensureNotDisposed();let e=new n(this);for(let[t,r]of this._registry.entries())r.some(({options:i})=>i.lifecycle===Zn.default.ContainerScoped)&&e._registry.setAll(t,r.map(i=>i.options.lifecycle===Zn.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,t,r={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:t,options:r})}afterResolution(e,t,r={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:t,options:r})}dispose(){return JV.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let r=t.dispose();r&&e.push(r)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,t){if(e instanceof rq.DelayedConstructor)return e.createProxy(i=>this.resolve(i,t));let r=(()=>{let i=vo.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 nq.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(r,i)=>{try{return sg.isTokenDescriptor(r)?sg.isTransformDescriptor(r)?r.multiple?this.resolve(r.transform).transform(this.resolveAll(r.token,new og.default,r.isOptional),...r.transformArgs):this.resolve(r.transform).transform(this.resolve(r.token,e,r.isOptional),...r.transformArgs):r.multiple?this.resolveAll(r.token,new og.default,r.isOptional):this.resolve(r.token,e,r.isOptional):sg.isTransformDescriptor(r)?this.resolve(r.transform,e).transform(this.resolve(r.token,e),...r.transformArgs):this.resolve(r,e)}catch(s){throw new Error(tq.formatErrorCtor(t,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};vo.instance=new b1;vo.default=vo.instance});var _P=v(w1=>{"use strict";Object.defineProperty(w1,"__esModule",{value:!0});var sq=Fl(),To=Ea(),S1=Xm(),oq=y1();function aq(){return function(n){let e=sq.getParamInfo(n);return class extends n{constructor(...t){super(...t.concat(e.slice(t.length).map((r,i)=>{try{return S1.isTokenDescriptor(r)?S1.isTransformDescriptor(r)?r.multiple?To.instance.resolve(r.transform).transform(To.instance.resolveAll(r.token),...r.transformArgs):To.instance.resolve(r.transform).transform(To.instance.resolve(r.token),...r.transformArgs):r.multiple?To.instance.resolveAll(r.token):To.instance.resolve(r.token):S1.isTransformDescriptor(r)?To.instance.resolve(r.transform).transform(To.instance.resolve(r.token),...r.transformArgs):To.instance.resolve(r)}catch(s){let o=i+t.length;throw new Error(oq.formatErrorCtor(n,o,s))}})))}}}}a(aq,"autoInjectable");w1.default=aq});var bP=v(E1=>{"use strict";Object.defineProperty(E1,"__esModule",{value:!0});var lq=Fl();function cq(n,e){let t={token:n,multiple:!1,isOptional:e&&e.isOptional};return lq.defineInjectionTokenMetadata(t)}a(cq,"inject");E1.default=cq});var ag=v(v1=>{"use strict";Object.defineProperty(v1,"__esModule",{value:!0});var uq=Fl(),fq=Ea(),SP=Ea();function dq(n){return function(e){fq.typeInfo.set(e,uq.getParamInfo(e)),n&&n.token&&(Array.isArray(n.token)?n.token.forEach(t=>{SP.instance.register(t,e)}):SP.instance.register(n.token,e))}}a(dq,"injectable");v1.default=dq});var wP=v(T1=>{"use strict";Object.defineProperty(T1,"__esModule",{value:!0});var pq=(Hm(),hm(Wm)),hq=Ea();function mq(n=[]){return function(e){return n.forEach(t=>{var{token:r,options:i}=t,s=pq.__rest(t,["token","options"]);return hq.instance.register(r,s,i)}),e}}a(mq,"registry");T1.default=mq});var EP=v(A1=>{"use strict";Object.defineProperty(A1,"__esModule",{value:!0});var gq=ag(),yq=Ea();function _q(){return function(n){gq.default()(n),yq.instance.registerSingleton(n)}}a(_q,"singleton");A1.default=_q});var vP=v(I1=>{"use strict";Object.defineProperty(I1,"__esModule",{value:!0});var bq=Fl();function Sq(n,e){let t={token:n,multiple:!0,isOptional:e&&e.isOptional};return bq.defineInjectionTokenMetadata(t)}a(Sq,"injectAll");I1.default=Sq});var TP=v(x1=>{"use strict";Object.defineProperty(x1,"__esModule",{value:!0});var wq=Fl();function Eq(n,e,...t){let r={token:n,multiple:!0,transform:e,transformArgs:t};return wq.defineInjectionTokenMetadata(r)}a(Eq,"injectAllWithTransform");x1.default=Eq});var AP=v(R1=>{"use strict";Object.defineProperty(R1,"__esModule",{value:!0});var vq=Fl();function Tq(n,e,...t){return vq.defineInjectionTokenMetadata(n,{transformToken:e,args:t})}a(Tq,"injectWithTransform");R1.default=Tq});var IP=v(C1=>{"use strict";Object.defineProperty(C1,"__esModule",{value:!0});var Aq=ag(),Iq=Ea();function xq(n,e){return function(t){Aq.default()(t),Iq.instance.register(e||t,t,{lifecycle:n})}}a(xq,"scoped");C1.default=xq});var xP=v(Gi=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});var Rq=_P();Object.defineProperty(Gi,"autoInjectable",{enumerable:!0,get:a(function(){return Rq.default},"get")});var Cq=bP();Object.defineProperty(Gi,"inject",{enumerable:!0,get:a(function(){return Cq.default},"get")});var Oq=ag();Object.defineProperty(Gi,"injectable",{enumerable:!0,get:a(function(){return Oq.default},"get")});var Pq=wP();Object.defineProperty(Gi,"registry",{enumerable:!0,get:a(function(){return Pq.default},"get")});var Dq=EP();Object.defineProperty(Gi,"singleton",{enumerable:!0,get:a(function(){return Dq.default},"get")});var Fq=vP();Object.defineProperty(Gi,"injectAll",{enumerable:!0,get:a(function(){return Fq.default},"get")});var Lq=TP();Object.defineProperty(Gi,"injectAllWithTransform",{enumerable:!0,get:a(function(){return Lq.default},"get")});var Nq=AP();Object.defineProperty(Gi,"injectWithTransform",{enumerable:!0,get:a(function(){return Nq.default},"get")});var kq=IP();Object.defineProperty(Gi,"scoped",{enumerable:!0,get:a(function(){return kq.default},"get")})});var RP=v(O1=>{"use strict";Object.defineProperty(O1,"__esModule",{value:!0});function Mq(n){let e;return t=>(e==null&&(e=n(t)),e)}a(Mq,"instanceCachingFactory");O1.default=Mq});var CP=v(P1=>{"use strict";Object.defineProperty(P1,"__esModule",{value:!0});function jq(n){let e=new WeakMap;return t=>{let r=e.get(t);return r==null&&(r=n(t),e.set(t,r)),r}}a(jq,"instancePerContainerCachingFactory");P1.default=jq});var OP=v(D1=>{"use strict";Object.defineProperty(D1,"__esModule",{value:!0});function $q(n,e,t,r=!0){let i,s;return o=>{let l=n(o);return(!r||s!==l)&&((s=l)?i=o.resolve(e):i=o.resolve(t)),i}}a($q,"predicateAwareClassFactory");D1.default=$q});var PP=v(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});var Uq=RP();Object.defineProperty(Dd,"instanceCachingFactory",{enumerable:!0,get:a(function(){return Uq.default},"get")});var Bq=CP();Object.defineProperty(Dd,"instancePerContainerCachingFactory",{enumerable:!0,get:a(function(){return Bq.default},"get")});var Vq=OP();Object.defineProperty(Dd,"predicateAwareClassFactory",{enumerable:!0,get:a(function(){return Vq.default},"get")})});var ut=v(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});var F1=(Hm(),hm(Wm));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 qq=fP();Object.defineProperty(va,"Lifecycle",{enumerable:!0,get:a(function(){return qq.Lifecycle},"get")});F1.__exportStar(xP(),va);F1.__exportStar(PP(),va);F1.__exportStar(c1(),va);var Gq=Qm();Object.defineProperty(va,"delay",{enumerable:!0,get:a(function(){return Gq.delay},"get")});var Wq=Ea();Object.defineProperty(va,"container",{enumerable:!0,get:a(function(){return Wq.instance},"get")})});var Fd=v(lg=>{"use strict";Object.defineProperty(lg,"__esModule",{value:!0});lg.NullLogger=void 0;lg.NullLogger={debug(){},info(){},warn(){},error(){}}});var Vc=v(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.bytesToBase64=FP;Bc.base64ToBytes=LP;Bc.base64ToUtf8=Hq;Bc.utf8ToBase64=zq;var DP=32768;function FP(n){let e="";for(let t=0;t<n.length;t+=DP)e+=String.fromCharCode(...n.subarray(t,t+DP));return btoa(e)}a(FP,"bytesToBase64");function LP(n){let e=n.replace(/\s/g,""),t=e.length%4,r=t===2||t===3?e+"=".repeat(4-t):e,i=atob(r),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}a(LP,"base64ToBytes");function Hq(n){return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(LP(n))}a(Hq,"base64ToUtf8");function zq(n){return FP(new TextEncoder().encode(n))}a(zq,"utf8ToBase64")});var Ld=v(L1=>{"use strict";Object.defineProperty(L1,"__esModule",{value:!0});L1.iriToObsidianName=Yq;var Kq=Vt();function Yq(n){let e=Kq.Namespace.fromTermIRI(n);if(e)return`${e.namespace.prefix}__${e.localName}`;let t=n.match(/\/([^/]+)\.md$/);return t?t[1]:null}a(Yq,"iriToObsidianName")});var NP=v(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.registerUniversalDefaultLoader=Qq;Ta.clearUniversalDefaultLoader=Xq;Ta.clearUniversalDefault=Jq;Ta.loadUniversalDefault=Zq;Ta.mergePropertyDefaults=eG;Ta.mergeInheritanceRules=tG;var cg=null,Ao,Nd=!1;function Qq(n){cg=n,Ao=void 0,Nd=!1}a(Qq,"registerUniversalDefaultLoader");function Xq(){cg=null,Ao=void 0,Nd=!1}a(Xq,"clearUniversalDefaultLoader");function Jq(){Ao=void 0,Nd=!1}a(Jq,"clearUniversalDefault");async function Zq(){if(Ao!==void 0)return Ao;if(!cg)return Ao=null,null;try{Ao=await cg()??null}catch(n){Nd||(console.warn("[UniversalDefaultTemplateResolver] loader threw, falling back to legacy primitives:",n),Nd=!0),Ao=null}return Ao}a(Zq,"loadUniversalDefault");function eG(n,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.propertyName);o?(r.push(o),i.add(o.propertyName)):r.push(s)}for(let s of e)i.has(s.propertyName)||r.push(s);return r}a(eG,"mergePropertyDefaults");function tG(n,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.targetPropertyName);o?(r.push(o),i.add(o.targetPropertyName)):r.push(s)}for(let s of e)i.has(s.targetPropertyName)||r.push(s);return r}a(tG,"mergeInheritanceRules")});var N1=v((jye,kP)=>{var qc=class{static{a(this,"Wildcard")}constructor(){return rG||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(qc.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(qc.prototype,"termType",{enumerable:!0,value:"Wildcard"});var rG=new qc;kP.exports.Wildcard=qc});var jP=v((Uye,MP)=>{var nG=(function(){var n=a(function(Y,W,Z,le){for(Z=Z||{},le=Y.length;le--;Z[Y[le]]=W);return Z},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],r=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],l=[13,16,45,197,224,229,308],c=[28,29,53],u=[28,53],f=[1,42],d=[1,45],p=[1,41],h=[1,44],_=[123,126],y=[1,67],b=[39,45,87],S=[13,16,45,197,224,308],I=[1,87],O=[2,281],T=[1,86],E=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],P=[6,28,29,53,63,70,73,81,83,85],V=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],M=[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],j=[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],$=[13,16,308],G=[112,132,327,334],ge=[13,16,112,132,308],ye=[1,111],Q=[1,117],se=[112,132,327,328,334],J=[13,16,112,132,308,328],ve=[28,29,45,53,87],re=[1,138],ie=[1,151],he=[1,128],Ue=[1,127],ce=[1,129],ue=[1,140],fe=[1,141],ne=[1,142],me=[1,143],Le=[1,144],B=[1,145],oe=[1,147],Ee=[1,148],Ce=[2,457],xe=[1,158],Oe=[1,159],Re=[1,160],Ae=[1,152],ee=[1,153],_e=[1,156],Te=[1,171],Pe=[1,172],Me=[1,173],Ne=[1,174],Ge=[1,175],ke=[1,176],We=[1,167],qe=[1,168],je=[1,169],He=[1,170],m=[1,157],L=[1,166],U=[1,161],R=[1,162],C=[1,163],D=[1,164],w=[1,165],F=[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],X=[1,195],H=[6,31,73,81,83,85],q=[2,285],k=[1,199],N=[1,201],z=[6,31,70,73,81,83,85],K=[2,283],ae=[1,207],Se=[1,218],De=[1,223],rt=[1,219],Jr=[1,225],Cr=[1,226],sr=[1,224],aC=[6,63,70,73,81,83,85],lC=[1,236],cC=[2,334],uC=[1,243],fC=[1,241],Zr=[6,193],Wh=[2,349],dC=[2,339],ya=[28,128],pC=[47,48,193,272],Hh=[47,48,193,242,272],Rc=[47,48,193,242,246,272],Cc=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],$r=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],hC=[1,271],mC=[1,270],hr=[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],gC=[1,281],yC=[1,280],Cn=[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],td=[45,89],zh=[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],Kh=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Yh=[31,89],Qh=[48,87],ml=[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],xs=[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],_C=[1,313],Oc=[6,85],bS=[6,31,81,83,85],bC=[2,361],fo=[2,353],gl=[1,343],rd=[31,112,335],po=[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],SS=[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],SC=[6,109,193],yl=[31,112],mr=[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],wS=[1,390],ES=[1,391],_a=[13,16,87,197,308,314],wC=[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],Xh=[1,417],Jh=[1,418],EC=[13,16,48,197,229,308],ba=[6,31,85],vC=[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],vS=[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],_l=[29,31,85,112,159,160,161,163,164],Zh=[1,443],em=[1,444],TC=[1,449],bl=[31,112,193,232,318,335],tm=[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],AC=[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],TS=[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],nd=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],id=[31,45],IC=[1,507],xC=[1,508],RC=[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],rm=[29,31,85,112,159,160,161,163,164,335],Sl=[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],CC=[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],OC=[2,352],AS=[13,16,197,308,314],PC=[1,565],Pc=[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],DC=[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],ho=[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],FC=[13,16,87,308],mo=[2,364],Dc=[29,31,85,112,159,160,161,163,164,193,232,318,335],nm=[31,112,193,232,272,318,335],go=[2,359],LC=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],im=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],NC=[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],kC=[2,347],IS={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(W,Z,le,Be,it,A,Pn){var x=A.length-1;switch(it){case 1:if(A[x-1]=A[x-1]||{},ot.base&&(A[x-1].base=ot.base),ot.base="",A[x-1].prefixes=ot.prefixes,ot.prefixes=null,ot.pathOnly){if(A[x-1].type==="path"||"termType"in A[x-1])return A[x-1];throw new Error("Received full SPARQL query in path only mode")}else if(A[x-1].type==="path"||"termType"in A[x-1])throw new Error("Received only path in full SPARQL mode");if(A[x-1].type==="update"){let Nt={};for(let Kt of A[x-1].updates)if(Kt.updateType==="insert"){let bt={};for(let Rt of Kt.insert)if(Rt.type==="bgp"||Rt.type==="graph")for(let zn of Rt.triples)zn.subject.termType==="BlankNode"&&(bt[zn.subject.value]=!0),zn.predicate.termType==="BlankNode"&&(bt[zn.predicate.value]=!0),zn.object.termType==="BlankNode"&&(bt[zn.object.value]=!0);for(let Rt of Object.keys(bt)){if(Nt[Rt])throw new Error("Detected reuse blank node across different INSERT DATA clauses");Nt[Rt]=!0}}}return A[x-1];case 2:this.$={...A[x-1],...A[x],type:"query"};break;case 4:ot.base=sd(A[x]);break;case 5:ot.prefixes||(ot.prefixes={}),A[x-1]=A[x-1].substr(0,A[x-1].length-1),A[x]=sd(A[x]),ot.prefixes[A[x-1]]=A[x];break;case 6:this.$={...A[x-3],...vl(A[x-2]),...A[x-1],...A[x]};break;case 7:if(!ot.skipValidation&&(LS(A[x-3].variables.map(Kt=>FS(Kt.expression))).some(Kt=>Kt.aggregation==="count"&&!(Kt.expression instanceof sm))||A[x].group)){for(let Kt of A[x-3].variables)if(Kt.termType==="Variable"){if(!A[x].group||!A[x].group.map(bt=>kc(bt)).includes(kc(Kt)))throw Error("Projection of ungrouped variable (?"+kc(Kt)+")")}else if(FS(Kt.expression).length===0){let bt=EB(Kt.expression);for(let Rt of bt)if(!A[x].group||!A[x].group.map||!A[x].group.map(zn=>kc(zn)).includes(kc(Rt)))throw Error("Use of ungrouped variable in projection of operation (?"+kc(Rt)+")")}}let Ps=A[x-1].where.filter(Nt=>Nt.type==="query");if(Ps.length>0){let Nt=A[x-3].variables.filter(bt=>bt.variable&&bt.variable.value).map(bt=>bt.variable.value),Kt=LS(Ps.map(bt=>bt.variables)).map(bt=>bt.value||bt.variable.value);for(let bt of Nt)if(Kt.indexOf(bt)>=0)throw Error("Target id of 'AS' (?"+bt+") already used in subquery")}this.$=or(A[x-3],vl(A[x-2]),A[x-1],A[x]);break;case 8:this.$=or({queryType:"CONSTRUCT",template:A[x-3]},vl(A[x-2]),A[x-1],A[x]);break;case 9:this.$=or({queryType:"CONSTRUCT",template:A[x-2]=A[x-2]?A[x-2].triples:[]},vl(A[x-5]),{where:[{type:"bgp",triples:El([],A[x-2])}]},A[x]);break;case 10:this.$=or({queryType:"DESCRIBE",variables:A[x-3]==="*"?[new sm]:A[x-3]},vl(A[x-2]),A[x-1],A[x]);break;case 11:this.$=or({queryType:"ASK"},vl(A[x-2]),A[x-1],A[x]);break;case 12:this.$=or(A[x-1],{variables:[new sm]});break;case 13:let ud=A[x].map(Nt=>Nt.value||Nt.variable.value),Mc=vB(ud);if(Mc.length>0)throw Error("Two or more of the resulting columns have the same name (?"+Mc[0]+")");this.$=or(A[x-1],{variables:A[x]});break;case 14:this.$=or({queryType:"SELECT"},A[x]&&(A[x-1]=On(A[x]),A[x]={},A[x][A[x-1]]=!0,A[x]));break;case 16:case 27:this.$=Fc(A[x-3],{variable:A[x-1]});break;case 17:case 18:this.$=or(A[x-3],A[x-2],A[x-1],A[x],{type:"query"});break;case 19:case 58:this.$={iri:A[x],named:!!A[x-1]};break;case 20:this.$={where:A[x].patterns};break;case 21:this.$=or(A[x-1],A[x]);break;case 22:this.$=or(A[x-2],A[x-1],A[x]);break;case 23:this.$={group:A[x]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Fc(A[x]);break;case 26:this.$=Fc(A[x-1]);break;case 29:this.$={having:A[x]};break;case 30:this.$={order:A[x]};break;case 32:this.$=Fc(A[x],{descending:!0});break;case 35:this.$={limit:Nc(A[x])};break;case 36:this.$={offset:Nc(A[x])};break;case 37:this.$={limit:Nc(A[x-2]),offset:Nc(A[x])};break;case 38:this.$={limit:Nc(A[x]),offset:Nc(A[x-2])};break;case 39:case 43:this.$={type:"values",values:A[x]};break;case 40:case 84:this.$=A[x-1].map(Nt=>({[A[x-3]]:Nt}));break;case 41:case 85:this.$=A[x-1].map(()=>({}));break;case 42:case 86:var Os=A[x-4].length;A[x-4]=A[x-4].map(xS),this.$=A[x-1].map(function(Nt){if(Nt.length!==Os)throw Error("Inconsistent VALUES length");for(var Kt={},bt=0;bt<Os;bt++)Kt["?"+A[x-4][bt].value]=Nt[bt];return Kt});break;case 44:case 65:case 100:case 126:case 175:this.$=A[x-1];break;case 45:this.$={type:"update",updates:yo(A[x-2],A[x-1])};break;case 46:this.$=or({type:"load",silent:!!A[x-2],source:A[x-1]},A[x]&&{destination:A[x]});break;case 47:this.$={type:On(A[x-2]),silent:!!A[x-1],graph:A[x]};break;case 48:this.$={type:On(A[x-4]),silent:!!A[x-3],source:A[x-2],destination:A[x]};break;case 49:this.$={type:"create",silent:!!A[x-2],graph:{type:"graph",name:A[x]}};break;case 50:this.$={updateType:"insert",insert:zC(A[x])};break;case 51:this.$={updateType:"delete",delete:MS(zC(A[x]))};break;case 52:this.$={updateType:"deletewhere",delete:MS(A[x])};break;case 53:this.$={updateType:"insertdelete",...A[x-4],...A[x-3],...vl(A[x-2],"using"),where:A[x].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=A[x];break;case 55:this.$={delete:MS(A[x-1]),insert:A[x]||[]};break;case 56:this.$={delete:[],insert:A[x]};break;case 59:this.$={graph:A[x]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:A[x]};break;case 64:this.$={[On(A[x])]:!0};break;case 66:this.$=A[x-1]?Rs(A[x],[A[x-1]]):Rs(A[x]);break;case 67:var ld=or(A[x-3]||{triples:[]},{type:"graph",name:A[x-5]});this.$=A[x]?[ld,A[x]]:[ld];break;case 68:case 73:this.$={type:"bgp",triples:Rs(A[x-2],[A[x-1]])};break;case 69:this.$={type:"group",patterns:[A[x-1]]};break;case 70:for(let Nt of A[x-1].filter(Kt=>Kt.type==="bind")){let Kt=A[x-1].indexOf(Nt),bt=new Set;for(let Rt of A[x-1].slice(0,Kt))(Rt.type==="group"||Rt.type==="bgp")&&WC(Rt).forEach(zn=>bt.add(zn));if(bt.has(Nt.variable.value))throw Error("Variable used to bind is already bound (?"+Nt.variable.value+")")}this.$={type:"group",patterns:A[x-1]};break;case 71:this.$=A[x-1]?Rs([A[x-1]],A[x]):Rs(A[x]);break;case 72:this.$=A[x]?[A[x-2],A[x]]:A[x-2];break;case 75:this.$=or(A[x],{type:"optional"});break;case 76:this.$=or(A[x],{type:"minus"});break;case 77:this.$=or(A[x],{type:"graph",name:A[x-1]});break;case 78:this.$=or(A[x],{type:"service",name:A[x-1],silent:!!A[x-2]});break;case 79:this.$={type:"filter",expression:A[x]};break;case 80:this.$={type:"bind",variable:A[x-1],expression:A[x-3]};break;case 89:this.$=ad(A[x]);break;case 90:this.$=void 0;break;case 91:this.$=A[x-1].length?{type:"union",patterns:Rs(A[x-1].map(CS),[CS(A[x])])}:A[x];break;case 95:this.$={...A[x],function:A[x-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:yo(A[x-2],A[x-1]),distinct:!!A[x-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.$=yo(A[x-2],A[x-1]);break;case 101:this.$=Rs(A[x-2],[A[x-1]]);break;case 102:case 112:this.$=kS(A[x].map(Nt=>or(_o(A[x-1]),Nt)));break;case 103:this.$=kS(El(A[x].map(Nt=>or(_o(A[x-1].entity),Nt)),A[x-1].triples));break;case 105:this.$=Rs([A[x-1]],A[x]);break;case 106:this.$=Rs(A[x]);break;case 107:this.$=DS(A[x-1],A[x]);break;case 109:case 237:this.$=ot.factory.namedNode(dB);break;case 110:case 118:this.$=yo(A[x-1],A[x]);break;case 111:this.$=A[x]?{annotation:A[x],object:A[x-1]}:A[x-1];break;case 113:this.$=A[x]?kS(El(A[x].map(Nt=>or(_o(A[x-1].entity),Nt)),A[x-1].triples)):A[x-1].triples;break;case 114:this.$=DS(...A[x-1],A[x]);break;case 116:this.$=DS(...A[x]);break;case 117:case 159:case 163:this.$=[A[x-1],A[x]];break;case 119:this.$=A[x]?{object:A[x-1],annotation:A[x]}:A[x-1];break;case 120:this.$=A[x-1].length?Lc("|",yo(A[x-1],A[x])):A[x];break;case 121:this.$=A[x-1].length?Lc("/",yo(A[x-1],A[x])):A[x];break;case 122:this.$=A[x]?Lc(A[x],[A[x-1]]):A[x-1];break;case 123:this.$=A[x-1]?Lc(A[x-1],[A[x]]):A[x];break;case 125:case 131:this.$=Lc(A[x-1],[A[x]]);break;case 129:this.$=Lc("|",yo(A[x-2],A[x-1]));break;case 132:case 134:this.$=SB(A[x-1]);break;case 133:case 135:this.$=wB(A[x-1]);break;case 140:this.$={entity:A[x],triples:[]};break;case 145:this.$=xS(A[x]);break;case 149:this.$=ot.factory.namedNode(MC);break;case 151:case 153:case 158:case 162:this.$=RS(A[x-1],A[x]);break;case 152:this.$=["||",A[x]];break;case 154:this.$=["&&",A[x]];break;case 156:this.$=en(A[x-1],[A[x-2],A[x]]);break;case 157:this.$=en(A[x-2]?"notin":"in",[A[x-3],A[x]]);break;case 160:this.$=["+",RS(A[x-1],A[x])];break;case 161:var lm=Cs(A[x-1].value.replace("-",""),A[x-1].datatype);this.$=["-",RS(lm,A[x])];break;case 164:this.$=en("UPLUS",[A[x]]);break;case 165:this.$=en(A[x-1],[A[x]]);break;case 166:this.$=en("UMINUS",[A[x]]);break;case 177:this.$=en(On(A[x-1]));break;case 178:this.$=en(On(A[x-3]),[A[x-1]]);break;case 179:this.$=ad(en(On(A[x-3]),[A[x-1]]));break;case 180:this.$=en(On(A[x-5]),[A[x-3],A[x-1]]);break;case 181:this.$=en(On(A[x-7]),[A[x-5],A[x-3],A[x-1]]);break;case 182:this.$=ad(en(On(A[x-7]),[A[x-5],A[x-3],A[x-1]]));break;case 183:this.$=en(On(A[x-1]),A[x]);break;case 184:this.$=en("bound",[xS(A[x-1])]);break;case 185:this.$=en(A[x-1],[]);break;case 186:this.$=en(A[x-3],[A[x-1]]);break;case 187:this.$=en(A[x-2]?"notexists":"exists",[CS(A[x])]);break;case 188:case 189:this.$=Fc(A[x-1],{type:"aggregate",aggregation:On(A[x-4]),distinct:!!A[x-2]});break;case 190:this.$=Fc(A[x-2],{type:"aggregate",aggregation:On(A[x-5]),distinct:!!A[x-3],separator:typeof A[x-1]=="string"?A[x-1]:" "});break;case 192:this.$=Cs(A[x]);break;case 193:this.$=gB(A[x-1],On(A[x].substr(1)));break;case 194:this.$=Cs(A[x-2],A[x]);break;case 195:case 204:this.$=Cs(A[x],jC);break;case 196:case 205:this.$=Cs(A[x],$C);break;case 197:case 206:this.$=Cs(On(A[x]),UC);break;case 200:this.$=Cs(A[x].toLowerCase(),mB);break;case 201:this.$=Cs(A[x].substr(1),jC);break;case 202:this.$=Cs(A[x].substr(1),$C);break;case 203:this.$=Cs(A[x].substr(1).toLowerCase(),UC);break;case 207:case 208:this.$=GC(A[x],1);break;case 209:case 210:this.$=GC(A[x],3);break;case 211:this.$=ot.factory.namedNode(sd(A[x]));break;case 213:var cm=A[x].indexOf(":"),cd=A[x].substr(0,cm),um=ot.prefixes[cd];if(!um)throw new Error("Unknown prefix: "+cd);var Zt=sd(um+A[x].substr(cm+1));this.$=ot.factory.namedNode(Zt);break;case 214:if(A[x]=A[x].substr(0,A[x].length-1),!(A[x]in ot.prefixes))throw new Error("Unknown prefix: "+A[x]);var Zt=sd(ot.prefixes[A[x]]);this.$=ot.factory.namedNode(Zt);break;case 215:this.$=od(A[x].replace(/^(_:)/,""));break;case 216:this.$=od();break;case 217:case 218:case 232:this.$=ad(OS(A[x-3],A[x-2],A[x-1]));break;case 230:case 231:this.$=ad(A[x-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:A[x-1].push(A[x]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[A[x]];break;case 308:A[x-3].push(A[x-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:A[x-2].push(A[x-1]);break}},"anonymous"),table:[n(e,t,{3:1,4:2,10:3}),{1:[3]},n(r,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),n([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:o},{6:[2,239]},n(l,[2,411],{216:28,217:29}),n(c,[2,249],{18:30}),n(c,[2,251],{22:31}),n(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:p,139:38,307:43,308:h,323:36},n(c,[2,267],{37:46}),n(_,[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:y,87:p},n(b,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),n(e,[2,248]),n(e,[2,245]),n(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),n(S,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:I,29:O,52:84,53:T,56:85},{19:88,28:I,29:O,52:89,53:T,56:85},n(c,[2,253],{26:90}),{28:[1,91],52:92,53:T},n(E,[2,385],{181:93,182:94,183:95,31:[2,383]}),n(P,[2,263],{34:96}),n(P,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:p,308:h}),n(P,[2,262]),n(V,[2,259]),n(M,[2,143]),n(M,[2,144]),n([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),n(j,[2,211]),n(j,[2,212]),n(j,[2,213]),n(j,[2,214]),{19:98,28:I,29:O,52:99,53:T,56:85},{6:[2,309],99:100,193:[1,101]},n($,[2,311],{101:102,328:[1,103]}),n(G,[2,317],{104:104,328:[1,105]}),n(ge,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:ye,114:110},{29:ye,114:112},{29:ye,114:113},{118:114,123:[1,115],125:116,126:Q},n(se,[2,315]),n(se,[2,316]),n(J,[2,319]),n(J,[2,320]),n(J,[2,321]),n(_,[2,327]),{13:f,16:d,55:118,307:43,308:h},n(c,[2,12]),n(c,[2,13],{44:66,43:119,45:y,87:p}),n(ve,[2,269]),n(ve,[2,15]),{13:f,16:d,44:136,45:re,46:120,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(b,[2,14]),n(b,[2,274]),n(b,[2,271]),n(b,[2,272]),n(e,[2,4]),{13:[1,177]},n(F,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},n(l,[2,410]),n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:d,45:[1,193],55:194,197:X,219:189,220:190,223:191,224:[1,192],307:43,308:h},n(S,[2,419]),n(H,q,{20:196,59:197,69:198,70:k}),n(c,[2,250]),{29:N,57:200},n($,[2,279],{54:202,327:[1,203]}),{29:[2,282]},n(z,K,{23:204,58:205,62:206,63:ae}),n(c,[2,252]),{19:208,28:I,29:O,52:209,53:T,56:85},{29:[1,210]},n(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,145:212,172:221,185:213,187:214,231:rt,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},n(aC,[2,265],{56:85,35:227,52:228,19:229,28:I,29:O,53:T}),n(V,[2,260]),n(z,K,{58:205,62:206,23:230,63:ae}),n(c,[2,268]),{6:[2,45]},n(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:h},n($,[2,312]),{105:233,112:lC,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},n(G,[2,318]),n($,cC,{108:240,133:242,112:uC,132:fC}),n(ge,[2,323]),{112:[1,244]},{112:[2,325]},n(Zr,[2,50]),n(E,Wh,{135:245,136:246,143:247,144:248,31:dC,112:dC}),n(Zr,[2,51]),n(Zr,[2,52]),n(ya,[2,328],{119:249}),{29:ye,114:250},n(ya,[2,56]),{29:ye,114:251},n(_,[2,59]),n(ve,[2,270]),{47:[1,252]},n(pC,[2,150]),n(Hh,[2,428],{240:253}),n(Rc,[2,430],{244:254}),n(Rc,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),n(Cc,[2,440],{252:264}),n($r,[2,448],{260:265}),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,255:154,257:155,264:266,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,255:154,257:155,264:267,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,255:154,257:155,264:268,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n($r,[2,167]),n($r,[2,168]),n($r,[2,169]),n($r,[2,170],{176:269,45:hC,89:mC}),n($r,[2,171]),n($r,[2,172]),n($r,[2,173]),n($r,[2,174]),{13:f,16:d,44:136,45:re,46:272,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:gC,89:yC,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},n(Cn,[2,192],{292:[1,286],293:[1,287]}),n(Cn,[2,195]),n(Cn,[2,196]),n(Cn,[2,197]),n(Cn,[2,198]),n(Cn,[2,199]),n(Cn,[2,200]),{13:f,16:d,44:39,55:40,82:ie,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},n(td,[2,452]),n(td,[2,453]),n(td,[2,454]),n(td,[2,455]),n(td,[2,456]),{279:[2,458]},n(zh,[2,207]),n(zh,[2,208]),n(zh,[2,209]),n(zh,[2,210]),n(Cn,[2,201]),n(Cn,[2,202]),n(Cn,[2,203]),n(Cn,[2,204]),n(Cn,[2,205]),n(Cn,[2,206]),n(e,[2,5]),n(Kh,[2,297],{88:295}),n(Yh,[2,299],{90:296}),{48:[1,297],87:[1,298]},n(Qh,[2,301]),n(F,[2,43]),n(F,[2,82]),n(F,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},n(l,[2,412]),n(ml,[2,123]),n(ml,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),n(xs,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:X,223:312,225:308,226:309,229:_C,307:43,308:h},n(l,i,{215:10,214:314}),n(xs,[2,236]),n(xs,[2,237]),n(Oc,[2,6]),n(bS,[2,287],{60:315,72:316,73:[1,317]}),n(H,[2,286]),{13:f,16:d,45:re,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},n([6,31,63,70,73,81,83,85],[2,20]),n(E,bC,{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},n($,[2,280]),n(Oc,[2,7]),n(H,q,{59:197,69:198,20:332,70:k}),n(z,[2,284]),{64:[1,333]},n(z,K,{58:205,62:206,23:334,63:ae}),n(c,[2,254]),n(E,Wh,{144:248,30:335,143:336,31:[2,257]}),n(c,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:p,139:342,186:339,190:340,195:341,197:gl,307:43,308:h},n(rd,[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:gl,308:h}),n(po,[2,227]),n(po,[2,228]),n(po,[2,229]),{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,172:221,185:351,187:350,200:348,230:347,231:rt,234:349,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},{13:f,16:d,44:39,55:40,87:p,139:342,186:352,190:340,195:341,197:gl,307:43,308:h},n(po,[2,146]),n(po,[2,147]),n(po,[2,148]),n(po,[2,149]),{13:f,16:d,44:354,55:355,82:ie,87:p,172:357,237:356,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:358,312:sr,313:353},n(SS,[2,215]),n(SS,[2,216]),n(z,K,{58:205,62:206,23:359,63:ae}),n(P,[2,264]),n(aC,[2,266]),n(Oc,[2,11]),n(r,[2,308],{6:[2,310]}),n(Zr,[2,313],{102:360,120:361,121:[1,362]}),n(Zr,[2,47]),n(Zr,[2,63]),n(Zr,[2,64]),{13:f,16:d,55:363,307:43,308:h},n(Zr,[2,336]),n(Zr,[2,337]),n(Zr,[2,338]),{109:[1,364]},n(SC,[2,60]),{13:f,16:d,55:365,307:43,308:h},n($,[2,335]),{13:f,16:d,55:366,307:43,308:h},{31:[1,367]},n(yl,[2,341],{137:368}),n(yl,[2,340]),{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,145:369,172:221,185:213,187:214,231:rt,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},{28:[1,370],127:371,128:[1,372]},n(ya,[2,330],{124:373,125:374,126:Q}),n(ya,[2,57]),{44:375,87:p},n(pC,[2,151],{241:376,242:[1,377]}),n(Hh,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,247:380,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{250:[1,381]},n(mr,[2,432]),n(mr,[2,433]),n(mr,[2,434]),n(mr,[2,435]),n(mr,[2,436]),n(mr,[2,437]),{250:[2,439]},n([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke}),n(Cc,[2,162],{261:388,262:389,39:wS,338:ES}),n($r,[2,164]),n($r,[2,165]),n($r,[2,166]),n(hr,[2,95]),n(hr,[2,96]),n(mr,[2,377],{177:392,325:[1,393]}),{48:[1,394]},n(hr,[2,177]),{13:f,16:d,44:136,45:re,46:395,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:396,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:397,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:398,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:399,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,183]),n(hr,[2,98]),n(mr,[2,381],{180:400}),{87:[1,401]},n(hr,[2,185]),{13:f,16:d,44:136,45:re,46:402,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{29:N,57:403},n(Cn,[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:gl,307:43,308:h},n(_a,[2,233]),n(_a,[2,234]),n(_a,[2,235]),n(wC,[2,459],{281:406,325:[1,407]}),n(mr,[2,463],{284:408,325:[1,409]}),n(mr,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:ie,171:413,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},{31:[1,419],89:[1,420]},{29:[1,421]},n(Qh,[2,302]),n(Kh,[2,367],{167:422}),n(Yh,[2,369],{168:423}),{48:[1,424],87:[1,425]},n(Qh,[2,371]),n(ml,[2,122]),n(ml,[2,417]),n(ml,[2,413]),n(ml,[2,414]),n(ml,[2,415]),n(xs,[2,125]),n(xs,[2,127]),n(xs,[2,128]),n(EC,[2,420],{227:426}),n(xs,[2,130]),{13:f,16:d,55:194,197:X,223:427,307:43,308:h},{48:[1,428]},n(ba,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),n(bS,[2,288]),{64:[1,433]},n(H,[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:re,268:ue,269:fe,270:ne,271:me,273:Le,274:B,276:oe,277:Ee,279:Ce,280:xe,283:Oe,285:Re,308:h,346:L,347:U,348:R,349:C,350:D,351:w}),n(vC,[2,293]),n(vS,[2,92]),n(vS,[2,93]),n(vS,[2,94]),{45:hC,89:mC,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:I,29:O,56:85},{19:438,28:I,29:O,56:85},n(_l,[2,355],{149:439}),n(_l,[2,354]),{13:f,16:d,44:215,45:Zh,55:220,82:ie,87:p,89:De,156:440,172:221,185:441,203:442,231:em,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},n(P,[2,19]),n(ba,[2,21]),{13:f,16:d,44:450,45:TC,55:323,65:445,66:446,67:447,68:448,87:p,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},n(Oc,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},n(E,[2,386],{31:[2,388]}),n(rd,[2,102]),n(bl,[2,391],{191:452}),n(E,[2,395],{196:453,198:454}),n(E,[2,108]),n(E,[2,109]),n(rd,[2,103]),n(rd,[2,104]),n(rd,[2,390]),{13:f,16:d,44:215,45:Se,48:[1,455],55:220,82:ie,87:p,89:De,172:221,185:351,187:350,200:456,231:rt,234:349,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},n(tm,[2,424]),n(AC,[2,136]),n(AC,[2,137]),n(TS,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:p,139:342,195:458,197:gl,307:43,308:h},n(_a,[2,219]),n(_a,[2,220]),n(_a,[2,221]),n(_a,[2,222]),n(_a,[2,223]),n(Oc,[2,10]),n(Zr,[2,46]),n(Zr,[2,314]),{112:lC,122:459},n(Zr,[2,62]),n($,cC,{133:242,108:460,112:uC,132:fC}),n(SC,[2,61]),n(Zr,[2,49]),n([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},n(yl,[2,351],{146:463,335:[1,464]}),{29:N,57:465},n(ya,[2,329]),n($,[2,332],{129:466,327:[1,467]}),n(ya,[2,55]),n(ya,[2,331]),{48:[1,468]},n(Hh,[2,429]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(Rc,[2,431]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,243:470,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(Rc,[2,156]),{45:gC,89:yC,179:471},n(Cc,[2,441]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,251:472,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n($r,[2,444],{256:473}),n($r,[2,446],{258:474}),n(mr,[2,442]),n(mr,[2,443]),n($r,[2,449]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,255:154,257:155,259:475,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(mr,[2,450]),n(mr,[2,451]),n(mr,[2,379],{178:476}),n(mr,[2,378]),n([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:d,44:136,45:re,46:482,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{48:[1,483]},{48:[1,484]},n(hr,[2,187]),n(Cn,[2,194]),{13:f,16:d,44:39,55:40,82:ie,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,320:485},{13:f,16:d,39:[1,487],44:136,45:re,46:488,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,282:486,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(wC,[2,460]),{13:f,16:d,44:136,45:re,46:489,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(mr,[2,464]),{13:f,16:d,44:136,45:re,46:490,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(mr,[2,466]),n(F,[2,40]),n(Kh,[2,298]),n(nd,[2,87]),n(nd,[2,88]),n(nd,[2,89]),n(nd,[2,90]),{13:f,16:d,55:492,82:ie,172:493,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,311:494,312:sr,315:491},n(F,[2,41]),n(Yh,[2,300]),n(id,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:ie,171:497,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},{31:[1,498],89:[1,499]},{29:[1,500]},n(Qh,[2,372]),{13:f,16:d,48:[2,422],55:194,197:X,223:312,226:502,228:501,229:_C,307:43,308:h},n(xs,[2,131]),n(xs,[2,126]),n(ba,[2,22]),n(ba,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:re,55:323,67:321,68:322,74:505,75:506,76:IC,77:320,78:xC,79:509,87:p,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},n(vC,[2,294]),n(RC,[2,69]),n(RC,[2,70]),n(H,q,{59:197,69:198,20:511,70:k}),n(z,K,{58:205,62:206,23:512,63:ae}),{29:[2,375],31:[2,71],84:522,85:o,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},n(_l,[2,363],{157:524,335:[1,525]}),n(l,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:p}),n(rm,[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:Zh,55:220,82:ie,87:p,89:De,172:221,185:351,203:536,212:534,231:em,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},n(l,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:p}),n(z,[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:TC,87:p,268:ue,269:fe,270:ne,271:me,273:Le,274:B,276:oe,277:Ee,279:Ce,280:xe,283:Oe,285:Re,308:h,346:L,347:U,348:R,349:C,350:D,351:w}),n(Sl,[2,291]),n(Sl,[2,24]),n(Sl,[2,25]),{13:f,16:d,44:136,45:re,46:539,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(Sl,[2,28]),n(z,K,{58:205,62:206,23:540,63:ae}),n([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),n(bl,[2,107]),{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,172:221,185:351,187:350,199:543,200:544,231:rt,234:349,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},n(CC,[2,132]),n(tm,[2,425]),n(CC,[2,133]),{13:f,16:d,44:354,55:355,82:ie,87:p,172:357,237:356,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:358,312:sr,313:545},n(Zr,[2,54]),n(Zr,[2,48]),n(yl,[2,342]),{13:f,16:d,44:39,55:40,87:p,139:546,307:43,308:h},n(yl,[2,68]),n(E,[2,350],{31:OC,112:OC}),n(Zr,[2,53]),{13:f,16:d,55:547,307:43,308:h},n($,[2,333]),n(ve,[2,16]),n(Hh,[2,152]),n(Rc,[2,154]),n(Rc,[2,157]),n(Cc,[2,159]),n(Cc,[2,160],{262:389,261:548,39:wS,338:ES}),n(Cc,[2,161],{262:389,261:549,39:wS,338:ES}),n($r,[2,163]),{13:f,16:d,44:136,45:re,46:550,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,178]),n(hr,[2,179]),{13:f,16:d,44:136,45:re,46:551,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:552,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:553,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{48:[1,554],272:[1,555]},n(hr,[2,184]),n(hr,[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:X,223:562,307:43,308:h},n(AS,[2,224]),n(AS,[2,225]),n(AS,[2,226]),{31:[1,563],45:PC,94:564},n(F,[2,84]),n(Kh,[2,368]),n(F,[2,85]),n(Yh,[2,370]),n(id,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},n(ba,[2,35],{83:[1,569]}),n(ba,[2,36],{81:[1,570]}),n(bS,[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:re,76:IC,78:xC,87:p,268:ue,269:fe,270:ne,271:me,273:Le,274:B,276:oe,277:Ee,279:Ce,280:xe,283:Oe,285:Re,308:h,346:L,347:U,348:R,349:C,350:D,351:w}),n(Pc,[2,295]),{45:re,77:572},{45:re,77:573},n(Pc,[2,33]),n(Pc,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},n(_l,[2,356]),n(DC,[2,357],{152:578,335:[1,579]}),n(ho,[2,74]),{29:N,57:580},{29:N,57:581},{13:f,16:d,44:39,55:40,87:p,139:582,307:43,308:h},n(FC,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:re,55:323,67:321,68:322,77:320,79:585,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},{45:[1,586]},n(ho,[2,81]),{29:N,57:587},n(_l,[2,73]),n(E,[2,362],{29:mo,31:mo,85:mo,112:mo,159:mo,160:mo,161:mo,163:mo,164:mo}),n(rm,[2,112]),n(Dc,[2,401],{206:588}),n(E,[2,405],{209:589,210:590}),n(E,[2,403]),n(E,[2,404]),n(rm,[2,113]),n(rm,[2,400]),{13:f,16:d,44:215,45:Zh,48:[1,591],55:220,82:ie,87:p,89:De,172:221,185:351,203:536,212:592,231:em,234:535,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},n(tm,[2,426]),n(TS,[2,138]),n(TS,[2,139]),{232:[1,593]},n(Sl,[2,292]),{47:[1,595],48:[1,594]},n(Oc,[2,9]),n(bl,[2,392]),n(bl,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:p,197:gl,308:h}),n(bl,[2,110],{272:[1,598]}),n(nm,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},n(ya,[2,58]),n($r,[2,445]),n($r,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},n(hr,[2,99]),n(mr,[2,382]),n([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),n(hr,[2,188]),n(hr,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:ie,172:493,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,311:494,312:sr,315:611},n(F,[2,42]),n(id,[2,304]),{13:f,16:d,55:414,82:ie,95:612,171:613,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},{31:[1,614],45:PC,94:615},n(xs,[2,129]),n(EC,[2,421]),{82:[1,616]},{82:[1,617]},n(Pc,[2,296]),n(Pc,[2,31]),n(Pc,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},n(E,bC,{155:330,153:618,154:619,29:go,31:go,85:go,112:go,159:go,160:go,161:go,163:go,164:go}),n(DC,[2,358]),n(ho,[2,75]),n(ho,[2,76]),{29:N,57:620},{13:f,16:d,44:39,55:40,87:p,139:621,307:43,308:h},n(FC,[2,366]),n(ho,[2,79]),{13:f,16:d,44:136,45:re,46:622,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(ho,[2,91],{336:[1,623]}),n([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),n(Dc,[2,117]),{13:f,16:d,44:215,45:Zh,55:220,82:ie,87:p,89:De,172:221,185:351,203:536,211:626,212:627,231:em,234:535,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:sr},n(po,[2,134]),n(tm,[2,427]),n(po,[2,135]),n(Sl,[2,26]),{44:628,87:p},n(bl,[2,106]),n(bl,[2,394]),n(E,[2,396]),n(nm,[2,111]),n(nm,[2,398]),{13:f,16:d,44:39,55:40,87:p,139:342,186:629,190:340,195:341,197:gl,307:43,308:h},n(SS,[2,217]),n(E,Wh,{144:248,140:630,143:631,31:[2,343]}),n(hr,[2,97]),n(mr,[2,380]),n(hr,[2,180]),{13:f,16:d,44:136,45:re,46:632,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:633,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:ie,171:637,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},n(LC,[2,305]),n(F,[2,86]),n(id,[2,374]),n(ba,[2,37]),n(ba,[2,38]),n(_l,[2,72]),n(_l,[2,360]),n(ho,[2,77]),{29:N,57:638},{47:[1,639]},{29:[2,376]},n(Dc,[2,402]),n(Dc,[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}),n(Dc,[2,118],{272:[1,641]}),n(im,[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:We,304:qe,305:je,306:He},n(nd,[2,218]),n(id,[2,44]),n(LC,[2,306]),n(ho,[2,78]),{44:651,87:p},n(Dc,[2,116]),n(E,[2,406]),n(im,[2,119]),n(im,[2,408]),n(l,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:p}),n(Sl,[2,27]),n(nm,[2,230]),n(NC,[2,345],{141:653,335:[1,654]}),n(hr,[2,181]),n(hr,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},n(E,Wh,{144:248,142:657,143:658,31:kC,112:kC}),n(NC,[2,346]),n(ho,[2,80]),n(im,[2,231]),n(yl,[2,67]),n(yl,[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(W,Z){if(Z.recoverable)this.trace(W);else{var le=new Error(W);throw le.hash=Z,le}},"parseError"),parse:a(function(W){var Z=this,le=[0],Be=[],it=[null],A=[],Pn=this.table,x="",Os=0,ld=0,lm=0,cm=2,cd=1,um=A.slice.call(arguments,1),Zt=Object.create(this.lexer),Ps={yy:{}};for(var ud in this.yy)Object.prototype.hasOwnProperty.call(this.yy,ud)&&(Ps.yy[ud]=this.yy[ud]);Zt.setInput(W,Ps.yy),Ps.yy.lexer=Zt,Ps.yy.parser=this,typeof Zt.yylloc>"u"&&(Zt.yylloc={});var Mc=Zt.yylloc;A.push(Mc);var Nt=Zt.options&&Zt.options.ranges;typeof Ps.yy.parseError=="function"?this.parseError=Ps.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Kt(Ds){le.length=le.length-2*Ds,it.length=it.length-Ds,A.length=A.length-Ds}a(Kt,"popStack");for(var bt=a(function(){var Ds;return Ds=Zt.lex()||cd,typeof Ds!="number"&&(Ds=Z.symbols_[Ds]||Ds),Ds},"lex"),Rt,zn,Tl,Ti,Qpe,jS,jc={},fm,bo,KC,dm;;){if(Tl=le[le.length-1],this.defaultActions[Tl]?Ti=this.defaultActions[Tl]:((Rt===null||typeof Rt>"u")&&(Rt=bt()),Ti=Pn[Tl]&&Pn[Tl][Rt]),typeof Ti>"u"||!Ti.length||!Ti[0]){var $S="";dm=[];for(fm in Pn[Tl])this.terminals_[fm]&&fm>cm&&dm.push("'"+this.terminals_[fm]+"'");Zt.showPosition?$S="Parse error on line "+(Os+1)+`:
34
+ `)}a(YV,"composeErrorMessage");function QV(n,e,t){let[,r=null]=n.toString().match(/constructor\(([\w, ]+)\)/)||[],i=KV(r,e);return YV(`Cannot inject the dependency ${i} of "${n.name}" constructor. Reason:`,t)}a(QV,"formatErrorCtor");tg.formatErrorCtor=QV});var mP=v(rg=>{"use strict";Object.defineProperty(rg,"__esModule",{value:!0});rg.isDisposable=void 0;function XV(n){return!(typeof n.dispose!="function"||n.dispose.length>0)}a(XV,"isDisposable");rg.isDisposable=XV});var yP=v(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.PostResolutionInterceptors=Nl.PreResolutionInterceptors=void 0;var gP=d1(),ng=class extends gP.default{static{a(this,"PreResolutionInterceptors")}};Nl.PreResolutionInterceptors=ng;var ig=class extends gP.default{static{a(this,"PostResolutionInterceptors")}};Nl.PostResolutionInterceptors=ig;var _1=class{static{a(this,"Interceptors")}constructor(){this.preResolution=new ng,this.postResolution=new ig}};Nl.default=_1});var Ea=v(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.instance=vo.typeInfo=void 0;var JV=(Hm(),hm(Wm)),Dn=c1(),ZV=dP(),sg=Xm(),eq=pP(),Zn=n1(),og=hP(),tq=y1(),rq=Qm(),nq=mP(),iq=yP();vo.typeInfo=new Map;var b1=class n{static{a(this,"InternalDependencyContainer")}constructor(e){this.parent=e,this._registry=new eq.default,this.interceptors=new iq.default,this.disposed=!1,this.disposables=new Set}register(e,t,r={lifecycle:Zn.default.Transient}){this.ensureNotDisposed();let i;if(ZV.isProvider(t)?i=t:i={useClass:t},Dn.isTokenProvider(i)){let s=[e],o=i;for(;o!=null;){let l=o.useToken;if(s.includes(l))throw new Error(`Token registration cycle detected! ${[...s,l].join(" -> ")}`);s.push(l);let c=this._registry.get(l);c&&Dn.isTokenProvider(c.provider)?o=c.provider:o=null}}if((r.lifecycle===Zn.default.Singleton||r.lifecycle==Zn.default.ContainerScoped||r.lifecycle==Zn.default.ResolutionScoped)&&(Dn.isValueProvider(i)||Dn.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Zn.default[r.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:r}),this}registerType(e,t){return this.ensureNotDisposed(),Dn.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(),Dn.isNormalToken(e)){if(Dn.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:Zn.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Zn.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let r=e;return t&&!Dn.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:Zn.default.Singleton})}resolve(e,t=new og.default,r=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&Dn.isNormalToken(e)){if(r)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(sg.isConstructorToken(e)){let s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let r=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&r.push(i),i.callback(e,t);this.interceptors.preResolution.setAll(e,r)}}executePostResolutionInterceptor(e,t,r){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,t,r);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Zn.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===Zn.default.Singleton,i=e.options.lifecycle===Zn.default.ContainerScoped,s=r||i,o;return Dn.isValueProvider(e.provider)?o=e.provider.useValue:Dn.isTokenProvider(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Dn.isClassProvider(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Dn.isFactoryProvider(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===Zn.default.ResolutionScoped&&t.scopedResolutions.set(e,o),o}resolveAll(e,t=new og.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&Dn.isNormalToken(e)){if(r)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let o=i.map(l=>this.resolveRegistration(l,t));return this.executePostResolutionInterceptor(e,o,"All"),o}let s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(r=>!Dn.isValueProvider(r.provider)).map(r=>(r.instance=void 0,r)))}createChildContainer(){this.ensureNotDisposed();let e=new n(this);for(let[t,r]of this._registry.entries())r.some(({options:i})=>i.lifecycle===Zn.default.ContainerScoped)&&e._registry.setAll(t,r.map(i=>i.options.lifecycle===Zn.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,t,r={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:t,options:r})}afterResolution(e,t,r={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:t,options:r})}dispose(){return JV.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let r=t.dispose();r&&e.push(r)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,t){if(e instanceof rq.DelayedConstructor)return e.createProxy(i=>this.resolve(i,t));let r=(()=>{let i=vo.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 nq.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(r,i)=>{try{return sg.isTokenDescriptor(r)?sg.isTransformDescriptor(r)?r.multiple?this.resolve(r.transform).transform(this.resolveAll(r.token,new og.default,r.isOptional),...r.transformArgs):this.resolve(r.transform).transform(this.resolve(r.token,e,r.isOptional),...r.transformArgs):r.multiple?this.resolveAll(r.token,new og.default,r.isOptional):this.resolve(r.token,e,r.isOptional):sg.isTransformDescriptor(r)?this.resolve(r.transform,e).transform(this.resolve(r.token,e),...r.transformArgs):this.resolve(r,e)}catch(s){throw new Error(tq.formatErrorCtor(t,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};vo.instance=new b1;vo.default=vo.instance});var _P=v(w1=>{"use strict";Object.defineProperty(w1,"__esModule",{value:!0});var sq=Fl(),To=Ea(),S1=Xm(),oq=y1();function aq(){return function(n){let e=sq.getParamInfo(n);return class extends n{constructor(...t){super(...t.concat(e.slice(t.length).map((r,i)=>{try{return S1.isTokenDescriptor(r)?S1.isTransformDescriptor(r)?r.multiple?To.instance.resolve(r.transform).transform(To.instance.resolveAll(r.token),...r.transformArgs):To.instance.resolve(r.transform).transform(To.instance.resolve(r.token),...r.transformArgs):r.multiple?To.instance.resolveAll(r.token):To.instance.resolve(r.token):S1.isTransformDescriptor(r)?To.instance.resolve(r.transform).transform(To.instance.resolve(r.token),...r.transformArgs):To.instance.resolve(r)}catch(s){let o=i+t.length;throw new Error(oq.formatErrorCtor(n,o,s))}})))}}}}a(aq,"autoInjectable");w1.default=aq});var bP=v(E1=>{"use strict";Object.defineProperty(E1,"__esModule",{value:!0});var lq=Fl();function cq(n,e){let t={token:n,multiple:!1,isOptional:e&&e.isOptional};return lq.defineInjectionTokenMetadata(t)}a(cq,"inject");E1.default=cq});var ag=v(v1=>{"use strict";Object.defineProperty(v1,"__esModule",{value:!0});var uq=Fl(),fq=Ea(),SP=Ea();function dq(n){return function(e){fq.typeInfo.set(e,uq.getParamInfo(e)),n&&n.token&&(Array.isArray(n.token)?n.token.forEach(t=>{SP.instance.register(t,e)}):SP.instance.register(n.token,e))}}a(dq,"injectable");v1.default=dq});var wP=v(T1=>{"use strict";Object.defineProperty(T1,"__esModule",{value:!0});var pq=(Hm(),hm(Wm)),hq=Ea();function mq(n=[]){return function(e){return n.forEach(t=>{var{token:r,options:i}=t,s=pq.__rest(t,["token","options"]);return hq.instance.register(r,s,i)}),e}}a(mq,"registry");T1.default=mq});var EP=v(A1=>{"use strict";Object.defineProperty(A1,"__esModule",{value:!0});var gq=ag(),yq=Ea();function _q(){return function(n){gq.default()(n),yq.instance.registerSingleton(n)}}a(_q,"singleton");A1.default=_q});var vP=v(I1=>{"use strict";Object.defineProperty(I1,"__esModule",{value:!0});var bq=Fl();function Sq(n,e){let t={token:n,multiple:!0,isOptional:e&&e.isOptional};return bq.defineInjectionTokenMetadata(t)}a(Sq,"injectAll");I1.default=Sq});var TP=v(x1=>{"use strict";Object.defineProperty(x1,"__esModule",{value:!0});var wq=Fl();function Eq(n,e,...t){let r={token:n,multiple:!0,transform:e,transformArgs:t};return wq.defineInjectionTokenMetadata(r)}a(Eq,"injectAllWithTransform");x1.default=Eq});var AP=v(R1=>{"use strict";Object.defineProperty(R1,"__esModule",{value:!0});var vq=Fl();function Tq(n,e,...t){return vq.defineInjectionTokenMetadata(n,{transformToken:e,args:t})}a(Tq,"injectWithTransform");R1.default=Tq});var IP=v(C1=>{"use strict";Object.defineProperty(C1,"__esModule",{value:!0});var Aq=ag(),Iq=Ea();function xq(n,e){return function(t){Aq.default()(t),Iq.instance.register(e||t,t,{lifecycle:n})}}a(xq,"scoped");C1.default=xq});var xP=v(Gi=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});var Rq=_P();Object.defineProperty(Gi,"autoInjectable",{enumerable:!0,get:a(function(){return Rq.default},"get")});var Cq=bP();Object.defineProperty(Gi,"inject",{enumerable:!0,get:a(function(){return Cq.default},"get")});var Oq=ag();Object.defineProperty(Gi,"injectable",{enumerable:!0,get:a(function(){return Oq.default},"get")});var Pq=wP();Object.defineProperty(Gi,"registry",{enumerable:!0,get:a(function(){return Pq.default},"get")});var Dq=EP();Object.defineProperty(Gi,"singleton",{enumerable:!0,get:a(function(){return Dq.default},"get")});var Fq=vP();Object.defineProperty(Gi,"injectAll",{enumerable:!0,get:a(function(){return Fq.default},"get")});var Lq=TP();Object.defineProperty(Gi,"injectAllWithTransform",{enumerable:!0,get:a(function(){return Lq.default},"get")});var Nq=AP();Object.defineProperty(Gi,"injectWithTransform",{enumerable:!0,get:a(function(){return Nq.default},"get")});var kq=IP();Object.defineProperty(Gi,"scoped",{enumerable:!0,get:a(function(){return kq.default},"get")})});var RP=v(O1=>{"use strict";Object.defineProperty(O1,"__esModule",{value:!0});function Mq(n){let e;return t=>(e==null&&(e=n(t)),e)}a(Mq,"instanceCachingFactory");O1.default=Mq});var CP=v(P1=>{"use strict";Object.defineProperty(P1,"__esModule",{value:!0});function jq(n){let e=new WeakMap;return t=>{let r=e.get(t);return r==null&&(r=n(t),e.set(t,r)),r}}a(jq,"instancePerContainerCachingFactory");P1.default=jq});var OP=v(D1=>{"use strict";Object.defineProperty(D1,"__esModule",{value:!0});function $q(n,e,t,r=!0){let i,s;return o=>{let l=n(o);return(!r||s!==l)&&((s=l)?i=o.resolve(e):i=o.resolve(t)),i}}a($q,"predicateAwareClassFactory");D1.default=$q});var PP=v(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});var Uq=RP();Object.defineProperty(Dd,"instanceCachingFactory",{enumerable:!0,get:a(function(){return Uq.default},"get")});var Bq=CP();Object.defineProperty(Dd,"instancePerContainerCachingFactory",{enumerable:!0,get:a(function(){return Bq.default},"get")});var Vq=OP();Object.defineProperty(Dd,"predicateAwareClassFactory",{enumerable:!0,get:a(function(){return Vq.default},"get")})});var ut=v(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});var F1=(Hm(),hm(Wm));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 qq=fP();Object.defineProperty(va,"Lifecycle",{enumerable:!0,get:a(function(){return qq.Lifecycle},"get")});F1.__exportStar(xP(),va);F1.__exportStar(PP(),va);F1.__exportStar(c1(),va);var Gq=Qm();Object.defineProperty(va,"delay",{enumerable:!0,get:a(function(){return Gq.delay},"get")});var Wq=Ea();Object.defineProperty(va,"container",{enumerable:!0,get:a(function(){return Wq.instance},"get")})});var Fd=v(lg=>{"use strict";Object.defineProperty(lg,"__esModule",{value:!0});lg.NullLogger=void 0;lg.NullLogger={debug(){},info(){},warn(){},error(){}}});var Vc=v(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.bytesToBase64=FP;Bc.base64ToBytes=LP;Bc.base64ToUtf8=Hq;Bc.utf8ToBase64=zq;var DP=32768;function FP(n){let e="";for(let t=0;t<n.length;t+=DP)e+=String.fromCharCode(...n.subarray(t,t+DP));return btoa(e)}a(FP,"bytesToBase64");function LP(n){let e=n.replace(/\s/g,""),t=e.length%4,r=t===2||t===3?e+"=".repeat(4-t):e,i=atob(r),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}a(LP,"base64ToBytes");function Hq(n){return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(LP(n))}a(Hq,"base64ToUtf8");function zq(n){return FP(new TextEncoder().encode(n))}a(zq,"utf8ToBase64")});var Ld=v(L1=>{"use strict";Object.defineProperty(L1,"__esModule",{value:!0});L1.iriToObsidianName=Yq;var Kq=Vt();function Yq(n){let e=Kq.Namespace.fromTermIRI(n);if(e)return`${e.namespace.prefix}__${e.localName}`;let t=n.match(/\/([^/]+)\.md$/);return t?t[1]:null}a(Yq,"iriToObsidianName")});var NP=v(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.registerUniversalDefaultLoader=Qq;Ta.clearUniversalDefaultLoader=Xq;Ta.clearUniversalDefault=Jq;Ta.loadUniversalDefault=Zq;Ta.mergePropertyDefaults=eG;Ta.mergeInheritanceRules=tG;var cg=null,Ao,Nd=!1;function Qq(n){cg=n,Ao=void 0,Nd=!1}a(Qq,"registerUniversalDefaultLoader");function Xq(){cg=null,Ao=void 0,Nd=!1}a(Xq,"clearUniversalDefaultLoader");function Jq(){Ao=void 0,Nd=!1}a(Jq,"clearUniversalDefault");async function Zq(){if(Ao!==void 0)return Ao;if(!cg)return Ao=null,null;try{Ao=await cg()??null}catch(n){Nd||(console.warn("[UniversalDefaultTemplateResolver] loader threw, falling back to legacy primitives:",n),Nd=!0),Ao=null}return Ao}a(Zq,"loadUniversalDefault");function eG(n,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.propertyName);o?(r.push(o),i.add(o.propertyName)):r.push(s)}for(let s of e)i.has(s.propertyName)||r.push(s);return r}a(eG,"mergePropertyDefaults");function tG(n,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let r=[],i=new Set;for(let s of n){let o=t.get(s.targetPropertyName);o?(r.push(o),i.add(o.targetPropertyName)):r.push(s)}for(let s of e)i.has(s.targetPropertyName)||r.push(s);return r}a(tG,"mergeInheritanceRules")});var N1=v((jye,kP)=>{var qc=class{static{a(this,"Wildcard")}constructor(){return rG||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(qc.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(qc.prototype,"termType",{enumerable:!0,value:"Wildcard"});var rG=new qc;kP.exports.Wildcard=qc});var jP=v((Uye,MP)=>{var nG=(function(){var n=a(function(Y,W,Z,le){for(Z=Z||{},le=Y.length;le--;Z[Y[le]]=W);return Z},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],r=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],l=[13,16,45,197,224,229,308],c=[28,29,53],u=[28,53],f=[1,42],d=[1,45],p=[1,41],h=[1,44],_=[123,126],y=[1,67],b=[39,45,87],S=[13,16,45,197,224,308],I=[1,87],O=[2,281],T=[1,86],E=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],P=[6,28,29,53,63,70,73,81,83,85],V=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],M=[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],j=[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],$=[13,16,308],G=[112,132,327,334],ge=[13,16,112,132,308],ye=[1,111],Q=[1,117],se=[112,132,327,328,334],J=[13,16,112,132,308,328],ve=[28,29,45,53,87],re=[1,138],ie=[1,151],he=[1,128],Ue=[1,127],ce=[1,129],ue=[1,140],fe=[1,141],ne=[1,142],me=[1,143],Le=[1,144],B=[1,145],oe=[1,147],Ee=[1,148],Ce=[2,457],xe=[1,158],Oe=[1,159],Re=[1,160],Ae=[1,152],ee=[1,153],_e=[1,156],Te=[1,171],Pe=[1,172],Me=[1,173],Ne=[1,174],Ge=[1,175],ke=[1,176],We=[1,167],qe=[1,168],je=[1,169],He=[1,170],m=[1,157],L=[1,166],U=[1,161],R=[1,162],C=[1,163],D=[1,164],w=[1,165],F=[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],X=[1,195],H=[6,31,73,81,83,85],q=[2,285],k=[1,199],N=[1,201],z=[6,31,70,73,81,83,85],K=[2,283],ae=[1,207],Se=[1,218],De=[1,223],rt=[1,219],Jr=[1,225],Cr=[1,226],or=[1,224],aC=[6,63,70,73,81,83,85],lC=[1,236],cC=[2,334],uC=[1,243],fC=[1,241],Zr=[6,193],Wh=[2,349],dC=[2,339],ya=[28,128],pC=[47,48,193,272],Hh=[47,48,193,242,272],Rc=[47,48,193,242,246,272],Cc=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],$r=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],hC=[1,271],mC=[1,270],hr=[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],gC=[1,281],yC=[1,280],Cn=[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],td=[45,89],zh=[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],Kh=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Yh=[31,89],Qh=[48,87],ml=[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],xs=[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],_C=[1,313],Oc=[6,85],bS=[6,31,81,83,85],bC=[2,361],fo=[2,353],gl=[1,343],rd=[31,112,335],po=[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],SS=[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],SC=[6,109,193],yl=[31,112],mr=[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],wS=[1,390],ES=[1,391],_a=[13,16,87,197,308,314],wC=[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],Xh=[1,417],Jh=[1,418],EC=[13,16,48,197,229,308],ba=[6,31,85],vC=[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],vS=[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],_l=[29,31,85,112,159,160,161,163,164],Zh=[1,443],em=[1,444],TC=[1,449],bl=[31,112,193,232,318,335],tm=[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],AC=[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],TS=[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],nd=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],id=[31,45],IC=[1,507],xC=[1,508],RC=[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],rm=[29,31,85,112,159,160,161,163,164,335],Sl=[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],CC=[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],OC=[2,352],AS=[13,16,197,308,314],PC=[1,565],Pc=[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],DC=[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],ho=[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],FC=[13,16,87,308],mo=[2,364],Dc=[29,31,85,112,159,160,161,163,164,193,232,318,335],nm=[31,112,193,232,272,318,335],go=[2,359],LC=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],im=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],NC=[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],kC=[2,347],IS={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(W,Z,le,Be,it,A,Pn){var x=A.length-1;switch(it){case 1:if(A[x-1]=A[x-1]||{},ot.base&&(A[x-1].base=ot.base),ot.base="",A[x-1].prefixes=ot.prefixes,ot.prefixes=null,ot.pathOnly){if(A[x-1].type==="path"||"termType"in A[x-1])return A[x-1];throw new Error("Received full SPARQL query in path only mode")}else if(A[x-1].type==="path"||"termType"in A[x-1])throw new Error("Received only path in full SPARQL mode");if(A[x-1].type==="update"){let Nt={};for(let Kt of A[x-1].updates)if(Kt.updateType==="insert"){let bt={};for(let Rt of Kt.insert)if(Rt.type==="bgp"||Rt.type==="graph")for(let zn of Rt.triples)zn.subject.termType==="BlankNode"&&(bt[zn.subject.value]=!0),zn.predicate.termType==="BlankNode"&&(bt[zn.predicate.value]=!0),zn.object.termType==="BlankNode"&&(bt[zn.object.value]=!0);for(let Rt of Object.keys(bt)){if(Nt[Rt])throw new Error("Detected reuse blank node across different INSERT DATA clauses");Nt[Rt]=!0}}}return A[x-1];case 2:this.$={...A[x-1],...A[x],type:"query"};break;case 4:ot.base=sd(A[x]);break;case 5:ot.prefixes||(ot.prefixes={}),A[x-1]=A[x-1].substr(0,A[x-1].length-1),A[x]=sd(A[x]),ot.prefixes[A[x-1]]=A[x];break;case 6:this.$={...A[x-3],...vl(A[x-2]),...A[x-1],...A[x]};break;case 7:if(!ot.skipValidation&&(LS(A[x-3].variables.map(Kt=>FS(Kt.expression))).some(Kt=>Kt.aggregation==="count"&&!(Kt.expression instanceof sm))||A[x].group)){for(let Kt of A[x-3].variables)if(Kt.termType==="Variable"){if(!A[x].group||!A[x].group.map(bt=>kc(bt)).includes(kc(Kt)))throw Error("Projection of ungrouped variable (?"+kc(Kt)+")")}else if(FS(Kt.expression).length===0){let bt=EB(Kt.expression);for(let Rt of bt)if(!A[x].group||!A[x].group.map||!A[x].group.map(zn=>kc(zn)).includes(kc(Rt)))throw Error("Use of ungrouped variable in projection of operation (?"+kc(Rt)+")")}}let Ps=A[x-1].where.filter(Nt=>Nt.type==="query");if(Ps.length>0){let Nt=A[x-3].variables.filter(bt=>bt.variable&&bt.variable.value).map(bt=>bt.variable.value),Kt=LS(Ps.map(bt=>bt.variables)).map(bt=>bt.value||bt.variable.value);for(let bt of Nt)if(Kt.indexOf(bt)>=0)throw Error("Target id of 'AS' (?"+bt+") already used in subquery")}this.$=ar(A[x-3],vl(A[x-2]),A[x-1],A[x]);break;case 8:this.$=ar({queryType:"CONSTRUCT",template:A[x-3]},vl(A[x-2]),A[x-1],A[x]);break;case 9:this.$=ar({queryType:"CONSTRUCT",template:A[x-2]=A[x-2]?A[x-2].triples:[]},vl(A[x-5]),{where:[{type:"bgp",triples:El([],A[x-2])}]},A[x]);break;case 10:this.$=ar({queryType:"DESCRIBE",variables:A[x-3]==="*"?[new sm]:A[x-3]},vl(A[x-2]),A[x-1],A[x]);break;case 11:this.$=ar({queryType:"ASK"},vl(A[x-2]),A[x-1],A[x]);break;case 12:this.$=ar(A[x-1],{variables:[new sm]});break;case 13:let ud=A[x].map(Nt=>Nt.value||Nt.variable.value),Mc=vB(ud);if(Mc.length>0)throw Error("Two or more of the resulting columns have the same name (?"+Mc[0]+")");this.$=ar(A[x-1],{variables:A[x]});break;case 14:this.$=ar({queryType:"SELECT"},A[x]&&(A[x-1]=On(A[x]),A[x]={},A[x][A[x-1]]=!0,A[x]));break;case 16:case 27:this.$=Fc(A[x-3],{variable:A[x-1]});break;case 17:case 18:this.$=ar(A[x-3],A[x-2],A[x-1],A[x],{type:"query"});break;case 19:case 58:this.$={iri:A[x],named:!!A[x-1]};break;case 20:this.$={where:A[x].patterns};break;case 21:this.$=ar(A[x-1],A[x]);break;case 22:this.$=ar(A[x-2],A[x-1],A[x]);break;case 23:this.$={group:A[x]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Fc(A[x]);break;case 26:this.$=Fc(A[x-1]);break;case 29:this.$={having:A[x]};break;case 30:this.$={order:A[x]};break;case 32:this.$=Fc(A[x],{descending:!0});break;case 35:this.$={limit:Nc(A[x])};break;case 36:this.$={offset:Nc(A[x])};break;case 37:this.$={limit:Nc(A[x-2]),offset:Nc(A[x])};break;case 38:this.$={limit:Nc(A[x]),offset:Nc(A[x-2])};break;case 39:case 43:this.$={type:"values",values:A[x]};break;case 40:case 84:this.$=A[x-1].map(Nt=>({[A[x-3]]:Nt}));break;case 41:case 85:this.$=A[x-1].map(()=>({}));break;case 42:case 86:var Os=A[x-4].length;A[x-4]=A[x-4].map(xS),this.$=A[x-1].map(function(Nt){if(Nt.length!==Os)throw Error("Inconsistent VALUES length");for(var Kt={},bt=0;bt<Os;bt++)Kt["?"+A[x-4][bt].value]=Nt[bt];return Kt});break;case 44:case 65:case 100:case 126:case 175:this.$=A[x-1];break;case 45:this.$={type:"update",updates:yo(A[x-2],A[x-1])};break;case 46:this.$=ar({type:"load",silent:!!A[x-2],source:A[x-1]},A[x]&&{destination:A[x]});break;case 47:this.$={type:On(A[x-2]),silent:!!A[x-1],graph:A[x]};break;case 48:this.$={type:On(A[x-4]),silent:!!A[x-3],source:A[x-2],destination:A[x]};break;case 49:this.$={type:"create",silent:!!A[x-2],graph:{type:"graph",name:A[x]}};break;case 50:this.$={updateType:"insert",insert:zC(A[x])};break;case 51:this.$={updateType:"delete",delete:MS(zC(A[x]))};break;case 52:this.$={updateType:"deletewhere",delete:MS(A[x])};break;case 53:this.$={updateType:"insertdelete",...A[x-4],...A[x-3],...vl(A[x-2],"using"),where:A[x].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=A[x];break;case 55:this.$={delete:MS(A[x-1]),insert:A[x]||[]};break;case 56:this.$={delete:[],insert:A[x]};break;case 59:this.$={graph:A[x]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:A[x]};break;case 64:this.$={[On(A[x])]:!0};break;case 66:this.$=A[x-1]?Rs(A[x],[A[x-1]]):Rs(A[x]);break;case 67:var ld=ar(A[x-3]||{triples:[]},{type:"graph",name:A[x-5]});this.$=A[x]?[ld,A[x]]:[ld];break;case 68:case 73:this.$={type:"bgp",triples:Rs(A[x-2],[A[x-1]])};break;case 69:this.$={type:"group",patterns:[A[x-1]]};break;case 70:for(let Nt of A[x-1].filter(Kt=>Kt.type==="bind")){let Kt=A[x-1].indexOf(Nt),bt=new Set;for(let Rt of A[x-1].slice(0,Kt))(Rt.type==="group"||Rt.type==="bgp")&&WC(Rt).forEach(zn=>bt.add(zn));if(bt.has(Nt.variable.value))throw Error("Variable used to bind is already bound (?"+Nt.variable.value+")")}this.$={type:"group",patterns:A[x-1]};break;case 71:this.$=A[x-1]?Rs([A[x-1]],A[x]):Rs(A[x]);break;case 72:this.$=A[x]?[A[x-2],A[x]]:A[x-2];break;case 75:this.$=ar(A[x],{type:"optional"});break;case 76:this.$=ar(A[x],{type:"minus"});break;case 77:this.$=ar(A[x],{type:"graph",name:A[x-1]});break;case 78:this.$=ar(A[x],{type:"service",name:A[x-1],silent:!!A[x-2]});break;case 79:this.$={type:"filter",expression:A[x]};break;case 80:this.$={type:"bind",variable:A[x-1],expression:A[x-3]};break;case 89:this.$=ad(A[x]);break;case 90:this.$=void 0;break;case 91:this.$=A[x-1].length?{type:"union",patterns:Rs(A[x-1].map(CS),[CS(A[x])])}:A[x];break;case 95:this.$={...A[x],function:A[x-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:yo(A[x-2],A[x-1]),distinct:!!A[x-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.$=yo(A[x-2],A[x-1]);break;case 101:this.$=Rs(A[x-2],[A[x-1]]);break;case 102:case 112:this.$=kS(A[x].map(Nt=>ar(_o(A[x-1]),Nt)));break;case 103:this.$=kS(El(A[x].map(Nt=>ar(_o(A[x-1].entity),Nt)),A[x-1].triples));break;case 105:this.$=Rs([A[x-1]],A[x]);break;case 106:this.$=Rs(A[x]);break;case 107:this.$=DS(A[x-1],A[x]);break;case 109:case 237:this.$=ot.factory.namedNode(dB);break;case 110:case 118:this.$=yo(A[x-1],A[x]);break;case 111:this.$=A[x]?{annotation:A[x],object:A[x-1]}:A[x-1];break;case 113:this.$=A[x]?kS(El(A[x].map(Nt=>ar(_o(A[x-1].entity),Nt)),A[x-1].triples)):A[x-1].triples;break;case 114:this.$=DS(...A[x-1],A[x]);break;case 116:this.$=DS(...A[x]);break;case 117:case 159:case 163:this.$=[A[x-1],A[x]];break;case 119:this.$=A[x]?{object:A[x-1],annotation:A[x]}:A[x-1];break;case 120:this.$=A[x-1].length?Lc("|",yo(A[x-1],A[x])):A[x];break;case 121:this.$=A[x-1].length?Lc("/",yo(A[x-1],A[x])):A[x];break;case 122:this.$=A[x]?Lc(A[x],[A[x-1]]):A[x-1];break;case 123:this.$=A[x-1]?Lc(A[x-1],[A[x]]):A[x];break;case 125:case 131:this.$=Lc(A[x-1],[A[x]]);break;case 129:this.$=Lc("|",yo(A[x-2],A[x-1]));break;case 132:case 134:this.$=SB(A[x-1]);break;case 133:case 135:this.$=wB(A[x-1]);break;case 140:this.$={entity:A[x],triples:[]};break;case 145:this.$=xS(A[x]);break;case 149:this.$=ot.factory.namedNode(MC);break;case 151:case 153:case 158:case 162:this.$=RS(A[x-1],A[x]);break;case 152:this.$=["||",A[x]];break;case 154:this.$=["&&",A[x]];break;case 156:this.$=en(A[x-1],[A[x-2],A[x]]);break;case 157:this.$=en(A[x-2]?"notin":"in",[A[x-3],A[x]]);break;case 160:this.$=["+",RS(A[x-1],A[x])];break;case 161:var lm=Cs(A[x-1].value.replace("-",""),A[x-1].datatype);this.$=["-",RS(lm,A[x])];break;case 164:this.$=en("UPLUS",[A[x]]);break;case 165:this.$=en(A[x-1],[A[x]]);break;case 166:this.$=en("UMINUS",[A[x]]);break;case 177:this.$=en(On(A[x-1]));break;case 178:this.$=en(On(A[x-3]),[A[x-1]]);break;case 179:this.$=ad(en(On(A[x-3]),[A[x-1]]));break;case 180:this.$=en(On(A[x-5]),[A[x-3],A[x-1]]);break;case 181:this.$=en(On(A[x-7]),[A[x-5],A[x-3],A[x-1]]);break;case 182:this.$=ad(en(On(A[x-7]),[A[x-5],A[x-3],A[x-1]]));break;case 183:this.$=en(On(A[x-1]),A[x]);break;case 184:this.$=en("bound",[xS(A[x-1])]);break;case 185:this.$=en(A[x-1],[]);break;case 186:this.$=en(A[x-3],[A[x-1]]);break;case 187:this.$=en(A[x-2]?"notexists":"exists",[CS(A[x])]);break;case 188:case 189:this.$=Fc(A[x-1],{type:"aggregate",aggregation:On(A[x-4]),distinct:!!A[x-2]});break;case 190:this.$=Fc(A[x-2],{type:"aggregate",aggregation:On(A[x-5]),distinct:!!A[x-3],separator:typeof A[x-1]=="string"?A[x-1]:" "});break;case 192:this.$=Cs(A[x]);break;case 193:this.$=gB(A[x-1],On(A[x].substr(1)));break;case 194:this.$=Cs(A[x-2],A[x]);break;case 195:case 204:this.$=Cs(A[x],jC);break;case 196:case 205:this.$=Cs(A[x],$C);break;case 197:case 206:this.$=Cs(On(A[x]),UC);break;case 200:this.$=Cs(A[x].toLowerCase(),mB);break;case 201:this.$=Cs(A[x].substr(1),jC);break;case 202:this.$=Cs(A[x].substr(1),$C);break;case 203:this.$=Cs(A[x].substr(1).toLowerCase(),UC);break;case 207:case 208:this.$=GC(A[x],1);break;case 209:case 210:this.$=GC(A[x],3);break;case 211:this.$=ot.factory.namedNode(sd(A[x]));break;case 213:var cm=A[x].indexOf(":"),cd=A[x].substr(0,cm),um=ot.prefixes[cd];if(!um)throw new Error("Unknown prefix: "+cd);var Zt=sd(um+A[x].substr(cm+1));this.$=ot.factory.namedNode(Zt);break;case 214:if(A[x]=A[x].substr(0,A[x].length-1),!(A[x]in ot.prefixes))throw new Error("Unknown prefix: "+A[x]);var Zt=sd(ot.prefixes[A[x]]);this.$=ot.factory.namedNode(Zt);break;case 215:this.$=od(A[x].replace(/^(_:)/,""));break;case 216:this.$=od();break;case 217:case 218:case 232:this.$=ad(OS(A[x-3],A[x-2],A[x-1]));break;case 230:case 231:this.$=ad(A[x-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:A[x-1].push(A[x]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[A[x]];break;case 308:A[x-3].push(A[x-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:A[x-2].push(A[x-1]);break}},"anonymous"),table:[n(e,t,{3:1,4:2,10:3}),{1:[3]},n(r,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),n([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:o},{6:[2,239]},n(l,[2,411],{216:28,217:29}),n(c,[2,249],{18:30}),n(c,[2,251],{22:31}),n(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:p,139:38,307:43,308:h,323:36},n(c,[2,267],{37:46}),n(_,[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:y,87:p},n(b,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),n(e,[2,248]),n(e,[2,245]),n(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),n(S,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:I,29:O,52:84,53:T,56:85},{19:88,28:I,29:O,52:89,53:T,56:85},n(c,[2,253],{26:90}),{28:[1,91],52:92,53:T},n(E,[2,385],{181:93,182:94,183:95,31:[2,383]}),n(P,[2,263],{34:96}),n(P,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:p,308:h}),n(P,[2,262]),n(V,[2,259]),n(M,[2,143]),n(M,[2,144]),n([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),n(j,[2,211]),n(j,[2,212]),n(j,[2,213]),n(j,[2,214]),{19:98,28:I,29:O,52:99,53:T,56:85},{6:[2,309],99:100,193:[1,101]},n($,[2,311],{101:102,328:[1,103]}),n(G,[2,317],{104:104,328:[1,105]}),n(ge,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:ye,114:110},{29:ye,114:112},{29:ye,114:113},{118:114,123:[1,115],125:116,126:Q},n(se,[2,315]),n(se,[2,316]),n(J,[2,319]),n(J,[2,320]),n(J,[2,321]),n(_,[2,327]),{13:f,16:d,55:118,307:43,308:h},n(c,[2,12]),n(c,[2,13],{44:66,43:119,45:y,87:p}),n(ve,[2,269]),n(ve,[2,15]),{13:f,16:d,44:136,45:re,46:120,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(b,[2,14]),n(b,[2,274]),n(b,[2,271]),n(b,[2,272]),n(e,[2,4]),{13:[1,177]},n(F,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},n(l,[2,410]),n([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:d,45:[1,193],55:194,197:X,219:189,220:190,223:191,224:[1,192],307:43,308:h},n(S,[2,419]),n(H,q,{20:196,59:197,69:198,70:k}),n(c,[2,250]),{29:N,57:200},n($,[2,279],{54:202,327:[1,203]}),{29:[2,282]},n(z,K,{23:204,58:205,62:206,63:ae}),n(c,[2,252]),{19:208,28:I,29:O,52:209,53:T,56:85},{29:[1,210]},n(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,145:212,172:221,185:213,187:214,231:rt,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},n(aC,[2,265],{56:85,35:227,52:228,19:229,28:I,29:O,53:T}),n(V,[2,260]),n(z,K,{58:205,62:206,23:230,63:ae}),n(c,[2,268]),{6:[2,45]},n(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:h},n($,[2,312]),{105:233,112:lC,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},n(G,[2,318]),n($,cC,{108:240,133:242,112:uC,132:fC}),n(ge,[2,323]),{112:[1,244]},{112:[2,325]},n(Zr,[2,50]),n(E,Wh,{135:245,136:246,143:247,144:248,31:dC,112:dC}),n(Zr,[2,51]),n(Zr,[2,52]),n(ya,[2,328],{119:249}),{29:ye,114:250},n(ya,[2,56]),{29:ye,114:251},n(_,[2,59]),n(ve,[2,270]),{47:[1,252]},n(pC,[2,150]),n(Hh,[2,428],{240:253}),n(Rc,[2,430],{244:254}),n(Rc,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),n(Cc,[2,440],{252:264}),n($r,[2,448],{260:265}),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,255:154,257:155,264:266,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,255:154,257:155,264:267,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,255:154,257:155,264:268,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n($r,[2,167]),n($r,[2,168]),n($r,[2,169]),n($r,[2,170],{176:269,45:hC,89:mC}),n($r,[2,171]),n($r,[2,172]),n($r,[2,173]),n($r,[2,174]),{13:f,16:d,44:136,45:re,46:272,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:gC,89:yC,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},n(Cn,[2,192],{292:[1,286],293:[1,287]}),n(Cn,[2,195]),n(Cn,[2,196]),n(Cn,[2,197]),n(Cn,[2,198]),n(Cn,[2,199]),n(Cn,[2,200]),{13:f,16:d,44:39,55:40,82:ie,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},n(td,[2,452]),n(td,[2,453]),n(td,[2,454]),n(td,[2,455]),n(td,[2,456]),{279:[2,458]},n(zh,[2,207]),n(zh,[2,208]),n(zh,[2,209]),n(zh,[2,210]),n(Cn,[2,201]),n(Cn,[2,202]),n(Cn,[2,203]),n(Cn,[2,204]),n(Cn,[2,205]),n(Cn,[2,206]),n(e,[2,5]),n(Kh,[2,297],{88:295}),n(Yh,[2,299],{90:296}),{48:[1,297],87:[1,298]},n(Qh,[2,301]),n(F,[2,43]),n(F,[2,82]),n(F,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},n(l,[2,412]),n(ml,[2,123]),n(ml,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),n(xs,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:X,223:312,225:308,226:309,229:_C,307:43,308:h},n(l,i,{215:10,214:314}),n(xs,[2,236]),n(xs,[2,237]),n(Oc,[2,6]),n(bS,[2,287],{60:315,72:316,73:[1,317]}),n(H,[2,286]),{13:f,16:d,45:re,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},n([6,31,63,70,73,81,83,85],[2,20]),n(E,bC,{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},n($,[2,280]),n(Oc,[2,7]),n(H,q,{59:197,69:198,20:332,70:k}),n(z,[2,284]),{64:[1,333]},n(z,K,{58:205,62:206,23:334,63:ae}),n(c,[2,254]),n(E,Wh,{144:248,30:335,143:336,31:[2,257]}),n(c,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:p,139:342,186:339,190:340,195:341,197:gl,307:43,308:h},n(rd,[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:gl,308:h}),n(po,[2,227]),n(po,[2,228]),n(po,[2,229]),{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,172:221,185:351,187:350,200:348,230:347,231:rt,234:349,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},{13:f,16:d,44:39,55:40,87:p,139:342,186:352,190:340,195:341,197:gl,307:43,308:h},n(po,[2,146]),n(po,[2,147]),n(po,[2,148]),n(po,[2,149]),{13:f,16:d,44:354,55:355,82:ie,87:p,172:357,237:356,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:358,312:or,313:353},n(SS,[2,215]),n(SS,[2,216]),n(z,K,{58:205,62:206,23:359,63:ae}),n(P,[2,264]),n(aC,[2,266]),n(Oc,[2,11]),n(r,[2,308],{6:[2,310]}),n(Zr,[2,313],{102:360,120:361,121:[1,362]}),n(Zr,[2,47]),n(Zr,[2,63]),n(Zr,[2,64]),{13:f,16:d,55:363,307:43,308:h},n(Zr,[2,336]),n(Zr,[2,337]),n(Zr,[2,338]),{109:[1,364]},n(SC,[2,60]),{13:f,16:d,55:365,307:43,308:h},n($,[2,335]),{13:f,16:d,55:366,307:43,308:h},{31:[1,367]},n(yl,[2,341],{137:368}),n(yl,[2,340]),{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,145:369,172:221,185:213,187:214,231:rt,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},{28:[1,370],127:371,128:[1,372]},n(ya,[2,330],{124:373,125:374,126:Q}),n(ya,[2,57]),{44:375,87:p},n(pC,[2,151],{241:376,242:[1,377]}),n(Hh,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,247:380,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{250:[1,381]},n(mr,[2,432]),n(mr,[2,433]),n(mr,[2,434]),n(mr,[2,435]),n(mr,[2,436]),n(mr,[2,437]),{250:[2,439]},n([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke}),n(Cc,[2,162],{261:388,262:389,39:wS,338:ES}),n($r,[2,164]),n($r,[2,165]),n($r,[2,166]),n(hr,[2,95]),n(hr,[2,96]),n(mr,[2,377],{177:392,325:[1,393]}),{48:[1,394]},n(hr,[2,177]),{13:f,16:d,44:136,45:re,46:395,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:396,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:397,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:398,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:399,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,183]),n(hr,[2,98]),n(mr,[2,381],{180:400}),{87:[1,401]},n(hr,[2,185]),{13:f,16:d,44:136,45:re,46:402,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{29:N,57:403},n(Cn,[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:gl,307:43,308:h},n(_a,[2,233]),n(_a,[2,234]),n(_a,[2,235]),n(wC,[2,459],{281:406,325:[1,407]}),n(mr,[2,463],{284:408,325:[1,409]}),n(mr,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:ie,171:413,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},{31:[1,419],89:[1,420]},{29:[1,421]},n(Qh,[2,302]),n(Kh,[2,367],{167:422}),n(Yh,[2,369],{168:423}),{48:[1,424],87:[1,425]},n(Qh,[2,371]),n(ml,[2,122]),n(ml,[2,417]),n(ml,[2,413]),n(ml,[2,414]),n(ml,[2,415]),n(xs,[2,125]),n(xs,[2,127]),n(xs,[2,128]),n(EC,[2,420],{227:426}),n(xs,[2,130]),{13:f,16:d,55:194,197:X,223:427,307:43,308:h},{48:[1,428]},n(ba,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),n(bS,[2,288]),{64:[1,433]},n(H,[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:re,268:ue,269:fe,270:ne,271:me,273:Le,274:B,276:oe,277:Ee,279:Ce,280:xe,283:Oe,285:Re,308:h,346:L,347:U,348:R,349:C,350:D,351:w}),n(vC,[2,293]),n(vS,[2,92]),n(vS,[2,93]),n(vS,[2,94]),{45:hC,89:mC,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:I,29:O,56:85},{19:438,28:I,29:O,56:85},n(_l,[2,355],{149:439}),n(_l,[2,354]),{13:f,16:d,44:215,45:Zh,55:220,82:ie,87:p,89:De,156:440,172:221,185:441,203:442,231:em,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},n(P,[2,19]),n(ba,[2,21]),{13:f,16:d,44:450,45:TC,55:323,65:445,66:446,67:447,68:448,87:p,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},n(Oc,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},n(E,[2,386],{31:[2,388]}),n(rd,[2,102]),n(bl,[2,391],{191:452}),n(E,[2,395],{196:453,198:454}),n(E,[2,108]),n(E,[2,109]),n(rd,[2,103]),n(rd,[2,104]),n(rd,[2,390]),{13:f,16:d,44:215,45:Se,48:[1,455],55:220,82:ie,87:p,89:De,172:221,185:351,187:350,200:456,231:rt,234:349,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},n(tm,[2,424]),n(AC,[2,136]),n(AC,[2,137]),n(TS,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:p,139:342,195:458,197:gl,307:43,308:h},n(_a,[2,219]),n(_a,[2,220]),n(_a,[2,221]),n(_a,[2,222]),n(_a,[2,223]),n(Oc,[2,10]),n(Zr,[2,46]),n(Zr,[2,314]),{112:lC,122:459},n(Zr,[2,62]),n($,cC,{133:242,108:460,112:uC,132:fC}),n(SC,[2,61]),n(Zr,[2,49]),n([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},n(yl,[2,351],{146:463,335:[1,464]}),{29:N,57:465},n(ya,[2,329]),n($,[2,332],{129:466,327:[1,467]}),n(ya,[2,55]),n(ya,[2,331]),{48:[1,468]},n(Hh,[2,429]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(Rc,[2,431]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,243:470,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(Rc,[2,156]),{45:gC,89:yC,179:471},n(Cc,[2,441]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,251:472,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n($r,[2,444],{256:473}),n($r,[2,446],{258:474}),n(mr,[2,442]),n(mr,[2,443]),n($r,[2,449]),{13:f,16:d,44:136,45:re,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,255:154,257:155,259:475,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(mr,[2,450]),n(mr,[2,451]),n(mr,[2,379],{178:476}),n(mr,[2,378]),n([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:d,44:136,45:re,46:482,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{48:[1,483]},{48:[1,484]},n(hr,[2,187]),n(Cn,[2,194]),{13:f,16:d,44:39,55:40,82:ie,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,320:485},{13:f,16:d,39:[1,487],44:136,45:re,46:488,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,282:486,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(wC,[2,460]),{13:f,16:d,44:136,45:re,46:489,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(mr,[2,464]),{13:f,16:d,44:136,45:re,46:490,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(mr,[2,466]),n(F,[2,40]),n(Kh,[2,298]),n(nd,[2,87]),n(nd,[2,88]),n(nd,[2,89]),n(nd,[2,90]),{13:f,16:d,55:492,82:ie,172:493,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,311:494,312:or,315:491},n(F,[2,41]),n(Yh,[2,300]),n(id,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:ie,171:497,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},{31:[1,498],89:[1,499]},{29:[1,500]},n(Qh,[2,372]),{13:f,16:d,48:[2,422],55:194,197:X,223:312,226:502,228:501,229:_C,307:43,308:h},n(xs,[2,131]),n(xs,[2,126]),n(ba,[2,22]),n(ba,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:re,55:323,67:321,68:322,74:505,75:506,76:IC,77:320,78:xC,79:509,87:p,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},n(vC,[2,294]),n(RC,[2,69]),n(RC,[2,70]),n(H,q,{59:197,69:198,20:511,70:k}),n(z,K,{58:205,62:206,23:512,63:ae}),{29:[2,375],31:[2,71],84:522,85:o,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},n(_l,[2,363],{157:524,335:[1,525]}),n(l,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:p}),n(rm,[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:Zh,55:220,82:ie,87:p,89:De,172:221,185:351,203:536,212:534,231:em,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},n(l,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:p}),n(z,[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:TC,87:p,268:ue,269:fe,270:ne,271:me,273:Le,274:B,276:oe,277:Ee,279:Ce,280:xe,283:Oe,285:Re,308:h,346:L,347:U,348:R,349:C,350:D,351:w}),n(Sl,[2,291]),n(Sl,[2,24]),n(Sl,[2,25]),{13:f,16:d,44:136,45:re,46:539,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(Sl,[2,28]),n(z,K,{58:205,62:206,23:540,63:ae}),n([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),n(bl,[2,107]),{13:f,16:d,44:215,45:Se,55:220,82:ie,87:p,89:De,172:221,185:351,187:350,199:543,200:544,231:rt,234:349,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},n(CC,[2,132]),n(tm,[2,425]),n(CC,[2,133]),{13:f,16:d,44:354,55:355,82:ie,87:p,172:357,237:356,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:358,312:or,313:545},n(Zr,[2,54]),n(Zr,[2,48]),n(yl,[2,342]),{13:f,16:d,44:39,55:40,87:p,139:546,307:43,308:h},n(yl,[2,68]),n(E,[2,350],{31:OC,112:OC}),n(Zr,[2,53]),{13:f,16:d,55:547,307:43,308:h},n($,[2,333]),n(ve,[2,16]),n(Hh,[2,152]),n(Rc,[2,154]),n(Rc,[2,157]),n(Cc,[2,159]),n(Cc,[2,160],{262:389,261:548,39:wS,338:ES}),n(Cc,[2,161],{262:389,261:549,39:wS,338:ES}),n($r,[2,163]),{13:f,16:d,44:136,45:re,46:550,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,178]),n(hr,[2,179]),{13:f,16:d,44:136,45:re,46:551,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:552,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:553,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{48:[1,554],272:[1,555]},n(hr,[2,184]),n(hr,[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:X,223:562,307:43,308:h},n(AS,[2,224]),n(AS,[2,225]),n(AS,[2,226]),{31:[1,563],45:PC,94:564},n(F,[2,84]),n(Kh,[2,368]),n(F,[2,85]),n(Yh,[2,370]),n(id,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},n(ba,[2,35],{83:[1,569]}),n(ba,[2,36],{81:[1,570]}),n(bS,[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:re,76:IC,78:xC,87:p,268:ue,269:fe,270:ne,271:me,273:Le,274:B,276:oe,277:Ee,279:Ce,280:xe,283:Oe,285:Re,308:h,346:L,347:U,348:R,349:C,350:D,351:w}),n(Pc,[2,295]),{45:re,77:572},{45:re,77:573},n(Pc,[2,33]),n(Pc,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},n(_l,[2,356]),n(DC,[2,357],{152:578,335:[1,579]}),n(ho,[2,74]),{29:N,57:580},{29:N,57:581},{13:f,16:d,44:39,55:40,87:p,139:582,307:43,308:h},n(FC,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:re,55:323,67:321,68:322,77:320,79:585,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,307:43,308:h,346:L,347:U,348:R,349:C,350:D,351:w},{45:[1,586]},n(ho,[2,81]),{29:N,57:587},n(_l,[2,73]),n(E,[2,362],{29:mo,31:mo,85:mo,112:mo,159:mo,160:mo,161:mo,163:mo,164:mo}),n(rm,[2,112]),n(Dc,[2,401],{206:588}),n(E,[2,405],{209:589,210:590}),n(E,[2,403]),n(E,[2,404]),n(rm,[2,113]),n(rm,[2,400]),{13:f,16:d,44:215,45:Zh,48:[1,591],55:220,82:ie,87:p,89:De,172:221,185:351,203:536,212:592,231:em,234:535,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},n(tm,[2,426]),n(TS,[2,138]),n(TS,[2,139]),{232:[1,593]},n(Sl,[2,292]),{47:[1,595],48:[1,594]},n(Oc,[2,9]),n(bl,[2,392]),n(bl,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:p,197:gl,308:h}),n(bl,[2,110],{272:[1,598]}),n(nm,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},n(ya,[2,58]),n($r,[2,445]),n($r,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},n(hr,[2,99]),n(mr,[2,382]),n([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),n(hr,[2,188]),n(hr,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:ie,172:493,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,311:494,312:or,315:611},n(F,[2,42]),n(id,[2,304]),{13:f,16:d,55:414,82:ie,95:612,171:613,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},{31:[1,614],45:PC,94:615},n(xs,[2,129]),n(EC,[2,421]),{82:[1,616]},{82:[1,617]},n(Pc,[2,296]),n(Pc,[2,31]),n(Pc,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},n(E,bC,{155:330,153:618,154:619,29:go,31:go,85:go,112:go,159:go,160:go,161:go,163:go,164:go}),n(DC,[2,358]),n(ho,[2,75]),n(ho,[2,76]),{29:N,57:620},{13:f,16:d,44:39,55:40,87:p,139:621,307:43,308:h},n(FC,[2,366]),n(ho,[2,79]),{13:f,16:d,44:136,45:re,46:622,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(ho,[2,91],{336:[1,623]}),n([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),n(Dc,[2,117]),{13:f,16:d,44:215,45:Zh,55:220,82:ie,87:p,89:De,172:221,185:351,203:536,211:626,212:627,231:em,234:535,236:216,237:222,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,309:Jr,310:Cr,311:217,312:or},n(po,[2,134]),n(tm,[2,427]),n(po,[2,135]),n(Sl,[2,26]),{44:628,87:p},n(bl,[2,106]),n(bl,[2,394]),n(E,[2,396]),n(nm,[2,111]),n(nm,[2,398]),{13:f,16:d,44:39,55:40,87:p,139:342,186:629,190:340,195:341,197:gl,307:43,308:h},n(SS,[2,217]),n(E,Wh,{144:248,140:630,143:631,31:[2,343]}),n(hr,[2,97]),n(mr,[2,380]),n(hr,[2,180]),{13:f,16:d,44:136,45:re,46:632,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},{13:f,16:d,44:136,45:re,46:633,55:133,67:132,68:134,77:131,82:ie,87:p,172:135,224:he,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ue,264:130,265:ce,266:137,267:139,268:ue,269:fe,270:ne,271:me,273:Le,274:B,275:146,276:oe,277:Ee,278:149,279:Ce,280:xe,283:Oe,285:Re,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:m,346:L,347:U,348:R,349:C,350:D,351:w},n(hr,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:ie,171:637,172:415,173:416,174:Xh,255:154,257:155,291:150,294:Ae,295:ee,296:_e,297:Te,298:Pe,299:Me,300:Ne,301:Ge,302:ke,303:We,304:qe,305:je,306:He,307:43,308:h,312:Jh},n(LC,[2,305]),n(F,[2,86]),n(id,[2,374]),n(ba,[2,37]),n(ba,[2,38]),n(_l,[2,72]),n(_l,[2,360]),n(ho,[2,77]),{29:N,57:638},{47:[1,639]},{29:[2,376]},n(Dc,[2,402]),n(Dc,[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}),n(Dc,[2,118],{272:[1,641]}),n(im,[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:We,304:qe,305:je,306:He},n(nd,[2,218]),n(id,[2,44]),n(LC,[2,306]),n(ho,[2,78]),{44:651,87:p},n(Dc,[2,116]),n(E,[2,406]),n(im,[2,119]),n(im,[2,408]),n(l,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:p}),n(Sl,[2,27]),n(nm,[2,230]),n(NC,[2,345],{141:653,335:[1,654]}),n(hr,[2,181]),n(hr,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},n(E,Wh,{144:248,142:657,143:658,31:kC,112:kC}),n(NC,[2,346]),n(ho,[2,80]),n(im,[2,231]),n(yl,[2,67]),n(yl,[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(W,Z){if(Z.recoverable)this.trace(W);else{var le=new Error(W);throw le.hash=Z,le}},"parseError"),parse:a(function(W){var Z=this,le=[0],Be=[],it=[null],A=[],Pn=this.table,x="",Os=0,ld=0,lm=0,cm=2,cd=1,um=A.slice.call(arguments,1),Zt=Object.create(this.lexer),Ps={yy:{}};for(var ud in this.yy)Object.prototype.hasOwnProperty.call(this.yy,ud)&&(Ps.yy[ud]=this.yy[ud]);Zt.setInput(W,Ps.yy),Ps.yy.lexer=Zt,Ps.yy.parser=this,typeof Zt.yylloc>"u"&&(Zt.yylloc={});var Mc=Zt.yylloc;A.push(Mc);var Nt=Zt.options&&Zt.options.ranges;typeof Ps.yy.parseError=="function"?this.parseError=Ps.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Kt(Ds){le.length=le.length-2*Ds,it.length=it.length-Ds,A.length=A.length-Ds}a(Kt,"popStack");for(var bt=a(function(){var Ds;return Ds=Zt.lex()||cd,typeof Ds!="number"&&(Ds=Z.symbols_[Ds]||Ds),Ds},"lex"),Rt,zn,Tl,Ti,Qpe,jS,jc={},fm,bo,KC,dm;;){if(Tl=le[le.length-1],this.defaultActions[Tl]?Ti=this.defaultActions[Tl]:((Rt===null||typeof Rt>"u")&&(Rt=bt()),Ti=Pn[Tl]&&Pn[Tl][Rt]),typeof Ti>"u"||!Ti.length||!Ti[0]){var $S="";dm=[];for(fm in Pn[Tl])this.terminals_[fm]&&fm>cm&&dm.push("'"+this.terminals_[fm]+"'");Zt.showPosition?$S="Parse error on line "+(Os+1)+`:
35
35
  `+Zt.showPosition()+`
36
- Expecting `+dm.join(", ")+", got '"+(this.terminals_[Rt]||Rt)+"'":$S="Parse error on line "+(Os+1)+": Unexpected "+(Rt==cd?"end of input":"'"+(this.terminals_[Rt]||Rt)+"'"),this.parseError($S,{text:Zt.match,token:this.terminals_[Rt]||Rt,line:Zt.yylineno,loc:Mc,expected:dm})}if(Ti[0]instanceof Array&&Ti.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Tl+", token: "+Rt);switch(Ti[0]){case 1:le.push(Rt),it.push(Zt.yytext),A.push(Zt.yylloc),le.push(Ti[1]),Rt=null,zn?(Rt=zn,zn=null):(ld=Zt.yyleng,x=Zt.yytext,Os=Zt.yylineno,Mc=Zt.yylloc,lm>0&&lm--);break;case 2:if(bo=this.productions_[Ti[1]][1],jc.$=it[it.length-bo],jc._$={first_line:A[A.length-(bo||1)].first_line,last_line:A[A.length-1].last_line,first_column:A[A.length-(bo||1)].first_column,last_column:A[A.length-1].last_column},Nt&&(jc._$.range=[A[A.length-(bo||1)].range[0],A[A.length-1].range[1]]),jS=this.performAction.apply(jc,[x,ld,Os,Ps.yy,Ti[1],it,A].concat(um)),typeof jS<"u")return jS;bo&&(le=le.slice(0,-1*bo*2),it=it.slice(0,-1*bo),A=A.slice(0,-1*bo)),le.push(this.productions_[Ti[1]][0]),it.push(jc.$),A.push(jc._$),KC=Pn[le[le.length-2]][le[le.length-1]],le.push(KC);break;case 3:return!0}}return!0},"parse")},sm=N1().Wildcard,om="http://www.w3.org/1999/02/22-rdf-syntax-ns#",dB=om+"type",pB=om+"first",hB=om+"rest",MC=om+"nil",am="http://www.w3.org/2001/XMLSchema#",jC=am+"integer",$C=am+"decimal",UC=am+"double",mB=am+"boolean",wl="",BC="",VC="";function On(Y){return Y.toLowerCase()}a(On,"lowercase");function yo(Y,W){return Y.push(W),Y}a(yo,"appendTo");function El(Y,W){return Y.push.apply(Y,W),Y}a(El,"appendAllTo");function or(Y){Y||(Y={});for(var W=1,Z=arguments.length,le;W<Z&&(le=arguments[W]||{});W++)for(var Be in le)Y[Be]=le[Be];return Y}a(or,"extend");function Rs(){for(var Y=[],W=0,Z=arguments.length;W<Z;W++)Y=Y.concat.apply(Y,arguments[W]);return Y}a(Rs,"unionAll");function sd(Y){if(Y[0]==="<"&&(Y=Y.substring(1,Y.length-1)),/^[a-z][a-z0-9.+-]*:/i.test(Y))return Y;if(!ot.base)throw new Error("Cannot resolve relative IRI "+Y+" because no base IRI was set.");switch(wl!==ot.base&&(wl=ot.base,BC=wl.replace(/[^\/:]*$/,""),VC=wl.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),Y[0]){case void 0:return wl;case"#":return wl+Y;case"?":return wl.replace(/(?:\?.*)?$/,Y);case"/":return VC+Y;default:return BC+Y}}a(sd,"resolveIRI");function xS(Y){if(Y){var W=Y[0];if(W==="?"||W==="$")return ot.factory.variable(Y.substr(1))}return Y}a(xS,"toVar");function en(Y,W){return{type:"operation",operator:Y,args:W||[]}}a(en,"operation");function Fc(Y,W){var Z={expression:Y==="*"?new sm:Y};if(W)for(var le in W)Z[le]=W[le];return Z}a(Fc,"expression");function Lc(Y,W){return{type:"path",pathType:Y,items:W}}a(Lc,"path");function RS(Y,W){for(var Z=0,le=W.length,Be;Z<le&&(Be=W[Z]);Z++)Y=en(Be[0],[Y,Be[1]]);return Y}a(RS,"createOperationTree");function vl(Y,W){var Z=[],le=[],Be=Y.length,it,A={};if(!Be)return null;for(var Pn=0;Pn<Be&&(it=Y[Pn]);Pn++)(it.named?le:Z).push(it.iri);return A[W||"from"]={default:Z,named:le},A}a(vl,"groupDatasets");function Nc(Y){return parseInt(Y,10)}a(Nc,"toInt");function CS(Y){return Y.type==="group"&&Y.patterns.length===1?Y.patterns[0]:Y}a(CS,"degroupSingle");function Cs(Y,W){return W&&W.termType!=="NamedNode"&&(W=ot.factory.namedNode(W)),ot.factory.literal(Y,W)}a(Cs,"createTypedLiteral");function gB(Y,W){return ot.factory.literal(Y,W)}a(gB,"createLangLiteral");function OS(Y,W,Z){if(!("termType"in W))throw new Error("Nested triples cannot contain paths");return ot.factory.quad(Y,W,Z)}a(OS,"nestedTriple");function _o(Y,W,Z,le){var Be={};return Y!=null&&(Be.subject=Y),W!=null&&(Be.predicate=W),Z!=null&&(Be.object=Z),le!=null&&(Be.annotations=le),Be}a(_o,"triple");function od(Y){return typeof Y=="string"?Y.startsWith("e_")?ot.factory.blankNode(Y):ot.factory.blankNode("e_"+Y):ot.factory.blankNode("g_"+qC++)}a(od,"blank");var qC=0;ot._resetBlanks=function(){qC=0};var yB=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,_B={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
37
- `,r:"\r",f:"\f"},bB=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,PS=String.fromCharCode;function GC(Y,W){Y=Y.substring(W,Y.length-W);try{Y=Y.replace(yB,function(Z,le,Be,it){var A;if(le){if(A=parseInt(le,16),isNaN(A))throw new Error;return PS(A)}else if(Be){if(A=parseInt(Be,16),isNaN(A))throw new Error;return A<65535?PS(A):PS(55296+((A-=65536)>>10),56320+(A&1023))}else{var Pn=_B[it];if(!Pn)throw new Error;return Pn}})}catch{return""}if(bB.exec(Y))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+Y);return Y}a(GC,"unescapeString");function SB(Y){var W=od(),Z=W,le=[],Be,it=[];Y.forEach(function(Os){le.push(Os.entity),El(it,Os.triples)});for(var A=0,Pn=0,x=le.length,Be=Array(x*2);A<x;)Be[Pn++]=_o(Z,ot.factory.namedNode(pB),le[A]),Be[Pn++]=_o(Z,ot.factory.namedNode(hB),Z=++A<x?od():ot.factory.namedNode(MC));return{entity:W,triples:El(Be,it)}}a(SB,"createList");function wB(Y){var W=od();return{entity:W,triples:Y.map(function(Z){return or(_o(W),Z)})}}a(wB,"createAnonymousObject");function DS(Y,W,Z){var le=[],Be=[];return W.forEach(function(it){let A=null;it.annotation&&(A=it.annotation,it=it.object),le.push(_o(null,Y,it.entity,A)),El(Be,it.triples)}),Rs(le,Z||[],Be)}a(DS,"objectListToTriples");function Kpe(Y){for(var W=[],Z,le=0,Be;Be=Y[le];le++)switch(Be.type){case"bgp":Be.triples.length&&(Z?El(Z.triples,Be.triples):yo(W,Z=Be));break;default:(!Be.patterns||Be.patterns.length>0)&&(yo(W,Be),Z=null)}return W}a(Kpe,"mergeAdjacentBGPs");function kc(Y){return Y.variable?Y.variable.value:Y.value||Y.expression.value}a(kc,"getExpressionId");function FS(Y){if(!Y)return[];if(Y.type==="aggregate")return[Y];if(Y.type==="operation"){let W=[];for(let Z of Y.args)W.push(...FS(Z));return W}return[]}a(FS,"getAggregatesOfExpression");function EB(Y){let W=new Set,Z=a(function(le){le&&(le.termType==="Variable"?W.add(le):le.type==="operation"&&le.args.forEach(Z))},"visitExpression");return Z(Y),W}a(EB,"getVariablesFromExpression");function LS(Y,W=1,Z=[]){for(let le of Y)W>0&&le instanceof Array?LS(le,W-1,Z):Z.push(le);return Z}a(LS,"flatten");function NS(Y){return Y.termType==="Variable"}a(NS,"isVariable");function WC(Y){if(Y.triples){let W=[];for(let Z of Y.triples)NS(Z.subject)&&W.push(Z.subject.value),NS(Z.predicate)&&W.push(Z.predicate.value),NS(Z.object)&&W.push(Z.object.value);return W}else if(Y.patterns){let W=[];for(let Z of Y.patterns)W.push(...WC(Z));return W}return[]}a(WC,"getBoundVarsFromGroupGraphPattern");function vB(Y){let W=Y.slice().sort(),Z=[];for(let le=0;le<W.length-1;le++)W[le+1]==W[le]&&Z.push(W[le]);return Z}a(vB,"getDuplicatesInArray");function ad(Y){if(!ot.sparqlStar)throw new Error("SPARQL-star support is not enabled");return Y}a(ad,"ensureSparqlStar");function HC(Y,W,Z){for(let le of W){let Be=_o("subject"in le?le.subject:Y,le.predicate,le.object);Z.push(Be),le.annotations&&HC(OS(Y,le.predicate,le.object),le.annotations,Z)}}a(HC,"_applyAnnotations");function kS(Y){if(ot.sparqlStar){let W=[];return Y.forEach(Z=>{let le=_o(Z.subject,Z.predicate,Z.object);W.push(le),Z.annotations&&HC(OS(Z.subject,Z.predicate,Z.object),Z.annotations,W)}),W}return Y}a(kS,"applyAnnotations");function Ype(Y){if(!ot.sparqlStarNestedQuads)throw new Error("Lenient SPARQL-star support with nested quads is not enabled");return Y}a(Ype,"ensureSparqlStarNestedQuads");function zC(Y){for(let W of Y){if(W.type==="graph"&&W.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(W.type==="bgp"||W.type==="graph"){for(let Z of W.triples)if(Z.subject.termType==="Variable"||Z.predicate.termType==="Variable"||Z.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return Y}a(zC,"ensureNoVariables");function MS(Y){for(let W of Y)if(W.type==="bgp"){for(let Z of W.triples)if(Z.subject.termType==="BlankNode"||Z.predicate.termType==="BlankNode"||Z.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return Y}a(MS,"ensureNoBnodes");var TB=(function(){var Y={EOF:1,parseError:a(function(Z,le){if(this.yy.parser)this.yy.parser.parseError(Z,le);else throw new Error(Z)},"parseError"),setInput:a(function(W,Z){return this.yy=Z||this.yy||{},this._input=W,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 W=this._input[0];this.yytext+=W,this.yyleng++,this.offset++,this.match+=W,this.matched+=W;var Z=W.match(/(?:\r\n?|\n).*/g);return Z?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),W},"input"),unput:a(function(W){var Z=W.length,le=W.split(/(?:\r\n?|\n)/g);this._input=W+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-Z),this.offset-=Z;var Be=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),le.length-1&&(this.yylineno-=le.length-1);var it=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:le?(le.length===Be.length?this.yylloc.first_column:0)+Be[Be.length-le.length].length-le[0].length:this.yylloc.first_column-Z},this.options.ranges&&(this.yylloc.range=[it[0],it[0]+this.yyleng-Z]),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).
36
+ Expecting `+dm.join(", ")+", got '"+(this.terminals_[Rt]||Rt)+"'":$S="Parse error on line "+(Os+1)+": Unexpected "+(Rt==cd?"end of input":"'"+(this.terminals_[Rt]||Rt)+"'"),this.parseError($S,{text:Zt.match,token:this.terminals_[Rt]||Rt,line:Zt.yylineno,loc:Mc,expected:dm})}if(Ti[0]instanceof Array&&Ti.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Tl+", token: "+Rt);switch(Ti[0]){case 1:le.push(Rt),it.push(Zt.yytext),A.push(Zt.yylloc),le.push(Ti[1]),Rt=null,zn?(Rt=zn,zn=null):(ld=Zt.yyleng,x=Zt.yytext,Os=Zt.yylineno,Mc=Zt.yylloc,lm>0&&lm--);break;case 2:if(bo=this.productions_[Ti[1]][1],jc.$=it[it.length-bo],jc._$={first_line:A[A.length-(bo||1)].first_line,last_line:A[A.length-1].last_line,first_column:A[A.length-(bo||1)].first_column,last_column:A[A.length-1].last_column},Nt&&(jc._$.range=[A[A.length-(bo||1)].range[0],A[A.length-1].range[1]]),jS=this.performAction.apply(jc,[x,ld,Os,Ps.yy,Ti[1],it,A].concat(um)),typeof jS<"u")return jS;bo&&(le=le.slice(0,-1*bo*2),it=it.slice(0,-1*bo),A=A.slice(0,-1*bo)),le.push(this.productions_[Ti[1]][0]),it.push(jc.$),A.push(jc._$),KC=Pn[le[le.length-2]][le[le.length-1]],le.push(KC);break;case 3:return!0}}return!0},"parse")},sm=N1().Wildcard,om="http://www.w3.org/1999/02/22-rdf-syntax-ns#",dB=om+"type",pB=om+"first",hB=om+"rest",MC=om+"nil",am="http://www.w3.org/2001/XMLSchema#",jC=am+"integer",$C=am+"decimal",UC=am+"double",mB=am+"boolean",wl="",BC="",VC="";function On(Y){return Y.toLowerCase()}a(On,"lowercase");function yo(Y,W){return Y.push(W),Y}a(yo,"appendTo");function El(Y,W){return Y.push.apply(Y,W),Y}a(El,"appendAllTo");function ar(Y){Y||(Y={});for(var W=1,Z=arguments.length,le;W<Z&&(le=arguments[W]||{});W++)for(var Be in le)Y[Be]=le[Be];return Y}a(ar,"extend");function Rs(){for(var Y=[],W=0,Z=arguments.length;W<Z;W++)Y=Y.concat.apply(Y,arguments[W]);return Y}a(Rs,"unionAll");function sd(Y){if(Y[0]==="<"&&(Y=Y.substring(1,Y.length-1)),/^[a-z][a-z0-9.+-]*:/i.test(Y))return Y;if(!ot.base)throw new Error("Cannot resolve relative IRI "+Y+" because no base IRI was set.");switch(wl!==ot.base&&(wl=ot.base,BC=wl.replace(/[^\/:]*$/,""),VC=wl.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),Y[0]){case void 0:return wl;case"#":return wl+Y;case"?":return wl.replace(/(?:\?.*)?$/,Y);case"/":return VC+Y;default:return BC+Y}}a(sd,"resolveIRI");function xS(Y){if(Y){var W=Y[0];if(W==="?"||W==="$")return ot.factory.variable(Y.substr(1))}return Y}a(xS,"toVar");function en(Y,W){return{type:"operation",operator:Y,args:W||[]}}a(en,"operation");function Fc(Y,W){var Z={expression:Y==="*"?new sm:Y};if(W)for(var le in W)Z[le]=W[le];return Z}a(Fc,"expression");function Lc(Y,W){return{type:"path",pathType:Y,items:W}}a(Lc,"path");function RS(Y,W){for(var Z=0,le=W.length,Be;Z<le&&(Be=W[Z]);Z++)Y=en(Be[0],[Y,Be[1]]);return Y}a(RS,"createOperationTree");function vl(Y,W){var Z=[],le=[],Be=Y.length,it,A={};if(!Be)return null;for(var Pn=0;Pn<Be&&(it=Y[Pn]);Pn++)(it.named?le:Z).push(it.iri);return A[W||"from"]={default:Z,named:le},A}a(vl,"groupDatasets");function Nc(Y){return parseInt(Y,10)}a(Nc,"toInt");function CS(Y){return Y.type==="group"&&Y.patterns.length===1?Y.patterns[0]:Y}a(CS,"degroupSingle");function Cs(Y,W){return W&&W.termType!=="NamedNode"&&(W=ot.factory.namedNode(W)),ot.factory.literal(Y,W)}a(Cs,"createTypedLiteral");function gB(Y,W){return ot.factory.literal(Y,W)}a(gB,"createLangLiteral");function OS(Y,W,Z){if(!("termType"in W))throw new Error("Nested triples cannot contain paths");return ot.factory.quad(Y,W,Z)}a(OS,"nestedTriple");function _o(Y,W,Z,le){var Be={};return Y!=null&&(Be.subject=Y),W!=null&&(Be.predicate=W),Z!=null&&(Be.object=Z),le!=null&&(Be.annotations=le),Be}a(_o,"triple");function od(Y){return typeof Y=="string"?Y.startsWith("e_")?ot.factory.blankNode(Y):ot.factory.blankNode("e_"+Y):ot.factory.blankNode("g_"+qC++)}a(od,"blank");var qC=0;ot._resetBlanks=function(){qC=0};var yB=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,_B={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
37
+ `,r:"\r",f:"\f"},bB=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,PS=String.fromCharCode;function GC(Y,W){Y=Y.substring(W,Y.length-W);try{Y=Y.replace(yB,function(Z,le,Be,it){var A;if(le){if(A=parseInt(le,16),isNaN(A))throw new Error;return PS(A)}else if(Be){if(A=parseInt(Be,16),isNaN(A))throw new Error;return A<65535?PS(A):PS(55296+((A-=65536)>>10),56320+(A&1023))}else{var Pn=_B[it];if(!Pn)throw new Error;return Pn}})}catch{return""}if(bB.exec(Y))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+Y);return Y}a(GC,"unescapeString");function SB(Y){var W=od(),Z=W,le=[],Be,it=[];Y.forEach(function(Os){le.push(Os.entity),El(it,Os.triples)});for(var A=0,Pn=0,x=le.length,Be=Array(x*2);A<x;)Be[Pn++]=_o(Z,ot.factory.namedNode(pB),le[A]),Be[Pn++]=_o(Z,ot.factory.namedNode(hB),Z=++A<x?od():ot.factory.namedNode(MC));return{entity:W,triples:El(Be,it)}}a(SB,"createList");function wB(Y){var W=od();return{entity:W,triples:Y.map(function(Z){return ar(_o(W),Z)})}}a(wB,"createAnonymousObject");function DS(Y,W,Z){var le=[],Be=[];return W.forEach(function(it){let A=null;it.annotation&&(A=it.annotation,it=it.object),le.push(_o(null,Y,it.entity,A)),El(Be,it.triples)}),Rs(le,Z||[],Be)}a(DS,"objectListToTriples");function Kpe(Y){for(var W=[],Z,le=0,Be;Be=Y[le];le++)switch(Be.type){case"bgp":Be.triples.length&&(Z?El(Z.triples,Be.triples):yo(W,Z=Be));break;default:(!Be.patterns||Be.patterns.length>0)&&(yo(W,Be),Z=null)}return W}a(Kpe,"mergeAdjacentBGPs");function kc(Y){return Y.variable?Y.variable.value:Y.value||Y.expression.value}a(kc,"getExpressionId");function FS(Y){if(!Y)return[];if(Y.type==="aggregate")return[Y];if(Y.type==="operation"){let W=[];for(let Z of Y.args)W.push(...FS(Z));return W}return[]}a(FS,"getAggregatesOfExpression");function EB(Y){let W=new Set,Z=a(function(le){le&&(le.termType==="Variable"?W.add(le):le.type==="operation"&&le.args.forEach(Z))},"visitExpression");return Z(Y),W}a(EB,"getVariablesFromExpression");function LS(Y,W=1,Z=[]){for(let le of Y)W>0&&le instanceof Array?LS(le,W-1,Z):Z.push(le);return Z}a(LS,"flatten");function NS(Y){return Y.termType==="Variable"}a(NS,"isVariable");function WC(Y){if(Y.triples){let W=[];for(let Z of Y.triples)NS(Z.subject)&&W.push(Z.subject.value),NS(Z.predicate)&&W.push(Z.predicate.value),NS(Z.object)&&W.push(Z.object.value);return W}else if(Y.patterns){let W=[];for(let Z of Y.patterns)W.push(...WC(Z));return W}return[]}a(WC,"getBoundVarsFromGroupGraphPattern");function vB(Y){let W=Y.slice().sort(),Z=[];for(let le=0;le<W.length-1;le++)W[le+1]==W[le]&&Z.push(W[le]);return Z}a(vB,"getDuplicatesInArray");function ad(Y){if(!ot.sparqlStar)throw new Error("SPARQL-star support is not enabled");return Y}a(ad,"ensureSparqlStar");function HC(Y,W,Z){for(let le of W){let Be=_o("subject"in le?le.subject:Y,le.predicate,le.object);Z.push(Be),le.annotations&&HC(OS(Y,le.predicate,le.object),le.annotations,Z)}}a(HC,"_applyAnnotations");function kS(Y){if(ot.sparqlStar){let W=[];return Y.forEach(Z=>{let le=_o(Z.subject,Z.predicate,Z.object);W.push(le),Z.annotations&&HC(OS(Z.subject,Z.predicate,Z.object),Z.annotations,W)}),W}return Y}a(kS,"applyAnnotations");function Ype(Y){if(!ot.sparqlStarNestedQuads)throw new Error("Lenient SPARQL-star support with nested quads is not enabled");return Y}a(Ype,"ensureSparqlStarNestedQuads");function zC(Y){for(let W of Y){if(W.type==="graph"&&W.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(W.type==="bgp"||W.type==="graph"){for(let Z of W.triples)if(Z.subject.termType==="Variable"||Z.predicate.termType==="Variable"||Z.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return Y}a(zC,"ensureNoVariables");function MS(Y){for(let W of Y)if(W.type==="bgp"){for(let Z of W.triples)if(Z.subject.termType==="BlankNode"||Z.predicate.termType==="BlankNode"||Z.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return Y}a(MS,"ensureNoBnodes");var TB=(function(){var Y={EOF:1,parseError:a(function(Z,le){if(this.yy.parser)this.yy.parser.parseError(Z,le);else throw new Error(Z)},"parseError"),setInput:a(function(W,Z){return this.yy=Z||this.yy||{},this._input=W,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 W=this._input[0];this.yytext+=W,this.yyleng++,this.offset++,this.match+=W,this.matched+=W;var Z=W.match(/(?:\r\n?|\n).*/g);return Z?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),W},"input"),unput:a(function(W){var Z=W.length,le=W.split(/(?:\r\n?|\n)/g);this._input=W+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-Z),this.offset-=Z;var Be=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),le.length-1&&(this.yylineno-=le.length-1);var it=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:le?(le.length===Be.length?this.yylloc.first_column:0)+Be[Be.length-le.length].length-le[0].length:this.yylloc.first_column-Z},this.options.ranges&&(this.yylloc.range=[it[0],it[0]+this.yyleng-Z]),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).
38
38
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:a(function(W){this.unput(this.match.slice(W))},"less"),pastInput:a(function(){var W=this.matched.substr(0,this.matched.length-this.match.length);return(W.length>20?"...":"")+W.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var W=this.match;return W.length<20&&(W+=this._input.substr(0,20-W.length)),(W.substr(0,20)+(W.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var W=this.pastInput(),Z=new Array(W.length+1).join("-");return W+this.upcomingInput()+`
39
39
  `+Z+"^"},"showPosition"),test_match:a(function(W,Z){var le,Be,it;if(this.options.backtrack_lexer&&(it={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(it.yylloc.range=this.yylloc.range.slice(0))),Be=W[0].match(/(?:\r\n?|\n).*/g),Be&&(this.yylineno+=Be.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:Be?Be[Be.length-1].length-Be[Be.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+W[0].length},this.yytext+=W[0],this.match+=W[0],this.matches=W,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(W[0].length),this.matched+=W[0],le=this.performAction.call(this,this.yy,this,Z,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),le)return le;if(this._backtrack){for(var A in it)this[A]=it[A];return!1}return!1},"test_match"),next:a(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var W,Z,le,Be;this._more||(this.yytext="",this.match="");for(var it=this._currentRules(),A=0;A<it.length;A++)if(le=this._input.match(this.rules[it[A]]),le&&(!Z||le[0].length>Z[0].length)){if(Z=le,Be=A,this.options.backtrack_lexer){if(W=this.test_match(le,it[A]),W!==!1)return W;if(this._backtrack){Z=!1;continue}else return!1}else if(!this.options.flex)break}return Z?(W=this.test_match(Z,it[Be]),W!==!1?W:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
40
40
  `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:a(function(){var Z=this.next();return Z||this.lex()},"lex"),begin:a(function(Z){this.conditionStack.push(Z)},"begin"),popState:a(function(){var Z=this.conditionStack.length-1;return Z>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:a(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:a(function(Z){return Z=this.conditionStack.length-1-Math.abs(Z||0),Z>=0?this.conditionStack[Z]:"INITIAL"},"topState"),pushState:a(function(Z){this.begin(Z)},"pushState"),stateStackSize:a(function(){return this.conditionStack.length},"stateStackSize"),options:{flex:!0,"case-insensitive":!0},performAction:a(function(Z,le,Be,it){var A=it;switch(Be){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(le.yytext);break}},"anonymous"),rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};return Y})();IS.lexer=TB;function ot(){this.yy={}}return a(ot,"Parser"),ot.prototype=IS,IS.Parser=ot,new ot})();MP.exports=nG});var VP=v((Vye,BP)=>{var iG="http://www.w3.org/2001/XMLSchema#integer",sG="http://www.w3.org/2001/XMLSchema#string";function Bt(n){this._options=n=n||{};var e=n.prefixes||{};this._prefixByIri={};var t=[];for(var r in e){var i=e[r];kd(i)&&(this._prefixByIri[i]=r,t.push(i))}var s=t.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=n.sparqlStar,this._indent=kd(n.indent)?n.indent:" ",this._newline=kd(n.newline)?n.newline:`
@@ -68,8 +68,8 @@ ${r}}`}default:throw new bu(`Unsupported operation type for SPARQL generation: $
68
68
  `)}generateTriple(e){let t=this.generateElement(e.subject),r=this.generatePredicate(e.predicate),i=this.generateElement(e.object);return`${t} ${r} ${i}`}generatePredicate(e){return"pathType"in e?this.generatePropertyPath(e):this.generateElement(e)}generatePropertyPath(e){let t=e.items.map(r=>"pathType"in r?`(${this.generatePropertyPath(r)})`:`<${r.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}generateElement(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":{let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}case"blank":return`_:${e.value}`;default:throw new bu(`Unknown element type: ${e.type}`)}}generateValues(e,t){let r=" ".repeat(t);if(e.variables.length===0||e.bindings.length===0)return"";if(e.variables.length===1){let o=e.variables[0],l=e.bindings.map(c=>{let u=c[o];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ");return`${r}VALUES ?${o} { ${l} }`}let i=e.variables.map(o=>`?${o}`).join(" "),s=e.bindings.map(o=>`(${e.variables.map(c=>{let u=o[c];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ")})`);return`${r}VALUES (${i}) {
69
69
  ${s.map(o=>`${r} ${o}`).join(`
70
70
  `)}
71
- ${r}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(r=>this.generateExpression(r)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),r=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${r})`:`${t} IN (${r})`}default:throw new bu(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let r of e.triples)this.collectVariablesFromTriple(r,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let r of e.variables)t.add(r);break;case"project":for(let r of e.variables)t.add(r);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let r of e.variables)t.add(r);for(let r of e.aggregates)t.add(r.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let r of e.operands)this.collectVariablesFromExpression(r,t);break;case"function":case"functionCall":for(let r of e.args)this.collectVariablesFromExpression(r,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let r of e.list)this.collectVariablesFromExpression(r,t);break}}};Su.SPARQLGenerator=HE});var Eu=v(ti=>{"use strict";var aW=ti&&ti.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),lW=ti&&ti.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),W3=ti&&ti.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&aW(t,e,r[i]);return lW(t,e),t}})();Object.defineProperty(ti,"__esModule",{value:!0});ti.QueryExecutor=ti.ExoQLQueryExecutor=ti.QueryExecutorError=void 0;var cW=hE(),uW=ry(),fW=FE(),dW=NE(),pW=O3(),hW=D3(),mW=k3(),gW=qE(),yW=j3(),_W=U3(),bW=q3(),SW=G3(),wW=ze(),EW=tt(),vW=Yg(),ln="http://www.w3.org/2001/XMLSchema#",TW=new Set([`${ln}integer`,`${ln}decimal`,`${ln}float`,`${ln}double`,`${ln}nonPositiveInteger`,`${ln}negativeInteger`,`${ln}long`,`${ln}int`,`${ln}short`,`${ln}byte`,`${ln}nonNegativeInteger`,`${ln}unsignedLong`,`${ln}unsignedInt`,`${ln}unsignedShort`,`${ln}unsignedByte`,`${ln}positiveInteger`]),wu=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};ti.QueryExecutorError=wu;var uy=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let r=t.resolveClassHierarchy===!1?e:new bW.ClassHierarchyResolvingStore(e);this.tripleStore=r,this.bgpExecutor=new cW.BGPExecutor(r),this.filterExecutor=new uW.FilterExecutor,this.optionalExecutor=new fW.OptionalExecutor,this.unionExecutor=new dW.UnionExecutor,this.minusExecutor=new pW.MinusExecutor,this.valuesExecutor=new hW.ValuesExecutor,this.aggregateExecutor=new mW.AggregateExecutor,this.constructExecutor=new gW.ConstructExecutor,this.serviceExecutor=new yW.ServiceExecutor(t.serviceConfig),this.graphExecutor=new _W.GraphExecutor(r),this.sparqlGenerator=new SW.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(r)}async evaluateExistsPattern(e,t){for await(let r of this.execute(e))if(t.merge(r)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new wu(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let r=new Set;for(let o of t)for(let l of o.variables())r.add(l);let i=this.collectOperationVariables(e.right);if([...r].some(o=>i.has(o)))for(let o of t){let l=this.substituteVariables(e.right,o);for await(let c of this.execute(l)){let u=o.merge(c);u!==null&&(yield u)}}else{let o=[];for await(let l of this.execute(e.right))o.push(l);for(let l of t)for(let c of o){let u=l.merge(c);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>W3(Ro())),r=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(r.has(o)){let l=i.get(o);l!==void 0&&s.set(o,l)}yield s}}async*executeOrderBy(e){let t=[];for await(let r of this.execute(e.input))t.push(r);t.sort((r,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,r),l=this.getExpressionValue(s.expression,i),c=0;if(o===void 0&&l===void 0?c=0:o===void 0?c=1:l===void 0?c=-1:typeof o=="number"&&typeof l=="number"?c=o-l:c=String(o).localeCompare(String(l)),s.descending&&(c=-c),c!==0)return c}return 0});for(let r of t)yield r}async*executeSlice(e){let t=0,r=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=r){if(i!==void 0&&t-r>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeReduced(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let r=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of r)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of r)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let r of this.execute(e.input)){let i=r.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,r):this.evaluateExtendExpression(e.expression,r);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let r of this.execute(e.left))t.push(r);for(let r of t){let i=this.substituteVariables(e.right,r);for await(let s of this.execute(i)){let o=r.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let r=JSON.parse(JSON.stringify(e));return this.substituteInOperation(r,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let r=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(r.input&&(r.input=this.substituteInOperation(r.input,t)),r.left&&(r.left=this.substituteInOperation(r.left,t)),r.right&&(r.right=this.substituteInOperation(r.right,t)),r.pattern&&(r.pattern=this.substituteInOperation(r.pattern,t)),r.query&&(r.query=this.substituteInOperation(r.query,t)),r.where&&(r.where=this.substituteInOperation(r.where,t)),r.expression&&this.substituteInExpression(r.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let r of e.operands)this.substituteInExpression(r,t);if(e.args)for(let r of e.args)this.substituteInExpression(r,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let r of e.list)this.substituteInExpression(r,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let r=t.get(e.value);if(r!=null){let i=r;if(r instanceof wW.IRI||i.termType==="NamedNode")return{type:"iri",value:r.value};if(i.termType==="Literal"||typeof i.value=="string")return{type:"literal",value:i.value,datatype:i.datatype?.value??i._datatype?.value,language:i.language??i._language}}}return e}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(r,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{r.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(r,i):yield*this.execute(r)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:r}=await Promise.resolve().then(()=>W3(Ro()));yield new r;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let r=t.get(e.name);if(!r)return;if(r instanceof EW.Literal){let i=r.datatype?.value;if(i===`${ln}dayTimeDuration`)try{return vW.DateTimeFunctions.parseDayTimeDuration(r.value)}catch{return r.value}if(i&&TW.has(i)){let s=parseFloat(r.value);if(!Number.isNaN(s))return s}return r.value}return r.value??r.id??String(r)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="bgp"&&r.triples)for(let i of r.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(r.type==="values"&&r.variables)for(let i of r.variables)t.add(i);r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.type==="extend"&&r.variable&&t.add(r.variable),r.input&&this.collectVarsFromOperation(r.input,t),r.left&&this.collectVarsFromOperation(r.left,t),r.right&&this.collectVarsFromOperation(r.right,t),r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.query&&this.collectVarsFromOperation(r.query,t),r.where&&this.collectVarsFromOperation(r.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let r=e;r.type==="variable"&&t.add(r.value),r.type==="quoted"&&(this.collectVarsFromElement(r.subject,t),this.collectVarsFromElement(r.predicate,t),this.collectVarsFromElement(r.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="variable"&&r.name&&t.add(r.name),r.type==="exists"&&r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.left&&this.collectVarsFromExpressionTree(r.left,t),r.right&&this.collectVarsFromExpressionTree(r.right,t),r.operands)for(let i of r.operands)this.collectVarsFromExpressionTree(i,t);if(r.args)for(let i of r.args)this.collectVarsFromExpressionTree(i,t);if(r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.list)for(let i of r.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new wu("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 wu("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};ti.ExoQLQueryExecutor=uy;ti.QueryExecutor=uy});var Z3=v(Co=>{"use strict";var AW=Co&&Co.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},IW=Co&&Co.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Co,"__esModule",{value:!0});Co.CommandResolver=void 0;var xW=ut(),RW=Fd(),ar=ze(),Gt=tt(),te=Vt(),H3=Sa(),z3=pd(),CW=Vc(),OW=Ld(),vu=ow(),fy=NP(),PW=Jc(),DW=nu(),FW=Eu(),Hl=10,dy="exo__Asset",LW=Hl+1,K3="08cec529-90eb-4d43-88de-ceecccea12b0",NW=te.Namespace.EXOCMD.term("SubstitutionToken").value,Y3=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","targetClassSelf"]);function kW(n,e){return`__SUBSTITUTE__${n}__${e}__`}a(kW,"buildSubstitutionMarker");function MW(n,e,t){let r=(0,CW.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${n}__${e}__${r}__`}a(MW,"buildParameterisedMarker");var Q3="3f28af98-c031-4718-8ba2-44ad0b012c52",jW=te.Namespace.EXOCMD.term("TokenInvocation").value,X3="29e2c8f8-2d27-4e58-b467-2e85d46f8122",J3="universal-default-template",zE=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null,(0,fy.clearUniversalDefault)()}constructor(e,t=RW.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,r){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${r??""}`,o=this.multiCache.get(s);if(o)return o;let l=r?await this.expandPrototypeChain(r):void 0,c=await this.expandClassHierarchy(t),u=new Map;for(let[h,_]of c){let y=await this.resolveForAsset(e,h,l);for(let b of y){let S=this.getBindingPriority(b.binding)===2?_:0,I=u.get(b.binding.id);(!I||S<I.depth)&&u.set(b.binding.id,{rc:b,depth:S})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let _ of h.binding.overrides)f.add(_);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,_)=>{let y=this.getBindingPriority(h.rc.binding),b=this.getBindingPriority(_.rc.binding);return y!==b?y-b:h.depth!==_.depth?h.depth-_.depth:(h.rc.binding.order??100)-(_.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 l of e){if(l===dy){t.set(l,new Set);continue}let c=[];try{c=await this.getClassAncestors(l)}catch{c=[]}t.set(l,new Set(c))}let r=a(l=>{for(let c of e)if(c!==l&&t.get(c)?.has(l)&&!t.get(l)?.has(c))return!0;return!1},"isAncestorOfSibling"),i=e.filter(l=>!r(l)),s=new Map,o=a((l,c)=>{let u=s.get(l);(u===void 0||c<u)&&s.set(l,c)},"setMin");for(let l of i){if(o(l,0),this.looksLikeUUID(l))try{let u=await this.resolveLabelByUID(l);u&&o(u,0)}catch{}if(l===dy)continue;let c=[];try{c=await this.getClassAncestorsWithDepth(l)}catch{c=[]}for(let{ref:u,depth:f}of c)o(u,f)}return s.has(dy)||s.set(dy,LW),s}async resolveForAsset(e,t,r){let i=typeof r=="string"?`s:${r}`:r?`c:${r.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let l=typeof r=="string"?await this.expandPrototypeChain(r):r,c=await this.findBindings(t,l,e),u=[];for(let f of c){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 r=await this.findSubjectByUID(e);if(!r||(await this.tripleStore.match(r,te.Namespace.RDF.term("type"),te.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(r,te.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_labelTemplate")),l=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_icon")),c=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(r),_=await this.loadLinkedGrounding(r,0,t);return _?{id:e,name:s,labelTemplate:o??void 0,icon:l??void 0,precondition:h??void 0,grounding:_,confirmMessage:c??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,r){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,te.Namespace.RDF.term("type"),te.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let l of s){let c=l.subject,u=await this.loadBindingDefinition(c);u&&this.bindingMatches(u,e,i,r)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,te.Namespace.RDF.term("type"),te.Namespace.EXOCMD.term("Command")),t=[],r=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,te.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let l=await this.getLiteralValue(s,te.Namespace.EXO.term("Asset_uid"));if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let c=await this.loadCommand(l);if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command ${l} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,te.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,te.Namespace.EXOCMD.term("Command_cliName")),d=u??f??l;if(r.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${l}`);continue}r.add(d),t.push({command:c,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let r=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let l=await this.evaluateSelectSnippet(o,t);r=r.replace(s,l)}return r}extractPlaceholders(e){let t=[],r=0;for(;r<e.length;)if(e[r]==="{"){let i=1,s=r+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(r,s),l=e.slice(r+1,s-1);t.push({full:o,body:l})}r=s}else r++;return t}async evaluateSelectSnippet(e,t){try{let r=e.replace(/\$target/g,`<${t}>`),s=new PW.ExoQLParser().parse(r),l=new DW.ExoQLAlgebraTranslator().translate(s),u=await new FW.ExoQLQueryExecutor(this.tripleStore).executeAll(l);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 Gt.Literal||p instanceof ar.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,te.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,te.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,te.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),l=await this.getLinkedValue(e,te.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!l)return null;let c=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,te.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),_=await this.getLinkedUIDs(e,te.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:r,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:l??void 0,position:c??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:_.length>0?_:void 0}}async loadLinkedStyle(e,t){let r=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(r.length>0){let s=r[0].object,o=null;if(s instanceof ar.IRI)o=s;else if(s instanceof Gt.Literal){let l=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(l)}if(o){let l=await this.loadStyleAsset(o);if(l)return l}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,te.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,te.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),l=this.coerceBoolean(o),c=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=c!==null?this.coerceLabelClass(c,t):void 0,f=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_source")),_=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:r,variant:s,showIcon:l,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:_,inline:!1}}coerceVariant(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(vu.COMMAND_VARIANT_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${r}" not in whitelist [${vu.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(vu.LABEL_CLASS_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${r}" not in whitelist [${vu.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(vu.STYLE_SOURCE_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle source "${r}" not in whitelist [${vu.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,r,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&r){for(let s of r)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let r=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(r===i)return!0;let s=this.extractPathBasename(i);if(s&&s===r)return!0;let o=this.extractPathBasename(r);if(o&&o===i)return!0;let l=this.extractAlias(t);if(l&&r===l)return!0;let c=this.extractAlias(e);return!!(c&&c===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(r+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,te.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=await this.resolvePreconditionRef(r[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof ar.IRI)return e;if(e instanceof Gt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,r){let i=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_uid")),s=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(r>=Hl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||l.length>0||c.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||l.length>0){let _=o.length>0?"all":"any",y=o.length>0?o:l,b=[];for(let S of y)b.push(await this.loadChildPrecondition(S.object,p,r+1));return{id:i??"",label:s,composite:{op:_,children:b}}}let h=await this.loadChildPrecondition(c[0].object,p,r+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,te.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,r){let i=await this.resolvePreconditionRef(e);if(!i){let l=e instanceof Gt.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(l,"")}let s=await this.loadPreconditionSubject(i,t,r);if(s)return s;let o=await this.getLiteralValue(i,te.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let r=t[0].object;if(r instanceof ar.IRI)return await this.getLiteralValue(r,te.Namespace.EXO.term("Asset_uid"))??void 0;if(r instanceof Gt.Literal)return this.normalizeWikilink(r.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,r){if(t>=Hl)return null;let i=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!r?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let l=await this.resolveGroundingRef(o.object);if(!l)continue;let c=await this.getObsidianName(l,te.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(c&&this.matchesReference(c,r.targetClass))return this.loadGroundingDefinition(l,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${r.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof ar.IRI)return e;if(e instanceof Gt.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>=Hl)return null;let r=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_uid"));if(!r)return null;let i=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let B=await this.resolveLabelByUID(o);if(!B)return this.logger.warn(`Grounding ${r}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=B}if(s===H3.GroundingType.SERVICE_CALL){let B=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_serviceId"));B&&(o=B)}let l=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetValueRef")),c=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let B=await this.resolveLabelByUID(u);if(!B)return this.logger.warn(`Grounding ${r}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=B}else u&&(f=u);let d=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),_=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_appendExpression")),y=await this.getObsidianWikilinkValue(e,te.Namespace.EXOCMD.term("Grounding_isDefinedBy")),b=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),S=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetClass"));if(S&&!this.looksLikeUUID(S)){let B=await this.findUidByLabel(S);B&&(S=B)}let I=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetPrototype")),O=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_targetFolder")),T=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_linkBackProperty")),E=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_inputSchema")),P=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_incrementBy")),V=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_shiftDelta")),M;if(P!=null&&P!==""){let B=Number.parseInt(String(P),10);Number.isFinite(B)&&(M=B)}let j=await this.resolvePropertyDefaults(e,r),$=await this.resolveInheritanceRules(e,r),G=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_propertyDefaults"));G!==null&&G!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(r)&&(this.logger.warn(`Grounding ${r}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(r));let ge;s===H3.GroundingType.COMPOSITE&&(ge=await this.loadCompositeSteps(e,t+1));let ye;if(E)try{let B=JSON.parse(E);B?.properties&&(ye=Object.entries(B.properties).map(([oe,Ee])=>{let Ce=Ee.type,xe=Ce==="string"?"text":Ce,Oe=Ee.defaultValue!==void 0?Ee.defaultValue:Ee.default,Re={name:oe,type:xe,label:Ee.title??oe,required:Array.isArray(B.required)&&B.required.includes(oe)};return Oe!=null&&(Re.defaultValue=String(Oe)),typeof Ee.targetClassUid=="string"&&(Re.targetClassUid=Ee.targetClassUid),Re}))}catch{}let Q=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),se=Q!==null&&String(Q).trim().toLowerCase()==="true",J=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_labelTemplate")),ve=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_direction")),re;if(ve!=null){let B=String(ve).trim().toLowerCase();B==="forward"||B==="rollback"?re=B:B!==""&&this.logger.warn(`Grounding ${r}: exocmd__Grounding_direction value '${ve}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let ie=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_bodyTemplate")),he=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_templateRef")),Ue=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),ce=Ue!==null&&String(Ue).trim().toLowerCase()==="true",ue=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),fe=ue!==null&&String(ue).trim().toLowerCase()==="true",ne=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_omitLabel")),me=ne!==null&&String(ne).trim().toLowerCase()==="true",Le={id:r,label:i,type:s,targetProperty:o??void 0,targetValueRef:l??void 0,targetValueLiteral:c??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:_??void 0,sparqlUpdate:b??void 0,steps:ge,targetClass:S??void 0,targetPrototype:I??void 0,targetFolder:O??void 0,linkBackProperty:T??void 0,incrementBy:M,shiftDelta:V??void 0,propertyDefault:j.length>0?j:void 0,inheritanceRule:$.length>0?$:void 0,isDefinedBy:y??void 0,prefillLabelWithDate:se||void 0,labelTemplate:J??void 0,direction:re,bodyTemplate:ie??void 0,templateRef:he??void 0,cloneTargetBody:ce||void 0,targetsCreatedInstance:fe||void 0,omitLabel:me||void 0};return ye&&(Le.inputSchema=ye),Le}async loadCompositeSteps(e,t){if(t>=Hl)return[];let r=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of r){let o=null;if(s.object instanceof ar.IRI)o=s.object;else if(s.object instanceof Gt.Literal){let c=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(c)}if(!o)continue;let l=await this.loadGroundingDefinition(o,t);l&&i.push(l)}return i}async resolvePropertyDefaults(e,t){let r=await this.resolvePropertyDefaultsForSubject(e,t,te.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,fy.mergePropertyDefaults)(i.propertyDefaults,r):r}async resolvePropertyDefaultsForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[];for(let o of i){let l=await this.resolveRefTripleObject(o.object);if(!l)continue;let c=await this.getObsidianName(l,te.Namespace.EXOCMD.term("PropertyDefault_property"));if(!c){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(c)?await this.resolveLabelByUID(c):c;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${c}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(l,te.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.logger.warn(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await(0,fy.loadUniversalDefault)();if(e)return this._universalCacheValue=e,e;let t=await this.findUniversalSingleton();if(!t)return this._universalCacheValue=null,null;let r=await this.resolvePropertyDefaultsForSubject(t,J3,te.Namespace.EXOCMD.term("Template_propertyDefault")),i=await this.resolveInheritanceRulesForSubject(t,J3,te.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:r,inheritanceRules:i},this._universalCacheValue}async findUniversalSingleton(){let e=te.Namespace.EXOCMD.term("UniversalDefaultTemplate").value,t=await this.tripleStore.match(void 0,te.Namespace.EXO.term("Instance_class"),void 0),r=[];for(let i of t){let s=!1;if(i.object instanceof ar.IRI)s=i.object.value===e||i.object.value.includes(X3);else if(i.object instanceof Gt.Literal){let o=this.unwrapWikilink(i.object.value);s=o==="exocmd__UniversalDefaultTemplate"||o===X3}s&&i.subject instanceof ar.IRI&&r.push(i.subject)}return r.length===0?null:(r.length===1||(r.sort((i,s)=>i.value.localeCompare(s.value)),this.logger.warn(`Multiple UniversalDefaultTemplate singletons found (${r.length}); selecting deterministically by lexicographic UID order: ${r[0].value}`)),r[0])}async resolveInheritanceRules(e,t){let r=await this.resolveInheritanceRulesForSubject(e,t,te.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,fy.mergeInheritanceRules)(i.inheritanceRules,r):r}async resolveInheritanceRulesForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[],o=t;for(let l of i){let c=await this.resolveRefTripleObject(l.object);if(!c)continue;let u=await this.resolveLabelRef(c,te.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(c,te.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(c,te.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let T=await this.getObsidianName(c,te.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!T||!T.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(T)?(h=T,p=await this.resolveLabelByUID(T)??void 0):p=T}let _=await this.tripleStore.match(c,te.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),y=[],b=[],S=!1;for(let T of _){let E=null;if(T.object instanceof ar.IRI?E=this.iriToObsidianName(T.object.value)??T.object.value:T.object instanceof Gt.Literal&&(E=this.unwrapWikilink(T.object.value)),!E){S=!0;continue}if(this.looksLikeUUID(E)){b.push(E);let P=await this.resolveLabelByUID(E);P&&y.push(P)}else y.push(E)}if(S){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 I=await this.getLiteralValue(c,te.Namespace.EXOCMD.term("InheritanceRule_priority")),O=50;if(I!==null&&I!==""){let T=Number.parseInt(String(I),10);Number.isFinite(T)&&(O=T)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:y,targetClassExclusionUids:b,priority:O})}return s}async resolveRefTripleObject(e){if(e instanceof ar.IRI)return e;if(e instanceof Gt.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let r=await this.getObsidianName(e,t);return r?this.looksLikeUUID(r)?this.resolveLabelByUID(r):r:null}async resolvePropertyDefaultValue(e,t,r){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let l=`${t}|${e}`;return this._fallbackWarnedKeys.has(l)||(this._fallbackWarnedKeys.add(l),this.logger.warn(this.capWarning(`Grounding ${t}: PropertyDefault '${r}' \u2192 value asset ${e} not in store; emitting wikilink (a link, not the substituted value).`))),`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,r):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,r,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${r}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,r,i,s){let o=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let l=o.trim();return Y3.has(l)?s!==void 0?MW(l,t,s):kW(l,t):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${l}' \u2014 falling back to wikilink form. Known ids: ${Array.from(Y3).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,r,i){let s=await this.getObsidianName(e,te.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let l=await this.findSubjectByUID(s);return l?this.dispatchSubstitutionToken(l,s,r,i,o):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,te.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof ar.IRI){if(i.object.value===jW||i.object.value.includes(Q3))return!0}else if(i.object instanceof Gt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===Q3)return!0}return(await this.tripleStore.match(e,te.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,te.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof ar.IRI){if(i.object.value===NW||i.object.value.includes(K3))return!0}else if(i.object instanceof Gt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===K3)return!0}return(await this.tripleStore.match(e,te.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,te.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let r=t[0].object;if(r instanceof ar.IRI)return(0,z3.resolveGroundingTypeFromIRI)(r.value);if(r instanceof Gt.Literal){let i=r.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,z3.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],r=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Hl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let l=null;try{let u=await this.findSubjectByUID(o);if(!u)break;l=await this.getLinkedValue(u,te.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(!l)break;let c=this.normalizeWikilink(l).toLowerCase();if(r.has(c))break;r.add(c),t.push(l),i=l}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let r=this.extractPathBasename(t);return r&&this.looksLikeUUID(r)?r:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let r=await this.tripleStore.findSubjectsByUUID(e);if(r.length>0)return r[0]}let t=await this.tripleStore.match(void 0,te.Namespace.EXO.term("Asset_uid"),void 0);for(let r of t)if(r.object instanceof Gt.Literal&&r.object.value===e)return r.subject;return null}async getLiteralValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Gt.Literal||i instanceof ar.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);return t?this.getLiteralValue(t,te.Namespace.EXO.term("Asset_label")):null}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(r=>r.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let r=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),l=await this.getLiteralValue(s,te.Namespace.EXO.term("Asset_uid"));l&&o.add(l);let c=await this.getLiteralValue(s,te.Namespace.EXO.term("Asset_label"));c&&o.add(c);let u=a((p,h)=>{if(o.has(p))return;let _=r.get(p);(_===void 0||h<_)&&r.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:_}=p;if(_>=Hl||i.has(h.value))continue;i.add(h.value);let y=await this.tripleStore.match(h,te.Namespace.EXO.term("Class_superClass"),void 0);for(let b of y){let S=b.object;if(!(S instanceof ar.IRI))continue;let I=_+1,O=S.value.startsWith("obsidian://vault/"),T=this.iriToObsidianName(S.value);T&&u(T,I);let E=null;if(O?E=S:T&&(E=await this.resolveClassFileIRI(T)),!E)continue;let P=await this.getLiteralValue(E,te.Namespace.EXO.term("Asset_uid"));P&&u(P,I),i.has(E.value)||f.push({fileIRI:E,depth:I})}}let d=Array.from(r.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,te.Namespace.EXO.term("Asset_label"),void 0);for(let r of t)if(r.object instanceof Gt.Literal&&r.object.value===e&&r.subject instanceof ar.IRI){let i=await this.tripleStore.match(r.subject,te.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Gt.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof ar.IRI){let s=await this.tripleStore.match(i,te.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Gt.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Gt.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let r=await this.tripleStore.match(e,t,void 0),i=[];for(let s of r){let o=s.object;if(o instanceof ar.IRI){let l=await this.tripleStore.match(o,te.Namespace.EXO.term("Asset_uid"),void 0);if(l.length>0&&l[0].object instanceof Gt.Literal)i.push(l[0].object.value);else{let c=o.value.split("/").pop()?.replace(".md","");c&&i.push(c)}}else if(o instanceof Gt.Literal){let l=this.normalizeWikilink(o.value);l&&i.push(l)}}return i}async getLinkedValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Gt.Literal?this.normalizeWikilink(i.value):i instanceof ar.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Gt.Literal?this.unwrapWikilink(i.value):i instanceof ar.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let r=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(r)return r[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof Gt.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof ar.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let r=t[1],i=await this.findSubjectByUID(r);if(!i)return e;let s=await this.getLiteralValue(i,te.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${r}]]`,`[[${r}|${s}]]`):e}iriToObsidianName(e){return(0,OW.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(0,r):t}};Co.CommandResolver=zE;Co.CommandResolver=zE=AW([(0,xW.injectable)(),IW("design:paramtypes",[Object,Object])],zE)});var YE=v(KE=>{"use strict";Object.defineProperty(KE,"__esModule",{value:!0});KE.validateExoQLAllowlist=$W;var py=qd();function $W(n){if(!n||typeof n!="object")return;let e=n;if(e.type==="update"){let t=n.updates??[];for(let r of t)if(r?.type==="load")throw new py.ExoQLForbiddenKeywordError("LOAD");throw new py.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,r=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||r)throw new py.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)hy(t);if(Array.isArray(e.template))for(let t of e.template)hy(t)}}a($W,"validateExoQLAllowlist");function hy(n){if(!n||typeof n!="object")return;if(n.type==="service")throw new py.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(n.patterns))for(let t of n.patterns)hy(t);let e=n.where;if(Array.isArray(e))for(let t of e)hy(t)}a(hy,"walkPatternForBannedKeywords")});var QE=v(my=>{"use strict";Object.defineProperty(my,"__esModule",{value:!0});my.DEFAULT_EVAL_CONFIG=void 0;my.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var gy=v(XE=>{"use strict";Object.defineProperty(XE,"__esModule",{value:!0});XE.evaluateWithExoEval=HW;var UW=Jc(),BW=nu(),VW=Eu(),qW=YE(),GW=QE(),WW=qd();async function HW(n,e={}){if(typeof n!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let r=new UW.ExoQLParser().parse(n);if((0,qW.validateExoQLAllowlist)(r),!{...GW.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new WW.ExoQLEvalDisabledError;let s="queryType"in r&&typeof r.queryType=="string"?r.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let l=new BW.ExoQLAlgebraTranslator().translate(r),c=new VW.ExoQLQueryExecutor(e.store);return c.isAskQuery(l)?{kind:"ask",result:await c.executeAsk(l)}:c.isConstructQuery(l)?{kind:"construct",triples:await c.executeConstruct(l)}:{kind:"select",rows:await c.executeAll(l)}}a(HW,"evaluateWithExoEval")});var zi=v(yy=>{"use strict";Object.defineProperty(yy,"__esModule",{value:!0});yy.DateFormatter=void 0;var JE=class n{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}-${r}-${i}T${s}:${o}:${l}`}static toDateWikilink(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${r}-${i}]]"`}static getTodayWikilink(){return n.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${i}`}static parseWikilink(e){let r=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return r?r[1]:null}static addDays(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),n.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[r,i,s]=t,o=new Date(r,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return n.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return n.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};yy.DateFormatter=JE});var Wd=v(_y=>{"use strict";Object.defineProperty(_y,"__esModule",{value:!0});_y.liveClock=zW;_y.frozenClock=KW;function zW(){return{now:a(()=>new Date,"now")}}a(zW,"liveClock");function KW(n){let e=new Date(n);return{now:a(()=>new Date(e.getTime()),"now")}}a(KW,"frozenClock")});var tD=v(Oo=>{"use strict";var YW=Oo&&Oo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},QW=Oo&&Oo.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},zd;Object.defineProperty(Oo,"__esModule",{value:!0});Oo.PreconditionEvaluator=void 0;var XW=ut(),JW=Jc(),ZW=nu(),eD=Eu(),eH=gy(),Hd=zi(),tH=Wd(),Kd=zd=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,r){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=r?.clock??(0,tH.liveClock)()}async evaluate(e,t,r){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,r,i)==="yes"}async evaluateNode(e,t,r,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let l=await Promise.all(o.map(c=>this.evaluateNode(c,t,r,i)));return s==="all"?l.includes("no")?"no":l.includes("unknown")?"unknown":"yes":l.includes("yes")?"yes":l.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,r,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,r)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,r){let i=r.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return r.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let r=await this.queryBodyResolver.resolveSparql(e);if(!r)return!1;let i=this.substituteVariables(r,t),s=await(0,eH.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,r){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,r):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,zd.SENTINEL_IRI),i=new JW.ExoQLParser().parse(t),o=new ZW.ExoQLAlgebraTranslator().translate(i);return new eD.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,r){let i=this.hostFunctions.get(e);if(!i)return!0;let s=r?{...r,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let r=zd.TEMPORAL_TOKEN.test(e),i=r?Hd.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||r&&s.day!==i){let c=this.compileAsk(e);if(!c)return!1;s={day:i,compiled:c},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll(zd.SENTINEL_IRI,t));return await new eD.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let r=this.clock.now(),i=r.toISOString(),s=r.getFullYear(),o=r.getMonth(),l=r.getDate(),c=r.getDay(),u=Hd.DateFormatter.toDateString(r),f=Hd.DateFormatter.toDateString(new Date(s,o,l-1)),d=(c+6)%7,p=Hd.DateFormatter.toDateString(new Date(s,o,l-d)),h=Hd.DateFormatter.toDateString(new Date(s,o,l-d-7)),_=`${s}-${String(o+1).padStart(2,"0")}-01`,y=o===0?11:o-1,S=`${o===0?s-1:s}-${String(y+1).padStart(2,"0")}-01`,I=`${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,`"${_}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${S}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${I}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};Oo.PreconditionEvaluator=Kd;Kd.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Kd.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;Oo.PreconditionEvaluator=Kd=zd=YW([(0,XW.injectable)(),QW("design:paramtypes",[Object,Object,Object])],Kd)});var rD=v(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.hasUidFilename=Po.hasNonUidFilename=void 0;Po.registerDefaultHostFunctions=iH;var rH=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");Po.hasNonUidFilename=rH;var nH=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");Po.hasUidFilename=nH;function iH(n){n.registerHostFunction("hasNonUidFilename",Po.hasNonUidFilename),n.registerHostFunction("hasUidFilename",Po.hasUidFilename)}a(iH,"registerDefaultHostFunctions")});var Sy=v(by=>{"use strict";Object.defineProperty(by,"__esModule",{value:!0});by.liveUidGenerator=sH;by.seededUidGenerator=aH;var ZE=Ol();function sH(){return{next:a(()=>(0,ZE.v4)(),"next")}}a(sH,"liveUidGenerator");var oH="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function aH(n){let e=0,t=(0,ZE.v5)(n,oH);return{next:a(()=>{let r=`${n}#${e}`;return e+=1,(0,ZE.v5)(r,t)},"next")}}a(aH,"seededUidGenerator")});var vy=v(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});Da.registerResolver=lr;Da.getResolver=cH;Da.isResolverModifierAware=uH;Da.getRegisteredResolverIds=fH;Da.clearResolvers=dH;Da.installDefaultResolvers=EH;var lH=zi(),Ey=new Map,ev=new Set;function lr(n,e,t=!1){Ey.set(n,e),t&&ev.add(n)}a(lr,"registerResolver");function cH(n){return Ey.get(n)}a(cH,"getResolver");function uH(n){return ev.has(n)}a(uH,"isResolverModifierAware");function fH(){return Array.from(Ey.keys())}a(fH,"getRegisteredResolverIds");function dH(){Ey.clear(),ev.clear()}a(dH,"clearResolvers");function cn(n){return n<10?`0${n}`:String(n)}a(cn,"pad2");var pH=["January","February","March","April","May","June","July","August","September","October","November","December"],hH=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mH=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],gH=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function yH(n){let e=["th","st","nd","rd"],t=n%100;return`${n}${e[(t-20)%10]||e[t]||e[0]}`}a(yH,"ordinalDay");var _H=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function bH(n,e){let t=(n.getHours()+11)%12+1;return e.replace(_H,r=>{switch(r){case"YYYY":return String(n.getFullYear());case"YY":return cn(n.getFullYear()%100);case"MMMM":return pH[n.getMonth()];case"MMM":return hH[n.getMonth()];case"MM":return cn(n.getMonth()+1);case"M":return String(n.getMonth()+1);case"Do":return yH(n.getDate());case"DD":return cn(n.getDate());case"D":return String(n.getDate());case"dddd":return mH[n.getDay()];case"ddd":return gH[n.getDay()];case"HH":return cn(n.getHours());case"H":return String(n.getHours());case"hh":return cn(t);case"h":return String(t);case"mm":return cn(n.getMinutes());case"m":return String(n.getMinutes());case"ss":return cn(n.getSeconds());case"s":return String(n.getSeconds());case"A":return n.getHours()<12?"AM":"PM";case"a":return n.getHours()<12?"am":"pm";default:return r}})}a(bH,"formatDate");function nD(n,e,t){let r=n.getDate(),i=new Date(n.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(r,s)),i}a(nD,"addMonthsClamped");function SH(n,e){if(!e)return n;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return n;let r=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(n.getTime());switch(i){case"d":s.setDate(s.getDate()+r);break;case"w":s.setDate(s.getDate()+r*7);break;case"M":s=nD(s,r,"M");break;case"y":s=nD(s,r,"y");break}return isNaN(s.getTime())?n:s}a(SH,"applyDateOffset");function wH(n){if(!n)return{offset:null,format:null};let e=n.indexOf(":");if(e<0)return{offset:n,format:null};let t=n.slice(0,e),r=n.slice(e+1);return{offset:t||null,format:r||null}}a(wH,"parseDateModifier");function wy(n,e){return(t,r)=>{let{offset:i,format:s}=wH(r),o=new Date;return n!==0&&o.setDate(o.getDate()+n),o=SH(o,i),bH(o,s??e)}}a(wy,"makeDateResolver");function EH(){lr("today",()=>{let n=new Date;return`${n.getFullYear()}-${cn(n.getMonth()+1)}-${cn(n.getDate())}`}),lr("todayStart",()=>lH.DateFormatter.getTodayStartTimestamp()),lr("date",wy(0,"YYYY-MM-DD"),!0),lr("now",wy(0,"YYYY-MM-DDTHH:mm:ss"),!0),lr("tomorrow",wy(1,"YYYY-MM-DD"),!0),lr("yesterday",wy(-1,"YYYY-MM-DD"),!0),lr("target",n=>n.targetIRI?`"[[${n.targetIRI}]]"`:""),lr("targetFolder",n=>{if(!n.targetFilePath)return"";let e=n.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),lr("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.")}),lr("nowTimestamp",()=>{let n=new Date;return`${n.getFullYear()}-${cn(n.getMonth()+1)}-${cn(n.getDate())}T${cn(n.getHours())}:${cn(n.getMinutes())}:${cn(n.getSeconds())}`}),lr("nowDate",()=>{let n=new Date;return`${n.getFullYear()}-${cn(n.getMonth()+1)}-${cn(n.getDate())}`}),lr("nowYear",()=>String(new Date().getFullYear())),lr("nowMonth",()=>cn(new Date().getMonth()+1)),lr("userInputLabel",n=>{let e=n.userInput?.label;return typeof e=="string"?e:""}),lr("userInput",(n,e)=>{if(!e)return null;let t=n.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),lr("targetProperty",(n,e)=>{if(!e||!n.targetFm)return null;let t=n.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),lr("targetRefProperty",(n,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let r=e.slice(0,t),i=e.slice(t+1);if(!r||!i)return null;let s=n.targetRefFm?.[r];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),lr("labelAsArray",n=>{let e=n.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),lr("groundingTargetClass",n=>n.groundingTargetClassUid?`"[[${n.groundingTargetClassUid}]]"`:null),lr("targetClassSelf",n=>{if(!n.targetFilePath)return null;let e=n.targetFilePath.replace(/^\/+/,""),r=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return r.length>0?`"[[${r}]]"`:null})}a(EH,"installDefaultResolvers")});var rv=v(Ty=>{"use strict";Object.defineProperty(Ty,"__esModule",{value:!0});Ty.resolveTemplateBody=TH;Ty.stripTemplateFrontmatter=AH;var tv=vy();(0,tv.installDefaultResolvers)();var vH=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function TH(n,e={}){return n.replace(vH,(t,r,i)=>{let s=(0,tv.getResolver)(r);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,tv.isResolverModifierAware)(r)?o:o+i})}a(TH,"resolveTemplateBody");function AH(n){let e=n.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?n.slice(e[0].length):n}a(AH,"stripTemplateFrontmatter")});var xy=v(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});Tu.registerOrderSpecLoader=IH;Tu.clearOrderSpecLoader=xH;Tu.loadDefaultSpec=RH;Tu.orderProperties=CH;var Ay=null,Fa,Iy=!1;function IH(n){Ay=n,Fa=void 0,Iy=!1}a(IH,"registerOrderSpecLoader");function xH(){Ay=null,Fa=void 0,Iy=!1}a(xH,"clearOrderSpecLoader");function RH(){if(Fa!==void 0)return Fa;if(!Ay)return Fa=null,null;try{Fa=Ay()}catch(n){Iy||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",n),Iy=!0),Fa=null}return Fa}a(RH,"loadDefaultSpec");function CH(n,e){if(!e||e.head.length===0&&e.tail.length===0)return n;let t=Object.keys(n),r=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),l=t.filter(u=>!r.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&l.sort((u,f)=>u.localeCompare(f));let c={};for(let u of s)c[u]=n[u];for(let u of l)c[u]=n[u];for(let u of o)c[u]=n[u];return c}a(CH,"orderProperties")});var Yd=v(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});zl.STRING_SCALAR_PROPERTIES=void 0;zl.needsYamlQuoting=iD;zl.quoteYamlString=sD;zl.serializeYamlScalar=$H;var OH=/^[-!&*?|>%@`"'#,[\]{}]/,PH=/[\u0000-\u001f\u007f]/,DH=/^(?:true|True|TRUE|false|False|FALSE)$/,FH=/^(?:null|Null|NULL|~)$/,LH=/^[-+]?(?:0b[01_]+|0o[0-7_]+|0x[0-9a-fA-F_]+|[0-9][0-9_]*)$/,NH=/^(?:[-+]?[0-9][0-9_]*(?:\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/,kH=/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;zl.STRING_SCALAR_PROPERTIES=new Set(["exo__Asset_label","aliases"]);function MH(n){if(n.length<2||!n.startsWith('"')||!n.endsWith('"'))return!1;let e=n.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(MH,"isCompleteDoubleQuotedScalar");function jH(n){return DH.test(n)||FH.test(n)||LH.test(n)||NH.test(n)||kH.test(n)}a(jH,"looksLikeNonStringScalar");function iD(n,e=!1){return n===""?!0:MH(n)?!1:!!(n!==n.trim()||/:(\s|$)/.test(n)||/\s#/.test(n)||OH.test(n)||PH.test(n)||e&&jH(n))}a(iD,"needsYamlQuoting");function sD(n){let e="";for(let t=0;t<n.length;t++){let r=n[t],i=n.charCodeAt(t);r==="\\"?e+="\\\\":r==='"'?e+='\\"':r===`
72
- `?e+="\\n":r==="\r"?e+="\\r":r===" "?e+="\\t":i<32||i===127?e+="\\x"+i.toString(16).toUpperCase().padStart(2,"0"):e+=r}return`"${e}"`}a(sD,"quoteYamlString");function $H(n,e=!1){return typeof n!="string"?String(n):iD(n,e)?sD(n):n}a($H,"serializeYamlScalar")});var Nn=v(Ry=>{"use strict";Object.defineProperty(Ry,"__esModule",{value:!0});Ry.DI_TOKENS=void 0;Ry.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 iv=v(Cy=>{"use strict";Object.defineProperty(Cy,"__esModule",{value:!0});Cy.RDFVocabularyMapper=void 0;var yr=Qn(),oD=ze(),Fe=Vt(),nv=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",Fe.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",Fe.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",Fe.Namespace.RDFS.term("subClassOf")],["exo__Property_range",Fe.Namespace.RDFS.term("range")],["exo__Property_domain",Fe.Namespace.RDFS.term("domain")],["exo__Property_superProperty",Fe.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new yr.Triple(Fe.Namespace.EXO.term("Asset"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.RDFS.term("Resource"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Class"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.RDFS.term("Class"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.RDF.term("Property"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Task"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Project"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Area"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Workflow"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("WorkflowState"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("WorkflowTransition"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("Command"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("Precondition"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("Grounding"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("CommandBinding"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new yr.Triple(Fe.Namespace.EXO.term("Instance_class"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDF.term("type"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Asset_isDefinedBy"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("isDefinedBy"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Class_superClass"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("subClassOf"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property_range"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("range"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property_domain"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("domain"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property_superProperty"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof oD.IRI)s=r;else{let o=r.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,l,c]=o;s=(l==="ems"?Fe.Namespace.EMS:l==="exocmd"?Fe.Namespace.EXOCMD:Fe.Namespace.EXO).term(c)}else s=new oD.IRI(r)}return new yr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};Cy.RDFVocabularyMapper=nv});var Oy=v(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.OBSIDIAN_VAULT_SCHEME=void 0;Do.vaultPathToIRI=UH;Do.iriToVaultPath=BH;Do.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function UH(n){let e=n.startsWith("./")?n.slice(2):n;return`${Do.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(UH,"vaultPathToIRI");function BH(n){if(!n.startsWith(Do.OBSIDIAN_VAULT_SCHEME))return null;let e=n.slice(Do.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(BH,"iriToVaultPath")});var Dy=v(Qd=>{"use strict";Object.defineProperty(Qd,"__esModule",{value:!0});Qd.derivePath=aD;Qd.deriveUrl=VH;Qd.deriveLegacyFlatPath=qH;var sv="assetspaces",Py=/^[A-Za-z0-9._-]+$/;function aD(n){if(typeof n!="string")return null;let e=n.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 l=o.indexOf("/");if(l<0)return null;t=o.slice(l+1)}let r=t.split("/").filter(o=>o.length>0);if(r.length<2)return null;let i=r[0],s=r[1];return i==="."||i===".."||s==="."||s===".."||!Py.test(i)||!Py.test(s)?null:`${sv}/${i}/${s}`}a(aD,"derivePath");function VH(n){if(typeof n!="string")return null;let e=n.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${sv}/`;if(!e.startsWith(t))return null;let r=e.slice(t.length).split("/").filter(o=>o.length>0);if(r.length<2)return null;let i=r[0],s=r[1];return i==="."||i===".."||s==="."||s===".."||!Py.test(i)||!Py.test(s)?null:`https://github.com/${i}/${s}`}a(VH,"deriveUrl");function qH(n){let e=aD(n);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let r=t.startsWith("exoas-")?t.slice(6):t;return r.length===0?null:`${sv}/${r}`}a(qH,"deriveLegacyFlatPath")});var Fy=v(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});Ki.FILE_SPACE_CLASS_UID=void 0;Ki.frontmatterDeclaresFileSpace=WH;Ki.discoverFileSpaceExclusions=zH;var GH=Dy();Ki.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var lD=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,ov=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function uD(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(typeof r!="string")continue;lD.lastIndex=0;let i;for(;(i=lD.exec(r))!==null;)t.push(i[1].trim())}return t}a(uD,"wikilinkTargets");function WH(n){return n?uD(n.exo__Instance_class).some(e=>ov.test(e)&&e.toLowerCase()===Ki.FILE_SPACE_CLASS_UID):!1}a(WH,"frontmatterDeclaresFileSpace");function cD(n,e){try{return n.getFrontmatter(e)}catch{return null}}a(cD,"readFrontmatterSafe");function HH(n){let e=n.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=n.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(HH,"readSource");function zH(n){let e=[],t=[],r=[],i=new Map,s=a((l,c)=>{if(ov.test(l))return l.toLowerCase()===Ki.FILE_SPACE_CLASS_UID;let u=n.getFirstLinkpathDest(l,c);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=cD(n,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===Ki.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(l=>l.some(c=>ov.test(c)&&c.toLowerCase()===Ki.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let l of n.getAllFiles()){let c=cD(n,l);if(!c)continue;let u=uD(c.exo__Instance_class);if(!u.some(h=>s(h,l.path)))continue;t.push(l.path),o(u)||r.push(`FileSpace declaration ${l.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Ki.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=HH(c);if(f===null){r.push(`FileSpace declaration ${l.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,GH.derivePath)(f);if(d===null){r.push(`FileSpace declaration ${l.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;l.path.startsWith(p)&&r.push(`FileSpace declaration ${l.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:r}}a(zH,"discoverFileSpaceExclusions")});var Yl=v(Lr=>{"use strict";var KH=Lr&&Lr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},YH=Lr&&Lr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},fD=Lr&&Lr.__param||function(n,e){return function(t,r){e(t,r,n)}},cv;Object.defineProperty(Lr,"__esModule",{value:!0});Lr.NoteToRDFConverter=Lr.UNPREFIXED_ASSET_FIELDS=void 0;Lr.canonicalYamlKey=ez;Lr.normaliseExcludedFolders=hD;Lr.isPathExcluded=mD;var av=ut(),_r=Qn(),Yi=ze(),yn=tt(),dD=Yt(),rr=Vt(),pD=Nn(),QH=iv(),XH=Fd(),lv=Oy(),ri=Gw(),JH=Fy();Lr.UNPREFIXED_ASSET_FIELDS=new Set(["archived","draft","pinned","aliases"]);var ZH=/^exo__Asset_(.+)$/;function ez(n){let e=ZH.exec(n);return e&&Lr.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:n}a(ez,"canonicalYamlKey");function hD(n){return Array.isArray(n)?n.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(hD,"normaliseExcludedFolders");function mD(n,e){if(e.length===0)return!1;let t=n.replace(/\\/g,"/");for(let r of e)if(t.startsWith(r))return!0;return!1}a(mD,"isPathExcluded");function tz(n){if(!n)return"";let e=n.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(tz,"normaliseSubjectIriPrefix");var Kl=cv=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=XH.NullLogger,r={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new QH.RDFVocabularyMapper,this.subjectIriPrefix=tz(r.subjectIriPrefix),this.emitInstanceClassAsUid=r.emitInstanceClassAsUid??!1}async convertNote(e){return this.convertNoteFromFrontmatter(e,this.vault.getFrontmatter(e))}async convertNoteFromFrontmatter(e,t){if(!t)return[];let r=this.notePathToIRI(e.path),i=rr.Namespace.EXO.term("Asset_filename"),s=new _r.Triple(r,i,new yn.Literal(e.basename));if(ri.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,r){this.pendingExtraTriples=[];let i=[r],s=this.notePathToIRI(e.path),o,l,c,u=!1,f=rr.Namespace.EXO.term("Statement").value;for(let[y,b]of Object.entries(t)){let S=Lr.UNPREFIXED_ASSET_FIELDS.has(y)?`exo__Asset_${y}`:y;if(!this.isExocortexProperty(S))continue;let I=this.propertyKeyToIRI(S),O=Array.isArray(b)?b:[b];for(let T of O)if(!((y==="exo__Asset_label"||Lr.UNPREFIXED_ASSET_FIELDS.has(y))&&(T==null||typeof T=="string"&&T.trim()==="")))if(y==="exo__Instance_class"){let E=this.valueToClassURI(T);i.push(new _r.Triple(s,I,E))}else{let E=await this.valueToRDFObject(T,e,I);if(S==="exo__Statement_subject"&&o===void 0){let P=E.find(V=>V instanceof Yi.IRI);P&&(o=P)}else if(S==="exo__Statement_predicate"&&l===void 0){let P=E.find(V=>V instanceof Yi.IRI);P&&(l=P)}else S==="exo__Statement_object"&&c===void 0&&(c=E[0]);for(let P of E)if(i.push(new _r.Triple(s,I,P)),this.vocabularyMapper.hasMappingFor(y)&&P instanceof Yi.IRI){let V=this.vocabularyMapper.generateMappedTriple(s,y,P);V&&i.push(V)}}if(y==="exo__Instance_class")for(let T of O){let E=this.valueToClassURI(T);if(E instanceof Yi.IRI){let P=rr.Namespace.RDF.term("type");i.push(new _r.Triple(s,P,E)),E.value===f&&(u=!0)}}if(y==="exo__Asset_label"){let T=rr.Namespace.RDFS.term("label");for(let E of O)typeof E=="string"&&E.length>0&&i.push(new _r.Triple(s,T,new yn.Literal(E)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let y=rr.Namespace.RDFS.term("label"),b=rr.Namespace.EXO.term("Asset_label"),S=new yn.Literal(e.basename);i.push(new _r.Triple(s,y,S)),i.push(new _r.Triple(s,b,S))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&l&&c&&i.push(new _r.Triple(o,l,c));let _=await this.convertBodyWikilinks(e,s);return i.push(..._),i}async convertExo003Note(e,t){let r=ri.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case ri.Exo003MetadataType.Namespace:break;case ri.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case ri.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case ri.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case ri.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new Yi.IRI(t.uri);return[new _r.Triple(r,rr.Namespace.OWL.term("sameAs"),i),new _r.Triple(i,rr.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new _r.Triple(r,rr.Namespace.OWL.term("sameAs"),new dD.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=ri.Exo003Parser.toTriple(t,i);r.push(s);let o=this.notePathToIRI(e.path);r.push(new _r.Triple(o,rr.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),l=o(t.subject),c=o(t.predicate);if(l.type==="literal")throw new Error("Body subject cannot be a literal");if(c.type!=="iri")throw new Error("Body predicate must be an IRI");let u=l.type==="iri"?new Yi.IRI(l.value):new dD.BlankNode(l.value),f=new Yi.IRI(c.value),d=ri.Exo003Parser.toLiteral(t,s.trim());r.push(new _r.Triple(u,f,d));let p=this.notePathToIRI(e.path);r.push(new _r.Triple(p,rr.Namespace.RDF.term("value"),u))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.vault.getFrontmatter(s);if(o&&ri.Exo003Parser.isExo003Format(o)){let l=ri.Exo003Parser.parse(o);if(l.success&&l.metadata){let c=l.metadata;if(c.metadata===ri.Exo003MetadataType.Anchor||c.metadata===ri.Exo003MetadataType.Namespace)return{type:"iri",value:c.uri};if(c.metadata===ri.Exo003MetadataType.BlankNode)return{type:"blank",value:c.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!r&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1,o=0,l=0,c=(0,JH.discoverFileSpaceExclusions)(this.vault);for(let y of c.warnings)this.logger.warn(`FileSpace discovery: ${y}`);let u=[...hD(e.excludedFolders),...c.prefixes],f=u.length===0?t:t.filter(y=>!mD(y.path,u)),d=e.onProgress,p=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:cv.INDEX_PROGRESS_INTERVAL,h=f.length,_=0;for(let y of f){if(_++,d&&_%p===0&&_<h)try{d(_,h)}catch{}try{let b=this.vault.getFrontmatter(y),S=b?this.validateExocortexAsset(b,y.basename):null;if(S){if(s)throw new Error(`Invariant violation in "${y.path}": ${S.message}`);i.push({path:y.path,reason:`Invariant violation: ${S.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${y.path}`,{code:S.code,property:S.property,reason:S.message});continue}let I=await this.convertNote(y);r.push(...I)}catch(b){let S=b instanceof Error?b.message:String(b);if(s)throw new Error(`Invalid IRI for file "${y.path}": ${S}`);i.push({path:y.path,reason:`Invalid IRI: ${S}`}),l++,this.logger.info(`Skipping file with invalid IRI: ${y.path}`,{reason:S})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),l>0&&this.logger.warn(`Skipped ${l} file${l===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:l}),{triples:r,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length},fileSpaces:c}}static inferLabelFromBasename(e){return rr.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(r):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(r(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&r(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let l=e.exo__Instance_class,c=Array.isArray(l)?l:[l],u=null,f=!1;for(let d of c){if(typeof d!="string")continue;let p=this.removeQuotes(d),_=(this.extractWikilink(p)??p).trim();/^[a-z][a-zA-Z0-9]*__/.test(_)&&/[\s()]/.test(_)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=(0,lv.vaultPathToIRI)(r.path);Yi.IRI.isValidIRI(i)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new Yi.IRI((0,lv.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new Yi.IRI((0,lv.vaultPathToIRI)(e))}isExocortexProperty(e){return rr.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=rr.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let r=this.vault.getFrontmatter(t);if(!r)return;let i=r.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof Yi.IRI&&(this.pendingExtraTriples.push(new _r.Triple(e,rr.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new _r.Triple(e,rr.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e);if(r?.value.endsWith("#TokenInvocation_parameter"))return[new yn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let c=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new yn.Literal(u);if(r?.value.endsWith("#Grounding_targetValueRef")||r?.value.endsWith("#Grounding_targetValueSubstitution")||r?.value.endsWith("#Grounding_targetClass")||r?.value.endsWith("#Grounding_type")||r?.value.endsWith("#PropertyDefault_value"))return[c];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let _=this.vault.getFrontmatter(o);if(_){let O=_.exo__Asset_label;if(typeof O=="string"){let T=this.expandClassValue(O);if(T)return this.emitTypeTripleForEnumInstance(T,o),[T]}}let y=r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype"),S=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(O=>O.trim()).filter(Boolean),I=S.length>0&&S.some(O=>r?.value.endsWith(`#${O}`));return y||I?[c,d]:[c]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[c]}if(this.isClassReference(s)){let c=this.expandClassValue(s);if(c)return[c]}let l=s.includes("|")?s.split("|")[0]:s;return this.isUUID(l)?[this.synthesizeWikilinkTargetIRI(`${l}.md`)]:[new yn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new yn.Literal(i,rr.Namespace.XSD.term("dateTime"))]:[new yn.Literal(i)]}return typeof e=="boolean"?[new yn.Literal(e.toString())]:typeof e=="number"?[new yn.Literal(e.toString(),rr.Namespace.XSD.term("decimal"))]:e instanceof Date?[new yn.Literal(e.toISOString(),rr.Namespace.XSD.term("dateTime"))]:[new yn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1];return r.includes("|")?r.split("|")[0]:r}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1],i=r.indexOf("|");return i>=0?r.substring(i+1).trim():null}valueToClassURI(e){if(typeof e!="string")return new yn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let l=this.expandClassValue(o);if(l)return l}if(this.isUUID(i)){let l=this.vault.getFirstLinkpathDest(i,"");if(l){let c=this.expandClassValue(l.basename);if(c)return this.emitInstanceClassAsUid?this.notePathToIRI(l.path):c;let u=this.vault.getFrontmatter(l);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(l.path):d}}return this.notePathToIRI(l.path)}}return new yn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:rr.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),r=rr.Namespace.fromPropertyKey(t);return!r||/[\s()]/.test(r.localName)?null:r.namespace.term(r.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),l=rr.Namespace.EXO.term("Asset_bodyLink");for(let c of o){let u=this.vault.getFirstLinkpathDest(c,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new _r.Triple(t,l,f))}else if(this.isClassReference(c)){let f=this.expandClassValue(c);f?r.push(new _r.Triple(t,l,f)):r.push(new _r.Triple(t,l,new yn.Literal(c)))}else r.push(new _r.Triple(t,l,new yn.Literal(c)))}}catch{}return r}};Lr.NoteToRDFConverter=Kl;Kl.INDEX_PROGRESS_INTERVAL=200;Kl.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};Kl.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};Kl.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Lr.NoteToRDFConverter=Kl=cv=KH([(0,av.injectable)(),fD(0,(0,av.inject)(pD.DI_TOKENS.IVaultAdapter)),fD(1,(0,av.inject)(pD.DI_TOKENS.ILogger)),YH("design:paramtypes",[Object,Object,Object])],Kl)});var Ql=v(Ly=>{"use strict";Object.defineProperty(Ly,"__esModule",{value:!0});Ly.FrontmatterService=void 0;var gD=xy(),uv=Yd(),fv=Yl(),Xd=class n{static{a(this,"FrontmatterService")}parse(e){let t=e.match(n.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let r={},i=t.content.split(/\r?\n/),s=null,o=null,l=a(()=>{s!==null&&o!==null&&(r[s]=o),s=null,o=null},"flushArray");for(let c of i){let u=/^ {2}- (.*)$/.exec(c);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}l();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(c);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(s=d,o=[]):r[d]=p}return l(),r}updateProperty(e,t,r){t=(0,fv.canonicalYamlKey)(n.normalizeIRI(t)),typeof r=="string"&&(r=n.normalizeIRIValue(r));let i=this.parse(e),s=this.serializeValue(t,r);if(!i.exists)return`---
71
+ ${r}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let r=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?r+=`@${e.language}`:e.datatype&&(r+=`^^<${e.datatype}>`),r}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(r=>this.generateExpression(r)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),r=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${r})`:`${t} IN (${r})`}default:throw new bu(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let r of e.triples)this.collectVariablesFromTriple(r,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let r of e.variables)t.add(r);break;case"project":for(let r of e.variables)t.add(r);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let r of e.variables)t.add(r);for(let r of e.aggregates)t.add(r.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let r of e.operands)this.collectVariablesFromExpression(r,t);break;case"function":case"functionCall":for(let r of e.args)this.collectVariablesFromExpression(r,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let r of e.list)this.collectVariablesFromExpression(r,t);break}}};Su.SPARQLGenerator=HE});var Eu=v(ti=>{"use strict";var aW=ti&&ti.__createBinding||(Object.create?(function(n,e,t,r){r===void 0&&(r=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(n,r,i)}):(function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]})),lW=ti&&ti.__setModuleDefault||(Object.create?(function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}):function(n,e){n.default=e}),W3=ti&&ti.__importStar||(function(){var n=a(function(e){return n=Object.getOwnPropertyNames||function(t){var r=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[r.length]=i);return r},n(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=n(e),i=0;i<r.length;i++)r[i]!=="default"&&aW(t,e,r[i]);return lW(t,e),t}})();Object.defineProperty(ti,"__esModule",{value:!0});ti.QueryExecutor=ti.ExoQLQueryExecutor=ti.QueryExecutorError=void 0;var cW=hE(),uW=ry(),fW=FE(),dW=NE(),pW=O3(),hW=D3(),mW=k3(),gW=qE(),yW=j3(),_W=U3(),bW=q3(),SW=G3(),wW=ze(),EW=tt(),vW=Yg(),ln="http://www.w3.org/2001/XMLSchema#",TW=new Set([`${ln}integer`,`${ln}decimal`,`${ln}float`,`${ln}double`,`${ln}nonPositiveInteger`,`${ln}negativeInteger`,`${ln}long`,`${ln}int`,`${ln}short`,`${ln}byte`,`${ln}nonNegativeInteger`,`${ln}unsignedLong`,`${ln}unsignedInt`,`${ln}unsignedShort`,`${ln}unsignedByte`,`${ln}positiveInteger`]),wu=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};ti.QueryExecutorError=wu;var uy=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let r=t.resolveClassHierarchy===!1?e:new bW.ClassHierarchyResolvingStore(e);this.tripleStore=r,this.bgpExecutor=new cW.BGPExecutor(r),this.filterExecutor=new uW.FilterExecutor,this.optionalExecutor=new fW.OptionalExecutor,this.unionExecutor=new dW.UnionExecutor,this.minusExecutor=new pW.MinusExecutor,this.valuesExecutor=new hW.ValuesExecutor,this.aggregateExecutor=new mW.AggregateExecutor,this.constructExecutor=new gW.ConstructExecutor,this.serviceExecutor=new yW.ServiceExecutor(t.serviceConfig),this.graphExecutor=new _W.GraphExecutor(r),this.sparqlGenerator=new SW.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(r)}async evaluateExistsPattern(e,t){for await(let r of this.execute(e))if(t.merge(r)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let r of this.execute(e))t.push(r);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new wu(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let r=new Set;for(let o of t)for(let l of o.variables())r.add(l);let i=this.collectOperationVariables(e.right);if([...r].some(o=>i.has(o)))for(let o of t){let l=this.substituteVariables(e.right,o);for await(let c of this.execute(l)){let u=o.merge(c);u!==null&&(yield u)}}else{let o=[];for await(let l of this.execute(e.right))o.push(l);for(let l of t)for(let c of o){let u=l.merge(c);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let r=[];for await(let o of this.execute(e.right))r.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of r)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>W3(Ro())),r=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(r.has(o)){let l=i.get(o);l!==void 0&&s.set(o,l)}yield s}}async*executeOrderBy(e){let t=[];for await(let r of this.execute(e.input))t.push(r);t.sort((r,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,r),l=this.getExpressionValue(s.expression,i),c=0;if(o===void 0&&l===void 0?c=0:o===void 0?c=1:l===void 0?c=-1:typeof o=="number"&&typeof l=="number"?c=o-l:c=String(o).localeCompare(String(l)),s.descending&&(c=-c),c!==0)return c}return 0});for(let r of t)yield r}async*executeSlice(e){let t=0,r=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=r){if(i!==void 0&&t-r>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeReduced(e){let t=new Set;for await(let r of this.execute(e.input)){let i=this.getSolutionKey(r);t.has(i)||(t.add(i),yield r)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let r=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of r)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of r)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let r of this.execute(e.input)){let i=r.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,r):this.evaluateExtendExpression(e.expression,r);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let r of this.execute(e.left))t.push(r);for(let r of t){let i=this.substituteVariables(e.right,r);for await(let s of this.execute(i)){let o=r.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let r=JSON.parse(JSON.stringify(e));return this.substituteInOperation(r,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let r=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(r.input&&(r.input=this.substituteInOperation(r.input,t)),r.left&&(r.left=this.substituteInOperation(r.left,t)),r.right&&(r.right=this.substituteInOperation(r.right,t)),r.pattern&&(r.pattern=this.substituteInOperation(r.pattern,t)),r.query&&(r.query=this.substituteInOperation(r.query,t)),r.where&&(r.where=this.substituteInOperation(r.where,t)),r.expression&&this.substituteInExpression(r.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let r of e.operands)this.substituteInExpression(r,t);if(e.args)for(let r of e.args)this.substituteInExpression(r,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let r of e.list)this.substituteInExpression(r,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let r=t.get(e.value);if(r!=null){let i=r;if(r instanceof wW.IRI||i.termType==="NamedNode")return{type:"iri",value:r.value};if(i.termType==="Literal"||typeof i.value=="string")return{type:"literal",value:i.value,datatype:i.datatype?.value??i._datatype?.value,language:i.language??i._language}}}return e}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(r,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{r.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(r,i):yield*this.execute(r)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:r}=await Promise.resolve().then(()=>W3(Ro()));yield new r;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let r=t.get(e.name);if(!r)return;if(r instanceof EW.Literal){let i=r.datatype?.value;if(i===`${ln}dayTimeDuration`)try{return vW.DateTimeFunctions.parseDayTimeDuration(r.value)}catch{return r.value}if(i&&TW.has(i)){let s=parseFloat(r.value);if(!Number.isNaN(s))return s}return r.value}return r.value??r.id??String(r)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="bgp"&&r.triples)for(let i of r.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(r.type==="values"&&r.variables)for(let i of r.variables)t.add(i);r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.type==="extend"&&r.variable&&t.add(r.variable),r.input&&this.collectVarsFromOperation(r.input,t),r.left&&this.collectVarsFromOperation(r.left,t),r.right&&this.collectVarsFromOperation(r.right,t),r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.query&&this.collectVarsFromOperation(r.query,t),r.where&&this.collectVarsFromOperation(r.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let r=e;r.type==="variable"&&t.add(r.value),r.type==="quoted"&&(this.collectVarsFromElement(r.subject,t),this.collectVarsFromElement(r.predicate,t),this.collectVarsFromElement(r.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let r=e;if(r.type==="variable"&&r.name&&t.add(r.name),r.type==="exists"&&r.pattern&&this.collectVarsFromOperation(r.pattern,t),r.left&&this.collectVarsFromExpressionTree(r.left,t),r.right&&this.collectVarsFromExpressionTree(r.right,t),r.operands)for(let i of r.operands)this.collectVarsFromExpressionTree(i,t);if(r.args)for(let i of r.args)this.collectVarsFromExpressionTree(i,t);if(r.expression&&this.collectVarsFromExpressionTree(r.expression,t),r.list)for(let i of r.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new wu("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 wu("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};ti.ExoQLQueryExecutor=uy;ti.QueryExecutor=uy});var Z3=v(Co=>{"use strict";var AW=Co&&Co.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},IW=Co&&Co.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)};Object.defineProperty(Co,"__esModule",{value:!0});Co.CommandResolver=void 0;var xW=ut(),RW=Fd(),rr=ze(),Gt=tt(),te=Vt(),H3=Sa(),z3=pd(),CW=Vc(),OW=Ld(),vu=ow(),fy=NP(),PW=Jc(),DW=nu(),FW=Eu(),Hl=10,dy="exo__Asset",LW=Hl+1,K3="08cec529-90eb-4d43-88de-ceecccea12b0",NW=te.Namespace.EXOCMD.term("SubstitutionToken").value,Y3=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","targetClassSelf"]);function kW(n,e){return`__SUBSTITUTE__${n}__${e}__`}a(kW,"buildSubstitutionMarker");function MW(n,e,t){let r=(0,CW.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${n}__${e}__${r}__`}a(MW,"buildParameterisedMarker");var Q3="3f28af98-c031-4718-8ba2-44ad0b012c52",jW=te.Namespace.EXOCMD.term("TokenInvocation").value,X3="29e2c8f8-2d27-4e58-b467-2e85d46f8122",J3="universal-default-template",zE=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null,(0,fy.clearUniversalDefault)()}constructor(e,t=RW.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,r){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${r??""}`,o=this.multiCache.get(s);if(o)return o;let l=r?await this.expandPrototypeChain(r):void 0,c=await this.expandClassHierarchy(t),u=new Map;for(let[h,_]of c){let y=await this.resolveForAsset(e,h,l);for(let b of y){let S=this.getBindingPriority(b.binding)===2?_:0,I=u.get(b.binding.id);(!I||S<I.depth)&&u.set(b.binding.id,{rc:b,depth:S})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let _ of h.binding.overrides)f.add(_);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,_)=>{let y=this.getBindingPriority(h.rc.binding),b=this.getBindingPriority(_.rc.binding);return y!==b?y-b:h.depth!==_.depth?h.depth-_.depth:(h.rc.binding.order??100)-(_.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 l of e){if(l===dy){t.set(l,new Set);continue}let c=[];try{c=await this.getClassAncestors(l)}catch{c=[]}t.set(l,new Set(c))}let r=a(l=>{for(let c of e)if(c!==l&&t.get(c)?.has(l)&&!t.get(l)?.has(c))return!0;return!1},"isAncestorOfSibling"),i=e.filter(l=>!r(l)),s=new Map,o=a((l,c)=>{let u=s.get(l);(u===void 0||c<u)&&s.set(l,c)},"setMin");for(let l of i){if(o(l,0),this.looksLikeUUID(l))try{let u=await this.resolveLabelByUID(l);u&&o(u,0)}catch{}if(l===dy)continue;let c=[];try{c=await this.getClassAncestorsWithDepth(l)}catch{c=[]}for(let{ref:u,depth:f}of c)o(u,f)}return s.has(dy)||s.set(dy,LW),s}async resolveForAsset(e,t,r){let i=typeof r=="string"?`s:${r}`:r?`c:${r.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let l=typeof r=="string"?await this.expandPrototypeChain(r):r,c=await this.findBindings(t,l,e),u=[];for(let f of c){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 r=await this.findSubjectByUID(e);if(!r||(await this.tripleStore.match(r,te.Namespace.RDF.term("type"),te.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(r,te.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_labelTemplate")),l=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_icon")),c=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(r,te.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(r),_=await this.loadLinkedGrounding(r,0,t);return _?{id:e,name:s,labelTemplate:o??void 0,icon:l??void 0,precondition:h??void 0,grounding:_,confirmMessage:c??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,r){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,te.Namespace.RDF.term("type"),te.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let l of s){let c=l.subject,u=await this.loadBindingDefinition(c);u&&this.bindingMatches(u,e,i,r)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,te.Namespace.RDF.term("type"),te.Namespace.EXOCMD.term("Command")),t=[],r=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,te.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let l=await this.getLiteralValue(s,te.Namespace.EXO.term("Asset_uid"));if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let c=await this.loadCommand(l);if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command ${l} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,te.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,te.Namespace.EXOCMD.term("Command_cliName")),d=u??f??l;if(r.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${l}`);continue}r.add(d),t.push({command:c,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear(),this.clearUniversalCache()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let r=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let l=await this.evaluateSelectSnippet(o,t);r=r.replace(s,l)}return r}extractPlaceholders(e){let t=[],r=0;for(;r<e.length;)if(e[r]==="{"){let i=1,s=r+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(r,s),l=e.slice(r+1,s-1);t.push({full:o,body:l})}r=s}else r++;return t}async evaluateSelectSnippet(e,t){try{let r=e.replace(/\$target/g,`<${t}>`),s=new PW.ExoQLParser().parse(r),l=new DW.ExoQLAlgebraTranslator().translate(s),u=await new FW.ExoQLQueryExecutor(this.tripleStore).executeAll(l);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 Gt.Literal||p instanceof rr.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,te.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,te.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,te.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),l=await this.getLinkedValue(e,te.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!l)return null;let c=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,te.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),_=await this.getLinkedUIDs(e,te.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:r,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:l??void 0,position:c??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:_.length>0?_:void 0}}async loadLinkedStyle(e,t){let r=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(r.length>0){let s=r[0].object,o=null;if(s instanceof rr.IRI)o=s;else if(s instanceof Gt.Literal){let l=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(l)}if(o){let l=await this.loadStyleAsset(o);if(l)return l}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,te.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,te.Namespace.EXO.term("Asset_uid"));if(!t)return null;let r=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),l=this.coerceBoolean(o),c=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=c!==null?this.coerceLabelClass(c,t):void 0,f=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("CommandBindingStyle_source")),_=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:r,variant:s,showIcon:l,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:_,inline:!1}}coerceVariant(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(vu.COMMAND_VARIANT_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${r}" not in whitelist [${vu.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(vu.LABEL_CLASS_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${r}" not in whitelist [${vu.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let r=String(e).trim().toLowerCase();if(r!==""){if(vu.STYLE_SOURCE_VALUES.includes(r))return r;this.logger.warn(this.capWarning(`CommandBindingStyle source "${r}" not in whitelist [${vu.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,r,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&r){for(let s of r)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let r=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(r===i)return!0;let s=this.extractPathBasename(i);if(s&&s===r)return!0;let o=this.extractPathBasename(r);if(o&&o===i)return!0;let l=this.extractAlias(t);if(l&&r===l)return!0;let c=this.extractAlias(e);return!!(c&&c===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(r+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,te.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=await this.resolvePreconditionRef(r[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof rr.IRI)return e;if(e instanceof Gt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,r){let i=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_uid")),s=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(r>=Hl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||l.length>0||c.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||l.length>0){let _=o.length>0?"all":"any",y=o.length>0?o:l,b=[];for(let S of y)b.push(await this.loadChildPrecondition(S.object,p,r+1));return{id:i??"",label:s,composite:{op:_,children:b}}}let h=await this.loadChildPrecondition(c[0].object,p,r+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,te.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,r){let i=await this.resolvePreconditionRef(e);if(!i){let l=e instanceof Gt.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(l,"")}let s=await this.loadPreconditionSubject(i,t,r);if(s)return s;let o=await this.getLiteralValue(i,te.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let r=t[0].object;if(r instanceof rr.IRI)return await this.getLiteralValue(r,te.Namespace.EXO.term("Asset_uid"))??void 0;if(r instanceof Gt.Literal)return this.normalizeWikilink(r.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,r){if(t>=Hl)return null;let i=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!r?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let l=await this.resolveGroundingRef(o.object);if(!l)continue;let c=await this.getObsidianName(l,te.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(c&&this.matchesReference(c,r.targetClass))return this.loadGroundingDefinition(l,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${r.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof rr.IRI)return e;if(e instanceof Gt.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>=Hl)return null;let r=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_uid"));if(!r)return null;let i=await this.getLiteralValue(e,te.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let B=await this.resolveLabelByUID(o);if(!B)return this.logger.warn(`Grounding ${r}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=B}if(s===H3.GroundingType.SERVICE_CALL){let B=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_serviceId"));B&&(o=B)}let l=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetValueRef")),c=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let B=await this.resolveLabelByUID(u);if(!B)return this.logger.warn(`Grounding ${r}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=B}else u&&(f=u);let d=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),_=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_appendExpression")),y=await this.getObsidianWikilinkValue(e,te.Namespace.EXOCMD.term("Grounding_isDefinedBy")),b=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),S=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetClass"));if(S&&!this.looksLikeUUID(S)){let B=await this.findUidByLabel(S);B&&(S=B)}let I=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_targetPrototype")),O=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_targetFolder")),T=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_linkBackProperty")),E=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_inputSchema")),P=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_incrementBy")),V=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_shiftDelta")),M;if(P!=null&&P!==""){let B=Number.parseInt(String(P),10);Number.isFinite(B)&&(M=B)}let j=await this.resolvePropertyDefaults(e,r),$=await this.resolveInheritanceRules(e,r),G=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_propertyDefaults"));G!==null&&G!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(r)&&(this.logger.warn(`Grounding ${r}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(r));let ge;s===H3.GroundingType.COMPOSITE&&(ge=await this.loadCompositeSteps(e,t+1));let ye;if(E)try{let B=JSON.parse(E);B?.properties&&(ye=Object.entries(B.properties).map(([oe,Ee])=>{let Ce=Ee.type,xe=Ce==="string"?"text":Ce,Oe=Ee.defaultValue!==void 0?Ee.defaultValue:Ee.default,Re={name:oe,type:xe,label:Ee.title??oe,required:Array.isArray(B.required)&&B.required.includes(oe)};return Oe!=null&&(Re.defaultValue=String(Oe)),typeof Ee.targetClassUid=="string"&&(Re.targetClassUid=Ee.targetClassUid),Re}))}catch{}let Q=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),se=Q!==null&&String(Q).trim().toLowerCase()==="true",J=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_labelTemplate")),ve=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_direction")),re;if(ve!=null){let B=String(ve).trim().toLowerCase();B==="forward"||B==="rollback"?re=B:B!==""&&this.logger.warn(`Grounding ${r}: exocmd__Grounding_direction value '${ve}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let ie=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_bodyTemplate")),he=await this.getObsidianName(e,te.Namespace.EXOCMD.term("Grounding_templateRef")),Ue=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),ce=Ue!==null&&String(Ue).trim().toLowerCase()==="true",ue=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),fe=ue!==null&&String(ue).trim().toLowerCase()==="true",ne=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("Grounding_omitLabel")),me=ne!==null&&String(ne).trim().toLowerCase()==="true",Le={id:r,label:i,type:s,targetProperty:o??void 0,targetValueRef:l??void 0,targetValueLiteral:c??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:_??void 0,sparqlUpdate:b??void 0,steps:ge,targetClass:S??void 0,targetPrototype:I??void 0,targetFolder:O??void 0,linkBackProperty:T??void 0,incrementBy:M,shiftDelta:V??void 0,propertyDefault:j.length>0?j:void 0,inheritanceRule:$.length>0?$:void 0,isDefinedBy:y??void 0,prefillLabelWithDate:se||void 0,labelTemplate:J??void 0,direction:re,bodyTemplate:ie??void 0,templateRef:he??void 0,cloneTargetBody:ce||void 0,targetsCreatedInstance:fe||void 0,omitLabel:me||void 0};return ye&&(Le.inputSchema=ye),Le}async loadCompositeSteps(e,t){if(t>=Hl)return[];let r=await this.tripleStore.match(e,te.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of r){let o=null;if(s.object instanceof rr.IRI)o=s.object;else if(s.object instanceof Gt.Literal){let c=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(c)}if(!o)continue;let l=await this.loadGroundingDefinition(o,t);l&&i.push(l)}return i}async resolvePropertyDefaults(e,t){let r=await this.resolvePropertyDefaultsForSubject(e,t,te.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,fy.mergePropertyDefaults)(i.propertyDefaults,r):r}async resolvePropertyDefaultsForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[];for(let o of i){let l=await this.resolveRefTripleObject(o.object);if(!l)continue;let c=await this.getObsidianName(l,te.Namespace.EXOCMD.term("PropertyDefault_property"));if(!c){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(c)?await this.resolveLabelByUID(c):c;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${c}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(l,te.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.logger.warn(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await(0,fy.loadUniversalDefault)();if(e)return this._universalCacheValue=e,e;let t=await this.findUniversalSingleton();if(!t)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 r=await this.resolvePropertyDefaultsForSubject(t,J3,te.Namespace.EXOCMD.term("Template_propertyDefault")),i=await this.resolveInheritanceRulesForSubject(t,J3,te.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:r,inheritanceRules:i},this._universalCacheValue}async findUniversalSingleton(){let e=te.Namespace.EXOCMD.term("UniversalDefaultTemplate"),t=e.value,i=(await this.tripleStore.match(void 0,te.Namespace.EXO.term("Instance_class"),e)).map(l=>l.subject).filter(l=>l instanceof rr.IRI);if(i.length>0)return this.pickUniversalSingleton(i);let s=await this.tripleStore.match(void 0,te.Namespace.EXO.term("Instance_class"),void 0),o=[];for(let l of s){let c=!1;if(l.object instanceof rr.IRI)c=l.object.value===t||l.object.value.includes(X3);else if(l.object instanceof Gt.Literal){let u=this.unwrapWikilink(l.object.value);c=u==="exocmd__UniversalDefaultTemplate"||u===X3}c&&l.subject instanceof rr.IRI&&o.push(l.subject)}return this.pickUniversalSingleton(o)}pickUniversalSingleton(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=[...e].sort((r,i)=>r.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 r=await this.resolveInheritanceRulesForSubject(e,t,te.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,fy.mergeInheritanceRules)(i.inheritanceRules,r):r}async resolveInheritanceRulesForSubject(e,t,r){let i=await this.tripleStore.match(e,r,void 0),s=[],o=t;for(let l of i){let c=await this.resolveRefTripleObject(l.object);if(!c)continue;let u=await this.resolveLabelRef(c,te.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(c,te.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(c,te.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let T=await this.getObsidianName(c,te.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!T||!T.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(T)?(h=T,p=await this.resolveLabelByUID(T)??void 0):p=T}let _=await this.tripleStore.match(c,te.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),y=[],b=[],S=!1;for(let T of _){let E=null;if(T.object instanceof rr.IRI?E=this.iriToObsidianName(T.object.value)??T.object.value:T.object instanceof Gt.Literal&&(E=this.unwrapWikilink(T.object.value)),!E){S=!0;continue}if(this.looksLikeUUID(E)){b.push(E);let P=await this.resolveLabelByUID(E);P&&y.push(P)}else y.push(E)}if(S){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 I=await this.getLiteralValue(c,te.Namespace.EXOCMD.term("InheritanceRule_priority")),O=50;if(I!==null&&I!==""){let T=Number.parseInt(String(I),10);Number.isFinite(T)&&(O=T)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:y,targetClassExclusionUids:b,priority:O})}return s}async resolveRefTripleObject(e){if(e instanceof rr.IRI)return e;if(e instanceof Gt.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let r=await this.getObsidianName(e,t);return r?this.looksLikeUUID(r)?this.resolveLabelByUID(r):r:null}async resolvePropertyDefaultValue(e,t,r){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let l=`${t}|${e}`;return this._fallbackWarnedKeys.has(l)||(this._fallbackWarnedKeys.add(l),this.logger.warn(this.capWarning(`Grounding ${t}: PropertyDefault '${r}' \u2192 value asset ${e} not in store; emitting wikilink (a link, not the substituted value).`))),`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,r):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,r,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${r}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,r,i,s){let o=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let l=o.trim();return Y3.has(l)?s!==void 0?MW(l,t,s):kW(l,t):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${l}' \u2014 falling back to wikilink form. Known ids: ${Array.from(Y3).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,r,i){let s=await this.getObsidianName(e,te.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,te.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let l=await this.findSubjectByUID(s);return l?this.dispatchSubstitutionToken(l,s,r,i,o):(this.logger.warn(`Grounding ${r}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,te.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof rr.IRI){if(i.object.value===jW||i.object.value.includes(Q3))return!0}else if(i.object instanceof Gt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===Q3)return!0}return(await this.tripleStore.match(e,te.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,te.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof rr.IRI){if(i.object.value===NW||i.object.value.includes(K3))return!0}else if(i.object instanceof Gt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===K3)return!0}return(await this.tripleStore.match(e,te.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,te.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let r=t[0].object;if(r instanceof rr.IRI)return(0,z3.resolveGroundingTypeFromIRI)(r.value);if(r instanceof Gt.Literal){let i=r.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,z3.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],r=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Hl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let l=null;try{let u=await this.findSubjectByUID(o);if(!u)break;l=await this.getLinkedValue(u,te.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(!l)break;let c=this.normalizeWikilink(l).toLowerCase();if(r.has(c))break;r.add(c),t.push(l),i=l}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let r=this.extractPathBasename(t);return r&&this.looksLikeUUID(r)?r:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let r=await this.tripleStore.findSubjectsByUUID(e);if(r.length>0)return r[0]}let t=await this.tripleStore.match(void 0,te.Namespace.EXO.term("Asset_uid"),void 0);for(let r of t)if(r.object instanceof Gt.Literal&&r.object.value===e)return r.subject;return null}async getLiteralValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Gt.Literal||i instanceof rr.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);return t?this.getLiteralValue(t,te.Namespace.EXO.term("Asset_label")):null}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(r=>r.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let r=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),l=await this.getLiteralValue(s,te.Namespace.EXO.term("Asset_uid"));l&&o.add(l);let c=await this.getLiteralValue(s,te.Namespace.EXO.term("Asset_label"));c&&o.add(c);let u=a((p,h)=>{if(o.has(p))return;let _=r.get(p);(_===void 0||h<_)&&r.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:_}=p;if(_>=Hl||i.has(h.value))continue;i.add(h.value);let y=await this.tripleStore.match(h,te.Namespace.EXO.term("Class_superClass"),void 0);for(let b of y){let S=b.object;if(!(S instanceof rr.IRI))continue;let I=_+1,O=S.value.startsWith("obsidian://vault/"),T=this.iriToObsidianName(S.value);T&&u(T,I);let E=null;if(O?E=S:T&&(E=await this.resolveClassFileIRI(T)),!E)continue;let P=await this.getLiteralValue(E,te.Namespace.EXO.term("Asset_uid"));P&&u(P,I),i.has(E.value)||f.push({fileIRI:E,depth:I})}}let d=Array.from(r.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,te.Namespace.EXO.term("Asset_label"),void 0);for(let r of t)if(r.object instanceof Gt.Literal&&r.object.value===e&&r.subject instanceof rr.IRI){let i=await this.tripleStore.match(r.subject,te.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Gt.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof rr.IRI){let s=await this.tripleStore.match(i,te.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Gt.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Gt.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let r=await this.tripleStore.match(e,t,void 0),i=[];for(let s of r){let o=s.object;if(o instanceof rr.IRI){let l=await this.tripleStore.match(o,te.Namespace.EXO.term("Asset_uid"),void 0);if(l.length>0&&l[0].object instanceof Gt.Literal)i.push(l[0].object.value);else{let c=o.value.split("/").pop()?.replace(".md","");c&&i.push(c)}}else if(o instanceof Gt.Literal){let l=this.normalizeWikilink(o.value);l&&i.push(l)}}return i}async getLinkedValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Gt.Literal?this.normalizeWikilink(i.value):i instanceof rr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;return i instanceof Gt.Literal?this.unwrapWikilink(i.value):i instanceof rr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let r=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(r)return r[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let r=await this.tripleStore.match(e,t,void 0);if(r.length===0)return null;let i=r[0].object;if(i instanceof Gt.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof rr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let r=t[1],i=await this.findSubjectByUID(r);if(!i)return e;let s=await this.getLiteralValue(i,te.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${r}]]`,`[[${r}|${s}]]`):e}iriToObsidianName(e){return(0,OW.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),r=t.indexOf("|");return r>=0?t.substring(0,r):t}};Co.CommandResolver=zE;Co.CommandResolver=zE=AW([(0,xW.injectable)(),IW("design:paramtypes",[Object,Object])],zE)});var YE=v(KE=>{"use strict";Object.defineProperty(KE,"__esModule",{value:!0});KE.validateExoQLAllowlist=$W;var py=qd();function $W(n){if(!n||typeof n!="object")return;let e=n;if(e.type==="update"){let t=n.updates??[];for(let r of t)if(r?.type==="load")throw new py.ExoQLForbiddenKeywordError("LOAD");throw new py.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,r=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||r)throw new py.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)hy(t);if(Array.isArray(e.template))for(let t of e.template)hy(t)}}a($W,"validateExoQLAllowlist");function hy(n){if(!n||typeof n!="object")return;if(n.type==="service")throw new py.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(n.patterns))for(let t of n.patterns)hy(t);let e=n.where;if(Array.isArray(e))for(let t of e)hy(t)}a(hy,"walkPatternForBannedKeywords")});var QE=v(my=>{"use strict";Object.defineProperty(my,"__esModule",{value:!0});my.DEFAULT_EVAL_CONFIG=void 0;my.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var gy=v(XE=>{"use strict";Object.defineProperty(XE,"__esModule",{value:!0});XE.evaluateWithExoEval=HW;var UW=Jc(),BW=nu(),VW=Eu(),qW=YE(),GW=QE(),WW=qd();async function HW(n,e={}){if(typeof n!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let r=new UW.ExoQLParser().parse(n);if((0,qW.validateExoQLAllowlist)(r),!{...GW.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new WW.ExoQLEvalDisabledError;let s="queryType"in r&&typeof r.queryType=="string"?r.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let l=new BW.ExoQLAlgebraTranslator().translate(r),c=new VW.ExoQLQueryExecutor(e.store);return c.isAskQuery(l)?{kind:"ask",result:await c.executeAsk(l)}:c.isConstructQuery(l)?{kind:"construct",triples:await c.executeConstruct(l)}:{kind:"select",rows:await c.executeAll(l)}}a(HW,"evaluateWithExoEval")});var zi=v(yy=>{"use strict";Object.defineProperty(yy,"__esModule",{value:!0});yy.DateFormatter=void 0;var JE=class n{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}-${r}-${i}T${s}:${o}:${l}`}static toDateWikilink(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${r}-${i}]]"`}static getTodayWikilink(){return n.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${i}`}static parseWikilink(e){let r=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return r?r[1]:null}static addDays(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),n.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[r,i,s]=t,o=new Date(r,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return n.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return n.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};yy.DateFormatter=JE});var Wd=v(_y=>{"use strict";Object.defineProperty(_y,"__esModule",{value:!0});_y.liveClock=zW;_y.frozenClock=KW;function zW(){return{now:a(()=>new Date,"now")}}a(zW,"liveClock");function KW(n){let e=new Date(n);return{now:a(()=>new Date(e.getTime()),"now")}}a(KW,"frozenClock")});var tD=v(Oo=>{"use strict";var YW=Oo&&Oo.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},QW=Oo&&Oo.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},zd;Object.defineProperty(Oo,"__esModule",{value:!0});Oo.PreconditionEvaluator=void 0;var XW=ut(),JW=Jc(),ZW=nu(),eD=Eu(),eH=gy(),Hd=zi(),tH=Wd(),Kd=zd=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,r){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=r?.clock??(0,tH.liveClock)()}async evaluate(e,t,r){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,r,i)==="yes"}async evaluateNode(e,t,r,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let l=await Promise.all(o.map(c=>this.evaluateNode(c,t,r,i)));return s==="all"?l.includes("no")?"no":l.includes("unknown")?"unknown":"yes":l.includes("yes")?"yes":l.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,r,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,r)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,r){let i=r.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return r.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let r=await this.queryBodyResolver.resolveSparql(e);if(!r)return!1;let i=this.substituteVariables(r,t),s=await(0,eH.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,r){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,r):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,zd.SENTINEL_IRI),i=new JW.ExoQLParser().parse(t),o=new ZW.ExoQLAlgebraTranslator().translate(i);return new eD.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,r){let i=this.hostFunctions.get(e);if(!i)return!0;let s=r?{...r,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let r=zd.TEMPORAL_TOKEN.test(e),i=r?Hd.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||r&&s.day!==i){let c=this.compileAsk(e);if(!c)return!1;s={day:i,compiled:c},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll(zd.SENTINEL_IRI,t));return await new eD.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let r=this.clock.now(),i=r.toISOString(),s=r.getFullYear(),o=r.getMonth(),l=r.getDate(),c=r.getDay(),u=Hd.DateFormatter.toDateString(r),f=Hd.DateFormatter.toDateString(new Date(s,o,l-1)),d=(c+6)%7,p=Hd.DateFormatter.toDateString(new Date(s,o,l-d)),h=Hd.DateFormatter.toDateString(new Date(s,o,l-d-7)),_=`${s}-${String(o+1).padStart(2,"0")}-01`,y=o===0?11:o-1,S=`${o===0?s-1:s}-${String(y+1).padStart(2,"0")}-01`,I=`${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,`"${_}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${S}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${I}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};Oo.PreconditionEvaluator=Kd;Kd.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Kd.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;Oo.PreconditionEvaluator=Kd=zd=YW([(0,XW.injectable)(),QW("design:paramtypes",[Object,Object,Object])],Kd)});var rD=v(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.hasUidFilename=Po.hasNonUidFilename=void 0;Po.registerDefaultHostFunctions=iH;var rH=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");Po.hasNonUidFilename=rH;var nH=a(n=>{let e=n.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=n.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");Po.hasUidFilename=nH;function iH(n){n.registerHostFunction("hasNonUidFilename",Po.hasNonUidFilename),n.registerHostFunction("hasUidFilename",Po.hasUidFilename)}a(iH,"registerDefaultHostFunctions")});var Sy=v(by=>{"use strict";Object.defineProperty(by,"__esModule",{value:!0});by.liveUidGenerator=sH;by.seededUidGenerator=aH;var ZE=Ol();function sH(){return{next:a(()=>(0,ZE.v4)(),"next")}}a(sH,"liveUidGenerator");var oH="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function aH(n){let e=0,t=(0,ZE.v5)(n,oH);return{next:a(()=>{let r=`${n}#${e}`;return e+=1,(0,ZE.v5)(r,t)},"next")}}a(aH,"seededUidGenerator")});var vy=v(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});Da.registerResolver=lr;Da.getResolver=cH;Da.isResolverModifierAware=uH;Da.getRegisteredResolverIds=fH;Da.clearResolvers=dH;Da.installDefaultResolvers=EH;var lH=zi(),Ey=new Map,ev=new Set;function lr(n,e,t=!1){Ey.set(n,e),t&&ev.add(n)}a(lr,"registerResolver");function cH(n){return Ey.get(n)}a(cH,"getResolver");function uH(n){return ev.has(n)}a(uH,"isResolverModifierAware");function fH(){return Array.from(Ey.keys())}a(fH,"getRegisteredResolverIds");function dH(){Ey.clear(),ev.clear()}a(dH,"clearResolvers");function cn(n){return n<10?`0${n}`:String(n)}a(cn,"pad2");var pH=["January","February","March","April","May","June","July","August","September","October","November","December"],hH=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mH=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],gH=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function yH(n){let e=["th","st","nd","rd"],t=n%100;return`${n}${e[(t-20)%10]||e[t]||e[0]}`}a(yH,"ordinalDay");var _H=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function bH(n,e){let t=(n.getHours()+11)%12+1;return e.replace(_H,r=>{switch(r){case"YYYY":return String(n.getFullYear());case"YY":return cn(n.getFullYear()%100);case"MMMM":return pH[n.getMonth()];case"MMM":return hH[n.getMonth()];case"MM":return cn(n.getMonth()+1);case"M":return String(n.getMonth()+1);case"Do":return yH(n.getDate());case"DD":return cn(n.getDate());case"D":return String(n.getDate());case"dddd":return mH[n.getDay()];case"ddd":return gH[n.getDay()];case"HH":return cn(n.getHours());case"H":return String(n.getHours());case"hh":return cn(t);case"h":return String(t);case"mm":return cn(n.getMinutes());case"m":return String(n.getMinutes());case"ss":return cn(n.getSeconds());case"s":return String(n.getSeconds());case"A":return n.getHours()<12?"AM":"PM";case"a":return n.getHours()<12?"am":"pm";default:return r}})}a(bH,"formatDate");function nD(n,e,t){let r=n.getDate(),i=new Date(n.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(r,s)),i}a(nD,"addMonthsClamped");function SH(n,e){if(!e)return n;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return n;let r=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(n.getTime());switch(i){case"d":s.setDate(s.getDate()+r);break;case"w":s.setDate(s.getDate()+r*7);break;case"M":s=nD(s,r,"M");break;case"y":s=nD(s,r,"y");break}return isNaN(s.getTime())?n:s}a(SH,"applyDateOffset");function wH(n){if(!n)return{offset:null,format:null};let e=n.indexOf(":");if(e<0)return{offset:n,format:null};let t=n.slice(0,e),r=n.slice(e+1);return{offset:t||null,format:r||null}}a(wH,"parseDateModifier");function wy(n,e){return(t,r)=>{let{offset:i,format:s}=wH(r),o=new Date;return n!==0&&o.setDate(o.getDate()+n),o=SH(o,i),bH(o,s??e)}}a(wy,"makeDateResolver");function EH(){lr("today",()=>{let n=new Date;return`${n.getFullYear()}-${cn(n.getMonth()+1)}-${cn(n.getDate())}`}),lr("todayStart",()=>lH.DateFormatter.getTodayStartTimestamp()),lr("date",wy(0,"YYYY-MM-DD"),!0),lr("now",wy(0,"YYYY-MM-DDTHH:mm:ss"),!0),lr("tomorrow",wy(1,"YYYY-MM-DD"),!0),lr("yesterday",wy(-1,"YYYY-MM-DD"),!0),lr("target",n=>n.targetIRI?`"[[${n.targetIRI}]]"`:""),lr("targetFolder",n=>{if(!n.targetFilePath)return"";let e=n.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),lr("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.")}),lr("nowTimestamp",()=>{let n=new Date;return`${n.getFullYear()}-${cn(n.getMonth()+1)}-${cn(n.getDate())}T${cn(n.getHours())}:${cn(n.getMinutes())}:${cn(n.getSeconds())}`}),lr("nowDate",()=>{let n=new Date;return`${n.getFullYear()}-${cn(n.getMonth()+1)}-${cn(n.getDate())}`}),lr("nowYear",()=>String(new Date().getFullYear())),lr("nowMonth",()=>cn(new Date().getMonth()+1)),lr("userInputLabel",n=>{let e=n.userInput?.label;return typeof e=="string"?e:""}),lr("userInput",(n,e)=>{if(!e)return null;let t=n.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),lr("targetProperty",(n,e)=>{if(!e||!n.targetFm)return null;let t=n.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),lr("targetRefProperty",(n,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let r=e.slice(0,t),i=e.slice(t+1);if(!r||!i)return null;let s=n.targetRefFm?.[r];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),lr("labelAsArray",n=>{let e=n.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),lr("groundingTargetClass",n=>n.groundingTargetClassUid?`"[[${n.groundingTargetClassUid}]]"`:null),lr("targetClassSelf",n=>{if(!n.targetFilePath)return null;let e=n.targetFilePath.replace(/^\/+/,""),r=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return r.length>0?`"[[${r}]]"`:null})}a(EH,"installDefaultResolvers")});var rv=v(Ty=>{"use strict";Object.defineProperty(Ty,"__esModule",{value:!0});Ty.resolveTemplateBody=TH;Ty.stripTemplateFrontmatter=AH;var tv=vy();(0,tv.installDefaultResolvers)();var vH=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function TH(n,e={}){return n.replace(vH,(t,r,i)=>{let s=(0,tv.getResolver)(r);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,tv.isResolverModifierAware)(r)?o:o+i})}a(TH,"resolveTemplateBody");function AH(n){let e=n.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?n.slice(e[0].length):n}a(AH,"stripTemplateFrontmatter")});var xy=v(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});Tu.registerOrderSpecLoader=IH;Tu.clearOrderSpecLoader=xH;Tu.loadDefaultSpec=RH;Tu.orderProperties=CH;var Ay=null,Fa,Iy=!1;function IH(n){Ay=n,Fa=void 0,Iy=!1}a(IH,"registerOrderSpecLoader");function xH(){Ay=null,Fa=void 0,Iy=!1}a(xH,"clearOrderSpecLoader");function RH(){if(Fa!==void 0)return Fa;if(!Ay)return Fa=null,null;try{Fa=Ay()}catch(n){Iy||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",n),Iy=!0),Fa=null}return Fa}a(RH,"loadDefaultSpec");function CH(n,e){if(!e||e.head.length===0&&e.tail.length===0)return n;let t=Object.keys(n),r=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(n,u)),l=t.filter(u=>!r.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&l.sort((u,f)=>u.localeCompare(f));let c={};for(let u of s)c[u]=n[u];for(let u of l)c[u]=n[u];for(let u of o)c[u]=n[u];return c}a(CH,"orderProperties")});var Yd=v(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});zl.STRING_SCALAR_PROPERTIES=void 0;zl.needsYamlQuoting=iD;zl.quoteYamlString=sD;zl.serializeYamlScalar=$H;var OH=/^[-!&*?|>%@`"'#,[\]{}]/,PH=/[\u0000-\u001f\u007f]/,DH=/^(?:true|True|TRUE|false|False|FALSE)$/,FH=/^(?:null|Null|NULL|~)$/,LH=/^[-+]?(?:0b[01_]+|0o[0-7_]+|0x[0-9a-fA-F_]+|[0-9][0-9_]*)$/,NH=/^(?:[-+]?[0-9][0-9_]*(?:\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/,kH=/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;zl.STRING_SCALAR_PROPERTIES=new Set(["exo__Asset_label","aliases"]);function MH(n){if(n.length<2||!n.startsWith('"')||!n.endsWith('"'))return!1;let e=n.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(MH,"isCompleteDoubleQuotedScalar");function jH(n){return DH.test(n)||FH.test(n)||LH.test(n)||NH.test(n)||kH.test(n)}a(jH,"looksLikeNonStringScalar");function iD(n,e=!1){return n===""?!0:MH(n)?!1:!!(n!==n.trim()||/:(\s|$)/.test(n)||/\s#/.test(n)||OH.test(n)||PH.test(n)||e&&jH(n))}a(iD,"needsYamlQuoting");function sD(n){let e="";for(let t=0;t<n.length;t++){let r=n[t],i=n.charCodeAt(t);r==="\\"?e+="\\\\":r==='"'?e+='\\"':r===`
72
+ `?e+="\\n":r==="\r"?e+="\\r":r===" "?e+="\\t":i<32||i===127?e+="\\x"+i.toString(16).toUpperCase().padStart(2,"0"):e+=r}return`"${e}"`}a(sD,"quoteYamlString");function $H(n,e=!1){return typeof n!="string"?String(n):iD(n,e)?sD(n):n}a($H,"serializeYamlScalar")});var Nn=v(Ry=>{"use strict";Object.defineProperty(Ry,"__esModule",{value:!0});Ry.DI_TOKENS=void 0;Ry.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 iv=v(Cy=>{"use strict";Object.defineProperty(Cy,"__esModule",{value:!0});Cy.RDFVocabularyMapper=void 0;var yr=Qn(),oD=ze(),Fe=Vt(),nv=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",Fe.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",Fe.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",Fe.Namespace.RDFS.term("subClassOf")],["exo__Property_range",Fe.Namespace.RDFS.term("range")],["exo__Property_domain",Fe.Namespace.RDFS.term("domain")],["exo__Property_superProperty",Fe.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new yr.Triple(Fe.Namespace.EXO.term("Asset"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.RDFS.term("Resource"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Class"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.RDFS.term("Class"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.RDF.term("Property"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Task"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Project"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Area"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("Workflow"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("WorkflowState"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EMS.term("WorkflowTransition"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("Command"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("Precondition"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("Grounding"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e.push(new yr.Triple(Fe.Namespace.EXOCMD.term("CommandBinding"),Fe.Namespace.RDFS.term("subClassOf"),Fe.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new yr.Triple(Fe.Namespace.EXO.term("Instance_class"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDF.term("type"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Asset_isDefinedBy"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("isDefinedBy"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Class_superClass"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("subClassOf"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property_range"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("range"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property_domain"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("domain"))),e.push(new yr.Triple(Fe.Namespace.EXO.term("Property_superProperty"),Fe.Namespace.RDFS.term("subPropertyOf"),Fe.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,r){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(r instanceof oD.IRI)s=r;else{let o=r.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,l,c]=o;s=(l==="ems"?Fe.Namespace.EMS:l==="exocmd"?Fe.Namespace.EXOCMD:Fe.Namespace.EXO).term(c)}else s=new oD.IRI(r)}return new yr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};Cy.RDFVocabularyMapper=nv});var Oy=v(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.OBSIDIAN_VAULT_SCHEME=void 0;Do.vaultPathToIRI=UH;Do.iriToVaultPath=BH;Do.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function UH(n){let e=n.startsWith("./")?n.slice(2):n;return`${Do.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(UH,"vaultPathToIRI");function BH(n){if(!n.startsWith(Do.OBSIDIAN_VAULT_SCHEME))return null;let e=n.slice(Do.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(BH,"iriToVaultPath")});var Dy=v(Qd=>{"use strict";Object.defineProperty(Qd,"__esModule",{value:!0});Qd.derivePath=aD;Qd.deriveUrl=VH;Qd.deriveLegacyFlatPath=qH;var sv="assetspaces",Py=/^[A-Za-z0-9._-]+$/;function aD(n){if(typeof n!="string")return null;let e=n.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 l=o.indexOf("/");if(l<0)return null;t=o.slice(l+1)}let r=t.split("/").filter(o=>o.length>0);if(r.length<2)return null;let i=r[0],s=r[1];return i==="."||i===".."||s==="."||s===".."||!Py.test(i)||!Py.test(s)?null:`${sv}/${i}/${s}`}a(aD,"derivePath");function VH(n){if(typeof n!="string")return null;let e=n.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${sv}/`;if(!e.startsWith(t))return null;let r=e.slice(t.length).split("/").filter(o=>o.length>0);if(r.length<2)return null;let i=r[0],s=r[1];return i==="."||i===".."||s==="."||s===".."||!Py.test(i)||!Py.test(s)?null:`https://github.com/${i}/${s}`}a(VH,"deriveUrl");function qH(n){let e=aD(n);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let r=t.startsWith("exoas-")?t.slice(6):t;return r.length===0?null:`${sv}/${r}`}a(qH,"deriveLegacyFlatPath")});var Fy=v(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});Ki.FILE_SPACE_CLASS_UID=void 0;Ki.frontmatterDeclaresFileSpace=WH;Ki.discoverFileSpaceExclusions=zH;var GH=Dy();Ki.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var lD=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,ov=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function uD(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(typeof r!="string")continue;lD.lastIndex=0;let i;for(;(i=lD.exec(r))!==null;)t.push(i[1].trim())}return t}a(uD,"wikilinkTargets");function WH(n){return n?uD(n.exo__Instance_class).some(e=>ov.test(e)&&e.toLowerCase()===Ki.FILE_SPACE_CLASS_UID):!1}a(WH,"frontmatterDeclaresFileSpace");function cD(n,e){try{return n.getFrontmatter(e)}catch{return null}}a(cD,"readFrontmatterSafe");function HH(n){let e=n.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=n.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(HH,"readSource");function zH(n){let e=[],t=[],r=[],i=new Map,s=a((l,c)=>{if(ov.test(l))return l.toLowerCase()===Ki.FILE_SPACE_CLASS_UID;let u=n.getFirstLinkpathDest(l,c);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=cD(n,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===Ki.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(l=>l.some(c=>ov.test(c)&&c.toLowerCase()===Ki.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let l of n.getAllFiles()){let c=cD(n,l);if(!c)continue;let u=uD(c.exo__Instance_class);if(!u.some(h=>s(h,l.path)))continue;t.push(l.path),o(u)||r.push(`FileSpace declaration ${l.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Ki.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=HH(c);if(f===null){r.push(`FileSpace declaration ${l.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,GH.derivePath)(f);if(d===null){r.push(`FileSpace declaration ${l.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;l.path.startsWith(p)&&r.push(`FileSpace declaration ${l.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:r}}a(zH,"discoverFileSpaceExclusions")});var Yl=v(Lr=>{"use strict";var KH=Lr&&Lr.__decorate||function(n,e,t,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var l=n.length-1;l>=0;l--)(o=n[l])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},YH=Lr&&Lr.__metadata||function(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)},fD=Lr&&Lr.__param||function(n,e){return function(t,r){e(t,r,n)}},cv;Object.defineProperty(Lr,"__esModule",{value:!0});Lr.NoteToRDFConverter=Lr.UNPREFIXED_ASSET_FIELDS=void 0;Lr.canonicalYamlKey=ez;Lr.normaliseExcludedFolders=hD;Lr.isPathExcluded=mD;var av=ut(),_r=Qn(),Yi=ze(),yn=tt(),dD=Yt(),nr=Vt(),pD=Nn(),QH=iv(),XH=Fd(),lv=Oy(),ri=Gw(),JH=Fy();Lr.UNPREFIXED_ASSET_FIELDS=new Set(["archived","draft","pinned","aliases"]);var ZH=/^exo__Asset_(.+)$/;function ez(n){let e=ZH.exec(n);return e&&Lr.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:n}a(ez,"canonicalYamlKey");function hD(n){return Array.isArray(n)?n.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(hD,"normaliseExcludedFolders");function mD(n,e){if(e.length===0)return!1;let t=n.replace(/\\/g,"/");for(let r of e)if(t.startsWith(r))return!0;return!1}a(mD,"isPathExcluded");function tz(n){if(!n)return"";let e=n.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(tz,"normaliseSubjectIriPrefix");var Kl=cv=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=XH.NullLogger,r={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.vocabularyMapper=new QH.RDFVocabularyMapper,this.subjectIriPrefix=tz(r.subjectIriPrefix),this.emitInstanceClassAsUid=r.emitInstanceClassAsUid??!1}async convertNote(e){return this.convertNoteFromFrontmatter(e,this.vault.getFrontmatter(e))}async convertNoteFromFrontmatter(e,t){if(!t)return[];let r=this.notePathToIRI(e.path),i=nr.Namespace.EXO.term("Asset_filename"),s=new _r.Triple(r,i,new yn.Literal(e.basename));if(ri.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,r){this.pendingExtraTriples=[];let i=[r],s=this.notePathToIRI(e.path),o,l,c,u=!1,f=nr.Namespace.EXO.term("Statement").value;for(let[y,b]of Object.entries(t)){let S=Lr.UNPREFIXED_ASSET_FIELDS.has(y)?`exo__Asset_${y}`:y;if(!this.isExocortexProperty(S))continue;let I=this.propertyKeyToIRI(S),O=Array.isArray(b)?b:[b];for(let T of O)if(!((y==="exo__Asset_label"||Lr.UNPREFIXED_ASSET_FIELDS.has(y))&&(T==null||typeof T=="string"&&T.trim()==="")))if(y==="exo__Instance_class"){let E=this.valueToClassURI(T);i.push(new _r.Triple(s,I,E))}else{let E=await this.valueToRDFObject(T,e,I);if(S==="exo__Statement_subject"&&o===void 0){let P=E.find(V=>V instanceof Yi.IRI);P&&(o=P)}else if(S==="exo__Statement_predicate"&&l===void 0){let P=E.find(V=>V instanceof Yi.IRI);P&&(l=P)}else S==="exo__Statement_object"&&c===void 0&&(c=E[0]);for(let P of E)if(i.push(new _r.Triple(s,I,P)),this.vocabularyMapper.hasMappingFor(y)&&P instanceof Yi.IRI){let V=this.vocabularyMapper.generateMappedTriple(s,y,P);V&&i.push(V)}}if(y==="exo__Instance_class")for(let T of O){let E=this.valueToClassURI(T);if(E instanceof Yi.IRI){let P=nr.Namespace.RDF.term("type");i.push(new _r.Triple(s,P,E)),E.value===f&&(u=!0)}}if(y==="exo__Asset_label"){let T=nr.Namespace.RDFS.term("label");for(let E of O)typeof E=="string"&&E.length>0&&i.push(new _r.Triple(s,T,new yn.Literal(E)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let y=nr.Namespace.RDFS.term("label"),b=nr.Namespace.EXO.term("Asset_label"),S=new yn.Literal(e.basename);i.push(new _r.Triple(s,y,S)),i.push(new _r.Triple(s,b,S))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&l&&c&&i.push(new _r.Triple(o,l,c));let _=await this.convertBodyWikilinks(e,s);return i.push(..._),i}async convertExo003Note(e,t){let r=ri.Exo003Parser.parse(t);if(!r.success||!r.metadata)return[];let i=r.metadata,s=[];switch(i.metadata){case ri.Exo003MetadataType.Namespace:break;case ri.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case ri.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case ri.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case ri.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let r=this.notePathToIRI(e.path),i=new Yi.IRI(t.uri);return[new _r.Triple(r,nr.Namespace.OWL.term("sameAs"),i),new _r.Triple(i,nr.Namespace.OWL.term("sameAs"),r)]}convertExo003BlankNode(e,t){let r=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new _r.Triple(r,nr.Namespace.OWL.term("sameAs"),new dD.BlankNode(i))]}convertExo003Statement(e,t){let r=[];try{let i=this.createExo003ReferenceResolver(e),s=ri.Exo003Parser.toTriple(t,i);r.push(s);let o=this.notePathToIRI(e.path);r.push(new _r.Triple(o,nr.Namespace.RDF.term("value"),s.subject))}catch{}return r}async convertExo003Body(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),l=o(t.subject),c=o(t.predicate);if(l.type==="literal")throw new Error("Body subject cannot be a literal");if(c.type!=="iri")throw new Error("Body predicate must be an IRI");let u=l.type==="iri"?new Yi.IRI(l.value):new dD.BlankNode(l.value),f=new Yi.IRI(c.value),d=ri.Exo003Parser.toLiteral(t,s.trim());r.push(new _r.Triple(u,f,d));let p=this.notePathToIRI(e.path);r.push(new _r.Triple(p,nr.Namespace.RDF.term("value"),u))}catch{}return r}createExo003ReferenceResolver(e){return t=>{let r=this.extractWikilink(t),i=r||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.vault.getFrontmatter(s);if(o&&ri.Exo003Parser.isExo003Format(o)){let l=ri.Exo003Parser.parse(o);if(l.success&&l.metadata){let c=l.metadata;if(c.metadata===ri.Exo003MetadataType.Anchor||c.metadata===ri.Exo003MetadataType.Namespace)return{type:"iri",value:c.uri};if(c.metadata===ri.Exo003MetadataType.BlankNode)return{type:"blank",value:c.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!r&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders})).triples}async convertVaultWithValidation(e={}){let t=this.vault.getAllFiles(),r=[],i=[],s=e.strict??!1,o=0,l=0,c=(0,JH.discoverFileSpaceExclusions)(this.vault);for(let y of c.warnings)this.logger.warn(`FileSpace discovery: ${y}`);let u=[...hD(e.excludedFolders),...c.prefixes],f=u.length===0?t:t.filter(y=>!mD(y.path,u)),d=e.onProgress,p=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:cv.INDEX_PROGRESS_INTERVAL,h=f.length,_=0;for(let y of f){if(_++,d&&_%p===0&&_<h)try{d(_,h)}catch{}try{let b=this.vault.getFrontmatter(y),S=b?this.validateExocortexAsset(b,y.basename):null;if(S){if(s)throw new Error(`Invariant violation in "${y.path}": ${S.message}`);i.push({path:y.path,reason:`Invariant violation: ${S.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${y.path}`,{code:S.code,property:S.property,reason:S.message});continue}let I=await this.convertNote(y);r.push(...I)}catch(b){let S=b instanceof Error?b.message:String(b);if(s)throw new Error(`Invalid IRI for file "${y.path}": ${S}`);i.push({path:y.path,reason:`Invalid IRI: ${S}`}),l++,this.logger.info(`Skipping file with invalid IRI: ${y.path}`,{reason:S})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),l>0&&this.logger.warn(`Skipped ${l} file${l===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:l}),{triples:r,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length},fileSpaces:c}}static inferLabelFromBasename(e){return nr.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let r=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(r):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(r(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&r(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let l=e.exo__Instance_class,c=Array.isArray(l)?l:[l],u=null,f=!1;for(let d of c){if(typeof d!="string")continue;let p=this.removeQuotes(d),_=(this.extractWikilink(p)??p).trim();/^[a-z][a-zA-Z0-9]*__/.test(_)&&/[\s()]/.test(_)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let r of e){let i=(0,lv.vaultPathToIRI)(r.path);Yi.IRI.isValidIRI(i)||t.push({path:r.path,reason:`Path "${r.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new Yi.IRI((0,lv.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new Yi.IRI((0,lv.vaultPathToIRI)(e))}isExocortexProperty(e){return nr.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=nr.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let r=this.vault.getFrontmatter(t);if(!r)return;let i=r.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof Yi.IRI&&(this.pendingExtraTriples.push(new _r.Triple(e,nr.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new _r.Triple(e,nr.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,r){if(typeof e=="string"){let i=this.removeQuotes(e);if(r?.value.endsWith("#TokenInvocation_parameter"))return[new yn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let c=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new yn.Literal(u);if(r?.value.endsWith("#Grounding_targetValueRef")||r?.value.endsWith("#Grounding_targetValueSubstitution")||r?.value.endsWith("#Grounding_targetClass")||r?.value.endsWith("#Grounding_type")||r?.value.endsWith("#PropertyDefault_value"))return[c];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let _=this.vault.getFrontmatter(o);if(_){let O=_.exo__Asset_label;if(typeof O=="string"){let T=this.expandClassValue(O);if(T)return this.emitTypeTripleForEnumInstance(T,o),[T]}}let y=r?.value.endsWith("#Asset_prototype")||r?.value.endsWith("/Asset_prototype"),S=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(O=>O.trim()).filter(Boolean),I=S.length>0&&S.some(O=>r?.value.endsWith(`#${O}`));return y||I?[c,d]:[c]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[c]}if(this.isClassReference(s)){let c=this.expandClassValue(s);if(c)return[c]}let l=s.includes("|")?s.split("|")[0]:s;return this.isUUID(l)?[this.synthesizeWikilinkTargetIRI(`${l}.md`)]:[new yn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new yn.Literal(i,nr.Namespace.XSD.term("dateTime"))]:[new yn.Literal(i)]}return typeof e=="boolean"?[new yn.Literal(e.toString())]:typeof e=="number"?[new yn.Literal(e.toString(),nr.Namespace.XSD.term("decimal"))]:e instanceof Date?[new yn.Literal(e.toISOString(),nr.Namespace.XSD.term("dateTime"))]:[new yn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1];return r.includes("|")?r.split("|")[0]:r}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let r=t[1],i=r.indexOf("|");return i>=0?r.substring(i+1).trim():null}valueToClassURI(e){if(typeof e!="string")return new yn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let l=this.expandClassValue(o);if(l)return l}if(this.isUUID(i)){let l=this.vault.getFirstLinkpathDest(i,"");if(l){let c=this.expandClassValue(l.basename);if(c)return this.emitInstanceClassAsUid?this.notePathToIRI(l.path):c;let u=this.vault.getFrontmatter(l);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(l.path):d}}return this.notePathToIRI(l.path)}}return new yn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:nr.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),r=nr.Namespace.fromPropertyKey(t);return!r||/[\s()]/.test(r.localName)?null:r.namespace.term(r.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,r,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(r=i.exec(e))!==null;)r[1]&&t.add(r[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let r=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),l=nr.Namespace.EXO.term("Asset_bodyLink");for(let c of o){let u=this.vault.getFirstLinkpathDest(c,e.path);if(u){let f=this.notePathToIRI(u.path);r.push(new _r.Triple(t,l,f))}else if(this.isClassReference(c)){let f=this.expandClassValue(c);f?r.push(new _r.Triple(t,l,f)):r.push(new _r.Triple(t,l,new yn.Literal(c)))}else r.push(new _r.Triple(t,l,new yn.Literal(c)))}}catch{}return r}};Lr.NoteToRDFConverter=Kl;Kl.INDEX_PROGRESS_INTERVAL=200;Kl.SkippedFileInfo=class{constructor(n,e){this.path=n,this.reason=e}};Kl.VaultValidationResult=class{constructor(n,e,t){this.triples=n,this.skippedFiles=e,this.summary=t}};Kl.VaultValidationOptions=class{constructor(n=!1){this.strict=n}};Lr.NoteToRDFConverter=Kl=cv=KH([(0,av.injectable)(),fD(0,(0,av.inject)(pD.DI_TOKENS.IVaultAdapter)),fD(1,(0,av.inject)(pD.DI_TOKENS.ILogger)),YH("design:paramtypes",[Object,Object,Object])],Kl)});var Ql=v(Ly=>{"use strict";Object.defineProperty(Ly,"__esModule",{value:!0});Ly.FrontmatterService=void 0;var gD=xy(),uv=Yd(),fv=Yl(),Xd=class n{static{a(this,"FrontmatterService")}parse(e){let t=e.match(n.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let r={},i=t.content.split(/\r?\n/),s=null,o=null,l=a(()=>{s!==null&&o!==null&&(r[s]=o),s=null,o=null},"flushArray");for(let c of i){let u=/^ {2}- (.*)$/.exec(c);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}l();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(c);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(s=d,o=[]):r[d]=p}return l(),r}updateProperty(e,t,r){t=(0,fv.canonicalYamlKey)(n.normalizeIRI(t)),typeof r=="string"&&(r=n.normalizeIRIValue(r));let i=this.parse(e),s=this.serializeValue(t,r);if(!i.exists)return`---
73
73
  ${s}
74
74
  ---
75
75
  ${e}`;let o=i.content;if(this.hasProperty(o,t)){let l=new RegExp(`^${this.escapeRegex(t)}:.*(?:
@@ -317,7 +317,7 @@ To resolve:
317
317
  path = ${e}
318
318
  url = ${t}
319
319
  `;return{content:n+i+s,added:!0}}a(_te,"appendGitmodulesEntry");function bte(n,e){let t=n.split(/\r?\n/),r=[],i=!1,s=new RegExp(`^\\[submodule\\s+"${mA(e)}"\\]\\s*$`);for(let c of t){if(i){if(/^\[.+\]\s*$/.test(c)){i=!1,r.push(c);continue}continue}if(s.test(c)){i=!0;continue}r.push(c)}let o=[],l=!1;for(let c of r){let u=c.trim().length===0;u&&l||(o.push(c),l=u)}return o.join(`
320
- `)}a(bte,"stripGitmodulesEntry")});var ef=v(gA=>{"use strict";Object.defineProperty(gA,"__esModule",{value:!0});gA.gitBlobSha=Ste;async function Ste(n,e){let t=new TextEncoder,r=typeof n=="string"?t.encode(n):n,i=t.encode(`blob ${r.byteLength}\0`),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),e(s)}a(Ste,"gitBlobSha")});var Tp=v(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});s_.extractAssetUid=tk;s_.detectChanges=Ete;var wte=ef();function tk(n){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(n);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(tk,"extractAssetUid");async function Ete(n){let{localFiles:e,cachedEntries:t,watermark:r,actualBaseTreeSha:i,sha1:s}=n;if(r===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${r.lastSyncedSha} not resolvable on remote`};if(i!==r.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${r.rootTreeSha} != actual ${i} at ${r.lastSyncedSha}`};let o=[],l=new Map;for(let[T,E]of e){let P=await(0,wte.gitBlobSha)(E,s);l.set(T,P),o.push({path:T,blobSha:P,uid:typeof E=="string"?tk(E):void 0})}if(t!==void 0)for(let[T,E]of t)l.set(T,E.blobSha),o.push({path:T,blobSha:E.blobSha,uid:E.uid});let c=[],u=[],f=[],d=[],p=new Map;for(let T of o){if(T.uid===void 0)continue;let E=p.get(T.uid)??[];E.push(T.path),p.set(T.uid,E)}let h=new Map;for(let T of r.files){if(T.uid===void 0)continue;let E=h.get(T.uid)??[];E.push(T.path),h.set(T.uid,E)}let _=new Set;for(let[T,E]of p)E.length>1&&_.add(T);for(let[T,E]of h)E.length>1&&_.add(T);for(let T of[..._].sort()){let E=p.get(T)??[],P=E.length>1?`on disk (${E.join(", ")})`:`in the sync base (${(h.get(T)??[]).join(", ")})`;d.push(`duplicate uid ${T} ${P} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let y=new Map,b=[];for(let T of r.files)T.uid!==void 0&&!_.has(T.uid)?y.set(T.uid,T):b.push(T);let S=[],I=new Set;for(let T of o){let E=T.uid!==void 0&&!_.has(T.uid)?y.get(T.uid):void 0;T.uid!==void 0&&E!==void 0?(I.add(T.uid),(E.blobSha!==T.blobSha||E.path!==T.path)&&u.push({path:T.path,uid:T.uid,blobSha:T.blobSha,...E.path!==T.path?{basePath:E.path}:{}})):S.push(T)}let O=new Map;for(let T of b)O.set(T.path,T);for(let[T,E]of y)I.has(T)||O.set(E.path,E);for(let T of S){let E=O.get(T.path);E!==void 0?(O.delete(T.path),E.blobSha!==T.blobSha&&u.push({path:T.path,uid:T.uid,blobSha:T.blobSha})):c.push({path:T.path,uid:T.uid,blobSha:T.blobSha})}for(let T of O.values())f.push({path:T.path,uid:T.uid,blobSha:T.blobSha});return{kind:"changes",added:c,modified:u,deleted:f,warnings:d,diskBlobShas:l,duplicateUids:_}}a(Ete,"detectChanges")});var ik=v(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});Ap.rewriteAssetUid=rk;Ap.findDuplicateUidGroups=nk;Ap.planDuplicateUidFix=Tte;var vte=Tp();function rk(n,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(n);if(t===null)return n;let r=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return r===t[2]?n:n.slice(0,t.index)+t[1]+r+t[3]+n.slice(t.index+t[0].length)}a(rk,"rewriteAssetUid");function nk(n){let e=new Map;for(let t of n){let r=(0,vte.extractAssetUid)(t.content);if(r===void 0)continue;let i=e.get(r)??[];i.push(t.path),e.set(r,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>({uid:t,paths:r}))}a(nk,"findDuplicateUidGroups");function Tte(n,e){let t=new Map(n.map(i=>[i.path,i.content])),r=[];for(let i of nk(n)){let s=[...i.paths].sort((o,l)=>o.localeCompare(l));for(let o of s.slice(1)){let l=t.get(o);if(l===void 0)continue;let c=e(),u=rk(l,c);u!==l&&r.push({path:o,fromUid:i.uid,toUid:c,content:u})}}return r}a(Tte,"planDuplicateUidFix")});var tf=v(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});cc.getHeadSha=Ite;cc.getCommitInfo=xte;cc.getTree=Rte;cc.getBlobText=Cte;cc.getBlobBytes=Ote;var sk=Vc(),Ate="https://api.github.com";function Ip(n){return(n??Ate).replace(/\/$/,"")}a(Ip,"api");function lc(n){return n!==null&&typeof n=="object"?n:void 0}a(lc,"asRecord");function Ys(n,e){let r=lc(n)?.[e];return typeof r=="string"?r:void 0}a(Ys,"readString");async function Ite(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(r)}`}),o=Ys(lc(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${r}`);return o}a(Ite,"getHeadSha");async function xte(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(r)}`}),o=lc(s?.json),l=Ys(o,"sha"),c=Ys(o?.tree,"sha");if(!l||!c)throw new Error(`ExoSync: malformed commit response for ${r}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>Ys(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:l,treeSha:c,parents:f}}a(xte,"getCommitInfo");async function Rte(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(r)}?recursive=1`}),o=lc(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${r} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let l=o?.tree;if(!Array.isArray(l))throw new Error(`ExoSync: malformed tree response for ${r}`);let c=[];for(let u of l){let f=lc(u);if(f?.type!=="blob")continue;let d=Ys(f,"path"),p=Ys(f,"sha"),h=typeof f.size=="number"?f.size:void 0;d&&p&&c.push({path:d,blobSha:p,...h!==void 0?{size:h}:{}})}return c}a(Rte,"getTree");async function Cte(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=lc(s?.json),l=Ys(o,"content");if(typeof l!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ys(o,"encoding")==="utf-8"?l:(0,sk.base64ToUtf8)(l)}a(Cte,"getBlobText");async function Ote(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=lc(s?.json),l=Ys(o,"content");if(typeof l!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ys(o,"encoding")==="utf-8"?new TextEncoder().encode(l):(0,sk.base64ToBytes)(l)}a(Ote,"getBlobBytes")});var ak=v(yA=>{"use strict";Object.defineProperty(yA,"__esModule",{value:!0});yA.checkParkedStaleness=Dte;var Pte=tf();async function Dte(n,e){let t={repoKey:n.repoKey,localPath:n.localPath},r=e.redact??(o=>o),i=null;try{let l=(await e.watermarks.get(n.repoKey))?.lastSyncedSha??"";l.length>0&&(i=l)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:`watermark unreadable: ${r(ok(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,Pte.getHeadSha)(e.transport,n.owner,n.repo,n.branch,e.baseURL)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:i,remoteHeadSha:null,reason:`remote unreachable: ${r(ok(o))}`}}return{...t,freshness:s===i?"current":"behind",lastSyncedSha:i,remoteHeadSha:s}}a(Dte,"checkParkedStaleness");function ok(n){return n instanceof Error?n.message:String(n)}a(ok,"errorText")});var SA=v(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.SyncPhaseTimer=nr.SYNC_PHASES=void 0;nr.classifyRestPhase=Fte;nr.emptyTimings=ck;nr.totalMs=o_;nr.addTimings=uk;nr.aggregateTimings=Lte;nr.dominantPhase=Nte;nr.fmtMs=xp;nr.formatTimingsLine=kte;nr.formatRepoTimings=Mte;nr.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function bA(){let n={};for(let e of nr.SYNC_PHASES)n[e]=0;return n}a(bA,"zeroDurations");function lk(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(lk,"zeroCounts");function Fte(n){if(n.method!=="GET")return"restPush";let e=n.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(Fte,"classifyRestPhase");var _A=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=bA(),this.counts=lk()}async time(e,t){let r=this.now();try{return await t()}finally{this.durations[e]+=this.now()-r}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};nr.SyncPhaseTimer=_A;function ck(){return{durations:bA(),counts:lk()}}a(ck,"emptyTimings");function o_(n){let e=0;for(let t of nr.SYNC_PHASES)e+=n.durations[t];return e}a(o_,"totalMs");function uk(n,e){let t=bA();for(let r of nr.SYNC_PHASES)t[r]=n.durations[r]+e.durations[r];return{durations:t,counts:{filesRead:n.counts.filesRead+e.counts.filesRead,filesHashed:n.counts.filesHashed+e.counts.filesHashed,filesWritten:n.counts.filesWritten+e.counts.filesWritten,restCalls:n.counts.restCalls+e.counts.restCalls}}}a(uk,"addTimings");function Lte(n){let e=ck();for(let t of n)t.timings!==void 0&&(e=uk(e,t.timings));return e}a(Lte,"aggregateTimings");function Nte(n){let e=o_(n);if(e<=0)return null;let t=nr.SYNC_PHASES[0],r=-1;for(let i of nr.SYNC_PHASES)n.durations[i]>r&&(r=n.durations[i],t=i);return{phase:t,ms:r,pct:r/e*100}}a(Nte,"dominantPhase");function xp(n){return n>=1e3?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}a(xp,"fmtMs");function kte(n){let e=o_(n);if(e<=0)return"";let t=nr.SYNC_PHASES.filter(r=>n.durations[r]>0).sort((r,i)=>n.durations[i]-n.durations[r]).map(r=>`${r} ${xp(n.durations[r])} ${Math.round(n.durations[r]/e*100)}%`);return`\u23F1 ExoSync ${xp(e)} \u2014 ${t.join(" \xB7 ")} (${n.counts.filesHashed} hashed, ${n.counts.filesRead} read, ${n.counts.restCalls} REST)`}a(kte,"formatTimingsLine");function Mte(n,e){let t=nr.SYNC_PHASES.map(r=>`${r}=${xp(e.durations[r])}`);return`[ExoSync timings] ${n}: total ${xp(o_(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(Mte,"formatRepoTimings")});var a_=v(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.LocalOutboxStore=Ba.OUTBOX_REMOTE_ABSENT=Ba.OUTBOX_STORE_FILENAME=void 0;Ba.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";Ba.OUTBOX_REMOTE_ABSENT=" absent";function wA(n,e){return`${n}\0${e}`}a(wA,"outboxKey");function fk(n){if(n===null||typeof n!="object")return!1;let e=n;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(fk,"isEntry");var EA=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[wA(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(r=>{delete r.entries[wA(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(fk)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[wA(e,t)];return i!==void 0&&fk(i)}async mutate(e){let t=this.writeChain.then(async()=>{let r=await this.read();e(r),await this.io.writeAtomic(JSON.stringify(r,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 r=t.entries;return r===null||typeof r!="object"?{version:1,entries:{}}:{version:1,entries:{...r}}}catch{return{version:1,entries:{}}}}};Ba.LocalOutboxStore=EA});var l_=v(vA=>{"use strict";Object.defineProperty(vA,"__esModule",{value:!0});vA.isAuthError=jte;function jte(n){let e=n instanceof Error?n.message:String(n);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(jte,"isAuthError")});var TA=v(c_=>{"use strict";Object.defineProperty(c_,"__esModule",{value:!0});c_.scanForSecrets=$te;c_.redactSecrets=Ute;var dk=[{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 $te(n){let e=[];for(let[t,r]of n)for(let{kind:i,re:s}of dk)s.test(r)&&e.push({path:t,kind:i});return e}a($te,"scanForSecrets");function Ute(n){let e=n;for(let{kind:t,re:r}of dk)e=e.replace(new RegExp(r.source,"g"),`[REDACTED:${t}]`);return e}a(Ute,"redactSecrets")});var xA=v(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.caseInsensitiveHeaderGetter=Bte;Va.parseRetryAfterMs=pk;Va.extractRateLimitFields=hk;Va.getRateLimitFields=Vte;Va.attachRateLimitFields=mk;Va.enrichRateLimitError=qte;function Bte(n){let e=new Map;if(n&&typeof n=="object")for(let[t,r]of Object.entries(n))typeof r=="string"&&e.set(t.toLowerCase(),r);return t=>e.get(t.toLowerCase())}a(Bte,"caseInsensitiveHeaderGetter");function IA(n){if(n==null)return;let e=n.trim();if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0}a(IA,"parseIntHeader");function pk(n,e=Date.now){if(n==null)return;let t=n.trim();if(t.length===0)return;let r=IA(t);if(r!==void 0)return Math.max(0,r*1e3);let i=Date.parse(t);if(!Number.isNaN(i))return Math.max(0,i-e())}a(pk,"parseRetryAfterMs");function hk(n,e=Date.now){let t={},r=pk(n("retry-after"),e);r!==void 0&&(t.retryAfterMs=r);let i=IA(n("x-ratelimit-reset"));i!==void 0&&(t.rateLimitReset=i);let s=IA(n("x-ratelimit-remaining"));return s!==void 0&&(t.rateLimitRemaining=s),t}a(hk,"extractRateLimitFields");function Vte(n){if(n===null||typeof n!="object")return{};let e=n,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(Vte,"getRateLimitFields");function AA(n,e,t){Object.defineProperty(n,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}a(AA,"defineHidden");function mk(n,e){return e.retryAfterMs!==void 0&&AA(n,"retryAfterMs",e.retryAfterMs),e.rateLimitReset!==void 0&&AA(n,"rateLimitReset",e.rateLimitReset),e.rateLimitRemaining!==void 0&&AA(n,"rateLimitRemaining",e.rateLimitRemaining),n}a(mk,"attachRateLimitFields");function qte(n,e,t=Date.now){return mk(n,hk(e,t))}a(qte,"enrichRateLimitError")});var u_=v(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});Ci.DEFAULT_MAX_RETRIES=Ci.MIN_RATE_LIMIT_WAIT_MS=void 0;Ci.isRateLimitError=gk;Ci.createRateLimitBudget=Wte;Ci.withRateLimitBackoff=Kte;var Gte=xA();function gk(n){let e=n instanceof Error?n.message:String(n);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(gk,"isRateLimitError");Ci.MIN_RATE_LIMIT_WAIT_MS=6e4;Ci.DEFAULT_MAX_RETRIES=6;function Wte(n){let e=!(n>0),t=e?Number.POSITIVE_INFINITY:n;return{reset(){t=e?Number.POSITIVE_INFINITY:n},tryReserve(r){return r<=0?!0:r<=t?(t-=r,!0):!1}}}a(Wte,"createRateLimitBudget");var Hte=a(n=>new Promise(e=>setTimeout(e,n)),"defaultSleep");function zte(n,e,t,r,i,s){let o=(0,Gte.getRateLimitFields)(n);if(typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0)return o.retryAfterMs;if(o.rateLimitRemaining===0&&typeof o.rateLimitReset=="number"){let c=o.rateLimitReset*1e3-s();if(c>0)return c}let l=t*2**e*(1+i());return Math.max(r,l)}a(zte,"computeRateLimitDelay");function Kte(n,e={}){let t=e.maxRetries??Ci.DEFAULT_MAX_RETRIES,r=e.baseDelayMs??1e3,i=Math.max(Ci.MIN_RATE_LIMIT_WAIT_MS,e.minRateLimitWaitMs??Ci.MIN_RATE_LIMIT_WAIT_MS),s=e.budget,o=e.sleep??Hte,l=e.random??Math.random,c=e.now??(()=>Date.now());return async u=>{let f=0;for(;;)try{return await n(u)}catch(d){if(!gk(d)||f>=t)throw d;let p=zte(d,f,r,i,l,c);if(s!==void 0&&!s.tryReserve(p))throw d;f++,await o(p)}}}a(Kte,"withRateLimitBackoff")});var f_=v(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.DEFAULT_MAX_FILE_BYTES=Jo.InMemoryQuarantineStore=void 0;Jo.contentEquals=Yte;Jo.isSyncablePath=Qte;Jo.isFileSpaceSyncablePath=Xte;function Yte(n,e){if(n===void 0||e===void 0||typeof n=="string"&&typeof e=="string")return n===e;if(typeof n=="string"||typeof e=="string"||n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return!1;return!0}a(Yte,"contentEquals");var RA=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};Jo.InMemoryQuarantineStore=RA;function Qte(n){return n.endsWith(".md")&&!n.includes(".local.")&&!n.includes(".conflict.")}a(Qte,"isSyncablePath");function Xte(n){return!n.includes(".local.")&&!n.includes(".conflict.")}a(Xte,"isFileSpaceSyncablePath");Jo.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var Ik=v(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.SyncEngine=fn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=fn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=fn.DEFAULT_MAX_PUSH_RETRIES=void 0;fn.syncProgressPhaseText=ere;fn.isNonFastForwardError=Ak;fn.orderChildrenFirst=lre;var yk=n_(),_k=SA(),_t=tf(),Qs=Tp(),Jte=Vc(),uc=ef(),CA=a_(),Zte=l_(),bk=TA(),Sk=u_(),Xs=f_();fn.DEFAULT_MAX_PUSH_RETRIES=3;fn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=3e5;fn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function ere(n){switch(n.phase){case"reading-local":return n.detail!==void 0?`reading local files ${n.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 n.detail!==void 0?`fetching remote files ${n.detail.done}/${n.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return n.detail!==void 0?`writing files ${n.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return n.phase}}a(ere,"syncProgressPhaseText");var wk=25,tre=10,rre=6,nre=500,ire=25;function sre(n){try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{return null}}a(sre,"decodeUtf8Strict");function ore(n){return typeof n=="string"?n:{base64:(0,Jte.bytesToBase64)(n)}}a(ore,"toCommitContent");async function Ek(n,e){if(n.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return n.readBinary(e)}a(Ek,"readBinaryStrict");async function are(n,e,t){if(n.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return n.writeBinary(e,t)}a(are,"writeBinaryStrict");function vk(n){return n.length===0||n.startsWith("/")||n.includes("\\")?!1:n.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(vk,"isSafeRepoRelativePath");function Ak(n){let e=n instanceof Error?n.message:String(n);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(Ak,"isNonFastForwardError");function lre(n){let e=a(t=>t.split("/").filter(r=>r.length>0).length,"depth");return[...n].sort((t,r)=>e(r.localPath)-e(t.localPath))}a(lre,"orderChildrenFirst");function Tk(n,e){let t=new Map(n.map(o=>[o.path,o])),r=new Set,i=[];for(let o of e){r.add(o.path);let l=t.get(o.path);(l===void 0||l.blobSha!==o.blobSha)&&i.push(o)}let s=n.filter(o=>!r.has(o.path));return{changed:i,deleted:s}}a(Tk,"diffTrees");function qa(n){return n instanceof Error?n.message:String(n)}a(qa,"errMsg");function cre(n,e,t){if(t.size===0)return n;let r=new Map(e.files.map(o=>[o.path,o])),i=new Set(n.map(o=>o.path)),s=[];for(let o of n){if(!t.has(o.path)){s.push(o);continue}let l=r.get(o.path);l!==void 0&&s.push(l)}for(let o of t){if(i.has(o))continue;let l=r.get(o);l!==void 0&&s.push(l)}return s}a(cre,"applyWatermarkPins");var OA={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function PA(n){return new Map(n.map(e=>[e.path,e.blobSha]))}a(PA,"treeByPath");function d_(n){return[...n.quarantineEntries.map(e=>e.path),...n.resolvedQuarantineEntries.map(e=>e.path)]}a(d_,"quarantinedPathsOf");var DA=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,Sk.createRateLimitBudget)(e.backoff?.maxTotalRateLimitWaitMs??fn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS),this.transport=this.instrumentTransport((0,Sk.withRateLimitBackoff)(e.transport,{...e.backoff,budget:this.rateLimitBudget,now:this.now})),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpRest(),r.time((0,_k.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpHashed(),r.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((l,c)=>{let u=this.activeTimer;return u===null?c():u.time(l,c)},"timed"),r={list:a(()=>t("localList",()=>e.list()),"list"),read:a(l=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(l))),"read"),write:a((l,c)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(l,c))),"write"),delete:a(l=>e.delete(l),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(r.readBinary=l=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(l))));let s=e.writeBinary?.bind(e);s!==void 0&&(r.writeBinary=(l,c)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(l,c))));let o=e.stat?.bind(e);return o!==void 0&&(r.stat=l=>t("localList",()=>o(l))),r}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",r=t?Xs.isFileSpaceSyncablePath:Xs.isSyncablePath,i=this.deps.maxFileBytes??Xs.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:r,treeFilter:a(s=>r(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,r,i){let s=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,_t.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(r.treeFilter),c=[];for(let u of l){let f=t.get(u.path);f!==void 0&&await(0,uc.gitBlobSha)(f,this.sha1)===u.blobSha&&c.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${c.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:c,spaceKind:"file"}}async syncAll(e,t="sync",r){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,r));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",r){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0,this.rateLimitBudget.reset();try{return await this.syncLocked(e,t,r)}finally{this.opInProgress=!1}}emitProgress(e,t,r,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:r}:{repoKey:t,phase:r,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%nre===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%ire===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",r){let i=new _k.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=r!==void 0?{emit:r,repoKey:e.repoKey,reads:0,writes:0}:null;let l=[],c=[],u=0,f=0,d=[],p=a((h,_={})=>({repoKey:e.repoKey,status:h,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:l,deferredDeletes:c,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),..._}),"result");try{let h=await this.deps.materializationCheck.check(e);if(!h.fullyMaterialized)return l.push(`skipped: repo not fully materialized${h.reason?` (${h.reason})`:""} \u2014 deletes NOT inferred (D19)`),p("skipped-not-materialized");let _=this.modeOps(e),y=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(_.fileMode&&(y.readBinary===void 0||y.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(_.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 b=this.deps.maxFileBytes??Xs.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let ee=await this.flushOutbox(e,l);u=ee.pushed,f=ee.reconflicted}let S=await this.deps.watermarkStore.get(e.repoKey);if(S?.spaceKind==="file"&&!_.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)"});S!==null&&_.fileMode&&S.spaceKind!=="file"&&(l.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),S=null);let I=this.deps.localManifestStore!==void 0?y.stat?.bind(y):void 0,O=I!==void 0&&S!==null&&!_.fileMode,T=O&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,E=this.deps.localManifestFullRehashMs??fn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,P=O&&(T===null||this.now()-T.lastFullRehashMs>=E),V=new Map,M=new Set,j=new Map,$=new Map,G=new Map,ge=!1,ye=new Map;if(O&&S!==null)for(let ee of S.files)ye.set(ee.path,ee.blobSha);for(let ee of(await y.list()).filter(_.syncable)){if(_.fileMode){let Pe=await Ek(y,ee);if(Pe.byteLength>b){M.add(ee),l.push(`skipped oversized file ${ee} (${Pe.byteLength} bytes > ${b} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}V.set(ee,Pe);continue}if(!O||I===void 0){V.set(ee,await y.read(ee));continue}let _e=await I(ee),Te=!P&&_e!==null?T?.files[ee]:void 0;if(_e!==null&&Te!==void 0&&Te.mtimeMs===_e.mtimeMs&&Te.size===_e.size&&Te.blobSha===ye.get(ee)){j.set(ee,{blobSha:Te.blobSha,...Te.uid!==void 0?{uid:Te.uid}:{}}),$.set(ee,Te.blobSha),G.set(ee,_e);continue}ge=!0,V.set(ee,await y.read(ee)),_e!==null&&G.set(ee,_e)}let Q=!1;if(S===null)if(_.fileMode)Q=!0,S=await this.buildFileModeFirstSyncBase(e,V,_,l);else{let ee=await this.bootstrapWatermark(e,V,l,p);if(ee.kind==="settled")return ee.outcome;Q=!0,S=ee.base}let se=S;_.fileMode&&M.size>0&&(S={...S,files:S.files.filter(ee=>!M.has(ee.path))});let J,ve;O&&!P?(J=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),ve=J===S.lastSyncedSha?S.rootTreeSha:await this.resolveBaseTreeSha(e,S)):ve=await this.resolveBaseTreeSha(e,S),this.emitProgress(r,e.repoKey,"detecting");let re=await(0,Qs.detectChanges)({localFiles:V,...O?{cachedEntries:j}:{},watermark:S,actualBaseTreeSha:ve,sha1:this.sha1});if(re.kind==="full-conflict")return p("full-conflict",{detail:`${re.reason}${re.detail?`: ${re.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(l.push(...re.warnings),O&&this.deps.localManifestStore!==void 0){let ee={};for(let[_e,Te]of V){let Pe=G.get(_e),Me=re.diskBlobShas.get(_e);if(Pe===void 0||Me===void 0)continue;let Ne=typeof Te=="string"?(0,Qs.extractAssetUid)(Te):void 0;ee[_e]={mtimeMs:Pe.mtimeMs,size:Pe.size,blobSha:Me,...Ne!==void 0?{uid:Ne}:{}}}for(let[_e,Te]of j){let Pe=G.get(_e);Pe!==void 0&&(ee[_e]={mtimeMs:Pe.mtimeMs,size:Pe.size,blobSha:Te.blobSha,...Te.uid!==void 0?{uid:Te.uid}:{}})}if(T!==null&&Object.keys(T.files).some(_e=>!(_e in ee))&&(ge=!0),ge||P||T===null){let _e={version:1,files:ee,lastFullRehashMs:P||T===null?this.now():T.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,_e)}}let ie=this.pinLocalChanges(re,V,l,c,t);d=[...ie.pushDeletionsAll.keys()];let he=await this.runPushLoop(e,S,ie,V,l,_,Q,M,t,r,J);if(d=[],he.kind!=="done"&&ie.pushDeletionsAll.size>0&&c.push(...ie.pushDeletionsAll.keys()),he.kind==="conflict")return p("conflict",{detail:he.detail});if(he.kind==="retry-exhausted"){l.push(...he.merge.warnings);let ee=await this.buildTerminalQuarantineEntries(e,S,he.pushFiles,he.merge.quarantineEntries,V),_e=[...he.merge.quarantineEntries,...he.merge.resolvedQuarantineEntries,...ee];return await this.flushQuarantine(_e,l),p("retry-exhausted",{detail:he.detail,quarantinedCount:_e.length,..._e.length>0?{quarantinedPaths:_e.map(Te=>Te.path)}:{}})}let{examinedHead:Ue,pushedSha:ce,applyWrites:ue,applyDeletes:fe,pushFiles:ne}=he,me=he.merge;l.push(...me.warnings),l.push(...he.deferredWarnings),c.push(...he.withheldDeletions);let Le=he.deferredPaths.size>0?{deferredPaths:[...he.deferredPaths]}:{},B=he.pushedDeletions.length>0?{pushedDeletes:he.pushedDeletions}:{},oe=await this.flushQuarantine([...me.quarantineEntries,...me.resolvedQuarantineEntries],l);he.secretQuarantineEntries.length>0&&await this.flushQuarantine(he.secretQuarantineEntries,l);let Ee=new Set;if(!oe&&me.resolvedQuarantineEntries.length>0){for(let ee of me.resolvedQuarantineEntries)Ee.add(ee.path);l.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${Ee.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(ce===void 0&&Ue===S.lastSyncedSha&&ue.length===0&&fe.length===0&&me.mergedWrites.length===0&&me.quarantineEntries.length===0&&me.resolvedQuarantineEntries.length===0&&(S.pinnedPaths?.length??0)===0&&he.alreadyInHead.length===0&&he.deferredPaths.size===0&&!Q)return p("synced");let Ce=ce??Ue,xe=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,Ce,this.deps.baseURL);if(ce!==void 0&&xe.parents[0]!==Ue)return await this.checkRaceWindow(e,S,Ue,xe.parents[0],ne,new Set(he.pushedDeletions),l,_),l.push(`race-window: watermark NOT advanced (pushed commit's parent ${xe.parents[0]} != examined head ${Ue}) \u2014 next sync reconciles the concurrent change`),p("synced",{pushedSha:ce,pushedCount:ne.size,mergedCount:me.mergedCount,quarantinedCount:me.quarantineEntries.length+me.resolvedQuarantineEntries.length,...me.mergedPaths.length>0?{mergedPaths:me.mergedPaths}:{},...d_(me).length>0?{quarantinedPaths:d_(me)}:{},...Le,...B});let{pulledCount:Oe,pinnedPaths:Re,pulledPaths:Ae}=await this.applyRemoteChanges(y,V,[...ue,...me.mergedWrites].filter(ee=>!Ee.has(ee.path)),fe.filter(ee=>!Ee.has(ee.path)),l,$);for(let ee of me.quarantineEntries)Re.add(ee.path);for(let ee of he.deferredPaths)Re.add(ee);for(let ee of Ee)Re.add(ee);if(_.fileMode){for(let ee of M)Re.add(ee);for(let ee of he.remoteOversized)Re.add(ee)}return await this.advanceWatermark(e,Ce,xe.treeSha,V,[...ue,...me.mergedWrites,...he.deferredRemoteChanges],se,Re,re.diskBlobShas,_,M),await this.resolveClearedPins(e,se,Re,l,new Set(me.resolvedQuarantineEntries.map(ee=>ee.path))),p("synced",{pushedSha:ce,pulledCount:Oe,pushedCount:ne.size,mergedCount:me.mergedCount,quarantinedCount:me.quarantineEntries.length+me.resolvedQuarantineEntries.length,...me.mergedPaths.length>0?{mergedPaths:me.mergedPaths}:{},...Ae.length>0?{pulledPaths:Ae}:{},...d_(me).length>0?{quarantinedPaths:d_(me)}:{},...Le,...B})}catch(h){let _=this.deps.redact??(y=>y);return d.length>0&&c.push(...d),(0,Zte.isAuthError)(h)?p("auth-required",{detail:_(`authentication failed: ${qa(h)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)}):(l.push(`sync failed: ${_(qa(h))}`),p("error",{detail:_(qa(h))}))}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let r=this.deps.redact??(s=>s);for(let s of e)t.push(r(`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??(l=>l);return t.push(`quarantine sink failed: ${o(qa(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let r=this.deps.outbox;if(r===void 0)return{pushed:0,reconflicted:0};let i=await r.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(_=>_),o,l;try{({head:o,shaByPath:l}=await this.outboxHeadTreeShas(e))}catch(_){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(qa(_))}`),{pushed:0,reconflicted:0}}let c=0,u=[];for(let _ of i){let y=l.get(_.path)??CA.OUTBOX_REMOTE_ABSENT,b=y===CA.OUTBOX_REMOTE_ABSENT&&_.baseRemoteSha!==CA.OUTBOX_REMOTE_ABSENT?[...l].filter(([S,I])=>S!==_.path&&I===_.baseRemoteSha).map(([S])=>S):[];if(y!==_.baseRemoteSha&&b.length===0){await r.remove(_.repoKey,_.path),c++,t.push(s(`outbox: remote moved for ${_.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:_,stalePaths:b})}if(u.length===0)return{pushed:0,reconflicted:c};let f=new Map;for(let{entry:_}of u)f.set(_.path,_.chosenContent);let d=new Set;for(let{stalePaths:_}of u)for(let y of _)f.has(y)||d.add(y);let p=[...d];try{await(0,yk.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(_){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(qa(_))}`),{pushed:0,reconflicted:c}}let h=0;for(let{entry:_,stalePaths:y}of u){let b=y.filter(S=>!f.has(S));await this.snapOutboxWatermark(e,_.path,_.chosenContent,b),await this.deps.quarantine?.markResolved?.(_.repoKey,_.path);for(let S of b)await this.deps.quarantine?.markResolved?.(_.repoKey,S);await r.remove(_.repoKey,_.path),h++,b.length>0&&t.push(`consolidated cross-path conflict for ${_.path} \u2014 removed ${b.length} stale remote copy/copies (recoverable in git history)`)}return h>0&&t.push(`pushed ${h} resolved conflict(s)`),{pushed:h,reconflicted:c}}async outboxHeadTreeShas(e){let t=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,_t.getTree)(this.transport,e.owner,e.repo,r.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,r,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),l=(s.pinnedPaths??[]).filter(y=>!o.has(y)),c=await(0,uc.gitBlobSha)(r,this.sha1),u=(0,Qs.extractAssetUid)(r),f={path:t,blobSha:c,...u!==void 0?{uid:u}:{}},d=new Set(i),p=s.files.filter(y=>!d.has(y.path)),h=p.findIndex(y=>y.path===t),_=h>=0?p.map((y,b)=>b===h?f:y):[...p,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:_,...l.length>0?{pinnedPaths:l}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,r,i,s){let o=new Set(i.map(u=>u.path)),l=new Map;try{let u=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,_t.getTree)(this.transport,e.owner,e.repo,(await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>r.has(d.path));for(let d of f)l.set(d.path,await(0,_t.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let c=[];for(let[u,f]of r){if(o.has(u))continue;let d=s.get(u),p=d??f,h=d!==void 0&&!(0,Xs.contentEquals)(d,f),_=typeof p=="string"?(0,Qs.extractAssetUid)(p):void 0,y=l.get(u);c.push({repoKey:e.repoKey,path:u,..._!==void 0?{uid:_}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??fn.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},...y!==void 0?{remoteContent:y}:{}})}return c}async resolveClearedPins(e,t,r,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let l=(t.pinnedPaths??[]).filter(c=>!r.has(c)&&!s.has(c));for(let c of l)try{await o.markResolved?.(e.repoKey,c)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${c}: ${f(qa(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t){try{return(await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch{return null}}pinLocalChanges(e,t,r,i,s){let o=e.modified.filter(p=>p.basePath!==void 0),l=[...e.added,...e.modified.filter(p=>p.basePath===void 0)],c=new Map;if(s==="pull"){for(let p of o)p.basePath!==void 0&&i.push(p.basePath),r.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),r.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&&c.set(p.basePath,p.path);for(let p of e.deleted)c.set(p.path,p.path)}let u=[...l,...o,...e.deleted.map(p=>({...p}))],f=new Set(e.deleted.map(p=>p.path)),d=new Map;for(let p of[...l,...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:c,dupUids:e.duplicateUids}}async runPushLoop(e,t,r,i,s,o,l=!1,c=new Set,u="sync",f,d){let{localChanges:p,localDeletedPaths:h,pushFilesAll:_,pushDeletionsAll:y,dupUids:b}=r,S=this.deps.maxPushRetries??fn.DEFAULT_MAX_PUSH_RETRIES,I=0,O="",T,E=[],P=[],V=new Map,M=new Set,j=[],$=OA,G=[],ge=new Set,ye=[],Q=[],se=new Set,J=[],ve=new Set;for(;;){O=I===0&&d!==void 0&&_.size===0&&y.size===0?d:await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),E=[],P=[],$=OA,G=[],ge=new Set,ye=[],Q=[];let re,ie=new Set,he=(t.pinnedPaths?.length??0)>0;if(O!==t.lastSyncedSha||he||l){this.emitProgress(f,e.repoKey,"pulling-remote");let ue=await this.collectRemoteChanges(e,t,O,o,c,s,se,f);re=ue.headTreeByPath;let fe=this.matchLocalVsRemote(p,h,i,ue.changes,ie,b,ue.headTreeByPath);if(fe.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let ne of fe.conflicts){ge.add(ne.local.path),ne.local.basePath!==void 0&&ge.add(ne.local.basePath);for(let me of ne.remotes)ge.add(me.path),me.kind==="change"&&ye.push(me)}Q.push(`${u}-only: ${fe.conflicts.length} conflict(s) deferred to a full Sync (${fe.conflicts.map(ne=>ne.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)$=this.resolveFileModeConflicts(e,fe.conflicts,i,fe.applyWrites,fe.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${fe.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};$=await this.resolveMergeConflicts(e,t,fe.conflicts,i)}if(u==="sync")for(let ne of fe.conflicts)for(let me of ne.remotes)me.path!==ne.local.path&&(ge.add(me.path),me.kind==="change"&&ye.push(me),Q.push(`conflict group ${ne.desc}: remote change at ${me.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(E=fe.applyWrites,P=fe.applyDeletes,u==="push"&&(E.length>0||P.length>0)){for(let ne of E)ge.add(ne.path),ye.push(ne);for(let ne of P)ge.add(ne.path);Q.push(`push-only: ${E.length+P.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),E=[],P=[]}}V=u==="pull"?new Map:new Map([...[..._].filter(([ue])=>!ie.has(ue)),...$.mergedFiles]),M=new Set,j=[];for(let[ue,fe]of y){if(ie.has(fe)){j.push(ue);continue}V.has(ue)||M.add(ue)}if((V.size>0||M.size>0)&&re===void 0&&(re=PA(await(0,_t.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),V.size>0&&re!==void 0){for(let[ue,fe]of V){let ne=re.get(ue);ne!==void 0&&ne===await(0,uc.gitBlobSha)(fe,this.sha1)&&(V.delete(ue),G.push(ue))}G.length>0&&s.push(`phantom push skipped: ${G.length} file(s) already identical in remote HEAD (${G.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(M.size>0&&re!==void 0){for(let ue of[...M])re.has(ue)||M.delete(ue);V.size===0&&M.size>=re.size&&(j.push(...M),Q.push(`deletion of ALL ${M.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`),M.clear())}if(V.size===0&&M.size===0)break;let Ue=new Map;for(let[ue,fe]of V)if(typeof fe=="string")Ue.set(ue,fe);else{let ne=sre(fe);ne!==null&&Ue.set(ue,ne)}let ce=(0,bk.scanForSecrets)(Ue);if(ce.length>0){let ue=new Map;for(let fe of ce){let ne=ue.get(fe.path);ne===void 0?ue.set(fe.path,[fe.kind]):ne.includes(fe.kind)||ne.push(fe.kind)}for(let[fe,ne]of ue){if(!ve.has(fe)){ve.add(fe);let me=Ue.get(fe),Le=me!==void 0?(0,bk.redactSecrets)(me):void 0,B=Le!==void 0?(0,Qs.extractAssetUid)(Le):void 0;J.push({repoKey:e.repoKey,path:fe,...B!==void 0?{uid:B}:{},reason:`secret-scan (R5): detected ${ne.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.`,...Le!==void 0?{localContent:Le}:{}})}V.delete(fe)}s.push(`secret-scan (R5): skipped ${ue.size} file(s) with a detected secret from the push \u2014 the rest of the changeset shipped; REVOKE the credential(s): ${[...ue].map(([fe,ne])=>`${fe} (${ne.join(", ")})`).join(", ")}`);for(let[fe,ne]of y)ve.has(ne)&&M.has(fe)&&(M.delete(fe),j.push(fe));if(V.size===0&&M.size===0)break}try{T=await(0,yk.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...V].map(([ue,fe])=>[ue,ore(fe)])),deletions:[...M],message:this.deps.commitMessage?.(e,V.size,M.size)??`chore(exosync): sync ${V.size} file(s)${M.size>0?`, ${M.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(ue){if(!Ak(ue))throw ue;if(I++,I>S)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${S} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:V,merge:$};s.push(`non-fast-forward push (attempt ${I}/${S}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:O,pushedSha:T,applyWrites:E,applyDeletes:P,pushFiles:V,pushedDeletions:T!==void 0?[...M]:[],withheldDeletions:j,merge:$,remoteOversized:se,alreadyInHead:G,deferredPaths:ge,deferredRemoteChanges:ye,deferredWarnings:Q,secretQuarantineEntries:J}}async resolveMergeConflicts(e,t,r,i){let s=this.deps.mergeLayer;if(s===void 0)return OA;let o=new Map(t.files.map(y=>[y.path,y])),l=new Map,c=[],u=[],f=[],d=[],p=0,h=a(y=>typeof y=="string"?y:void 0,"asText"),_=a((y,b,S)=>{let I=h(i.get(y.local.path)),O=h(y.remotes[0]?.content);return{repoKey:e.repoKey,path:y.local.path,...y.local.uid!==void 0?{uid:y.local.uid}:{},reason:b,...S!==void 0?{baseContent:S}:{},...I!==void 0?{localContent:I}:{},...O!==void 0?{remoteContent:O}:{}}},"entry");for(let y of r){let b=o.get(y.local.basePath??y.local.path)??o.get(y.remotes[0]?.path??""),S;if(b!==void 0&&(S=await(0,_t.getBlobText)(this.transport,e.owner,e.repo,b.blobSha,this.deps.baseURL)),y.remotes.length>1){u.push(_(y,`ambiguous conflict: local change overlaps ${y.remotes.length} remote changes (${y.remotes.map(P=>P.path).join(", ")})`,S));continue}let I=y.remotes[0],O=h(i.get(y.local.path)),T=await s.resolve({path:y.local.path,...y.local.uid!==void 0?{uid:y.local.uid}:{},...S!==void 0?{base:S}:{},...O!==void 0?{local:O}:{},...I.kind==="change"&&typeof I.content=="string"?{remote:I.content}:{}});if(T.action==="quarantine"){u.push(_(y,T.reason,S));continue}p++,d.push(y.local.path);for(let P of T.warnings??[])f.push(`merge(${y.local.path}): ${P}`);let E=I.kind==="change"?I.content:void 0;if(T.content!==E&&l.set(y.local.path,T.content),T.content!==i.get(y.local.path)){let P=(0,Qs.extractAssetUid)(T.content)??y.local.uid;c.push({path:y.local.path,kind:"change",content:T.content,blobSha:await(0,uc.gitBlobSha)(T.content,this.sha1),...P!==void 0?{uid:P}:{}})}}return{mergedFiles:l,mergedWrites:c,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:p,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,r,i,s){let o=[],l=[];for(let c of t){c.remotes.length>1&&l.push(`file-mode conflict on ${c.local.path} unexpectedly overlaps ${c.remotes.length} remote changes \u2014 resolving against the first`);let u=c.remotes[0],f=r.get(c.local.path);u.kind==="change"?i.push(u):s.push(u),!(c.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:c.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:l}}async applyRemoteChanges(e,t,r,i,s,o=new Map){let l=0,c=new Set,u=[],f=a(async(h,_)=>{try{return _?await Ek(e,h):await e.read(h)}catch{return}},"tryRead"),d=a(async(h,_)=>{typeof _=="string"?await e.write(h,_):await are(e,h,_)},"writeContent"),p=a(async h=>{let _=await f(h,!1);return _===void 0?!0:await(0,uc.gitBlobSha)(_,this.sha1)===o.get(h)},"cacheHitUnchanged");for(let h of r){if(h.content===void 0)continue;if(!vk(h.path)){s.push(`unsafe remote path skipped on pull-apply: ${h.path}`),c.add(h.path);continue}let _=t.get(h.path);if(_===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`),c.add(h.path);continue}await d(h.path,h.content),l++,u.push(h.path);continue}let y=await f(h.path,typeof(_??h.content)!="string");if(!(0,Xs.contentEquals)(y,_)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),c.add(h.path);continue}await d(h.path,h.content),l++,u.push(h.path)}for(let h of i){if(!vk(h.path)){s.push(`unsafe remote path skipped on pull-delete: ${h.path}`),c.add(h.path);continue}let _=t.get(h.path);if(_===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`),c.add(h.path);continue}await e.delete(h.path),l++,u.push(h.path);continue}if(_!==void 0){let y=await f(h.path,typeof _!="string");if(y!==void 0&&!(0,Xs.contentEquals)(y,_)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),c.add(h.path);continue}await e.delete(h.path),l++,u.push(h.path)}}return{pulledCount:l,pinnedPaths:c,pulledPaths:u}}async advanceWatermark(e,t,r,i,s,o,l,c,u,f=new Set){let d=(await(0,_t.getTree)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).filter(h=>u.treeFilter(h)&&!f.has(h.path)),p=cre(await this.buildWatermarkFiles(e,d,i,s,o,c,u),o,l);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:r,files:p,...l.size>0?{pinnedPaths:[...l]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,r,i,s){let o=this.deps.mountBaseStore,l=null;if(o!==void 0)try{l=await o.get(e.repoKey)}catch{return null}let c=!1;if(l===null&&this.deps.localBaseShaProvider!==void 0)try{let b=await this.deps.localBaseShaProvider(e);typeof b=="string"&&b.length>0&&(l=b,c=!0)}catch{}if(l===null||t.startsWith(l))return null;let u=300,f=null;try{let b=t;for(let S=0;S<u;S++){let I=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,b,this.deps.baseURL);if(I.sha===l||I.sha.startsWith(l)){f=I;break}if(I.parents.length===0)break;b=I.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,_t.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(b=>(0,Xs.isSyncablePath)(b.path))}catch{return null}let p;try{let b=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);p=PA((await(0,_t.getTree)(this.transport,e.owner,e.repo,b.treeSha,this.deps.baseURL)).filter(S=>(0,Xs.isSyncablePath)(S.path)))}catch{return null}let h=d.filter(b=>!r.has(b.path)&&p.get(b.path)===b.blobSha);if(h.length>0){let b=h.slice(0,3).map(S=>S.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 (${b}); 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 (${b}); 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 _=d.map(b=>({path:b.path,blobSha:b.blobSha})),y={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:_};if(c&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(c?`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:y}}async bootstrapWatermark(e,t,r,i){let s=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,r,i);if(o!==null)return o;let l=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,_t.getTree)(this.transport,e.owner,e.repo,l.treeSha,this.deps.baseURL)).filter(p=>(0,Xs.isSyncablePath)(p.path)),u=[],f;for(let p of c){let h=t.get(p.path);if(h===void 0||await(0,uc.gitBlobSha)(h,this.sha1)!==p.blobSha){f===void 0&&(f=p.path);continue}let _=typeof h=="string"?(0,Qs.extractAssetUid)(h):void 0;u.push({path:p.path,blobSha:p.blobSha,..._?{uid:_}:{}})}let d={lastSyncedSha:s,rootTreeSha:l.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`})}:(r.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===c.length?(await this.deps.watermarkStore.set(e.repoKey,d),r.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(r.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${c.length} files) \u2014 ${t.size-c.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,r,i,s=new Set,o=[],l=new Set,c){let u=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL),f=await(0,_t.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let M of f)i.syncable(M.path)&&!i.treeFilter(M)&&!l.has(M.path)&&(l.add(M.path),o.push(`skipped oversized REMOTE file ${M.path} (${M.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(M=>i.treeFilter(M)&&!s.has(M.path)),p=t.files.filter(M=>!l.has(M.path)&&!s.has(M.path)),{changed:h,deleted:_}=Tk(p,d),y=h.length;y>=wk&&this.emitProgress(c,e.repoKey,"fetching-blobs",{done:0,total:y});let b=new Array(h.length),S=0,I=0,O,T=a(async M=>{if(i.fileMode){let $=await(0,_t.getBlobBytes)(this.transport,e.owner,e.repo,M.blobSha,this.deps.baseURL);return{path:M.path,kind:"change",blobSha:M.blobSha,content:$}}let j=await(0,_t.getBlobText)(this.transport,e.owner,e.repo,M.blobSha,this.deps.baseURL);return{path:M.path,kind:"change",blobSha:M.blobSha,content:j,uid:(0,Qs.extractAssetUid)(j)}},"fetchOne"),E=a(async()=>{for(;;){if(O!==void 0)return;let M=S++;if(M>=h.length)return;try{b[M]=await T(h[M])}catch(j){O===void 0&&(O=j);return}I+=1,y>=wk&&I%tre===0&&I<y&&this.emitProgress(c,e.repoKey,"fetching-blobs",{done:I,total:y})}},"worker"),P=Math.min(rre,h.length);if(await Promise.all(Array.from({length:P},()=>E())),O!==void 0)throw O instanceof Error?O:new Error(String(O));let V=b;for(let M of _)V.push({path:M.path,kind:"delete",uid:M.uid});return{changes:V,headTreeByPath:PA(f)}}matchLocalVsRemote(e,t,r,i,s,o=new Set,l){let c=new Set,u=[],f=new Map;for(let y of i)y.kind==="change"&&y.uid!==void 0&&f.set(y.uid,(f.get(y.uid)??0)+1);let d=new Set(o);for(let[y,b]of f)b>1&&d.add(y);let p=new Map,h=new Map;for(let y of i){if(y.uid!==void 0&&!d.has(y.uid)){let b=p.get(y.uid)??[];b.push(y),p.set(y.uid,b)}h.set(y.path,y)}for(let y of e){let b=new Set;if(y.uid!==void 0&&!d.has(y.uid))for(let T of p.get(y.uid)??[])T.kind==="change"&&T.path!==y.path&&(l?.has(y.path)===!0||y.basePath!==void 0&&l?.has(y.basePath)===!0)||b.add(T);let S=h.get(y.path);if(S!==void 0&&b.add(S),y.basePath!==void 0){let T=h.get(y.basePath);T!==void 0&&b.add(T)}let I=[],O=!1;for(let T of b){if(O=t.has(y.path)&&!r.has(y.path),O&&T.kind==="delete"){c.add(T);continue}if(!O&&T.kind==="change"&&T.path===y.path&&T.blobSha===y.blobSha){c.add(T),s.add(y.path);continue}if(T.kind==="delete"&&y.basePath!==void 0&&T.path===y.basePath){let E=h.get(y.path);if(E!==void 0&&E.kind==="change"&&(E.blobSha===y.blobSha||E.uid!==void 0&&E.uid===y.uid)){c.add(T);continue}}if(T.kind==="delete"&&T.path!==y.path&&T.path!==y.basePath&&!r.has(T.path)&&l?.has(T.path)!==!0){c.add(T);continue}I.push(T),c.add(T)}I.length>0&&(u.push({local:y,localIsDelete:O,remotes:I,desc:`${y.uid!==void 0&&!d.has(y.uid)?y.uid:y.path} (local ${O?"delete":"change"} vs remote ${I[0].kind} at ${I[0].path})`}),s.add(y.path))}let _=i.filter(y=>!c.has(y));return{conflicts:u,applyWrites:_.filter(y=>y.kind==="change"),applyDeletes:_.filter(y=>y.kind==="delete")}}async checkRaceWindow(e,t,r,i,s,o,l,c){try{let u=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,_t.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(c.treeFilter),d=r===t.lastSyncedSha?t.files:(await(0,_t.getTree)(this.transport,e.owner,e.repo,(await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(c.treeFilter),{changed:p,deleted:h}=Tk(d,f);for(let _ of p)s.has(_.path)&&l.push(`race-window: concurrent commit ${i} changed ${_.path} between conflict check (head ${r}) and push \u2014 local version won; previous version recoverable from git history`),o.has(_.path)&&l.push(`race-window: concurrent commit ${i} changed ${_.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let _ of h)s.has(_.path)&&l.push(`race-window: concurrent commit ${i} deleted ${_.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);l.push(`race-window check failed: ${f(qa(u))}`)}}async buildWatermarkFiles(e,t,r,i,s,o,l){if(l.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let c=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&c.set(f.blobSha,f.uid);for(let[f,d]of r){let p=o?.get(f)??await(0,uc.gitBlobSha)(d,this.sha1);c.set(p,typeof d=="string"?(0,Qs.extractAssetUid)(d):void 0)}for(let f of s.files)c.has(f.blobSha)||c.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(c.has(f.blobSha))d=c.get(f.blobSha);else{let p=await(0,_t.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,Qs.extractAssetUid)(p)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};fn.SyncEngine=DA});var Rk=v(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});Op.QuarantineResolver=void 0;Op.backupPathFor=xk;var ure=n_(),p_=tf(),Rp=ef(),Cp=Tp(),fre=a_(),Js="\0absent",FA=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let r of e)t.push(...await this.listRepoConflicts(r));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),r=t?.pinnedPaths??[];if(r.length===0)return[];if(this.deps.outbox!==void 0){let h=await this.deps.outbox.listForRepo(e.repoKey);if(h.length>0){let _=new Set(h.map(y=>y.path));if(r=r.filter(y=>!_.has(y)),r.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,r),l=r.some(h=>!o.has(h)),c=new Map,u=!0;if(l)if(s)try{c=await this.remoteTreeShas(e)}catch{u=!1}else c=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),p=[];for(let h of r){let _=o.get(h),y,b;if(_!==void 0)b=_.remoteContent!==void 0?await(0,Rp.gitBlobSha)(_.remoteContent,this.deps.sha1):Js,y=_.baseContent!==void 0?await(0,Rp.gitBlobSha)(_.baseContent,this.deps.sha1):i.get(h)??Js;else{if(!u)continue;b=c.get(h)??Js,y=i.get(h)??Js}let S=Js,I;if(d.has(h)&&(I=await f.read(h),S=await(0,Rp.gitBlobSha)(I,this.deps.sha1)),!(S!==b&&S!==y&&b!==y))continue;let T=(I!==void 0?(0,Cp.extractAssetUid)(I):void 0)??_?.uid;p.push({repoKey:e.repoKey,path:h,...T!==void 0?{uid:T}:{},hasLocal:S!==Js,hasRemote:b!==Js})}return p}async cachedRecordsFor(e,t){let r=new Map,i=this.deps.conflictCache;if(i===void 0)return r;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&r.set(s,o)}return r}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 l;try{l=await s.read(o)}catch{continue}let c=(0,Cp.extractAssetUid)(l);c!==void 0&&t.set(c,(t.get(c)??0)+1)}}let r=0;for(let i of t.values())i>1&&r++;return r}async loadConflict(e,t){let r=this.deps.localFilesFor(e),s=new Set(await r.list()).has(t)?await r.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,l,c;if(o!==null)l=o.remoteContent,c=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);l=d!==void 0?await this.blobText(e,d):void 0;let h=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(_=>_.path===t)?.blobSha;if(h!==void 0)try{c=await this.blobText(e,h)}catch{c=void 0}}let u=(s!==void 0?(0,Cp.extractAssetUid)(s):void 0)??(l!==void 0?(0,Cp.extractAssetUid)(l):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:l!==void 0,...c!==void 0?{base:c}:{},...s!==void 0?{local:s}:{},...l!==void 0?{remote:l}:{}}}async resolve(e,t,r){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,l=this.deps.outbox!==void 0,{remote:c,remoteSha:u}=l?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(r,o,c),d;r.take!=="local"&&o!==void 0&&o!==f&&(d=xk(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let h=f===void 0&&c===void 0||f===c;if(l&&this.deps.outbox!==void 0&&!h&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:r.take==="merged"?"merged":"local",baseRemoteSha:u===Js?fre.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:r.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let _;return h||(_=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:r.take,..._!==void 0?{pushedSha:_}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let r=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(r!==null){let i=r.remoteContent,s=i!==void 0?await(0,Rp.gitBlobSha)(i,this.deps.sha1):Js;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??Js}}chosenContent(e,t,r){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 r;case"merged":return e.content}}async commitChoice(e,t,r){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(r===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,ure.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,r]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,r){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(l=>l!==t),o=i.files;if(r===void 0)o=o.filter(l=>l.path!==t);else{let l=await(0,Rp.gitBlobSha)(r,this.deps.sha1),c=(0,Cp.extractAssetUid)(r),u={path:t,blobSha:l,...c!==void 0?{uid:c}:{}},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,p_.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,p_.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,p_.getTree)(this.deps.transport,e.owner,e.repo,r.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,p_.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};Op.QuarantineResolver=FA;function xk(n){return`${n}.conflict.local.txt`}a(xk,"backupPathFor")});var Ck=v(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.FileLocalManifestStore=rf.LOCAL_MANIFEST_STORE_FILENAME=void 0;rf.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function dre(n){if(n===null||typeof n!="object")return!1;let e=n;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(dre,"isLocalManifestRecord");var LA=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let r=(await this.readRepos())[e];return dre(r)?r:null}async set(e,t){let r=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=r.catch(()=>{}),r}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 r=t.repos;return r===null||typeof r!="object"?{}:{...r}}catch{return{}}}};rf.FileLocalManifestStore=LA});var MA=v(kA=>{"use strict";Object.defineProperty(kA,"__esModule",{value:!0});kA.diff3=pre;function Ok(n,e){let t=n.length,r=e.length,i=Array.from({length:t+1},()=>new Int32Array(r+1));for(let c=t-1;c>=0;c--)for(let u=r-1;u>=0;u--)i[c][u]=n[c]===e[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);let s=new Map,o=0,l=0;for(;o<t&&l<r;)n[o]===e[l]?(s.set(o,l),o++,l++):i[o+1][l]>=i[o][l+1]?o++:l++;return s}a(Ok,"lcsMatch");function NA(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}a(NA,"sliceEq");function pre(n,e,t){let r=Ok(n,e),i=Ok(n,t),s=[],o=0,l=0,c=0;for(;;){let u=o;for(;u<n.length&&!(r.has(u)&&i.has(u));)u++;let f=u<n.length?r.get(u):e.length,d=u<n.length?i.get(u):t.length,p=n.slice(o,u),h=e.slice(l,f),_=t.slice(c,d),y=!NA(h,p),b=!NA(_,p);if(!y&&!b)s.push(...p);else if(!y)s.push(..._);else if(!b)s.push(...h);else if(NA(h,_))s.push(...h);else return{ok:!1,conflict:{base:p,local:h,remote:_}};if(u>=n.length)break;s.push(n[u]),o=u+1,l=f+1,c=d+1}return{ok:!0,merged:s}}a(pre,"diff3")});var Dk=v(Fp=>{"use strict";Object.defineProperty(Fp,"__esModule",{value:!0});Fp.StructuredMerger=void 0;Fp.splitSections=h_;var Pk=MA(),hre=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,Pp="exo__Instance_class";function Dp(n){if(n===null||typeof n!="object")return!0;if(Array.isArray(n))return n.every(Dp);let e=Object.getPrototypeOf(n);return e!==Object.prototype&&e!==null?!1:Object.values(n).every(Dp)}a(Dp,"isPlainValue");function Ga(n,e){if(n===e)return!0;if(n===null||e===null||n===void 0||e===void 0||typeof n!="object"||typeof e!="object"||Array.isArray(n)!==Array.isArray(e))return!1;if(Array.isArray(n)&&Array.isArray(e))return n.length!==e.length?!1:n.every((s,o)=>Ga(s,e[o]));let t=n,r=e,i=Object.keys(t);return i.length!==Object.keys(r).length?!1:i.every(s=>Ga(t[s],r[s]))}a(Ga,"deepEqual");function fc(n){return typeof n=="string"?`s:${n}`:`j:${JSON.stringify(n)}`}a(fc,"setKey");function Oi(n){return n==null?[]:Array.isArray(n)?n:[n]}a(Oi,"toElements");function mre(n,e,t){let r=new Set(Oi(n).map(fc)),i=Oi(e),s=Oi(t),o=new Set(i.map(fc)),l=new Set(s.map(fc)),c=a(d=>o.has(d)&&l.has(d)||o.has(d)&&!r.has(d)||l.has(d)&&!r.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let p=fc(d);f.has(p)||!c(p)||(f.add(p),u.push(d))}return u}a(mre,"mergeSet");function gre(n,e,t){let r=[],i=[],s=new Set;for(let l of[...Object.keys(n),...Object.keys(e),...Object.keys(t)])s.has(l)||(s.add(l),i.push(l));let o={};for(let l of i){let c=n[l],u=e[l],f=t[l];if(!Dp(c)||!Dp(u)||!Dp(f))return{ok:!1,reason:`frontmatter key "${l}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(c)||Array.isArray(u)||Array.isArray(f)){if(!(l in e)&&!(l in t))continue;let d=mre(c,u,f),p=new Set(Oi(c).map(fc)),h=Oi(u).some(y=>!p.has(fc(y))),_=Oi(f).some(y=>!p.has(fc(y)));h&&_&&!Ga(Oi(u),Oi(f))&&r.push(`both sides added values to multi-valued key "${l}" \u2014 union kept (D20)`),d.length>0&&(o[l]=d);continue}if(Ga(u,f)){u!==void 0&&(o[l]=u);continue}if(Ga(u,c)){f!==void 0&&(o[l]=f);continue}if(Ga(f,c)){u!==void 0&&(o[l]=u);continue}return{ok:!1,reason:`frontmatter key "${l}" changed differently on both sides`}}return{ok:!0,value:o,warnings:r}}a(gre,"mergeFrontmatter");var yre=/^(```|~~~)/,_re=/^#{1,6}\s/;function h_(n){let e=n.split(`
320
+ `)}a(bte,"stripGitmodulesEntry")});var ef=v(gA=>{"use strict";Object.defineProperty(gA,"__esModule",{value:!0});gA.gitBlobSha=Ste;async function Ste(n,e){let t=new TextEncoder,r=typeof n=="string"?t.encode(n):n,i=t.encode(`blob ${r.byteLength}\0`),s=new Uint8Array(i.byteLength+r.byteLength);return s.set(i,0),s.set(r,i.byteLength),e(s)}a(Ste,"gitBlobSha")});var Tp=v(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});s_.extractAssetUid=tk;s_.detectChanges=Ete;var wte=ef();function tk(n){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(n);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(tk,"extractAssetUid");async function Ete(n){let{localFiles:e,cachedEntries:t,watermark:r,actualBaseTreeSha:i,sha1:s}=n;if(r===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${r.lastSyncedSha} not resolvable on remote`};if(i!==r.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${r.rootTreeSha} != actual ${i} at ${r.lastSyncedSha}`};let o=[],l=new Map;for(let[T,E]of e){let P=await(0,wte.gitBlobSha)(E,s);l.set(T,P),o.push({path:T,blobSha:P,uid:typeof E=="string"?tk(E):void 0})}if(t!==void 0)for(let[T,E]of t)l.set(T,E.blobSha),o.push({path:T,blobSha:E.blobSha,uid:E.uid});let c=[],u=[],f=[],d=[],p=new Map;for(let T of o){if(T.uid===void 0)continue;let E=p.get(T.uid)??[];E.push(T.path),p.set(T.uid,E)}let h=new Map;for(let T of r.files){if(T.uid===void 0)continue;let E=h.get(T.uid)??[];E.push(T.path),h.set(T.uid,E)}let _=new Set;for(let[T,E]of p)E.length>1&&_.add(T);for(let[T,E]of h)E.length>1&&_.add(T);for(let T of[..._].sort()){let E=p.get(T)??[],P=E.length>1?`on disk (${E.join(", ")})`:`in the sync base (${(h.get(T)??[]).join(", ")})`;d.push(`duplicate uid ${T} ${P} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let y=new Map,b=[];for(let T of r.files)T.uid!==void 0&&!_.has(T.uid)?y.set(T.uid,T):b.push(T);let S=[],I=new Set;for(let T of o){let E=T.uid!==void 0&&!_.has(T.uid)?y.get(T.uid):void 0;T.uid!==void 0&&E!==void 0?(I.add(T.uid),(E.blobSha!==T.blobSha||E.path!==T.path)&&u.push({path:T.path,uid:T.uid,blobSha:T.blobSha,...E.path!==T.path?{basePath:E.path}:{}})):S.push(T)}let O=new Map;for(let T of b)O.set(T.path,T);for(let[T,E]of y)I.has(T)||O.set(E.path,E);for(let T of S){let E=O.get(T.path);E!==void 0?(O.delete(T.path),E.blobSha!==T.blobSha&&u.push({path:T.path,uid:T.uid,blobSha:T.blobSha})):c.push({path:T.path,uid:T.uid,blobSha:T.blobSha})}for(let T of O.values())f.push({path:T.path,uid:T.uid,blobSha:T.blobSha});return{kind:"changes",added:c,modified:u,deleted:f,warnings:d,diskBlobShas:l,duplicateUids:_}}a(Ete,"detectChanges")});var ik=v(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});Ap.rewriteAssetUid=rk;Ap.findDuplicateUidGroups=nk;Ap.planDuplicateUidFix=Tte;var vte=Tp();function rk(n,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(n);if(t===null)return n;let r=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return r===t[2]?n:n.slice(0,t.index)+t[1]+r+t[3]+n.slice(t.index+t[0].length)}a(rk,"rewriteAssetUid");function nk(n){let e=new Map;for(let t of n){let r=(0,vte.extractAssetUid)(t.content);if(r===void 0)continue;let i=e.get(r)??[];i.push(t.path),e.set(r,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>({uid:t,paths:r}))}a(nk,"findDuplicateUidGroups");function Tte(n,e){let t=new Map(n.map(i=>[i.path,i.content])),r=[];for(let i of nk(n)){let s=[...i.paths].sort((o,l)=>o.localeCompare(l));for(let o of s.slice(1)){let l=t.get(o);if(l===void 0)continue;let c=e(),u=rk(l,c);u!==l&&r.push({path:o,fromUid:i.uid,toUid:c,content:u})}}return r}a(Tte,"planDuplicateUidFix")});var tf=v(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});cc.getHeadSha=Ite;cc.getCommitInfo=xte;cc.getTree=Rte;cc.getBlobText=Cte;cc.getBlobBytes=Ote;var sk=Vc(),Ate="https://api.github.com";function Ip(n){return(n??Ate).replace(/\/$/,"")}a(Ip,"api");function lc(n){return n!==null&&typeof n=="object"?n:void 0}a(lc,"asRecord");function Ys(n,e){let r=lc(n)?.[e];return typeof r=="string"?r:void 0}a(Ys,"readString");async function Ite(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(r)}`}),o=Ys(lc(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${r}`);return o}a(Ite,"getHeadSha");async function xte(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(r)}`}),o=lc(s?.json),l=Ys(o,"sha"),c=Ys(o?.tree,"sha");if(!l||!c)throw new Error(`ExoSync: malformed commit response for ${r}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>Ys(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:l,treeSha:c,parents:f}}a(xte,"getCommitInfo");async function Rte(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(r)}?recursive=1`}),o=lc(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${r} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let l=o?.tree;if(!Array.isArray(l))throw new Error(`ExoSync: malformed tree response for ${r}`);let c=[];for(let u of l){let f=lc(u);if(f?.type!=="blob")continue;let d=Ys(f,"path"),p=Ys(f,"sha"),h=typeof f.size=="number"?f.size:void 0;d&&p&&c.push({path:d,blobSha:p,...h!==void 0?{size:h}:{}})}return c}a(Rte,"getTree");async function Cte(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=lc(s?.json),l=Ys(o,"content");if(typeof l!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ys(o,"encoding")==="utf-8"?l:(0,sk.base64ToUtf8)(l)}a(Cte,"getBlobText");async function Ote(n,e,t,r,i){let s=await n({method:"GET",url:`${Ip(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(r)}`}),o=lc(s?.json),l=Ys(o,"content");if(typeof l!="string")throw new Error(`ExoSync: malformed blob response for ${r}`);return Ys(o,"encoding")==="utf-8"?new TextEncoder().encode(l):(0,sk.base64ToBytes)(l)}a(Ote,"getBlobBytes")});var ak=v(yA=>{"use strict";Object.defineProperty(yA,"__esModule",{value:!0});yA.checkParkedStaleness=Dte;var Pte=tf();async function Dte(n,e){let t={repoKey:n.repoKey,localPath:n.localPath},r=e.redact??(o=>o),i=null;try{let l=(await e.watermarks.get(n.repoKey))?.lastSyncedSha??"";l.length>0&&(i=l)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:`watermark unreadable: ${r(ok(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,Pte.getHeadSha)(e.transport,n.owner,n.repo,n.branch,e.baseURL)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:i,remoteHeadSha:null,reason:`remote unreachable: ${r(ok(o))}`}}return{...t,freshness:s===i?"current":"behind",lastSyncedSha:i,remoteHeadSha:s}}a(Dte,"checkParkedStaleness");function ok(n){return n instanceof Error?n.message:String(n)}a(ok,"errorText")});var SA=v(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.SyncPhaseTimer=ir.SYNC_PHASES=void 0;ir.classifyRestPhase=Fte;ir.emptyTimings=ck;ir.totalMs=o_;ir.addTimings=uk;ir.aggregateTimings=Lte;ir.dominantPhase=Nte;ir.fmtMs=xp;ir.formatTimingsLine=kte;ir.formatRepoTimings=Mte;ir.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function bA(){let n={};for(let e of ir.SYNC_PHASES)n[e]=0;return n}a(bA,"zeroDurations");function lk(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(lk,"zeroCounts");function Fte(n){if(n.method!=="GET")return"restPush";let e=n.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(Fte,"classifyRestPhase");var _A=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=bA(),this.counts=lk()}async time(e,t){let r=this.now();try{return await t()}finally{this.durations[e]+=this.now()-r}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};ir.SyncPhaseTimer=_A;function ck(){return{durations:bA(),counts:lk()}}a(ck,"emptyTimings");function o_(n){let e=0;for(let t of ir.SYNC_PHASES)e+=n.durations[t];return e}a(o_,"totalMs");function uk(n,e){let t=bA();for(let r of ir.SYNC_PHASES)t[r]=n.durations[r]+e.durations[r];return{durations:t,counts:{filesRead:n.counts.filesRead+e.counts.filesRead,filesHashed:n.counts.filesHashed+e.counts.filesHashed,filesWritten:n.counts.filesWritten+e.counts.filesWritten,restCalls:n.counts.restCalls+e.counts.restCalls}}}a(uk,"addTimings");function Lte(n){let e=ck();for(let t of n)t.timings!==void 0&&(e=uk(e,t.timings));return e}a(Lte,"aggregateTimings");function Nte(n){let e=o_(n);if(e<=0)return null;let t=ir.SYNC_PHASES[0],r=-1;for(let i of ir.SYNC_PHASES)n.durations[i]>r&&(r=n.durations[i],t=i);return{phase:t,ms:r,pct:r/e*100}}a(Nte,"dominantPhase");function xp(n){return n>=1e3?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}a(xp,"fmtMs");function kte(n){let e=o_(n);if(e<=0)return"";let t=ir.SYNC_PHASES.filter(r=>n.durations[r]>0).sort((r,i)=>n.durations[i]-n.durations[r]).map(r=>`${r} ${xp(n.durations[r])} ${Math.round(n.durations[r]/e*100)}%`);return`\u23F1 ExoSync ${xp(e)} \u2014 ${t.join(" \xB7 ")} (${n.counts.filesHashed} hashed, ${n.counts.filesRead} read, ${n.counts.restCalls} REST)`}a(kte,"formatTimingsLine");function Mte(n,e){let t=ir.SYNC_PHASES.map(r=>`${r}=${xp(e.durations[r])}`);return`[ExoSync timings] ${n}: total ${xp(o_(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(Mte,"formatRepoTimings")});var a_=v(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.LocalOutboxStore=Ba.OUTBOX_REMOTE_ABSENT=Ba.OUTBOX_STORE_FILENAME=void 0;Ba.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";Ba.OUTBOX_REMOTE_ABSENT=" absent";function wA(n,e){return`${n}\0${e}`}a(wA,"outboxKey");function fk(n){if(n===null||typeof n!="object")return!1;let e=n;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(fk,"isEntry");var EA=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[wA(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(r=>{delete r.entries[wA(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(fk)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[wA(e,t)];return i!==void 0&&fk(i)}async mutate(e){let t=this.writeChain.then(async()=>{let r=await this.read();e(r),await this.io.writeAtomic(JSON.stringify(r,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 r=t.entries;return r===null||typeof r!="object"?{version:1,entries:{}}:{version:1,entries:{...r}}}catch{return{version:1,entries:{}}}}};Ba.LocalOutboxStore=EA});var l_=v(vA=>{"use strict";Object.defineProperty(vA,"__esModule",{value:!0});vA.isAuthError=jte;function jte(n){let e=n instanceof Error?n.message:String(n);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(jte,"isAuthError")});var TA=v(c_=>{"use strict";Object.defineProperty(c_,"__esModule",{value:!0});c_.scanForSecrets=$te;c_.redactSecrets=Ute;var dk=[{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 $te(n){let e=[];for(let[t,r]of n)for(let{kind:i,re:s}of dk)s.test(r)&&e.push({path:t,kind:i});return e}a($te,"scanForSecrets");function Ute(n){let e=n;for(let{kind:t,re:r}of dk)e=e.replace(new RegExp(r.source,"g"),`[REDACTED:${t}]`);return e}a(Ute,"redactSecrets")});var xA=v(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.caseInsensitiveHeaderGetter=Bte;Va.parseRetryAfterMs=pk;Va.extractRateLimitFields=hk;Va.getRateLimitFields=Vte;Va.attachRateLimitFields=mk;Va.enrichRateLimitError=qte;function Bte(n){let e=new Map;if(n&&typeof n=="object")for(let[t,r]of Object.entries(n))typeof r=="string"&&e.set(t.toLowerCase(),r);return t=>e.get(t.toLowerCase())}a(Bte,"caseInsensitiveHeaderGetter");function IA(n){if(n==null)return;let e=n.trim();if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0}a(IA,"parseIntHeader");function pk(n,e=Date.now){if(n==null)return;let t=n.trim();if(t.length===0)return;let r=IA(t);if(r!==void 0)return Math.max(0,r*1e3);let i=Date.parse(t);if(!Number.isNaN(i))return Math.max(0,i-e())}a(pk,"parseRetryAfterMs");function hk(n,e=Date.now){let t={},r=pk(n("retry-after"),e);r!==void 0&&(t.retryAfterMs=r);let i=IA(n("x-ratelimit-reset"));i!==void 0&&(t.rateLimitReset=i);let s=IA(n("x-ratelimit-remaining"));return s!==void 0&&(t.rateLimitRemaining=s),t}a(hk,"extractRateLimitFields");function Vte(n){if(n===null||typeof n!="object")return{};let e=n,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(Vte,"getRateLimitFields");function AA(n,e,t){Object.defineProperty(n,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}a(AA,"defineHidden");function mk(n,e){return e.retryAfterMs!==void 0&&AA(n,"retryAfterMs",e.retryAfterMs),e.rateLimitReset!==void 0&&AA(n,"rateLimitReset",e.rateLimitReset),e.rateLimitRemaining!==void 0&&AA(n,"rateLimitRemaining",e.rateLimitRemaining),n}a(mk,"attachRateLimitFields");function qte(n,e,t=Date.now){return mk(n,hk(e,t))}a(qte,"enrichRateLimitError")});var u_=v(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});Ci.DEFAULT_MAX_RETRIES=Ci.MIN_RATE_LIMIT_WAIT_MS=void 0;Ci.isRateLimitError=gk;Ci.createRateLimitBudget=Wte;Ci.withRateLimitBackoff=Kte;var Gte=xA();function gk(n){let e=n instanceof Error?n.message:String(n);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(gk,"isRateLimitError");Ci.MIN_RATE_LIMIT_WAIT_MS=6e4;Ci.DEFAULT_MAX_RETRIES=6;function Wte(n){let e=!(n>0),t=e?Number.POSITIVE_INFINITY:n;return{reset(){t=e?Number.POSITIVE_INFINITY:n},tryReserve(r){return r<=0?!0:r<=t?(t-=r,!0):!1}}}a(Wte,"createRateLimitBudget");var Hte=a(n=>new Promise(e=>setTimeout(e,n)),"defaultSleep");function zte(n,e,t,r,i,s){let o=(0,Gte.getRateLimitFields)(n);if(typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0)return o.retryAfterMs;if(o.rateLimitRemaining===0&&typeof o.rateLimitReset=="number"){let c=o.rateLimitReset*1e3-s();if(c>0)return c}let l=t*2**e*(1+i());return Math.max(r,l)}a(zte,"computeRateLimitDelay");function Kte(n,e={}){let t=e.maxRetries??Ci.DEFAULT_MAX_RETRIES,r=e.baseDelayMs??1e3,i=Math.max(Ci.MIN_RATE_LIMIT_WAIT_MS,e.minRateLimitWaitMs??Ci.MIN_RATE_LIMIT_WAIT_MS),s=e.budget,o=e.sleep??Hte,l=e.random??Math.random,c=e.now??(()=>Date.now());return async u=>{let f=0;for(;;)try{return await n(u)}catch(d){if(!gk(d)||f>=t)throw d;let p=zte(d,f,r,i,l,c);if(s!==void 0&&!s.tryReserve(p))throw d;f++,await o(p)}}}a(Kte,"withRateLimitBackoff")});var f_=v(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.DEFAULT_MAX_FILE_BYTES=Jo.InMemoryQuarantineStore=void 0;Jo.contentEquals=Yte;Jo.isSyncablePath=Qte;Jo.isFileSpaceSyncablePath=Xte;function Yte(n,e){if(n===void 0||e===void 0||typeof n=="string"&&typeof e=="string")return n===e;if(typeof n=="string"||typeof e=="string"||n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return!1;return!0}a(Yte,"contentEquals");var RA=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};Jo.InMemoryQuarantineStore=RA;function Qte(n){return n.endsWith(".md")&&!n.includes(".local.")&&!n.includes(".conflict.")}a(Qte,"isSyncablePath");function Xte(n){return!n.includes(".local.")&&!n.includes(".conflict.")}a(Xte,"isFileSpaceSyncablePath");Jo.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var Ik=v(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.SyncEngine=fn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=fn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=fn.DEFAULT_MAX_PUSH_RETRIES=void 0;fn.syncProgressPhaseText=ere;fn.isNonFastForwardError=Ak;fn.orderChildrenFirst=lre;var yk=n_(),_k=SA(),_t=tf(),Qs=Tp(),Jte=Vc(),uc=ef(),CA=a_(),Zte=l_(),bk=TA(),Sk=u_(),Xs=f_();fn.DEFAULT_MAX_PUSH_RETRIES=3;fn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=3e5;fn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function ere(n){switch(n.phase){case"reading-local":return n.detail!==void 0?`reading local files ${n.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 n.detail!==void 0?`fetching remote files ${n.detail.done}/${n.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return n.detail!==void 0?`writing files ${n.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return n.phase}}a(ere,"syncProgressPhaseText");var wk=25,tre=10,rre=6,nre=500,ire=25;function sre(n){try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{return null}}a(sre,"decodeUtf8Strict");function ore(n){return typeof n=="string"?n:{base64:(0,Jte.bytesToBase64)(n)}}a(ore,"toCommitContent");async function Ek(n,e){if(n.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return n.readBinary(e)}a(Ek,"readBinaryStrict");async function are(n,e,t){if(n.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return n.writeBinary(e,t)}a(are,"writeBinaryStrict");function vk(n){return n.length===0||n.startsWith("/")||n.includes("\\")?!1:n.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(vk,"isSafeRepoRelativePath");function Ak(n){let e=n instanceof Error?n.message:String(n);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(Ak,"isNonFastForwardError");function lre(n){let e=a(t=>t.split("/").filter(r=>r.length>0).length,"depth");return[...n].sort((t,r)=>e(r.localPath)-e(t.localPath))}a(lre,"orderChildrenFirst");function Tk(n,e){let t=new Map(n.map(o=>[o.path,o])),r=new Set,i=[];for(let o of e){r.add(o.path);let l=t.get(o.path);(l===void 0||l.blobSha!==o.blobSha)&&i.push(o)}let s=n.filter(o=>!r.has(o.path));return{changed:i,deleted:s}}a(Tk,"diffTrees");function qa(n){return n instanceof Error?n.message:String(n)}a(qa,"errMsg");function cre(n,e,t){if(t.size===0)return n;let r=new Map(e.files.map(o=>[o.path,o])),i=new Set(n.map(o=>o.path)),s=[];for(let o of n){if(!t.has(o.path)){s.push(o);continue}let l=r.get(o.path);l!==void 0&&s.push(l)}for(let o of t){if(i.has(o))continue;let l=r.get(o);l!==void 0&&s.push(l)}return s}a(cre,"applyWatermarkPins");var OA={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function PA(n){return new Map(n.map(e=>[e.path,e.blobSha]))}a(PA,"treeByPath");function d_(n){return[...n.quarantineEntries.map(e=>e.path),...n.resolvedQuarantineEntries.map(e=>e.path)]}a(d_,"quarantinedPathsOf");var DA=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,Sk.createRateLimitBudget)(e.backoff?.maxTotalRateLimitWaitMs??fn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS),this.transport=this.instrumentTransport((0,Sk.withRateLimitBackoff)(e.transport,{...e.backoff,budget:this.rateLimitBudget,now:this.now})),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpRest(),r.time((0,_k.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let r=this.activeTimer;return r===null?e(t):(r.bumpHashed(),r.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((l,c)=>{let u=this.activeTimer;return u===null?c():u.time(l,c)},"timed"),r={list:a(()=>t("localList",()=>e.list()),"list"),read:a(l=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(l))),"read"),write:a((l,c)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(l,c))),"write"),delete:a(l=>e.delete(l),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(r.readBinary=l=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(l))));let s=e.writeBinary?.bind(e);s!==void 0&&(r.writeBinary=(l,c)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(l,c))));let o=e.stat?.bind(e);return o!==void 0&&(r.stat=l=>t("localList",()=>o(l))),r}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",r=t?Xs.isFileSpaceSyncablePath:Xs.isSyncablePath,i=this.deps.maxFileBytes??Xs.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:r,treeFilter:a(s=>r(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,r,i){let s=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,_t.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(r.treeFilter),c=[];for(let u of l){let f=t.get(u.path);f!==void 0&&await(0,uc.gitBlobSha)(f,this.sha1)===u.blobSha&&c.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${c.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:c,spaceKind:"file"}}async syncAll(e,t="sync",r){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,r));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",r){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0,this.rateLimitBudget.reset();try{return await this.syncLocked(e,t,r)}finally{this.opInProgress=!1}}emitProgress(e,t,r,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:r}:{repoKey:t,phase:r,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%nre===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%ire===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",r){let i=new _k.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=r!==void 0?{emit:r,repoKey:e.repoKey,reads:0,writes:0}:null;let l=[],c=[],u=0,f=0,d=[],p=a((h,_={})=>({repoKey:e.repoKey,status:h,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:l,deferredDeletes:c,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),..._}),"result");try{let h=await this.deps.materializationCheck.check(e);if(!h.fullyMaterialized)return l.push(`skipped: repo not fully materialized${h.reason?` (${h.reason})`:""} \u2014 deletes NOT inferred (D19)`),p("skipped-not-materialized");let _=this.modeOps(e),y=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(_.fileMode&&(y.readBinary===void 0||y.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(_.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 b=this.deps.maxFileBytes??Xs.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let ee=await this.flushOutbox(e,l);u=ee.pushed,f=ee.reconflicted}let S=await this.deps.watermarkStore.get(e.repoKey);if(S?.spaceKind==="file"&&!_.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)"});S!==null&&_.fileMode&&S.spaceKind!=="file"&&(l.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),S=null);let I=this.deps.localManifestStore!==void 0?y.stat?.bind(y):void 0,O=I!==void 0&&S!==null&&!_.fileMode,T=O&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,E=this.deps.localManifestFullRehashMs??fn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,P=O&&(T===null||this.now()-T.lastFullRehashMs>=E),V=new Map,M=new Set,j=new Map,$=new Map,G=new Map,ge=!1,ye=new Map;if(O&&S!==null)for(let ee of S.files)ye.set(ee.path,ee.blobSha);for(let ee of(await y.list()).filter(_.syncable)){if(_.fileMode){let Pe=await Ek(y,ee);if(Pe.byteLength>b){M.add(ee),l.push(`skipped oversized file ${ee} (${Pe.byteLength} bytes > ${b} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}V.set(ee,Pe);continue}if(!O||I===void 0){V.set(ee,await y.read(ee));continue}let _e=await I(ee),Te=!P&&_e!==null?T?.files[ee]:void 0;if(_e!==null&&Te!==void 0&&Te.mtimeMs===_e.mtimeMs&&Te.size===_e.size&&Te.blobSha===ye.get(ee)){j.set(ee,{blobSha:Te.blobSha,...Te.uid!==void 0?{uid:Te.uid}:{}}),$.set(ee,Te.blobSha),G.set(ee,_e);continue}ge=!0,V.set(ee,await y.read(ee)),_e!==null&&G.set(ee,_e)}let Q=!1;if(S===null)if(_.fileMode)Q=!0,S=await this.buildFileModeFirstSyncBase(e,V,_,l);else{let ee=await this.bootstrapWatermark(e,V,l,p);if(ee.kind==="settled")return ee.outcome;Q=!0,S=ee.base}let se=S;_.fileMode&&M.size>0&&(S={...S,files:S.files.filter(ee=>!M.has(ee.path))});let J,ve;O&&!P?(J=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),ve=J===S.lastSyncedSha?S.rootTreeSha:await this.resolveBaseTreeSha(e,S)):ve=await this.resolveBaseTreeSha(e,S),this.emitProgress(r,e.repoKey,"detecting");let re=await(0,Qs.detectChanges)({localFiles:V,...O?{cachedEntries:j}:{},watermark:S,actualBaseTreeSha:ve,sha1:this.sha1});if(re.kind==="full-conflict")return p("full-conflict",{detail:`${re.reason}${re.detail?`: ${re.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(l.push(...re.warnings),O&&this.deps.localManifestStore!==void 0){let ee={};for(let[_e,Te]of V){let Pe=G.get(_e),Me=re.diskBlobShas.get(_e);if(Pe===void 0||Me===void 0)continue;let Ne=typeof Te=="string"?(0,Qs.extractAssetUid)(Te):void 0;ee[_e]={mtimeMs:Pe.mtimeMs,size:Pe.size,blobSha:Me,...Ne!==void 0?{uid:Ne}:{}}}for(let[_e,Te]of j){let Pe=G.get(_e);Pe!==void 0&&(ee[_e]={mtimeMs:Pe.mtimeMs,size:Pe.size,blobSha:Te.blobSha,...Te.uid!==void 0?{uid:Te.uid}:{}})}if(T!==null&&Object.keys(T.files).some(_e=>!(_e in ee))&&(ge=!0),ge||P||T===null){let _e={version:1,files:ee,lastFullRehashMs:P||T===null?this.now():T.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,_e)}}let ie=this.pinLocalChanges(re,V,l,c,t);d=[...ie.pushDeletionsAll.keys()];let he=await this.runPushLoop(e,S,ie,V,l,_,Q,M,t,r,J);if(d=[],he.kind!=="done"&&ie.pushDeletionsAll.size>0&&c.push(...ie.pushDeletionsAll.keys()),he.kind==="conflict")return p("conflict",{detail:he.detail});if(he.kind==="retry-exhausted"){l.push(...he.merge.warnings);let ee=await this.buildTerminalQuarantineEntries(e,S,he.pushFiles,he.merge.quarantineEntries,V),_e=[...he.merge.quarantineEntries,...he.merge.resolvedQuarantineEntries,...ee];return await this.flushQuarantine(_e,l),p("retry-exhausted",{detail:he.detail,quarantinedCount:_e.length,..._e.length>0?{quarantinedPaths:_e.map(Te=>Te.path)}:{}})}let{examinedHead:Ue,pushedSha:ce,applyWrites:ue,applyDeletes:fe,pushFiles:ne}=he,me=he.merge;l.push(...me.warnings),l.push(...he.deferredWarnings),c.push(...he.withheldDeletions);let Le=he.deferredPaths.size>0?{deferredPaths:[...he.deferredPaths]}:{},B=he.pushedDeletions.length>0?{pushedDeletes:he.pushedDeletions}:{},oe=await this.flushQuarantine([...me.quarantineEntries,...me.resolvedQuarantineEntries],l);he.secretQuarantineEntries.length>0&&await this.flushQuarantine(he.secretQuarantineEntries,l);let Ee=new Set;if(!oe&&me.resolvedQuarantineEntries.length>0){for(let ee of me.resolvedQuarantineEntries)Ee.add(ee.path);l.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${Ee.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(ce===void 0&&Ue===S.lastSyncedSha&&ue.length===0&&fe.length===0&&me.mergedWrites.length===0&&me.quarantineEntries.length===0&&me.resolvedQuarantineEntries.length===0&&(S.pinnedPaths?.length??0)===0&&he.alreadyInHead.length===0&&he.deferredPaths.size===0&&!Q)return p("synced");let Ce=ce??Ue,xe=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,Ce,this.deps.baseURL);if(ce!==void 0&&xe.parents[0]!==Ue)return await this.checkRaceWindow(e,S,Ue,xe.parents[0],ne,new Set(he.pushedDeletions),l,_),l.push(`race-window: watermark NOT advanced (pushed commit's parent ${xe.parents[0]} != examined head ${Ue}) \u2014 next sync reconciles the concurrent change`),p("synced",{pushedSha:ce,pushedCount:ne.size,mergedCount:me.mergedCount,quarantinedCount:me.quarantineEntries.length+me.resolvedQuarantineEntries.length,...me.mergedPaths.length>0?{mergedPaths:me.mergedPaths}:{},...d_(me).length>0?{quarantinedPaths:d_(me)}:{},...Le,...B});let{pulledCount:Oe,pinnedPaths:Re,pulledPaths:Ae}=await this.applyRemoteChanges(y,V,[...ue,...me.mergedWrites].filter(ee=>!Ee.has(ee.path)),fe.filter(ee=>!Ee.has(ee.path)),l,$);for(let ee of me.quarantineEntries)Re.add(ee.path);for(let ee of he.deferredPaths)Re.add(ee);for(let ee of Ee)Re.add(ee);if(_.fileMode){for(let ee of M)Re.add(ee);for(let ee of he.remoteOversized)Re.add(ee)}return await this.advanceWatermark(e,Ce,xe.treeSha,V,[...ue,...me.mergedWrites,...he.deferredRemoteChanges],se,Re,re.diskBlobShas,_,M),await this.resolveClearedPins(e,se,Re,l,new Set(me.resolvedQuarantineEntries.map(ee=>ee.path))),p("synced",{pushedSha:ce,pulledCount:Oe,pushedCount:ne.size,mergedCount:me.mergedCount,quarantinedCount:me.quarantineEntries.length+me.resolvedQuarantineEntries.length,...me.mergedPaths.length>0?{mergedPaths:me.mergedPaths}:{},...Ae.length>0?{pulledPaths:Ae}:{},...d_(me).length>0?{quarantinedPaths:d_(me)}:{},...Le,...B})}catch(h){let _=this.deps.redact??(y=>y);return d.length>0&&c.push(...d),(0,Zte.isAuthError)(h)?p("auth-required",{detail:_(`authentication failed: ${qa(h)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)}):(l.push(`sync failed: ${_(qa(h))}`),p("error",{detail:_(qa(h))}))}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let r=this.deps.redact??(s=>s);for(let s of e)t.push(r(`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??(l=>l);return t.push(`quarantine sink failed: ${o(qa(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let r=this.deps.outbox;if(r===void 0)return{pushed:0,reconflicted:0};let i=await r.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(_=>_),o,l;try{({head:o,shaByPath:l}=await this.outboxHeadTreeShas(e))}catch(_){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(qa(_))}`),{pushed:0,reconflicted:0}}let c=0,u=[];for(let _ of i){let y=l.get(_.path)??CA.OUTBOX_REMOTE_ABSENT,b=y===CA.OUTBOX_REMOTE_ABSENT&&_.baseRemoteSha!==CA.OUTBOX_REMOTE_ABSENT?[...l].filter(([S,I])=>S!==_.path&&I===_.baseRemoteSha).map(([S])=>S):[];if(y!==_.baseRemoteSha&&b.length===0){await r.remove(_.repoKey,_.path),c++,t.push(s(`outbox: remote moved for ${_.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:_,stalePaths:b})}if(u.length===0)return{pushed:0,reconflicted:c};let f=new Map;for(let{entry:_}of u)f.set(_.path,_.chosenContent);let d=new Set;for(let{stalePaths:_}of u)for(let y of _)f.has(y)||d.add(y);let p=[...d];try{await(0,yk.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(_){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(qa(_))}`),{pushed:0,reconflicted:c}}let h=0;for(let{entry:_,stalePaths:y}of u){let b=y.filter(S=>!f.has(S));await this.snapOutboxWatermark(e,_.path,_.chosenContent,b),await this.deps.quarantine?.markResolved?.(_.repoKey,_.path);for(let S of b)await this.deps.quarantine?.markResolved?.(_.repoKey,S);await r.remove(_.repoKey,_.path),h++,b.length>0&&t.push(`consolidated cross-path conflict for ${_.path} \u2014 removed ${b.length} stale remote copy/copies (recoverable in git history)`)}return h>0&&t.push(`pushed ${h} resolved conflict(s)`),{pushed:h,reconflicted:c}}async outboxHeadTreeShas(e){let t=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,_t.getTree)(this.transport,e.owner,e.repo,r.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,r,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),l=(s.pinnedPaths??[]).filter(y=>!o.has(y)),c=await(0,uc.gitBlobSha)(r,this.sha1),u=(0,Qs.extractAssetUid)(r),f={path:t,blobSha:c,...u!==void 0?{uid:u}:{}},d=new Set(i),p=s.files.filter(y=>!d.has(y.path)),h=p.findIndex(y=>y.path===t),_=h>=0?p.map((y,b)=>b===h?f:y):[...p,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:_,...l.length>0?{pinnedPaths:l}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,r,i,s){let o=new Set(i.map(u=>u.path)),l=new Map;try{let u=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,_t.getTree)(this.transport,e.owner,e.repo,(await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>r.has(d.path));for(let d of f)l.set(d.path,await(0,_t.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let c=[];for(let[u,f]of r){if(o.has(u))continue;let d=s.get(u),p=d??f,h=d!==void 0&&!(0,Xs.contentEquals)(d,f),_=typeof p=="string"?(0,Qs.extractAssetUid)(p):void 0,y=l.get(u);c.push({repoKey:e.repoKey,path:u,..._!==void 0?{uid:_}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??fn.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},...y!==void 0?{remoteContent:y}:{}})}return c}async resolveClearedPins(e,t,r,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let l=(t.pinnedPaths??[]).filter(c=>!r.has(c)&&!s.has(c));for(let c of l)try{await o.markResolved?.(e.repoKey,c)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${c}: ${f(qa(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t){try{return(await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch{return null}}pinLocalChanges(e,t,r,i,s){let o=e.modified.filter(p=>p.basePath!==void 0),l=[...e.added,...e.modified.filter(p=>p.basePath===void 0)],c=new Map;if(s==="pull"){for(let p of o)p.basePath!==void 0&&i.push(p.basePath),r.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),r.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&&c.set(p.basePath,p.path);for(let p of e.deleted)c.set(p.path,p.path)}let u=[...l,...o,...e.deleted.map(p=>({...p}))],f=new Set(e.deleted.map(p=>p.path)),d=new Map;for(let p of[...l,...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:c,dupUids:e.duplicateUids}}async runPushLoop(e,t,r,i,s,o,l=!1,c=new Set,u="sync",f,d){let{localChanges:p,localDeletedPaths:h,pushFilesAll:_,pushDeletionsAll:y,dupUids:b}=r,S=this.deps.maxPushRetries??fn.DEFAULT_MAX_PUSH_RETRIES,I=0,O="",T,E=[],P=[],V=new Map,M=new Set,j=[],$=OA,G=[],ge=new Set,ye=[],Q=[],se=new Set,J=[],ve=new Set;for(;;){O=I===0&&d!==void 0&&_.size===0&&y.size===0?d:await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),E=[],P=[],$=OA,G=[],ge=new Set,ye=[],Q=[];let re,ie=new Set,he=(t.pinnedPaths?.length??0)>0;if(O!==t.lastSyncedSha||he||l){this.emitProgress(f,e.repoKey,"pulling-remote");let ue=await this.collectRemoteChanges(e,t,O,o,c,s,se,f);re=ue.headTreeByPath;let fe=this.matchLocalVsRemote(p,h,i,ue.changes,ie,b,ue.headTreeByPath);if(fe.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let ne of fe.conflicts){ge.add(ne.local.path),ne.local.basePath!==void 0&&ge.add(ne.local.basePath);for(let me of ne.remotes)ge.add(me.path),me.kind==="change"&&ye.push(me)}Q.push(`${u}-only: ${fe.conflicts.length} conflict(s) deferred to a full Sync (${fe.conflicts.map(ne=>ne.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)$=this.resolveFileModeConflicts(e,fe.conflicts,i,fe.applyWrites,fe.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${fe.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};$=await this.resolveMergeConflicts(e,t,fe.conflicts,i)}if(u==="sync")for(let ne of fe.conflicts)for(let me of ne.remotes)me.path!==ne.local.path&&(ge.add(me.path),me.kind==="change"&&ye.push(me),Q.push(`conflict group ${ne.desc}: remote change at ${me.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(E=fe.applyWrites,P=fe.applyDeletes,u==="push"&&(E.length>0||P.length>0)){for(let ne of E)ge.add(ne.path),ye.push(ne);for(let ne of P)ge.add(ne.path);Q.push(`push-only: ${E.length+P.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),E=[],P=[]}}V=u==="pull"?new Map:new Map([...[..._].filter(([ue])=>!ie.has(ue)),...$.mergedFiles]),M=new Set,j=[];for(let[ue,fe]of y){if(ie.has(fe)){j.push(ue);continue}V.has(ue)||M.add(ue)}if((V.size>0||M.size>0)&&re===void 0&&(re=PA(await(0,_t.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),V.size>0&&re!==void 0){for(let[ue,fe]of V){let ne=re.get(ue);ne!==void 0&&ne===await(0,uc.gitBlobSha)(fe,this.sha1)&&(V.delete(ue),G.push(ue))}G.length>0&&s.push(`phantom push skipped: ${G.length} file(s) already identical in remote HEAD (${G.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(M.size>0&&re!==void 0){for(let ue of[...M])re.has(ue)||M.delete(ue);V.size===0&&M.size>=re.size&&(j.push(...M),Q.push(`deletion of ALL ${M.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`),M.clear())}if(V.size===0&&M.size===0)break;let Ue=new Map;for(let[ue,fe]of V)if(typeof fe=="string")Ue.set(ue,fe);else{let ne=sre(fe);ne!==null&&Ue.set(ue,ne)}let ce=(0,bk.scanForSecrets)(Ue);if(ce.length>0){let ue=new Map;for(let fe of ce){let ne=ue.get(fe.path);ne===void 0?ue.set(fe.path,[fe.kind]):ne.includes(fe.kind)||ne.push(fe.kind)}for(let[fe,ne]of ue){if(!ve.has(fe)){ve.add(fe);let me=Ue.get(fe),Le=me!==void 0?(0,bk.redactSecrets)(me):void 0,B=Le!==void 0?(0,Qs.extractAssetUid)(Le):void 0;J.push({repoKey:e.repoKey,path:fe,...B!==void 0?{uid:B}:{},reason:`secret-scan (R5): detected ${ne.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.`,...Le!==void 0?{localContent:Le}:{}})}V.delete(fe)}s.push(`secret-scan (R5): skipped ${ue.size} file(s) with a detected secret from the push \u2014 the rest of the changeset shipped; REVOKE the credential(s): ${[...ue].map(([fe,ne])=>`${fe} (${ne.join(", ")})`).join(", ")}`);for(let[fe,ne]of y)ve.has(ne)&&M.has(fe)&&(M.delete(fe),j.push(fe));if(V.size===0&&M.size===0)break}try{T=await(0,yk.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...V].map(([ue,fe])=>[ue,ore(fe)])),deletions:[...M],message:this.deps.commitMessage?.(e,V.size,M.size)??`chore(exosync): sync ${V.size} file(s)${M.size>0?`, ${M.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(ue){if(!Ak(ue))throw ue;if(I++,I>S)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${S} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:V,merge:$};s.push(`non-fast-forward push (attempt ${I}/${S}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:O,pushedSha:T,applyWrites:E,applyDeletes:P,pushFiles:V,pushedDeletions:T!==void 0?[...M]:[],withheldDeletions:j,merge:$,remoteOversized:se,alreadyInHead:G,deferredPaths:ge,deferredRemoteChanges:ye,deferredWarnings:Q,secretQuarantineEntries:J}}async resolveMergeConflicts(e,t,r,i){let s=this.deps.mergeLayer;if(s===void 0)return OA;let o=new Map(t.files.map(y=>[y.path,y])),l=new Map,c=[],u=[],f=[],d=[],p=0,h=a(y=>typeof y=="string"?y:void 0,"asText"),_=a((y,b,S)=>{let I=h(i.get(y.local.path)),O=h(y.remotes[0]?.content);return{repoKey:e.repoKey,path:y.local.path,...y.local.uid!==void 0?{uid:y.local.uid}:{},reason:b,...S!==void 0?{baseContent:S}:{},...I!==void 0?{localContent:I}:{},...O!==void 0?{remoteContent:O}:{}}},"entry");for(let y of r){let b=o.get(y.local.basePath??y.local.path)??o.get(y.remotes[0]?.path??""),S;if(b!==void 0&&(S=await(0,_t.getBlobText)(this.transport,e.owner,e.repo,b.blobSha,this.deps.baseURL)),y.remotes.length>1){u.push(_(y,`ambiguous conflict: local change overlaps ${y.remotes.length} remote changes (${y.remotes.map(P=>P.path).join(", ")})`,S));continue}let I=y.remotes[0],O=h(i.get(y.local.path)),T=await s.resolve({path:y.local.path,...y.local.uid!==void 0?{uid:y.local.uid}:{},...S!==void 0?{base:S}:{},...O!==void 0?{local:O}:{},...I.kind==="change"&&typeof I.content=="string"?{remote:I.content}:{}});if(T.action==="quarantine"){u.push(_(y,T.reason,S));continue}p++,d.push(y.local.path);for(let P of T.warnings??[])f.push(`merge(${y.local.path}): ${P}`);let E=I.kind==="change"?I.content:void 0;if(T.content!==E&&l.set(y.local.path,T.content),T.content!==i.get(y.local.path)){let P=(0,Qs.extractAssetUid)(T.content)??y.local.uid;c.push({path:y.local.path,kind:"change",content:T.content,blobSha:await(0,uc.gitBlobSha)(T.content,this.sha1),...P!==void 0?{uid:P}:{}})}}return{mergedFiles:l,mergedWrites:c,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:p,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,r,i,s){let o=[],l=[];for(let c of t){c.remotes.length>1&&l.push(`file-mode conflict on ${c.local.path} unexpectedly overlaps ${c.remotes.length} remote changes \u2014 resolving against the first`);let u=c.remotes[0],f=r.get(c.local.path);u.kind==="change"?i.push(u):s.push(u),!(c.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:c.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:l}}async applyRemoteChanges(e,t,r,i,s,o=new Map){let l=0,c=new Set,u=[],f=a(async(h,_)=>{try{return _?await Ek(e,h):await e.read(h)}catch{return}},"tryRead"),d=a(async(h,_)=>{typeof _=="string"?await e.write(h,_):await are(e,h,_)},"writeContent"),p=a(async h=>{let _=await f(h,!1);return _===void 0?!0:await(0,uc.gitBlobSha)(_,this.sha1)===o.get(h)},"cacheHitUnchanged");for(let h of r){if(h.content===void 0)continue;if(!vk(h.path)){s.push(`unsafe remote path skipped on pull-apply: ${h.path}`),c.add(h.path);continue}let _=t.get(h.path);if(_===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`),c.add(h.path);continue}await d(h.path,h.content),l++,u.push(h.path);continue}let y=await f(h.path,typeof(_??h.content)!="string");if(!(0,Xs.contentEquals)(y,_)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),c.add(h.path);continue}await d(h.path,h.content),l++,u.push(h.path)}for(let h of i){if(!vk(h.path)){s.push(`unsafe remote path skipped on pull-delete: ${h.path}`),c.add(h.path);continue}let _=t.get(h.path);if(_===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`),c.add(h.path);continue}await e.delete(h.path),l++,u.push(h.path);continue}if(_!==void 0){let y=await f(h.path,typeof _!="string");if(y!==void 0&&!(0,Xs.contentEquals)(y,_)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),c.add(h.path);continue}await e.delete(h.path),l++,u.push(h.path)}}return{pulledCount:l,pinnedPaths:c,pulledPaths:u}}async advanceWatermark(e,t,r,i,s,o,l,c,u,f=new Set){let d=(await(0,_t.getTree)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).filter(h=>u.treeFilter(h)&&!f.has(h.path)),p=cre(await this.buildWatermarkFiles(e,d,i,s,o,c,u),o,l);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:r,files:p,...l.size>0?{pinnedPaths:[...l]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,r,i,s){let o=this.deps.mountBaseStore,l=null;if(o!==void 0)try{l=await o.get(e.repoKey)}catch{return null}let c=!1;if(l===null&&this.deps.localBaseShaProvider!==void 0)try{let b=await this.deps.localBaseShaProvider(e);typeof b=="string"&&b.length>0&&(l=b,c=!0)}catch{}if(l===null||t.startsWith(l))return null;let u=300,f=null;try{let b=t;for(let S=0;S<u;S++){let I=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,b,this.deps.baseURL);if(I.sha===l||I.sha.startsWith(l)){f=I;break}if(I.parents.length===0)break;b=I.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,_t.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(b=>(0,Xs.isSyncablePath)(b.path))}catch{return null}let p;try{let b=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);p=PA((await(0,_t.getTree)(this.transport,e.owner,e.repo,b.treeSha,this.deps.baseURL)).filter(S=>(0,Xs.isSyncablePath)(S.path)))}catch{return null}let h=d.filter(b=>!r.has(b.path)&&p.get(b.path)===b.blobSha);if(h.length>0){let b=h.slice(0,3).map(S=>S.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 (${b}); 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 (${b}); 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 _=d.map(b=>({path:b.path,blobSha:b.blobSha})),y={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:_};if(c&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(c?`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:y}}async bootstrapWatermark(e,t,r,i){let s=await(0,_t.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,r,i);if(o!==null)return o;let l=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,_t.getTree)(this.transport,e.owner,e.repo,l.treeSha,this.deps.baseURL)).filter(p=>(0,Xs.isSyncablePath)(p.path)),u=[],f;for(let p of c){let h=t.get(p.path);if(h===void 0||await(0,uc.gitBlobSha)(h,this.sha1)!==p.blobSha){f===void 0&&(f=p.path);continue}let _=typeof h=="string"?(0,Qs.extractAssetUid)(h):void 0;u.push({path:p.path,blobSha:p.blobSha,..._?{uid:_}:{}})}let d={lastSyncedSha:s,rootTreeSha:l.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`})}:(r.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===c.length?(await this.deps.watermarkStore.set(e.repoKey,d),r.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(r.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${c.length} files) \u2014 ${t.size-c.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,r,i,s=new Set,o=[],l=new Set,c){let u=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL),f=await(0,_t.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let M of f)i.syncable(M.path)&&!i.treeFilter(M)&&!l.has(M.path)&&(l.add(M.path),o.push(`skipped oversized REMOTE file ${M.path} (${M.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(M=>i.treeFilter(M)&&!s.has(M.path)),p=t.files.filter(M=>!l.has(M.path)&&!s.has(M.path)),{changed:h,deleted:_}=Tk(p,d),y=h.length;y>=wk&&this.emitProgress(c,e.repoKey,"fetching-blobs",{done:0,total:y});let b=new Array(h.length),S=0,I=0,O,T=a(async M=>{if(i.fileMode){let $=await(0,_t.getBlobBytes)(this.transport,e.owner,e.repo,M.blobSha,this.deps.baseURL);return{path:M.path,kind:"change",blobSha:M.blobSha,content:$}}let j=await(0,_t.getBlobText)(this.transport,e.owner,e.repo,M.blobSha,this.deps.baseURL);return{path:M.path,kind:"change",blobSha:M.blobSha,content:j,uid:(0,Qs.extractAssetUid)(j)}},"fetchOne"),E=a(async()=>{for(;;){if(O!==void 0)return;let M=S++;if(M>=h.length)return;try{b[M]=await T(h[M])}catch(j){O===void 0&&(O=j);return}I+=1,y>=wk&&I%tre===0&&I<y&&this.emitProgress(c,e.repoKey,"fetching-blobs",{done:I,total:y})}},"worker"),P=Math.min(rre,h.length);if(await Promise.all(Array.from({length:P},()=>E())),O!==void 0)throw O instanceof Error?O:new Error(String(O));let V=b;for(let M of _)V.push({path:M.path,kind:"delete",uid:M.uid});return{changes:V,headTreeByPath:PA(f)}}matchLocalVsRemote(e,t,r,i,s,o=new Set,l){let c=new Set,u=[],f=new Map;for(let y of i)y.kind==="change"&&y.uid!==void 0&&f.set(y.uid,(f.get(y.uid)??0)+1);let d=new Set(o);for(let[y,b]of f)b>1&&d.add(y);let p=new Map,h=new Map;for(let y of i){if(y.uid!==void 0&&!d.has(y.uid)){let b=p.get(y.uid)??[];b.push(y),p.set(y.uid,b)}h.set(y.path,y)}for(let y of e){let b=new Set;if(y.uid!==void 0&&!d.has(y.uid))for(let T of p.get(y.uid)??[])T.kind==="change"&&T.path!==y.path&&(l?.has(y.path)===!0||y.basePath!==void 0&&l?.has(y.basePath)===!0)||b.add(T);let S=h.get(y.path);if(S!==void 0&&b.add(S),y.basePath!==void 0){let T=h.get(y.basePath);T!==void 0&&b.add(T)}let I=[],O=!1;for(let T of b){if(O=t.has(y.path)&&!r.has(y.path),O&&T.kind==="delete"){c.add(T);continue}if(!O&&T.kind==="change"&&T.path===y.path&&T.blobSha===y.blobSha){c.add(T),s.add(y.path);continue}if(T.kind==="delete"&&y.basePath!==void 0&&T.path===y.basePath){let E=h.get(y.path);if(E!==void 0&&E.kind==="change"&&(E.blobSha===y.blobSha||E.uid!==void 0&&E.uid===y.uid)){c.add(T);continue}}if(T.kind==="delete"&&T.path!==y.path&&T.path!==y.basePath&&!r.has(T.path)&&l?.has(T.path)!==!0){c.add(T);continue}I.push(T),c.add(T)}I.length>0&&(u.push({local:y,localIsDelete:O,remotes:I,desc:`${y.uid!==void 0&&!d.has(y.uid)?y.uid:y.path} (local ${O?"delete":"change"} vs remote ${I[0].kind} at ${I[0].path})`}),s.add(y.path))}let _=i.filter(y=>!c.has(y));return{conflicts:u,applyWrites:_.filter(y=>y.kind==="change"),applyDeletes:_.filter(y=>y.kind==="delete")}}async checkRaceWindow(e,t,r,i,s,o,l,c){try{let u=await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,_t.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(c.treeFilter),d=r===t.lastSyncedSha?t.files:(await(0,_t.getTree)(this.transport,e.owner,e.repo,(await(0,_t.getCommitInfo)(this.transport,e.owner,e.repo,r,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(c.treeFilter),{changed:p,deleted:h}=Tk(d,f);for(let _ of p)s.has(_.path)&&l.push(`race-window: concurrent commit ${i} changed ${_.path} between conflict check (head ${r}) and push \u2014 local version won; previous version recoverable from git history`),o.has(_.path)&&l.push(`race-window: concurrent commit ${i} changed ${_.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let _ of h)s.has(_.path)&&l.push(`race-window: concurrent commit ${i} deleted ${_.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);l.push(`race-window check failed: ${f(qa(u))}`)}}async buildWatermarkFiles(e,t,r,i,s,o,l){if(l.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let c=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&c.set(f.blobSha,f.uid);for(let[f,d]of r){let p=o?.get(f)??await(0,uc.gitBlobSha)(d,this.sha1);c.set(p,typeof d=="string"?(0,Qs.extractAssetUid)(d):void 0)}for(let f of s.files)c.has(f.blobSha)||c.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(c.has(f.blobSha))d=c.get(f.blobSha);else{let p=await(0,_t.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,Qs.extractAssetUid)(p)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};fn.SyncEngine=DA});var Rk=v(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});Op.QuarantineResolver=void 0;Op.backupPathFor=xk;var ure=n_(),p_=tf(),Rp=ef(),Cp=Tp(),fre=a_(),Js="\0absent",FA=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let r of e)t.push(...await this.listRepoConflicts(r));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),r=t?.pinnedPaths??[];if(r.length===0)return[];if(this.deps.outbox!==void 0){let h=await this.deps.outbox.listForRepo(e.repoKey);if(h.length>0){let _=new Set(h.map(y=>y.path));if(r=r.filter(y=>!_.has(y)),r.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,r),l=r.some(h=>!o.has(h)),c=new Map,u=!0;if(l)if(s)try{c=await this.remoteTreeShas(e)}catch{u=!1}else c=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),p=[];for(let h of r){let _=o.get(h),y,b;if(_!==void 0)b=_.remoteContent!==void 0?await(0,Rp.gitBlobSha)(_.remoteContent,this.deps.sha1):Js,y=_.baseContent!==void 0?await(0,Rp.gitBlobSha)(_.baseContent,this.deps.sha1):i.get(h)??Js;else{if(!u)continue;b=c.get(h)??Js,y=i.get(h)??Js}let S=Js,I;if(d.has(h)&&(I=await f.read(h),S=await(0,Rp.gitBlobSha)(I,this.deps.sha1)),!(S!==b&&S!==y&&b!==y))continue;let T=(I!==void 0?(0,Cp.extractAssetUid)(I):void 0)??_?.uid;p.push({repoKey:e.repoKey,path:h,...T!==void 0?{uid:T}:{},hasLocal:S!==Js,hasRemote:b!==Js})}return p}async cachedRecordsFor(e,t){let r=new Map,i=this.deps.conflictCache;if(i===void 0)return r;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&r.set(s,o)}return r}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 l;try{l=await s.read(o)}catch{continue}let c=(0,Cp.extractAssetUid)(l);c!==void 0&&t.set(c,(t.get(c)??0)+1)}}let r=0;for(let i of t.values())i>1&&r++;return r}async loadConflict(e,t){let r=this.deps.localFilesFor(e),s=new Set(await r.list()).has(t)?await r.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,l,c;if(o!==null)l=o.remoteContent,c=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);l=d!==void 0?await this.blobText(e,d):void 0;let h=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(_=>_.path===t)?.blobSha;if(h!==void 0)try{c=await this.blobText(e,h)}catch{c=void 0}}let u=(s!==void 0?(0,Cp.extractAssetUid)(s):void 0)??(l!==void 0?(0,Cp.extractAssetUid)(l):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:l!==void 0,...c!==void 0?{base:c}:{},...s!==void 0?{local:s}:{},...l!==void 0?{remote:l}:{}}}async resolve(e,t,r){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,l=this.deps.outbox!==void 0,{remote:c,remoteSha:u}=l?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(r,o,c),d;r.take!=="local"&&o!==void 0&&o!==f&&(d=xk(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let h=f===void 0&&c===void 0||f===c;if(l&&this.deps.outbox!==void 0&&!h&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:r.take==="merged"?"merged":"local",baseRemoteSha:u===Js?fre.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:r.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let _;return h||(_=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:r.take,..._!==void 0?{pushedSha:_}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let r=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(r!==null){let i=r.remoteContent,s=i!==void 0?await(0,Rp.gitBlobSha)(i,this.deps.sha1):Js;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??Js}}chosenContent(e,t,r){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 r;case"merged":return e.content}}async commitChoice(e,t,r){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(r===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,ure.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,r]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,r){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(l=>l!==t),o=i.files;if(r===void 0)o=o.filter(l=>l.path!==t);else{let l=await(0,Rp.gitBlobSha)(r,this.deps.sha1),c=(0,Cp.extractAssetUid)(r),u={path:t,blobSha:l,...c!==void 0?{uid:c}:{}},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,p_.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),r=await(0,p_.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,p_.getTree)(this.deps.transport,e.owner,e.repo,r.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,p_.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};Op.QuarantineResolver=FA;function xk(n){return`${n}.conflict.local.txt`}a(xk,"backupPathFor")});var Ck=v(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.FileLocalManifestStore=rf.LOCAL_MANIFEST_STORE_FILENAME=void 0;rf.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function dre(n){if(n===null||typeof n!="object")return!1;let e=n;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(dre,"isLocalManifestRecord");var LA=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let r=(await this.readRepos())[e];return dre(r)?r:null}async set(e,t){let r=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=r.catch(()=>{}),r}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 r=t.repos;return r===null||typeof r!="object"?{}:{...r}}catch{return{}}}};rf.FileLocalManifestStore=LA});var MA=v(kA=>{"use strict";Object.defineProperty(kA,"__esModule",{value:!0});kA.diff3=pre;function Ok(n,e){let t=n.length,r=e.length,i=Array.from({length:t+1},()=>new Int32Array(r+1));for(let c=t-1;c>=0;c--)for(let u=r-1;u>=0;u--)i[c][u]=n[c]===e[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);let s=new Map,o=0,l=0;for(;o<t&&l<r;)n[o]===e[l]?(s.set(o,l),o++,l++):i[o+1][l]>=i[o][l+1]?o++:l++;return s}a(Ok,"lcsMatch");function NA(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}a(NA,"sliceEq");function pre(n,e,t){let r=Ok(n,e),i=Ok(n,t),s=[],o=0,l=0,c=0;for(;;){let u=o;for(;u<n.length&&!(r.has(u)&&i.has(u));)u++;let f=u<n.length?r.get(u):e.length,d=u<n.length?i.get(u):t.length,p=n.slice(o,u),h=e.slice(l,f),_=t.slice(c,d),y=!NA(h,p),b=!NA(_,p);if(!y&&!b)s.push(...p);else if(!y)s.push(..._);else if(!b)s.push(...h);else if(NA(h,_))s.push(...h);else return{ok:!1,conflict:{base:p,local:h,remote:_}};if(u>=n.length)break;s.push(n[u]),o=u+1,l=f+1,c=d+1}return{ok:!0,merged:s}}a(pre,"diff3")});var Dk=v(Fp=>{"use strict";Object.defineProperty(Fp,"__esModule",{value:!0});Fp.StructuredMerger=void 0;Fp.splitSections=h_;var Pk=MA(),hre=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,Pp="exo__Instance_class";function Dp(n){if(n===null||typeof n!="object")return!0;if(Array.isArray(n))return n.every(Dp);let e=Object.getPrototypeOf(n);return e!==Object.prototype&&e!==null?!1:Object.values(n).every(Dp)}a(Dp,"isPlainValue");function Ga(n,e){if(n===e)return!0;if(n===null||e===null||n===void 0||e===void 0||typeof n!="object"||typeof e!="object"||Array.isArray(n)!==Array.isArray(e))return!1;if(Array.isArray(n)&&Array.isArray(e))return n.length!==e.length?!1:n.every((s,o)=>Ga(s,e[o]));let t=n,r=e,i=Object.keys(t);return i.length!==Object.keys(r).length?!1:i.every(s=>Ga(t[s],r[s]))}a(Ga,"deepEqual");function fc(n){return typeof n=="string"?`s:${n}`:`j:${JSON.stringify(n)}`}a(fc,"setKey");function Oi(n){return n==null?[]:Array.isArray(n)?n:[n]}a(Oi,"toElements");function mre(n,e,t){let r=new Set(Oi(n).map(fc)),i=Oi(e),s=Oi(t),o=new Set(i.map(fc)),l=new Set(s.map(fc)),c=a(d=>o.has(d)&&l.has(d)||o.has(d)&&!r.has(d)||l.has(d)&&!r.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let p=fc(d);f.has(p)||!c(p)||(f.add(p),u.push(d))}return u}a(mre,"mergeSet");function gre(n,e,t){let r=[],i=[],s=new Set;for(let l of[...Object.keys(n),...Object.keys(e),...Object.keys(t)])s.has(l)||(s.add(l),i.push(l));let o={};for(let l of i){let c=n[l],u=e[l],f=t[l];if(!Dp(c)||!Dp(u)||!Dp(f))return{ok:!1,reason:`frontmatter key "${l}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(c)||Array.isArray(u)||Array.isArray(f)){if(!(l in e)&&!(l in t))continue;let d=mre(c,u,f),p=new Set(Oi(c).map(fc)),h=Oi(u).some(y=>!p.has(fc(y))),_=Oi(f).some(y=>!p.has(fc(y)));h&&_&&!Ga(Oi(u),Oi(f))&&r.push(`both sides added values to multi-valued key "${l}" \u2014 union kept (D20)`),d.length>0&&(o[l]=d);continue}if(Ga(u,f)){u!==void 0&&(o[l]=u);continue}if(Ga(u,c)){f!==void 0&&(o[l]=f);continue}if(Ga(f,c)){u!==void 0&&(o[l]=u);continue}return{ok:!1,reason:`frontmatter key "${l}" changed differently on both sides`}}return{ok:!0,value:o,warnings:r}}a(gre,"mergeFrontmatter");var yre=/^(```|~~~)/,_re=/^#{1,6}\s/;function h_(n){let e=n.split(`
321
321
  `),t=[],r=null,i="",s=!1,o=a(()=>{r!==null&&t.push({heading:i,text:r.join(`
322
322
  `)})},"flush");for(let l of e){if(yre.test(l.trimStart())&&(s=!s),!s&&_re.test(l)){o(),r=[l],i=l.trim();continue}r===null&&(r=[],i=""),r.push(l)}return o(),t}a(h_,"splitSections");function jA(n){return n.split(/\n{2,}/)}a(jA,"splitParagraphs");function bre(n){return n.join(`
323
323
 
@@ -359,7 +359,7 @@ GFS4: `),console.error(n)},"debug"));Xt[dn]||(_j=global[dn]||[],Sj(Xt,_j),Xt.clo
359
359
  `),m.charCodeAt(0)===65279&&(m=m.slice(1)));let U=new Q(m,L),R=m.indexOf("\0");for(R!==-1&&(U.position=R,J(U,"null byte is not allowed in input")),U.input+="\0";U.input.charCodeAt(U.position)===32;)U.lineIndent+=1,U.position+=1;for(;U.position<U.length-1;)We(U);return U.documents}a(qe,"loadDocuments");function je(m,L,U){L!==null&&typeof L=="object"&&typeof U>"u"&&(U=L,L=null);let R=qe(m,U);if(typeof L!="function")return R;for(let C=0,D=R.length;C<D;C+=1)L(R[C])}a(je,"loadAll2");function He(m,L){let U=qe(m,L);if(U.length!==0){if(U.length===1)return U[0];throw new e("expected a single document in the stream, but found more")}}return a(He,"load2"),W_.loadAll=je,W_.load=He,W_}function Rae(){if(C9)return ux;C9=1;let n=sh(),e=oh(),t=fx(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,s=65279,o=9,l=10,c=13,u=32,f=33,d=34,p=35,h=37,_=38,y=39,b=42,S=44,I=45,O=58,T=61,E=62,P=63,V=64,M=91,j=93,$=96,G=123,ge=124,ye=125,Q={};Q[0]="\\0",Q[7]="\\a",Q[8]="\\b",Q[9]="\\t",Q[10]="\\n",Q[11]="\\v",Q[12]="\\f",Q[13]="\\r",Q[27]="\\e",Q[34]='\\"',Q[92]="\\\\",Q[133]="\\N",Q[160]="\\_",Q[8232]="\\L",Q[8233]="\\P";let se=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],J=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function ve(w,F){if(F===null)return{};let X={},H=Object.keys(F);for(let q=0,k=H.length;q<k;q+=1){let N=H[q],z=String(F[N]);N.slice(0,2)==="!!"&&(N="tag:yaml.org,2002:"+N.slice(2));let K=w.compiledTypeMap.fallback[N];K&&i.call(K.styleAliases,z)&&(z=K.styleAliases[z]),X[N]=z}return X}a(ve,"compileStyleMap");function re(w){let F,X,H=w.toString(16).toUpperCase();if(w<=255)F="x",X=2;else if(w<=65535)F="u",X=4;else if(w<=4294967295)F="U",X=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+F+n.repeat("0",X-H.length)+H}a(re,"encodeHex");let ie=1,he=2;function Ue(w){this.schema=w.schema||t,this.indent=Math.max(1,w.indent||2),this.noArrayIndent=w.noArrayIndent||!1,this.skipInvalid=w.skipInvalid||!1,this.flowLevel=n.isNothing(w.flowLevel)?-1:w.flowLevel,this.styleMap=ve(this.schema,w.styles||null),this.sortKeys=w.sortKeys||!1,this.lineWidth=w.lineWidth||80,this.noRefs=w.noRefs||!1,this.noCompatMode=w.noCompatMode||!1,this.condenseFlow=w.condenseFlow||!1,this.quotingType=w.quotingType==='"'?he:ie,this.forceQuotes=w.forceQuotes||!1,this.replacer=typeof w.replacer=="function"?w.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}a(Ue,"State");function ce(w,F){let X=n.repeat(" ",F),H=0,q="",k=w.length;for(;H<k;){let N,z=w.indexOf(`
360
360
  `,H);z===-1?(N=w.slice(H),H=k):(N=w.slice(H,z+1),H=z+1),N.length&&N!==`
361
361
  `&&(q+=X),q+=N}return q}a(ce,"indentString");function ue(w,F){return`
362
- `+n.repeat(" ",w.indent*F)}a(ue,"generateNextLine");function fe(w,F){for(let X=0,H=w.implicitTypes.length;X<H;X+=1)if(w.implicitTypes[X].resolve(F))return!0;return!1}a(fe,"testImplicitResolving");function ne(w){return w===u||w===o}a(ne,"isWhitespace");function me(w){return w>=32&&w<=126||w>=161&&w<=55295&&w!==8232&&w!==8233||w>=57344&&w<=65533&&w!==s||w>=65536&&w<=1114111}a(me,"isPrintable");function Le(w){return me(w)&&w!==s&&w!==c&&w!==l}a(Le,"isNsCharOrWhitespace");function B(w,F,X){let H=Le(w),q=H&&!ne(w);return(X?H:H&&w!==S&&w!==M&&w!==j&&w!==G&&w!==ye)&&w!==p&&!(F===O&&!q)||Le(F)&&!ne(F)&&w===p||F===O&&q}a(B,"isPlainSafe");function oe(w){return me(w)&&w!==s&&!ne(w)&&w!==I&&w!==P&&w!==O&&w!==S&&w!==M&&w!==j&&w!==G&&w!==ye&&w!==p&&w!==_&&w!==b&&w!==f&&w!==ge&&w!==T&&w!==E&&w!==y&&w!==d&&w!==h&&w!==V&&w!==$}a(oe,"isPlainSafeFirst");function Ee(w){return!ne(w)&&w!==O}a(Ee,"isPlainSafeLast");function Ce(w,F){let X=w.charCodeAt(F),H;return X>=55296&&X<=56319&&F+1<w.length&&(H=w.charCodeAt(F+1),H>=56320&&H<=57343)?(X-55296)*1024+H-56320+65536:X}a(Ce,"codePointAt");function xe(w){return/^\n* /.test(w)}a(xe,"needIndentIndicator");let Oe=1,Re=2,Ae=3,ee=4,_e=5;function Te(w,F,X,H,q,k,N,z){let K,ae=0,Se=null,De=!1,rt=!1,Jr=H!==-1,Cr=-1,sr=oe(Ce(w,0))&&Ee(Ce(w,w.length-1));if(F||N)for(K=0;K<w.length;ae>=65536?K+=2:K++){if(ae=Ce(w,K),!me(ae))return _e;sr=sr&&B(ae,Se,z),Se=ae}else{for(K=0;K<w.length;ae>=65536?K+=2:K++){if(ae=Ce(w,K),ae===l)De=!0,Jr&&(rt=rt||K-Cr-1>H&&w[Cr+1]!==" ",Cr=K);else if(!me(ae))return _e;sr=sr&&B(ae,Se,z),Se=ae}rt=rt||Jr&&K-Cr-1>H&&w[Cr+1]!==" "}return!De&&!rt?sr&&!N&&!q(w)?Oe:k===he?_e:Re:X>9&&xe(w)?_e:N?k===he?_e:Re:rt?ee:Ae}a(Te,"chooseScalarStyle");function Pe(w,F,X,H,q){w.dump=(function(){if(F.length===0)return w.quotingType===he?'""':"''";if(!w.noCompatMode&&(se.indexOf(F)!==-1||J.test(F)))return w.quotingType===he?'"'+F+'"':"'"+F+"'";let k=w.indent*Math.max(1,X),N=w.lineWidth===-1?-1:Math.max(Math.min(w.lineWidth,40),w.lineWidth-k),z=H||w.flowLevel>-1&&X>=w.flowLevel;function K(ae){return fe(w,ae)}switch(a(K,"testAmbiguity"),Te(F,z,w.indent,N,K,w.quotingType,w.forceQuotes&&!H,q)){case Oe:return F;case Re:return"'"+F.replace(/'/g,"''")+"'";case Ae:return"|"+Me(F,w.indent)+Ne(ce(F,k));case ee:return">"+Me(F,w.indent)+Ne(ce(Ge(F,N),k));case _e:return'"'+We(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}a(Pe,"writeScalar");function Me(w,F){let X=xe(w)?String(F):"",H=w[w.length-1]===`
362
+ `+n.repeat(" ",w.indent*F)}a(ue,"generateNextLine");function fe(w,F){for(let X=0,H=w.implicitTypes.length;X<H;X+=1)if(w.implicitTypes[X].resolve(F))return!0;return!1}a(fe,"testImplicitResolving");function ne(w){return w===u||w===o}a(ne,"isWhitespace");function me(w){return w>=32&&w<=126||w>=161&&w<=55295&&w!==8232&&w!==8233||w>=57344&&w<=65533&&w!==s||w>=65536&&w<=1114111}a(me,"isPrintable");function Le(w){return me(w)&&w!==s&&w!==c&&w!==l}a(Le,"isNsCharOrWhitespace");function B(w,F,X){let H=Le(w),q=H&&!ne(w);return(X?H:H&&w!==S&&w!==M&&w!==j&&w!==G&&w!==ye)&&w!==p&&!(F===O&&!q)||Le(F)&&!ne(F)&&w===p||F===O&&q}a(B,"isPlainSafe");function oe(w){return me(w)&&w!==s&&!ne(w)&&w!==I&&w!==P&&w!==O&&w!==S&&w!==M&&w!==j&&w!==G&&w!==ye&&w!==p&&w!==_&&w!==b&&w!==f&&w!==ge&&w!==T&&w!==E&&w!==y&&w!==d&&w!==h&&w!==V&&w!==$}a(oe,"isPlainSafeFirst");function Ee(w){return!ne(w)&&w!==O}a(Ee,"isPlainSafeLast");function Ce(w,F){let X=w.charCodeAt(F),H;return X>=55296&&X<=56319&&F+1<w.length&&(H=w.charCodeAt(F+1),H>=56320&&H<=57343)?(X-55296)*1024+H-56320+65536:X}a(Ce,"codePointAt");function xe(w){return/^\n* /.test(w)}a(xe,"needIndentIndicator");let Oe=1,Re=2,Ae=3,ee=4,_e=5;function Te(w,F,X,H,q,k,N,z){let K,ae=0,Se=null,De=!1,rt=!1,Jr=H!==-1,Cr=-1,or=oe(Ce(w,0))&&Ee(Ce(w,w.length-1));if(F||N)for(K=0;K<w.length;ae>=65536?K+=2:K++){if(ae=Ce(w,K),!me(ae))return _e;or=or&&B(ae,Se,z),Se=ae}else{for(K=0;K<w.length;ae>=65536?K+=2:K++){if(ae=Ce(w,K),ae===l)De=!0,Jr&&(rt=rt||K-Cr-1>H&&w[Cr+1]!==" ",Cr=K);else if(!me(ae))return _e;or=or&&B(ae,Se,z),Se=ae}rt=rt||Jr&&K-Cr-1>H&&w[Cr+1]!==" "}return!De&&!rt?or&&!N&&!q(w)?Oe:k===he?_e:Re:X>9&&xe(w)?_e:N?k===he?_e:Re:rt?ee:Ae}a(Te,"chooseScalarStyle");function Pe(w,F,X,H,q){w.dump=(function(){if(F.length===0)return w.quotingType===he?'""':"''";if(!w.noCompatMode&&(se.indexOf(F)!==-1||J.test(F)))return w.quotingType===he?'"'+F+'"':"'"+F+"'";let k=w.indent*Math.max(1,X),N=w.lineWidth===-1?-1:Math.max(Math.min(w.lineWidth,40),w.lineWidth-k),z=H||w.flowLevel>-1&&X>=w.flowLevel;function K(ae){return fe(w,ae)}switch(a(K,"testAmbiguity"),Te(F,z,w.indent,N,K,w.quotingType,w.forceQuotes&&!H,q)){case Oe:return F;case Re:return"'"+F.replace(/'/g,"''")+"'";case Ae:return"|"+Me(F,w.indent)+Ne(ce(F,k));case ee:return">"+Me(F,w.indent)+Ne(ce(Ge(F,N),k));case _e:return'"'+We(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}a(Pe,"writeScalar");function Me(w,F){let X=xe(w)?String(F):"",H=w[w.length-1]===`
363
363
  `,k=H&&(w[w.length-2]===`
364
364
  `||w===`
365
365
  `)?"+":H?"":"-";return X+k+`
@@ -376,18 +376,18 @@ ${r.trim()}
376
376
  ---`):`---
377
377
  ${r.trim()}
378
378
  ---
379
- ${e}`}shouldSkipDirectory(e){return e.startsWith(".")}walkDirectory(e,t){let r;try{r=vr.default.readdirSync(e,{withFileTypes:!0})}catch(i){let s=i;if(s.code==="EPERM"||s.code==="EACCES")return;throw i}for(let i of r){let s=Jt.default.join(e,i.name);if(i.isDirectory()){if(this.shouldSkipDirectory(i.name))continue;this.walkDirectory(s,t)}else i.isFile()&&t(s)}}}});var ir=et(()=>{"use strict"});function Z$(n){return n.startsWith("VALIDATION_")?"validation":n.startsWith("PERMISSION_")?"permission":n.startsWith("STATE_")?"state":"internal"}var dt,e5=et(()=>{"use strict";a(Z$,"getErrorCategory");dt=class{static{a(this,"ResponseBuilder")}static success(e,t){return{success:!0,data:e,...t&&{meta:t}}}static error(e,t,r,i){return{success:!1,error:{code:e,category:Z$(e),message:t,exitCode:r,...i?.recovery&&{recovery:i.recovery},...i?.context&&{context:i.context},...i?.stack&&{stack:i.stack}}}}}});var fr=et(()=>{"use strict";e5()});var Tr,Si=et(()=>{"use strict";fr();Tr=class extends Error{static{a(this,"CLIError")}constructor(e,t,r){super(e),this.name=this.constructor.name,this.context=t,this.recoveryHint=r,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}format(){let e=`\u274C ${this.name}: ${this.message}`;if(this.guidance&&(e+=`
379
+ ${e}`}shouldSkipDirectory(e){return e.startsWith(".")}walkDirectory(e,t){let r;try{r=vr.default.readdirSync(e,{withFileTypes:!0})}catch(i){let s=i;if(s.code==="EPERM"||s.code==="EACCES")return;throw i}for(let i of r){let s=Jt.default.join(e,i.name);if(i.isDirectory()){if(this.shouldSkipDirectory(i.name))continue;this.walkDirectory(s,t)}else i.isFile()&&t(s)}}}});var sr=et(()=>{"use strict"});function Z$(n){return n.startsWith("VALIDATION_")?"validation":n.startsWith("PERMISSION_")?"permission":n.startsWith("STATE_")?"state":"internal"}var dt,e5=et(()=>{"use strict";a(Z$,"getErrorCategory");dt=class{static{a(this,"ResponseBuilder")}static success(e,t){return{success:!0,data:e,...t&&{meta:t}}}static error(e,t,r,i){return{success:!1,error:{code:e,category:Z$(e),message:t,exitCode:r,...i?.recovery&&{recovery:i.recovery},...i?.context&&{context:i.context},...i?.stack&&{stack:i.stack}}}}}});var fr=et(()=>{"use strict";e5()});var Tr,Si=et(()=>{"use strict";fr();Tr=class extends Error{static{a(this,"CLIError")}constructor(e,t,r){super(e),this.name=this.constructor.name,this.context=t,this.recoveryHint=r,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}format(){let e=`\u274C ${this.name}: ${this.message}`;if(this.guidance&&(e+=`
380
380
 
381
381
  \u{1F4A1} ${this.guidance}`),this.context&&Object.keys(this.context).length>0){e+=`
382
382
 
383
383
  \u{1F4CB} Context:`;for(let[t,r]of Object.entries(this.context))e+=`
384
- ${t}: ${JSON.stringify(r)}`}return e}toStructuredResponse(e=!1){return dt.error(this.errorCode,this.message,this.exitCode,{recovery:this.recoveryHint||{message:this.guidance},context:this.context,stack:e?this.stack:void 0})}formatJson(e=!1){return JSON.stringify(this.toStructuredResponse(e),null,2)}}});var we,xt=et(()=>{"use strict";ir();Si();fr();we=class n{static{a(this,"ErrorHandler")}static{this.outputFormat="text"}static setFormat(e){n.outputFormat=e}static getFormat(){return n.outputFormat}static isDebugMode(){return!!process.env.DEBUG}static handle(e){if(e instanceof Tr){if(n.outputFormat==="json"){let i=e.toStructuredResponse(n.isDebugMode());console.log(JSON.stringify(i,null,2))}else console.error(e.format()),n.isDebugMode()&&(console.error(`
385
- \u{1F4CD} Stack trace:`),console.error(e.stack));process.exit(e.exitCode)}let{exitCode:t,errorCode:r}=n.classifyError(e);if(n.outputFormat==="json"){let i=n.buildErrorResponse(r,e.message,t,n.isDebugMode()?e.stack:void 0);console.log(JSON.stringify(i,null,2))}else console.error(`\u274C Error: ${e.message}`),n.isDebugMode()&&console.error(e.stack);process.exit(t)}static handleWithMessage(e,t=1,r="INTERNAL_UNKNOWN"){if(n.outputFormat==="json"){let i=n.buildErrorResponse(r,e,t);console.log(JSON.stringify(i,null,2))}else console.error(`\u274C Error: ${e}`);process.exit(t)}static classifyError(e){let t=e.message.toLowerCase();return t.includes("transition")?{exitCode:6,errorCode:"STATE_INVALID_TRANSITION"}:t.includes("transaction")?{exitCode:7,errorCode:"INTERNAL_TRANSACTION_FAILED"}:t.includes("concurrent")||t.includes("modified")?{exitCode:8,errorCode:"STATE_CONCURRENT_MODIFICATION"}:e.message.includes("not found")||e.message.includes("ENOENT")?{exitCode:3,errorCode:"VALIDATION_FILE_NOT_FOUND"}:e.message.includes("EACCES")||e.message.includes("permission denied")?{exitCode:4,errorCode:"PERMISSION_DENIED"}:e.message.includes("Invalid")||e.message.includes("outside vault")||e.message.includes("Not a")?{exitCode:2,errorCode:"VALIDATION_INVALID_ARGUMENTS"}:{exitCode:1,errorCode:"INTERNAL_UNKNOWN"}}static buildErrorResponse(e,t,r,i){return dt.error(e,t,r,{recovery:n.getRecoveryHint(e),stack:i})}static getRecoveryHint(e){switch(e){case"VALIDATION_FILE_NOT_FOUND":return{message:"Verify the file path is correct and the file exists",suggestion:"Check file path spelling and ensure the file is in the vault"};case"VALIDATION_VAULT_NOT_FOUND":return{message:"Verify the vault path is correct",suggestion:"Check --vault option or current directory"};case"VALIDATION_INVALID_ARGUMENTS":return{message:"Check command syntax and argument format",suggestion:"Use --help for usage information"};case"STATE_INVALID_TRANSITION":return{message:"The requested state transition is not allowed",suggestion:"Check the current asset state and valid transitions"};case"STATE_CONCURRENT_MODIFICATION":return{message:"File was modified by another process",suggestion:"Wait and retry the command"};case"PERMISSION_DENIED":return{message:"Check file permissions",suggestion:"Ensure you have write access to the vault"};case"INTERNAL_TRANSACTION_FAILED":return{message:"Transaction could not complete",suggestion:"Check for locked files and retry"};default:return{message:"An unexpected error occurred",suggestion:"Check the error details and retry"}}}}});var t5=et(()=>{"use strict";ir();Si();fr()});var nt,r5=et(()=>{"use strict";ir();Si();fr();nt=class extends Tr{constructor(t,r,i){let s=`Check command syntax and argument format.
386
- Use: exocortex command --help for usage information.`;super(t,i,{message:r||"Check command syntax and argument format",suggestion:"exocortex command --help"});this.exitCode=2;this.errorCode="VALIDATION_INVALID_ARGUMENTS";this.guidance=r||s}static{a(this,"InvalidArgumentsError")}}});var n5=et(()=>{"use strict";ir();Si();fr()});var Qe,i5=et(()=>{"use strict";ir();Si();fr();Qe=class extends Tr{constructor(t,r){super(`Vault not found: ${t}`,{vaultPath:t,...r},{message:"Verify the vault path is correct and the directory exists",suggestion:`ls -la "${t}" or check --vault option`});this.exitCode=3;this.errorCode="VALIDATION_VAULT_NOT_FOUND";this.guidance=`The specified vault directory does not exist.
384
+ ${t}: ${JSON.stringify(r)}`}return e}toStructuredResponse(e=!1){return dt.error(this.errorCode,this.message,this.exitCode,{recovery:this.recoveryHint||{message:this.guidance},context:this.context,stack:e?this.stack:void 0})}formatJson(e=!1){return JSON.stringify(this.toStructuredResponse(e),null,2)}}});var we,xt=et(()=>{"use strict";sr();Si();fr();we=class n{static{a(this,"ErrorHandler")}static{this.outputFormat="text"}static setFormat(e){n.outputFormat=e}static getFormat(){return n.outputFormat}static isDebugMode(){return!!process.env.DEBUG}static handle(e){if(e instanceof Tr){if(n.outputFormat==="json"){let i=e.toStructuredResponse(n.isDebugMode());console.log(JSON.stringify(i,null,2))}else console.error(e.format()),n.isDebugMode()&&(console.error(`
385
+ \u{1F4CD} Stack trace:`),console.error(e.stack));process.exit(e.exitCode)}let{exitCode:t,errorCode:r}=n.classifyError(e);if(n.outputFormat==="json"){let i=n.buildErrorResponse(r,e.message,t,n.isDebugMode()?e.stack:void 0);console.log(JSON.stringify(i,null,2))}else console.error(`\u274C Error: ${e.message}`),n.isDebugMode()&&console.error(e.stack);process.exit(t)}static handleWithMessage(e,t=1,r="INTERNAL_UNKNOWN"){if(n.outputFormat==="json"){let i=n.buildErrorResponse(r,e,t);console.log(JSON.stringify(i,null,2))}else console.error(`\u274C Error: ${e}`);process.exit(t)}static classifyError(e){let t=e.message.toLowerCase();return t.includes("transition")?{exitCode:6,errorCode:"STATE_INVALID_TRANSITION"}:t.includes("transaction")?{exitCode:7,errorCode:"INTERNAL_TRANSACTION_FAILED"}:t.includes("concurrent")||t.includes("modified")?{exitCode:8,errorCode:"STATE_CONCURRENT_MODIFICATION"}:e.message.includes("not found")||e.message.includes("ENOENT")?{exitCode:3,errorCode:"VALIDATION_FILE_NOT_FOUND"}:e.message.includes("EACCES")||e.message.includes("permission denied")?{exitCode:4,errorCode:"PERMISSION_DENIED"}:e.message.includes("Invalid")||e.message.includes("outside vault")||e.message.includes("Not a")?{exitCode:2,errorCode:"VALIDATION_INVALID_ARGUMENTS"}:{exitCode:1,errorCode:"INTERNAL_UNKNOWN"}}static buildErrorResponse(e,t,r,i){return dt.error(e,t,r,{recovery:n.getRecoveryHint(e),stack:i})}static getRecoveryHint(e){switch(e){case"VALIDATION_FILE_NOT_FOUND":return{message:"Verify the file path is correct and the file exists",suggestion:"Check file path spelling and ensure the file is in the vault"};case"VALIDATION_VAULT_NOT_FOUND":return{message:"Verify the vault path is correct",suggestion:"Check --vault option or current directory"};case"VALIDATION_INVALID_ARGUMENTS":return{message:"Check command syntax and argument format",suggestion:"Use --help for usage information"};case"STATE_INVALID_TRANSITION":return{message:"The requested state transition is not allowed",suggestion:"Check the current asset state and valid transitions"};case"STATE_CONCURRENT_MODIFICATION":return{message:"File was modified by another process",suggestion:"Wait and retry the command"};case"PERMISSION_DENIED":return{message:"Check file permissions",suggestion:"Ensure you have write access to the vault"};case"INTERNAL_TRANSACTION_FAILED":return{message:"Transaction could not complete",suggestion:"Check for locked files and retry"};default:return{message:"An unexpected error occurred",suggestion:"Check the error details and retry"}}}}});var t5=et(()=>{"use strict";sr();Si();fr()});var nt,r5=et(()=>{"use strict";sr();Si();fr();nt=class extends Tr{constructor(t,r,i){let s=`Check command syntax and argument format.
386
+ Use: exocortex command --help for usage information.`;super(t,i,{message:r||"Check command syntax and argument format",suggestion:"exocortex command --help"});this.exitCode=2;this.errorCode="VALIDATION_INVALID_ARGUMENTS";this.guidance=r||s}static{a(this,"InvalidArgumentsError")}}});var n5=et(()=>{"use strict";sr();Si();fr()});var Qe,i5=et(()=>{"use strict";sr();Si();fr();Qe=class extends Tr{constructor(t,r){super(`Vault not found: ${t}`,{vaultPath:t,...r},{message:"Verify the vault path is correct and the directory exists",suggestion:`ls -la "${t}" or check --vault option`});this.exitCode=3;this.errorCode="VALIDATION_VAULT_NOT_FOUND";this.guidance=`The specified vault directory does not exist.
387
387
  Check:
388
388
  \u2022 Path spelling and case sensitivity
389
389
  \u2022 Directory exists and is accessible
390
- \u2022 You have read permissions for the directory`}static{a(this,"VaultNotFoundError")}}});var s5=et(()=>{"use strict";ir();Si();fr()});var o5=et(()=>{"use strict";ir();Si();fr()});var a5=et(()=>{"use strict";ir();Si();fr()});var Ih,l5=et(()=>{"use strict";ir();Si();fr();Ih=class extends Tr{constructor(t,r,i){let s=Math.round(t/1e3),l=`Query timeout after ${r!==void 0?Math.round(r/1e3):s}s (limit: ${s}s)`;super(l,{timeoutMs:t,elapsedMs:r??t,partialResultsCount:i},{message:"Increase timeout with --timeout <duration> (e.g., --timeout 60s)",suggestion:`exocortex query --timeout ${s*2}s "..."`});this.exitCode=5;this.errorCode="INTERNAL_QUERY_TIMEOUT";this.guidance=`Query exceeded the ${s}s timeout limit.
390
+ \u2022 You have read permissions for the directory`}static{a(this,"VaultNotFoundError")}}});var s5=et(()=>{"use strict";sr();Si();fr()});var o5=et(()=>{"use strict";sr();Si();fr()});var a5=et(()=>{"use strict";sr();Si();fr()});var Ih,l5=et(()=>{"use strict";sr();Si();fr();Ih=class extends Tr{constructor(t,r,i){let s=Math.round(t/1e3),l=`Query timeout after ${r!==void 0?Math.round(r/1e3):s}s (limit: ${s}s)`;super(l,{timeoutMs:t,elapsedMs:r??t,partialResultsCount:i},{message:"Increase timeout with --timeout <duration> (e.g., --timeout 60s)",suggestion:`exocortex query --timeout ${s*2}s "..."`});this.exitCode=5;this.errorCode="INTERNAL_QUERY_TIMEOUT";this.guidance=`Query exceeded the ${s}s timeout limit.
391
391
 
392
392
  To fix this:
393
393
  1. Increase timeout: --timeout ${s*2}s
@@ -395,7 +395,7 @@ To fix this:
395
395
  3. Simplify query: reduce WHERE clauses or add LIMIT
396
396
  4. Use cache: --use-cache for faster vault loading${i!==void 0?`
397
397
 
398
- Partial results: ${i} result(s) were collected before timeout.`:""}`}static{a(this,"QueryTimeoutError")}}});var xh,Vx=et(()=>{"use strict";ir();Si();fr();xh=class extends Tr{constructor(t,r){let i=r.length>0?` Did you mean '${r[0]}'?`:"",s=`Unknown property '${t}' \u2014 not in the mounted TBox.${i}`;super(s,{unknown:t,suggestions:r},{message:r.length>0?`Use '${r[0]}' (or another property that exists in the mounted TBox).`:"Use a property name that exists in the mounted TBox.",suggestion:"New properties are authored through the TBox (a new exo__Property asset), not via create."});this.exitCode=2;this.errorCode="VALIDATION_INVALID_ARGUMENTS";this.unknown=t,this.suggestions=r,this.guidance="The property name does not exist in the mounted TBox. Fix the spelling"+(r.length>0?` (e.g. '${r[0]}')`:"")+", or author the new property through the TBox path \u2014 `create` does not mint properties."}static{a(this,"UnknownPropertyError")}}});var Rh,c5=et(()=>{"use strict";ir();Si();fr();Rh=class extends Tr{constructor(t,r){let i=r.map(o=>` \u2022 ${o.propertyPath} (${o.constraint}): ${o.message}`+(o.expectedRange?` [expected: ${o.expectedRange}]`:"")+(o.actualValue?` [actual: ${o.actualValue}]`:"")).join(`
398
+ Partial results: ${i} result(s) were collected before timeout.`:""}`}static{a(this,"QueryTimeoutError")}}});var xh,Vx=et(()=>{"use strict";sr();Si();fr();xh=class extends Tr{constructor(t,r){let i=r.length>0?` Did you mean '${r[0]}'?`:"",s=`Unknown property '${t}' \u2014 not in the mounted TBox.${i}`;super(s,{unknown:t,suggestions:r},{message:r.length>0?`Use '${r[0]}' (or another property that exists in the mounted TBox).`:"Use a property name that exists in the mounted TBox.",suggestion:"New properties are authored through the TBox (a new exo__Property asset), not via create."});this.exitCode=2;this.errorCode="VALIDATION_INVALID_ARGUMENTS";this.unknown=t,this.suggestions=r,this.guidance="The property name does not exist in the mounted TBox. Fix the spelling"+(r.length>0?` (e.g. '${r[0]}')`:"")+", or author the new property through the TBox path \u2014 `create` does not mint properties."}static{a(this,"UnknownPropertyError")}}});var Rh,c5=et(()=>{"use strict";sr();Si();fr();Rh=class extends Tr{constructor(t,r){let i=r.map(o=>` \u2022 ${o.propertyPath} (${o.constraint}): ${o.message}`+(o.expectedRange?` [expected: ${o.expectedRange}]`:"")+(o.actualValue?` [actual: ${o.actualValue}]`:"")).join(`
399
399
  `),s=`SHACL-lite validation failed for the new asset \u2014 nothing was written.
400
400
  ${r.length} violation(s) in ${t}:
401
401
  ${i}`;super(s,{path:t,violations:r},{message:"Fix the frontmatter so the asset satisfies its class shapes, then re-run create.",suggestion:"Run `validate schema --shapes-mode` on the vault to see the same shapes the gate applied."});this.exitCode=2;this.errorCode="VALIDATION_INVALID_FORMAT";this.assetPath=t,this.violations=r,this.guidance="The asset does not conform to the SHACL-lite shapes declared for its class. Add the missing required properties (or correct the offending value's class/datatype) and re-run `create --validate`. Omitting `--validate` skips the gate entirely."}static{a(this,"ShaclConformanceError")}}});var jt=et(()=>{"use strict";Si();t5();r5();n5();i5();s5();o5();a5();l5();Vx();c5()});function gb(n){if(n instanceof wi.IRI)return{type:"IRI",value:n.value};if(n instanceof wi.Literal){let e={type:"Literal",value:n.value};return n.datatype&&(e.datatype=n.datatype.value),n.language&&(e.language=n.language),e}return n instanceof wi.BlankNode?{type:"BlankNode",value:n.value}:{type:"IRI",value:String(n)}}function yb(n){switch(n.type){case"IRI":return new wi.IRI(n.value);case"Literal":return n.datatype?new wi.Literal(n.value,new wi.IRI(n.datatype)):n.language?new wi.Literal(n.value,void 0,n.language):new wi.Literal(n.value);case"BlankNode":return new wi.BlankNode(n.value);default:return new wi.IRI(n.value)}}var wi,u5=et(()=>{"use strict";wi=be(Xe());a(gb,"serializeNode");a(yb,"deserializeNode")});var Ch,xn,Oh,Li,Ff=et(()=>{"use strict";Ch=be(require("path")),xn=be(na()),Oh=be(Xe());bi();u5();Li=class{constructor(e){this.cliVersion="1.0.0";this.vaultPath=Ch.default.resolve(e),this.cachePath=Ch.default.join(this.vaultPath,".exocortex","cache","triples.json")}static{a(this,"CacheManager")}getCachePath(){return this.cachePath}async isCacheValid(){try{if(!await xn.default.pathExists(this.cachePath))return!1;let e=await xn.default.readJson(this.cachePath);return!(!e.metadata||typeof e.metadata.vaultMtime!="number"||typeof e.metadata.tripleCount!="number"||(await xn.default.stat(this.vaultPath)).mtimeMs!==e.metadata.vaultMtime)}catch{return!1}}async loadOrBuild(){let e=Date.now();if(await this.isCacheValid())return{triples:await this.loadFromCache(),cacheHit:!0,durationMs:Date.now()-e};let{tripleCount:t}=await this.buildCache();return{triples:await this.loadFromCache(),cacheHit:!1,durationMs:Date.now()-e}}async loadFromCache(){return(await xn.default.readJson(this.cachePath)).triples.map(this.deserializeTriple)}async buildCache(){let e=await this.buildCacheWithValidation({strict:!1});return{tripleCount:e.tripleCount,durationMs:e.durationMs}}async buildCacheWithValidation(e={}){let t=Date.now(),r=new Lt(this.vaultPath),s=await new Oh.NoteToRDFConverter(r).convertVaultWithValidation({strict:e.strict??!1}),o=await xn.default.stat(this.vaultPath),l=s.triples.map(this.serializeTriple),c={metadata:{version:this.cliVersion,timestamp:Date.now(),vaultPath:this.vaultPath,tripleCount:s.triples.length,vaultMtime:o.mtimeMs},triples:l};return await xn.default.ensureDir(Ch.default.dirname(this.cachePath)),await xn.default.writeJson(this.cachePath,c,{spaces:0}),{tripleCount:s.triples.length,durationMs:Date.now()-t,skippedFiles:s.skippedFiles,summary:s.summary}}async validateVault(){let e=new Lt(this.vaultPath);return new Oh.NoteToRDFConverter(e).validateVault()}async invalidate(){await xn.default.pathExists(this.cachePath)&&await xn.default.remove(this.cachePath)}async getCacheStats(){try{if(!await xn.default.pathExists(this.cachePath))return null;let e=await xn.default.readJson(this.cachePath),t=await xn.default.stat(this.cachePath),r=await this.isCacheValid();return{tripleCount:e.metadata.tripleCount,createdAt:new Date(e.metadata.timestamp),isValid:r,sizeBytes:t.size}}catch{return null}}async saveTriples(e){let t=await xn.default.stat(this.vaultPath),r=e.map(this.serializeTriple),i={metadata:{version:this.cliVersion,timestamp:Date.now(),vaultPath:this.vaultPath,tripleCount:e.length,vaultMtime:t.mtimeMs},triples:r};await xn.default.ensureDir(Ch.default.dirname(this.cachePath)),await xn.default.writeJson(this.cachePath,i,{spaces:0})}serializeTriple(e){return{subject:gb(e.subject),predicate:gb(e.predicate),object:gb(e.object)}}deserializeTriple(e){return new Oh.Triple(yb(e.subject),yb(e.predicate),yb(e.object))}}});function Mf(n){let e=new Set,t=/PREFIX\s+(\w+)\s*:/gi,r;for(;(r=t.exec(n))!==null;)e.add(r[1].toLowerCase());let i=U5.SPARQL_PREFIXES.split(`
@@ -438,7 +438,7 @@ ${i}`;super(s,{path:t,violations:r},{message:"Fix the frontmatter so the asset s
438
438
  `)}getAllVariables(e){let t=new Set;for(let r of e)for(let i of r.variables())t.add(i);return Array.from(t).sort()}escapeValue(e){return e.includes(",")||e.includes('"')||e.includes(`
439
439
  `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}};var Df=class{static{a(this,"TriplesFormatter")}formatNTriples(e){return e.map(t=>t.toString()).join(`
440
440
  `)}formatTable(e){if(e.length===0)return"No triples generated.";let t=[];t.push("Subject | Predicate | Object"),t.push("------- | --------- | ------");for(let r of e){let i=this.formatNode(r.subject),s=this.formatNode(r.predicate),o=this.formatNode(r.object);t.push(`${i} | ${s} | ${o}`)}return t.join(`
441
- `)}formatJson(e){let t=e.map(r=>({subject:this.nodeToJson(r.subject),predicate:this.nodeToJson(r.predicate),object:this.nodeToJson(r.object)}));return JSON.stringify(t,null,2)}formatNode(e){return e.value!==void 0?String(e.value):String(e)}nodeToJson(e){return"datatype"in e||"language"in e?{type:"literal",value:String(e.value),...e.datatype&&{datatype:e.datatype.value||String(e.datatype)},...e.language&&{language:e.language}}:"id"in e&&String(e.id).startsWith("_:")?{type:"bnode",value:String(e.id)}:{type:"uri",value:String(e.value)}}};xt();jt();fr();ir();Ff();var f5=be(require("crypto")),_c=be(require("path")),d5=be(require("os")),Qr=be(na());var gce=500,yce=50*1024*1024,oa=class{static{a(this,"QueryResultCache")}constructor(e={}){this.cacheDir=e.cacheDir??_c.default.join(d5.default.homedir(),".exocortex","cache","query-results"),this.maxEntries=e.maxEntries??gce,this.maxSizeBytes=e.maxSizeBytes??yce}getCacheDir(){return this.cacheDir}getCacheKey(e){let t=e.trim().replace(/\s+/g," ");return f5.default.createHash("sha256").update(t).digest("hex")}async get(e,t,r){let i=this.getCacheKey(e),s=this.getCachePath(i);try{if(!await Qr.default.pathExists(s))return null;let o=await Qr.default.readJson(s),l=Date.now()-o.timestamp,c=t*1e3;return l>c?(await Qr.default.remove(s),null):r&&o.vaultSignature&&o.vaultSignature!==r?(await Qr.default.remove(s),null):o.result}catch{return null}}async set(e,t,r,i){let s=this.getCacheKey(e),o=this.getCachePath(s);await Qr.default.ensureDir(this.cacheDir);let l={timestamp:Date.now(),result:t,...i?{vaultSignature:i}:{}};await Qr.default.writeJson(o,l,{spaces:0}),await this.prune(s)}async prune(e){try{let t=Number.isFinite(this.maxEntries)&&this.maxEntries>0,r=Number.isFinite(this.maxSizeBytes)&&this.maxSizeBytes>0;if(!t&&!r)return;let s=(await Qr.default.readdir(this.cacheDir)).filter(d=>d.endsWith(".json")),o=[],l=0,c=`${e}.json`;for(let d of s){if(d===c){try{let p=await Qr.default.stat(_c.default.join(this.cacheDir,d));l+=p.size}catch{}continue}try{let p=_c.default.join(this.cacheDir,d),h=await Qr.default.stat(p);o.push({path:p,mtimeMs:h.mtimeMs,size:h.size}),l+=h.size}catch{}}let u=o.length+1,f=a(()=>t&&u>this.maxEntries||r&&l>this.maxSizeBytes,"overCap");if(!f())return;o.sort((d,p)=>d.mtimeMs-p.mtimeMs);for(let d of o){if(!f())break;try{await Qr.default.remove(d.path),u--,l-=d.size}catch{}}}catch{}}async isCached(e,t){return await this.get(e,t)!==null}async invalidate(e){let t=this.getCacheKey(e),r=this.getCachePath(t);try{await Qr.default.remove(r)}catch{}}async clear(){try{if(await Qr.default.pathExists(this.cacheDir)){let e=await Qr.default.readdir(this.cacheDir);await Promise.all(e.filter(t=>t.endsWith(".json")).map(t=>Qr.default.remove(_c.default.join(this.cacheDir,t))))}}catch{}}async getCacheStats(){try{if(!await Qr.default.pathExists(this.cacheDir))return{entryCount:0,totalSizeBytes:0};let t=(await Qr.default.readdir(this.cacheDir)).filter(i=>i.endsWith(".json")),r=0;for(let i of t){let s=await Qr.default.stat(_c.default.join(this.cacheDir,i));r+=s.size}return{entryCount:t.length,totalSizeBytes:r}}catch{return{entryCount:0,totalSizeBytes:0}}}getCachePath(e){return _c.default.join(this.cacheDir,`${e}.json`)}};var qx=be(na()),Gx=be(require("path")),p5=be(require("crypto"));async function h5(n){let e=[],t=a(async r=>{let i;try{i=await qx.default.readdir(r,{withFileTypes:!0})}catch{return}for(let s of i){let o=Gx.default.join(r,s.name);if(s.isDirectory()){if(s.name===".git"||s.name==="node_modules"||s.name===".exocortex")continue;await t(o)}else if(s.name.endsWith(".md"))try{let l=await qx.default.stat(o);e.push(`${Gx.default.relative(n,o)}:${l.mtimeMs}`)}catch{}}},"walk");try{await t(n)}catch{return null}return e.length===0?null:(e.sort(),p5.default.createHash("sha256").update(e.join(`
441
+ `)}formatJson(e){let t=e.map(r=>({subject:this.nodeToJson(r.subject),predicate:this.nodeToJson(r.predicate),object:this.nodeToJson(r.object)}));return JSON.stringify(t,null,2)}formatNode(e){return e.value!==void 0?String(e.value):String(e)}nodeToJson(e){return"datatype"in e||"language"in e?{type:"literal",value:String(e.value),...e.datatype&&{datatype:e.datatype.value||String(e.datatype)},...e.language&&{language:e.language}}:"id"in e&&String(e.id).startsWith("_:")?{type:"bnode",value:String(e.id)}:{type:"uri",value:String(e.value)}}};xt();jt();fr();sr();Ff();var f5=be(require("crypto")),_c=be(require("path")),d5=be(require("os")),Qr=be(na());var gce=500,yce=50*1024*1024,oa=class{static{a(this,"QueryResultCache")}constructor(e={}){this.cacheDir=e.cacheDir??_c.default.join(d5.default.homedir(),".exocortex","cache","query-results"),this.maxEntries=e.maxEntries??gce,this.maxSizeBytes=e.maxSizeBytes??yce}getCacheDir(){return this.cacheDir}getCacheKey(e){let t=e.trim().replace(/\s+/g," ");return f5.default.createHash("sha256").update(t).digest("hex")}async get(e,t,r){let i=this.getCacheKey(e),s=this.getCachePath(i);try{if(!await Qr.default.pathExists(s))return null;let o=await Qr.default.readJson(s),l=Date.now()-o.timestamp,c=t*1e3;return l>c?(await Qr.default.remove(s),null):r&&o.vaultSignature&&o.vaultSignature!==r?(await Qr.default.remove(s),null):o.result}catch{return null}}async set(e,t,r,i){let s=this.getCacheKey(e),o=this.getCachePath(s);await Qr.default.ensureDir(this.cacheDir);let l={timestamp:Date.now(),result:t,...i?{vaultSignature:i}:{}};await Qr.default.writeJson(o,l,{spaces:0}),await this.prune(s)}async prune(e){try{let t=Number.isFinite(this.maxEntries)&&this.maxEntries>0,r=Number.isFinite(this.maxSizeBytes)&&this.maxSizeBytes>0;if(!t&&!r)return;let s=(await Qr.default.readdir(this.cacheDir)).filter(d=>d.endsWith(".json")),o=[],l=0,c=`${e}.json`;for(let d of s){if(d===c){try{let p=await Qr.default.stat(_c.default.join(this.cacheDir,d));l+=p.size}catch{}continue}try{let p=_c.default.join(this.cacheDir,d),h=await Qr.default.stat(p);o.push({path:p,mtimeMs:h.mtimeMs,size:h.size}),l+=h.size}catch{}}let u=o.length+1,f=a(()=>t&&u>this.maxEntries||r&&l>this.maxSizeBytes,"overCap");if(!f())return;o.sort((d,p)=>d.mtimeMs-p.mtimeMs);for(let d of o){if(!f())break;try{await Qr.default.remove(d.path),u--,l-=d.size}catch{}}}catch{}}async isCached(e,t){return await this.get(e,t)!==null}async invalidate(e){let t=this.getCacheKey(e),r=this.getCachePath(t);try{await Qr.default.remove(r)}catch{}}async clear(){try{if(await Qr.default.pathExists(this.cacheDir)){let e=await Qr.default.readdir(this.cacheDir);await Promise.all(e.filter(t=>t.endsWith(".json")).map(t=>Qr.default.remove(_c.default.join(this.cacheDir,t))))}}catch{}}async getCacheStats(){try{if(!await Qr.default.pathExists(this.cacheDir))return{entryCount:0,totalSizeBytes:0};let t=(await Qr.default.readdir(this.cacheDir)).filter(i=>i.endsWith(".json")),r=0;for(let i of t){let s=await Qr.default.stat(_c.default.join(this.cacheDir,i));r+=s.size}return{entryCount:t.length,totalSizeBytes:r}}catch{return{entryCount:0,totalSizeBytes:0}}}getCachePath(e){return _c.default.join(this.cacheDir,`${e}.json`)}};var qx=be(na()),Gx=be(require("path")),p5=be(require("crypto"));async function h5(n){let e=[],t=a(async r=>{let i;try{i=await qx.default.readdir(r,{withFileTypes:!0})}catch{return}for(let s of i){let o=Gx.default.join(r,s.name);if(s.isDirectory()){if(s.name===".git"||s.name==="node_modules"||s.name===".exocortex")continue;await t(o)}else if(s.name.endsWith(".md"))try{let l=await qx.default.stat(o);e.push(`${Gx.default.relative(n,o)}:${l.mtimeMs}`)}catch{}}},"walk");try{await t(n)}catch{return null}return e.length===0?null:(e.sort(),p5.default.createHash("sha256").update(e.join(`
442
442
  `)).digest("hex"))}a(h5,"computeVaultSignature");var Mh=be(require("node:process"),1);var m5=a((n=0)=>e=>`\x1B[${e+n}m`,"wrapAnsi16"),g5=a((n=0)=>e=>`\x1B[${38+n};5;${e}m`,"wrapAnsi256"),y5=a((n=0)=>(e,t,r)=>`\x1B[${38+n};2;${e};${t};${r}m`,"wrapAnsi16m"),Ht={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},hCe=Object.keys(Ht.modifier),_ce=Object.keys(Ht.color),bce=Object.keys(Ht.bgColor),mCe=[..._ce,...bce];function Sce(){let n=new Map;for(let[e,t]of Object.entries(Ht)){for(let[r,i]of Object.entries(t))Ht[r]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},t[r]=Ht[r],n.set(i[0],i[1]);Object.defineProperty(Ht,e,{value:t,enumerable:!1})}return Object.defineProperty(Ht,"codes",{value:n,enumerable:!1}),Ht.color.close="\x1B[39m",Ht.bgColor.close="\x1B[49m",Ht.color.ansi=m5(),Ht.color.ansi256=g5(),Ht.color.ansi16m=y5(),Ht.bgColor.ansi=m5(10),Ht.bgColor.ansi256=g5(10),Ht.bgColor.ansi16m=y5(10),Object.defineProperties(Ht,{rgbToAnsi256:{value(e,t,r){return e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;r.length===3&&(r=[...r].map(s=>s+s).join(""));let i=Number.parseInt(r,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:a(e=>Ht.rgbToAnsi256(...Ht.hexToRgb(e)),"value"),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,r,i;if(e>=232)t=((e-232)*10+8)/255,r=t,i=t;else{e-=16;let l=e%36;t=Math.floor(e/36)/5,r=Math.floor(l/6)/5,i=l%6/5}let s=Math.max(t,r,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(r)<<1|Math.round(t));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:a((e,t,r)=>Ht.ansi256ToAnsi(Ht.rgbToAnsi256(e,t,r)),"value"),enumerable:!1},hexToAnsi:{value:a(e=>Ht.ansi256ToAnsi(Ht.hexToAnsi256(e)),"value"),enumerable:!1}}),Ht}a(Sce,"assembleStyles");var wce=Sce(),bs=wce;var bb=be(require("node:process"),1),b5=be(require("node:os"),1),Wx=be(require("node:tty"),1);function Ni(n,e=globalThis.Deno?globalThis.Deno.args:bb.default.argv){let t=n.startsWith("-")?"":n.length===1?"-":"--",r=e.indexOf(t+n),i=e.indexOf("--");return r!==-1&&(i===-1||r<i)}a(Ni,"hasFlag");var{env:zt}=bb.default,_b;Ni("no-color")||Ni("no-colors")||Ni("color=false")||Ni("color=never")?_b=0:(Ni("color")||Ni("colors")||Ni("color=true")||Ni("color=always"))&&(_b=1);function Ece(){if("FORCE_COLOR"in zt)return zt.FORCE_COLOR==="true"?1:zt.FORCE_COLOR==="false"?0:zt.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(zt.FORCE_COLOR,10),3)}a(Ece,"envForceColor");function vce(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}a(vce,"translateLevel");function Tce(n,{streamIsTTY:e,sniffFlags:t=!0}={}){let r=Ece();r!==void 0&&(_b=r);let i=t?_b:r;if(i===0)return 0;if(t){if(Ni("color=16m")||Ni("color=full")||Ni("color=truecolor"))return 3;if(Ni("color=256"))return 2}if("TF_BUILD"in zt&&"AGENT_NAME"in zt)return 1;if(n&&!e&&i===void 0)return 0;let s=i||0;if(zt.TERM==="dumb")return s;if(bb.default.platform==="win32"){let o=b5.default.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in zt)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in zt)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in zt)||zt.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in zt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(zt.TEAMCITY_VERSION)?1:0;if(zt.COLORTERM==="truecolor"||zt.TERM==="xterm-kitty"||zt.TERM==="xterm-ghostty"||zt.TERM==="wezterm")return 3;if("TERM_PROGRAM"in zt){let o=Number.parseInt((zt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(zt.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(zt.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(zt.TERM)||"COLORTERM"in zt?1:s}a(Tce,"_supportsColor");function _5(n,e={}){let t=Tce(n,{streamIsTTY:n&&n.isTTY,...e});return vce(t)}a(_5,"createSupportsColor");var Ace={stdout:_5({isTTY:Wx.default.isatty(1)}),stderr:_5({isTTY:Wx.default.isatty(2)})},S5=Ace;function w5(n,e,t){let r=n.indexOf(e);if(r===-1)return n;let i=e.length,s=0,o="";do o+=n.slice(s,r)+e+t,s=r+i,r=n.indexOf(e,s);while(r!==-1);return o+=n.slice(s),o}a(w5,"stringReplaceAll");function E5(n,e,t,r){let i=0,s="";do{let o=n[r-1]==="\r";s+=n.slice(i,o?r-1:r)+e+(o?`\r
443
443
  `:`
444
444
  `)+t,i=r+1,r=n.indexOf(`
@@ -524,14 +524,14 @@ Available prefixes: ${u}`,this.wellKnownPrefixes[r]&&l.push(`Add: PREFIX ${r}: <
524
524
  \u{1F4CA} Execution Statistics:`),console.log(` Vault loading: ${S}ms${y?" (from cache)":""}`),console.log(` Query execution: ${G}ms`),console.log(` Total time: ${ge}ms`),console.log(` Triples scanned: ${_.length}`),console.log(` Results returned: ${$.length}`),e.useCache&&console.log(` Triple cache: ${y?"HIT":"MISS (rebuilt)"}`),c&&console.log(" Query result cache: MISS (cached for next run)"))}}catch(s){W5(s,i,t)}finally{e.strict&&(r===void 0?delete process.env.EXOCORTEX_SPARQL_STRICT:process.env.EXOCORTEX_SPARQL_STRICT=r)}})}a(G5,"sparqlQueryCommand");function W5(n,e,t){let r=new Ob;if(r.classifyError(n)!=="unknown"){let s=r.enhanceError(n,e);if(t==="json"){let o=dt.error("VALIDATION_INVALID_FORMAT",s.message,2,{context:{errorType:s.type,suggestions:s.suggestions,line:s.line,column:s.column,queryContext:s.context?{startLine:s.context.startLine,endLine:s.context.endLine,errorLine:s.context.errorLine}:void 0},recovery:{message:s.suggestions?.[0]||"Check query syntax"}});console.log(JSON.stringify(o,null,2)),process.exit(2)}else console.error(r.formatForText(s)),process.exit(2)}we.handle(n)}a(W5,"handleSparqlError");function Eue(n){if(n.includes("SELECT")||n.includes("CONSTRUCT")||n.includes("INSERT")||n.includes("DELETE"))return n;let e=(0,bR.resolve)(n);return(0,jh.existsSync)(e)?(0,jh.readFileSync)(e,"utf-8"):n}a(Eue,"loadQuery");async function vue(n,e,t){if(e.explain){let i=new xb,s=await i.analyze(n,{includeAlgebraPlan:!0,optimize:!e.noOptimize});if(t==="json"){let o=dt.success(s);console.log(JSON.stringify(o,null,2))}else s.valid?(console.log(`\u2705 Query syntax is valid
525
525
  `),console.log(i.formatAnalysis(s,"text"))):(console.log(i.formatAnalysis(s,"text")),process.exit(2));return}let r=new dr.ExoQLParser;try{let i=r.parse(n);if(i.type!=="update"){let o=new dr.ExoQLAlgebraTranslator().translate(i);if(!e.noOptimize&&o.type!=="construct")o=new dr.AlgebraOptimizer().optimize(o);else if(!e.noOptimize&&o.type==="construct"){let l=new dr.AlgebraOptimizer,c=o;o={...c,where:l.optimize(c.where)}}}if(t==="json"){let s=dt.success({valid:!0,queryType:q5(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: ${q5(i)}`)}catch(i){W5(i,n,t)}}a(vue,"executeDryRun");function q5(n){return n.type==="update"?"UPDATE":"queryType"in n?n.queryType:"UNKNOWN"}a(q5,"getQueryType");function Tue(n,e){switch(e){case"json":let t=new hb;console.log(t.format(n));break;case"csv":let r=new mb;console.log(r.format(n));break;case"table":default:let i=new Pf;console.log(i.format(n));break}}a(Tue,"formatSelectResults");function Aue(n,e){let t=new Df;switch(e){case"json":console.log(t.formatJson(n));break;case"ntriples":console.log(t.formatNTriples(n));break;case"table":default:console.log(t.formatTable(n));break}}a(Aue,"formatConstructResults");function Iue(n,e){switch(e){case"json":console.log(JSON.stringify(n,null,2));break;case"csv":if(n.length===0){console.log("");return}let t=Object.keys(n[0]);console.log(t.join(","));for(let i of n){let s=t.map(o=>{let l=i[o];return l==null?"":String(l).includes(",")?`"${l}"`:String(l)});console.log(s.join(","))}break;case"table":default:if(n.length===0){console.log("No results.");return}let r=Object.keys(n[0]);console.log(r.join(" ")),console.log(r.map(()=>"---").join(" "));for(let i of n){let s=r.map(o=>String(i[o]??""));console.log(s.join(" "))}break}}a(Iue,"formatCachedSelectResults");function xue(n,e){switch(e){case"json":console.log(JSON.stringify(n,null,2));break;case"ntriples":for(let t of n)console.log(`<${t.subject}> <${t.predicate}> ${Rue(t.object)} .`);break;case"table":default:console.log("Subject Predicate Object"),console.log("--- --- ---");for(let t of n)console.log(`${t.subject} ${t.predicate} ${t.object}`);break}}a(xue,"formatCachedConstructResults");function Rue(n){return Pb.formatObject(n)}a(Rue,"formatNTriplesObject");function Cue(n,e){for(let t of n){let r=[`${t.type.toUpperCase()}`];switch(t.inserted!==void 0&&r.push(`inserted: ${t.inserted}`),t.deleted!==void 0&&r.push(`deleted: ${t.deleted}`),r.push(t.success?"OK":"FAILED"),e){case"json":console.log(JSON.stringify(t,null,2));break;case"csv":n.indexOf(t)===0&&console.log("type,inserted,deleted,success"),console.log(`${t.type},${t.inserted??""},${t.deleted??""},${t.success}`);break;case"table":default:console.log(`\u2705 ${r.join(" | ")}`);break}}}a(Cue,"formatUpdateResults");ft();var H5=require("fs"),z5=require("path"),so=be(Xe());Ff();xt();jt();fr();function K5(){return new Ie("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 n=>{let e=n.output||"text";we.setFormat(e);try{let t=(0,z5.resolve)(n.vault);if(!(0,H5.existsSync)(t))throw new Qe(t);let r=new Li(t),i=r.getCachePath();n.force&&(e==="text"&&console.log("\u{1F5D1}\uFE0F Invalidating existing cache..."),await r.invalidate()),e==="text"&&console.log(`\u{1F4E6} Building triple cache for: ${t}...`);let s=Date.now(),o=await r.buildCacheWithValidation({strict:n.strict??!1}),l=0;if(n.inference!==!1){let{triples:u}=await r.loadOrBuild(),f=new so.InMemoryTripleStore;await f.addAll(u),l=await new so.RDFSInferenceEngine().materialize(f);let p=new so.NonInheritablePropertyRegistry;await p.initialize(f);let h=new so.PropertyCardinalityRegistry;await h.initialize(f);let y=await new so.PrototypeChainMaterializer(p,h).materialize(f);if(l+=y,l>0){let b=await f.match();await r.saveTriples(b),o.tripleCount+=l}e==="text"&&l>0&&console.log(`\u{1F9E0} Materialized ${l} inferred triples (RDFS + prototype chain)`)}let c=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(n.stats){let d=await r.getCacheStats();if(d){let p={tripleCount:d.tripleCount,createdAt:d.createdAt.toISOString(),isValid:d.isValid,sizeBytes:d.sizeBytes,cachePath:i},h=dt.success({cache:u,stats:p,validation:f},{durationMs:c});console.log(JSON.stringify(h,null,2))}}else{let d=dt.success({cache:u,validation:f},{durationMs:c});console.log(JSON.stringify(d,null,2))}}else{if(o.skippedFiles.length>0){console.log(`
526
526
  \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`),n.stats){let u=await r.getCacheStats();u&&(console.log(`
527
- \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: ${Oue(u.sizeBytes)}`))}}}catch(t){we.handle(t)}})}a(K5,"sparqlIndexCommand");function Oue(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}a(Oue,"formatBytes");ft();var kb=require("fs"),ws=require("path");xt();jt();fr();ir();function Y5(){return new Ie("resolve").description("Resolve UUID to file path").argument("<uuid>","Full or partial UUID to resolve").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: uri|path|json (default: uri)","uri").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--partial","Match partial UUIDs (returns all matches)").action(async(n,e)=>{let t=e.output||"text";we.setFormat(t);try{let r=Date.now();if(!Pue(n))throw new nt(`Invalid UUID format: ${n}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:n});let i=(0,ws.resolve)(e.vault);if(!(0,kb.existsSync)(i))throw new Qe(i);let s=Due(i,n,e.partial??!1),o=Date.now()-r;if(s.length===0){if(t==="json"){let l=dt.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${n}`,3,{context:{uuid:n}});console.log(JSON.stringify(l,null,2))}else console.error(`UUID not found: ${n}`);process.exit(1)}e.partial||s.length>1?Lue(s,i,e.format,t,n,o):Fue(s[0],i,e.format,t,n,o)}catch(r){we.handle(r)}})}a(Y5,"resolveCommand");function Pue(n){if(n.length<4)return!1;let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,t=/^[0-9a-f-]+$/i;return e.test(n)||t.test(n)}a(Pue,"isValidUuidFormat");function Due(n,e,t){let r=[],i=e.toLowerCase();function s(o){let l=(0,kb.readdirSync)(o,{withFileTypes:!0});for(let c of l){let u=(0,ws.join)(o,c.name);if(c.isDirectory())!c.name.startsWith(".")&&c.name!=="node_modules"&&s(u);else if(c.isFile()&&c.name.endsWith(".md")){let f=c.name.toLowerCase();t?f.includes(i)&&r.push(u):(f.startsWith(i+".md")||f.startsWith(i+" ")||f.startsWith(i+"-"))&&r.push(u)}}}return a(s,"walk"),s(n),r}a(Due,"findFilesWithUuid");function Q5(n){return`obsidian://vault/${encodeURI(n)}`}a(Q5,"pathToObsidianUri");function X5(n){let e=n.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);return e?e[1]:(0,ws.basename)(n,".md")}a(X5,"extractUuidFromFilename");function Fue(n,e,t,r,i,s){let o=(0,ws.relative)(e,n),l=Q5(o),c=X5((0,ws.basename)(n));if(r==="json"){let u={uuid:c,path:o,absolutePath:n,uri:l},f=dt.success(u,{durationMs:s,searchUuid:i});console.log(JSON.stringify(f,null,2))}else switch(t){case"path":console.log(n);break;case"json":console.log(JSON.stringify({uuid:c,path:o,absolutePath:n,uri:l},null,2));break;case"uri":default:console.log(l);break}}a(Fue,"outputSingleResult");function Lue(n,e,t,r,i,s){let o=n.map(l=>{let c=(0,ws.relative)(e,l),u=Q5(c);return{uuid:X5((0,ws.basename)(l)),path:c,absolutePath:l,uri:u}});if(r==="json"){let l=dt.success({matches:o,count:o.length},{durationMs:s,searchUuid:i,itemCount:o.length});console.log(JSON.stringify(l,null,2))}else switch(t){case"path":for(let l of o)console.log(l.absolutePath);break;case"json":console.log(JSON.stringify(o,null,2));break;case"uri":default:for(let l of o)console.log(l.uri);break}}a(Lue,"outputMultipleResults");ft();var SR=require("fs"),Es=require("path"),pr=be(Xe());xt();jt();ir();bi();var J5=be(Xe());function Mb(n,e){return t=>{let r=typeof t.filePath=="string"&&t.filePath.length>0?t.filePath:null;if(r===null||r.split("/").includes("09 Templates"))return!1;let i=n.getAbstractFileByPath(r);if(i===null||!("basename"in i))return!1;let s=i,o=n.getFrontmatter(s)??{},l=e.getExpectedFolderSync(s,o),c=typeof t.currentFolder=="string"?t.currentFolder:s.parent?.path??"";return(0,J5.needsFolderRepair)(c,l)}}a(Mb,"createIsInWrongFolderHostFunction");var Z5=be(Xe());function jb(n){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 r=n.getAbstractFileByPath(t);if(r===null||!("basename"in r))return!1;let i=r,s=n.getFrontmatter(i)??{};return(0,Z5.hasEmptyProperties)(s)}}a(jb,"createHasEmptyPropertiesHostFunction");var Nue=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function e6(n){if(typeof n!="string")return null;let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t!==-1&&(e=e.slice(0,t).trim()),e.length>0?e:null}a(e6,"cleanRef");function kue(n){if(!n)return[];let e=n.exo__Instance_class,t=[],r=a(i=>{let s=e6(i);s&&!t.includes(s)&&t.push(s)},"collect");if(typeof e=="string")r(e);else if(Array.isArray(e))for(let i of e)r(i);return t}a(kue,"extractClasses");function Mue(n){let e=n.match(/\/ontology\/([^#/]+)#(.+)$/);return e?`${e[1]}__${e[2]}`:null}a(Mue,"ontologyIriToSymbolic");async function jue(n,e){let t=await n.match(new pr.IRI(e),pr.Namespace.EXO.term("Instance_class"),void 0),r=[];for(let i of t){let s=typeof i.object.value=="string"?i.object.value:String(i.object),o=Mue(s);o&&!r.includes(o)&&r.push(o)}return r}a(jue,"deriveStoreSymbolicClasses");async function $ue(n){let e=new pr.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),t=await n.match(void 0,e,void 0),r=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),l=s.match(Nue);l&&o.length>0&&r.set(l[1],o)}return r}a($ue,"buildCliNameMap");async function Uue(n,e,t=(0,pr.liveClock)()){let r=(0,Es.resolve)(n);if(!(0,SR.existsSync)(r))throw new Qe(r);let i=(0,Es.resolve)(r,e);if(!(0,SR.existsSync)(i))throw new Error(`Target file not found: ${e}`);let s=(0,Es.relative)(r,i);if(s===".."||s.startsWith(`..${Es.sep}`)||(0,Es.isAbsolute)(s))throw new Error(`Target is outside the vault: ${e} (vault: ${r})`);let o=new Lt(r),c=await new pr.NoteToRDFConverter(o).convertVault(),u=new pr.InMemoryTripleStore;await u.addAll(c);let f=(0,pr.vaultPathToIRI)(s),d=o.getAbstractFileByPath(s),p=d!==null&&"basename"in d?d:null,h=p?o.getFrontmatter(p):null,_=kue(h),y=await jue(u,f),b=[...new Set([..._,...y])],S=e6(h?.exo__Asset_prototype),I=h?.exo__Asset_uid,O=typeof I=="string"?I:void 0,E=await new pr.CommandResolver(u).resolveForAssetMulti(f,b,S??void 0),P=new pr.FolderRepairService(o),V=new pr.PreconditionEvaluator(u,void 0,{clock:t});(0,pr.registerDefaultHostFunctions)(V),V.registerHostFunction("isInWrongFolder",Mb(o,P)),V.registerHostFunction("hasObsoleteProperties",jb(o));let M=(0,Es.dirname)(s),j={targetIRI:f,filePath:s,fileBasename:p?.basename,currentFolder:M==="."?"":M,assetUid:O},$=await $ue(u),G=await Promise.all(E.map(async se=>{let J;try{J=await V.evaluate(se.command.precondition,f,j)}catch{J=!1}return{rc:se,available:J}})),ge=a(se=>({id:se.command.id,label:se.command.name,cliName:$.get(se.command.id)??null,category:se.command.category??null}),"toEntry"),ye=G.filter(se=>se.available).map(se=>ge(se.rc)),Q=G.filter(se=>!se.available).map(se=>({...ge(se.rc),reason:"precondition-false"}));return{target:s,classes:b,prototype:S,visible:ye,hidden:Q}}a(Uue,"resolveButtons");function Bue(n,e){let t=a(r=>`${r.label}${r.cliName?` (${r.cliName})`:""}`,"fmt");if(console.log(`Command buttons on "${n.target}" (${n.visible.length} visible):`),n.visible.length===0)console.log(" (none)");else for(let r of n.visible)console.log(` \u2713 ${t(r)}`);if(e)if(console.log(`
528
- Hidden by precondition (${n.hidden.length}):`),n.hidden.length===0)console.log(" (none)");else for(let r of n.hidden)console.log(` \u2717 ${t(r)} \u2014 precondition not satisfied`)}a(Bue,"printHuman");function t6(){return new Ie("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(n,e)=>{we.setFormat(e.json?"json":"text");try{let t=await Uue(e.vault,n);if(e.json){let r=e.showHidden?t:{...t,hidden:[]};console.log(JSON.stringify(r,null,2))}else Bue(t,e.showHidden??!1)}catch(t){we.handle(t),process.exit(5)}})}a(t6,"resolveButtonsCommand");ft();var wR=require("fs"),vs=require("path"),ol=be(Xe());xt();jt();ir();bi();var $b=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},r=this.vault.getFirstLinkpathDest(e,"",t);return!r&&!e.endsWith(".md")&&(r=this.vault.getFirstLinkpathDest(`${e}.md`,"",t)),r?this.vault.getFrontmatter(r)??{}:null}};async function Vue(n,e){let t=(0,vs.resolve)(n);if(!(0,wR.existsSync)(t))throw new Qe(t);let r=(0,vs.resolve)(t,e);if(!(0,wR.existsSync)(r))throw new Error(`Target file not found: ${e}`);let i=(0,vs.relative)(t,r);if(i===".."||i.startsWith(`..${vs.sep}`)||(0,vs.isAbsolute)(i))throw new Error(`Target is outside the vault: ${e} (vault: ${t})`);let s=new Lt(t),o=new $b(s),l=new ol.PrintNameRuleService(o,(0,ol.createDisplayMatcherHostFunctions)(o));l.initialize();let c=new ol.DisplayNameResolver(ol.DEFAULT_DISPLAY_NAME_SETTINGS,l,l.createMetadataResolver()),u=s.getAbstractFileByPath(i),f=u!==null&&"basename"in u?u:null,d=(f?s.getFrontmatter(f):null)??{},p=(0,vs.basename)(i).replace(/\.md$/,""),h=c.resolveWithProvenance({metadata:d,basename:p}),_=h.displayName??p,y=d.exo__Asset_label,b=typeof y=="string"&&y.trim().length>0,S=h.displayName===null?"basename":h.provenance==="default"?b?"label":"basename":h.provenance,I=d.exo__Asset_uid;return{target:i,uid:typeof I=="string"&&I.trim()?I.trim():null,basename:p,displayName:_,source:S}}a(Vue,"resolveDisplayName");function r6(){return new Ie("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(n,e)=>{we.setFormat(e.json?"json":"text");try{let t=await Vue(e.vault,n);e.json?console.log(JSON.stringify(t,null,2)):console.log(t.displayName)}catch(t){we.handle(t),process.exit(5)}})}a(r6,"resolveDisplayNameCommand");ft();xR();ft();var Ub=require("fs"),h6=require("path"),al=be(Xe());var Ir=be(na()),ki=be(require("path"));Ux();var la=be(Xe());var Wn=class{constructor(e){this.rootPath=e}static{a(this,"NodeFsAdapter")}async readFile(e){let t=this.resolvePath(e);if(!await Ir.default.pathExists(t))throw new la.FileNotFoundError(e);return Ir.default.readFile(t,"utf-8")}async fileExists(e){let t=this.resolvePath(e);return Ir.default.pathExists(t)}async getFileMetadata(e){let t=await this.readFile(e);return this.extractFrontmatter(t)}async createFile(e,t){let r=this.resolvePath(e);if(await Ir.default.pathExists(r))throw new la.FileAlreadyExistsError(e);return await Ir.default.ensureDir(ki.default.dirname(r)),await Ir.default.writeFile(r,t,"utf-8"),e}async updateFile(e,t){let r=this.resolvePath(e);if(!await Ir.default.pathExists(r))throw new la.FileNotFoundError(e);await Ir.default.writeFile(r,t,"utf-8")}async writeFile(e,t){let r=this.resolvePath(e);await Ir.default.ensureDir(ki.default.dirname(r)),await Ir.default.writeFile(r,t,"utf-8")}async deleteFile(e){let t=this.resolvePath(e);if(!await Ir.default.pathExists(t))throw new la.FileNotFoundError(e);await Ir.default.remove(t)}async renameFile(e,t){let r=this.resolvePath(e),i=this.resolvePath(t);if(!await Ir.default.pathExists(r))throw new la.FileNotFoundError(e);await Ir.default.ensureDir(ki.default.dirname(i)),await Ir.default.move(r,i)}async createDirectory(e){let t=this.resolvePath(e);await Ir.default.ensureDir(t)}async directoryExists(e){let t=this.resolvePath(e);return await Ir.default.pathExists(t)?(await Ir.default.stat(t)).isDirectory():!1}async getMarkdownFiles(e){let t=e?this.resolvePath(e):this.rootPath,r=ki.default.join(t,"**/*.md");return(await Of(r,{nodir:!0})).map(o=>ki.default.relative(this.rootPath,o))}async findFilesByMetadata(e){let t=await this.getMarkdownFiles(),r=[];for(let i of t)try{let s=await this.getFileMetadata(i);this.matchesQuery(s,e)&&r.push(i)}catch{continue}return r}async findFileByUID(e){let t=await this.findFilesByMetadata({exo__Asset_uid:e});return t.length>0?t[0]:null}async findFileByUidFilename(e){let t=e.toLowerCase(),r=a(async i=>{let s;try{s=await Ir.default.readdir(i,{withFileTypes:!0})}catch{return null}for(let o of s){let l=ki.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules")continue;let c=await r(l);if(c)return c}else if(o.isFile()&&o.name.endsWith(".md")){let c=o.name.toLowerCase();if(c.startsWith(t+".md")||c.startsWith(t+" ")||c.startsWith(t+"-"))return ki.default.relative(this.rootPath,l)}}return null},"walk");return r(this.rootPath)}resolvePath(e){if(ki.default.isAbsolute(e))return e;let t=this.rootPath.replace(/[/\\]+$/,""),r=ki.default.sep+e;return r===t||r.startsWith(t+ki.default.sep)?r:ki.default.join(this.rootPath,e)}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);return r?(0,la.parseYamlFrontmatterTolerant)(r[1])??{}:{}}matchesQuery(e,t){for(let[r,i]of Object.entries(t)){let s=e[r];if(Array.isArray(s)){if(!s.some(o=>this.normalizeValue(o)===this.normalizeValue(i)))return!1}else if(this.normalizeValue(s)!==this.normalizeValue(i))return!1}return!0}normalizeValue(e){return e==null?"":String(e).replace(/["'[\]]/g,"").trim()}};var ci=class n extends Wn{constructor(t,r){super(t);this.indexed=!1;this.uidToPath=new Map;this.basenameToPaths=new Map;this.allPaths=[];this.pathSet=new Set;this.assets=[];this.cacheContent=r?.cacheContent??!1}static{a(this,"CachingNodeFsAdapter")}async buildIndex(){if(this.indexed)return;let t=await super.getMarkdownFiles();for(let r of t){this.allPaths.push(r),this.pathSet.add(r);let i={},s;try{this.cacheContent?(s=await super.readFile(r),i=this.extractFrontmatter(s)):i=await super.getFileMetadata(r)}catch{i={}}let o=i?.exo__Asset_uid,l=Array.isArray(o)?o:[o];for(let f of l){let d=n.normalizeUid(f);d.length>0&&!this.uidToPath.has(d)&&this.uidToPath.set(d,r)}let c=n.basenameOf(r),u=this.basenameToPaths.get(c);u?u.push(r):this.basenameToPaths.set(c,[r]),this.assets.push(this.cacheContent?{path:r,metadata:i,content:s}:{path:r,metadata:i})}this.indexed=!0}async findPathsByBasename(t){return await this.buildIndex(),this.basenameToPaths.get(t)??[]}async hasIndexedPath(t){await this.buildIndex();let r=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(r)}static basenameOf(t){let r=t.lastIndexOf("/"),i=r===-1?t:t.slice(r+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(n.normalizeUid(t))??null}static normalizeUid(t){return t==null?"":String(t).replace(/["'[\]]/g,"").trim()}async fileExists(t){await this.buildIndex();let r=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(r)?!0:super.fileExists(t)}};xt();jt();var RR=class{constructor(e){this.vaultPath=e}static{a(this,"CliFsCheckReader")}async read(){return{assets:(await new ci(this.vaultPath).indexedAssets()).map(i=>({path:i.path,frontmatter:i.metadata}))}}};function m6(){return new Ie("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 n=>{let e=n.output??"text";we.setFormat(e);try{let t=(0,h6.resolve)(n.vault);if(!(0,Ub.existsSync)(t)||!(0,Ub.statSync)(t).isDirectory())throw new Qe(t);let i=await new RR(t).read(),s=n.all?[...al.KNOWN_CHECK_IDS]:(0,al.readEnabledCheckIds)(i.assets),o=await new al.VaultCheckRunner((0,al.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 l of o.results){let c=`${l.status==="pass"?"OK":l.status==="fail"?"FAIL":"ERROR"} ${l.label}`;if(l.status==="pass")console.log(`${c} (${i.assets.length} assets)`);else if(l.status==="error")console.error(`${c}: ${l.errorMessage}`);else{console.error(`${c}: ${l.findings.length} violation(s)`);for(let u of l.findings.slice(0,50))console.error(` ${u.path?u.path+" \u2014 ":""}${u.message}`);l.findings.length>50&&console.error(` \u2026and ${l.findings.length-50} more`)}}console.error(o.ok?`
527
+ \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: ${Oue(u.sizeBytes)}`))}}}catch(t){we.handle(t)}})}a(K5,"sparqlIndexCommand");function Oue(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}a(Oue,"formatBytes");ft();var kb=require("fs"),ws=require("path");xt();jt();fr();sr();function Y5(){return new Ie("resolve").description("Resolve UUID to file path").argument("<uuid>","Full or partial UUID to resolve").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--format <type>","Output format: uri|path|json (default: uri)","uri").option("--output <type>","Response format: text|json (for MCP tools)","text").option("--partial","Match partial UUIDs (returns all matches)").action(async(n,e)=>{let t=e.output||"text";we.setFormat(t);try{let r=Date.now();if(!Pue(n))throw new nt(`Invalid UUID format: ${n}`,"exocortex resolve <uuid> [--format uri|path|json] [--partial]",{uuid:n});let i=(0,ws.resolve)(e.vault);if(!(0,kb.existsSync)(i))throw new Qe(i);let s=Due(i,n,e.partial??!1),o=Date.now()-r;if(s.length===0){if(t==="json"){let l=dt.error("VALIDATION_FILE_NOT_FOUND",`UUID not found: ${n}`,3,{context:{uuid:n}});console.log(JSON.stringify(l,null,2))}else console.error(`UUID not found: ${n}`);process.exit(1)}e.partial||s.length>1?Lue(s,i,e.format,t,n,o):Fue(s[0],i,e.format,t,n,o)}catch(r){we.handle(r)}})}a(Y5,"resolveCommand");function Pue(n){if(n.length<4)return!1;let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,t=/^[0-9a-f-]+$/i;return e.test(n)||t.test(n)}a(Pue,"isValidUuidFormat");function Due(n,e,t){let r=[],i=e.toLowerCase();function s(o){let l=(0,kb.readdirSync)(o,{withFileTypes:!0});for(let c of l){let u=(0,ws.join)(o,c.name);if(c.isDirectory())!c.name.startsWith(".")&&c.name!=="node_modules"&&s(u);else if(c.isFile()&&c.name.endsWith(".md")){let f=c.name.toLowerCase();t?f.includes(i)&&r.push(u):(f.startsWith(i+".md")||f.startsWith(i+" ")||f.startsWith(i+"-"))&&r.push(u)}}}return a(s,"walk"),s(n),r}a(Due,"findFilesWithUuid");function Q5(n){return`obsidian://vault/${encodeURI(n)}`}a(Q5,"pathToObsidianUri");function X5(n){let e=n.match(/^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);return e?e[1]:(0,ws.basename)(n,".md")}a(X5,"extractUuidFromFilename");function Fue(n,e,t,r,i,s){let o=(0,ws.relative)(e,n),l=Q5(o),c=X5((0,ws.basename)(n));if(r==="json"){let u={uuid:c,path:o,absolutePath:n,uri:l},f=dt.success(u,{durationMs:s,searchUuid:i});console.log(JSON.stringify(f,null,2))}else switch(t){case"path":console.log(n);break;case"json":console.log(JSON.stringify({uuid:c,path:o,absolutePath:n,uri:l},null,2));break;case"uri":default:console.log(l);break}}a(Fue,"outputSingleResult");function Lue(n,e,t,r,i,s){let o=n.map(l=>{let c=(0,ws.relative)(e,l),u=Q5(c);return{uuid:X5((0,ws.basename)(l)),path:c,absolutePath:l,uri:u}});if(r==="json"){let l=dt.success({matches:o,count:o.length},{durationMs:s,searchUuid:i,itemCount:o.length});console.log(JSON.stringify(l,null,2))}else switch(t){case"path":for(let l of o)console.log(l.absolutePath);break;case"json":console.log(JSON.stringify(o,null,2));break;case"uri":default:for(let l of o)console.log(l.uri);break}}a(Lue,"outputMultipleResults");ft();var SR=require("fs"),Es=require("path"),pr=be(Xe());xt();jt();sr();bi();var J5=be(Xe());function Mb(n,e){return t=>{let r=typeof t.filePath=="string"&&t.filePath.length>0?t.filePath:null;if(r===null||r.split("/").includes("09 Templates"))return!1;let i=n.getAbstractFileByPath(r);if(i===null||!("basename"in i))return!1;let s=i,o=n.getFrontmatter(s)??{},l=e.getExpectedFolderSync(s,o),c=typeof t.currentFolder=="string"?t.currentFolder:s.parent?.path??"";return(0,J5.needsFolderRepair)(c,l)}}a(Mb,"createIsInWrongFolderHostFunction");var Z5=be(Xe());function jb(n){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 r=n.getAbstractFileByPath(t);if(r===null||!("basename"in r))return!1;let i=r,s=n.getFrontmatter(i)??{};return(0,Z5.hasEmptyProperties)(s)}}a(jb,"createHasEmptyPropertiesHostFunction");var Nue=/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i;function e6(n){if(typeof n!="string")return null;let e=n.replace(/["'[\]]/g,"").trim(),t=e.indexOf("|");return t!==-1&&(e=e.slice(0,t).trim()),e.length>0?e:null}a(e6,"cleanRef");function kue(n){if(!n)return[];let e=n.exo__Instance_class,t=[],r=a(i=>{let s=e6(i);s&&!t.includes(s)&&t.push(s)},"collect");if(typeof e=="string")r(e);else if(Array.isArray(e))for(let i of e)r(i);return t}a(kue,"extractClasses");function Mue(n){let e=n.match(/\/ontology\/([^#/]+)#(.+)$/);return e?`${e[1]}__${e[2]}`:null}a(Mue,"ontologyIriToSymbolic");async function jue(n,e){let t=await n.match(new pr.IRI(e),pr.Namespace.EXO.term("Instance_class"),void 0),r=[];for(let i of t){let s=typeof i.object.value=="string"?i.object.value:String(i.object),o=Mue(s);o&&!r.includes(o)&&r.push(o)}return r}a(jue,"deriveStoreSymbolicClasses");async function $ue(n){let e=new pr.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),t=await n.match(void 0,e,void 0),r=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),l=s.match(Nue);l&&o.length>0&&r.set(l[1],o)}return r}a($ue,"buildCliNameMap");async function Uue(n,e,t=(0,pr.liveClock)()){let r=(0,Es.resolve)(n);if(!(0,SR.existsSync)(r))throw new Qe(r);let i=(0,Es.resolve)(r,e);if(!(0,SR.existsSync)(i))throw new Error(`Target file not found: ${e}`);let s=(0,Es.relative)(r,i);if(s===".."||s.startsWith(`..${Es.sep}`)||(0,Es.isAbsolute)(s))throw new Error(`Target is outside the vault: ${e} (vault: ${r})`);let o=new Lt(r),c=await new pr.NoteToRDFConverter(o).convertVault(),u=new pr.InMemoryTripleStore;await u.addAll(c);let f=(0,pr.vaultPathToIRI)(s),d=o.getAbstractFileByPath(s),p=d!==null&&"basename"in d?d:null,h=p?o.getFrontmatter(p):null,_=kue(h),y=await jue(u,f),b=[...new Set([..._,...y])],S=e6(h?.exo__Asset_prototype),I=h?.exo__Asset_uid,O=typeof I=="string"?I:void 0,E=await new pr.CommandResolver(u).resolveForAssetMulti(f,b,S??void 0),P=new pr.FolderRepairService(o),V=new pr.PreconditionEvaluator(u,void 0,{clock:t});(0,pr.registerDefaultHostFunctions)(V),V.registerHostFunction("isInWrongFolder",Mb(o,P)),V.registerHostFunction("hasObsoleteProperties",jb(o));let M=(0,Es.dirname)(s),j={targetIRI:f,filePath:s,fileBasename:p?.basename,currentFolder:M==="."?"":M,assetUid:O},$=await $ue(u),G=await Promise.all(E.map(async se=>{let J;try{J=await V.evaluate(se.command.precondition,f,j)}catch{J=!1}return{rc:se,available:J}})),ge=a(se=>({id:se.command.id,label:se.command.name,cliName:$.get(se.command.id)??null,category:se.command.category??null}),"toEntry"),ye=G.filter(se=>se.available).map(se=>ge(se.rc)),Q=G.filter(se=>!se.available).map(se=>({...ge(se.rc),reason:"precondition-false"}));return{target:s,classes:b,prototype:S,visible:ye,hidden:Q}}a(Uue,"resolveButtons");function Bue(n,e){let t=a(r=>`${r.label}${r.cliName?` (${r.cliName})`:""}`,"fmt");if(console.log(`Command buttons on "${n.target}" (${n.visible.length} visible):`),n.visible.length===0)console.log(" (none)");else for(let r of n.visible)console.log(` \u2713 ${t(r)}`);if(e)if(console.log(`
528
+ Hidden by precondition (${n.hidden.length}):`),n.hidden.length===0)console.log(" (none)");else for(let r of n.hidden)console.log(` \u2717 ${t(r)} \u2014 precondition not satisfied`)}a(Bue,"printHuman");function t6(){return new Ie("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(n,e)=>{we.setFormat(e.json?"json":"text");try{let t=await Uue(e.vault,n);if(e.json){let r=e.showHidden?t:{...t,hidden:[]};console.log(JSON.stringify(r,null,2))}else Bue(t,e.showHidden??!1)}catch(t){we.handle(t),process.exit(5)}})}a(t6,"resolveButtonsCommand");ft();var wR=require("fs"),vs=require("path"),ol=be(Xe());xt();jt();sr();bi();var $b=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},r=this.vault.getFirstLinkpathDest(e,"",t);return!r&&!e.endsWith(".md")&&(r=this.vault.getFirstLinkpathDest(`${e}.md`,"",t)),r?this.vault.getFrontmatter(r)??{}:null}};async function Vue(n,e){let t=(0,vs.resolve)(n);if(!(0,wR.existsSync)(t))throw new Qe(t);let r=(0,vs.resolve)(t,e);if(!(0,wR.existsSync)(r))throw new Error(`Target file not found: ${e}`);let i=(0,vs.relative)(t,r);if(i===".."||i.startsWith(`..${vs.sep}`)||(0,vs.isAbsolute)(i))throw new Error(`Target is outside the vault: ${e} (vault: ${t})`);let s=new Lt(t),o=new $b(s),l=new ol.PrintNameRuleService(o,(0,ol.createDisplayMatcherHostFunctions)(o));l.initialize();let c=new ol.DisplayNameResolver(ol.DEFAULT_DISPLAY_NAME_SETTINGS,l,l.createMetadataResolver()),u=s.getAbstractFileByPath(i),f=u!==null&&"basename"in u?u:null,d=(f?s.getFrontmatter(f):null)??{},p=(0,vs.basename)(i).replace(/\.md$/,""),h=c.resolveWithProvenance({metadata:d,basename:p}),_=h.displayName??p,y=d.exo__Asset_label,b=typeof y=="string"&&y.trim().length>0,S=h.displayName===null?"basename":h.provenance==="default"?b?"label":"basename":h.provenance,I=d.exo__Asset_uid;return{target:i,uid:typeof I=="string"&&I.trim()?I.trim():null,basename:p,displayName:_,source:S}}a(Vue,"resolveDisplayName");function r6(){return new Ie("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(n,e)=>{we.setFormat(e.json?"json":"text");try{let t=await Vue(e.vault,n);e.json?console.log(JSON.stringify(t,null,2)):console.log(t.displayName)}catch(t){we.handle(t),process.exit(5)}})}a(r6,"resolveDisplayNameCommand");ft();xR();ft();var Ub=require("fs"),h6=require("path"),al=be(Xe());var Ir=be(na()),ki=be(require("path"));Ux();var la=be(Xe());var Wn=class{constructor(e){this.rootPath=e}static{a(this,"NodeFsAdapter")}async readFile(e){let t=this.resolvePath(e);if(!await Ir.default.pathExists(t))throw new la.FileNotFoundError(e);return Ir.default.readFile(t,"utf-8")}async fileExists(e){let t=this.resolvePath(e);return Ir.default.pathExists(t)}async getFileMetadata(e){let t=await this.readFile(e);return this.extractFrontmatter(t)}async createFile(e,t){let r=this.resolvePath(e);if(await Ir.default.pathExists(r))throw new la.FileAlreadyExistsError(e);return await Ir.default.ensureDir(ki.default.dirname(r)),await Ir.default.writeFile(r,t,"utf-8"),e}async updateFile(e,t){let r=this.resolvePath(e);if(!await Ir.default.pathExists(r))throw new la.FileNotFoundError(e);await Ir.default.writeFile(r,t,"utf-8")}async writeFile(e,t){let r=this.resolvePath(e);await Ir.default.ensureDir(ki.default.dirname(r)),await Ir.default.writeFile(r,t,"utf-8")}async deleteFile(e){let t=this.resolvePath(e);if(!await Ir.default.pathExists(t))throw new la.FileNotFoundError(e);await Ir.default.remove(t)}async renameFile(e,t){let r=this.resolvePath(e),i=this.resolvePath(t);if(!await Ir.default.pathExists(r))throw new la.FileNotFoundError(e);await Ir.default.ensureDir(ki.default.dirname(i)),await Ir.default.move(r,i)}async createDirectory(e){let t=this.resolvePath(e);await Ir.default.ensureDir(t)}async directoryExists(e){let t=this.resolvePath(e);return await Ir.default.pathExists(t)?(await Ir.default.stat(t)).isDirectory():!1}async getMarkdownFiles(e){let t=e?this.resolvePath(e):this.rootPath,r=ki.default.join(t,"**/*.md");return(await Of(r,{nodir:!0})).map(o=>ki.default.relative(this.rootPath,o))}async findFilesByMetadata(e){let t=await this.getMarkdownFiles(),r=[];for(let i of t)try{let s=await this.getFileMetadata(i);this.matchesQuery(s,e)&&r.push(i)}catch{continue}return r}async findFileByUID(e){let t=await this.findFilesByMetadata({exo__Asset_uid:e});return t.length>0?t[0]:null}async findFileByUidFilename(e){let t=e.toLowerCase(),r=a(async i=>{let s;try{s=await Ir.default.readdir(i,{withFileTypes:!0})}catch{return null}for(let o of s){let l=ki.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules")continue;let c=await r(l);if(c)return c}else if(o.isFile()&&o.name.endsWith(".md")){let c=o.name.toLowerCase();if(c.startsWith(t+".md")||c.startsWith(t+" ")||c.startsWith(t+"-"))return ki.default.relative(this.rootPath,l)}}return null},"walk");return r(this.rootPath)}resolvePath(e){if(ki.default.isAbsolute(e))return e;let t=this.rootPath.replace(/[/\\]+$/,""),r=ki.default.sep+e;return r===t||r.startsWith(t+ki.default.sep)?r:ki.default.join(this.rootPath,e)}extractFrontmatter(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);return r?(0,la.parseYamlFrontmatterTolerant)(r[1])??{}:{}}matchesQuery(e,t){for(let[r,i]of Object.entries(t)){let s=e[r];if(Array.isArray(s)){if(!s.some(o=>this.normalizeValue(o)===this.normalizeValue(i)))return!1}else if(this.normalizeValue(s)!==this.normalizeValue(i))return!1}return!0}normalizeValue(e){return e==null?"":String(e).replace(/["'[\]]/g,"").trim()}};var ci=class n extends Wn{constructor(t,r){super(t);this.indexed=!1;this.uidToPath=new Map;this.basenameToPaths=new Map;this.allPaths=[];this.pathSet=new Set;this.assets=[];this.cacheContent=r?.cacheContent??!1}static{a(this,"CachingNodeFsAdapter")}async buildIndex(){if(this.indexed)return;let t=await super.getMarkdownFiles();for(let r of t){this.allPaths.push(r),this.pathSet.add(r);let i={},s;try{this.cacheContent?(s=await super.readFile(r),i=this.extractFrontmatter(s)):i=await super.getFileMetadata(r)}catch{i={}}let o=i?.exo__Asset_uid,l=Array.isArray(o)?o:[o];for(let f of l){let d=n.normalizeUid(f);d.length>0&&!this.uidToPath.has(d)&&this.uidToPath.set(d,r)}let c=n.basenameOf(r),u=this.basenameToPaths.get(c);u?u.push(r):this.basenameToPaths.set(c,[r]),this.assets.push(this.cacheContent?{path:r,metadata:i,content:s}:{path:r,metadata:i})}this.indexed=!0}async findPathsByBasename(t){return await this.buildIndex(),this.basenameToPaths.get(t)??[]}async hasIndexedPath(t){await this.buildIndex();let r=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(r)}static basenameOf(t){let r=t.lastIndexOf("/"),i=r===-1?t:t.slice(r+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(n.normalizeUid(t))??null}static normalizeUid(t){return t==null?"":String(t).replace(/["'[\]]/g,"").trim()}async fileExists(t){await this.buildIndex();let r=t.replace(/\\/g,"/").replace(/^\.\//,"");return this.pathSet.has(r)?!0:super.fileExists(t)}};xt();jt();var RR=class{constructor(e){this.vaultPath=e}static{a(this,"CliFsCheckReader")}async read(){return{assets:(await new ci(this.vaultPath).indexedAssets()).map(i=>({path:i.path,frontmatter:i.metadata}))}}};function m6(){return new Ie("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 n=>{let e=n.output??"text";we.setFormat(e);try{let t=(0,h6.resolve)(n.vault);if(!(0,Ub.existsSync)(t)||!(0,Ub.statSync)(t).isDirectory())throw new Qe(t);let i=await new RR(t).read(),s=n.all?[...al.KNOWN_CHECK_IDS]:(0,al.readEnabledCheckIds)(i.assets),o=await new al.VaultCheckRunner((0,al.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 l of o.results){let c=`${l.status==="pass"?"OK":l.status==="fail"?"FAIL":"ERROR"} ${l.label}`;if(l.status==="pass")console.log(`${c} (${i.assets.length} assets)`);else if(l.status==="error")console.error(`${c}: ${l.errorMessage}`);else{console.error(`${c}: ${l.findings.length} violation(s)`);for(let u of l.findings.slice(0,50))console.error(` ${u.path?u.path+" \u2014 ":""}${u.message}`);l.findings.length>50&&console.error(` \u2026and ${l.findings.length-50} more`)}}console.error(o.ok?`
529
529
  \u2705 ${t}: all ${s.length} enabled check(s) passed`:`
530
- \u274C ${t}: validation failed`)}o.ok||(process.exitCode=1)}catch(t){we.handle(t)}})}a(m6,"validateVaultCommand");function g6(){let n=new Ie("validate").description("Validate vault files (schema linting, homoiconic vault-integrity checks)");return n.addCommand(p6()),n.addCommand(m6()),n}a(g6,"validateCommand");ft();var w6=require("fs"),E6=require("path"),Vb=be(Xe());bi();xt();ir();fr();jt();fr();Ff();var y6=be(Xe());var Mi=be(Xe());var $f=class{constructor(e,t){this.tripleStore=e;this.reader=t}static{a(this,"FsQueryBodyResolver")}async resolveSparql(e){if(!e)return null;let r=(await this.tripleStore.match(void 0,Mi.Namespace.EXO.term("Asset_uid"),new Mi.Literal(e)))[0]?.subject;if(!(r instanceof Mi.IRI))return null;let i=(0,Mi.iriToVaultPath)(r.value);if(!i)return null;let s;try{s=await this.reader.readFile(i)}catch{return null}return(0,Mi.extractSparqlBlock)((0,Mi.stripFrontmatter)(s))}};function Bb(n,e){let t=new Wn(e);return new y6.NamedQueryRunner(new $f(n,t),n)}a(Bb,"buildNamedQueryRunner");var _6="b6aa1da9-96b9-4066-99a9-f81cc8b316aa",b6="5ba1031d-2c6e-4528-ab81-fb768d8e061a",S6="efb7bb79-6378-44b0-b1ca-9a27e3eeb684";function v6(){return new Ie("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(n,e)=>{let t=e.output||"text";we.setFormat(t);try{let r=Date.now(),i=(0,E6.resolve)(e.vault);if(!(0,w6.existsSync)(i))throw new Qe(i);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let s=e.useCache??!1,o,l=!1;if(s){let p=await new Li(i).loadOrBuild();o=p.triples,l=p.cacheHit,t==="text"&&l&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let d=new Lt(i);o=await new Vb.NoteToRDFConverter(d).convertVault()}let c=new Vb.InMemoryTripleStore;await c.addAll(o);let u=Date.now()-r;if(t==="text"){let d=l?" (from cache)":"";console.log(`\u2705 Loaded ${o.length} triples in ${u}ms${d}
530
+ \u274C ${t}: validation failed`)}o.ok||(process.exitCode=1)}catch(t){we.handle(t)}})}a(m6,"validateVaultCommand");function g6(){let n=new Ie("validate").description("Validate vault files (schema linting, homoiconic vault-integrity checks)");return n.addCommand(p6()),n.addCommand(m6()),n}a(g6,"validateCommand");ft();var w6=require("fs"),E6=require("path"),Vb=be(Xe());bi();xt();sr();fr();jt();fr();Ff();var y6=be(Xe());var Mi=be(Xe());var $f=class{constructor(e,t){this.tripleStore=e;this.reader=t}static{a(this,"FsQueryBodyResolver")}async resolveSparql(e){if(!e)return null;let r=(await this.tripleStore.match(void 0,Mi.Namespace.EXO.term("Asset_uid"),new Mi.Literal(e)))[0]?.subject;if(!(r instanceof Mi.IRI))return null;let i=(0,Mi.iriToVaultPath)(r.value);if(!i)return null;let s;try{s=await this.reader.readFile(i)}catch{return null}return(0,Mi.extractSparqlBlock)((0,Mi.stripFrontmatter)(s))}};function Bb(n,e){let t=new Wn(e);return new y6.NamedQueryRunner(new $f(n,t),n)}a(Bb,"buildNamedQueryRunner");var _6="b6aa1da9-96b9-4066-99a9-f81cc8b316aa",b6="5ba1031d-2c6e-4528-ab81-fb768d8e061a",S6="efb7bb79-6378-44b0-b1ca-9a27e3eeb684";function v6(){return new Ie("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(n,e)=>{let t=e.output||"text";we.setFormat(t);try{let r=Date.now(),i=(0,E6.resolve)(e.vault);if(!(0,w6.existsSync)(i))throw new Qe(i);t==="text"&&console.log(`\u{1F4E6} Loading vault: ${i}...`);let s=e.useCache??!1,o,l=!1;if(s){let p=await new Li(i).loadOrBuild();o=p.triples,l=p.cacheHit,t==="text"&&l&&console.log("\u{1F680} Cache hit! Loading from persistent cache...")}else{let d=new Lt(i);o=await new Vb.NoteToRDFConverter(d).convertVault()}let c=new Vb.InMemoryTripleStore;await c.addAll(o);let u=Date.now()-r;if(t==="text"){let d=l?" (from cache)":"";console.log(`\u2705 Loaded ${o.length} triples in ${u}ms${d}
531
531
  `)}let f=Bb(c,i);n?await lfe(f,n,e,t):await afe(f,e,t)}catch(r){we.handle(r)}})}a(v6,"classesCommand");function CR(n,e){return n===null&&we.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"),n.kind!=="select"&&we.handleWithMessage(`Introspection query "${e}" is an ${n.kind} query; expected SELECT.`,2,"VALIDATION_INVALID_ARGUMENTS"),n.rows}a(CR,"requireSelectRows");function OR(n){let e=n?.value,t=typeof e=="string"?parseInt(e,10):NaN;return Number.isNaN(t)?0:t}a(OR,"parseCount");async function afe(n,e,t){let r=await n.run(_6),s=CR(r,_6).map(o=>{let l=o.get("class"),c=o.get("count");return{name:l?T6(l.toString()):"unknown",count:OR(c)}});if(t==="json"||e.format==="json"){let o=dt.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):
532
532
  `),s.length===0){console.log("No classes found in vault.");return}let o=Math.max(...s.map(l=>l.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 l of s)console.log("\u2502 "+l.name.padEnd(o)+" \u2502 "+l.count.toString().padStart(10)+" \u2502");console.log("\u2514"+"\u2500".repeat(o+2)+"\u2534"+"\u2500".repeat(12)+"\u2518")}}a(afe,"listAllClasses");async function lfe(n,e,t,r){let i={params:{className:{value:e,kind:"literal"}}},s=await n.run(b6,i),o=CR(s,b6),l=o.length>0?OR(o[0].get("count")):0,c=await n.run(S6,i),f=CR(c,S6).map(p=>{let h=p.get("property"),_=p.get("usageCount");return{name:h?T6(h.toString()):"unknown",usageCount:OR(_)}}),d={name:e,instanceCount:l,properties:f};if(r==="json"||t.format==="json"){let p=dt.success(d);console.log(JSON.stringify(p,null,2))}else{if(console.log(`\u{1F4CB} Class: ${e}
533
533
  `),console.log(` Instances: ${l}`),console.log(` Properties: ${f.length}
534
- `),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(lfe,"showClassDetails");function T6(n){let e=n.replace(/^<|>$/g,""),t=e.lastIndexOf("#");if(t!==-1)return e.substring(t+1);let r=e.lastIndexOf("/");return r!==-1?e.substring(r+1):e}a(T6,"extractLocalName");ft();var I6=require("fs"),x6=require("path"),Ec=be(Xe());bi();xt();ir();fr();jt();fr();Ff();function A6(n,e){return e.concat([n])}a(A6,"collect");function cfe(n,e){let t={},r=a((i,s)=>{let o=i.indexOf("=");if(o<=0)throw new Error(`Invalid --param "${i}" \u2014 expected name=value.`);let l=i.slice(0,o),c=i.slice(o+1);t[l]={value:s==="iri"?(0,Ec.vaultPathToIRI)(c):c,kind:s}},"add");for(let i of n)r(i,"literal");for(let i of e)r(i,"iri");return Object.keys(t).length>0?t:void 0}a(cfe,"buildParams");function R6(){return new Ie("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.",A6,[]).option("--param-iri <name=path>","IRI parameter $<name>; value is a vault-relative path resolved to an IRI. Repeatable.",A6,[]).action(async(n,e)=>{let t=e.output||"text",r=t==="json"||e.format==="json";we.setFormat(t);try{let i=(0,x6.resolve)(e.vault);if(!(0,I6.existsSync)(i))throw new Qe(i);r||console.log(`\u{1F4E6} Loading vault: ${i}...`);let s;e.useCache??!1?s=(await new Li(i).loadOrBuild()).triples:s=await new Ec.NoteToRDFConverter(new Lt(i)).convertVault();let o=new Ec.InMemoryTripleStore;await o.addAll(s);let l=Bb(o,i),c={};e.currentAsset&&(c.currentAsset=(0,Ec.vaultPathToIRI)(e.currentAsset));let u=cfe(e.param,e.paramIri);u&&(c.params=u);let f=await l.run(n,c);f===null&&we.handleWithMessage(`No resolvable query__NamedQuery for UID "${n}" (asset not found, or it has no \`\`\`sparql code-block).`,3,"VALIDATION_FILE_NOT_FOUND"),ufe(f,r)}catch(i){we.handle(i)}})}a(R6,"runQueryCommand");function ufe(n,e){if(n.kind==="ask"){console.log(e?JSON.stringify(dt.success({kind:"ask",result:n.result}),null,2):String(n.result));return}if(n.kind==="construct"){let t=n.triples.map(r=>({subject:r.subject.toString(),predicate:r.predicate.toString(),object:r.object.toString()}));if(e)console.log(JSON.stringify(dt.success({kind:"construct",triples:t,count:t.length}),null,2));else{console.log(`\u{1F4CA} CONSTRUCT \u2014 ${t.length} triple(s):
534
+ `),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(lfe,"showClassDetails");function T6(n){let e=n.replace(/^<|>$/g,""),t=e.lastIndexOf("#");if(t!==-1)return e.substring(t+1);let r=e.lastIndexOf("/");return r!==-1?e.substring(r+1):e}a(T6,"extractLocalName");ft();var I6=require("fs"),x6=require("path"),Ec=be(Xe());bi();xt();sr();fr();jt();fr();Ff();function A6(n,e){return e.concat([n])}a(A6,"collect");function cfe(n,e){let t={},r=a((i,s)=>{let o=i.indexOf("=");if(o<=0)throw new Error(`Invalid --param "${i}" \u2014 expected name=value.`);let l=i.slice(0,o),c=i.slice(o+1);t[l]={value:s==="iri"?(0,Ec.vaultPathToIRI)(c):c,kind:s}},"add");for(let i of n)r(i,"literal");for(let i of e)r(i,"iri");return Object.keys(t).length>0?t:void 0}a(cfe,"buildParams");function R6(){return new Ie("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.",A6,[]).option("--param-iri <name=path>","IRI parameter $<name>; value is a vault-relative path resolved to an IRI. Repeatable.",A6,[]).action(async(n,e)=>{let t=e.output||"text",r=t==="json"||e.format==="json";we.setFormat(t);try{let i=(0,x6.resolve)(e.vault);if(!(0,I6.existsSync)(i))throw new Qe(i);r||console.log(`\u{1F4E6} Loading vault: ${i}...`);let s;e.useCache??!1?s=(await new Li(i).loadOrBuild()).triples:s=await new Ec.NoteToRDFConverter(new Lt(i)).convertVault();let o=new Ec.InMemoryTripleStore;await o.addAll(s);let l=Bb(o,i),c={};e.currentAsset&&(c.currentAsset=(0,Ec.vaultPathToIRI)(e.currentAsset));let u=cfe(e.param,e.paramIri);u&&(c.params=u);let f=await l.run(n,c);f===null&&we.handleWithMessage(`No resolvable query__NamedQuery for UID "${n}" (asset not found, or it has no \`\`\`sparql code-block).`,3,"VALIDATION_FILE_NOT_FOUND"),ufe(f,r)}catch(i){we.handle(i)}})}a(R6,"runQueryCommand");function ufe(n,e){if(n.kind==="ask"){console.log(e?JSON.stringify(dt.success({kind:"ask",result:n.result}),null,2):String(n.result));return}if(n.kind==="construct"){let t=n.triples.map(r=>({subject:r.subject.toString(),predicate:r.predicate.toString(),object:r.object.toString()}));if(e)console.log(JSON.stringify(dt.success({kind:"construct",triples:t,count:t.length}),null,2));else{console.log(`\u{1F4CA} CONSTRUCT \u2014 ${t.length} triple(s):
535
535
  `);for(let r of t)console.log(`${r.subject} ${r.predicate} ${r.object} .`)}return}if(e){let t=n.rows.map(r=>{let i={};for(let s of r.variables()){let o=r.get(s);i[s]=o?o.toString():null}return i});console.log(JSON.stringify(dt.success({kind:"select",rows:t,count:t.length}),null,2))}else console.log(new Pf().format(n.rows))}a(ufe,"printResult");ft();var j6=require("path"),jR=require("fs"),$6=require("fs"),ji=be(Xe());bi();var PR=class extends Error{static{a(this,"ClassNotFoundError")}constructor(e,t){let r=`Class '${e}' not found in vault`;t&&t.length>0&&(r+=`
536
536
  Available classes: ${t.join(", ")}`),super(r),this.name="ClassNotFoundError"}},qb=class{constructor(e){this.fsAdapter=e;this.cache=new Map}static{a(this,"ClassResolverService")}async resolve(e,t){if(this.isUUID(t))return t;let r=await this.getOrBuildIndex(e),i=r.get(t);if(!i){let s=Array.from(r.keys()).filter(o=>!this.isUUID(o));throw new PR(t,s)}return i}async listClasses(e){let t=await this.getOrBuildIndex(e);return Array.from(t.keys())}async getOrBuildIndex(e){if(this.cache.has(e))return this.cache.get(e);let t=await this.buildIndex(e);return this.cache.set(e,t),t}async buildIndex(e){let t=new Map,r=await this.fsAdapter.getMarkdownFiles(),i=[],s=new Set;for(let o of r)try{let l=await this.fsAdapter.getFileMetadata(o),c=this.getBasename(o),u=l.exo__Asset_uid;!u&&this.isUUID(c)&&(u=c);let f=u?String(u):void 0,d=l.exo__Asset_label,p=typeof d=="string"?d:void 0,h=l.exo__Instance_class,_=h?(Array.isArray(h)?h:[h]).map(y=>String(y)):[];i.push({basename:c,uid:f,label:p,classValues:_}),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(r=>{if(r.includes("ims__Class")||r.includes("exo__Class"))return!0;for(let i of t)if(i&&r.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 DR=class extends Error{static{a(this,"WikilinkNotFoundError")}constructor(e,t){let r=t?`|${t}`:"";super(`Wikilink [[${e}${r}]] \u2014 file not found in vault`),this.name="WikilinkNotFoundError"}},ll=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 r=Array.isArray(t)?t:[t];for(let i of r)await this.validateValue(i)}}async validateValue(e){let t=this.extractWikilinks(e);for(let r of t)await this.validateWikilink(r.uuid,r.label)}extractWikilinks(e){let t=[],r=/\[\[([^\]|]+)(?:\|([^\]]*))?\]\]/g,i;for(;(i=r.exec(e))!==null;)t.push({uuid:i[1].trim(),label:i[2]?.trim()});return t}async validateWikilink(e,t){if(!this.looksLikeUUID(e)||await this.fsAdapter.findFileByUidFilename(e))return;if(!await this.fsAdapter.findFileByUID(e))throw new DR(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)}};Vx();var cl=class n{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:r}=await this.collect();if(t.size!==0)for(let i of e){let s=n.KEY_SHAPE.exec(i);if(!s||t.has(i))continue;let o=s[1],l=r.has(o)?o:void 0,c=n.suggest(i,t,l);throw new xh(i,c)}}async isUnknownName(e){let{names:t}=await this.collect();return t.size===0||!n.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"),r=[],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}n.scan(h,r,i)}}},"walk");await s(this.vaultPath);let o=n.buildPropertyMetaclassClosure(r),l=new Set,c=new Set;for(let u of i){if(!u.classRefs.some(d=>o.has(d)))continue;l.add(u.name);let f=n.KEY_SHAPE.exec(u.name);f&&c.add(f[1])}return this.cache={names:l,prefixes:c},this.cache}static scan(e,t,r){let i=n.parseFrontmatter(e);if(!i)return;let s=n.asArray(i.exo__Instance_class).flatMap(l=>n.refHalves(l));if(s.length===0)return;let o=n.cleanLabel(i.exo__Asset_label);if(s.some(l=>n.isClassMetaclass(l))){let l=i.exo__Asset_uid,c=typeof l=="string"?l.trim():null,u=n.asArray(i.exo__Class_superClass).flatMap(f=>n.refHalves(f));t.push({uid:c,label:o,superRefs:u});return}o===null||!n.KEY_SHAPE.test(o)||r.push({classRefs:s,name:o})}static buildPropertyMetaclassClosure(e){let t=new Set([...n.PROPERTY_METACLASS_UIDS,...n.PROPERTY_METACLASS_LABELS]),r=!0;for(;r;){r=!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),r=!0)}return t}static isClassMetaclass(e){return e===n.CLASS_METACLASS_UID||e===n.CLASS_METACLASS_LABEL}static refHalves(e){let t=String(e).replace(/^["']|["']$/g,"").trim(),r=/\[\[([^\]]+)\]\]/.exec(t);return(r?r[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 r={},i=t[1].split(/\r?\n/),s=null,o=null;for(let l of i){let c=/^ {2}- (.*)$/.exec(l);if(c){s&&o&&o.push(c[1].trim());continue}s&&o&&(r[s]=o,s=null,o=null);let u=/^([^:]+):\s*(.*)$/.exec(l);if(!u)continue;let f=u[1].trim(),d=u[2].trim();d===""?(s=f,o=[]):r[f]=d}return s&&o&&(r[s]=o),r}static suggest(e,t,r){let i=r?[...t].filter(o=>o.startsWith(`${r}__`)):[...t],s=Math.max(3,Math.floor(e.length*.4));return i.map(o=>({name:o,distance:n.levenshtein(e,o)})).filter(o=>o.distance<=s).sort((o,l)=>o.distance-l.distance||o.name.localeCompare(l.name)).slice(0,3).map(o=>o.name)}static levenshtein(e,t){let r=e.length,i=t.length;if(r===0)return i;if(i===0)return r;let s=Array.from({length:i+1},(l,c)=>c),o=new Array(i+1);for(let l=1;l<=r;l++){o[0]=l;for(let c=1;c<=i;c++){let u=e[l-1]===t[c-1]?0:1;o[c]=Math.min(s[c]+1,o[c-1]+1,s[c-1]+u)}[s,o]=[o,s]}return s[i]}};var C6="ems__Effort",ffe="ems__EffortStatus",Gb=class{constructor(e){this.fsAdapter=e;this.statusUidCache=new Map}static{a(this,"EffortStatusResolver")}async isStatusBearing(e){let t=new Set,r=[e];for(;r.length>0;){let i=r.shift();if(i===void 0)break;if(t.has(i))continue;if(t.add(i),i===C6)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===C6)return!0;let l=o.exo__Class_superClass,c=Array.isArray(l)?l:l!=null?[l]:[];for(let u of c){let f=pfe(String(u));f&&!t.has(f)&&r.push(f)}}return!1}async resolveStatusUid(e){let t=dfe(e),r=this.statusUidCache.get(t);if(r!==void 0)return r;let i=null,s=await this.fsAdapter.findFilesByMetadata({exo__Asset_label:t});for(let o of s)try{let l=await this.fsAdapter.getFileMetadata(o);if(l.exo__Asset_uid){i=String(l.exo__Asset_uid);break}}catch{continue}return this.statusUidCache.set(t,i),i}async resolveClassFile(e){if(hfe(e))return this.fsAdapter.findFileByUidFilename(e);let t=await this.fsAdapter.findFilesByMetadata({exo__Asset_label:e});return t.length>0?t[0]:null}};function dfe(n){let e=n.trim();if(e.startsWith("ems__"))return e;let t=e.charAt(0).toUpperCase()+e.slice(1);return`${ffe}${t}`}a(dfe,"toStatusEnumLabel");function pfe(n){return n.trim().replace(/^["']|["']$/g,"").replace(/^\[\[|\]\]$/g,"").split("|")[0].trim()||null}a(pfe,"extractRef");function hfe(n){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n)}a(hfe,"isUuid");xt();jt();var Uf=require("fs"),FR=require("path"),P6=be(Xe());function Wb(n){(0,P6.registerOrderSpecLoader)(()=>{let e=mfe(n);for(let t of e){let r=gfe(t);if(r)return r}return null})}a(Wb,"registerOrderSpecFromVault");function mfe(n){return[(0,FR.join)(n,"assetspaces","exo")]}a(mfe,"collectCandidateDirs");function gfe(n){if(!(0,Uf.existsSync)(n))return null;let e;try{e=(0,Uf.readdirSync)(n)}catch{return null}for(let t of e){if(!t.endsWith(".md"))continue;let r=(0,FR.join)(n,t),i;try{i=(0,Uf.readFileSync)(r,"utf-8")}catch{continue}let s=yfe(i);if(s&&/^exo__FrontmatterOrderSpec_default:\s*true\b/m.test(s))return{head:O6(s,"exo__FrontmatterOrderSpec_head"),tail:O6(s,"exo__FrontmatterOrderSpec_tail"),middleStrategy:_fe(s,"exo__FrontmatterOrderSpec_middleStrategy")??"alphabetical"}}return null}a(gfe,"scanDirForDefault");function yfe(n){let e=n.match(/^---\n([\s\S]*?)\n---/);return e?e[1]:null}a(yfe,"extractFrontmatter");function _fe(n,e){let t=new RegExp(`^${D6(e)}:\\s*(.+)$`,"m"),r=n.match(t);return r?r[1].trim():null}a(_fe,"extractScalar");function O6(n,e){let t=new RegExp(`^${D6(e)}:\\s*\\n((?: -.*\\n?)+)`,"m"),r=n.match(t);return r?r[1].split(`
537
537
  `).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>i.slice(2).trim()):[]}a(O6,"extractList");function D6(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(D6,"escapeRegex");var Bf=be(require("path")),NR=be(Xe());async function ul(n,e,t){let r=e.endsWith(".md")?e:`${e}.md`;if(e.includes("/")&&await n.fileExists(r))return r;let i=Bf.default.dirname(t),s=i!=="."?`${i}/${r}`:r;if(await n.fileExists(s))return s;let l=await n.findFileByUID(e);return l||(await n.getMarkdownFiles()).find(f=>{let d=Bf.default.basename(f,".md"),p=Bf.default.basename(r,".md");return d===p})||null}a(ul,"findReferencedFile");function kR(n){return n.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/$/,"")}a(kR,"normalizePath");async function Hb(n,e){let t=(0,NR.extractAssetReference)(e);if(!t||t.startsWith("!"))return null;let r=await ul(n,t,"");if(!r)return null;let i=Bf.default.dirname(r);return i==="."?"":i}a(Hb,"resolveCoLocationFolder");function LR(n){let e=n;for(;Array.isArray(e);){if(e.length===0)return null;e=e[0]}return(0,NR.extractAssetReference)(e)}a(LR,"wikilinkTarget");async function F6(n,e,t,r){let i=new Set;if(e&&i.add(e),t&&i.add(t),i.size===0)return null;let s=LR(r),o=await n.getMarkdownFiles(),l=new Map;for(let d of o){let p;try{p=await n.getFileMetadata(d)}catch{continue}if(LR(p.exo__Asset_isDefinedBy)!==s)continue;let h=p.exo__Instance_class;if(!(Array.isArray(h)?h:[h]).some(I=>{let O=LR(I);return O!==null&&i.has(O)}))continue;let b=Bf.default.dirname(d),S=b==="."?"":b;l.set(S,(l.get(S)??0)+1)}if(l.size===0)return null;let c=null,u=-1,f=Array.from(l.entries()).sort((d,p)=>d[0]<p[0]?-1:d[0]>p[0]?1:0);for(let[d,p]of f)p>u&&(c=d,u=p);return c}a(F6,"resolveNeighbourFolderByClass");var k6="01 Inbox",vfe="Asia/Almaty",Tfe="4ef3962d-b8a7-42b5-bd28-88ec846f1d13",M6="Backlog",Uh="ems__Effort_status",Afe={aliases:"--aliases <a,b>"};function Ife(n){if(!n||n.length===0)return{};let e={};for(let t of n){let r=t.indexOf("=");if(r===-1)throw new Error(`Invalid property format: "${t}". Expected "key=value" format.`);let i=t.substring(0,r).trim(),s=t.substring(r+1).trim();if(!i)throw new Error(`Invalid property format: "${t}". Key cannot be empty.`);let o=Afe[(0,ji.canonicalYamlKey)(i)];if(o!==void 0)throw new Error(`Refusing to set "${i}" via --property \u2014 create manages this field itself. Use: ${o}`);let l=e[i];l===void 0?e[i]=s:Array.isArray(l)?l.push(s):e[i]=[l,s]}return e}a(Ife,"parseProperties");async function xfe(n){if(n.bodyFile){if(!(0,jR.existsSync)(n.bodyFile))throw new Error(`Body file not found: ${n.bodyFile}`);return(0,$6.readFileSync)(n.bodyFile,"utf-8")}if(n.body==="-")return Rfe(3e4);if(n.body)return n.body}a(xfe,"resolveBody");function Rfe(n){return new Promise((e,t)=>{let r=[],i=setTimeout(()=>{process.stdin.removeAllListeners(),process.stdin.destroy(),t(new Error(`Stdin read timed out after ${n}ms. Ensure you pipe content to stdin or close the pipe.`))},n);process.stdin.on("data",s=>{r.push(s)}),process.stdin.on("end",()=>{clearTimeout(i),e(Buffer.concat(r).toString("utf-8"))}),process.stdin.on("error",s=>{clearTimeout(i),t(s)}),process.stdin.isTTY&&(clearTimeout(i),e("")),process.stdin.resume()})}a(Rfe,"readStdin");function U6(){return new Ie("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)",Cfe,[]).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 n=>{try{let e=(0,j6.resolve)(n.vault);if(!(0,jR.existsSync)(e))throw new Qe(e);if(Wb(e),!n.label||n.label.trim().length===0)throw new Error("Label cannot be empty");let t=n.label.trim(),r=Ife(n.property);await new cl(e).validate(Object.keys(r));let s=await xfe(n);s&&(s=s.replace(/\\n/g,`
@@ -565,8 +565,8 @@ ${y}
565
565
  `:`
566
566
  `,o=r.split(/\r?\n/),l=[];for(let _ of o){let y=Mfe.exec(_);y?l.push({key:y[1],lines:[_]}):l.length>0?l[l.length-1].lines.push(_):l.push({key:null,lines:[_]})}let c=new Map,u=new Map;l.forEach((_,y)=>{_.key!==null&&(c.set(_.key,(c.get(_.key)??0)+1),u.set(_.key,y))});let f=new Map,d=l.filter((_,y)=>_.key===null||(c.get(_.key)??0)<=1||y===u.get(_.key)?!0:(f.set(_.key,(f.get(_.key)??0)+1),!1));if(f.size===0)return{changed:!1,content:n,removed:[]};let p=d.map(_=>_.lines.join(s)).join(s);return{changed:!0,content:`${t}${p}${i}`+n.slice(e[0].length),removed:[...f.entries()].map(([_,y])=>({key:_,removedOccurrences:y}))}}a(jfe,"dedupeFrontmatterKeys");function W6(){return new Ie("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.").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("--yes","Accepted for symmetry with the apply/create subcommands (repair-frontmatter is non-interactive; no-op)").action(async(n,e)=>{try{let t=(0,fa.resolve)(e.vault);if(!(0,zf.existsSync)(t))throw new Qe(t);let r=(0,fa.resolve)(t,n),i=(0,fa.relative)(t,r);if(i===".."||i.startsWith(`..${fa.sep}`)||(0,fa.isAbsolute)(i))throw new Error(`Target is outside the vault: ${n} (vault: ${t})`);let s;try{s=(0,zf.readFileSync)(r,"utf-8")}catch(l){throw l.code==="ENOENT"?new Error(`Target file not found: ${n}`):l}let o=jfe(s);if(!o.changed){process.stdout.write(JSON.stringify({path:i,changed:!1,dryRun:!!e.dryRun,removed:[]})+`
567
567
  `);return}e.dryRun||(0,zf.writeFileSync)(r,o.content,"utf-8"),process.stdout.write(JSON.stringify({path:i,changed:!0,dryRun:!!e.dryRun,removed:o.removed})+`
568
- `)}catch(t){we.handle(t)}})}a(W6,"repairFrontmatterCommand");ft();var H6=require("fs"),z6=require("path"),$i=be(Xe());bi();xt();jt();ir();Nb();var $fe="https://exocortex.my/ontology/find#Alias_sparql",Ufe="https://exocortex.my/ontology/exo#Asset_label";function Kf(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}a(Kf,"nodeValue");async function Bfe(n,e){let t=await n.match(void 0,void 0,void 0),r=[];for(let s of t)Kf(s.predicate)!==Ufe||Kf(s.object)!==e||r.push(Kf(s.subject));if(r.length===0)return null;let i=[];for(let s of r)for(let o of t)Kf(o.predicate)===$fe&&Kf(o.subject)===s&&i.push(Kf(o.object));if(i.length===0)return null;if(i.length>1)throw new nt(`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(Bfe,"resolveAliasFragment");var Vfe=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,qfe="https://exocortex.my/ontology/";function Gfe(n,e){let t=Vfe.exec(e);if(t){let i=`<${qfe}${t[1]}#${t[2]}>`;return n.replace(/\?value\b/g,i)}let r=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return n.replace(/\?value\b/g,`"${r}"`)}a(Gfe,"bindValueLiteral");function K6(){return new Ie("find").description("Find vault assets via SPARQL \u2014 outputs file paths one per line (RFC 8e83442b T1.1)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--sparql <query>","SPARQL SELECT query (must bind ?path)").option("--class <value>","Filter by class label via find__Alias 'class' (e.g. ems__Task)").action(async n=>{we.setFormat("text");try{if(n.sparql&&n.class)throw new nt("--sparql and --class are mutually exclusive","Pass either a raw --sparql query or a find__Alias-backed flag like --class");if(!n.sparql&&!n.class)throw new nt("one of --sparql <query> or --class <value> is required",'exocortex find --class ems__Task OR exocortex find --sparql "SELECT ?path WHERE { ... }"');let e=(0,z6.resolve)(n.vault);if(!(0,H6.existsSync)(e))throw new Qe(e);let t=new Lt(e),i=await new $i.NoteToRDFConverter(t).convertVault(),s=new $i.InMemoryTripleStore;await s.addAll(i);let o;if(n.class){let b=await Bfe(s,"class");if(b===null)throw new nt('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 { ${Gfe(b,n.class)} }`}else o=n.sparql;let l=Fb(o);l=Mf(l);let c=new $i.ExoQLParser,u=Lb(Db(e));u.size>0&&c.setVaultPrefixes(u);let f=c.parse(l),p=new $i.ExoQLAlgebraTranslator().translate(f);p.type!=="construct"&&(p=new $i.AlgebraOptimizer().optimize(p));let _=await new $i.ExoQLQueryExecutor(s).executeAll(p),y="obsidian://vault/";for(let b of _){let I=b.toJSON().path;if(typeof I!="string"||!I.startsWith(y))continue;let O=I.slice(y.length),T;try{T=decodeURIComponent(O)}catch{T=O}process.stdout.write(T+`
569
- `)}}catch(e){we.handle(e),process.exit(5)}})}a(K6,"findCommand");ft();var qR=require("fs"),ha=require("path"),Ve=be(Xe());xt();jt();ir();bi();var tU=be(Xe()),Ut=be(J6());var Z6="obsidian://vault/";function dde(n){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return{async resolveTargetPath(t){if(!t)throw new Error("Cannot resolve empty targetIRI to a vault path");let r=t;if(r.startsWith(Z6))r=decodeURI(r.slice(Z6.length));else if(e.test(r)){let i=await n.findFileByUID(r);if(!i)throw new Error(`No vault file found for UID: ${r}`);r=i}if(r.endsWith(".md")||(r=`${r}.md`),!await n.fileExists(r))throw new Error(`Cannot resolve target file for IRI "${t}" (tried "${r}")`);return r}}}a(dde,"createCliPathResolver");var pde=["openFile","sparqlSelect","getActiveFileIRI","getActiveFilePath","trashFile","duplicateFile"],VR=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 eU(n){return{async execute(){throw new VR(n)}}}a(eU,"notImplementedService");function hde(n){return e=>{let t=n.getFirstLinkpathDest(e,"");if(!t||!("basename"in t))return null;let i=n.getFrontmatter(t)?.exo__Asset_label;return typeof i=="string"&&i.length>0?i:null}}a(hde,"createCliClassResolver");function rU(n,e){for(let t of pde)n.register(t,eU(t));for(let t of["updateProperty","removeProperty","setStatus","createAsset"])n.register(t,eU(t));if(e){if(e.fsAdapter){let t=new tU.FrontmatterService,r=dde(e.fsAdapter);n.register("updateProperty",(0,Ut.createUpdatePropertyService)(e.fsAdapter,t,r)),n.register("removeProperty",(0,Ut.createRemovePropertyService)(e.fsAdapter,t,r)),n.register("setStatus",(0,Ut.createSetStatusService)(e.fsAdapter,t,r)),n.register("createAsset",(0,Ut.createCreateAssetService)(e.vaultAdapter,e.fsAdapter,hde(e.vaultAdapter))),n.register("instantiatePrototypeSubtree",(0,Ut.createInstantiatePrototypeSubtreeService)(e.vaultAdapter,e.fsAdapter))}n.register("createRelatedTask",(0,Ut.createCreateRelatedTaskService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("createRelatedProject",(0,Ut.createCreateRelatedProjectService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("archiveAsset",(0,Ut.createArchiveAssetService)(e.vaultAdapter,e.archiveAssetService)),n.register("planForEvening",(0,Ut.createPlanForEveningService)(e.vaultAdapter,e.taskStatusService)),n.register("cleanProperties",(0,Ut.createCleanPropertiesService)(e.vaultAdapter,e.propertyCleanupService)),n.register("renameToUid",(0,Ut.createRenameToUidService)(e.vaultAdapter,e.renameToUidService)),n.register("repairFolder",(0,Ut.createRepairFolderService)(e.vaultAdapter,e.folderRepairService)),n.register("fixMissingLabel",(0,Ut.createFixMissingLabelService)(e.vaultAdapter,e.fixMissingLabelService))}}a(rU,"populateCliServiceRegistry");function mde(n,e){let t=n.getAbstractFileByPath(e),r=t!==null&&"basename"in t?t:null,i=r?n.getFrontmatter(r):null,s=i&&typeof i=="object"?i.exo__Asset_label:void 0;return{uuid:r?.basename??e.replace(/^.*\//,"").replace(/\.md$/,""),path:e,label:typeof s=="string"?s:""}}a(mde,"buildCreatedAsset");var gde=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function yde(){if(process.stdin.isTTY)return[];let n=[];for await(let t of process.stdin)n.push(t);return Buffer.concat(n).toString("utf-8").split(`
568
+ `)}catch(t){we.handle(t)}})}a(W6,"repairFrontmatterCommand");ft();var H6=require("fs"),z6=require("path"),$i=be(Xe());bi();xt();jt();sr();Nb();var $fe="https://exocortex.my/ontology/find#Alias_sparql",Ufe="https://exocortex.my/ontology/exo#Asset_label";function Kf(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}a(Kf,"nodeValue");async function Bfe(n,e){let t=await n.match(void 0,void 0,void 0),r=[];for(let s of t)Kf(s.predicate)!==Ufe||Kf(s.object)!==e||r.push(Kf(s.subject));if(r.length===0)return null;let i=[];for(let s of r)for(let o of t)Kf(o.predicate)===$fe&&Kf(o.subject)===s&&i.push(Kf(o.object));if(i.length===0)return null;if(i.length>1)throw new nt(`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(Bfe,"resolveAliasFragment");var Vfe=/^([a-z][a-zA-Z0-9]*)__([A-Za-z0-9_]+)$/,qfe="https://exocortex.my/ontology/";function Gfe(n,e){let t=Vfe.exec(e);if(t){let i=`<${qfe}${t[1]}#${t[2]}>`;return n.replace(/\?value\b/g,i)}let r=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return n.replace(/\?value\b/g,`"${r}"`)}a(Gfe,"bindValueLiteral");function K6(){return new Ie("find").description("Find vault assets via SPARQL \u2014 outputs file paths one per line (RFC 8e83442b T1.1)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--sparql <query>","SPARQL SELECT query (must bind ?path)").option("--class <value>","Filter by class label via find__Alias 'class' (e.g. ems__Task)").action(async n=>{we.setFormat("text");try{if(n.sparql&&n.class)throw new nt("--sparql and --class are mutually exclusive","Pass either a raw --sparql query or a find__Alias-backed flag like --class");if(!n.sparql&&!n.class)throw new nt("one of --sparql <query> or --class <value> is required",'exocortex find --class ems__Task OR exocortex find --sparql "SELECT ?path WHERE { ... }"');let e=(0,z6.resolve)(n.vault);if(!(0,H6.existsSync)(e))throw new Qe(e);let t=new Lt(e),i=await new $i.NoteToRDFConverter(t).convertVault(),s=new $i.InMemoryTripleStore;await s.addAll(i);let o;if(n.class){let b=await Bfe(s,"class");if(b===null)throw new nt('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 { ${Gfe(b,n.class)} }`}else o=n.sparql;let l=Fb(o);l=Mf(l);let c=new $i.ExoQLParser,u=Lb(Db(e));u.size>0&&c.setVaultPrefixes(u);let f=c.parse(l),p=new $i.ExoQLAlgebraTranslator().translate(f);p.type!=="construct"&&(p=new $i.AlgebraOptimizer().optimize(p));let _=await new $i.ExoQLQueryExecutor(s).executeAll(p),y="obsidian://vault/";for(let b of _){let I=b.toJSON().path;if(typeof I!="string"||!I.startsWith(y))continue;let O=I.slice(y.length),T;try{T=decodeURIComponent(O)}catch{T=O}process.stdout.write(T+`
569
+ `)}}catch(e){we.handle(e),process.exit(5)}})}a(K6,"findCommand");ft();var qR=require("fs"),ha=require("path"),Ve=be(Xe());xt();jt();sr();bi();var tU=be(Xe()),Ut=be(J6());var Z6="obsidian://vault/";function dde(n){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return{async resolveTargetPath(t){if(!t)throw new Error("Cannot resolve empty targetIRI to a vault path");let r=t;if(r.startsWith(Z6))r=decodeURI(r.slice(Z6.length));else if(e.test(r)){let i=await n.findFileByUID(r);if(!i)throw new Error(`No vault file found for UID: ${r}`);r=i}if(r.endsWith(".md")||(r=`${r}.md`),!await n.fileExists(r))throw new Error(`Cannot resolve target file for IRI "${t}" (tried "${r}")`);return r}}}a(dde,"createCliPathResolver");var pde=["openFile","sparqlSelect","getActiveFileIRI","getActiveFilePath","trashFile","duplicateFile"],VR=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 eU(n){return{async execute(){throw new VR(n)}}}a(eU,"notImplementedService");function hde(n){return e=>{let t=n.getFirstLinkpathDest(e,"");if(!t||!("basename"in t))return null;let i=n.getFrontmatter(t)?.exo__Asset_label;return typeof i=="string"&&i.length>0?i:null}}a(hde,"createCliClassResolver");function rU(n,e){for(let t of pde)n.register(t,eU(t));for(let t of["updateProperty","removeProperty","setStatus","createAsset"])n.register(t,eU(t));if(e){if(e.fsAdapter){let t=new tU.FrontmatterService,r=dde(e.fsAdapter);n.register("updateProperty",(0,Ut.createUpdatePropertyService)(e.fsAdapter,t,r)),n.register("removeProperty",(0,Ut.createRemovePropertyService)(e.fsAdapter,t,r)),n.register("setStatus",(0,Ut.createSetStatusService)(e.fsAdapter,t,r)),n.register("createAsset",(0,Ut.createCreateAssetService)(e.vaultAdapter,e.fsAdapter,hde(e.vaultAdapter))),n.register("instantiatePrototypeSubtree",(0,Ut.createInstantiatePrototypeSubtreeService)(e.vaultAdapter,e.fsAdapter))}n.register("createRelatedTask",(0,Ut.createCreateRelatedTaskService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("createRelatedProject",(0,Ut.createCreateRelatedProjectService)(e.vaultAdapter,e.genericAssetCreationService)),n.register("archiveAsset",(0,Ut.createArchiveAssetService)(e.vaultAdapter,e.archiveAssetService)),n.register("planForEvening",(0,Ut.createPlanForEveningService)(e.vaultAdapter,e.taskStatusService)),n.register("cleanProperties",(0,Ut.createCleanPropertiesService)(e.vaultAdapter,e.propertyCleanupService)),n.register("renameToUid",(0,Ut.createRenameToUidService)(e.vaultAdapter,e.renameToUidService)),n.register("repairFolder",(0,Ut.createRepairFolderService)(e.vaultAdapter,e.folderRepairService)),n.register("fixMissingLabel",(0,Ut.createFixMissingLabelService)(e.vaultAdapter,e.fixMissingLabelService))}}a(rU,"populateCliServiceRegistry");function mde(n,e){let t=n.getAbstractFileByPath(e),r=t!==null&&"basename"in t?t:null,i=r?n.getFrontmatter(r):null,s=i&&typeof i=="object"?i.exo__Asset_label:void 0;return{uuid:r?.basename??e.replace(/^.*\//,"").replace(/\.md$/,""),path:e,label:typeof s=="string"?s:""}}a(mde,"buildCreatedAsset");var gde=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function yde(){if(process.stdin.isTTY)return[];let n=[];for await(let t of process.stdin)n.push(t);return Buffer.concat(n).toString("utf-8").split(`
570
570
  `).map(t=>t.trim()).filter(t=>t.length>0)}a(yde,"readStdinLines");function Jb(n){if(n&&typeof n=="object"&&"value"in n){let e=n.value;return typeof e=="string"?e:String(e)}return String(n)}a(Jb,"nodeValue");async function _de(n,e){let t=new Ve.IRI("https://exocortex.my/ontology/exocmd#Command_cliName"),r=await n.match(void 0,t,void 0),i=[];for(let s of r)if(Jb(s.object)===e){let c=Jb(s.subject).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i);c&&i.push(c[1])}if(i.length===0)return null;if(i.length>1)throw new nt(`Ambiguous cliName "${e}" \u2014 resolves to ${i.length} commands: ${i.join(", ")}`,"Use the UUID directly: exocortex apply <uuid> <path>");return i[0]}a(_de,"resolveSlugToUuid");async function bde(n,e){let t=new Ve.IRI("https://exocortex.my/ontology/exocmd#Command_destructive"),r=await n.match(void 0,t,void 0);for(let i of r)if(Jb(i.subject).includes(e)){let o=Jb(i.object);if(o==="true"||o==="True")return!0}return!1}a(bde,"isDestructive");async function Sde(n,e,t,r,i,s,o,l){let c={ok:!1,created:[]},u=(0,ha.resolve)(n,i);if(!(0,qR.existsSync)(u))return console.error(`\u274C Target file not found: ${i}`),c;let f=(0,ha.relative)(n,u);if(f===".."||f.startsWith(`..${ha.sep}`)||(0,ha.isAbsolute)(f))return console.error(`\u274C Target is outside the vault: ${i} (vault: ${n})`),c;let d=new Ve.CommandResolver(e),p=await d.loadCommand(r);if(!p)return console.error(`\u274C Command with UID "${r}" not found.`),c;if(await bde(e,r)&&!s.dryRun&&!s.yes)return console.error(`\u274C Command "${p.name}" is marked destructive. Add --dry-run to preview, or --yes to apply.`),c;let _=(0,Ve.vaultPathToIRI)(f),y=new Lt(n),b=new Ve.FolderRepairService(y),S=new Ve.PreconditionEvaluator(e,void 0,{clock:o});(0,Ve.registerDefaultHostFunctions)(S),S.registerHostFunction("isInWrongFolder",Mb(y,b)),S.registerHostFunction("hasObsoleteProperties",jb(y));let I=y.getAbstractFileByPath(f),O=I!==null&&"basename"in I?I:null,T=O?y.getFrontmatter(O):null,E=T&&typeof T=="object"?T.exo__Asset_uid:void 0,P={targetIRI:_,filePath:f,fileBasename:O?.basename,assetUid:typeof E=="string"?E:void 0};if(!await S.evaluate(p.precondition,_,P))return console.error(`\u274C Precondition not satisfied for "${p.name}" on "${f}".`),c;if(s.dryRun)return s.json||console.log(`\u{1F50D} Dry-run: would apply "${p.name}" to "${f}" (precondition passed).`),{ok:!0,created:[]};let M=new Ve.ServiceRegistry,j=new Ve.GenericAssetCreationService(y).withDeterminism({clock:o,uidGenerator:l}),$=new Ve.ArchiveAssetService(y),G=new Ve.PropertyCleanupService(y),ge=new Ve.FixMissingLabelService(y),ye=new Ve.RenameToUidService(y),Q=new Ve.TaskStatusService(y,new Ve.EffortStatusWorkflow,new Ve.StatusTimestampService(y)),se=new Wn(n);rU(M,{vaultAdapter:y,fsAdapter:se,genericAssetCreationService:j,archiveAssetService:$,taskStatusService:Q,propertyCleanupService:G,fixMissingLabelService:ge,renameToUidService:ye,folderRepairService:b});let J=new Ve.NamedQueryRunner(new $f(e,se),e),ve=new Ve.GroundingExecutor(se,se,M,(0,Ve.createVaultFrontmatterClassLabelResolver)(se),{clock:o,uidGenerator:l,workflowResolver:t,groundingLoader:a(he=>d.loadGroundingByUid(he),"groundingLoader"),templateLoader:a(async he=>{let Ue=await se.findFileByUID(he);return Ue?(0,Ve.stripTemplateFrontmatter)(await se.readFile(Ue)):null},"templateLoader"),namedQueryRunner:J,refToFolder:(0,Ve.createVaultFrontmatterRefToFolderResolver)(se),refToFrontmatter:(0,Ve.createVaultFrontmatterRefToFrontmatterResolver)(se)}),re;if(s.input)try{let he=JSON.parse(s.input);if(typeof he!="object"||he===null||Array.isArray(he))throw new Error("must be a JSON object");re=he}catch(he){let Ue=he instanceof Error?he.message:String(he);return console.error(`\u274C --input: invalid JSON object (${Ue})`),c}let ie=await ve.execute(p.grounding,_,f,re);if(ie.success){let he=[];ie.openPath&&he.push(ie.openPath),ie.createdPaths&&he.push(...ie.createdPaths);let Ue=[],ce=new Set;for(let ue of he)ce.has(ue)||(ce.add(ue),Ue.push(mde(y,ue)));if(!s.json){let ue=p.successMessage??`Applied "${p.name}" to "${f}".`,fe=ie.openPath??ie.createdPaths?.[0],ne=fe?` \u2192 ${fe}`:"";console.log(`\u2705 ${ue}${ne}`)}return{ok:!0,created:Ue}}else return console.error(`\u274C "${p.name}" failed on "${f}": ${ie.error}`),c}a(Sde,"executeOnTarget");function nU(){return new Ie("apply").description("Apply an exocmd__Command to one or more vault assets (RFC 8e83442b T1.2). Pass a path arg or pipe paths via stdin.").argument("<cmd>","Command UUID or cliName slug").argument("[path]","Vault-relative path to target asset (omit to read paths from stdin)").option("--vault <path>","Path to Obsidian vault",process.cwd()).option("--dry-run","Preview without writing").option("--yes","Skip destructive-command confirmation").option("--input <json>",`JSON userInput for 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"}'. 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(n,e,t)=>{we.setFormat("text");try{let r=(0,ha.resolve)(t.vault);if(!(0,qR.existsSync)(r))throw new Qe(r);Wb(r);let i=t.frozenClock?(0,Ve.frozenClock)(t.frozenClock):(0,Ve.liveClock)(),s=t.seed?(0,Ve.seededUidGenerator)(t.seed):(0,Ve.liveUidGenerator)(),o=new Lt(r),c=await new Ve.NoteToRDFConverter(o).convertVault(),u=new Ve.InMemoryTripleStore;await u.addAll(c);let f=new Ve.WorkflowResolver(u),d;if(gde.test(n))d=n;else{let b=await _de(u,n);b||(console.error(`\u274C No command found with UUID or cliName "${n}".`),process.exit(3)),d=b}let p;if(e)p=[e];else if(p=await yde(),p.length===0)throw new nt("No target path provided and stdin is empty.","exocortex apply <uuid> <path> OR exocortex find ... | exocortex apply <uuid>");let h=0,_=0,y=[];for(let b of p){let S=await Sde(r,u,f,d,b,t,i,s);S.ok?h++:_++,y.push(...S.created)}if(p.length>1&&!t.json&&console.log(`
571
571
  \u{1F4CA} Applied to ${h}/${p.length} target(s) (${_} failed).`),t.json){let b={command:n,created:y};e?b.target=e:b.targets=p,process.stdout.write(JSON.stringify(b)+`
572
572
  `)}_>0&&process.exit(5)}catch(r){we.handle(r),process.exit(5)}})}a(nU,"applyCommand");ft();ft();var Zb=require("fs"),WR=be(require("path")),iU=require("path"),sU=be(Xe());xt();jt();var wde=new Set(["templates","09 templates"]);function Ui(n){return n.split("/").some(e=>wde.has(e.toLowerCase()))}a(Ui,"isTemplatesPath");function ao(n){return n.split("/").includes("node_modules")}a(ao,"isNodeModulesPath");var Ede=5;function GR(n,e,t){n[e].length<Ede&&n[e].push(t)}a(GR,"addExample");async function vde(n){let e=new ci(n),t=await e.indexedAssets(),r=[],i={"empty-isDefinedBy":0,"bang-prefix":0,unresolvable:0},s={"empty-isDefinedBy":[],"bang-prefix":[],unresolvable:[]},o=0;for(let{path:l,metadata:c}of t){if(l.split("/").includes("node_modules")||Ui(l))continue;let u=c.exo__Asset_isDefinedBy,f=(0,sU.extractAssetReference)(u);if(!f){i["empty-isDefinedBy"]++,GR(s,"empty-isDefinedBy",l);continue}if(f.startsWith("!")){i["bang-prefix"]++,GR(s,"bang-prefix",l);continue}let d=await ul(e,f,l);if(!d){i.unresolvable++,GR(s,"unresolvable",l);continue}o++;let p=kR(WR.default.dirname(d)),h=kR(WR.default.dirname(l));p!==h&&r.push({path:l,isDefinedBy:f,expectedFolder:p,actualFolder:h})}return{vaultPath:n,totalFiles:t.length,checked:o,violations:r,skips:i,skipExamples:s}}a(vde,"scanVaultForCoLocation");function oU(){return new Ie("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 n=>{let e=n.output??"text";we.setFormat(e);try{let t=(0,iU.resolve)(n.vault);if(!(0,Zb.existsSync)(t)||!(0,Zb.statSync)(t).isDirectory())throw new Qe(t);let r=await vde(t),i=r.skips["empty-isDefinedBy"]+r.skips["bang-prefix"]+r.skips.unresolvable;if(e==="json")console.log(JSON.stringify({vaultPath:r.vaultPath,totalFiles:r.totalFiles,checked:r.checked,violationCount:r.violations.length,violations:r.violations,skips:r.skips,skipTotal:i,skipExamples:r.skipExamples,clean:r.violations.length===0},null,2));else{if(r.violations.length===0)console.log(`OK ${t}: 0 co-location violations (${r.checked}/${r.totalFiles} checked)`);else{console.error(`FAIL ${t}: ${r.violations.length} co-location violation(s) (${r.checked}/${r.totalFiles} checked):`);for(let s of r.violations)console.error(` ${s.path}
@@ -604,7 +604,7 @@ Homoiconic validation-check setting (RFC f402002b, M1.5). \`Exocortex: Validate
604
604
  `}a(Jde,"settingAsset");function IU(){return new Ie("scaffold").description("Scaffold homoiconic configuration assets").addCommand(Zde())}a(IU,"scaffoldCommand");function Zde(){return new Ie("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 n=>{let e=n.output??"text";we.setFormat(e);try{let t=(0,Tc.resolve)(n.vault);if(!(0,sS.existsSync)(t)||!(0,sS.statSync)(t).isDirectory())throw new Qe(t);let s=(await new ci(t).indexedAssets()).find(u=>(0,lo.readUid)(u.metadata)===n.ontology);if(!s)throw new Error(`Ontology UID "${n.ontology}" not found in vault ${t} (its folder is where the check settings co-locate).`);let o=(0,Tc.join)(t,(0,Tc.dirname)(s.path)),l=new Date().toISOString().slice(0,19),c=[];for(let u of Xde){let f=(0,AU.randomUUID)(),d=(0,Tc.join)(o,`${f}.md`);await(0,TU.writeFile)(d,Jde(f,n.ontology,u.checkId,u.label,u.value,l),"utf-8"),c.push(d)}if(e==="json")console.log(JSON.stringify({vaultPath:t,ontology:n.ontology,targetDir:o,created:c},null,2));else{console.log(`OK: scaffolded ${c.length} validation-check setting(s) in ${o}`);for(let u of c)console.log(` ${u}`);console.log(`
605
605
  Defaults: uid-uniqueness=true, co-location/shacl/dag=false. Run 'exocortex validate vault --vault <path>'.`)}}catch(t){we.handle(t)}})}a(Zde,"scaffoldValidationCommand");ft();var $U=require("fs"),UU=require("path");var oS=be(na()),aS=be(require("path")),pl=be(Xe()),cS=be(Xe());var epe=pl.SDK_FLOOR_ASSETSPACE_UIDS,Gh="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb",XR="3de846cd-1f0e-4f98-8613-b8587aa15174",tpe=5,lS=class{static{a(this,"CliProfileResolver")}constructor(e){this.vaultPaths=[aS.default.resolve(e.vaultPath)],this.maxExtendsDepth=e.maxExtendsDepth??tpe,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,pl.transitiveDependsOnClosure)(i,t.dependsOn),o=new Set(t.folderMap.values()),l=new Set,c=[];for(let f of s){if(o.has(f)){l.add(f);continue}c.push(f)}for(let f of epe)l.add(f);if(!Array.from(l).some(f=>o.has(f))){let f=`[CliProfileResolver] profileUid=${e} produced effective set with zero AssetSpace folder overlap (${l.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:l,folderMap:t.folderMap,declaredOntologies:s,untranslated:c}}}walkProfileChain(e,t,r,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 l of o.includes)r.add(l);typeof o.extends=="string"&&o.extends.length>0&&this.walkProfileChain(o.extends,t,r,i,s+1)}}async scanAllVaults(){let e=new Map,t=new Map,r=new Map;for(let i of this.vaultPaths){if(!await oS.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 l=ma(o.frontmatter.exo__Instance_class);if(l.some(c=>c===Gh)){let c=npe(o.filePath,o.vaultRoot);c.length>0&&!e.has(c)&&e.set(c,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,pl.derivePath)(u);d!==null&&e.set(d,o.uid)}let f=ma(o.frontmatter.exo__AssetSpace_dependsOn);f.length>0&&r.set(o.uid,f)}if(l.some(c=>c===XR)){let c={uid:o.uid,label:typeof o.frontmatter.exo__Asset_label=="string"?o.frontmatter.exo__Asset_label:void 0,includes:ma(o.frontmatter.exo__Profile_includes),extends:ma(o.frontmatter.exo__Profile_imports)[0]??null};t.set(o.uid,c)}}}return{folderMap:e,profiles:t,dependsOn:r}}async walkVault(e){let t=[],r=[e];for(;r.length>0;){let i=r.pop(),s;try{s=await oS.default.readdir(i,{withFileTypes:!0})}catch{continue}for(let o of s){let l=aS.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules"||o.name===".obsidian"||o.name===".exocortex")continue;r.push(l);continue}if(!o.isFile()||!o.name.endsWith(".md"))continue;let c=await this.tryReadFrontmatter(l);if(c===null)continue;let u=c.exo__Asset_uid;typeof u!="string"||u.length===0||t.push({uid:u,filePath:l,vaultRoot:e,frontmatter:c})}}return t}async tryReadFrontmatter(e){let t;try{t=await oS.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let r=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(r===null)return null;try{let i=(0,pl.parseYamlFrontmatterTolerant)(r[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function ma(n){if(n==null)return[];let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(typeof r!="string")continue;let i=rpe(r);i!==null&&t.push(i)}return t}a(ma,"parseWikilinkArray");function rpe(n){let e=n.trim().replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0].trim();return e.length===0?null:e}a(rpe,"extractUidFromWikilink");function npe(n,e){let t=aS.default.relative(e,n).replace(/\\/g,"/");if(!t.startsWith("assetspaces/"))return"";let r=t.slice(12),i=r.indexOf("/");return i<0?"":`assetspaces/${r.slice(0,i)}`}a(npe,"parentFolderRelative");var hl=require("node:fs"),Ac=require("node:path"),xr=be(Xe());var ht=require("node:fs"),RU=require("node:fs/promises"),CU=require("node:os"),Xr=require("node:path"),Bi=be(Xe());var ipe=/^https:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+?)(?:\.git)?$/,xU=50*1024*1024,ui=class n{static{a(this,"BootstrapAssetSpaceService")}static{this.PAT_REGEX=/(?:gh[pousr]_[A-Za-z0-9_]{36,}|github_pat_[A-Za-z0-9_]{22,}_[A-Za-z0-9_]{59,})/g}constructor(e={}){this.fetchImpl=e.fetchImpl??globalThis.fetch,this.token=e.token??"",this.mountBaseStore=e.mountBaseStore}redact(e){return(typeof e=="string"?e:String(e)).replace(n.PAT_REGEX,"***REDACTED***")}static parseGitHubURL(e){let t=e.match(ipe);if(t===null)throw new Error(`parseGitHubURL: invalid URL shape \u2014 expected https://github.com/<owner>/<repo>, got: ${e}`);return{owner:t[1],repo:t[2]}}static deriveFolderName(e){let{repo:t}=n.parseGitHubURL(e);return t.startsWith("exoas-")?t.slice(6):t}async pullAssetSpace(e,t,r){let{owner:i,repo:s}=n.parseGitHubURL(e);if((0,ht.existsSync)(r)&&(0,ht.readdirSync)(r).length>0)throw new Error(`pullAssetSpace: target ${r} exists \u0438 not empty \u2014 refusing \u043A overwrite`);let o=await(0,Bi.mountAssetSpaceFiles)({http:this.httpPort(),fs:this.fsPort(),owner:i,repo:s,ref:t,targetPath:r});if(this.mountBaseStore!==void 0)try{await this.mountBaseStore.set(`${i}/${s}#${Bi.SYNC_BRANCH}`,o.sha)}catch{}return o}httpPort(){let e=this.fetchImpl,t=this.token,r=a(i=>this.redact(i),"redact");return{async fetchTarball(i,s,o){let l=`https://api.github.com/repos/${i}/${s}/tarball/${o}`,c={signal:AbortSignal.timeout(6e4)};t.length>0&&(c.headers={Authorization:`Bearer ${t}`,"User-Agent":"exocortex-cli","X-GitHub-Api-Version":"2022-11-28"});let u;try{u=await e(l,c)}catch(d){throw new Error(r(`pullAssetSpace: fetch error for ${l}: ${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(r(`pullAssetSpace: fetch failed (404 Not Found) for ${l} \u2014 ${d}`))}throw new Error(r(`pullAssetSpace: fetch failed (${u.status} ${u.statusText}) for ${l}`))}let f=await u.arrayBuffer();if(f.byteLength>xU)throw new Error(`pullAssetSpace: tarball too large (${f.byteLength} bytes > ${xU})`);return new Uint8Array(f)}}}fsPort(){return{async exists(e){return(0,ht.existsSync)(e)},async read(e){return(0,ht.readFileSync)(e,"utf8")},async write(e,t){(0,ht.writeFileSync)(e,t,{encoding:"utf8"})},async removeDir(e){(0,ht.rmSync)(e,{recursive:!0,force:!0})},async materialize(e,t,r){let i=await(0,RU.mkdtemp)((0,Xr.join)((0,CU.tmpdir)(),`exo-bootstrap-${(0,Xr.basename)(e)}-`)),s=0;try{for(let o of t){let l=o.relPath;if(l.split("/").some(u=>u===".."))throw new Error(`pullAssetSpace: path traversal detected for entry "${l}"`);let c=(0,Xr.resolve)(i,l);if(c!==i&&!c.startsWith(i+Xr.sep))throw new Error(`pullAssetSpace: zip-slip detected for entry "${l}"`);(0,ht.mkdirSync)((0,Xr.dirname)(c),{recursive:!0}),(0,ht.writeFileSync)(c,o.content),s++,r?.(s)}(0,ht.mkdirSync)((0,Xr.dirname)(e),{recursive:!0});try{(0,ht.renameSync)(i,e)}catch(o){if(o.code==="EXDEV"){let{cpSync:l}=await import("node:fs");l(i,e,{recursive:!0}),(0,ht.rmSync)(i,{recursive:!0,force:!0})}else throw o}}catch(o){throw(0,ht.rmSync)(i,{recursive:!0,force:!0}),o}return s}}}ensureGitmodulesEntry(e,t,r){let i=(0,Xr.join)(e,".gitmodules"),s="";try{s=(0,ht.readFileSync)(i,"utf8")}catch(c){if(c.code!=="ENOENT")throw c}let{content:o,added:l}=(0,Bi.appendGitmodulesEntry)(s,t,r);return l?((0,ht.appendFileSync)(i,o.slice(s.length),{encoding:"utf8"}),{added:!0}):{added:!1}}removeGitmodulesEntry(e,t){let r=(0,Xr.join)(e,".gitmodules"),i;try{i=(0,ht.readFileSync)(r,"utf8")}catch(o){if(o.code==="ENOENT")return{removed:!1};throw o}let s=(0,Bi.stripGitmodulesEntry)(i,t);return s===i?{removed:!1}:((0,ht.writeFileSync)(r,s,{encoding:"utf8"}),{removed:!0})}static stripGitmodulesEntry(e,t){return(0,Bi.stripGitmodulesEntry)(e,t)}unmountAssetSpace(e,t){let r=this.assertSafeVaultTarget(e,t,"unmountAssetSpace");this.removeGitmodulesEntry(e,t),(0,ht.existsSync)(r)&&(0,ht.rmSync)(r,{recursive:!0,force:!0})}parkAssetSpace(e,t){let r=this.assertSafeVaultTarget(e,t,"parkAssetSpace"),i=(0,Bi.parkedPathFor)(t),s=this.assertSafeVaultTarget(e,i,"parkAssetSpace",{requireAssetspacesRoot:!1});if((0,ht.existsSync)(r)){if((0,ht.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,ht.mkdirSync)((0,Xr.dirname)(s),{recursive:!0}),(0,ht.renameSync)(r,s)}}unparkAssetSpace(e,t){let r=this.assertSafeVaultTarget(e,t,"unparkAssetSpace"),i=(0,Bi.parkedPathFor)(t),s=this.assertSafeVaultTarget(e,i,"unparkAssetSpace",{requireAssetspacesRoot:!1});if(!(0,ht.existsSync)(s))throw new Error(`unparkAssetSpace: nothing parked at "${i}" for "${t}"`);if((0,ht.existsSync)(r))throw new Error(`unparkAssetSpace: refusing to unpark onto existing mount "${t}"`);(0,ht.mkdirSync)((0,Xr.dirname)(r),{recursive:!0}),(0,ht.renameSync)(s,r)}assertSafeVaultTarget(e,t,r,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(`${r}: refusing unsafe submodulePath "${t}"`);let l=(0,Xr.resolve)(e),c=(0,Xr.resolve)(l,t);if(c===l||!c.startsWith(l+Xr.sep))throw new Error(`${r}: target "${c}" escapes vault root "${l}"`);return c}};function spe(n){let e=(0,xr.derivePath)(n);return e===null?n:(0,xr.deriveUrl)(e)??n}a(spe,"toHttpsGitHubUrl");var ope=new Set(["node_modules",".obsidian",".exocortex",".git"]),Yf=class{static{a(this,"CliApplyProfileService")}constructor(e){this.vaultPath=e.vaultPath,this.mount=e.mount??new ui,this.ref=e.ref??"main"}scanVault(){let e=[],t=new Map,r=new Set,i=[this.vaultPath];for(;i.length>0;){let s=i.pop(),o;try{o=(0,hl.readdirSync)(s,{withFileTypes:!0})}catch{continue}for(let l of o){let c=(0,Ac.join)(s,l.name);if(l.isDirectory()){if(l.name.startsWith(".")||ope.has(l.name))continue;i.push(c);continue}if(!l.isFile()||!l.name.endsWith(".md"))continue;let u=this.readFrontmatter(c);if(u===null)continue;let f=u.exo__Asset_uid;if(typeof f!="string"||f.length===0)continue;let d=ma(u.exo__Instance_class);if(d.includes(Gh)){if(r.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 _=(0,xr.derivePath)(h);if(_===null)continue;let y=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:"",b=y||lpe(_)||f.slice(0,8),S=u.exo__AssetSpace_dependsOnKind,I=typeof S=="string"?S:Array.isArray(S)&&typeof S[0]=="string"?S[0]:void 0;r.add(f),e.push({uid:f,git:h,folderName:_,label:b,namespace:y,dependsOnKind:I})}if(d.includes(XR)){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,xr.assertTsFloorReconciled)(e,t,xr.SDK_FLOOR)}buildDiff(e){let{targetProfileUid:t,targetProfileLabel:r,sourceProfileUid:i,sourceProfileLabel:s,result:o,infos:l}=e,c=new Map;for(let E of l)c.set(E.uid,E);let u=new Set(c.keys()),f=new Set,d=new Set;for(let E of o.declaredOntologies)if(u.has(E)){f.add(E);let P=c.get(E)?.namespace;P!==void 0&&P.length>0&&d.add(P)}this.assertTsFloor(f,d);let p=new Set([...o.effective,...f]),h=new Map;for(let E of l){let P=(0,hl.existsSync)((0,Ac.join)(this.vaultPath,E.folderName))?"active":(0,hl.existsSync)((0,Ac.join)(this.vaultPath,(0,xr.parkedPathFor)(E.folderName)))?"parked":"absent";h.set(E.uid,P)}let _=new Set([...h].filter(([,E])=>E==="active").map(([E])=>E));for(let E of l)xr.CATALOG_KEEP_NAMESPACES.has(E.namespace)&&_.has(E.uid)&&p.add(E.uid);let y=[],b=[],S=[];for(let E of l){let P=(0,xr.classifyMountTransition)({state:h.get(E.uid)??"absent",inEffectiveSet:p.has(E.uid),dependsOnKind:E.dependsOnKind});switch(P){case"none":break;case"destroy":y.push({asUid:E.uid,folderName:E.folderName,label:E.label,files:this.enumerateFilesUnder(E.folderName)});break;case"park":b.push({asUid:E.uid,folderName:E.folderName,label:E.label,files:this.enumerateFilesUnder(E.folderName)});break;case"unpark":case"materialize":S.push({asUid:E.uid,folderName:E.folderName,httpsUrl:spe(E.git),label:E.label,source:P==="unpark"?"unpark":"pull"});break}}let I=new Map;for(let E of y)I.set(E.asUid,E.files);let O=new Set(S.filter(E=>E.source==="unpark").map(E=>E.asUid)),T={targetProfileUid:t,targetProfileLabel:r,sourceProfileUid:i,sourceProfileLabel:s,filesToDestroy:I,assetSpacesBeingTornDown:y.map(E=>({asUid:E.asUid,asLabel:E.label,fileCount:E.files.length})),assetSpacesBeingParked:b.map(E=>({asUid:E.asUid,asLabel:E.label,fileCount:E.files.length})),assetSpacesBeingMaterialized:S.map(E=>({asUid:E.asUid,asLabel:E.label})),assetSpacesBeingUnparked:S.filter(E=>O.has(E.asUid)).map(E=>({asUid:E.asUid,asLabel:E.label}))};return{toDestroy:y,toPark:b,toMaterialize:S,plan:T}}async execute(e){let t=[],r=[],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),r.push(s.asUid);for(let s of e.toMaterialize){if(s.source==="unpark")this.mount.unparkAssetSpace(this.vaultPath,s.folderName);else{let o=(0,Ac.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:r,materialized:i}}enumerateFilesUnder(e){let t=[],i=[(0,Ac.join)(this.vaultPath,e)];for(;i.length>0;){let s=i.pop(),o;try{o=(0,hl.readdirSync)(s,{withFileTypes:!0})}catch{continue}for(let l of o){let c=(0,Ac.join)(s,l.name);if(l.isDirectory()){if(l.name.startsWith("."))continue;i.push(c);continue}l.isFile()&&t.push(ape(c,this.vaultPath))}}return t}readFrontmatter(e){let t;try{t=(0,hl.readFileSync)(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let r=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(r===null)return null;try{let i=(0,xr.parseYamlFrontmatterTolerant)(r[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function ape(n,e){let t=e.endsWith("/")?e:e+"/";return(n.startsWith(t)?n.slice(t.length):n).split("\\").join("/")}a(ape,"relativeVaultPath");function lpe(n){let e=n.split("/").filter(t=>t.length>0);return e.length>0?e[e.length-1]:""}a(lpe,"lastSegment");ft();var Mr=require("node:fs"),NU=require("node:crypto"),kU=require("node:child_process"),MU=require("node:util"),jr=be(require("node:path"));ah();var lt=be(Xe());ft();var uo=require("node:fs"),PU=require("node:crypto"),Ei=be(require("node:path"));ah();var Rn=be(Xe());bi();var OU=require("node:child_process"),uS=be(Xe());var cpe=6e4,co=class n{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,OU.execFileSync)("gh",["auth","token"],{encoding:"utf8",timeout:15e3})),r;try{r=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(n.PAT_REGEX,"***REDACTED***"))}let i=r.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(n.PAT_REGEX,"***REDACTED***")}async push(e,t,r,i,s){return(0,uS.restCreateCommit)(this.buildTransport(),{owner:e,repo:t,branch:r,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,r=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(cpe)})}catch(u){throw new Error(r(`GitHub request failed: ${upe(u)}`))}let l=await o.text().catch(()=>"");if(o.status<200||o.status>=300){let u=a(f=>o.headers?.get?.(f)??void 0,"get");throw(0,uS.enrichRateLimitError)(new Error(fpe(r(`GitHub request ${i.method} ${i.url} \u2192 HTTP ${o.status}: ${l}`),512)),u)}let c;try{c=l.length>0?JSON.parse(l):void 0}catch{c=void 0}return{status:o.status,json:c,text:l}}}};function upe(n){if(n instanceof Error)return n.message;if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}a(upe,"errMsg");function fpe(n,e){return n.length>e?n.slice(0,e)+"...":n}a(fpe,"truncate");xt();var dpe=a(async n=>{let e=await PU.webcrypto.subtle.digest("SHA-1",n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),ppe={parse:a(n=>Sf(n,{schema:bf}),"parse"),stringify:a(n=>wf(n,{schema:bf,lineWidth:-1}),"stringify")};function hpe(n,e){if(n.tokenFromGh===!0)return co.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,r=n.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(r.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 r}a(hpe,"resolveToken");function mpe(n){let e=a(r=>Ei.join(n,r),"abs"),t=a(async(r,i)=>{let s;try{s=await uo.promises.readdir(r,{withFileTypes:!0})}catch{return}for(let o of s){let l=Ei.join(r,o.name);if(o.isDirectory()){if(o.name===".git")continue;await t(l,i)}else o.isFile()&&i.push(Ei.relative(n,l).split(Ei.sep).join("/"))}},"walk");return{async list(){let r=[];return(0,uo.existsSync)(n)&&await t(n,r),r},read:a(r=>uo.promises.readFile(e(r),"utf-8"),"read"),async readBinary(r){return new Uint8Array(await uo.promises.readFile(e(r)))},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(mpe,"nodeLocalFilesPort");function gpe(n,e){let t;try{t=(0,Rn.parkedPathFor)(e)}catch{return!1}return(0,uo.existsSync)(Ei.join(n,t))}a(gpe,"isParked");function Qf(n){let e=new Lt(n),t=new Rn.SpaceSpecAccumulator,r=[];for(let i of e.getAllFiles()){let s=e.getFrontmatter(i);if(!s)continue;let o=(0,Rn.classifySpaceDeclaration)(s,i.path);if(o.kind==="not-space"||(o.warning!==void 0&&t.warnings.push(o.warning),o.kind==="skip"))continue;let l=t.offer(o.candidate);if(l!==null){if(!(0,uo.existsSync)(Ei.join(n,l.localPath))){gpe(n,l.localPath)&&r.push(l);continue}t.commit(o.candidate)}}return{specs:t.specs,parked:r,warnings:t.warnings}}a(Qf,"collectVaultSpecs");function ype(n,e){for(let t of n.repos){let r=t.headSha!==void 0?` @${t.headSha.slice(0,7)}`:"";e(`${t.repoKey}${r}: ${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,Rn.summarizeParityRound)(n))}a(ype,"printHumanReport");function _pe(n,e){if(n.length!==0){e(`Parked AssetSpaces (frozen on this device, not synced): ${n.length}`);for(let t of n){let r=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 ${r}, remote head is ${i}`);break;case"current":e(` ${t.repoKey}: current \u2014 parked at ${r}, matches the remote head`);break;case"unknown":e(` ${t.repoKey}: unknown \u2014 ${t.reason??"no verdict"}`);break}}}}a(_pe,"printParkedSection");async function bpe(n,e={}){let t=e.out??(b=>console.log(b)),r=Ei.resolve(n.vault);if(!(0,uo.existsSync)(r))throw new Error(`Vault path does not exist: ${r}`);let i=hpe(n,e),s=new co({token:i,...n.apiBase!==void 0?{apiBase:n.apiBase}:{}}),o=e.transportFactory?.(i,n.apiBase)??s.transport(),{specs:l,parked:c,warnings:u}=Qf(r);for(let b of u)t(`warn: ${b}`);let f=n.configDir??".obsidian",d=Ei.join(r,f,"plugins","exocortex",Rn.WATERMARK_STORE_FILENAME),p=new Rn.FileWatermarkStore({read:a(async()=>{try{return await uo.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 b of c)h.push(await(0,Rn.checkParkedStaleness)(b,{transport:o,watermarks:{get:a(S=>p.get(S),"get")},redact:a(S=>s.redact(S),"redact"),...n.apiBase!==void 0?{baseURL:n.apiBase}:{}}));if(n.json!==!0&&_pe(h,t),l.length===0)return n.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 _=new Rn.ParityValidator({transport:o,sha1:dpe,localFilesFor:a(b=>mpe(Ei.join(r,b.localPath)),"localFilesFor"),watermarks:{get:a(b=>p.get(b),"get")},yaml:ppe,redact:a(b=>s.redact(b),"redact"),...n.apiBase!==void 0?{baseURL:n.apiBase}:{}});t(`ExoSync parity check: ${l.length} repo(s), vault ${r}`);let y=await _.runRound(l,{trigger:"standalone"});return n.json===!0?t(JSON.stringify({...y,parked:h},null,2)):ype(y,t),y.vacuous?2:y.ok?0:1}a(bpe,"runExosyncParity");function DU(){return new Ie("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 n=>{try{process.exitCode=await bpe(n)}catch(e){we.handle(e,{command:"exosync-parity"}),process.exitCode=1}})}a(DU,"exosyncParityCommand");ft();var vi=require("node:fs"),ZR=require("node:crypto"),fi=be(require("node:path")),Rr=be(Xe());xt();var Spe="exosync-watermarks.local.json";function FU(n,e,t){let r=rC(e,t),i=new co({token:r,...e.apiBase!==void 0?{apiBase:e.apiBase}:{}}),s=t.transportFactory?.(r,e.apiBase)??i.transport(),{specs:o,warnings:l}=Qf(n),c=e.configDir??".obsidian",u=fi.join(n,c,"plugins","exocortex",Spe),f=fi.join(n,c,"plugins","exocortex",Rr.CONFLICT_CACHE_STORE_FILENAME),d=new Rr.LocalConflictCacheStore({io:ga(f)}),p=fi.join(n,c,"plugins","exocortex",Rr.OUTBOX_STORE_FILENAME),h=new Rr.LocalOutboxStore({io:ga(p)});return{resolver:new Rr.QuarantineResolver({transport:s,watermarkStore:new Rr.FileWatermarkStore(ga(u)),localFilesFor:a(y=>fS(fi.join(n,y.localPath)),"localFilesFor"),sha1:tC,...e.apiBase!==void 0?{baseURL:e.apiBase}:{},redact:a(y=>i.redact(y),"redact"),conflictCache:d,outbox:h}),specs:o,warnings:l}}a(FU,"buildResolver");async function wpe(n,e={}){let t=e.out??(c=>console.log(c)),r=fi.resolve(n.vault);if(!(0,vi.existsSync)(r))throw new Error(`Vault path does not exist: ${r}`);let{resolver:i,specs:s,warnings:o}=FU(r,n,e);for(let c of o)t(`warn: ${c}`);if(s.length===0)return t("No materialized AssetSpaces with a GitHub source found in this vault."),0;let l=await i.listOpenConflicts(s);if(n.json===!0)return t(JSON.stringify(l,null,2)),0;if(l.length===0)return t("No open conflicts \u2014 nothing to resolve. \u2705"),0;t(`${l.length} open conflict(s):`);for(let c of l){let u=`${c.hasLocal?"local":"(no local)"} vs ${c.hasRemote?"remote":"(no remote)"}`;t(` ${c.repoKey} ${c.path} [${u}]${c.uid?` uid=${c.uid}`:""}`)}return t(""),t("Resolve with: exosync quarantine resolve <path> --take local|remote|file <path> --vault <vault>"),0}a(wpe,"runQuarantineList");async function Epe(n,e,t={}){let r=t.out??(b=>console.log(b)),i=fi.resolve(e.vault);if(!(0,vi.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 vi.promises.readFile(fi.resolve(e.file),"utf-8")}}else o={take:s};let{resolver:l,specs:c,warnings:u}=FU(i,e,t);for(let b of u)r(`warn: ${b}`);let d=(await l.listOpenConflicts(c)).filter(b=>b.path===n&&(e.repo===void 0||b.repoKey===e.repo));if(d.length===0)return r(`No open conflict for "${n}"${e.repo?` in ${e.repo}`:""} \u2014 run \`exosync quarantine list\` to see the current set.`),1;if(d.length>1){r(`"${n}" conflicts in ${d.length} repos \u2014 disambiguate with --repo <repoKey>:`);for(let b of d)r(` --repo ${b.repoKey}`);return 1}let p=d[0],h=c.find(b=>b.repoKey===p.repoKey),_=await l.resolve(h,p.path,o),y=_.awaitingPush===!0?" \u2014 awaiting push (run `exosync sync` to push it)":_.pushedSha!==void 0?` \u2014 pushed @${_.pushedSha.slice(0,7)}`:" \u2014 remote already matched";return r(`Resolved ${p.path} (${_.resolvedTo}) in ${p.repoKey}${y}.`),_.discardedLocalBackupPath!==void 0&&r(` \u21B3 your discarded local version is preserved at ${h.localPath}/${_.discardedLocalBackupPath}`),0}a(Epe,"runQuarantineResolve");function eC(n){return n.replace(/\r\n?/g,`
606
606
  `).replace(/\n+$/,"")}a(eC,"normalizeForCompare");function vpe(n,e,t){let r=[...e].sort((o,l)=>o.path.localeCompare(l.path)),i=[],s=[];for(let o of r){let l=eC(o.content),c=i.find(u=>u.norm===l);if(c!==void 0){s.push({action:"delete",path:o.path,identicalTo:c.path});continue}i.push({path:o.path,norm:l}),i.length===1?s.push({action:"keep",path:o.path,uid:n}):s.push({action:"reuuid",path:o.path,fromUid:n,toUid:t()})}return s}a(vpe,"planDedupGroup");async function Tpe(n,e={}){let t=e.out??(f=>console.log(f)),r=fi.resolve(n.vault);if(!(0,vi.existsSync)(r))throw new Error(`Vault path does not exist: ${r}`);let{specs:i,warnings:s}=Qf(r);for(let f of s)t(`warn: ${f}`);let o=[];for(let f of i){let d=fi.join(r,f.localPath);if(!(0,vi.existsSync)(d))continue;let p=fS(d);for(let h of await p.list())if(h.endsWith(".md"))try{o.push({path:fi.join(d,h),content:await p.read(h)})}catch{continue}}let l=(0,Rr.findDuplicateUidGroups)(o).map(f=>[f.uid,[...f.paths]]);if(l.length===0)return t("No duplicate uids on disk. \u2705"),0;let c=a(f=>fi.relative(r,f),"rel");if(n.auto===!0){let f=[];for(let[b,S]of l){let I=[],O=new Map;for(let T of S){let E=await vi.promises.readFile(T,"utf-8");I.push({path:T,content:E}),O.set(T,E)}f.push({uid:b,decisions:vpe(b,I,ZR.randomUUID),snap:O})}let d=0,p=0;t(`${l.length} duplicate uid(s) on disk \u2014 zero-loss plan:`);for(let{uid:b,decisions:S}of f){t(` ${b}:`);for(let I of S)I.action==="keep"?t(` KEEP ${c(I.path)} (keeps uid ${b})`):I.action==="reuuid"?(p++,t(` RE-UUID ${c(I.path)} (content differs \u2192 fresh uid; both survive, zero-loss)`)):(d++,t(` DELETE ${c(I.path)} (identical content \u2192 ${c(I.identicalTo)}; zero-loss)`))}if(n.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,_=0,y=0;for(let{decisions:b,snap:S}of f){for(let I of b){if(I.action!=="delete")continue;let O;try{O=await vi.promises.readFile(I.path,"utf-8")}catch{continue}if(eC(O)!==eC(S.get(I.path)??"")){t(` ! skipped delete ${c(I.path)} (changed since scan \u2014 re-run dedup-uids)`),y++;continue}await vi.promises.rm(I.path,{force:!0}),t(` deleted ${c(I.path)} (identical to ${c(I.identicalTo)})`),h++}for(let I of b){if(I.action!=="reuuid")continue;let O;try{O=await vi.promises.readFile(I.path,"utf-8")}catch{continue}if((0,Rr.extractAssetUid)(O)!==I.fromUid){t(` ! skipped re-uuid ${c(I.path)} (uid changed since scan \u2014 re-run dedup-uids)`),y++;continue}let T=(0,Rr.rewriteAssetUid)(O,I.toUid);T!==O&&(await vi.promises.writeFile(I.path,T,"utf-8"),t(` re-uuid ${c(I.path)} \u2192 uid=${I.toUid} (content differs from kept copy)`),_++)}}return t(`Resolved: deleted ${h} identical copy(ies), re-uuid ${_} differing variant(s).${y>0?` ${y} skipped (re-run).`:""} Run \`exosync sync\` to propagate.`),y>0?1:0}n.apply===!0&&t("Note: --apply only applies with --auto; running in report mode."),t(`${l.length} duplicate uid(s) on disk:`);for(let[f,d]of l){t(` ${f} \u2014 ${d.length} files:`);for(let p of d)t(` ${c(p)}`)}if(n.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,Rr.planDuplicateUidFix)(o,ZR.randomUUID))await vi.promises.writeFile(f.path,f.content,"utf-8"),t(` fixed ${c(f.path)} \u2192 uid=${f.toUid}`),u++;return t(`Reassigned ${u} uid(s). Run \`exosync sync\` to propagate.`),0}a(Tpe,"runDedupUids");function JR(n){return n.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(JR,"withQuarantineOptions");function LU(n){let e=new Ie("quarantine").description("Inspect and resolve ExoSync conflicts (quarantine resolver; RFC 4e4dc453, finding a0a3d1d6)");JR(e.command("list").description("List open conflicts that need a manual choice")).action(async t=>{try{process.exitCode=await wpe(t)}catch(r){we.handle(r,{command:"exosync quarantine list"}),process.exitCode=1}}),JR(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,r)=>{try{process.exitCode=await Epe(t,r)}catch(i){we.handle(i,{command:"exosync quarantine resolve"}),process.exitCode=1}}),n.addCommand(e),JR(n.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 Tpe(t)}catch(r){we.handle(r,{command:"exosync dedup-uids"}),process.exitCode=1}})}a(LU,"registerQuarantineCommands");xt();var tC=a(async n=>{let e=await NU.webcrypto.subtle.digest("SHA-1",n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")},"nodeSha1"),Ape={parse:a(n=>Sf(n,{schema:bf}),"parse"),stringify:a(n=>wf(n,{schema:bf,lineWidth:-1}),"stringify")};function rC(n,e){if(n.tokenFromGh===!0)return co.resolveGhToken(e.ghTokenRunner);let t=e.env??process.env,r=n.token||t.GITHUB_TOKEN||t.GH_TOKEN||"";if(r.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 r}a(rC,"resolveToken");function fS(n){let e=a(i=>jr.join(n,i),"abs"),t=a(async(i,s)=>{let o;try{o=await Mr.promises.readdir(i,{withFileTypes:!0})}catch{return}for(let l of o){let c=jr.join(i,l.name);if(l.isDirectory()){if(l.name===".git")continue;await t(c,s)}else l.isFile()&&s.push(jr.relative(n,c).split(jr.sep).join("/"))}},"walk"),r=a(async(i,s)=>{let o=jr.dirname(i);await Mr.promises.mkdir(o,{recursive:!0});let l=`${i}.local.tmp`;await s(l),await Mr.promises.rename(l,i)},"writeAtomic");return{async list(){let i=[];return(0,Mr.existsSync)(n)&&await t(n,i),i},read:a(i=>Mr.promises.readFile(e(i),"utf-8"),"read"),async write(i,s){await r(e(i),o=>Mr.promises.writeFile(o,s,"utf-8"))},async delete(i){await Mr.promises.rm(e(i),{force:!0})},async readBinary(i){return new Uint8Array(await Mr.promises.readFile(e(i)))},async writeBinary(i,s){let o=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);await r(e(i),l=>Mr.promises.writeFile(l,Buffer.from(o)))},async stat(i){try{let s=await Mr.promises.stat(e(i));return{mtimeMs:s.mtimeMs,size:s.size}}catch{return null}}}}a(fS,"nodeLocalFilesPort");function ga(n){return{async read(){try{return await Mr.promises.readFile(n,"utf-8")}catch{return null}},async writeAtomic(e){await Mr.promises.mkdir(jr.dirname(n),{recursive:!0});let t=`${n}.local.tmp`;await Mr.promises.writeFile(t,e,"utf-8"),await Mr.promises.rename(t,n)}}}a(ga,"nodeWatermarkFileIO");function Ic(n,e=".obsidian"){let t=jr.join(n,e,"plugins","exocortex",lt.MOUNT_BASE_STORE_FILENAME);return new lt.FileMountBaseStore(ga(t))}a(Ic,"nodeMountBaseStore");var Ipe=(0,MU.promisify)(kU.execFile);function xpe(n){return async e=>{if(e.localPath.length===0||e.localPath.startsWith("-"))return null;try{let{stdout:t}=await Ipe("git",["-C",n,"submodule","status",e.localPath],{timeout:3e4,maxBuffer:4194304}),r=t.match(/^[ +\-U]?([0-9a-f]{40})\b/m);return r?r[1]:null}catch{return null}}}a(xpe,"nodeLocalBaseShaProvider");function Rpe(n){return{async check(e){let t=jr.join(n,e.localPath);if(!(0,Mr.existsSync)(t))return{fullyMaterialized:!1,reason:`mount folder ${e.localPath} does not exist`};let r=0;try{r=(await Mr.promises.readdir(t)).length}catch{return{fullyMaterialized:!1,reason:`mount folder ${e.localPath} is not readable`}}return r===0&&e.spaceKind!=="file"?{fullyMaterialized:!1,reason:`mount folder ${e.localPath} is empty (mid-mount?)`}:{fullyMaterialized:!0}}}}a(Rpe,"nodeMaterializationCheck");function Cpe(n,e){let t=n.pushedSha!==void 0?` \u2192@${n.pushedSha.slice(0,7)}`:"",r=(n.outboxPushedCount??0)>0?`, pushed ${n.outboxPushedCount} resolved`:"",i=(n.outboxReconflictedCount??0)>0?`, ${n.outboxReconflictedCount} re-conflicted (remote moved)`:"";e(`${n.repoKey}${t}: ${n.status} \u2014 pulled ${n.pulledCount}, pushed ${n.pushedCount}, merged ${n.mergedCount}, quarantined ${n.quarantinedCount}${(n.pushedDeletes?.length??0)>0?`, deleted ${n.pushedDeletes.length}`:""}${r}${i}`),n.detail!==void 0&&e(` ${n.detail}`);for(let s of n.warnings)e(` warn: ${s}`);(n.quarantinedPaths?.length??0)>0&&e(` quarantined (\u2192 exosync quarantine resolve): ${n.quarantinedPaths.join(", ")}`),(n.deferredPaths?.length??0)>0&&e(` deferred (\u2192 full sync): ${n.deferredPaths.join(", ")}`),(n.deferredDeletes?.length??0)>0&&e(` deferred deletes: ${n.deferredDeletes.join(", ")}`),n.timings!==void 0&&(0,lt.totalMs)(n.timings)>0&&e(` ${(0,lt.formatRepoTimings)(n.repoKey,n.timings)}`)}a(Cpe,"printRepoResult");function Ope(n){return n==="conflict"||n==="full-conflict"||n==="retry-exhausted"||n==="busy"||n==="auth-required"||n==="error"}a(Ope,"isFailureStatus");async function Ppe(n,e,t={}){let r=t.out??(P=>console.log(P)),i=jr.resolve(e.vault);if(!(0,Mr.existsSync)(i))throw new Error(`Vault path does not exist: ${i}`);let s=rC(e,t),o=new co({token:s,...e.apiBase!==void 0?{apiBase:e.apiBase}:{}}),l=t.transportFactory?.(s,e.apiBase)??o.transport(),{specs:c,warnings:u}=Qf(i);for(let P of u)r(`warn: ${P}`);if(c.length===0)return r("Nothing to sync \u2014 no materialized AssetSpaces with a GitHub source found in this vault."),2;let f=e.configDir??".obsidian",d=jr.join(i,f,"plugins","exocortex",lt.WATERMARK_STORE_FILENAME),p=jr.join(i,f,"plugins","exocortex",lt.LOCAL_MANIFEST_STORE_FILENAME),h=jr.join(i,f,"plugins","exocortex",lt.CONFLICT_CACHE_STORE_FILENAME),_=new lt.LocalConflictCacheStore({io:ga(h)}),y=jr.join(i,f,"plugins","exocortex",lt.OUTBOX_STORE_FILENAME),b=new lt.LocalOutboxStore({io:ga(y)}),S=_,I=new lt.SyncEngine({transport:l,watermarkStore:new lt.FileWatermarkStore(ga(d)),localManifestStore:new lt.FileLocalManifestStore(ga(p)),mountBaseStore:Ic(i,f),localBaseShaProvider:xpe(i),materializationCheck:Rpe(i),localFilesFor:a(P=>fS(jr.join(i,P.localPath)),"localFilesFor"),sha1:tC,redact:a(P=>o.redact(P),"redact"),commitMessage:a((P,V,M=0)=>`exosync: ${V} change(s)${M>0?`, ${M} deletion(s)`:""} (CLI)`,"commitMessage"),mergeLayer:new lt.GatedStructuredMerger(new lt.StructuredMerger(Ape)),quarantine:S,outbox:b,...e.apiBase!==void 0?{baseURL:e.apiBase}:{}});r(`ExoSync ${n}: ${c.length} repo(s), vault ${i}`);let O=(0,lt.orderChildrenFirst)(c),T=e.json===!0?void 0:P=>{r(`[ExoSync] ${P.repoKey}: ${(0,lt.syncProgressPhaseText)(P)}`)},E=await I.syncAll(O,n,T);if(e.json===!0)r(JSON.stringify(E,null,2));else{for(let M of E)Cpe(M,r);let P=E.reduce((M,j)=>({pulled:M.pulled+j.pulledCount,pushed:M.pushed+j.pushedCount,merged:M.merged+j.mergedCount,quarantined:M.quarantined+j.quarantinedCount}),{pulled:0,pushed:0,merged:0,quarantined:0});r(`Summary: ${E.length} repo(s) \u2014 pulled ${P.pulled}, pushed ${P.pushed}, merged ${P.merged}, quarantined ${P.quarantined}`);let V=(0,lt.aggregateTimings)(E);(0,lt.totalMs)(V)>0&&r((0,lt.formatTimingsLine)(V))}return E.some(P=>Ope(P.status))?1:0}a(Ppe,"runExosyncSync");function nC(n){return n.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(nC,"withSyncOptions");function iC(n){return async e=>{try{process.exitCode=await Ppe(n,e)}catch(t){we.handle(t,{command:`exosync ${n}`}),process.exitCode=1}}}a(iC,"makeDirectionAction");function jU(){let n=new Ie("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 nC(n.command("sync").description("Full pull\u2192merge\u2192push cycle for every materialized repo")).action(iC("sync")),nC(n.command("pull").description("Apply remote changes only (nothing leaves the device; local changes re-derive)")).action(iC("pull")),nC(n.command("push").description("Send the local delta only (remote changes are pinned to re-derive on the next pull/sync)")).action(iC("push")),LU(n),n}a(jU,"exosyncCommand");var Dpe=a(n=>{process.stderr.write(`${n}
607
- `)},"DEFAULT_LOG"),dS=class{static{a(this,"HeadlessConfirmGate")}constructor(e){this.yes=e.yes,this.verbose=e.verbose??!1,this.log=e.log??Dpe}async confirmApply(e){if(this.verbose){let t=Array.from(e.filesToDestroy.values()).reduce((r,i)=>r+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 r=e.assetSpacesBeingParked.reduce((i,s)=>i+s.fileCount,0);this.log(`[apply-profile] ${r} 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)}};xt();jt();ir();async function Fpe(n,e,t={}){let r=[],i=[],s=t.out??(P=>process.stdout.write(`${P}
607
+ `)},"DEFAULT_LOG"),dS=class{static{a(this,"HeadlessConfirmGate")}constructor(e){this.yes=e.yes,this.verbose=e.verbose??!1,this.log=e.log??Dpe}async confirmApply(e){if(this.verbose){let t=Array.from(e.filesToDestroy.values()).reduce((r,i)=>r+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 r=e.assetSpacesBeingParked.reduce((i,s)=>i+s.fileCount,0);this.log(`[apply-profile] ${r} 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)}};xt();jt();sr();async function Fpe(n,e,t={}){let r=[],i=[],s=t.out??(P=>process.stdout.write(`${P}
608
608
  `)),o=t.err??(P=>process.stderr.write(`${P}
609
609
  `)),l=a(P=>{r.push(P),s(P)},"out"),c=a(P=>{i.push(P),o(P)},"err");if(!e.vault)throw new nt("--vault is required");let u=(0,UU.resolve)(e.vault);if(!(0,$U.existsSync)(u))throw new Qe(u);if(!n||n.length===0)throw new nt("profile-uid argument is required","exocortex apply-profile <profile-uid> --vault <path>");let d=await(t.resolverFactory?.(e)??new lS({vaultPath:u,warn:a(P=>c(P),"warn")})).resolveFilter(n);if(d.outcome==="missing-profile")throw new nt(`Profile not found: ${n}`,"Run `exocortex find --class exo__Profile` to list available profiles");if(d.outcome==="error")return c(`[apply-profile] Resolver error: ${d.reason}`),{exitCode:5,stdout:r,stderr:i};if(d.outcome==="degraded")return c(`[apply-profile] Refused: profile resolution degraded \u2014 ${d.reason}. Apply aborted to prevent vault corruption.`),{exitCode:5,stdout:r,stderr:i};if(d.outcome!=="engaged")return c(`[apply-profile] Unexpected resolver outcome: ${d.outcome}`),{exitCode:5,stdout:r,stderr:i};let p=d.result,h=e.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,_=t.applyServiceFactory?.(e,u)??new Yf({vaultPath:u,ref:e.ref??"main",mount:new ui({token:h,mountBaseStore:Ic(u)})}),{infos:y,profileLabels:b}=_.scanVault(),S=b.get(n)??n,I;try{I=_.buildDiff({targetProfileUid:n,targetProfileLabel:S,sourceProfileUid:null,sourceProfileLabel:"<unknown>",result:p,infos:y})}catch(P){if(P instanceof xr.TsFloorViolationError)return c(`[apply-profile] Refused: ${P.message}`),{exitCode:5,stdout:r,stderr:i};throw P}if(!await(t.confirmGate??new dS({yes:e.yes??!1,verbose:e.verbose??!1,log:a(P=>c(P),"log")})).confirmApply(I.plan))return{exitCode:0,stdout:r,stderr:i};if(I.toDestroy.length===0&&I.toMaterialize.length===0)return l(`[apply-profile] Already in target mount-state for ${S} \u2014 no-op.`),{exitCode:0,stdout:r,stderr:i};let E;try{E=await _.execute(I)}catch(P){return c(`[apply-profile] Execution failed: ${P instanceof Error?P.message:String(P)}`),{exitCode:5,stdout:r,stderr:i}}return l(`[apply-profile] Switched to ${S}: ${E.destroyed.length} AssetSpace(s) torn down, ${E.materialized.length} materialized.`),{exitCode:0,stdout:r,stderr:i}}a(Fpe,"runApplyProfile");function BU(){return new Ie("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 r=await Fpe(e,t);process.exit(r.exitCode)}catch(r){we.handle(r)}})}a(BU,"applyProfileCommand");ft();var Xf=require("node:path"),xc=require("node:fs"),VU=be(Xe());xt();jt();function qU(){return new Ie("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 n=>{try{if(!n.vault)throw new nt("--vault is required");let e=(0,Xf.resolve)(n.vault);(0,xc.mkdirSync)(e,{recursive:!0});let t=(0,Xf.join)(e,".gitmodules"),r=(0,Xf.join)(e,"assetspaces");if((0,xc.existsSync)(t))throw new nt(`Vault ${e} already has .gitmodules \u2014 refusing \u043A re-bootstrap. Use \`assetspace add\` \u0434\u043B\u044F individual AS.`);if((0,xc.existsSync)(r)&&(0,xc.readdirSync)(r).length>0)throw new nt(`Vault ${e}/assetspaces/ already has content \u2014 refusing \u043A re-bootstrap.`);let i=n.token||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,s=new ui({token:i,mountBaseStore:Ic(e)}),o=n.ref??"main",l=[],c=(0,VU.derivePath)(n.exo)??"assetspaces/exo",u=(0,Xf.join)(e,c);process.stderr.write(`[bootstrap] Pulling ${n.exo}@${o} \u2192 ${c}/...
610
610
  `);let f=await s.pullAssetSpace(n.exo,o,u);if(s.ensureGitmodulesEntry(e,c,n.exo),l.push({folder:c,url:n.exo,sha:f.sha,fileCount:f.fileCount}),n.json)process.stdout.write(JSON.stringify({vault:e,materialized:l},null,2)+`
@@ -626,7 +626,7 @@ Next steps:
626
626
  `),process.stdout.write(` URL: ${n.url}
627
627
  `),process.stdout.write(` SHA: ${l.sha} (${l.fileCount} files)
628
628
  `),process.stdout.write(` .gitmodules: ${c.added?"entry added":"entry already present"}
629
- `)),process.exit(0)}catch(e){we.handle(e)}})}a(HU,"assetSpaceAddCommand");ft();var hS=require("node:path"),sC=require("node:fs"),Jf=be(Xe());xt();jt();ir();function Npe(n){if(n.folder!==void 0&&n.folder.length>0)return n.folder.startsWith("assetspaces/")?n.folder:`assetspaces/${n.folder}`;if(n.url!==void 0&&n.url.length>0)return(0,Jf.derivePath)(n.url)??`assetspaces/${ui.deriveFolderName(n.url)}`;throw new nt("either --folder or --url is required","exocortex assetspace-remove --vault <path> (--folder <mount-path> | --url <url>)")}a(Npe,"resolveRemoveAssetSpacePath");async function kpe(n,e={}){let t=[],r=[],i=a(h=>{t.push(h),(e.out??(_=>process.stdout.write(`${_}
629
+ `)),process.exit(0)}catch(e){we.handle(e)}})}a(HU,"assetSpaceAddCommand");ft();var hS=require("node:path"),sC=require("node:fs"),Jf=be(Xe());xt();jt();sr();function Npe(n){if(n.folder!==void 0&&n.folder.length>0)return n.folder.startsWith("assetspaces/")?n.folder:`assetspaces/${n.folder}`;if(n.url!==void 0&&n.url.length>0)return(0,Jf.derivePath)(n.url)??`assetspaces/${ui.deriveFolderName(n.url)}`;throw new nt("either --folder or --url is required","exocortex assetspace-remove --vault <path> (--folder <mount-path> | --url <url>)")}a(Npe,"resolveRemoveAssetSpacePath");async function kpe(n,e={}){let t=[],r=[],i=a(h=>{t.push(h),(e.out??(_=>process.stdout.write(`${_}
630
630
  `)))(h)},"out"),s=a(h=>{r.push(h),(e.err??(_=>process.stderr.write(`${_}
631
631
  `)))(h)},"err");if(!n.vault)throw new nt("--vault is required");let o=(0,hS.resolve)(n.vault);if(!(0,sC.existsSync)(o))throw new Qe(o);let l=Npe(n),u=(e.scanInfos?.(o)??new Yf({vaultPath:o}).scanVault().infos).find(h=>h.folderName===l);if(u!==void 0&&(0,Jf.isTsFloorAssetSpace)(u.uid,u.namespace)||(0,Jf.isTsFloorMountPath)(l)){let h=u?.label??l,_=u?`${u.namespace||u.uid}`:"path resolves to a floor namespace";return s(`[assetspace-remove] Refused: \xAB${h}\xBB (${_}) is a TS-floor AssetSpace \u2014 unmounting it would self-brick the runtime (R24). Aborted, no changes made.`),{exitCode:5,stdout:t,stderr:r,removed:!1,folder:l}}let d=(0,sC.existsSync)((0,hS.join)(o,l)),p=e.unmount??((h,_)=>new ui().unmountAssetSpace(h,_));try{p(o,l)}catch(h){return s(`[assetspace-remove] Unmount failed: ${h instanceof Error?h.message:String(h)}`),{exitCode:5,stdout:t,stderr:r,removed:!1,folder:l}}return n.json?i(JSON.stringify({vault:o,folder:l,existedBefore:d,unmounted:!0},null,2)):d?(i(`
632
632
  \u2713 AssetSpace unmounted`),i(` Folder: ${l} (removed from vault + .gitmodules)`)):(i(`
@@ -636,7 +636,7 @@ Next steps:
636
636
  `).map(r=>r.trim()).filter(r=>r.length>0),t=e[e.length-1];if(t!==void 0)try{return JSON.parse(t)}catch{return}}a(Gpe,"parseLastJsonLine");function sB(n,e){return e.filter(t=>{let r=n[t];return typeof r!="string"||r.trim().length===0})}a(sB,"missingStringFields");var yS=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:iB,message:"Invalid request: expected a JSON-RPC object"}};let t=e.id,r=t===void 0;if(typeof e.method!="string")return r?null:{jsonrpc:"2.0",id:t??null,error:{code:iB,message:"Invalid request: missing method"}};if(r)return null;let i=t??null;switch(e.method){case"initialize":return{jsonrpc:"2.0",id:i,result:{protocolVersion:Vpe,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:nB}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:qpe,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,r=e.arguments??{},i;if(t==="create_asset"){let l=sB(r,["vault","class","label"]);if(l.length>0)return ed(`create_asset: missing required argument(s): ${l.join(", ")}`,!0);let c=eB(r);if(c!==null)return ed(`create_asset: ${c}`,!0);i=tB(r)}else if(t==="create_effort"){let l=sB(r,["vault","command","target"]);if(l.length>0)return ed(`create_effort: missing required argument(s): ${l.join(", ")}`,!0);i=rB(r)}else return ed(`Unknown tool: ${String(t)}`,!0);let s=await this.deps.runCli(i);if(s.exitCode!==0){let l=s.stderr.trim()||s.stdout.trim()||"(no diagnostic output)";return ed(`exocortex-cli exited ${s.exitCode}
637
637
  ${l}`,!0)}let o=Gpe(s.stdout);return ed(o===void 0?s.stdout.trim():JSON.stringify(o))}};var lB=require("child_process");var Wpe=32*1024*1024;function cB(n){return e=>new Promise(t=>{(0,lB.execFile)(process.execPath,[n,...e],{maxBuffer:Wpe},(r,i,s)=>{let o=0;if(r){let l=r.code;o=typeof l=="number"?l:1}t({stdout:i,stderr:s,exitCode:o})})})}a(cB,"createSelfCliRunner");async function Hpe(n,e,t){let r=(0,uB.createInterface)({input:e,crlfDelay:1/0});for await(let i of r){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:oB,message:"Parse error: invalid JSON"}})+`
638
638
  `);continue}let l;try{l=await n.handle(o)}catch(c){l={jsonrpc:"2.0",id:typeof o?.id=="string"||typeof o?.id=="number"?o.id:null,error:{code:aB,message:`Internal error: ${c instanceof Error?c.message:String(c)}`}}}l!==null&&t(JSON.stringify(l)+`
639
- `)}}a(Hpe,"runStdioServer");function fB(n){return new Ie("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],r=new yS({runCli:cB(t),version:n??"unknown"});await Hpe(r,process.stdin,i=>process.stdout.write(i))})}a(fB,"mcpCommand");function _S(n){let e=new Ie;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(n??"16.224.5"),e.addCommand(K6()),e.addCommand(nU()),e.addCommand(G5()),e.addCommand(K5()),e.addCommand(g6()),e.addCommand(Y5()),e.addCommand(t6()),e.addCommand(r6()),e.addCommand(v6()),e.addCommand(R6()),e.addCommand(U6()),e.addCommand(B6()),e.addCommand(V6()),e.addCommand(G6()),e.addCommand(W6()),e.addCommand(vU()),e.addCommand(IU()),e.addCommand(BU()),e.addCommand(qU()),e.addCommand(HU()),e.addCommand(zU()),e.addCommand(XU()),e.addCommand(DU()),e.addCommand(jU()),e.addCommand(JU()),e.addCommand(fB(n??"16.224.5")),e}a(_S,"createProgram");_S().parse();0&&(module.exports={createProgram});
639
+ `)}}a(Hpe,"runStdioServer");function fB(n){return new Ie("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],r=new yS({runCli:cB(t),version:n??"unknown"});await Hpe(r,process.stdin,i=>process.stdout.write(i))})}a(fB,"mcpCommand");function _S(n){let e=new Ie;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(n??"16.224.6"),e.addCommand(K6()),e.addCommand(nU()),e.addCommand(G5()),e.addCommand(K5()),e.addCommand(g6()),e.addCommand(Y5()),e.addCommand(t6()),e.addCommand(r6()),e.addCommand(v6()),e.addCommand(R6()),e.addCommand(U6()),e.addCommand(B6()),e.addCommand(V6()),e.addCommand(G6()),e.addCommand(W6()),e.addCommand(vU()),e.addCommand(IU()),e.addCommand(BU()),e.addCommand(qU()),e.addCommand(HU()),e.addCommand(zU()),e.addCommand(XU()),e.addCommand(DU()),e.addCommand(jU()),e.addCommand(JU()),e.addCommand(fB(n??"16.224.6")),e}a(_S,"createProgram");_S().parse();0&&(module.exports={createProgram});
640
640
  /*! Bundled license information:
641
641
 
642
642
  reflect-metadata/Reflect.js: