@kitelev/exocortex-cli 16.248.4 → 16.248.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -10
- 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.248.
|
|
2
|
+
// @kitelev/exocortex-cli v16.248.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 GV=Object.create;var Ip=Object.defineProperty;var qV=Object.getOwnPropertyDescriptor;var WV=Object.getOwnPropertyNames;var zV=Object.getPrototypeOf,HV=Object.prototype.hasOwnProperty;var a=(r,e)=>Ip(r,"name",{value:e,configurable:!0});var Ve=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var T=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Uu=(r,e)=>{for(var t in e)Ip(r,t,{get:e[t],enumerable:!0})},kF=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of WV(e))!HV.call(r,i)&&i!==t&&Ip(r,i,{get:()=>e[i],enumerable:!(n=qV(e,i))||n.enumerable});return r};var te=(r,e,t)=>(t=r!=null?GV(zV(r)):{},kF(e||!r||!r.__esModule?Ip(t,"default",{value:r,enumerable:!0}):t,r)),Vg=r=>kF(Ip({},"__esModule",{value:!0}),r);var KE=T(()=>{var MF;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(l,u){return function(f,d){Object.defineProperty(l,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}a(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}a(s,"functionThis");function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}a(o,"indirectEvalThis");function c(){return s()||o()}a(c,"sloppyModeThis")})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,f={create:c?function(){return et(Object.create(null))}:l?function(){return et({__proto__:null})}:function(){return et({})},has:u?function(C,O){return n.call(C,O)}:function(C,O){return O in C},get:u?function(C,O){return n.call(C,O)?C[O]:void 0}:function(C,O){return C[O]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Be(),h=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ze(),g=typeof WeakMap=="function"?WeakMap:nt(),m=i?Symbol.for("@reflect-metadata:registry"):void 0,b=Fe(),_=De(b);function S(C,O,L,W){if(ee(L)){if(!Ae(C))throw new TypeError;if(!Te(O))throw new TypeError;return Q(C,O)}else{if(!Ae(C))throw new TypeError;if(!X(O))throw new TypeError;if(!X(W)&&!ee(W)&&!Y(W))throw new TypeError;return Y(W)&&(W=void 0),L=ie(L),fe(C,O,L,W)}}a(S,"decorate"),e("decorate",S);function I(C,O){function L(W,ve){if(!X(W))throw new TypeError;if(!ee(ve)&&!Re(ve))throw new TypeError;K(C,O,W,ve)}return a(L,"decorator"),L}a(I,"metadata"),e("metadata",I);function E(C,O,L,W){if(!X(L))throw new TypeError;return ee(W)||(W=ie(W)),K(C,O,L,W)}a(E,"defineMetadata"),e("defineMetadata",E);function w(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),j(C,O,L)}a(w,"hasMetadata"),e("hasMetadata",w);function R(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),ce(C,O,L)}a(R,"hasOwnMetadata"),e("hasOwnMetadata",R);function x(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),V(C,O,L)}a(x,"getMetadata"),e("getMetadata",x);function P(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),oe(C,O,L)}a(P,"getOwnMetadata"),e("getOwnMetadata",P);function k(C,O){if(!X(C))throw new TypeError;return ee(O)||(O=ie(O)),z(C,O)}a(k,"getMetadataKeys"),e("getMetadataKeys",k);function B(C,O){if(!X(C))throw new TypeError;return ee(O)||(O=ie(O)),Z(C,O)}a(B,"getOwnMetadataKeys"),e("getOwnMetadataKeys",B);function D(C,O,L){if(!X(O))throw new TypeError;if(ee(L)||(L=ie(L)),!X(O))throw new TypeError;ee(L)||(L=ie(L));var W=xe(O,L,!1);return ee(W)?!1:W.OrdinaryDeleteMetadata(C,O,L)}a(D,"deleteMetadata"),e("deleteMetadata",D);function Q(C,O){for(var L=C.length-1;L>=0;--L){var W=C[L],ve=W(O);if(!ee(ve)&&!Y(ve)){if(!Te(ve))throw new TypeError;O=ve}}return O}a(Q,"DecorateConstructor");function fe(C,O,L,W){for(var ve=C.length-1;ve>=0;--ve){var Bt=C[ve],Kt=Bt(O,L,W);if(!ee(Kt)&&!Y(Kt)){if(!X(Kt))throw new TypeError;W=Kt}}return W}a(fe,"DecorateProperty");function j(C,O,L){var W=ce(C,O,L);if(W)return!0;var ve=Ce(O);return Y(ve)?!1:j(C,ve,L)}a(j,"OrdinaryHasMetadata");function ce(C,O,L){var W=xe(O,L,!1);return ee(W)?!1:$(W.OrdinaryHasOwnMetadata(C,O,L))}a(ce,"OrdinaryHasOwnMetadata");function V(C,O,L){var W=ce(C,O,L);if(W)return oe(C,O,L);var ve=Ce(O);if(!Y(ve))return V(C,ve,L)}a(V,"OrdinaryGetMetadata");function oe(C,O,L){var W=xe(O,L,!1);if(!ee(W))return W.OrdinaryGetOwnMetadata(C,O,L)}a(oe,"OrdinaryGetOwnMetadata");function K(C,O,L,W){var ve=xe(L,W,!0);ve.OrdinaryDefineOwnMetadata(C,O,L,W)}a(K,"OrdinaryDefineOwnMetadata");function z(C,O){var L=Z(C,O),W=Ce(C);if(W===null)return L;var ve=z(W,O);if(ve.length<=0)return L;if(L.length<=0)return ve;for(var Bt=new h,Kt=[],tt=0,me=L;tt<me.length;tt++){var ge=me[tt],be=Bt.has(ge);be||(Bt.add(ge),Kt.push(ge))}for(var we=0,Qe=ve;we<Qe.length;we++){var ge=Qe[we],be=Bt.has(ge);be||(Bt.add(ge),Kt.push(ge))}return Kt}a(z,"OrdinaryMetadataKeys");function Z(C,O){var L=xe(C,O,!1);return L?L.OrdinaryOwnMetadataKeys(C,O):[]}a(Z,"OrdinaryOwnMetadataKeys");function Ie(C){if(C===null)return 1;switch(typeof C){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return C===null?1:6;default:return 6}}a(Ie,"Type");function ee(C){return C===void 0}a(ee,"IsUndefined");function Y(C){return C===null}a(Y,"IsNull");function se(C){return typeof C=="symbol"}a(se,"IsSymbol");function X(C){return typeof C=="object"?C!==null:typeof C=="function"}a(X,"IsObject");function le(C,O){switch(Ie(C)){case 0:return C;case 1:return C;case 2:return C;case 3:return C;case 4:return C;case 5:return C}var L=O===3?"string":O===5?"number":"default",W=U(C,s);if(W!==void 0){var ve=W.call(C,L);if(X(ve))throw new TypeError;return ve}return Ue(C,L==="default"?"number":L)}a(le,"ToPrimitive");function Ue(C,O){if(O==="string"){var L=C.toString;if(ye(L)){var W=L.call(C);if(!X(W))return W}var ve=C.valueOf;if(ye(ve)){var W=ve.call(C);if(!X(W))return W}}else{var ve=C.valueOf;if(ye(ve)){var W=ve.call(C);if(!X(W))return W}var Bt=C.toString;if(ye(Bt)){var W=Bt.call(C);if(!X(W))return W}}throw new TypeError}a(Ue,"OrdinaryToPrimitive");function $(C){return!!C}a($,"ToBoolean");function de(C){return""+C}a(de,"ToString");function ie(C){var O=le(C,3);return se(O)?O:de(O)}a(ie,"ToPropertyKey");function Ae(C){return Array.isArray?Array.isArray(C):C instanceof Object?C instanceof Array:Object.prototype.toString.call(C)==="[object Array]"}a(Ae,"IsArray");function ye(C){return typeof C=="function"}a(ye,"IsCallable");function Te(C){return typeof C=="function"}a(Te,"IsConstructor");function Re(C){switch(Ie(C)){case 3:return!0;case 4:return!0;default:return!1}}a(Re,"IsPropertyKey");function pe(C,O){return C===O||C!==C&&O!==O}a(pe,"SameValueZero");function U(C,O){var L=C[O];if(L!=null){if(!ye(L))throw new TypeError;return L}}a(U,"GetMethod");function F(C){var O=U(C,o);if(!ye(O))throw new TypeError;var L=O.call(C);if(!X(L))throw new TypeError;return L}a(F,"GetIterator");function H(C){return C.value}a(H,"IteratorValue");function ae(C){var O=C.next();return O.done?!1:O}a(ae,"IteratorStep");function Se(C){var O=C.return;O&&O.call(C)}a(Se,"IteratorClose");function Ce(C){var O=Object.getPrototypeOf(C);if(typeof C!="function"||C===d||O!==d)return O;var L=C.prototype,W=L&&Object.getPrototypeOf(L);if(W==null||W===Object.prototype)return O;var ve=W.constructor;return typeof ve!="function"||ve===C?O:ve}a(Ce,"OrdinaryGetPrototypeOf");function qe(){var C;!ee(m)&&typeof t.Reflect<"u"&&!(m in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(C=We(t.Reflect));var O,L,W,ve=new g,Bt={registerProvider:Kt,getProvider:me,setProvider:be};return Bt;function Kt(we){if(!Object.isExtensible(Bt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case C===we:break;case ee(O):O=we;break;case O===we:break;case ee(L):L=we;break;case L===we:break;default:W===void 0&&(W=new h),W.add(we);break}}function tt(we,Qe){if(!ee(O)){if(O.isProviderFor(we,Qe))return O;if(!ee(L)){if(L.isProviderFor(we,Qe))return O;if(!ee(W))for(var Et=F(W);;){var vt=ae(Et);if(!vt)return;var fn=H(vt);if(fn.isProviderFor(we,Qe))return Se(Et),fn}}}if(!ee(C)&&C.isProviderFor(we,Qe))return C}function me(we,Qe){var Et=ve.get(we),vt;return ee(Et)||(vt=Et.get(Qe)),ee(vt)&&(vt=tt(we,Qe),ee(vt)||(ee(Et)&&(Et=new p,ve.set(we,Et)),Et.set(Qe,vt))),vt}function ge(we){if(ee(we))throw new TypeError;return O===we||L===we||!ee(W)&&W.has(we)}function be(we,Qe,Et){if(!ge(Et))throw new Error("Metadata provider not registered.");var vt=me(we,Qe);if(vt!==Et){if(!ee(vt))return!1;var fn=ve.get(we);ee(fn)&&(fn=new p,ve.set(we,fn)),fn.set(Qe,Et)}return!0}}a(qe,"CreateMetadataRegistry");function Fe(){var C;return!ee(m)&&X(t.Reflect)&&Object.isExtensible(t.Reflect)&&(C=t.Reflect[m]),ee(C)&&(C=qe()),!ee(m)&&X(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:C}),C}a(Fe,"GetOrCreateMetadataRegistry");function De(C){var O=new g,L={isProviderFor:a(function(ge,be){var we=O.get(ge);return ee(we)?!1:we.has(be)},"isProviderFor"),OrdinaryDefineOwnMetadata:Kt,OrdinaryHasOwnMetadata:ve,OrdinaryGetOwnMetadata:Bt,OrdinaryOwnMetadataKeys:tt,OrdinaryDeleteMetadata:me};return b.registerProvider(L),L;function W(ge,be,we){var Qe=O.get(ge),Et=!1;if(ee(Qe)){if(!we)return;Qe=new p,O.set(ge,Qe),Et=!0}var vt=Qe.get(be);if(ee(vt)){if(!we)return;if(vt=new p,Qe.set(be,vt),!C.setProvider(ge,be,L))throw Qe.delete(be),Et&&O.delete(ge),new Error("Wrong provider for target.")}return vt}a(W,"GetOrCreateMetadataMap");function ve(ge,be,we){var Qe=W(be,we,!1);return ee(Qe)?!1:$(Qe.has(ge))}a(ve,"OrdinaryHasOwnMetadata");function Bt(ge,be,we){var Qe=W(be,we,!1);if(!ee(Qe))return Qe.get(ge)}a(Bt,"OrdinaryGetOwnMetadata");function Kt(ge,be,we,Qe){var Et=W(we,Qe,!0);Et.set(ge,be)}a(Kt,"OrdinaryDefineOwnMetadata");function tt(ge,be){var we=[],Qe=W(ge,be,!1);if(ee(Qe))return we;for(var Et=Qe.keys(),vt=F(Et),fn=0;;){var Si=ae(vt);if(!Si)return we.length=fn,we;var Bi=H(Si);try{we[fn]=Bi}catch(Yn){try{Se(vt)}finally{throw Yn}}fn++}}a(tt,"OrdinaryOwnMetadataKeys");function me(ge,be,we){var Qe=W(be,we,!1);if(ee(Qe)||!Qe.delete(ge))return!1;if(Qe.size===0){var Et=O.get(be);ee(Et)||(Et.delete(we),Et.size===0&&O.delete(Et))}return!0}a(me,"OrdinaryDeleteMetadata")}a(De,"CreateMetadataProvider");function We(C){var O=C.defineMetadata,L=C.hasOwnMetadata,W=C.getOwnMetadata,ve=C.getOwnMetadataKeys,Bt=C.deleteMetadata,Kt=new g,tt={isProviderFor:a(function(me,ge){var be=Kt.get(me);return!ee(be)&&be.has(ge)?!0:ve(me,ge).length?(ee(be)&&(be=new h,Kt.set(me,be)),be.add(ge),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:O,OrdinaryHasOwnMetadata:L,OrdinaryGetOwnMetadata:W,OrdinaryOwnMetadataKeys:ve,OrdinaryDeleteMetadata:Bt};return tt}a(We,"CreateFallbackProvider");function xe(C,O,L){var W=b.getProvider(C,O);if(!ee(W))return W;if(L){if(b.setProvider(C,O,_))return _;throw new Error("Illegal state.")}}a(xe,"GetMetadataProvider");function Be(){var C={},O=[],L=(function(){function tt(me,ge,be){this._index=0,this._keys=me,this._values=ge,this._selector=be}return a(tt,"MapIterator"),tt.prototype["@@iterator"]=function(){return this},tt.prototype[o]=function(){return this},tt.prototype.next=function(){var me=this._index;if(me>=0&&me<this._keys.length){var ge=this._selector(this._keys[me],this._values[me]);return me+1>=this._keys.length?(this._index=-1,this._keys=O,this._values=O):this._index++,{value:ge,done:!1}}return{value:void 0,done:!0}},tt.prototype.throw=function(me){throw this._index>=0&&(this._index=-1,this._keys=O,this._values=O),me},tt.prototype.return=function(me){return this._index>=0&&(this._index=-1,this._keys=O,this._values=O),{value:me,done:!0}},tt})(),W=(function(){function tt(){this._keys=[],this._values=[],this._cacheKey=C,this._cacheIndex=-2}return a(tt,"Map"),Object.defineProperty(tt.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),tt.prototype.has=function(me){return this._find(me,!1)>=0},tt.prototype.get=function(me){var ge=this._find(me,!1);return ge>=0?this._values[ge]:void 0},tt.prototype.set=function(me,ge){var be=this._find(me,!0);return this._values[be]=ge,this},tt.prototype.delete=function(me){var ge=this._find(me,!1);if(ge>=0){for(var be=this._keys.length,we=ge+1;we<be;we++)this._keys[we-1]=this._keys[we],this._values[we-1]=this._values[we];return this._keys.length--,this._values.length--,pe(me,this._cacheKey)&&(this._cacheKey=C,this._cacheIndex=-2),!0}return!1},tt.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=C,this._cacheIndex=-2},tt.prototype.keys=function(){return new L(this._keys,this._values,ve)},tt.prototype.values=function(){return new L(this._keys,this._values,Bt)},tt.prototype.entries=function(){return new L(this._keys,this._values,Kt)},tt.prototype["@@iterator"]=function(){return this.entries()},tt.prototype[o]=function(){return this.entries()},tt.prototype._find=function(me,ge){if(!pe(this._cacheKey,me)){this._cacheIndex=-1;for(var be=0;be<this._keys.length;be++)if(pe(this._keys[be],me)){this._cacheIndex=be;break}}return this._cacheIndex<0&&ge&&(this._cacheIndex=this._keys.length,this._keys.push(me),this._values.push(void 0)),this._cacheIndex},tt})();return W;function ve(tt,me){return tt}function Bt(tt,me){return me}function Kt(tt,me){return[tt,me]}}a(Be,"CreateMapPolyfill");function Ze(){var C=(function(){function O(){this._map=new p}return a(O,"Set"),Object.defineProperty(O.prototype,"size",{get:a(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),O.prototype.has=function(L){return this._map.has(L)},O.prototype.add=function(L){return this._map.set(L,L),this},O.prototype.delete=function(L){return this._map.delete(L)},O.prototype.clear=function(){this._map.clear()},O.prototype.keys=function(){return this._map.keys()},O.prototype.values=function(){return this._map.keys()},O.prototype.entries=function(){return this._map.entries()},O.prototype["@@iterator"]=function(){return this.keys()},O.prototype[o]=function(){return this.keys()},O})();return C}a(Ze,"CreateSetPolyfill");function nt(){var C=16,O=f.create(),L=W();return(function(){function me(){this._key=W()}return a(me,"WeakMap"),me.prototype.has=function(ge){var be=ve(ge,!1);return be!==void 0?f.has(be,this._key):!1},me.prototype.get=function(ge){var be=ve(ge,!1);return be!==void 0?f.get(be,this._key):void 0},me.prototype.set=function(ge,be){var we=ve(ge,!0);return we[this._key]=be,this},me.prototype.delete=function(ge){var be=ve(ge,!1);return be!==void 0?delete be[this._key]:!1},me.prototype.clear=function(){this._key=W()},me})();function W(){var me;do me="@@WeakMap@@"+tt();while(f.has(O,me));return O[me]=!0,me}function ve(me,ge){if(!n.call(me,L)){if(!ge)return;Object.defineProperty(me,L,{value:f.create()})}return me[L]}function Bt(me,ge){for(var be=0;be<ge;++be)me[be]=Math.random()*255|0;return me}function Kt(me){if(typeof Uint8Array=="function"){var ge=new Uint8Array(me);return typeof crypto<"u"?crypto.getRandomValues(ge):typeof msCrypto<"u"?msCrypto.getRandomValues(ge):Bt(ge,me),ge}return Bt(new Array(me),me)}function tt(){var me=Kt(C);me[6]=me[6]&79|64,me[8]=me[8]&191|128;for(var ge="",be=0;be<C;++be){var we=me[be];(be===4||be===6||be===8)&&(ge+="-"),we<16&&(ge+="0"),ge+=we.toString(16).toLowerCase()}return ge}}a(nt,"CreateWeakMapPolyfill");function et(C){return C.__=void 0,delete C.__,C}a(et,"MakeDictionary")})})(MF||(MF={}))});var ac,hl,Rp=Ve(()=>{ac=class extends Error{static{a(this,"CommanderError")}constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},hl=class extends ac{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}});function Gg(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}var Cp,qg=Ve(()=>{Rp();Cp=class{static{a(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new hl(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};a(Gg,"humanReadableArgName")});var jF,xp,YE=Ve(()=>{qg();jF=require("node:util"),xp=class{static{a(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let n=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!i&&!s?t.push(n):n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>Gg(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function s(d,p){return t.formatItem(d,n,p,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(c),i),""]));let l=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let h=d.map(g=>s(t.styleOptionTerm(t.optionTerm(g)),t.styleOptionDescription(t.optionDescription(g))));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(g=>s(t.styleSubcommandTerm(t.subcommandTerm(g)),t.styleSubcommandDescription(t.subcommandDescription(g))));o=o.concat(this.formatItemList(p,h,t))}),o.join(`
|
|
6
|
+
"use strict";var GV=Object.create;var Ip=Object.defineProperty;var qV=Object.getOwnPropertyDescriptor;var WV=Object.getOwnPropertyNames;var zV=Object.getPrototypeOf,HV=Object.prototype.hasOwnProperty;var a=(r,e)=>Ip(r,"name",{value:e,configurable:!0});var Ve=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var T=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Uu=(r,e)=>{for(var t in e)Ip(r,t,{get:e[t],enumerable:!0})},kF=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of WV(e))!HV.call(r,i)&&i!==t&&Ip(r,i,{get:()=>e[i],enumerable:!(n=qV(e,i))||n.enumerable});return r};var te=(r,e,t)=>(t=r!=null?GV(zV(r)):{},kF(e||!r||!r.__esModule?Ip(t,"default",{value:r,enumerable:!0}):t,r)),Vg=r=>kF(Ip({},"__esModule",{value:!0}),r);var KE=T(()=>{var MF;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(l,u){return function(f,d){Object.defineProperty(l,f,{configurable:!0,writable:!0,value:d}),u&&u(f,d)}}a(i,"makeExporter");function s(){try{return Function("return this;")()}catch{}}a(s,"functionThis");function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}a(o,"indirectEvalThis");function c(){return s()||o()}a(c,"sloppyModeThis")})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,f={create:c?function(){return et(Object.create(null))}:l?function(){return et({__proto__:null})}:function(){return et({})},has:u?function(C,O){return n.call(C,O)}:function(C,O){return O in C},get:u?function(C,O){return n.call(C,O)?C[O]:void 0}:function(C,O){return C[O]}},d=Object.getPrototypeOf(Function),p=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Be(),h=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ze(),g=typeof WeakMap=="function"?WeakMap:nt(),m=i?Symbol.for("@reflect-metadata:registry"):void 0,b=Fe(),_=De(b);function S(C,O,L,W){if(ee(L)){if(!Ae(C))throw new TypeError;if(!ve(O))throw new TypeError;return Q(C,O)}else{if(!Ae(C))throw new TypeError;if(!X(O))throw new TypeError;if(!X(W)&&!ee(W)&&!Y(W))throw new TypeError;return Y(W)&&(W=void 0),L=ie(L),fe(C,O,L,W)}}a(S,"decorate"),e("decorate",S);function I(C,O){function L(W,Ee){if(!X(W))throw new TypeError;if(!ee(Ee)&&!Re(Ee))throw new TypeError;K(C,O,W,Ee)}return a(L,"decorator"),L}a(I,"metadata"),e("metadata",I);function E(C,O,L,W){if(!X(L))throw new TypeError;return ee(W)||(W=ie(W)),K(C,O,L,W)}a(E,"defineMetadata"),e("defineMetadata",E);function w(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),j(C,O,L)}a(w,"hasMetadata"),e("hasMetadata",w);function R(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),ce(C,O,L)}a(R,"hasOwnMetadata"),e("hasOwnMetadata",R);function x(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),V(C,O,L)}a(x,"getMetadata"),e("getMetadata",x);function P(C,O,L){if(!X(O))throw new TypeError;return ee(L)||(L=ie(L)),oe(C,O,L)}a(P,"getOwnMetadata"),e("getOwnMetadata",P);function k(C,O){if(!X(C))throw new TypeError;return ee(O)||(O=ie(O)),z(C,O)}a(k,"getMetadataKeys"),e("getMetadataKeys",k);function B(C,O){if(!X(C))throw new TypeError;return ee(O)||(O=ie(O)),Z(C,O)}a(B,"getOwnMetadataKeys"),e("getOwnMetadataKeys",B);function D(C,O,L){if(!X(O))throw new TypeError;if(ee(L)||(L=ie(L)),!X(O))throw new TypeError;ee(L)||(L=ie(L));var W=xe(O,L,!1);return ee(W)?!1:W.OrdinaryDeleteMetadata(C,O,L)}a(D,"deleteMetadata"),e("deleteMetadata",D);function Q(C,O){for(var L=C.length-1;L>=0;--L){var W=C[L],Ee=W(O);if(!ee(Ee)&&!Y(Ee)){if(!ve(Ee))throw new TypeError;O=Ee}}return O}a(Q,"DecorateConstructor");function fe(C,O,L,W){for(var Ee=C.length-1;Ee>=0;--Ee){var Bt=C[Ee],Kt=Bt(O,L,W);if(!ee(Kt)&&!Y(Kt)){if(!X(Kt))throw new TypeError;W=Kt}}return W}a(fe,"DecorateProperty");function j(C,O,L){var W=ce(C,O,L);if(W)return!0;var Ee=Ce(O);return Y(Ee)?!1:j(C,Ee,L)}a(j,"OrdinaryHasMetadata");function ce(C,O,L){var W=xe(O,L,!1);return ee(W)?!1:$(W.OrdinaryHasOwnMetadata(C,O,L))}a(ce,"OrdinaryHasOwnMetadata");function V(C,O,L){var W=ce(C,O,L);if(W)return oe(C,O,L);var Ee=Ce(O);if(!Y(Ee))return V(C,Ee,L)}a(V,"OrdinaryGetMetadata");function oe(C,O,L){var W=xe(O,L,!1);if(!ee(W))return W.OrdinaryGetOwnMetadata(C,O,L)}a(oe,"OrdinaryGetOwnMetadata");function K(C,O,L,W){var Ee=xe(L,W,!0);Ee.OrdinaryDefineOwnMetadata(C,O,L,W)}a(K,"OrdinaryDefineOwnMetadata");function z(C,O){var L=Z(C,O),W=Ce(C);if(W===null)return L;var Ee=z(W,O);if(Ee.length<=0)return L;if(L.length<=0)return Ee;for(var Bt=new h,Kt=[],tt=0,me=L;tt<me.length;tt++){var ge=me[tt],be=Bt.has(ge);be||(Bt.add(ge),Kt.push(ge))}for(var we=0,Qe=Ee;we<Qe.length;we++){var ge=Qe[we],be=Bt.has(ge);be||(Bt.add(ge),Kt.push(ge))}return Kt}a(z,"OrdinaryMetadataKeys");function Z(C,O){var L=xe(C,O,!1);return L?L.OrdinaryOwnMetadataKeys(C,O):[]}a(Z,"OrdinaryOwnMetadataKeys");function Ie(C){if(C===null)return 1;switch(typeof C){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return C===null?1:6;default:return 6}}a(Ie,"Type");function ee(C){return C===void 0}a(ee,"IsUndefined");function Y(C){return C===null}a(Y,"IsNull");function se(C){return typeof C=="symbol"}a(se,"IsSymbol");function X(C){return typeof C=="object"?C!==null:typeof C=="function"}a(X,"IsObject");function le(C,O){switch(Ie(C)){case 0:return C;case 1:return C;case 2:return C;case 3:return C;case 4:return C;case 5:return C}var L=O===3?"string":O===5?"number":"default",W=U(C,s);if(W!==void 0){var Ee=W.call(C,L);if(X(Ee))throw new TypeError;return Ee}return Ue(C,L==="default"?"number":L)}a(le,"ToPrimitive");function Ue(C,O){if(O==="string"){var L=C.toString;if(ye(L)){var W=L.call(C);if(!X(W))return W}var Ee=C.valueOf;if(ye(Ee)){var W=Ee.call(C);if(!X(W))return W}}else{var Ee=C.valueOf;if(ye(Ee)){var W=Ee.call(C);if(!X(W))return W}var Bt=C.toString;if(ye(Bt)){var W=Bt.call(C);if(!X(W))return W}}throw new TypeError}a(Ue,"OrdinaryToPrimitive");function $(C){return!!C}a($,"ToBoolean");function de(C){return""+C}a(de,"ToString");function ie(C){var O=le(C,3);return se(O)?O:de(O)}a(ie,"ToPropertyKey");function Ae(C){return Array.isArray?Array.isArray(C):C instanceof Object?C instanceof Array:Object.prototype.toString.call(C)==="[object Array]"}a(Ae,"IsArray");function ye(C){return typeof C=="function"}a(ye,"IsCallable");function ve(C){return typeof C=="function"}a(ve,"IsConstructor");function Re(C){switch(Ie(C)){case 3:return!0;case 4:return!0;default:return!1}}a(Re,"IsPropertyKey");function pe(C,O){return C===O||C!==C&&O!==O}a(pe,"SameValueZero");function U(C,O){var L=C[O];if(L!=null){if(!ye(L))throw new TypeError;return L}}a(U,"GetMethod");function F(C){var O=U(C,o);if(!ye(O))throw new TypeError;var L=O.call(C);if(!X(L))throw new TypeError;return L}a(F,"GetIterator");function H(C){return C.value}a(H,"IteratorValue");function ae(C){var O=C.next();return O.done?!1:O}a(ae,"IteratorStep");function Se(C){var O=C.return;O&&O.call(C)}a(Se,"IteratorClose");function Ce(C){var O=Object.getPrototypeOf(C);if(typeof C!="function"||C===d||O!==d)return O;var L=C.prototype,W=L&&Object.getPrototypeOf(L);if(W==null||W===Object.prototype)return O;var Ee=W.constructor;return typeof Ee!="function"||Ee===C?O:Ee}a(Ce,"OrdinaryGetPrototypeOf");function qe(){var C;!ee(m)&&typeof t.Reflect<"u"&&!(m in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(C=We(t.Reflect));var O,L,W,Ee=new g,Bt={registerProvider:Kt,getProvider:me,setProvider:be};return Bt;function Kt(we){if(!Object.isExtensible(Bt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case C===we:break;case ee(O):O=we;break;case O===we:break;case ee(L):L=we;break;case L===we:break;default:W===void 0&&(W=new h),W.add(we);break}}function tt(we,Qe){if(!ee(O)){if(O.isProviderFor(we,Qe))return O;if(!ee(L)){if(L.isProviderFor(we,Qe))return O;if(!ee(W))for(var Et=F(W);;){var vt=ae(Et);if(!vt)return;var fn=H(vt);if(fn.isProviderFor(we,Qe))return Se(Et),fn}}}if(!ee(C)&&C.isProviderFor(we,Qe))return C}function me(we,Qe){var Et=Ee.get(we),vt;return ee(Et)||(vt=Et.get(Qe)),ee(vt)&&(vt=tt(we,Qe),ee(vt)||(ee(Et)&&(Et=new p,Ee.set(we,Et)),Et.set(Qe,vt))),vt}function ge(we){if(ee(we))throw new TypeError;return O===we||L===we||!ee(W)&&W.has(we)}function be(we,Qe,Et){if(!ge(Et))throw new Error("Metadata provider not registered.");var vt=me(we,Qe);if(vt!==Et){if(!ee(vt))return!1;var fn=Ee.get(we);ee(fn)&&(fn=new p,Ee.set(we,fn)),fn.set(Qe,Et)}return!0}}a(qe,"CreateMetadataRegistry");function Fe(){var C;return!ee(m)&&X(t.Reflect)&&Object.isExtensible(t.Reflect)&&(C=t.Reflect[m]),ee(C)&&(C=qe()),!ee(m)&&X(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:C}),C}a(Fe,"GetOrCreateMetadataRegistry");function De(C){var O=new g,L={isProviderFor:a(function(ge,be){var we=O.get(ge);return ee(we)?!1:we.has(be)},"isProviderFor"),OrdinaryDefineOwnMetadata:Kt,OrdinaryHasOwnMetadata:Ee,OrdinaryGetOwnMetadata:Bt,OrdinaryOwnMetadataKeys:tt,OrdinaryDeleteMetadata:me};return b.registerProvider(L),L;function W(ge,be,we){var Qe=O.get(ge),Et=!1;if(ee(Qe)){if(!we)return;Qe=new p,O.set(ge,Qe),Et=!0}var vt=Qe.get(be);if(ee(vt)){if(!we)return;if(vt=new p,Qe.set(be,vt),!C.setProvider(ge,be,L))throw Qe.delete(be),Et&&O.delete(ge),new Error("Wrong provider for target.")}return vt}a(W,"GetOrCreateMetadataMap");function Ee(ge,be,we){var Qe=W(be,we,!1);return ee(Qe)?!1:$(Qe.has(ge))}a(Ee,"OrdinaryHasOwnMetadata");function Bt(ge,be,we){var Qe=W(be,we,!1);if(!ee(Qe))return Qe.get(ge)}a(Bt,"OrdinaryGetOwnMetadata");function Kt(ge,be,we,Qe){var Et=W(we,Qe,!0);Et.set(ge,be)}a(Kt,"OrdinaryDefineOwnMetadata");function tt(ge,be){var we=[],Qe=W(ge,be,!1);if(ee(Qe))return we;for(var Et=Qe.keys(),vt=F(Et),fn=0;;){var Si=ae(vt);if(!Si)return we.length=fn,we;var Bi=H(Si);try{we[fn]=Bi}catch(Yn){try{Se(vt)}finally{throw Yn}}fn++}}a(tt,"OrdinaryOwnMetadataKeys");function me(ge,be,we){var Qe=W(be,we,!1);if(ee(Qe)||!Qe.delete(ge))return!1;if(Qe.size===0){var Et=O.get(be);ee(Et)||(Et.delete(we),Et.size===0&&O.delete(Et))}return!0}a(me,"OrdinaryDeleteMetadata")}a(De,"CreateMetadataProvider");function We(C){var O=C.defineMetadata,L=C.hasOwnMetadata,W=C.getOwnMetadata,Ee=C.getOwnMetadataKeys,Bt=C.deleteMetadata,Kt=new g,tt={isProviderFor:a(function(me,ge){var be=Kt.get(me);return!ee(be)&&be.has(ge)?!0:Ee(me,ge).length?(ee(be)&&(be=new h,Kt.set(me,be)),be.add(ge),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:O,OrdinaryHasOwnMetadata:L,OrdinaryGetOwnMetadata:W,OrdinaryOwnMetadataKeys:Ee,OrdinaryDeleteMetadata:Bt};return tt}a(We,"CreateFallbackProvider");function xe(C,O,L){var W=b.getProvider(C,O);if(!ee(W))return W;if(L){if(b.setProvider(C,O,_))return _;throw new Error("Illegal state.")}}a(xe,"GetMetadataProvider");function Be(){var C={},O=[],L=(function(){function tt(me,ge,be){this._index=0,this._keys=me,this._values=ge,this._selector=be}return a(tt,"MapIterator"),tt.prototype["@@iterator"]=function(){return this},tt.prototype[o]=function(){return this},tt.prototype.next=function(){var me=this._index;if(me>=0&&me<this._keys.length){var ge=this._selector(this._keys[me],this._values[me]);return me+1>=this._keys.length?(this._index=-1,this._keys=O,this._values=O):this._index++,{value:ge,done:!1}}return{value:void 0,done:!0}},tt.prototype.throw=function(me){throw this._index>=0&&(this._index=-1,this._keys=O,this._values=O),me},tt.prototype.return=function(me){return this._index>=0&&(this._index=-1,this._keys=O,this._values=O),{value:me,done:!0}},tt})(),W=(function(){function tt(){this._keys=[],this._values=[],this._cacheKey=C,this._cacheIndex=-2}return a(tt,"Map"),Object.defineProperty(tt.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),tt.prototype.has=function(me){return this._find(me,!1)>=0},tt.prototype.get=function(me){var ge=this._find(me,!1);return ge>=0?this._values[ge]:void 0},tt.prototype.set=function(me,ge){var be=this._find(me,!0);return this._values[be]=ge,this},tt.prototype.delete=function(me){var ge=this._find(me,!1);if(ge>=0){for(var be=this._keys.length,we=ge+1;we<be;we++)this._keys[we-1]=this._keys[we],this._values[we-1]=this._values[we];return this._keys.length--,this._values.length--,pe(me,this._cacheKey)&&(this._cacheKey=C,this._cacheIndex=-2),!0}return!1},tt.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=C,this._cacheIndex=-2},tt.prototype.keys=function(){return new L(this._keys,this._values,Ee)},tt.prototype.values=function(){return new L(this._keys,this._values,Bt)},tt.prototype.entries=function(){return new L(this._keys,this._values,Kt)},tt.prototype["@@iterator"]=function(){return this.entries()},tt.prototype[o]=function(){return this.entries()},tt.prototype._find=function(me,ge){if(!pe(this._cacheKey,me)){this._cacheIndex=-1;for(var be=0;be<this._keys.length;be++)if(pe(this._keys[be],me)){this._cacheIndex=be;break}}return this._cacheIndex<0&&ge&&(this._cacheIndex=this._keys.length,this._keys.push(me),this._values.push(void 0)),this._cacheIndex},tt})();return W;function Ee(tt,me){return tt}function Bt(tt,me){return me}function Kt(tt,me){return[tt,me]}}a(Be,"CreateMapPolyfill");function Ze(){var C=(function(){function O(){this._map=new p}return a(O,"Set"),Object.defineProperty(O.prototype,"size",{get:a(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),O.prototype.has=function(L){return this._map.has(L)},O.prototype.add=function(L){return this._map.set(L,L),this},O.prototype.delete=function(L){return this._map.delete(L)},O.prototype.clear=function(){this._map.clear()},O.prototype.keys=function(){return this._map.keys()},O.prototype.values=function(){return this._map.keys()},O.prototype.entries=function(){return this._map.entries()},O.prototype["@@iterator"]=function(){return this.keys()},O.prototype[o]=function(){return this.keys()},O})();return C}a(Ze,"CreateSetPolyfill");function nt(){var C=16,O=f.create(),L=W();return(function(){function me(){this._key=W()}return a(me,"WeakMap"),me.prototype.has=function(ge){var be=Ee(ge,!1);return be!==void 0?f.has(be,this._key):!1},me.prototype.get=function(ge){var be=Ee(ge,!1);return be!==void 0?f.get(be,this._key):void 0},me.prototype.set=function(ge,be){var we=Ee(ge,!0);return we[this._key]=be,this},me.prototype.delete=function(ge){var be=Ee(ge,!1);return be!==void 0?delete be[this._key]:!1},me.prototype.clear=function(){this._key=W()},me})();function W(){var me;do me="@@WeakMap@@"+tt();while(f.has(O,me));return O[me]=!0,me}function Ee(me,ge){if(!n.call(me,L)){if(!ge)return;Object.defineProperty(me,L,{value:f.create()})}return me[L]}function Bt(me,ge){for(var be=0;be<ge;++be)me[be]=Math.random()*255|0;return me}function Kt(me){if(typeof Uint8Array=="function"){var ge=new Uint8Array(me);return typeof crypto<"u"?crypto.getRandomValues(ge):typeof msCrypto<"u"?msCrypto.getRandomValues(ge):Bt(ge,me),ge}return Bt(new Array(me),me)}function tt(){var me=Kt(C);me[6]=me[6]&79|64,me[8]=me[8]&191|128;for(var ge="",be=0;be<C;++be){var we=me[be];(be===4||be===6||be===8)&&(ge+="-"),we<16&&(ge+="0"),ge+=we.toString(16).toLowerCase()}return ge}}a(nt,"CreateWeakMapPolyfill");function et(C){return C.__=void 0,delete C.__,C}a(et,"MakeDictionary")})})(MF||(MF={}))});var ac,hl,Rp=Ve(()=>{ac=class extends Error{static{a(this,"CommanderError")}constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},hl=class extends ac{static{a(this,"InvalidArgumentError")}constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}});function Gg(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}var Cp,qg=Ve(()=>{Rp();Cp=class{static{a(this,"Argument")}constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new hl(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};a(Gg,"humanReadableArgName")});var jF,xp,YE=Ve(()=>{qg();jF=require("node:util"),xp=class{static{a(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let n=a(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!i&&!s?t.push(n):n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>Gg(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[])}),t.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function s(d,p){return t.formatItem(d,n,p,t)}a(s,"callFormatItem");let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],c=t.commandDescription(e);c.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(c),i),""]));let l=t.visibleArguments(e).map(d=>s(t.styleArgumentTerm(t.argumentTerm(d)),t.styleArgumentDescription(t.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let h=d.map(g=>s(t.styleOptionTerm(t.optionTerm(g)),t.styleOptionDescription(t.optionDescription(g))));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(g=>s(t.styleSubcommandTerm(t.subcommandTerm(g)),t.styleSubcommandDescription(t.subcommandDescription(g))));o=o.concat(this.formatItemList(p,h,t))}),o.join(`
|
|
7
7
|
`)}displayWidth(e){return(0,jF.stripVTControlCharacters)(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let o=" ".repeat(2);if(!n)return o+e;let c=e.padEnd(t+e.length-i.displayWidth(e)),l=2,f=(this.helpWidth??80)-t-l-2,d;return f<this.minWidthToWrap||i.preformatted(n)?d=n:d=i.boxWrap(n,f).replace(/\n/g,`
|
|
8
8
|
`+" ".repeat(t+l)),o+c+" ".repeat(l)+d.replace(/\n/g,`
|
|
9
9
|
${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return n.forEach(o=>{let c=o.match(i);if(c===null){s.push("");return}let l=[c.shift()],u=this.displayWidth(l[0]);c.forEach(f=>{let d=this.displayWidth(f);if(u+d<=t){l.push(f),u+=d;return}s.push(l.join(""));let p=f.trimStart();l=[p],u=this.displayWidth(p)}),s.push(l.join(""))}),s.join(`
|
|
@@ -76,7 +76,7 @@ ${r.slice(o+1)}`:l+=r.slice(i),l.slice(1)}a(P3,"foldLine");function nY(r){let e=
|
|
|
76
76
|
`}else n+=ia(t,0,o.contents,{block:!0,compact:!0})+`
|
|
77
77
|
`;i=o.explicitEnd||o.contents!==null&&cY(o.contents),i&&(n+=`...
|
|
78
78
|
`)}return n}a(IL,"present");var uY=Mt(Mt({},oT),{},{schema:eL,skipInvalid:!1,noRefs:!1,flowLevel:-1,transform:a(()=>{},"transform")});function fY(r,e={}){let t=Mt(Mt({},uY),e),n=yL(r,t.schema,{noRefs:t.noRefs,skipInvalid:t.skipInvalid});return t.flowLevel>=0&&_L(n,(i,s)=>{if(!(s.depth<t.flowLevel))return i.style.flow=!0,nT}),t.transform(n),IL(n,Mt(Mt({},M1(t,Object.keys(oT))),{},{schema:t.schema}))}a(fY,"dump");var rh=-1;function dY(r){return"tagStart"in r&&r.tagStart!==rh?r.tagStart:"anchorStart"in r&&r.anchorStart!==rh?r.anchorStart:"valueStart"in r&&r.valueStart!==rh?r.valueStart:"start"in r?r.start:0}a(dY,"eventPosition");function RL(r,e){return e.tagStart===rh?"":r.source.slice(e.tagStart,e.tagEnd)}a(RL,"rawTag");function CL(r,e){return e.anchorStart===rh?void 0:r.source.slice(e.anchorStart,e.anchorEnd)}a(CL,"anchorName");function pY(r,e){let t=eT(r.source,e),n=RL(r,e),i=new dc;switch(e.style){case sr.SINGLE_QUOTED:i.singleQuoted=!0;break;case sr.DOUBLE_QUOTED:i.doubleQuoted=!0;break;case sr.LITERAL_BLOCK:i.literal=!0;break;case sr.FOLDED_BLOCK:i.folded=!0;break}let s;return n!==""?(i.tagged=!0,s=n):e.style===sr.PLAIN?s=r.schema.resolveImplicitScalarTag(t).tag.tagName:s=r.schema.defaultScalarTag.tagName,{kind:"scalar",tag:s,style:i,anchor:CL(r,e),value:t}}a(pY,"buildScalar");function D3(r,e,t){let n=RL(r,e),i=new dc;e.style===po.FLOW&&(i.flow=!0);let s;return n===""?s=t:(s=n,i.tagged=!0),{tag:s,style:i,anchor:CL(r,e)}}a(D3,"buildCollection");function k1(r,e){let t=r.frames[r.frames.length-1];t.kind==="document"?t.doc.contents=e:t.kind==="sequence"?t.node.items.push(e):t.key?(t.node.items.push({key:t.key,value:e}),t.key=null):t.key=e}a(k1,"addNode");function hY(r,e){let t={source:e.source,schema:e.schema,eventIndex:0,position:0,frames:[],documents:[]};for(;t.eventIndex<r.length;){let n=r[t.eventIndex++];switch(t.position=dY(n),n.type){case Dt.DOCUMENT:{let i={contents:null,explicitStart:n.explicitStart,explicitEnd:n.explicitEnd,directives:n.directives};t.frames.push({kind:"document",doc:i});break}case Dt.SCALAR:k1(t,pY(t,n));break;case Dt.SEQUENCE:{let{tag:i,style:s,anchor:o}=D3(t,n,"tag:yaml.org,2002:seq"),c={kind:"sequence",tag:i,style:s,anchor:o,items:[]};t.frames.push({kind:"sequence",node:c});break}case Dt.MAPPING:{let{tag:i,style:s,anchor:o}=D3(t,n,"tag:yaml.org,2002:map"),c={kind:"mapping",tag:i,style:s,anchor:o,items:[]};t.frames.push({kind:"mapping",node:c,key:null});break}case Dt.ALIAS:{let i=t.source.slice(n.anchorStart,n.anchorEnd);k1(t,{kind:"alias",tag:"",style:new dc,anchor:i});break}case Dt.POP:{let i=t.frames.pop();if(i.kind==="mapping"&&i.key)throw new Error("incomplete mapping pair in event stream");i.kind==="document"?t.documents.push(i.doc):k1(t,i.node);break}}}return t.documents}a(hY,"eventsToAst");var mY=Dt.DOCUMENT,gY=Dt.SEQUENCE,yY=Dt.MAPPING,bY=Dt.SCALAR,_Y=Dt.ALIAS,SY=Dt.POP,wY=sr.PLAIN,EY=sr.SINGLE_QUOTED,vY=sr.DOUBLE_QUOTED,TY=sr.LITERAL_BLOCK,AY=sr.FOLDED_BLOCK,IY=po.BLOCK,RY=po.FLOW,CY=Ci.CLIP,xY=Ci.STRIP,OY=Ci.KEEP;_e.CHOMPING_CLIP=CY;_e.CHOMPING_KEEP=OY;_e.CHOMPING_MODE=Ci;_e.CHOMPING_STRIP=xY;_e.COLLECTION_STYLE=po;_e.COLLECTION_STYLE_BLOCK=IY;_e.COLLECTION_STYLE_FLOW=RY;_e.CORE_SCHEMA=J3;_e.DUMP_SCHEMA=eL;_e.EVENT_ALIAS=_Y;_e.EVENT_DOCUMENT=mY;_e.EVENT_ID=Dt;_e.EVENT_MAPPING=yY;_e.EVENT_POP=SY;_e.EVENT_SCALAR=bY;_e.EVENT_SEQUENCE=gY;_e.FAILSAFE_SCHEMA=Hy;_e.JSON_SCHEMA=GH;_e.NOT_RESOLVED=ft;_e.SCALAR_STYLE=sr;_e.SCALAR_STYLE_DOUBLE_QUOTED=vY;_e.SCALAR_STYLE_FOLDED_BLOCK=AY;_e.SCALAR_STYLE_LITERAL_BLOCK=TY;_e.SCALAR_STYLE_PLAIN=wY;_e.SCALAR_STYLE_SINGLE_QUOTED=EY;_e.Schema=lh;_e.Style=dc;_e.VISIT_BREAK=bL;_e.VISIT_SKIP=nT;_e.YAML11_SCHEMA=Z3;_e.YAMLException=sa;_e.binaryTag=q3;_e.boolCoreTag=j3;_e.boolJsonTag=$3;_e.boolYaml11Tag=U3;_e.constructFromEvents=cL;_e.defineMappingTag=ch;_e.defineScalarTag=gn;_e.defineSequenceTag=Wy;_e.dump=fY;_e.eventsToAst=hY;_e.floatCoreTag=J1;_e.floatJsonTag=V3;_e.floatYaml11Tag=By;_e.getScalarValue=eT;_e.intCoreTag=Q1;_e.intJsonTag=B3;_e.intYaml11Tag=Uy;_e.jsToAst=yL;_e.legacyMapTag=WH;_e.load=PK;_e.loadAll=OK;_e.mapTag=Y3;_e.mergeTag=G3;_e.nullCoreTag=N3;_e.nullJsonTag=k3;_e.nullYaml11Tag=M3;_e.omapTag=H3;_e.pairsTag=K3;_e.parseEvents=mL;_e.present=IL;_e.realMapTag=qH;_e.seqTag=z3;_e.setTag=X3;_e.strTag=L3;_e.timestampTag=W3;_e.visit=_L});var Yy=T(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.XSD_NS=void 0;ho.xsdDatatypeLocalName=OL;ho.xsdDatatypeIRI=PY;ho.xsdNumericFamily=FY;ho.XSD_NS="http://www.w3.org/2001/XMLSchema#";var xL="xsd:";function OL(r){return r.startsWith(ho.XSD_NS)?r.slice(ho.XSD_NS.length):r.startsWith(xL)?r.slice(xL.length):null}a(OL,"xsdDatatypeLocalName");function PY(r){let e=OL(r);return e===null?null:ho.XSD_NS+e}a(PY,"xsdDatatypeIRI");function FY(r){return DY.has(r)?"integer":LY.has(r)?"decimal":null}a(FY,"xsdNumericFamily");var DY=new Set(["integer","long","int","short","byte","nonNegativeInteger","unsignedLong","unsignedInt","unsignedShort","unsignedByte","positiveInteger","nonPositiveInteger","negativeInteger"]),LY=new Set(["decimal","float","double"])});var Fl=T(Nn=>{"use strict";var NY=Nn&&Nn.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),kY=Nn&&Nn.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),MY=Nn&&Nn.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&NY(t,e,n[i]);return kY(t,e),t}})();Object.defineProperty(Nn,"__esModule",{value:!0});Nn.STRING_SCALAR_PROPERTIES=void 0;Nn.scalarTypingForRange=DL;Nn.isCompleteDoubleQuotedScalar=uT;Nn.needsYamlQuoting=LL;Nn.quoteYamlString=NL;Nn.decodeYamlQuotedScalar=JY;Nn.serializeYamlScalar=ZY;var lT=MY(Ky()),PL=Yy(),jY=/^[-!&*?|>%@`"'#,[\]{}]/,$Y=/[\u0000-\u001f\u007f-\u009f]/,UY=/[\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,BY=/^(?:true|True|TRUE|false|False|FALSE)$/,VY=/^(?:null|Null|NULL|~)$/,GY=/^[-+]?(?:0b[01_]+|0o[0-7_]+|0x[0-9a-fA-F_]+|[0-9][0-9_]*)$/,qY=/^(?:[-+]?[0-9][0-9_]*(?:\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/,WY=/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/,zY=/^(?:true|false)$/;Nn.STRING_SCALAR_PROPERTIES=new Set(["exo__Asset_label","aliases"]);var HY=/^[+-]?(?:0|[1-9][0-9]*)$/,KY=/^[+-]?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/,YY=/^(?:true|false)$/;function DL(r){if(r===void 0||r.length!==1)return;let e=(0,PL.xsdDatatypeLocalName)(r[0].trim());if(e===null)return;let t=(0,PL.xsdNumericFamily)(e);if(t!==null)return t;if(e==="boolean")return"boolean";if(e==="string")return"string"}a(DL,"scalarTypingForRange");function uT(r){if(r.length<2||!r.startsWith('"')||!r.endsWith('"'))return!1;let e=r.slice(1,-1);for(let t=0;t<e.length;t++){if(e[t]==="\\"){if(t+1>=e.length)return!1;t++;continue}if(e[t]==='"')return!1}return!0}a(uT,"isCompleteDoubleQuotedScalar");function XY(r){let e;try{e=lT.load(`v: ${r}`,{schema:lT.YAML11_SCHEMA})}catch{return!0}return typeof e!="object"||e===null?!0:typeof e.v!="string"}a(XY,"yaml11ReaderCoercesToNonString");function FL(r){return XY(r)||BY.test(r)||VY.test(r)||GY.test(r)||qY.test(r)||WY.test(r)}a(FL,"looksLikeNonStringScalar");function LL(r,e=!1,t){if(r==="")return!0;if(uT(r))return!1;let n=DL(t);return n==="integer"&&HY.test(r)&&Number.isSafeInteger(Number(r))||n==="decimal"&&KY.test(r)||n==="boolean"&&YY.test(r)?!1:!!(r!==r.trim()||/:(\s|$)/.test(r)||/\s#/.test(r)||jY.test(r)||$Y.test(r)||UY.test(r)||e&&FL(r)||n==="string"&&FL(r)&&!zY.test(r))}a(LL,"needsYamlQuoting");function NL(r){let e="";for(let t=0;t<r.length;t++){let n=r[t],i=r.charCodeAt(t);n==="\\"?e+="\\\\":n==='"'?e+='\\"':n===`
|
|
79
|
-
`?e+="\\n":n==="\r"?e+="\\r":n===" "?e+="\\t":i<32||i>=127&&i<=159?e+="\\x"+i.toString(16).toUpperCase().padStart(2,"0"):i===65534||i===65535?e+="\\u"+i.toString(16).toUpperCase():i>=55296&&i<=56319&&t+1<r.length&&r.charCodeAt(t+1)>=56320&&r.charCodeAt(t+1)<=57343?(e+=n+r[t+1],t++):i>=55296&&i<=57343?e+="\\u"+i.toString(16).toUpperCase():e+=n}return`"${e}"`}a(NL,"quoteYamlString");function QY(r){if(r.length<2||!r.startsWith("'")||!r.endsWith("'"))return!1;let e=r.slice(1,-1);for(let t=0;t<e.length;t++)if(e[t]==="'"){if(e[t+1]!=="'")return!1;t++}return!0}a(QY,"isCompleteSingleQuotedScalar");function JY(r){if(!uT(r)&&!QY(r))return r;try{let e=lT.load(r);return typeof e=="string"?e:r}catch{return r}}a(JY,"decodeYamlQuotedScalar");function ZY(r,e=!1,t){return typeof r!="string"?String(r):LL(r,e,t)?NL(r):r}a(ZY,"serializeYamlScalar")});var ef=T(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.bytesToBase64=ML;Zu.base64ToBytes=jL;Zu.base64ToUtf8=eX;Zu.utf8ToBase64=tX;var kL=32768;function ML(r){let e="";for(let t=0;t<r.length;t+=kL)e+=String.fromCharCode(...r.subarray(t,t+kL));return btoa(e)}a(ML,"bytesToBase64");function jL(r){let e=r.replace(/\s/g,""),t=e.length%4,n=t===2||t===3?e+"=".repeat(4-t):e,i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}a(jL,"base64ToBytes");function eX(r){return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(jL(r))}a(eX,"base64ToUtf8");function tX(r){return ML(new TextEncoder().encode(r))}a(tX,"utf8ToBase64")});var oa=T(fT=>{"use strict";Object.defineProperty(fT,"__esModule",{value:!0});fT.iriToObsidianName=nX;var rX=Wt();function nX(r){let e=rX.Namespace.fromTermIRI(r);if(e)return`${e.namespace.prefix}__${e.localName}`;let t=r.match(/\/([^/]+)\.md$/);return t?t[1]:null}a(nX,"iriToObsidianName")});var $L=T(Xy=>{"use strict";Object.defineProperty(Xy,"__esModule",{value:!0});Xy.mergePropertyDefaults=iX;Xy.mergeInheritanceRules=sX;function iX(r,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.propertyName);o?(n.push(o),i.add(o.propertyName)):n.push(s)}for(let s of e)i.has(s.propertyName)||n.push(s);return n}a(iX,"mergePropertyDefaults");function sX(r,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.targetPropertyName);o?(n.push(o),i.add(o.targetPropertyName)):n.push(s)}for(let s of e)i.has(s.targetPropertyName)||n.push(s);return n}a(sX,"mergeInheritanceRules")});var dT=T((o1e,UL)=>{var tf=class{static{a(this,"Wildcard")}constructor(){return oX||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(tf.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(tf.prototype,"termType",{enumerable:!0,value:"Wildcard"});var oX=new tf;UL.exports.Wildcard=tf});var VL=T((c1e,BL)=>{var aX=(function(){var r=a(function(M,N,G,J){for(G=G||{},J=M.length;J--;G[M[J]]=N);return G},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],n=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],c=[13,16,45,197,224,229,308],l=[28,29,53],u=[28,53],f=[1,42],d=[1,45],p=[1,41],h=[1,44],g=[123,126],m=[1,67],b=[39,45,87],_=[13,16,45,197,224,308],S=[1,87],I=[2,281],E=[1,86],w=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],R=[6,28,29,53,63,70,73,81,83,85],x=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],P=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],k=[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],B=[13,16,308],D=[112,132,327,334],Q=[13,16,112,132,308],fe=[1,111],j=[1,117],ce=[112,132,327,328,334],V=[13,16,112,132,308,328],oe=[28,29,45,53,87],K=[1,138],z=[1,151],Z=[1,128],Ie=[1,127],ee=[1,129],Y=[1,140],se=[1,141],X=[1,142],le=[1,143],Ue=[1,144],$=[1,145],de=[1,147],ie=[1,148],Ae=[2,457],ye=[1,158],Te=[1,159],Re=[1,160],pe=[1,152],U=[1,153],F=[1,156],H=[1,171],ae=[1,172],Se=[1,173],Ce=[1,174],qe=[1,175],Fe=[1,176],De=[1,167],We=[1,168],xe=[1,169],Be=[1,170],Ze=[1,157],nt=[1,166],et=[1,161],C=[1,162],O=[1,163],L=[1,164],W=[1,165],ve=[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],Bt=[1,195],Kt=[6,31,73,81,83,85],tt=[2,285],me=[1,199],ge=[1,201],be=[6,31,70,73,81,83,85],we=[2,283],Qe=[1,207],Et=[1,218],vt=[1,223],fn=[1,219],Si=[1,225],Bi=[1,226],Yn=[1,224],KP=[6,63,70,73,81,83,85],YP=[1,236],XP=[2,334],QP=[1,243],JP=[1,241],dn=[6,193],Sg=[2,349],ZP=[2,339],ic=[28,128],eF=[47,48,193,272],wg=[47,48,193,242,272],xu=[47,48,193,242,246,272],Ou=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Yr=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],tF=[1,271],rF=[1,270],Ar=[6,13,16,29,31,39,45,47,48,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],nF=[1,281],iF=[1,280],Xn=[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],gp=[45,89],Eg=[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],vg=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Tg=[31,89],Ag=[48,87],il=[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],no=[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],sF=[1,313],Pu=[6,85],RE=[6,31,81,83,85],oF=[2,361],qo=[2,353],sl=[1,343],yp=[31,112,335],Wo=[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],CE=[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],aF=[6,109,193],ol=[31,112],Ir=[13,16,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],xE=[1,390],OE=[1,391],sc=[13,16,87,197,308,314],cF=[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],Ig=[1,417],Rg=[1,418],lF=[13,16,48,197,229,308],oc=[6,31,85],uF=[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],PE=[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],al=[29,31,85,112,159,160,161,163,164],Cg=[1,443],xg=[1,444],fF=[1,449],cl=[31,112,193,232,318,335],Og=[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],dF=[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],FE=[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],bp=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],_p=[31,45],pF=[1,507],hF=[1,508],mF=[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],Pg=[29,31,85,112,159,160,161,163,164,335],ll=[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],gF=[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],yF=[2,352],DE=[13,16,197,308,314],bF=[1,565],Fu=[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],_F=[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],zo=[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],SF=[13,16,87,308],Ho=[2,364],Du=[29,31,85,112,159,160,161,163,164,193,232,318,335],Fg=[31,112,193,232,272,318,335],Ko=[2,359],wF=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Dg=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],EF=[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],vF=[2,347],LE={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(N,G,J,Pe,Je,v,Jn){var A=v.length-1;switch(Je){case 1:if(v[A-1]=v[A-1]||{},it.base&&(v[A-1].base=it.base),it.base="",v[A-1].prefixes=it.prefixes,it.prefixes=null,it.pathOnly){if(v[A-1].type==="path"||"termType"in v[A-1])return v[A-1];throw new Error("Received full SPARQL query in path only mode")}else if(v[A-1].type==="path"||"termType"in v[A-1])throw new Error("Received only path in full SPARQL mode");if(v[A-1].type==="update"){let Vt={};for(let nr of v[A-1].updates)if(nr.updateType==="insert"){let Tt={};for(let Ft of nr.insert)if(Ft.type==="bgp"||Ft.type==="graph")for(let wi of Ft.triples)wi.subject.termType==="BlankNode"&&(Tt[wi.subject.value]=!0),wi.predicate.termType==="BlankNode"&&(Tt[wi.predicate.value]=!0),wi.object.termType==="BlankNode"&&(Tt[wi.object.value]=!0);for(let Ft of Object.keys(Tt)){if(Vt[Ft])throw new Error("Detected reuse blank node across different INSERT DATA clauses");Vt[Ft]=!0}}}return v[A-1];case 2:this.$={...v[A-1],...v[A],type:"query"};break;case 4:it.base=Sp(v[A]);break;case 5:it.prefixes||(it.prefixes={}),v[A-1]=v[A-1].substr(0,v[A-1].length-1),v[A]=Sp(v[A]),it.prefixes[v[A-1]]=v[A];break;case 6:this.$={...v[A-3],...dl(v[A-2]),...v[A-1],...v[A]};break;case 7:if(!it.skipValidation&&(VE(v[A-3].variables.map(nr=>BE(nr.expression))).some(nr=>nr.aggregation==="count"&&!(nr.expression instanceof Lg))||v[A].group)){for(let nr of v[A-3].variables)if(nr.termType==="Variable"){if(!v[A].group||!v[A].group.map(Tt=>Mu(Tt)).includes(Mu(nr)))throw Error("Projection of ungrouped variable (?"+Mu(nr)+")")}else if(BE(nr.expression).length===0){let Tt=UV(nr.expression);for(let Ft of Tt)if(!v[A].group||!v[A].group.map||!v[A].group.map(wi=>Mu(wi)).includes(Mu(Ft)))throw Error("Use of ungrouped variable in projection of operation (?"+Mu(Ft)+")")}}let ao=v[A-1].where.filter(Vt=>Vt.type==="query");if(ao.length>0){let Vt=v[A-3].variables.filter(Tt=>Tt.variable&&Tt.variable.value).map(Tt=>Tt.variable.value),nr=VE(ao.map(Tt=>Tt.variables)).map(Tt=>Tt.value||Tt.variable.value);for(let Tt of Vt)if(nr.indexOf(Tt)>=0)throw Error("Target id of 'AS' (?"+Tt+") already used in subquery")}this.$=yr(v[A-3],dl(v[A-2]),v[A-1],v[A]);break;case 8:this.$=yr({queryType:"CONSTRUCT",template:v[A-3]},dl(v[A-2]),v[A-1],v[A]);break;case 9:this.$=yr({queryType:"CONSTRUCT",template:v[A-2]=v[A-2]?v[A-2].triples:[]},dl(v[A-5]),{where:[{type:"bgp",triples:fl([],v[A-2])}]},v[A]);break;case 10:this.$=yr({queryType:"DESCRIBE",variables:v[A-3]==="*"?[new Lg]:v[A-3]},dl(v[A-2]),v[A-1],v[A]);break;case 11:this.$=yr({queryType:"ASK"},dl(v[A-2]),v[A-1],v[A]);break;case 12:this.$=yr(v[A-1],{variables:[new Lg]});break;case 13:let Ap=v[A].map(Vt=>Vt.value||Vt.variable.value),ju=BV(Ap);if(ju.length>0)throw Error("Two or more of the resulting columns have the same name (?"+ju[0]+")");this.$=yr(v[A-1],{variables:v[A]});break;case 14:this.$=yr({queryType:"SELECT"},v[A]&&(v[A-1]=Qn(v[A]),v[A]={},v[A][v[A-1]]=!0,v[A]));break;case 16:case 27:this.$=Lu(v[A-3],{variable:v[A-1]});break;case 17:case 18:this.$=yr(v[A-3],v[A-2],v[A-1],v[A],{type:"query"});break;case 19:case 58:this.$={iri:v[A],named:!!v[A-1]};break;case 20:this.$={where:v[A].patterns};break;case 21:this.$=yr(v[A-1],v[A]);break;case 22:this.$=yr(v[A-2],v[A-1],v[A]);break;case 23:this.$={group:v[A]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Lu(v[A]);break;case 26:this.$=Lu(v[A-1]);break;case 29:this.$={having:v[A]};break;case 30:this.$={order:v[A]};break;case 32:this.$=Lu(v[A],{descending:!0});break;case 35:this.$={limit:ku(v[A])};break;case 36:this.$={offset:ku(v[A])};break;case 37:this.$={limit:ku(v[A-2]),offset:ku(v[A])};break;case 38:this.$={limit:ku(v[A]),offset:ku(v[A-2])};break;case 39:case 43:this.$={type:"values",values:v[A]};break;case 40:case 84:this.$=v[A-1].map(Vt=>({[v[A-3]]:Vt}));break;case 41:case 85:this.$=v[A-1].map(()=>({}));break;case 42:case 86:var oo=v[A-4].length;v[A-4]=v[A-4].map(NE),this.$=v[A-1].map(function(Vt){if(Vt.length!==oo)throw Error("Inconsistent VALUES length");for(var nr={},Tt=0;Tt<oo;Tt++)nr["?"+v[A-4][Tt].value]=Vt[Tt];return nr});break;case 44:case 65:case 100:case 126:case 175:this.$=v[A-1];break;case 45:this.$={type:"update",updates:Yo(v[A-2],v[A-1])};break;case 46:this.$=yr({type:"load",silent:!!v[A-2],source:v[A-1]},v[A]&&{destination:v[A]});break;case 47:this.$={type:Qn(v[A-2]),silent:!!v[A-1],graph:v[A]};break;case 48:this.$={type:Qn(v[A-4]),silent:!!v[A-3],source:v[A-2],destination:v[A]};break;case 49:this.$={type:"create",silent:!!v[A-2],graph:{type:"graph",name:v[A]}};break;case 50:this.$={updateType:"insert",insert:LF(v[A])};break;case 51:this.$={updateType:"delete",delete:WE(LF(v[A]))};break;case 52:this.$={updateType:"deletewhere",delete:WE(v[A])};break;case 53:this.$={updateType:"insertdelete",...v[A-4],...v[A-3],...dl(v[A-2],"using"),where:v[A].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=v[A];break;case 55:this.$={delete:WE(v[A-1]),insert:v[A]||[]};break;case 56:this.$={delete:[],insert:v[A]};break;case 59:this.$={graph:v[A]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:v[A]};break;case 64:this.$={[Qn(v[A])]:!0};break;case 66:this.$=v[A-1]?io(v[A],[v[A-1]]):io(v[A]);break;case 67:var vp=yr(v[A-3]||{triples:[]},{type:"graph",name:v[A-5]});this.$=v[A]?[vp,v[A]]:[vp];break;case 68:case 73:this.$={type:"bgp",triples:io(v[A-2],[v[A-1]])};break;case 69:this.$={type:"group",patterns:[v[A-1]]};break;case 70:for(let Vt of v[A-1].filter(nr=>nr.type==="bind")){let nr=v[A-1].indexOf(Vt),Tt=new Set;for(let Ft of v[A-1].slice(0,nr))(Ft.type==="group"||Ft.type==="bgp")&&FF(Ft).forEach(wi=>Tt.add(wi));if(Tt.has(Vt.variable.value))throw Error("Variable used to bind is already bound (?"+Vt.variable.value+")")}this.$={type:"group",patterns:v[A-1]};break;case 71:this.$=v[A-1]?io([v[A-1]],v[A]):io(v[A]);break;case 72:this.$=v[A]?[v[A-2],v[A]]:v[A-2];break;case 75:this.$=yr(v[A],{type:"optional"});break;case 76:this.$=yr(v[A],{type:"minus"});break;case 77:this.$=yr(v[A],{type:"graph",name:v[A-1]});break;case 78:this.$=yr(v[A],{type:"service",name:v[A-1],silent:!!v[A-2]});break;case 79:this.$={type:"filter",expression:v[A]};break;case 80:this.$={type:"bind",variable:v[A-1],expression:v[A-3]};break;case 89:this.$=Ep(v[A]);break;case 90:this.$=void 0;break;case 91:this.$=v[A-1].length?{type:"union",patterns:io(v[A-1].map(ME),[ME(v[A])])}:v[A];break;case 95:this.$={...v[A],function:v[A-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:Yo(v[A-2],v[A-1]),distinct:!!v[A-3]};break;case 98:case 115:case 128:case 247:case 249:case 251:case 253:case 255:case 263:case 267:case 297:case 299:case 303:case 307:case 328:case 341:case 349:case 355:case 361:case 367:case 369:case 373:case 375:case 379:case 381:case 385:case 391:case 395:case 401:case 405:case 409:case 411:case 420:case 428:case 430:case 440:case 444:case 446:case 448:this.$=[];break;case 99:this.$=Yo(v[A-2],v[A-1]);break;case 101:this.$=io(v[A-2],[v[A-1]]);break;case 102:case 112:this.$=qE(v[A].map(Vt=>yr(Xo(v[A-1]),Vt)));break;case 103:this.$=qE(fl(v[A].map(Vt=>yr(Xo(v[A-1].entity),Vt)),v[A-1].triples));break;case 105:this.$=io([v[A-1]],v[A]);break;case 106:this.$=io(v[A]);break;case 107:this.$=UE(v[A-1],v[A]);break;case 109:case 237:this.$=it.factory.namedNode(OV);break;case 110:case 118:this.$=Yo(v[A-1],v[A]);break;case 111:this.$=v[A]?{annotation:v[A],object:v[A-1]}:v[A-1];break;case 113:this.$=v[A]?qE(fl(v[A].map(Vt=>yr(Xo(v[A-1].entity),Vt)),v[A-1].triples)):v[A-1].triples;break;case 114:this.$=UE(...v[A-1],v[A]);break;case 116:this.$=UE(...v[A]);break;case 117:case 159:case 163:this.$=[v[A-1],v[A]];break;case 119:this.$=v[A]?{object:v[A-1],annotation:v[A]}:v[A-1];break;case 120:this.$=v[A-1].length?Nu("|",Yo(v[A-1],v[A])):v[A];break;case 121:this.$=v[A-1].length?Nu("/",Yo(v[A-1],v[A])):v[A];break;case 122:this.$=v[A]?Nu(v[A],[v[A-1]]):v[A-1];break;case 123:this.$=v[A-1]?Nu(v[A-1],[v[A]]):v[A];break;case 125:case 131:this.$=Nu(v[A-1],[v[A]]);break;case 129:this.$=Nu("|",Yo(v[A-2],v[A-1]));break;case 132:case 134:this.$=jV(v[A-1]);break;case 133:case 135:this.$=$V(v[A-1]);break;case 140:this.$={entity:v[A],triples:[]};break;case 145:this.$=NE(v[A]);break;case 149:this.$=it.factory.namedNode(TF);break;case 151:case 153:case 158:case 162:this.$=kE(v[A-1],v[A]);break;case 152:this.$=["||",v[A]];break;case 154:this.$=["&&",v[A]];break;case 156:this.$=pn(v[A-1],[v[A-2],v[A]]);break;case 157:this.$=pn(v[A-2]?"notin":"in",[v[A-3],v[A]]);break;case 160:this.$=["+",kE(v[A-1],v[A])];break;case 161:var Mg=so(v[A-1].value.replace("-",""),v[A-1].datatype);this.$=["-",kE(Mg,v[A])];break;case 164:this.$=pn("UPLUS",[v[A]]);break;case 165:this.$=pn(v[A-1],[v[A]]);break;case 166:this.$=pn("UMINUS",[v[A]]);break;case 177:this.$=pn(Qn(v[A-1]));break;case 178:this.$=pn(Qn(v[A-3]),[v[A-1]]);break;case 179:this.$=Ep(pn(Qn(v[A-3]),[v[A-1]]));break;case 180:this.$=pn(Qn(v[A-5]),[v[A-3],v[A-1]]);break;case 181:this.$=pn(Qn(v[A-7]),[v[A-5],v[A-3],v[A-1]]);break;case 182:this.$=Ep(pn(Qn(v[A-7]),[v[A-5],v[A-3],v[A-1]]));break;case 183:this.$=pn(Qn(v[A-1]),v[A]);break;case 184:this.$=pn("bound",[NE(v[A-1])]);break;case 185:this.$=pn(v[A-1],[]);break;case 186:this.$=pn(v[A-3],[v[A-1]]);break;case 187:this.$=pn(v[A-2]?"notexists":"exists",[ME(v[A])]);break;case 188:case 189:this.$=Lu(v[A-1],{type:"aggregate",aggregation:Qn(v[A-4]),distinct:!!v[A-2]});break;case 190:this.$=Lu(v[A-2],{type:"aggregate",aggregation:Qn(v[A-5]),distinct:!!v[A-3],separator:typeof v[A-1]=="string"?v[A-1]:" "});break;case 192:this.$=so(v[A]);break;case 193:this.$=LV(v[A-1],Qn(v[A].substr(1)));break;case 194:this.$=so(v[A-2],v[A]);break;case 195:case 204:this.$=so(v[A],AF);break;case 196:case 205:this.$=so(v[A],IF);break;case 197:case 206:this.$=so(Qn(v[A]),RF);break;case 200:this.$=so(v[A].toLowerCase(),DV);break;case 201:this.$=so(v[A].substr(1),AF);break;case 202:this.$=so(v[A].substr(1),IF);break;case 203:this.$=so(v[A].substr(1).toLowerCase(),RF);break;case 207:case 208:this.$=PF(v[A],1);break;case 209:case 210:this.$=PF(v[A],3);break;case 211:this.$=it.factory.namedNode(Sp(v[A]));break;case 213:var jg=v[A].indexOf(":"),Tp=v[A].substr(0,jg),$g=it.prefixes[Tp];if(!$g)throw new Error("Unknown prefix: "+Tp);var fr=Sp($g+v[A].substr(jg+1));this.$=it.factory.namedNode(fr);break;case 214:if(v[A]=v[A].substr(0,v[A].length-1),!(v[A]in it.prefixes))throw new Error("Unknown prefix: "+v[A]);var fr=Sp(it.prefixes[v[A]]);this.$=it.factory.namedNode(fr);break;case 215:this.$=wp(v[A].replace(/^(_:)/,""));break;case 216:this.$=wp();break;case 217:case 218:case 232:this.$=Ep(jE(v[A-3],v[A-2],v[A-1]));break;case 230:case 231:this.$=Ep(v[A-1]);break;case 248:case 250:case 252:case 254:case 256:case 260:case 264:case 268:case 270:case 292:case 294:case 296:case 298:case 300:case 302:case 304:case 306:case 329:case 342:case 356:case 368:case 370:case 372:case 374:case 392:case 402:case 425:case 427:case 429:case 431:case 441:case 445:case 447:case 449:v[A-1].push(v[A]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[v[A]];break;case 308:v[A-3].push(v[A-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:v[A-2].push(v[A-1]);break}},"anonymous"),table:[r(e,t,{3:1,4:2,10:3}),{1:[3]},r(n,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),r([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:o},{6:[2,239]},r(c,[2,411],{216:28,217:29}),r(l,[2,249],{18:30}),r(l,[2,251],{22:31}),r(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:p,139:38,307:43,308:h,323:36},r(l,[2,267],{37:46}),r(g,[2,326],{98:47,103:49,106:50,117:55,130:61,100:[1,48],110:[1,51],113:[1,52],115:[1,53],116:[1,54],131:[1,62],329:[1,56],330:[1,57],331:[1,58],332:[1,59],333:[1,60]}),{39:[1,63],40:64,43:65,44:66,45:m,87:p},r(b,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),r(e,[2,248]),r(e,[2,245]),r(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},r([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),r(_,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:S,29:I,52:84,53:E,56:85},{19:88,28:S,29:I,52:89,53:E,56:85},r(l,[2,253],{26:90}),{28:[1,91],52:92,53:E},r(w,[2,385],{181:93,182:94,183:95,31:[2,383]}),r(R,[2,263],{34:96}),r(R,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:p,308:h}),r(R,[2,262]),r(x,[2,259]),r(P,[2,143]),r(P,[2,144]),r([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),r(k,[2,211]),r(k,[2,212]),r(k,[2,213]),r(k,[2,214]),{19:98,28:S,29:I,52:99,53:E,56:85},{6:[2,309],99:100,193:[1,101]},r(B,[2,311],{101:102,328:[1,103]}),r(D,[2,317],{104:104,328:[1,105]}),r(Q,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:fe,114:110},{29:fe,114:112},{29:fe,114:113},{118:114,123:[1,115],125:116,126:j},r(ce,[2,315]),r(ce,[2,316]),r(V,[2,319]),r(V,[2,320]),r(V,[2,321]),r(g,[2,327]),{13:f,16:d,55:118,307:43,308:h},r(l,[2,12]),r(l,[2,13],{44:66,43:119,45:m,87:p}),r(oe,[2,269]),r(oe,[2,15]),{13:f,16:d,44:136,45:K,46:120,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(b,[2,14]),r(b,[2,274]),r(b,[2,271]),r(b,[2,272]),r(e,[2,4]),{13:[1,177]},r(ve,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},r(c,[2,410]),r([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:d,45:[1,193],55:194,197:Bt,219:189,220:190,223:191,224:[1,192],307:43,308:h},r(_,[2,419]),r(Kt,tt,{20:196,59:197,69:198,70:me}),r(l,[2,250]),{29:ge,57:200},r(B,[2,279],{54:202,327:[1,203]}),{29:[2,282]},r(be,we,{23:204,58:205,62:206,63:Qe}),r(l,[2,252]),{19:208,28:S,29:I,52:209,53:E,56:85},{29:[1,210]},r(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,145:212,172:221,185:213,187:214,231:fn,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(KP,[2,265],{56:85,35:227,52:228,19:229,28:S,29:I,53:E}),r(x,[2,260]),r(be,we,{58:205,62:206,23:230,63:Qe}),r(l,[2,268]),{6:[2,45]},r(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:h},r(B,[2,312]),{105:233,112:YP,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},r(D,[2,318]),r(B,XP,{108:240,133:242,112:QP,132:JP}),r(Q,[2,323]),{112:[1,244]},{112:[2,325]},r(dn,[2,50]),r(w,Sg,{135:245,136:246,143:247,144:248,31:ZP,112:ZP}),r(dn,[2,51]),r(dn,[2,52]),r(ic,[2,328],{119:249}),{29:fe,114:250},r(ic,[2,56]),{29:fe,114:251},r(g,[2,59]),r(oe,[2,270]),{47:[1,252]},r(eF,[2,150]),r(wg,[2,428],{240:253}),r(xu,[2,430],{244:254}),r(xu,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),r(Ou,[2,440],{252:264}),r(Yr,[2,448],{260:265}),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,255:154,257:155,264:266,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,255:154,257:155,264:267,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,255:154,257:155,264:268,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Yr,[2,167]),r(Yr,[2,168]),r(Yr,[2,169]),r(Yr,[2,170],{176:269,45:tF,89:rF}),r(Yr,[2,171]),r(Yr,[2,172]),r(Yr,[2,173]),r(Yr,[2,174]),{13:f,16:d,44:136,45:K,46:272,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:nF,89:iF,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},r(Xn,[2,192],{292:[1,286],293:[1,287]}),r(Xn,[2,195]),r(Xn,[2,196]),r(Xn,[2,197]),r(Xn,[2,198]),r(Xn,[2,199]),r(Xn,[2,200]),{13:f,16:d,44:39,55:40,82:z,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},r(gp,[2,452]),r(gp,[2,453]),r(gp,[2,454]),r(gp,[2,455]),r(gp,[2,456]),{279:[2,458]},r(Eg,[2,207]),r(Eg,[2,208]),r(Eg,[2,209]),r(Eg,[2,210]),r(Xn,[2,201]),r(Xn,[2,202]),r(Xn,[2,203]),r(Xn,[2,204]),r(Xn,[2,205]),r(Xn,[2,206]),r(e,[2,5]),r(vg,[2,297],{88:295}),r(Tg,[2,299],{90:296}),{48:[1,297],87:[1,298]},r(Ag,[2,301]),r(ve,[2,43]),r(ve,[2,82]),r(ve,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},r(c,[2,412]),r(il,[2,123]),r(il,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),r(no,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:Bt,223:312,225:308,226:309,229:sF,307:43,308:h},r(c,i,{215:10,214:314}),r(no,[2,236]),r(no,[2,237]),r(Pu,[2,6]),r(RE,[2,287],{60:315,72:316,73:[1,317]}),r(Kt,[2,286]),{13:f,16:d,45:K,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},r([6,31,63,70,73,81,83,85],[2,20]),r(w,oF,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:qo,31:qo,85:qo,112:qo,159:qo,160:qo,161:qo,163:qo,164:qo,41:s}),{13:f,16:d,55:331,307:43,308:h},r(B,[2,280]),r(Pu,[2,7]),r(Kt,tt,{59:197,69:198,20:332,70:me}),r(be,[2,284]),{64:[1,333]},r(be,we,{58:205,62:206,23:334,63:Qe}),r(l,[2,254]),r(w,Sg,{144:248,30:335,143:336,31:[2,257]}),r(l,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:p,139:342,186:339,190:340,195:341,197:sl,307:43,308:h},r(yp,[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:sl,308:h}),r(Wo,[2,227]),r(Wo,[2,228]),r(Wo,[2,229]),{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,172:221,185:351,187:350,200:348,230:347,231:fn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},{13:f,16:d,44:39,55:40,87:p,139:342,186:352,190:340,195:341,197:sl,307:43,308:h},r(Wo,[2,146]),r(Wo,[2,147]),r(Wo,[2,148]),r(Wo,[2,149]),{13:f,16:d,44:354,55:355,82:z,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:358,312:Yn,313:353},r(CE,[2,215]),r(CE,[2,216]),r(be,we,{58:205,62:206,23:359,63:Qe}),r(R,[2,264]),r(KP,[2,266]),r(Pu,[2,11]),r(n,[2,308],{6:[2,310]}),r(dn,[2,313],{102:360,120:361,121:[1,362]}),r(dn,[2,47]),r(dn,[2,63]),r(dn,[2,64]),{13:f,16:d,55:363,307:43,308:h},r(dn,[2,336]),r(dn,[2,337]),r(dn,[2,338]),{109:[1,364]},r(aF,[2,60]),{13:f,16:d,55:365,307:43,308:h},r(B,[2,335]),{13:f,16:d,55:366,307:43,308:h},{31:[1,367]},r(ol,[2,341],{137:368}),r(ol,[2,340]),{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,145:369,172:221,185:213,187:214,231:fn,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},{28:[1,370],127:371,128:[1,372]},r(ic,[2,330],{124:373,125:374,126:j}),r(ic,[2,57]),{44:375,87:p},r(eF,[2,151],{241:376,242:[1,377]}),r(wg,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,247:380,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{250:[1,381]},r(Ir,[2,432]),r(Ir,[2,433]),r(Ir,[2,434]),r(Ir,[2,435]),r(Ir,[2,436]),r(Ir,[2,437]),{250:[2,439]},r([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe}),r(Ou,[2,162],{261:388,262:389,39:xE,338:OE}),r(Yr,[2,164]),r(Yr,[2,165]),r(Yr,[2,166]),r(Ar,[2,95]),r(Ar,[2,96]),r(Ir,[2,377],{177:392,325:[1,393]}),{48:[1,394]},r(Ar,[2,177]),{13:f,16:d,44:136,45:K,46:395,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:396,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:397,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:398,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:399,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,183]),r(Ar,[2,98]),r(Ir,[2,381],{180:400}),{87:[1,401]},r(Ar,[2,185]),{13:f,16:d,44:136,45:K,46:402,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{29:ge,57:403},r(Xn,[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:sl,307:43,308:h},r(sc,[2,233]),r(sc,[2,234]),r(sc,[2,235]),r(cF,[2,459],{281:406,325:[1,407]}),r(Ir,[2,463],{284:408,325:[1,409]}),r(Ir,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:z,171:413,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},{31:[1,419],89:[1,420]},{29:[1,421]},r(Ag,[2,302]),r(vg,[2,367],{167:422}),r(Tg,[2,369],{168:423}),{48:[1,424],87:[1,425]},r(Ag,[2,371]),r(il,[2,122]),r(il,[2,417]),r(il,[2,413]),r(il,[2,414]),r(il,[2,415]),r(no,[2,125]),r(no,[2,127]),r(no,[2,128]),r(lF,[2,420],{227:426}),r(no,[2,130]),{13:f,16:d,55:194,197:Bt,223:427,307:43,308:h},{48:[1,428]},r(oc,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),r(RE,[2,288]),{64:[1,433]},r(Kt,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:f,16:d,45:K,268:Y,269:se,270:X,271:le,273:Ue,274:$,276:de,277:ie,279:Ae,280:ye,283:Te,285:Re,308:h,346:nt,347:et,348:C,349:O,350:L,351:W}),r(uF,[2,293]),r(PE,[2,92]),r(PE,[2,93]),r(PE,[2,94]),{45:tF,89:rF,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:S,29:I,56:85},{19:438,28:S,29:I,56:85},r(al,[2,355],{149:439}),r(al,[2,354]),{13:f,16:d,44:215,45:Cg,55:220,82:z,87:p,89:vt,156:440,172:221,185:441,203:442,231:xg,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(R,[2,19]),r(oc,[2,21]),{13:f,16:d,44:450,45:fF,55:323,65:445,66:446,67:447,68:448,87:p,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},r(Pu,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},r(w,[2,386],{31:[2,388]}),r(yp,[2,102]),r(cl,[2,391],{191:452}),r(w,[2,395],{196:453,198:454}),r(w,[2,108]),r(w,[2,109]),r(yp,[2,103]),r(yp,[2,104]),r(yp,[2,390]),{13:f,16:d,44:215,45:Et,48:[1,455],55:220,82:z,87:p,89:vt,172:221,185:351,187:350,200:456,231:fn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(Og,[2,424]),r(dF,[2,136]),r(dF,[2,137]),r(FE,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:p,139:342,195:458,197:sl,307:43,308:h},r(sc,[2,219]),r(sc,[2,220]),r(sc,[2,221]),r(sc,[2,222]),r(sc,[2,223]),r(Pu,[2,10]),r(dn,[2,46]),r(dn,[2,314]),{112:YP,122:459},r(dn,[2,62]),r(B,XP,{133:242,108:460,112:QP,132:JP}),r(aF,[2,61]),r(dn,[2,49]),r([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},r(ol,[2,351],{146:463,335:[1,464]}),{29:ge,57:465},r(ic,[2,329]),r(B,[2,332],{129:466,327:[1,467]}),r(ic,[2,55]),r(ic,[2,331]),{48:[1,468]},r(wg,[2,429]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(xu,[2,431]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,243:470,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(xu,[2,156]),{45:nF,89:iF,179:471},r(Ou,[2,441]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,251:472,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Yr,[2,444],{256:473}),r(Yr,[2,446],{258:474}),r(Ir,[2,442]),r(Ir,[2,443]),r(Yr,[2,449]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,255:154,257:155,259:475,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ir,[2,450]),r(Ir,[2,451]),r(Ir,[2,379],{178:476}),r(Ir,[2,378]),r([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:d,44:136,45:K,46:482,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{48:[1,483]},{48:[1,484]},r(Ar,[2,187]),r(Xn,[2,194]),{13:f,16:d,44:39,55:40,82:z,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,320:485},{13:f,16:d,39:[1,487],44:136,45:K,46:488,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,282:486,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(cF,[2,460]),{13:f,16:d,44:136,45:K,46:489,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ir,[2,464]),{13:f,16:d,44:136,45:K,46:490,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ir,[2,466]),r(ve,[2,40]),r(vg,[2,298]),r(bp,[2,87]),r(bp,[2,88]),r(bp,[2,89]),r(bp,[2,90]),{13:f,16:d,55:492,82:z,172:493,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,311:494,312:Yn,315:491},r(ve,[2,41]),r(Tg,[2,300]),r(_p,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:z,171:497,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},{31:[1,498],89:[1,499]},{29:[1,500]},r(Ag,[2,372]),{13:f,16:d,48:[2,422],55:194,197:Bt,223:312,226:502,228:501,229:sF,307:43,308:h},r(no,[2,131]),r(no,[2,126]),r(oc,[2,22]),r(oc,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:K,55:323,67:321,68:322,74:505,75:506,76:pF,77:320,78:hF,79:509,87:p,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},r(uF,[2,294]),r(mF,[2,69]),r(mF,[2,70]),r(Kt,tt,{59:197,69:198,20:511,70:me}),r(be,we,{58:205,62:206,23:512,63:Qe}),{29:[2,375],31:[2,71],84:522,85:o,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},r(al,[2,363],{157:524,335:[1,525]}),r(c,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:p}),r(Pg,[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:Cg,55:220,82:z,87:p,89:vt,172:221,185:351,203:536,212:534,231:xg,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(c,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:p}),r(be,[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:fF,87:p,268:Y,269:se,270:X,271:le,273:Ue,274:$,276:de,277:ie,279:Ae,280:ye,283:Te,285:Re,308:h,346:nt,347:et,348:C,349:O,350:L,351:W}),r(ll,[2,291]),r(ll,[2,24]),r(ll,[2,25]),{13:f,16:d,44:136,45:K,46:539,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(ll,[2,28]),r(be,we,{58:205,62:206,23:540,63:Qe}),r([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),r(cl,[2,107]),{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,172:221,185:351,187:350,199:543,200:544,231:fn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(gF,[2,132]),r(Og,[2,425]),r(gF,[2,133]),{13:f,16:d,44:354,55:355,82:z,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:358,312:Yn,313:545},r(dn,[2,54]),r(dn,[2,48]),r(ol,[2,342]),{13:f,16:d,44:39,55:40,87:p,139:546,307:43,308:h},r(ol,[2,68]),r(w,[2,350],{31:yF,112:yF}),r(dn,[2,53]),{13:f,16:d,55:547,307:43,308:h},r(B,[2,333]),r(oe,[2,16]),r(wg,[2,152]),r(xu,[2,154]),r(xu,[2,157]),r(Ou,[2,159]),r(Ou,[2,160],{262:389,261:548,39:xE,338:OE}),r(Ou,[2,161],{262:389,261:549,39:xE,338:OE}),r(Yr,[2,163]),{13:f,16:d,44:136,45:K,46:550,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,178]),r(Ar,[2,179]),{13:f,16:d,44:136,45:K,46:551,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:552,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:553,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{48:[1,554],272:[1,555]},r(Ar,[2,184]),r(Ar,[2,186]),{314:[1,556]},{48:[1,557]},{48:[2,461]},{48:[2,462]},{48:[1,558]},{48:[2,467],193:[1,561],287:559,288:560},{13:f,16:d,55:194,197:Bt,223:562,307:43,308:h},r(DE,[2,224]),r(DE,[2,225]),r(DE,[2,226]),{31:[1,563],45:bF,94:564},r(ve,[2,84]),r(vg,[2,368]),r(ve,[2,85]),r(Tg,[2,370]),r(_p,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},r(oc,[2,35],{83:[1,569]}),r(oc,[2,36],{81:[1,570]}),r(RE,[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:K,76:pF,78:hF,87:p,268:Y,269:se,270:X,271:le,273:Ue,274:$,276:de,277:ie,279:Ae,280:ye,283:Te,285:Re,308:h,346:nt,347:et,348:C,349:O,350:L,351:W}),r(Fu,[2,295]),{45:K,77:572},{45:K,77:573},r(Fu,[2,33]),r(Fu,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},r(al,[2,356]),r(_F,[2,357],{152:578,335:[1,579]}),r(zo,[2,74]),{29:ge,57:580},{29:ge,57:581},{13:f,16:d,44:39,55:40,87:p,139:582,307:43,308:h},r(SF,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:K,55:323,67:321,68:322,77:320,79:585,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},{45:[1,586]},r(zo,[2,81]),{29:ge,57:587},r(al,[2,73]),r(w,[2,362],{29:Ho,31:Ho,85:Ho,112:Ho,159:Ho,160:Ho,161:Ho,163:Ho,164:Ho}),r(Pg,[2,112]),r(Du,[2,401],{206:588}),r(w,[2,405],{209:589,210:590}),r(w,[2,403]),r(w,[2,404]),r(Pg,[2,113]),r(Pg,[2,400]),{13:f,16:d,44:215,45:Cg,48:[1,591],55:220,82:z,87:p,89:vt,172:221,185:351,203:536,212:592,231:xg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(Og,[2,426]),r(FE,[2,138]),r(FE,[2,139]),{232:[1,593]},r(ll,[2,292]),{47:[1,595],48:[1,594]},r(Pu,[2,9]),r(cl,[2,392]),r(cl,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:p,197:sl,308:h}),r(cl,[2,110],{272:[1,598]}),r(Fg,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},r(ic,[2,58]),r(Yr,[2,445]),r(Yr,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},r(Ar,[2,99]),r(Ir,[2,382]),r([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),r(Ar,[2,188]),r(Ar,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:z,172:493,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,311:494,312:Yn,315:611},r(ve,[2,42]),r(_p,[2,304]),{13:f,16:d,55:414,82:z,95:612,171:613,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},{31:[1,614],45:bF,94:615},r(no,[2,129]),r(lF,[2,421]),{82:[1,616]},{82:[1,617]},r(Fu,[2,296]),r(Fu,[2,31]),r(Fu,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},r(w,oF,{155:330,153:618,154:619,29:Ko,31:Ko,85:Ko,112:Ko,159:Ko,160:Ko,161:Ko,163:Ko,164:Ko}),r(_F,[2,358]),r(zo,[2,75]),r(zo,[2,76]),{29:ge,57:620},{13:f,16:d,44:39,55:40,87:p,139:621,307:43,308:h},r(SF,[2,366]),r(zo,[2,79]),{13:f,16:d,44:136,45:K,46:622,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(zo,[2,91],{336:[1,623]}),r([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),r(Du,[2,117]),{13:f,16:d,44:215,45:Cg,55:220,82:z,87:p,89:vt,172:221,185:351,203:536,211:626,212:627,231:xg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(Wo,[2,134]),r(Og,[2,427]),r(Wo,[2,135]),r(ll,[2,26]),{44:628,87:p},r(cl,[2,106]),r(cl,[2,394]),r(w,[2,396]),r(Fg,[2,111]),r(Fg,[2,398]),{13:f,16:d,44:39,55:40,87:p,139:342,186:629,190:340,195:341,197:sl,307:43,308:h},r(CE,[2,217]),r(w,Sg,{144:248,140:630,143:631,31:[2,343]}),r(Ar,[2,97]),r(Ir,[2,380]),r(Ar,[2,180]),{13:f,16:d,44:136,45:K,46:632,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:633,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:Te,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:z,171:637,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},r(wF,[2,305]),r(ve,[2,86]),r(_p,[2,374]),r(oc,[2,37]),r(oc,[2,38]),r(al,[2,72]),r(al,[2,360]),r(zo,[2,77]),{29:ge,57:638},{47:[1,639]},{29:[2,376]},r(Du,[2,402]),r(Du,[2,115],{215:10,208:528,214:529,44:530,205:640,13:i,16:i,45:i,197:i,224:i,229:i,308:i,87:p}),r(Du,[2,118],{272:[1,641]}),r(Dg,[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:De,304:We,305:xe,306:Be},r(bp,[2,218]),r(_p,[2,44]),r(wF,[2,306]),r(zo,[2,78]),{44:651,87:p},r(Du,[2,116]),r(w,[2,406]),r(Dg,[2,119]),r(Dg,[2,408]),r(c,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:p}),r(ll,[2,27]),r(Fg,[2,230]),r(EF,[2,345],{141:653,335:[1,654]}),r(Ar,[2,181]),r(Ar,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},r(w,Sg,{144:248,142:657,143:658,31:vF,112:vF}),r(EF,[2,346]),r(zo,[2,80]),r(Dg,[2,231]),r(ol,[2,67]),r(ol,[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(N,G){if(G.recoverable)this.trace(N);else{var J=new Error(N);throw J.hash=G,J}},"parseError"),parse:a(function(N){var G=this,J=[0],Pe=[],Je=[null],v=[],Jn=this.table,A="",oo=0,vp=0,Mg=0,jg=2,Tp=1,$g=v.slice.call(arguments,1),fr=Object.create(this.lexer),ao={yy:{}};for(var Ap in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Ap)&&(ao.yy[Ap]=this.yy[Ap]);fr.setInput(N,ao.yy),ao.yy.lexer=fr,ao.yy.parser=this,typeof fr.yylloc>"u"&&(fr.yylloc={});var ju=fr.yylloc;v.push(ju);var Vt=fr.options&&fr.options.ranges;typeof ao.yy.parseError=="function"?this.parseError=ao.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function nr(co){J.length=J.length-2*co,Je.length=Je.length-co,v.length=v.length-co}a(nr,"popStack");for(var Tt=a(function(){var co;return co=fr.lex()||Tp,typeof co!="number"&&(co=G.symbols_[co]||co),co},"lex"),Ft,wi,pl,rs,sSe,zE,$u={},Ug,Qo,NF,Bg;;){if(pl=J[J.length-1],this.defaultActions[pl]?rs=this.defaultActions[pl]:((Ft===null||typeof Ft>"u")&&(Ft=Tt()),rs=Jn[pl]&&Jn[pl][Ft]),typeof rs>"u"||!rs.length||!rs[0]){var HE="";Bg=[];for(Ug in Jn[pl])this.terminals_[Ug]&&Ug>jg&&Bg.push("'"+this.terminals_[Ug]+"'");fr.showPosition?HE="Parse error on line "+(oo+1)+`:
|
|
79
|
+
`?e+="\\n":n==="\r"?e+="\\r":n===" "?e+="\\t":i<32||i>=127&&i<=159?e+="\\x"+i.toString(16).toUpperCase().padStart(2,"0"):i===65534||i===65535?e+="\\u"+i.toString(16).toUpperCase():i>=55296&&i<=56319&&t+1<r.length&&r.charCodeAt(t+1)>=56320&&r.charCodeAt(t+1)<=57343?(e+=n+r[t+1],t++):i>=55296&&i<=57343?e+="\\u"+i.toString(16).toUpperCase():e+=n}return`"${e}"`}a(NL,"quoteYamlString");function QY(r){if(r.length<2||!r.startsWith("'")||!r.endsWith("'"))return!1;let e=r.slice(1,-1);for(let t=0;t<e.length;t++)if(e[t]==="'"){if(e[t+1]!=="'")return!1;t++}return!0}a(QY,"isCompleteSingleQuotedScalar");function JY(r){if(!uT(r)&&!QY(r))return r;try{let e=lT.load(r);return typeof e=="string"?e:r}catch{return r}}a(JY,"decodeYamlQuotedScalar");function ZY(r,e=!1,t){return typeof r!="string"?String(r):LL(r,e,t)?NL(r):r}a(ZY,"serializeYamlScalar")});var ef=T(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.bytesToBase64=ML;Zu.base64ToBytes=jL;Zu.base64ToUtf8=eX;Zu.utf8ToBase64=tX;var kL=32768;function ML(r){let e="";for(let t=0;t<r.length;t+=kL)e+=String.fromCharCode(...r.subarray(t,t+kL));return btoa(e)}a(ML,"bytesToBase64");function jL(r){let e=r.replace(/\s/g,""),t=e.length%4,n=t===2||t===3?e+"=".repeat(4-t):e,i=atob(n),s=new Uint8Array(i.length);for(let o=0;o<i.length;o++)s[o]=i.charCodeAt(o);return s}a(jL,"base64ToBytes");function eX(r){return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(jL(r))}a(eX,"base64ToUtf8");function tX(r){return ML(new TextEncoder().encode(r))}a(tX,"utf8ToBase64")});var oa=T(fT=>{"use strict";Object.defineProperty(fT,"__esModule",{value:!0});fT.iriToObsidianName=nX;var rX=Wt();function nX(r){let e=rX.Namespace.fromTermIRI(r);if(e)return`${e.namespace.prefix}__${e.localName}`;let t=r.match(/\/([^/]+)\.md$/);return t?t[1]:null}a(nX,"iriToObsidianName")});var $L=T(Xy=>{"use strict";Object.defineProperty(Xy,"__esModule",{value:!0});Xy.mergePropertyDefaults=iX;Xy.mergeInheritanceRules=sX;function iX(r,e){let t=new Map;for(let s of e)t.set(s.propertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.propertyName);o?(n.push(o),i.add(o.propertyName)):n.push(s)}for(let s of e)i.has(s.propertyName)||n.push(s);return n}a(iX,"mergePropertyDefaults");function sX(r,e){let t=new Map;for(let s of e)t.set(s.targetPropertyName,s);let n=[],i=new Set;for(let s of r){let o=t.get(s.targetPropertyName);o?(n.push(o),i.add(o.targetPropertyName)):n.push(s)}for(let s of e)i.has(s.targetPropertyName)||n.push(s);return n}a(sX,"mergeInheritanceRules")});var dT=T((o1e,UL)=>{var tf=class{static{a(this,"Wildcard")}constructor(){return oX||this}equals(e){return e&&this.termType===e.termType}};Object.defineProperty(tf.prototype,"value",{enumerable:!0,value:"*"});Object.defineProperty(tf.prototype,"termType",{enumerable:!0,value:"Wildcard"});var oX=new tf;UL.exports.Wildcard=tf});var VL=T((c1e,BL)=>{var aX=(function(){var r=a(function(M,N,G,J){for(G=G||{},J=M.length;J--;G[M[J]]=N);return G},"o"),e=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],t=[2,247],n=[100,110,113,115,116,123,126,131,329,330,331,332,333],i=[2,409],s=[1,18],o=[1,27],c=[13,16,45,197,224,229,308],l=[28,29,53],u=[28,53],f=[1,42],d=[1,45],p=[1,41],h=[1,44],g=[123,126],m=[1,67],b=[39,45,87],_=[13,16,45,197,224,308],S=[1,87],I=[2,281],E=[1,86],w=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],R=[6,28,29,53,63,70,73,81,83,85],x=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],P=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],k=[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],B=[13,16,308],D=[112,132,327,334],Q=[13,16,112,132,308],fe=[1,111],j=[1,117],ce=[112,132,327,328,334],V=[13,16,112,132,308,328],oe=[28,29,45,53,87],K=[1,138],z=[1,151],Z=[1,128],Ie=[1,127],ee=[1,129],Y=[1,140],se=[1,141],X=[1,142],le=[1,143],Ue=[1,144],$=[1,145],de=[1,147],ie=[1,148],Ae=[2,457],ye=[1,158],ve=[1,159],Re=[1,160],pe=[1,152],U=[1,153],F=[1,156],H=[1,171],ae=[1,172],Se=[1,173],Ce=[1,174],qe=[1,175],Fe=[1,176],De=[1,167],We=[1,168],xe=[1,169],Be=[1,170],Ze=[1,157],nt=[1,166],et=[1,161],C=[1,162],O=[1,163],L=[1,164],W=[1,165],Ee=[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],Bt=[1,195],Kt=[6,31,73,81,83,85],tt=[2,285],me=[1,199],ge=[1,201],be=[6,31,70,73,81,83,85],we=[2,283],Qe=[1,207],Et=[1,218],vt=[1,223],fn=[1,219],Si=[1,225],Bi=[1,226],Yn=[1,224],KP=[6,63,70,73,81,83,85],YP=[1,236],XP=[2,334],QP=[1,243],JP=[1,241],dn=[6,193],Sg=[2,349],ZP=[2,339],ic=[28,128],eF=[47,48,193,272],wg=[47,48,193,242,272],xu=[47,48,193,242,246,272],Ou=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],Yr=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],tF=[1,271],rF=[1,270],Ar=[6,13,16,29,31,39,45,47,48,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],nF=[1,281],iF=[1,280],Xn=[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],gp=[45,89],Eg=[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],vg=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Tg=[31,89],Ag=[48,87],il=[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],no=[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],sF=[1,313],Pu=[6,85],RE=[6,31,81,83,85],oF=[2,361],qo=[2,353],sl=[1,343],yp=[31,112,335],Wo=[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],CE=[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],aF=[6,109,193],ol=[31,112],Ir=[13,16,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],xE=[1,390],OE=[1,391],sc=[13,16,87,197,308,314],cF=[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],Ig=[1,417],Rg=[1,418],lF=[13,16,48,197,229,308],oc=[6,31,85],uF=[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],PE=[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],al=[29,31,85,112,159,160,161,163,164],Cg=[1,443],xg=[1,444],fF=[1,449],cl=[31,112,193,232,318,335],Og=[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],dF=[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],FE=[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],bp=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],_p=[31,45],pF=[1,507],hF=[1,508],mF=[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],Pg=[29,31,85,112,159,160,161,163,164,335],ll=[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],gF=[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],yF=[2,352],DE=[13,16,197,308,314],bF=[1,565],Fu=[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],_F=[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],zo=[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],SF=[13,16,87,308],Ho=[2,364],Du=[29,31,85,112,159,160,161,163,164,193,232,318,335],Fg=[31,112,193,232,272,318,335],Ko=[2,359],wF=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Dg=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],EF=[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],vF=[2,347],LE={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(N,G,J,Pe,Je,v,Jn){var A=v.length-1;switch(Je){case 1:if(v[A-1]=v[A-1]||{},it.base&&(v[A-1].base=it.base),it.base="",v[A-1].prefixes=it.prefixes,it.prefixes=null,it.pathOnly){if(v[A-1].type==="path"||"termType"in v[A-1])return v[A-1];throw new Error("Received full SPARQL query in path only mode")}else if(v[A-1].type==="path"||"termType"in v[A-1])throw new Error("Received only path in full SPARQL mode");if(v[A-1].type==="update"){let Vt={};for(let nr of v[A-1].updates)if(nr.updateType==="insert"){let Tt={};for(let Ft of nr.insert)if(Ft.type==="bgp"||Ft.type==="graph")for(let wi of Ft.triples)wi.subject.termType==="BlankNode"&&(Tt[wi.subject.value]=!0),wi.predicate.termType==="BlankNode"&&(Tt[wi.predicate.value]=!0),wi.object.termType==="BlankNode"&&(Tt[wi.object.value]=!0);for(let Ft of Object.keys(Tt)){if(Vt[Ft])throw new Error("Detected reuse blank node across different INSERT DATA clauses");Vt[Ft]=!0}}}return v[A-1];case 2:this.$={...v[A-1],...v[A],type:"query"};break;case 4:it.base=Sp(v[A]);break;case 5:it.prefixes||(it.prefixes={}),v[A-1]=v[A-1].substr(0,v[A-1].length-1),v[A]=Sp(v[A]),it.prefixes[v[A-1]]=v[A];break;case 6:this.$={...v[A-3],...dl(v[A-2]),...v[A-1],...v[A]};break;case 7:if(!it.skipValidation&&(VE(v[A-3].variables.map(nr=>BE(nr.expression))).some(nr=>nr.aggregation==="count"&&!(nr.expression instanceof Lg))||v[A].group)){for(let nr of v[A-3].variables)if(nr.termType==="Variable"){if(!v[A].group||!v[A].group.map(Tt=>Mu(Tt)).includes(Mu(nr)))throw Error("Projection of ungrouped variable (?"+Mu(nr)+")")}else if(BE(nr.expression).length===0){let Tt=UV(nr.expression);for(let Ft of Tt)if(!v[A].group||!v[A].group.map||!v[A].group.map(wi=>Mu(wi)).includes(Mu(Ft)))throw Error("Use of ungrouped variable in projection of operation (?"+Mu(Ft)+")")}}let ao=v[A-1].where.filter(Vt=>Vt.type==="query");if(ao.length>0){let Vt=v[A-3].variables.filter(Tt=>Tt.variable&&Tt.variable.value).map(Tt=>Tt.variable.value),nr=VE(ao.map(Tt=>Tt.variables)).map(Tt=>Tt.value||Tt.variable.value);for(let Tt of Vt)if(nr.indexOf(Tt)>=0)throw Error("Target id of 'AS' (?"+Tt+") already used in subquery")}this.$=yr(v[A-3],dl(v[A-2]),v[A-1],v[A]);break;case 8:this.$=yr({queryType:"CONSTRUCT",template:v[A-3]},dl(v[A-2]),v[A-1],v[A]);break;case 9:this.$=yr({queryType:"CONSTRUCT",template:v[A-2]=v[A-2]?v[A-2].triples:[]},dl(v[A-5]),{where:[{type:"bgp",triples:fl([],v[A-2])}]},v[A]);break;case 10:this.$=yr({queryType:"DESCRIBE",variables:v[A-3]==="*"?[new Lg]:v[A-3]},dl(v[A-2]),v[A-1],v[A]);break;case 11:this.$=yr({queryType:"ASK"},dl(v[A-2]),v[A-1],v[A]);break;case 12:this.$=yr(v[A-1],{variables:[new Lg]});break;case 13:let Ap=v[A].map(Vt=>Vt.value||Vt.variable.value),ju=BV(Ap);if(ju.length>0)throw Error("Two or more of the resulting columns have the same name (?"+ju[0]+")");this.$=yr(v[A-1],{variables:v[A]});break;case 14:this.$=yr({queryType:"SELECT"},v[A]&&(v[A-1]=Qn(v[A]),v[A]={},v[A][v[A-1]]=!0,v[A]));break;case 16:case 27:this.$=Lu(v[A-3],{variable:v[A-1]});break;case 17:case 18:this.$=yr(v[A-3],v[A-2],v[A-1],v[A],{type:"query"});break;case 19:case 58:this.$={iri:v[A],named:!!v[A-1]};break;case 20:this.$={where:v[A].patterns};break;case 21:this.$=yr(v[A-1],v[A]);break;case 22:this.$=yr(v[A-2],v[A-1],v[A]);break;case 23:this.$={group:v[A]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Lu(v[A]);break;case 26:this.$=Lu(v[A-1]);break;case 29:this.$={having:v[A]};break;case 30:this.$={order:v[A]};break;case 32:this.$=Lu(v[A],{descending:!0});break;case 35:this.$={limit:ku(v[A])};break;case 36:this.$={offset:ku(v[A])};break;case 37:this.$={limit:ku(v[A-2]),offset:ku(v[A])};break;case 38:this.$={limit:ku(v[A]),offset:ku(v[A-2])};break;case 39:case 43:this.$={type:"values",values:v[A]};break;case 40:case 84:this.$=v[A-1].map(Vt=>({[v[A-3]]:Vt}));break;case 41:case 85:this.$=v[A-1].map(()=>({}));break;case 42:case 86:var oo=v[A-4].length;v[A-4]=v[A-4].map(NE),this.$=v[A-1].map(function(Vt){if(Vt.length!==oo)throw Error("Inconsistent VALUES length");for(var nr={},Tt=0;Tt<oo;Tt++)nr["?"+v[A-4][Tt].value]=Vt[Tt];return nr});break;case 44:case 65:case 100:case 126:case 175:this.$=v[A-1];break;case 45:this.$={type:"update",updates:Yo(v[A-2],v[A-1])};break;case 46:this.$=yr({type:"load",silent:!!v[A-2],source:v[A-1]},v[A]&&{destination:v[A]});break;case 47:this.$={type:Qn(v[A-2]),silent:!!v[A-1],graph:v[A]};break;case 48:this.$={type:Qn(v[A-4]),silent:!!v[A-3],source:v[A-2],destination:v[A]};break;case 49:this.$={type:"create",silent:!!v[A-2],graph:{type:"graph",name:v[A]}};break;case 50:this.$={updateType:"insert",insert:LF(v[A])};break;case 51:this.$={updateType:"delete",delete:WE(LF(v[A]))};break;case 52:this.$={updateType:"deletewhere",delete:WE(v[A])};break;case 53:this.$={updateType:"insertdelete",...v[A-4],...v[A-3],...dl(v[A-2],"using"),where:v[A].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=v[A];break;case 55:this.$={delete:WE(v[A-1]),insert:v[A]||[]};break;case 56:this.$={delete:[],insert:v[A]};break;case 59:this.$={graph:v[A]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:v[A]};break;case 64:this.$={[Qn(v[A])]:!0};break;case 66:this.$=v[A-1]?io(v[A],[v[A-1]]):io(v[A]);break;case 67:var vp=yr(v[A-3]||{triples:[]},{type:"graph",name:v[A-5]});this.$=v[A]?[vp,v[A]]:[vp];break;case 68:case 73:this.$={type:"bgp",triples:io(v[A-2],[v[A-1]])};break;case 69:this.$={type:"group",patterns:[v[A-1]]};break;case 70:for(let Vt of v[A-1].filter(nr=>nr.type==="bind")){let nr=v[A-1].indexOf(Vt),Tt=new Set;for(let Ft of v[A-1].slice(0,nr))(Ft.type==="group"||Ft.type==="bgp")&&FF(Ft).forEach(wi=>Tt.add(wi));if(Tt.has(Vt.variable.value))throw Error("Variable used to bind is already bound (?"+Vt.variable.value+")")}this.$={type:"group",patterns:v[A-1]};break;case 71:this.$=v[A-1]?io([v[A-1]],v[A]):io(v[A]);break;case 72:this.$=v[A]?[v[A-2],v[A]]:v[A-2];break;case 75:this.$=yr(v[A],{type:"optional"});break;case 76:this.$=yr(v[A],{type:"minus"});break;case 77:this.$=yr(v[A],{type:"graph",name:v[A-1]});break;case 78:this.$=yr(v[A],{type:"service",name:v[A-1],silent:!!v[A-2]});break;case 79:this.$={type:"filter",expression:v[A]};break;case 80:this.$={type:"bind",variable:v[A-1],expression:v[A-3]};break;case 89:this.$=Ep(v[A]);break;case 90:this.$=void 0;break;case 91:this.$=v[A-1].length?{type:"union",patterns:io(v[A-1].map(ME),[ME(v[A])])}:v[A];break;case 95:this.$={...v[A],function:v[A-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:Yo(v[A-2],v[A-1]),distinct:!!v[A-3]};break;case 98:case 115:case 128:case 247:case 249:case 251:case 253:case 255:case 263:case 267:case 297:case 299:case 303:case 307:case 328:case 341:case 349:case 355:case 361:case 367:case 369:case 373:case 375:case 379:case 381:case 385:case 391:case 395:case 401:case 405:case 409:case 411:case 420:case 428:case 430:case 440:case 444:case 446:case 448:this.$=[];break;case 99:this.$=Yo(v[A-2],v[A-1]);break;case 101:this.$=io(v[A-2],[v[A-1]]);break;case 102:case 112:this.$=qE(v[A].map(Vt=>yr(Xo(v[A-1]),Vt)));break;case 103:this.$=qE(fl(v[A].map(Vt=>yr(Xo(v[A-1].entity),Vt)),v[A-1].triples));break;case 105:this.$=io([v[A-1]],v[A]);break;case 106:this.$=io(v[A]);break;case 107:this.$=UE(v[A-1],v[A]);break;case 109:case 237:this.$=it.factory.namedNode(OV);break;case 110:case 118:this.$=Yo(v[A-1],v[A]);break;case 111:this.$=v[A]?{annotation:v[A],object:v[A-1]}:v[A-1];break;case 113:this.$=v[A]?qE(fl(v[A].map(Vt=>yr(Xo(v[A-1].entity),Vt)),v[A-1].triples)):v[A-1].triples;break;case 114:this.$=UE(...v[A-1],v[A]);break;case 116:this.$=UE(...v[A]);break;case 117:case 159:case 163:this.$=[v[A-1],v[A]];break;case 119:this.$=v[A]?{object:v[A-1],annotation:v[A]}:v[A-1];break;case 120:this.$=v[A-1].length?Nu("|",Yo(v[A-1],v[A])):v[A];break;case 121:this.$=v[A-1].length?Nu("/",Yo(v[A-1],v[A])):v[A];break;case 122:this.$=v[A]?Nu(v[A],[v[A-1]]):v[A-1];break;case 123:this.$=v[A-1]?Nu(v[A-1],[v[A]]):v[A];break;case 125:case 131:this.$=Nu(v[A-1],[v[A]]);break;case 129:this.$=Nu("|",Yo(v[A-2],v[A-1]));break;case 132:case 134:this.$=jV(v[A-1]);break;case 133:case 135:this.$=$V(v[A-1]);break;case 140:this.$={entity:v[A],triples:[]};break;case 145:this.$=NE(v[A]);break;case 149:this.$=it.factory.namedNode(TF);break;case 151:case 153:case 158:case 162:this.$=kE(v[A-1],v[A]);break;case 152:this.$=["||",v[A]];break;case 154:this.$=["&&",v[A]];break;case 156:this.$=pn(v[A-1],[v[A-2],v[A]]);break;case 157:this.$=pn(v[A-2]?"notin":"in",[v[A-3],v[A]]);break;case 160:this.$=["+",kE(v[A-1],v[A])];break;case 161:var Mg=so(v[A-1].value.replace("-",""),v[A-1].datatype);this.$=["-",kE(Mg,v[A])];break;case 164:this.$=pn("UPLUS",[v[A]]);break;case 165:this.$=pn(v[A-1],[v[A]]);break;case 166:this.$=pn("UMINUS",[v[A]]);break;case 177:this.$=pn(Qn(v[A-1]));break;case 178:this.$=pn(Qn(v[A-3]),[v[A-1]]);break;case 179:this.$=Ep(pn(Qn(v[A-3]),[v[A-1]]));break;case 180:this.$=pn(Qn(v[A-5]),[v[A-3],v[A-1]]);break;case 181:this.$=pn(Qn(v[A-7]),[v[A-5],v[A-3],v[A-1]]);break;case 182:this.$=Ep(pn(Qn(v[A-7]),[v[A-5],v[A-3],v[A-1]]));break;case 183:this.$=pn(Qn(v[A-1]),v[A]);break;case 184:this.$=pn("bound",[NE(v[A-1])]);break;case 185:this.$=pn(v[A-1],[]);break;case 186:this.$=pn(v[A-3],[v[A-1]]);break;case 187:this.$=pn(v[A-2]?"notexists":"exists",[ME(v[A])]);break;case 188:case 189:this.$=Lu(v[A-1],{type:"aggregate",aggregation:Qn(v[A-4]),distinct:!!v[A-2]});break;case 190:this.$=Lu(v[A-2],{type:"aggregate",aggregation:Qn(v[A-5]),distinct:!!v[A-3],separator:typeof v[A-1]=="string"?v[A-1]:" "});break;case 192:this.$=so(v[A]);break;case 193:this.$=LV(v[A-1],Qn(v[A].substr(1)));break;case 194:this.$=so(v[A-2],v[A]);break;case 195:case 204:this.$=so(v[A],AF);break;case 196:case 205:this.$=so(v[A],IF);break;case 197:case 206:this.$=so(Qn(v[A]),RF);break;case 200:this.$=so(v[A].toLowerCase(),DV);break;case 201:this.$=so(v[A].substr(1),AF);break;case 202:this.$=so(v[A].substr(1),IF);break;case 203:this.$=so(v[A].substr(1).toLowerCase(),RF);break;case 207:case 208:this.$=PF(v[A],1);break;case 209:case 210:this.$=PF(v[A],3);break;case 211:this.$=it.factory.namedNode(Sp(v[A]));break;case 213:var jg=v[A].indexOf(":"),Tp=v[A].substr(0,jg),$g=it.prefixes[Tp];if(!$g)throw new Error("Unknown prefix: "+Tp);var fr=Sp($g+v[A].substr(jg+1));this.$=it.factory.namedNode(fr);break;case 214:if(v[A]=v[A].substr(0,v[A].length-1),!(v[A]in it.prefixes))throw new Error("Unknown prefix: "+v[A]);var fr=Sp(it.prefixes[v[A]]);this.$=it.factory.namedNode(fr);break;case 215:this.$=wp(v[A].replace(/^(_:)/,""));break;case 216:this.$=wp();break;case 217:case 218:case 232:this.$=Ep(jE(v[A-3],v[A-2],v[A-1]));break;case 230:case 231:this.$=Ep(v[A-1]);break;case 248:case 250:case 252:case 254:case 256:case 260:case 264:case 268:case 270:case 292:case 294:case 296:case 298:case 300:case 302:case 304:case 306:case 329:case 342:case 356:case 368:case 370:case 372:case 374:case 392:case 402:case 425:case 427:case 429:case 431:case 441:case 445:case 447:case 449:v[A-1].push(v[A]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[v[A]];break;case 308:v[A-3].push(v[A-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:v[A-2].push(v[A-1]);break}},"anonymous"),table:[r(e,t,{3:1,4:2,10:3}),{1:[3]},r(n,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:i,16:i,45:i,197:i,224:i,229:i,308:i,24:[1,13],32:[1,14],36:[1,15],41:s}),r([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:o},{6:[2,239]},r(c,[2,411],{216:28,217:29}),r(l,[2,249],{18:30}),r(l,[2,251],{22:31}),r(u,[2,255],{25:32,27:33,29:[1,34]}),{13:f,16:d,33:35,39:[1,37],44:39,55:40,87:p,139:38,307:43,308:h,323:36},r(l,[2,267],{37:46}),r(g,[2,326],{98:47,103:49,106:50,117:55,130:61,100:[1,48],110:[1,51],113:[1,52],115:[1,53],116:[1,54],131:[1,62],329:[1,56],330:[1,57],331:[1,58],332:[1,59],333:[1,60]}),{39:[1,63],40:64,43:65,44:66,45:m,87:p},r(b,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),r(e,[2,248]),r(e,[2,245]),r(e,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},r([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),r(_,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:S,29:I,52:84,53:E,56:85},{19:88,28:S,29:I,52:89,53:E,56:85},r(l,[2,253],{26:90}),{28:[1,91],52:92,53:E},r(w,[2,385],{181:93,182:94,183:95,31:[2,383]}),r(R,[2,263],{34:96}),r(R,[2,261],{44:39,55:40,307:43,139:97,13:f,16:d,87:p,308:h}),r(R,[2,262]),r(x,[2,259]),r(P,[2,143]),r(P,[2,144]),r([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),r(k,[2,211]),r(k,[2,212]),r(k,[2,213]),r(k,[2,214]),{19:98,28:S,29:I,52:99,53:E,56:85},{6:[2,309],99:100,193:[1,101]},r(B,[2,311],{101:102,328:[1,103]}),r(D,[2,317],{104:104,328:[1,105]}),r(Q,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:fe,114:110},{29:fe,114:112},{29:fe,114:113},{118:114,123:[1,115],125:116,126:j},r(ce,[2,315]),r(ce,[2,316]),r(V,[2,319]),r(V,[2,320]),r(V,[2,321]),r(g,[2,327]),{13:f,16:d,55:118,307:43,308:h},r(l,[2,12]),r(l,[2,13],{44:66,43:119,45:m,87:p}),r(oe,[2,269]),r(oe,[2,15]),{13:f,16:d,44:136,45:K,46:120,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(b,[2,14]),r(b,[2,274]),r(b,[2,271]),r(b,[2,272]),r(e,[2,4]),{13:[1,177]},r(Ee,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},r(c,[2,410]),r([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:f,16:d,45:[1,193],55:194,197:Bt,219:189,220:190,223:191,224:[1,192],307:43,308:h},r(_,[2,419]),r(Kt,tt,{20:196,59:197,69:198,70:me}),r(l,[2,250]),{29:ge,57:200},r(B,[2,279],{54:202,327:[1,203]}),{29:[2,282]},r(be,we,{23:204,58:205,62:206,63:Qe}),r(l,[2,252]),{19:208,28:S,29:I,52:209,53:E,56:85},{29:[1,210]},r(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,145:212,172:221,185:213,187:214,231:fn,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(KP,[2,265],{56:85,35:227,52:228,19:229,28:S,29:I,53:E}),r(x,[2,260]),r(be,we,{58:205,62:206,23:230,63:Qe}),r(l,[2,268]),{6:[2,45]},r(e,t,{10:3,4:231}),{13:f,16:d,55:232,307:43,308:h},r(B,[2,312]),{105:233,112:YP,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},r(D,[2,318]),r(B,XP,{108:240,133:242,112:QP,132:JP}),r(Q,[2,323]),{112:[1,244]},{112:[2,325]},r(dn,[2,50]),r(w,Sg,{135:245,136:246,143:247,144:248,31:ZP,112:ZP}),r(dn,[2,51]),r(dn,[2,52]),r(ic,[2,328],{119:249}),{29:fe,114:250},r(ic,[2,56]),{29:fe,114:251},r(g,[2,59]),r(oe,[2,270]),{47:[1,252]},r(eF,[2,150]),r(wg,[2,428],{240:253}),r(xu,[2,430],{244:254}),r(xu,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),r(Ou,[2,440],{252:264}),r(Yr,[2,448],{260:265}),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,255:154,257:155,264:266,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,255:154,257:155,264:267,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,255:154,257:155,264:268,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Yr,[2,167]),r(Yr,[2,168]),r(Yr,[2,169]),r(Yr,[2,170],{176:269,45:tF,89:rF}),r(Yr,[2,171]),r(Yr,[2,172]),r(Yr,[2,173]),r(Yr,[2,174]),{13:f,16:d,44:136,45:K,46:272,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:nF,89:iF,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},r(Xn,[2,192],{292:[1,286],293:[1,287]}),r(Xn,[2,195]),r(Xn,[2,196]),r(Xn,[2,197]),r(Xn,[2,198]),r(Xn,[2,199]),r(Xn,[2,200]),{13:f,16:d,44:39,55:40,82:z,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},r(gp,[2,452]),r(gp,[2,453]),r(gp,[2,454]),r(gp,[2,455]),r(gp,[2,456]),{279:[2,458]},r(Eg,[2,207]),r(Eg,[2,208]),r(Eg,[2,209]),r(Eg,[2,210]),r(Xn,[2,201]),r(Xn,[2,202]),r(Xn,[2,203]),r(Xn,[2,204]),r(Xn,[2,205]),r(Xn,[2,206]),r(e,[2,5]),r(vg,[2,297],{88:295}),r(Tg,[2,299],{90:296}),{48:[1,297],87:[1,298]},r(Ag,[2,301]),r(Ee,[2,43]),r(Ee,[2,82]),r(Ee,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},r(c,[2,412]),r(il,[2,123]),r(il,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),r(no,[2,124]),{13:f,16:d,45:[1,311],55:194,89:[1,310],197:Bt,223:312,225:308,226:309,229:sF,307:43,308:h},r(c,i,{215:10,214:314}),r(no,[2,236]),r(no,[2,237]),r(Pu,[2,6]),r(RE,[2,287],{60:315,72:316,73:[1,317]}),r(Kt,[2,286]),{13:f,16:d,45:K,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},r([6,31,63,70,73,81,83,85],[2,20]),r(w,oF,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:qo,31:qo,85:qo,112:qo,159:qo,160:qo,161:qo,163:qo,164:qo,41:s}),{13:f,16:d,55:331,307:43,308:h},r(B,[2,280]),r(Pu,[2,7]),r(Kt,tt,{59:197,69:198,20:332,70:me}),r(be,[2,284]),{64:[1,333]},r(be,we,{58:205,62:206,23:334,63:Qe}),r(l,[2,254]),r(w,Sg,{144:248,30:335,143:336,31:[2,257]}),r(l,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:f,16:d,44:39,55:40,87:p,139:342,186:339,190:340,195:341,197:sl,307:43,308:h},r(yp,[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:sl,308:h}),r(Wo,[2,227]),r(Wo,[2,228]),r(Wo,[2,229]),{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,172:221,185:351,187:350,200:348,230:347,231:fn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},{13:f,16:d,44:39,55:40,87:p,139:342,186:352,190:340,195:341,197:sl,307:43,308:h},r(Wo,[2,146]),r(Wo,[2,147]),r(Wo,[2,148]),r(Wo,[2,149]),{13:f,16:d,44:354,55:355,82:z,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:358,312:Yn,313:353},r(CE,[2,215]),r(CE,[2,216]),r(be,we,{58:205,62:206,23:359,63:Qe}),r(R,[2,264]),r(KP,[2,266]),r(Pu,[2,11]),r(n,[2,308],{6:[2,310]}),r(dn,[2,313],{102:360,120:361,121:[1,362]}),r(dn,[2,47]),r(dn,[2,63]),r(dn,[2,64]),{13:f,16:d,55:363,307:43,308:h},r(dn,[2,336]),r(dn,[2,337]),r(dn,[2,338]),{109:[1,364]},r(aF,[2,60]),{13:f,16:d,55:365,307:43,308:h},r(B,[2,335]),{13:f,16:d,55:366,307:43,308:h},{31:[1,367]},r(ol,[2,341],{137:368}),r(ol,[2,340]),{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,145:369,172:221,185:213,187:214,231:fn,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},{28:[1,370],127:371,128:[1,372]},r(ic,[2,330],{124:373,125:374,126:j}),r(ic,[2,57]),{44:375,87:p},r(eF,[2,151],{241:376,242:[1,377]}),r(wg,[2,153],{245:378,246:[1,379]}),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,247:380,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{250:[1,381]},r(Ir,[2,432]),r(Ir,[2,433]),r(Ir,[2,434]),r(Ir,[2,435]),r(Ir,[2,436]),r(Ir,[2,437]),{250:[2,439]},r([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe}),r(Ou,[2,162],{261:388,262:389,39:xE,338:OE}),r(Yr,[2,164]),r(Yr,[2,165]),r(Yr,[2,166]),r(Ar,[2,95]),r(Ar,[2,96]),r(Ir,[2,377],{177:392,325:[1,393]}),{48:[1,394]},r(Ar,[2,177]),{13:f,16:d,44:136,45:K,46:395,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:396,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:397,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:398,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:399,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,183]),r(Ar,[2,98]),r(Ir,[2,381],{180:400}),{87:[1,401]},r(Ar,[2,185]),{13:f,16:d,44:136,45:K,46:402,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{29:ge,57:403},r(Xn,[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:sl,307:43,308:h},r(sc,[2,233]),r(sc,[2,234]),r(sc,[2,235]),r(cF,[2,459],{281:406,325:[1,407]}),r(Ir,[2,463],{284:408,325:[1,409]}),r(Ir,[2,465],{286:410,325:[1,411]}),{13:f,16:d,31:[1,412],55:414,82:z,171:413,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},{31:[1,419],89:[1,420]},{29:[1,421]},r(Ag,[2,302]),r(vg,[2,367],{167:422}),r(Tg,[2,369],{168:423}),{48:[1,424],87:[1,425]},r(Ag,[2,371]),r(il,[2,122]),r(il,[2,417]),r(il,[2,413]),r(il,[2,414]),r(il,[2,415]),r(no,[2,125]),r(no,[2,127]),r(no,[2,128]),r(lF,[2,420],{227:426}),r(no,[2,130]),{13:f,16:d,55:194,197:Bt,223:427,307:43,308:h},{48:[1,428]},r(oc,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),r(RE,[2,288]),{64:[1,433]},r(Kt,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:f,16:d,45:K,268:Y,269:se,270:X,271:le,273:Ue,274:$,276:de,277:ie,279:Ae,280:ye,283:ve,285:Re,308:h,346:nt,347:et,348:C,349:O,350:L,351:W}),r(uF,[2,293]),r(PE,[2,92]),r(PE,[2,93]),r(PE,[2,94]),{45:tF,89:rF,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:S,29:I,56:85},{19:438,28:S,29:I,56:85},r(al,[2,355],{149:439}),r(al,[2,354]),{13:f,16:d,44:215,45:Cg,55:220,82:z,87:p,89:vt,156:440,172:221,185:441,203:442,231:xg,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(R,[2,19]),r(oc,[2,21]),{13:f,16:d,44:450,45:fF,55:323,65:445,66:446,67:447,68:448,87:p,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},r(Pu,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},r(w,[2,386],{31:[2,388]}),r(yp,[2,102]),r(cl,[2,391],{191:452}),r(w,[2,395],{196:453,198:454}),r(w,[2,108]),r(w,[2,109]),r(yp,[2,103]),r(yp,[2,104]),r(yp,[2,390]),{13:f,16:d,44:215,45:Et,48:[1,455],55:220,82:z,87:p,89:vt,172:221,185:351,187:350,200:456,231:fn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(Og,[2,424]),r(dF,[2,136]),r(dF,[2,137]),r(FE,[2,140]),{232:[1,457]},{13:f,16:d,44:39,55:40,87:p,139:342,195:458,197:sl,307:43,308:h},r(sc,[2,219]),r(sc,[2,220]),r(sc,[2,221]),r(sc,[2,222]),r(sc,[2,223]),r(Pu,[2,10]),r(dn,[2,46]),r(dn,[2,314]),{112:YP,122:459},r(dn,[2,62]),r(B,XP,{133:242,108:460,112:QP,132:JP}),r(aF,[2,61]),r(dn,[2,49]),r([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},r(ol,[2,351],{146:463,335:[1,464]}),{29:ge,57:465},r(ic,[2,329]),r(B,[2,332],{129:466,327:[1,467]}),r(ic,[2,55]),r(ic,[2,331]),{48:[1,468]},r(wg,[2,429]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(xu,[2,431]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,243:470,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(xu,[2,156]),{45:nF,89:iF,179:471},r(Ou,[2,441]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,251:472,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Yr,[2,444],{256:473}),r(Yr,[2,446],{258:474}),r(Ir,[2,442]),r(Ir,[2,443]),r(Yr,[2,449]),{13:f,16:d,44:136,45:K,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,255:154,257:155,259:475,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ir,[2,450]),r(Ir,[2,451]),r(Ir,[2,379],{178:476}),r(Ir,[2,378]),r([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:f,16:d,44:136,45:K,46:482,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{48:[1,483]},{48:[1,484]},r(Ar,[2,187]),r(Xn,[2,194]),{13:f,16:d,44:39,55:40,82:z,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,320:485},{13:f,16:d,39:[1,487],44:136,45:K,46:488,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,282:486,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(cF,[2,460]),{13:f,16:d,44:136,45:K,46:489,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ir,[2,464]),{13:f,16:d,44:136,45:K,46:490,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ir,[2,466]),r(Ee,[2,40]),r(vg,[2,298]),r(bp,[2,87]),r(bp,[2,88]),r(bp,[2,89]),r(bp,[2,90]),{13:f,16:d,55:492,82:z,172:493,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,311:494,312:Yn,315:491},r(Ee,[2,41]),r(Tg,[2,300]),r(_p,[2,303],{92:495}),{13:f,16:d,31:[1,496],55:414,82:z,171:497,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},{31:[1,498],89:[1,499]},{29:[1,500]},r(Ag,[2,372]),{13:f,16:d,48:[2,422],55:194,197:Bt,223:312,226:502,228:501,229:sF,307:43,308:h},r(no,[2,131]),r(no,[2,126]),r(oc,[2,22]),r(oc,[2,290]),{82:[1,503]},{82:[1,504]},{13:f,16:d,44:510,45:K,55:323,67:321,68:322,74:505,75:506,76:pF,77:320,78:hF,79:509,87:p,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},r(uF,[2,294]),r(mF,[2,69]),r(mF,[2,70]),r(Kt,tt,{59:197,69:198,20:511,70:me}),r(be,we,{58:205,62:206,23:512,63:Qe}),{29:[2,375],31:[2,71],84:522,85:o,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},r(al,[2,363],{157:524,335:[1,525]}),r(c,i,{215:10,202:526,205:527,208:528,214:529,44:530,87:p}),r(Pg,[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:Cg,55:220,82:z,87:p,89:vt,172:221,185:351,203:536,212:534,231:xg,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(c,i,{215:10,205:527,208:528,214:529,44:530,202:537,87:p}),r(be,[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:fF,87:p,268:Y,269:se,270:X,271:le,273:Ue,274:$,276:de,277:ie,279:Ae,280:ye,283:ve,285:Re,308:h,346:nt,347:et,348:C,349:O,350:L,351:W}),r(ll,[2,291]),r(ll,[2,24]),r(ll,[2,25]),{13:f,16:d,44:136,45:K,46:539,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(ll,[2,28]),r(be,we,{58:205,62:206,23:540,63:Qe}),r([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),r(cl,[2,107]),{13:f,16:d,44:215,45:Et,55:220,82:z,87:p,89:vt,172:221,185:351,187:350,199:543,200:544,231:fn,234:349,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(gF,[2,132]),r(Og,[2,425]),r(gF,[2,133]),{13:f,16:d,44:354,55:355,82:z,87:p,172:357,237:356,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:358,312:Yn,313:545},r(dn,[2,54]),r(dn,[2,48]),r(ol,[2,342]),{13:f,16:d,44:39,55:40,87:p,139:546,307:43,308:h},r(ol,[2,68]),r(w,[2,350],{31:yF,112:yF}),r(dn,[2,53]),{13:f,16:d,55:547,307:43,308:h},r(B,[2,333]),r(oe,[2,16]),r(wg,[2,152]),r(xu,[2,154]),r(xu,[2,157]),r(Ou,[2,159]),r(Ou,[2,160],{262:389,261:548,39:xE,338:OE}),r(Ou,[2,161],{262:389,261:549,39:xE,338:OE}),r(Yr,[2,163]),{13:f,16:d,44:136,45:K,46:550,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,178]),r(Ar,[2,179]),{13:f,16:d,44:136,45:K,46:551,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:552,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:553,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{48:[1,554],272:[1,555]},r(Ar,[2,184]),r(Ar,[2,186]),{314:[1,556]},{48:[1,557]},{48:[2,461]},{48:[2,462]},{48:[1,558]},{48:[2,467],193:[1,561],287:559,288:560},{13:f,16:d,55:194,197:Bt,223:562,307:43,308:h},r(DE,[2,224]),r(DE,[2,225]),r(DE,[2,226]),{31:[1,563],45:bF,94:564},r(Ee,[2,84]),r(vg,[2,368]),r(Ee,[2,85]),r(Tg,[2,370]),r(_p,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},r(oc,[2,35],{83:[1,569]}),r(oc,[2,36],{81:[1,570]}),r(RE,[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:K,76:pF,78:hF,87:p,268:Y,269:se,270:X,271:le,273:Ue,274:$,276:de,277:ie,279:Ae,280:ye,283:ve,285:Re,308:h,346:nt,347:et,348:C,349:O,350:L,351:W}),r(Fu,[2,295]),{45:K,77:572},{45:K,77:573},r(Fu,[2,33]),r(Fu,[2,34]),{31:[2,275],50:574,84:575,85:o},{31:[2,277],51:576,84:577,85:o},r(al,[2,356]),r(_F,[2,357],{152:578,335:[1,579]}),r(zo,[2,74]),{29:ge,57:580},{29:ge,57:581},{13:f,16:d,44:39,55:40,87:p,139:582,307:43,308:h},r(SF,[2,365],{162:583,328:[1,584]}),{13:f,16:d,45:K,55:323,67:321,68:322,77:320,79:585,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,307:43,308:h,346:nt,347:et,348:C,349:O,350:L,351:W},{45:[1,586]},r(zo,[2,81]),{29:ge,57:587},r(al,[2,73]),r(w,[2,362],{29:Ho,31:Ho,85:Ho,112:Ho,159:Ho,160:Ho,161:Ho,163:Ho,164:Ho}),r(Pg,[2,112]),r(Du,[2,401],{206:588}),r(w,[2,405],{209:589,210:590}),r(w,[2,403]),r(w,[2,404]),r(Pg,[2,113]),r(Pg,[2,400]),{13:f,16:d,44:215,45:Cg,48:[1,591],55:220,82:z,87:p,89:vt,172:221,185:351,203:536,212:592,231:xg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(Og,[2,426]),r(FE,[2,138]),r(FE,[2,139]),{232:[1,593]},r(ll,[2,292]),{47:[1,595],48:[1,594]},r(Pu,[2,9]),r(cl,[2,392]),r(cl,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:f,16:d,87:p,197:sl,308:h}),r(cl,[2,110],{272:[1,598]}),r(Fg,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},r(ic,[2,58]),r(Yr,[2,445]),r(Yr,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},r(Ar,[2,99]),r(Ir,[2,382]),r([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),r(Ar,[2,188]),r(Ar,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:f,16:d,55:492,82:z,172:493,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,311:494,312:Yn,315:611},r(Ee,[2,42]),r(_p,[2,304]),{13:f,16:d,55:414,82:z,95:612,171:613,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},{31:[1,614],45:bF,94:615},r(no,[2,129]),r(lF,[2,421]),{82:[1,616]},{82:[1,617]},r(Fu,[2,296]),r(Fu,[2,31]),r(Fu,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},r(w,oF,{155:330,153:618,154:619,29:Ko,31:Ko,85:Ko,112:Ko,159:Ko,160:Ko,161:Ko,163:Ko,164:Ko}),r(_F,[2,358]),r(zo,[2,75]),r(zo,[2,76]),{29:ge,57:620},{13:f,16:d,44:39,55:40,87:p,139:621,307:43,308:h},r(SF,[2,366]),r(zo,[2,79]),{13:f,16:d,44:136,45:K,46:622,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(zo,[2,91],{336:[1,623]}),r([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),r(Du,[2,117]),{13:f,16:d,44:215,45:Cg,55:220,82:z,87:p,89:vt,172:221,185:351,203:536,211:626,212:627,231:xg,234:535,236:216,237:222,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,309:Si,310:Bi,311:217,312:Yn},r(Wo,[2,134]),r(Og,[2,427]),r(Wo,[2,135]),r(ll,[2,26]),{44:628,87:p},r(cl,[2,106]),r(cl,[2,394]),r(w,[2,396]),r(Fg,[2,111]),r(Fg,[2,398]),{13:f,16:d,44:39,55:40,87:p,139:342,186:629,190:340,195:341,197:sl,307:43,308:h},r(CE,[2,217]),r(w,Sg,{144:248,140:630,143:631,31:[2,343]}),r(Ar,[2,97]),r(Ir,[2,380]),r(Ar,[2,180]),{13:f,16:d,44:136,45:K,46:632,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},{13:f,16:d,44:136,45:K,46:633,55:133,67:132,68:134,77:131,82:z,87:p,172:135,224:Z,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:Ie,264:130,265:ee,266:137,267:139,268:Y,269:se,270:X,271:le,273:Ue,274:$,275:146,276:de,277:ie,278:149,279:Ae,280:ye,283:ve,285:Re,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Ze,346:nt,347:et,348:C,349:O,350:L,351:W},r(Ar,[2,190]),{290:[1,634]},{314:[1,635]},{13:f,16:d,48:[1,636],55:414,82:z,171:637,172:415,173:416,174:Ig,255:154,257:155,291:150,294:pe,295:U,296:F,297:H,298:ae,299:Se,300:Ce,301:qe,302:Fe,303:De,304:We,305:xe,306:Be,307:43,308:h,312:Rg},r(wF,[2,305]),r(Ee,[2,86]),r(_p,[2,374]),r(oc,[2,37]),r(oc,[2,38]),r(al,[2,72]),r(al,[2,360]),r(zo,[2,77]),{29:ge,57:638},{47:[1,639]},{29:[2,376]},r(Du,[2,402]),r(Du,[2,115],{215:10,208:528,214:529,44:530,205:640,13:i,16:i,45:i,197:i,224:i,229:i,308:i,87:p}),r(Du,[2,118],{272:[1,641]}),r(Dg,[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:De,304:We,305:xe,306:Be},r(bp,[2,218]),r(_p,[2,44]),r(wF,[2,306]),r(zo,[2,78]),{44:651,87:p},r(Du,[2,116]),r(w,[2,406]),r(Dg,[2,119]),r(Dg,[2,408]),r(c,i,{215:10,205:527,208:528,214:529,44:530,202:652,87:p}),r(ll,[2,27]),r(Fg,[2,230]),r(EF,[2,345],{141:653,335:[1,654]}),r(Ar,[2,181]),r(Ar,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},r(w,Sg,{144:248,142:657,143:658,31:vF,112:vF}),r(EF,[2,346]),r(zo,[2,80]),r(Dg,[2,231]),r(ol,[2,67]),r(ol,[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(N,G){if(G.recoverable)this.trace(N);else{var J=new Error(N);throw J.hash=G,J}},"parseError"),parse:a(function(N){var G=this,J=[0],Pe=[],Je=[null],v=[],Jn=this.table,A="",oo=0,vp=0,Mg=0,jg=2,Tp=1,$g=v.slice.call(arguments,1),fr=Object.create(this.lexer),ao={yy:{}};for(var Ap in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Ap)&&(ao.yy[Ap]=this.yy[Ap]);fr.setInput(N,ao.yy),ao.yy.lexer=fr,ao.yy.parser=this,typeof fr.yylloc>"u"&&(fr.yylloc={});var ju=fr.yylloc;v.push(ju);var Vt=fr.options&&fr.options.ranges;typeof ao.yy.parseError=="function"?this.parseError=ao.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function nr(co){J.length=J.length-2*co,Je.length=Je.length-co,v.length=v.length-co}a(nr,"popStack");for(var Tt=a(function(){var co;return co=fr.lex()||Tp,typeof co!="number"&&(co=G.symbols_[co]||co),co},"lex"),Ft,wi,pl,rs,sSe,zE,$u={},Ug,Qo,NF,Bg;;){if(pl=J[J.length-1],this.defaultActions[pl]?rs=this.defaultActions[pl]:((Ft===null||typeof Ft>"u")&&(Ft=Tt()),rs=Jn[pl]&&Jn[pl][Ft]),typeof rs>"u"||!rs.length||!rs[0]){var HE="";Bg=[];for(Ug in Jn[pl])this.terminals_[Ug]&&Ug>jg&&Bg.push("'"+this.terminals_[Ug]+"'");fr.showPosition?HE="Parse error on line "+(oo+1)+`:
|
|
80
80
|
`+fr.showPosition()+`
|
|
81
81
|
Expecting `+Bg.join(", ")+", got '"+(this.terminals_[Ft]||Ft)+"'":HE="Parse error on line "+(oo+1)+": Unexpected "+(Ft==Tp?"end of input":"'"+(this.terminals_[Ft]||Ft)+"'"),this.parseError(HE,{text:fr.match,token:this.terminals_[Ft]||Ft,line:fr.yylineno,loc:ju,expected:Bg})}if(rs[0]instanceof Array&&rs.length>1)throw new Error("Parse Error: multiple actions possible at state: "+pl+", token: "+Ft);switch(rs[0]){case 1:J.push(Ft),Je.push(fr.yytext),v.push(fr.yylloc),J.push(rs[1]),Ft=null,wi?(Ft=wi,wi=null):(vp=fr.yyleng,A=fr.yytext,oo=fr.yylineno,ju=fr.yylloc,Mg>0&&Mg--);break;case 2:if(Qo=this.productions_[rs[1]][1],$u.$=Je[Je.length-Qo],$u._$={first_line:v[v.length-(Qo||1)].first_line,last_line:v[v.length-1].last_line,first_column:v[v.length-(Qo||1)].first_column,last_column:v[v.length-1].last_column},Vt&&($u._$.range=[v[v.length-(Qo||1)].range[0],v[v.length-1].range[1]]),zE=this.performAction.apply($u,[A,vp,oo,ao.yy,rs[1],Je,v].concat($g)),typeof zE<"u")return zE;Qo&&(J=J.slice(0,-1*Qo*2),Je=Je.slice(0,-1*Qo),v=v.slice(0,-1*Qo)),J.push(this.productions_[rs[1]][0]),Je.push($u.$),v.push($u._$),NF=Jn[J[J.length-2]][J[J.length-1]],J.push(NF);break;case 3:return!0}}return!0},"parse")},Lg=dT().Wildcard,Ng="http://www.w3.org/1999/02/22-rdf-syntax-ns#",OV=Ng+"type",PV=Ng+"first",FV=Ng+"rest",TF=Ng+"nil",kg="http://www.w3.org/2001/XMLSchema#",AF=kg+"integer",IF=kg+"decimal",RF=kg+"double",DV=kg+"boolean",ul="",CF="",xF="";function Qn(M){return M.toLowerCase()}a(Qn,"lowercase");function Yo(M,N){return M.push(N),M}a(Yo,"appendTo");function fl(M,N){return M.push.apply(M,N),M}a(fl,"appendAllTo");function yr(M){M||(M={});for(var N=1,G=arguments.length,J;N<G&&(J=arguments[N]||{});N++)for(var Pe in J)M[Pe]=J[Pe];return M}a(yr,"extend");function io(){for(var M=[],N=0,G=arguments.length;N<G;N++)M=M.concat.apply(M,arguments[N]);return M}a(io,"unionAll");function Sp(M){if(M[0]==="<"&&(M=M.substring(1,M.length-1)),/^[a-z][a-z0-9.+-]*:/i.test(M))return M;if(!it.base)throw new Error("Cannot resolve relative IRI "+M+" because no base IRI was set.");switch(ul!==it.base&&(ul=it.base,CF=ul.replace(/[^\/:]*$/,""),xF=ul.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),M[0]){case void 0:return ul;case"#":return ul+M;case"?":return ul.replace(/(?:\?.*)?$/,M);case"/":return xF+M;default:return CF+M}}a(Sp,"resolveIRI");function NE(M){if(M){var N=M[0];if(N==="?"||N==="$")return it.factory.variable(M.substr(1))}return M}a(NE,"toVar");function pn(M,N){return{type:"operation",operator:M,args:N||[]}}a(pn,"operation");function Lu(M,N){var G={expression:M==="*"?new Lg:M};if(N)for(var J in N)G[J]=N[J];return G}a(Lu,"expression");function Nu(M,N){return{type:"path",pathType:M,items:N}}a(Nu,"path");function kE(M,N){for(var G=0,J=N.length,Pe;G<J&&(Pe=N[G]);G++)M=pn(Pe[0],[M,Pe[1]]);return M}a(kE,"createOperationTree");function dl(M,N){var G=[],J=[],Pe=M.length,Je,v={};if(!Pe)return null;for(var Jn=0;Jn<Pe&&(Je=M[Jn]);Jn++)(Je.named?J:G).push(Je.iri);return v[N||"from"]={default:G,named:J},v}a(dl,"groupDatasets");function ku(M){return parseInt(M,10)}a(ku,"toInt");function ME(M){return M.type==="group"&&M.patterns.length===1?M.patterns[0]:M}a(ME,"degroupSingle");function so(M,N){return N&&N.termType!=="NamedNode"&&(N=it.factory.namedNode(N)),it.factory.literal(M,N)}a(so,"createTypedLiteral");function LV(M,N){return it.factory.literal(M,N)}a(LV,"createLangLiteral");function jE(M,N,G){if(!("termType"in N))throw new Error("Nested triples cannot contain paths");return it.factory.quad(M,N,G)}a(jE,"nestedTriple");function Xo(M,N,G,J){var Pe={};return M!=null&&(Pe.subject=M),N!=null&&(Pe.predicate=N),G!=null&&(Pe.object=G),J!=null&&(Pe.annotations=J),Pe}a(Xo,"triple");function wp(M){return typeof M=="string"?M.startsWith("e_")?it.factory.blankNode(M):it.factory.blankNode("e_"+M):it.factory.blankNode("g_"+OF++)}a(wp,"blank");var OF=0;it._resetBlanks=function(){OF=0};var NV=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,kV={"\\":"\\","'":"'",'"':'"',t:" ",b:"\b",n:`
|
|
82
82
|
`,r:"\r",f:"\f"},MV=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,$E=String.fromCharCode;function PF(M,N){M=M.substring(N,M.length-N);try{M=M.replace(NV,function(G,J,Pe,Je){var v;if(J){if(v=parseInt(J,16),isNaN(v))throw new Error;return $E(v)}else if(Pe){if(v=parseInt(Pe,16),isNaN(v))throw new Error;return v<65535?$E(v):$E(55296+((v-=65536)>>10),56320+(v&1023))}else{var Jn=kV[Je];if(!Jn)throw new Error;return Jn}})}catch{return""}if(MV.exec(M))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+M);return M}a(PF,"unescapeString");function jV(M){var N=wp(),G=N,J=[],Pe,Je=[];M.forEach(function(oo){J.push(oo.entity),fl(Je,oo.triples)});for(var v=0,Jn=0,A=J.length,Pe=Array(A*2);v<A;)Pe[Jn++]=Xo(G,it.factory.namedNode(PV),J[v]),Pe[Jn++]=Xo(G,it.factory.namedNode(FV),G=++v<A?wp():it.factory.namedNode(TF));return{entity:N,triples:fl(Pe,Je)}}a(jV,"createList");function $V(M){var N=wp();return{entity:N,triples:M.map(function(G){return yr(Xo(N),G)})}}a($V,"createAnonymousObject");function UE(M,N,G){var J=[],Pe=[];return N.forEach(function(Je){let v=null;Je.annotation&&(v=Je.annotation,Je=Je.object),J.push(Xo(null,M,Je.entity,v)),fl(Pe,Je.triples)}),io(J,G||[],Pe)}a(UE,"objectListToTriples");function nSe(M){for(var N=[],G,J=0,Pe;Pe=M[J];J++)Pe.type==="bgp"?Pe.triples.length&&(G?fl(G.triples,Pe.triples):Yo(N,G=Pe)):(!Pe.patterns||Pe.patterns.length>0)&&(Yo(N,Pe),G=null);return N}a(nSe,"mergeAdjacentBGPs");function Mu(M){return M.variable?M.variable.value:M.value||M.expression.value}a(Mu,"getExpressionId");function BE(M){if(!M)return[];if(M.type==="aggregate")return[M];if(M.type==="operation"){let N=[];for(let G of M.args)N.push(...BE(G));return N}return[]}a(BE,"getAggregatesOfExpression");function UV(M){let N=new Set,G=a(function(J){J&&(J.termType==="Variable"?N.add(J):J.type==="operation"&&J.args.forEach(G))},"visitExpression");return G(M),N}a(UV,"getVariablesFromExpression");function VE(M,N=1,G=[]){for(let J of M)N>0&&J instanceof Array?VE(J,N-1,G):G.push(J);return G}a(VE,"flatten");function GE(M){return M.termType==="Variable"}a(GE,"isVariable");function FF(M){if(M.triples){let N=[];for(let G of M.triples)GE(G.subject)&&N.push(G.subject.value),GE(G.predicate)&&N.push(G.predicate.value),GE(G.object)&&N.push(G.object.value);return N}else if(M.patterns){let N=[];for(let G of M.patterns)N.push(...FF(G));return N}return[]}a(FF,"getBoundVarsFromGroupGraphPattern");function BV(M){let N=M.slice().sort(),G=[];for(let J=0;J<N.length-1;J++)N[J+1]==N[J]&&G.push(N[J]);return G}a(BV,"getDuplicatesInArray");function Ep(M){if(!it.sparqlStar)throw new Error("SPARQL-star support is not enabled");return M}a(Ep,"ensureSparqlStar");function DF(M,N,G){for(let J of N){let Pe=Xo("subject"in J?J.subject:M,J.predicate,J.object);G.push(Pe),J.annotations&&DF(jE(M,J.predicate,J.object),J.annotations,G)}}a(DF,"_applyAnnotations");function qE(M){if(it.sparqlStar){let N=[];return M.forEach(G=>{let J=Xo(G.subject,G.predicate,G.object);N.push(J),G.annotations&&DF(jE(G.subject,G.predicate,G.object),G.annotations,N)}),N}return M}a(qE,"applyAnnotations");function iSe(M){if(!it.sparqlStarNestedQuads)throw new Error("Lenient SPARQL-star support with nested quads is not enabled");return M}a(iSe,"ensureSparqlStarNestedQuads");function LF(M){for(let N of M){if(N.type==="graph"&&N.name.termType==="Variable")throw new Error("Detected illegal variable in GRAPH");if(N.type==="bgp"||N.type==="graph"){for(let G of N.triples)if(G.subject.termType==="Variable"||G.predicate.termType==="Variable"||G.object.termType==="Variable")throw new Error("Detected illegal variable in BGP")}}return M}a(LF,"ensureNoVariables");function WE(M){for(let N of M)if(N.type==="bgp"){for(let G of N.triples)if(G.subject.termType==="BlankNode"||G.predicate.termType==="BlankNode"||G.object.termType==="BlankNode")throw new Error("Detected illegal blank node in BGP")}return M}a(WE,"ensureNoBnodes");var VV=(function(){var M={EOF:1,parseError:a(function(G,J){if(this.yy.parser)this.yy.parser.parseError(G,J);else throw new Error(G)},"parseError"),setInput:a(function(N,G){return this.yy=G||this.yy||{},this._input=N,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 N=this._input[0];this.yytext+=N,this.yyleng++,this.offset++,this.match+=N,this.matched+=N;var G=N.match(/(?:\r\n?|\n).*/g);return G?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),N},"input"),unput:a(function(N){var G=N.length,J=N.split(/(?:\r\n?|\n)/g);this._input=N+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-G),this.offset-=G;var Pe=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),J.length-1&&(this.yylineno-=J.length-1);var Je=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:J?(J.length===Pe.length?this.yylloc.first_column:0)+Pe[Pe.length-J.length].length-J[0].length:this.yylloc.first_column-G},this.options.ranges&&(this.yylloc.range=[Je[0],Je[0]+this.yyleng-G]),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).
|
|
@@ -113,7 +113,7 @@ ${n}}`}default:throw new Df(`Unsupported operation type for SPARQL generation: $
|
|
|
113
113
|
`)}generateTriple(e){let t=this.generateElement(e.subject),n=this.generatePredicate(e.predicate),i=this.generateElement(e.object);return`${t} ${n} ${i}`}generatePredicate(e){return"pathType"in e?this.generatePropertyPath(e):this.generateElement(e)}generatePropertyPath(e){let t=e.items.map(n=>"pathType"in n?`(${this.generatePropertyPath(n)})`:`<${n.value}>`);switch(e.pathType){case"/":return t.join("/");case"|":return t.join("|");case"^":return`^${t[0]}`;case"+":return`${t[0]}+`;case"*":return`${t[0]}*`;case"?":return`${t[0]}?`}}generateElement(e){switch(e.type){case"variable":return`?${e.value}`;case"iri":return`<${e.value}>`;case"literal":{let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}case"blank":return`_:${e.value}`;default:throw new Df(`Unknown element type: ${e.type}`)}}generateValues(e,t){let n=" ".repeat(t);if(e.variables.length===0||e.bindings.length===0)return"";if(e.variables.length===1){let o=e.variables[0],c=e.bindings.map(l=>{let u=l[o];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ");return`${n}VALUES ?${o} { ${c} }`}let i=e.variables.map(o=>`?${o}`).join(" "),s=e.bindings.map(o=>`(${e.variables.map(l=>{let u=o[l];return u?this.generateValuesTerm(u):"UNDEF"}).join(" ")})`);return`${n}VALUES (${i}) {
|
|
114
114
|
${s.map(o=>`${n} ${o}`).join(`
|
|
115
115
|
`)}
|
|
116
|
-
${n}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(n=>this.generateExpression(n)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),n=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${n})`:`${t} IN (${n})`}default:throw new Df(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let n of e.triples)this.collectVariablesFromTriple(n,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let n of e.variables)t.add(n);break;case"project":for(let n of e.variables)t.add(n);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let n of e.variables)t.add(n);for(let n of e.aggregates)t.add(n.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let n of e.operands)this.collectVariablesFromExpression(n,t);break;case"function":case"functionCall":for(let n of e.args)this.collectVariablesFromExpression(n,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let n of e.list)this.collectVariablesFromExpression(n,t);break}}};Lf.SPARQLGenerator=IA});var kf=T(Oi=>{"use strict";var aQ=Oi&&Oi.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),cQ=Oi&&Oi.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),YN=Oi&&Oi.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&aQ(t,e,n[i]);return cQ(t,e),t}})();Object.defineProperty(Oi,"__esModule",{value:!0});Oi.QueryExecutor=Oi.ExoQLQueryExecutor=Oi.QueryExecutorError=void 0;var lQ=KT(),uQ=G0(),fQ=pA(),dQ=mA(),pQ=LN(),hQ=kN(),mQ=UN(),gQ=vA(),yQ=VN(),bQ=qN(),_Q=HN(),SQ=KN(),wQ=Le(),EQ=Ye(),vQ=k0(),wn="http://www.w3.org/2001/XMLSchema#",TQ=new Set([`${wn}integer`,`${wn}decimal`,`${wn}float`,`${wn}double`,`${wn}nonPositiveInteger`,`${wn}negativeInteger`,`${wn}long`,`${wn}int`,`${wn}short`,`${wn}byte`,`${wn}nonNegativeInteger`,`${wn}unsignedLong`,`${wn}unsignedInt`,`${wn}unsignedShort`,`${wn}unsignedByte`,`${wn}positiveInteger`]),Nf=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};Oi.QueryExecutorError=Nf;var Q0=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let n=t.resolveClassHierarchy===!1?e:new _Q.ClassHierarchyResolvingStore(e);this.tripleStore=n,this.bgpExecutor=new lQ.BGPExecutor(n),this.filterExecutor=new uQ.FilterExecutor,this.optionalExecutor=new fQ.OptionalExecutor,this.unionExecutor=new dQ.UnionExecutor,this.minusExecutor=new pQ.MinusExecutor,this.valuesExecutor=new hQ.ValuesExecutor,this.aggregateExecutor=new mQ.AggregateExecutor,this.constructExecutor=new gQ.ConstructExecutor,this.serviceExecutor=new yQ.ServiceExecutor(t.serviceConfig),this.graphExecutor=new bQ.GraphExecutor(n),this.sparqlGenerator=new SQ.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(n)}async evaluateExistsPattern(e,t){let n=this.substituteVariables(e,t);for await(let i of this.execute(n))if(t.merge(i)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let n of this.execute(e))t.push(n);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new Nf(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let n=new Set;for(let o of t)for(let c of o.variables())n.add(c);let i=this.collectOperationVariables(e.right);if([...n].some(o=>i.has(o)))for(let o of t){let c=this.substituteVariables(e.right,o);for await(let l of this.execute(c)){let u=o.merge(l);u!==null&&(yield u)}}else{let o=[];for await(let c of this.execute(e.right))o.push(c);for(let c of t)for(let l of o){let u=c.merge(l);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>YN(ua())),n=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(n.has(o)){let c=i.get(o);c!==void 0&&s.set(o,c)}yield s}}async*executeOrderBy(e){let t=[];for await(let n of this.execute(e.input))t.push(n);t.sort((n,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,n),c=this.getExpressionValue(s.expression,i),l=0;if(o===void 0&&c===void 0?l=0:o===void 0?l=1:c===void 0?l=-1:typeof o=="number"&&typeof c=="number"?l=o-c:l=String(o).localeCompare(String(c)),s.descending&&(l=-l),l!==0)return l}return 0});for(let n of t)yield n}async*executeSlice(e){let t=0,n=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=n){if(i!==void 0&&t-n>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeReduced(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let n=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of n)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of n)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let n of this.execute(e.input)){let i=n.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,n):this.evaluateExtendExpression(e.expression,n);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let n of this.execute(e.left))t.push(n);for(let n of t){let i=this.substituteVariables(e.right,n);for await(let s of this.execute(i)){let o=n.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let n=JSON.parse(JSON.stringify(e));return this.substituteInOperation(n,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let n=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(n.input&&(n.input=this.substituteInOperation(n.input,t)),n.left&&(n.left=this.substituteInOperation(n.left,t)),n.right&&(n.right=this.substituteInOperation(n.right,t)),n.pattern&&(n.pattern=this.substituteInOperation(n.pattern,t)),n.query&&(n.query=this.substituteInOperation(n.query,t)),n.where&&(n.where=this.substituteInOperation(n.where,t)),n.expression&&this.substituteInExpression(n.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.type==="variable"&&typeof e.name=="string"){let n=this.termToAlgebraNode(t.get(e.name));if(n!==null){delete e.name;for(let[i,s]of Object.entries(n))e[i]=s}}if(e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let n of e.operands)this.substituteInExpression(n,t);if(e.args)for(let n of e.args)this.substituteInExpression(n,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let n of e.list)this.substituteInExpression(n,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let n=this.termToAlgebraNode(t.get(e.value));if(n!==null)return n}return e}termToAlgebraNode(e){if(e==null)return null;let t=e;return e instanceof wQ.IRI||t.termType==="NamedNode"?{type:"iri",value:e.value}:t.termType==="Literal"||typeof t.value=="string"?{type:"literal",value:t.value,datatype:t.datatype?.value??t._datatype?.value,language:t.language??t._language}:null}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(n,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{n.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(n,i):yield*this.execute(n)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:n}=await Promise.resolve().then(()=>YN(ua()));yield new n;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let n=t.get(e.name);if(!n)return;if(n instanceof EQ.Literal){let i=n.datatype?.value;if(i===`${wn}dayTimeDuration`)try{return vQ.DateTimeFunctions.parseDayTimeDuration(n.value)}catch{return n.value}if(i&&TQ.has(i)){let s=parseFloat(n.value);if(!Number.isNaN(s))return s}return n.value}return n.value??n.id??String(n)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="bgp"&&n.triples)for(let i of n.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(n.type==="values"&&n.variables)for(let i of n.variables)t.add(i);n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.type==="extend"&&n.variable&&t.add(n.variable),n.input&&this.collectVarsFromOperation(n.input,t),n.left&&this.collectVarsFromOperation(n.left,t),n.right&&this.collectVarsFromOperation(n.right,t),n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.query&&this.collectVarsFromOperation(n.query,t),n.where&&this.collectVarsFromOperation(n.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let n=e;n.type==="variable"&&t.add(n.value),n.type==="quoted"&&(this.collectVarsFromElement(n.subject,t),this.collectVarsFromElement(n.predicate,t),this.collectVarsFromElement(n.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="variable"&&n.name&&t.add(n.name),n.type==="exists"&&n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.left&&this.collectVarsFromExpressionTree(n.left,t),n.right&&this.collectVarsFromExpressionTree(n.right,t),n.operands)for(let i of n.operands)this.collectVarsFromExpressionTree(i,t);if(n.args)for(let i of n.args)this.collectVarsFromExpressionTree(i,t);if(n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.list)for(let i of n.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new Nf("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 Nf("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};Oi.ExoQLQueryExecutor=Q0;Oi.QueryExecutor=Q0});var sk=T(fa=>{"use strict";var AQ=fa&&fa.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},IQ=fa&&fa.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(fa,"__esModule",{value:!0});fa.CommandResolver=void 0;var RQ=ct(),CQ=Qp(),xQ=Fl(),hr=Le(),Jt=Ye(),q=Wt(),XN=cc(),QN=Pp(),OQ=ef(),JN=oa(),PQ=/^[a-z][a-z0-9+.-]*:\/\//i,Mf=tv(),ZN=$L(),FQ=ff(),DQ=yf(),LQ=kf(),Gl=10,J0="exo__Asset",NQ=Gl+1,ek="08cec529-90eb-4d43-88de-ceecccea12b0",kQ=q.Namespace.EXOCMD.term("SubstitutionToken").value,tk=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","targetClassSelf"]);function MQ(r,e){return`__SUBSTITUTE__${r}__${e}__`}a(MQ,"buildSubstitutionMarker");function jQ(r,e,t){let n=(0,OQ.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${r}__${e}__${n}__`}a(jQ,"buildParameterisedMarker");var rk="3f28af98-c031-4718-8ba2-44ad0b012c52",$Q=q.Namespace.EXOCMD.term("TokenInvocation").value,nk="29e2c8f8-2d27-4e58-b467-2e85d46f8122",ik="universal-default-template",RA=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null}constructor(e,t=CQ.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorDepthCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._fallbackWarnedKeys=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,n){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${n??""}`,o=this.multiCache.get(s);if(o)return o;let c=n?await this.expandPrototypeChain(n):void 0,l=await this.expandClassHierarchy(t),u=new Map;for(let[h,g]of l){let m=await this.resolveForAsset(e,h,c);for(let b of m){let _=this.getBindingPriority(b.binding)===2?g:0,S=u.get(b.binding.id);(!S||_<S.depth)&&u.set(b.binding.id,{rc:b,depth:_})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let g of h.binding.overrides)f.add(g);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,g)=>{let m=this.getBindingPriority(h.rc.binding),b=this.getBindingPriority(g.rc.binding);return m!==b?m-b:h.depth!==g.depth?h.depth-g.depth:(h.rc.binding.order??100)-(g.rc.binding.order??100)});let p=d.map(h=>h.rc);return this.multiCache.set(s,p),p}async expandClassHierarchy(e){let t=new Map;for(let c of e){if(c===J0){t.set(c,new Set);continue}let l=[];try{l=await this.getClassAncestors(c)}catch{l=[]}t.set(c,new Set(l))}let n=a(c=>{for(let l of e)if(l!==c&&t.get(l)?.has(c)&&!t.get(c)?.has(l))return!0;return!1},"isAncestorOfSibling"),i=e.filter(c=>!n(c)),s=new Map,o=a((c,l)=>{let u=s.get(c);(u===void 0||l<u)&&s.set(c,l)},"setMin");for(let c of i){if(o(c,0),this.looksLikeUUID(c))try{let u=await this.resolveLabelByUID(c);u&&o(u,0)}catch{}if(c===J0)continue;let l=[];try{l=await this.getClassAncestorsWithDepth(c)}catch{l=[]}for(let{ref:u,depth:f}of l)o(u,f)}return s.has(J0)||s.set(J0,NQ),s}async resolveForAsset(e,t,n){let i=typeof n=="string"?`s:${n}`:n?`c:${n.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let c=typeof n=="string"?await this.expandPrototypeChain(n):n,l=await this.findBindings(t,c,e),u=[];for(let f of l){let d=await this.loadCommand(f.commandRef,{targetClass:f.targetClass});if(!d)continue;let p=f.precondition?{...d,precondition:f.precondition}:d;u.push({command:p,binding:f})}return u.sort((f,d)=>{let p=this.getBindingPriority(f.binding),h=this.getBindingPriority(d.binding);return p!==h?p-h:(f.binding.order??100)-(d.binding.order??100)}),this.cache.set(s,u),u}async loadCommand(e,t){let n=await this.findSubjectByUID(e);if(!n||(await this.tripleStore.match(n,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_labelTemplate")),c=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_icon")),l=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(n),g=await this.loadLinkedGrounding(n,0,t);return g?{id:e,name:s,labelTemplate:o??void 0,icon:c??void 0,precondition:h??void 0,grounding:g,confirmMessage:l??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,n){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let c of s){let l=c.subject,u=await this.loadBindingDefinition(l);u&&this.bindingMatches(u,e,i,n)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command")),t=[],n=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let l=await this.loadCommand(c);if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command ${c} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_cliName")),d=u??f??c;if(n.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${c}`);continue}n.add(d),t.push({command:l,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear(),this.clearUniversalCache()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let n=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let c=await this.evaluateSelectSnippet(o,t);n=n.replace(s,c)}return n}extractPlaceholders(e){let t=[],n=0;for(;n<e.length;)if(e[n]==="{"){let i=1,s=n+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(n,s),c=e.slice(n+1,s-1);t.push({full:o,body:c})}n=s}else n++;return t}async evaluateSelectSnippet(e,t){try{let n=e.replace(/\$target/g,`<${t}>`),s=new FQ.ExoQLParser().parse(n),c=new DQ.ExoQLAlgebraTranslator().translate(s),u=await new LQ.ExoQLQueryExecutor(this.tripleStore).executeAll(c);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let p=f.get(d[0]);return p?p instanceof Jt.Literal||p instanceof hr.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,q.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),c=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!c)return null;let l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),g=await this.getLinkedUIDs(e,q.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:n,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:c??void 0,position:l??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:g.length>0?g:void 0}}async loadLinkedStyle(e,t){let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(n.length>0){let s=n[0].object,o=null;if(s instanceof hr.IRI)o=s;else if(s instanceof Jt.Literal){let c=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(c)}if(o){let c=await this.loadStyleAsset(o);if(c)return c}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_variant"));if(i!==null){let s=this.coerceVariant(i,t);if(s!==void 0)return{id:`inline:${t}`,label:"",variant:s,inline:!0}}return null}async loadStyleAsset(e){let t=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),c=this.coerceBoolean(o),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=l!==null?this.coerceLabelClass(l,t):void 0,f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_source")),g=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:n,variant:s,showIcon:c,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:g,inline:!1}}coerceVariant(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Mf.COMMAND_VARIANT_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${n}" not in whitelist [${Mf.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Mf.LABEL_CLASS_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${n}" not in whitelist [${Mf.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Mf.STYLE_SOURCE_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle source "${n}" not in whitelist [${Mf.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,n,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&n){for(let s of n)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let n=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(n===i)return!0;let s=this.extractPathBasename(i);if(s&&s===n)return!0;let o=this.extractPathBasename(n);if(o&&o===i)return!0;let c=this.extractAlias(t);if(c&&n===c)return!0;let l=this.extractAlias(e);return!!(l&&l===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(n+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=await this.resolvePreconditionRef(n[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof hr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,n){let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid")),s=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(n>=Gl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||c.length>0||l.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||c.length>0){let g=o.length>0?"all":"any",m=o.length>0?o:c,b=[];for(let _ of m)b.push(await this.loadChildPrecondition(_.object,p,n+1));return{id:i??"",label:s,composite:{op:g,children:b}}}let h=await this.loadChildPrecondition(l[0].object,p,n+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_hostFunction")),d=await this.loadPreconditionQueryRef(e);return!i||!u&&!f&&!d?null:{id:i,label:s,...u&&{sparqlAsk:u},...f&&{hostFunction:f},...d&&{query:d}}}async loadChildPrecondition(e,t,n){let i=await this.resolvePreconditionRef(e);if(!i){let c=e instanceof Jt.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(c,"")}let s=await this.loadPreconditionSubject(i,t,n);if(s)return s;let o=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let n=t[0].object;if(n instanceof hr.IRI)return await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_uid"))??void 0;if(n instanceof Jt.Literal)return this.normalizeWikilink(n.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,n){if(t>=Gl)return null;let i=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!n?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let c=await this.resolveGroundingRef(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(l&&this.matchesReference(l,n.targetClass))return this.loadGroundingDefinition(c,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${n.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof hr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadGroundingByUid(e){let t=await this.findSubjectByUID(e);return t?this.loadGroundingDefinition(t,0):null}async loadGroundingDefinition(e,t){if(t>=Gl)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!n)return null;let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let ie=await this.resolveLabelByUID(o);if(!ie)return this.logger.warn(`Grounding ${n}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=ie}if(s===XN.GroundingType.SERVICE_CALL){let ie=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceId"));ie&&(o=ie)}let c=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueRef")),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let ie=await this.resolveLabelByUID(u);if(!ie)return this.logger.warn(`Grounding ${n}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=ie}else u&&(f=u);let d=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),g=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_appendExpression")),m=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_replaceFromExpression")),b=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_replaceToExpression")),_=await this.getObsidianWikilinkValue(e,q.Namespace.EXOCMD.term("Grounding_isDefinedBy")),S=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),I=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetClass"));if(I&&!this.looksLikeUUID(I)){let ie=await this.findUidByLabel(I);ie&&(I=ie)}let E=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetPrototype")),w=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetFolder")),R=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_linkBackProperty")),x=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_inputSchema")),P=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_incrementBy")),k=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_shiftDelta")),B;if(P!=null&&P!==""){let ie=Number.parseInt(String(P),10);Number.isFinite(ie)&&(B=ie)}let D=await this.resolvePropertyDefaults(e,n),Q=await this.resolveInheritanceRules(e,n),fe=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_propertyDefaults"));fe!==null&&fe!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(n)&&(this.logger.warn(`Grounding ${n}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(n));let j;s===XN.GroundingType.COMPOSITE&&(j=await this.loadCompositeSteps(e,t+1));let ce;if(x)try{let ie=JSON.parse(x);ie?.properties&&(ce=Object.entries(ie.properties).map(([Ae,ye])=>{let Te=ye.type,Re=Te==="string"?ye.format==="asset-reference"?"assetRef":"text":Te,pe=ye.defaultValue!==void 0?ye.defaultValue:ye.default,U={name:Ae,type:Re,label:ye.title??Ae,required:Array.isArray(ie.required)&&ie.required.includes(Ae)};return pe!=null&&(U.defaultValue=String(pe)),typeof ye.targetClassUid=="string"&&(U.targetClassUid=ye.targetClassUid),U}))}catch{}let V=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),oe=V!==null&&String(V).trim().toLowerCase()==="true",K=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_labelTemplate")),z=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_direction")),Z;if(z!=null){let ie=String(z).trim().toLowerCase();ie==="forward"||ie==="rollback"?Z=ie:ie!==""&&this.logger.warn(`Grounding ${n}: exocmd__Grounding_direction value '${z}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let Ie=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_bodyTemplate")),ee=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_templateRef")),Y=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),se=Y!==null&&String(Y).trim().toLowerCase()==="true",X=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),le=X!==null&&String(X).trim().toLowerCase()==="true",Ue=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_omitLabel")),$=Ue!==null&&String(Ue).trim().toLowerCase()==="true",de={id:n,label:i,type:s,targetProperty:o??void 0,targetValueRef:c??void 0,targetValueLiteral:l??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:g??void 0,replaceFromExpression:m??void 0,replaceToExpression:b??void 0,sparqlUpdate:S??void 0,steps:j,targetClass:I??void 0,targetPrototype:E??void 0,targetFolder:w??void 0,linkBackProperty:R??void 0,incrementBy:B,shiftDelta:k??void 0,propertyDefault:D.length>0?D:void 0,inheritanceRule:Q.length>0?Q:void 0,isDefinedBy:_??void 0,prefillLabelWithDate:oe||void 0,labelTemplate:K??void 0,direction:Z,bodyTemplate:Ie??void 0,templateRef:ee??void 0,cloneTargetBody:se||void 0,targetsCreatedInstance:le||void 0,omitLabel:$||void 0};return ce&&(de.inputSchema=ce),de}async loadCompositeSteps(e,t){if(t>=Gl)return[];let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of n){let o=null;if(s.object instanceof hr.IRI)o=s.object;else if(s.object instanceof Jt.Literal){let l=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(l)}if(!o)continue;let c=await this.loadGroundingDefinition(o,t);c&&i.push(c)}return i}async resolvePropertyDefaults(e,t){let n=await this.resolvePropertyDefaultsForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,ZN.mergePropertyDefaults)(i.propertyDefaults,n):n}async resolvePropertyDefaultsForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[];for(let o of i){let c=await this.resolveRefTripleObject(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("PropertyDefault_property"));if(!l){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(l)?await this.resolveLabelByUID(l):l;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${l}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(c,q.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.logger.warn(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await this.findUniversalSingleton();if(!e)return this.logger.debug("[CommandResolver] No exocmd__UniversalDefaultTemplate instance found in the store; universal property-defaults and inheritance-rules will not be applied. This verdict is cached until invalidateCache() is called \u2014 if the store was still warming up, the next invalidation re-resolves it."),this._universalCacheValue=null,null;let t=await this.resolvePropertyDefaultsForSubject(e,ik,q.Namespace.EXOCMD.term("Template_propertyDefault")),n=await this.resolveInheritanceRulesForSubject(e,ik,q.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:t,inheritanceRules:n},this._universalCacheValue}async findUniversalSingleton(){let e=q.Namespace.EXOCMD.term("UniversalDefaultTemplate"),t=e.value,i=(await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),e)).map(c=>c.subject).filter(c=>c instanceof hr.IRI);if(i.length>0)return this.pickUniversalSingleton(i);let s=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),void 0),o=[];for(let c of s){let l=!1;if(c.object instanceof hr.IRI)l=c.object.value===t||c.object.value.includes(nk);else if(c.object instanceof Jt.Literal){let u=this.unwrapWikilink(c.object.value);l=u==="exocmd__UniversalDefaultTemplate"||u===nk}l&&c.subject instanceof hr.IRI&&o.push(c.subject)}return this.pickUniversalSingleton(o)}pickUniversalSingleton(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=[...e].sort((n,i)=>n.value.localeCompare(i.value));return this.logger.warn(`Multiple UniversalDefaultTemplate singletons found (${t.length}); selecting deterministically by lexicographic UID order: ${t[0].value}`),t[0]}async resolveInheritanceRules(e,t){let n=await this.resolveInheritanceRulesForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,ZN.mergeInheritanceRules)(i.inheritanceRules,n):n}async resolveInheritanceRulesForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[],o=t;for(let c of i){let l=await this.resolveRefTripleObject(c.object);if(!l)continue;let u=await this.resolveLabelRef(l,q.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(l,q.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let E=await this.getObsidianName(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!E||!E.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(E)?(h=E,p=await this.resolveLabelByUID(E)??void 0):p=E}let g=await this.tripleStore.match(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),m=[],b=[],_=!1;for(let E of g){let w=null;if(E.object instanceof hr.IRI?w=this.iriToObsidianName(E.object.value)??E.object.value:E.object instanceof Jt.Literal&&(w=this.unwrapWikilink(E.object.value)),!w){_=!0;continue}if(this.looksLikeUUID(w)){b.push(w);let R=await this.resolveLabelByUID(w);R&&m.push(R)}else m.push(w)}if(_){this.logger.warn(`Grounding ${o}: InheritanceRule has unresolvable exocmd__InheritanceRule_targetClassExclusion entry \u2014 entire rule skipped (would otherwise expand scope by silently dropping the excluded class).`);continue}let S=await this.getLiteralValue(l,q.Namespace.EXOCMD.term("InheritanceRule_priority")),I=50;if(S!==null&&S!==""){let E=Number.parseInt(String(S),10);Number.isFinite(E)&&(I=E)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:m,targetClassExclusionUids:b,priority:I})}return s}async resolveRefTripleObject(e){if(e instanceof hr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let n=await this.getObsidianName(e,t);return n?this.looksLikeUUID(n)?this.resolveLabelByUID(n):n:null}async resolvePropertyDefaultValue(e,t,n){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let c=`${t}|${e}`;return this._fallbackWarnedKeys.has(c)||(this._fallbackWarnedKeys.add(c),this.logger.warn(this.capWarning(`Grounding ${t}: PropertyDefault '${n}' \u2192 value asset ${e} not in store; SKIPPING the property (the executor's own default applies). Previously this emitted a wikilink, i.e. a link written where a value belongs.`))),xQ.STRING_SCALAR_PROPERTIES.has(n)?null:`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,n):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,n,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${n}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,n,i,s){let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let c=o.trim();return tk.has(c)?s!==void 0?jQ(c,t,s):MQ(c,t):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${c}' \u2014 falling back to wikilink form. Known ids: ${Array.from(tk).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,n,i){let s=await this.getObsidianName(e,q.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let c=await this.findSubjectByUID(s);return c?this.dispatchSubstitutionToken(c,s,n,i,o):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof hr.IRI){if(i.object.value===$Q||i.object.value.includes(rk))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===rk)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("TokenInvocation_token"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as TokenInvocation via its exocmd__TokenInvocation_token property; exo__Instance_class was absent or unresolved.`),!0):!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof hr.IRI){if(i.object.value===kQ||i.object.value.includes(ek))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===ek)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as SubstitutionToken via its resolver property; exo__Instance_class was absent or unresolved.`),!0):!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let n=t[0].object;if(n instanceof hr.IRI)return(0,QN.resolveGroundingTypeFromIRI)(n.value);if(n instanceof Jt.Literal){let i=n.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,QN.resolveGroundingTypeFromIRI)(`obsidian://vault/${s[1].toLowerCase()}.md`):(this.logger.warn(`[exocmd-grounding-type-literal-form] legacy literal-string form '${i}' for exocmd__Grounding_type on <${e.value}>. Migrate to wikilink form per RFC 9d20c91f Phase 3.`),null)}return null}async expandPrototypeChain(e){if(!e||!this.normalizeWikilink(e))return[];let t=[e],n=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Gl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let c=null;try{let u=await this.findSubjectByUID(o);if(!u)break;c=await this.getLinkedValue(u,q.Namespace.EXO.term("Asset_prototype"))}catch(u){this.logger.debug(this.capWarning(`[expandPrototypeChain] store lookup failed at hop ${s} for '${i}': ${String(u)}`));break}if(!c)break;let l=this.normalizeWikilink(c).toLowerCase();if(n.has(l))break;n.add(l),t.push(c),i=c}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let n=this.extractPathBasename(t);return n&&this.looksLikeUUID(n)?n:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let n=await this.tripleStore.findSubjectsByUUID(e);if(n.length>0)return n[0]}let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_uid"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e)return n.subject;return null}async getLiteralValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal||i instanceof hr.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);if(!t)return null;let n=await this.getLiteralValue(t,q.Namespace.EXO.term("Asset_label"));return n===null?null:PQ.test(n)?(0,JN.iriToObsidianName)(n)??n:n}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(n=>n.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let n=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));c&&o.add(c);let l=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_label"));l&&o.add(l);let u=a((p,h)=>{if(o.has(p))return;let g=n.get(p);(g===void 0||h<g)&&n.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:g}=p;if(g>=Gl||i.has(h.value))continue;i.add(h.value);let m=await this.tripleStore.match(h,q.Namespace.EXO.term("Class_superClass"),void 0);for(let b of m){let _=b.object;if(!(_ instanceof hr.IRI))continue;let S=g+1,I=_.value.startsWith("obsidian://vault/"),E=this.iriToObsidianName(_.value);E&&u(E,S);let w=null;if(I?w=_:E&&(w=await this.resolveClassFileIRI(E)),!w)continue;let R=await this.getLiteralValue(w,q.Namespace.EXO.term("Asset_uid"));R&&u(R,S),i.has(w.value)||f.push({fileIRI:w,depth:S})}}let d=Array.from(n.entries()).map(([p,h])=>({ref:p,depth:h}));return this._ancestorDepthCache.set(e,d),d}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_label"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e&&n.subject instanceof hr.IRI){let i=await this.tripleStore.match(n.subject,q.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Jt.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof hr.IRI){let s=await this.tripleStore.match(i,q.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Jt.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Jt.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let n=await this.tripleStore.match(e,t,void 0),i=[];for(let s of n){let o=s.object;if(o instanceof hr.IRI){let c=await this.tripleStore.match(o,q.Namespace.EXO.term("Asset_uid"),void 0);if(c.length>0&&c[0].object instanceof Jt.Literal)i.push(c[0].object.value);else{let l=o.value.split("/").pop()?.replace(".md","");l&&i.push(l)}}else if(o instanceof Jt.Literal){let c=this.normalizeWikilink(o.value);c&&i.push(c)}}return i}async getLinkedValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.normalizeWikilink(i.value):i instanceof hr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.unwrapWikilink(i.value):i instanceof hr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let n=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(n)return n[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof Jt.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof hr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let n=t[1],i=await this.findSubjectByUID(n);if(!i)return e;let s=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${n}]]`,`[[${n}|${s}]]`):e}iriToObsidianName(e){return(0,JN.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(0,n):t}};fa.CommandResolver=RA;fa.CommandResolver=RA=AQ([(0,RQ.injectable)(),IQ("design:paramtypes",[Object,Object])],RA)});var xA=T(CA=>{"use strict";Object.defineProperty(CA,"__esModule",{value:!0});CA.validateExoQLAllowlist=UQ;var Z0=yh();function UQ(r){if(!r||typeof r!="object")return;let e=r;if(e.type==="update"){let t=r.updates??[];for(let n of t)if(n?.type==="load")throw new Z0.ExoQLForbiddenKeywordError("LOAD");throw new Z0.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,n=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||n)throw new Z0.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)eb(t);if(Array.isArray(e.template))for(let t of e.template)eb(t)}}a(UQ,"validateExoQLAllowlist");function eb(r){if(!r||typeof r!="object")return;if(r.type==="service")throw new Z0.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(r.patterns))for(let t of r.patterns)eb(t);let e=r.where;if(Array.isArray(e))for(let t of e)eb(t)}a(eb,"walkPatternForBannedKeywords")});var OA=T(tb=>{"use strict";Object.defineProperty(tb,"__esModule",{value:!0});tb.DEFAULT_EVAL_CONFIG=void 0;tb.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var rb=T(PA=>{"use strict";Object.defineProperty(PA,"__esModule",{value:!0});PA.evaluateWithExoEval=HQ;var BQ=ff(),VQ=yf(),GQ=kf(),qQ=xA(),WQ=OA(),zQ=yh();async function HQ(r,e={}){if(typeof r!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let n=new BQ.ExoQLParser().parse(r);if((0,qQ.validateExoQLAllowlist)(n),!{...WQ.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new zQ.ExoQLEvalDisabledError;let s="queryType"in n&&typeof n.queryType=="string"?n.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let c=new VQ.ExoQLAlgebraTranslator().translate(n),l=new GQ.ExoQLQueryExecutor(e.store);return l.isAskQuery(c)?{kind:"ask",result:await l.executeAsk(c)}:l.isConstructQuery(c)?{kind:"construct",triples:await l.executeConstruct(c)}:{kind:"select",rows:await l.executeAll(c)}}a(HQ,"evaluateWithExoEval")});var vs=T(nb=>{"use strict";Object.defineProperty(nb,"__esModule",{value:!0});nb.DateFormatter=void 0;var FA=class r{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${i}T${s}:${o}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${n}-${i}]]"`}static getTodayWikilink(){return r.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}static parseWikilink(e){let n=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return n?n[1]:null}static addDays(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),r.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[n,i,s]=t,o=new Date(n,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return r.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return r.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};nb.DateFormatter=FA});var _h=T(ib=>{"use strict";Object.defineProperty(ib,"__esModule",{value:!0});ib.liveClock=KQ;ib.frozenClock=YQ;function KQ(){return{now:a(()=>new Date,"now")}}a(KQ,"liveClock");function YQ(r){let e=new Date(r);return{now:a(()=>new Date(e.getTime()),"now")}}a(YQ,"frozenClock")});var ak=T(da=>{"use strict";var XQ=da&&da.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},QQ=da&&da.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},wh;Object.defineProperty(da,"__esModule",{value:!0});da.PreconditionEvaluator=void 0;var JQ=ct(),ZQ=ff(),eJ=yf(),ok=kf(),tJ=rb(),Sh=vs(),rJ=_h(),Eh=wh=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,n){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=n?.clock??(0,rJ.liveClock)()}async evaluate(e,t,n){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,n,i)==="yes"}async evaluateNode(e,t,n,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let c=await Promise.all(o.map(l=>this.evaluateNode(l,t,n,i)));return s==="all"?c.includes("no")?"no":c.includes("unknown")?"unknown":"yes":c.includes("yes")?"yes":c.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,n,i);return s==="unknown"?"unknown":s==="yes"?"no":"yes"}return e.sparqlAsk?await this.evaluateSparqlAskMemoized(e.sparqlAsk,t,i)?"yes":"no":e.query?await this.evaluateQueryRef(e.query,t)?"yes":"no":e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,n)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,n){let i=n.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return n.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return!1;let i=this.substituteVariables(n,t),s=await(0,tJ.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,n){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,n):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,wh.SENTINEL_IRI),i=new ZQ.ExoQLParser().parse(t),o=new eJ.ExoQLAlgebraTranslator().translate(i);return new ok.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,n){let i=this.hostFunctions.get(e);if(!i)return!0;let s=n?{...n,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let n=wh.TEMPORAL_TOKEN.test(e),i=n?Sh.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||n&&s.day!==i){let l=this.compileAsk(e);if(!l)return!1;s={day:i,compiled:l},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll(wh.SENTINEL_IRI,t));return await new ok.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let n=this.clock.now(),i=n.toISOString(),s=n.getFullYear(),o=n.getMonth(),c=n.getDate(),l=n.getDay(),u=Sh.DateFormatter.toDateString(n),f=Sh.DateFormatter.toDateString(new Date(s,o,c-1)),d=(l+6)%7,p=Sh.DateFormatter.toDateString(new Date(s,o,c-d)),h=Sh.DateFormatter.toDateString(new Date(s,o,c-d-7)),g=`${s}-${String(o+1).padStart(2,"0")}-01`,m=o===0?11:o-1,_=`${o===0?s-1:s}-${String(m+1).padStart(2,"0")}-01`,S=`${s}-01-01`;return e.replace(/\$target\b/g,`<${t}>`).replace(/\$now\b/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday\b/g,`"${f}"^^xsd:date`).replace(/\$thisWeekStart\b/g,`"${p}"^^xsd:date`).replace(/\$lastWeekStart\b/g,`"${h}"^^xsd:date`).replace(/\$thisMonthStart\b/g,`"${g}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${_}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${S}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};da.PreconditionEvaluator=Eh;Eh.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Eh.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;da.PreconditionEvaluator=Eh=wh=XQ([(0,JQ.injectable)(),QQ("design:paramtypes",[Object,Object,Object])],Eh)});var ck=T(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.hasUidFilename=pa.hasNonUidFilename=void 0;pa.registerDefaultHostFunctions=sJ;var nJ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");pa.hasNonUidFilename=nJ;var iJ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");pa.hasUidFilename=iJ;function sJ(r){r.registerHostFunction("hasNonUidFilename",pa.hasNonUidFilename),r.registerHostFunction("hasUidFilename",pa.hasUidFilename)}a(sJ,"registerDefaultHostFunctions")});var ob=T(sb=>{"use strict";Object.defineProperty(sb,"__esModule",{value:!0});sb.liveUidGenerator=oJ;sb.seededUidGenerator=cJ;var DA=Sl();function oJ(){return{next:a(()=>(0,DA.v4)(),"next")}}a(oJ,"liveUidGenerator");var aJ="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function cJ(r){let e=0,t=(0,DA.v5)(r,aJ);return{next:a(()=>{let n=`${r}#${e}`;return e+=1,(0,DA.v5)(n,t)},"next")}}a(cJ,"seededUidGenerator")});var lb=T(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.registerResolver=br;wc.getResolver=uJ;wc.isResolverModifierAware=fJ;wc.getRegisteredResolverIds=dJ;wc.clearResolvers=pJ;wc.installDefaultResolvers=vJ;var lJ=vs(),cb=new Map,LA=new Set;function br(r,e,t=!1){cb.set(r,e),t&&LA.add(r)}a(br,"registerResolver");function uJ(r){return cb.get(r)}a(uJ,"getResolver");function fJ(r){return LA.has(r)}a(fJ,"isResolverModifierAware");function dJ(){return Array.from(cb.keys())}a(dJ,"getRegisteredResolverIds");function pJ(){cb.clear(),LA.clear()}a(pJ,"clearResolvers");function En(r){return r<10?`0${r}`:String(r)}a(En,"pad2");var hJ=["January","February","March","April","May","June","July","August","September","October","November","December"],mJ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],gJ=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],yJ=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function bJ(r){let e=["th","st","nd","rd"],t=r%100;return`${r}${e[(t-20)%10]||e[t]||e[0]}`}a(bJ,"ordinalDay");var _J=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function SJ(r,e){let t=(r.getHours()+11)%12+1;return e.replace(_J,n=>{switch(n){case"YYYY":return String(r.getFullYear());case"YY":return En(r.getFullYear()%100);case"MMMM":return hJ[r.getMonth()];case"MMM":return mJ[r.getMonth()];case"MM":return En(r.getMonth()+1);case"M":return String(r.getMonth()+1);case"Do":return bJ(r.getDate());case"DD":return En(r.getDate());case"D":return String(r.getDate());case"dddd":return gJ[r.getDay()];case"ddd":return yJ[r.getDay()];case"HH":return En(r.getHours());case"H":return String(r.getHours());case"hh":return En(t);case"h":return String(t);case"mm":return En(r.getMinutes());case"m":return String(r.getMinutes());case"ss":return En(r.getSeconds());case"s":return String(r.getSeconds());case"A":return r.getHours()<12?"AM":"PM";case"a":return r.getHours()<12?"am":"pm";default:return n}})}a(SJ,"formatDate");function lk(r,e,t){let n=r.getDate(),i=new Date(r.getTime());i.setDate(1),t==="M"?i.setMonth(i.getMonth()+e):i.setFullYear(i.getFullYear()+e);let s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(n,s)),i}a(lk,"addMonthsClamped");function wJ(r,e){if(!e)return r;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return r;let n=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(r.getTime());switch(i){case"d":s.setDate(s.getDate()+n);break;case"w":s.setDate(s.getDate()+n*7);break;case"M":s=lk(s,n,"M");break;case"y":s=lk(s,n,"y");break}return isNaN(s.getTime())?r:s}a(wJ,"applyDateOffset");function EJ(r){if(!r)return{offset:null,format:null};let e=r.indexOf(":");if(e<0)return{offset:r,format:null};let t=r.slice(0,e),n=r.slice(e+1);return{offset:t||null,format:n||null}}a(EJ,"parseDateModifier");function ab(r,e){return(t,n)=>{let{offset:i,format:s}=EJ(n),o=new Date;return r!==0&&o.setDate(o.getDate()+r),o=wJ(o,i),SJ(o,s??e)}}a(ab,"makeDateResolver");function vJ(){br("today",()=>{let r=new Date;return`${r.getFullYear()}-${En(r.getMonth()+1)}-${En(r.getDate())}`}),br("todayStart",()=>lJ.DateFormatter.getTodayStartTimestamp()),br("date",ab(0,"YYYY-MM-DD"),!0),br("now",ab(0,"YYYY-MM-DDTHH:mm:ss"),!0),br("tomorrow",ab(1,"YYYY-MM-DD"),!0),br("yesterday",ab(-1,"YYYY-MM-DD"),!0),br("target",r=>r.targetIRI?`"[[${r.targetIRI}]]"`:""),br("targetFolder",r=>{if(!r.targetFilePath)return"";let e=r.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),br("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.")}),br("nowTimestamp",()=>{let r=new Date;return`${r.getFullYear()}-${En(r.getMonth()+1)}-${En(r.getDate())}T${En(r.getHours())}:${En(r.getMinutes())}:${En(r.getSeconds())}`}),br("nowDate",()=>{let r=new Date;return`${r.getFullYear()}-${En(r.getMonth()+1)}-${En(r.getDate())}`}),br("nowYear",()=>String(new Date().getFullYear())),br("nowMonth",()=>En(new Date().getMonth()+1)),br("userInputLabel",r=>{let e=r.userInput?.label;return typeof e=="string"?e:""}),br("userInput",(r,e)=>{if(!e)return null;let t=r.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),br("targetProperty",(r,e)=>{if(!e||!r.targetFm)return null;let t=r.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),br("targetRefProperty",(r,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!n||!i)return null;let s=r.targetRefFm?.[n];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),br("labelAsArray",r=>{let e=r.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),br("groundingTargetClass",r=>r.groundingTargetClassUid?`"[[${r.groundingTargetClassUid}]]"`:null),br("targetClassSelf",r=>{if(!r.targetFilePath)return null;let e=r.targetFilePath.replace(/^\/+/,""),n=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return n.length>0?`"[[${n}]]"`:null})}a(vJ,"installDefaultResolvers")});var kA=T(ub=>{"use strict";Object.defineProperty(ub,"__esModule",{value:!0});ub.resolveTemplateBody=AJ;ub.stripTemplateFrontmatter=IJ;var NA=lb();(0,NA.installDefaultResolvers)();var TJ=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function AJ(r,e={}){return r.replace(TJ,(t,n,i)=>{let s=(0,NA.getResolver)(n);if(s===void 0)return t;let o=s(e,i.length>0?i:void 0);return typeof o!="string"||o.length===0?t:(0,NA.isResolverModifierAware)(n)?o:o+i})}a(AJ,"resolveTemplateBody");function IJ(r){let e=r.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?r.slice(e[0].length):r}a(IJ,"stripTemplateFrontmatter")});var pb=T(jf=>{"use strict";Object.defineProperty(jf,"__esModule",{value:!0});jf.registerOrderSpecLoader=RJ;jf.clearOrderSpecLoader=CJ;jf.loadDefaultSpec=xJ;jf.orderProperties=OJ;var fb=null,Ec,db=!1;function RJ(r){fb=r,Ec=void 0,db=!1}a(RJ,"registerOrderSpecLoader");function CJ(){fb=null,Ec=void 0,db=!1}a(CJ,"clearOrderSpecLoader");function xJ(){if(Ec!==void 0)return Ec;if(!fb)return Ec=null,null;try{Ec=fb()}catch(r){db||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",r),db=!0),Ec=null}return Ec}a(xJ,"loadDefaultSpec");function OJ(r,e){if(!e||e.head.length===0&&e.tail.length===0)return r;let t=Object.keys(r),n=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),c=t.filter(u=>!n.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&c.sort((u,f)=>u.localeCompare(f));let l={};for(let u of s)l[u]=r[u];for(let u of c)l[u]=r[u];for(let u of o)l[u]=r[u];return l}a(OJ,"orderProperties")});var ii=T(hb=>{"use strict";Object.defineProperty(hb,"__esModule",{value:!0});hb.DI_TOKENS=void 0;hb.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 jA=T(mb=>{"use strict";Object.defineProperty(mb,"__esModule",{value:!0});mb.RDFVocabularyMapper=void 0;var Cr=Ti(),uk=Le(),Ee=Wt(),MA=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",Ee.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",Ee.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",Ee.Namespace.RDFS.term("subClassOf")],["exo__Property_range",Ee.Namespace.RDFS.term("range")],["exo__Property_domain",Ee.Namespace.RDFS.term("domain")],["exo__Property_superProperty",Ee.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Cr.Triple(Ee.Namespace.EXO.term("Asset"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDFS.term("Resource"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Class"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDFS.term("Class"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.RDF.term("Property"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Task"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Project"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Area"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("Workflow"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("WorkflowState"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EMS.term("WorkflowTransition"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Command"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Precondition"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("Grounding"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Ee.Namespace.EXOCMD.term("CommandBinding"),Ee.Namespace.RDFS.term("subClassOf"),Ee.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Cr.Triple(Ee.Namespace.EXO.term("Instance_class"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDF.term("type"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Asset_isDefinedBy"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("isDefinedBy"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Class_superClass"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("subClassOf"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_range"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("range"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_domain"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("domain"))),e.push(new Cr.Triple(Ee.Namespace.EXO.term("Property_superProperty"),Ee.Namespace.RDFS.term("subPropertyOf"),Ee.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,n){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(n instanceof uk.IRI)s=n;else{let o=n.match(/^(ems|exo|exocmd)__(.+)$/);if(o){let[,c,l]=o;s=(c==="ems"?Ee.Namespace.EMS:c==="exocmd"?Ee.Namespace.EXOCMD:Ee.Namespace.EXO).term(l)}else s=new uk.IRI(n)}return new Cr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};mb.RDFVocabularyMapper=MA});var gb=T(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.OBSIDIAN_VAULT_SCHEME=void 0;ha.vaultPathToIRI=PJ;ha.iriToVaultPath=FJ;ha.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function PJ(r){let e=r.startsWith("./")?r.slice(2):r;return`${ha.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(PJ,"vaultPathToIRI");function FJ(r){if(!r.startsWith(ha.OBSIDIAN_VAULT_SCHEME))return null;let e=r.slice(ha.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(FJ,"iriToVaultPath")});var bb=T(vh=>{"use strict";Object.defineProperty(vh,"__esModule",{value:!0});vh.derivePath=fk;vh.deriveUrl=DJ;vh.deriveLegacyFlatPath=LJ;var $A="assetspaces",yb=/^[A-Za-z0-9._-]+$/;function fk(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let n=t.split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!yb.test(i)||!yb.test(s)?null:`${$A}/${i}/${s}`}a(fk,"derivePath");function DJ(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${$A}/`;if(!e.startsWith(t))return null;let n=e.slice(t.length).split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!yb.test(i)||!yb.test(s)?null:`https://github.com/${i}/${s}`}a(DJ,"deriveUrl");function LJ(r){let e=fk(r);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let n=t.startsWith("exoas-")?t.slice(6):t;return n.length===0?null:`${$A}/${n}`}a(LJ,"deriveLegacyFlatPath")});var _b=T(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.FILE_SPACE_CLASS_UID=void 0;Ts.frontmatterDeclaresFileSpace=kJ;Ts.discoverFileSpaceExclusions=jJ;var NJ=bb();Ts.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var dk=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,UA=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function hk(r){let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;dk.lastIndex=0;let i;for(;(i=dk.exec(n))!==null;)t.push(i[1].trim())}return t}a(hk,"wikilinkTargets");function kJ(r){return r?hk(r.exo__Instance_class).some(e=>UA.test(e)&&e.toLowerCase()===Ts.FILE_SPACE_CLASS_UID):!1}a(kJ,"frontmatterDeclaresFileSpace");function pk(r,e){try{return r.getFrontmatter(e)}catch{return null}}a(pk,"readFrontmatterSafe");function MJ(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(MJ,"readSource");function jJ(r){let e=[],t=[],n=[],i=new Map,s=a((c,l)=>{if(UA.test(c))return c.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;let u=r.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=pk(r,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(c=>c.some(l=>UA.test(l)&&l.toLowerCase()===Ts.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of r.getAllFiles()){let l=pk(r,c);if(!l)continue;let u=hk(l.exo__Instance_class);if(!u.some(h=>s(h,c.path)))continue;t.push(c.path),o(u)||n.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Ts.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=MJ(l);if(f===null){n.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,NJ.derivePath)(f);if(d===null){n.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;c.path.startsWith(p)&&n.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${p} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(p)}return{prefixes:e,declarationPaths:t,warnings:n}}a(jJ,"discoverFileSpaceExclusions")});var Wl=T(Lt=>{"use strict";var $J=Lt&&Lt.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},UJ=Lt&&Lt.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},mk=Lt&&Lt.__param||function(r,e){return function(t,n){e(t,n,r)}},GA;Object.defineProperty(Lt,"__esModule",{value:!0});Lt.NoteToRDFConverter=Lt.LEGACY_YAML_KEYS=Lt.LEGACY_UNPREFIXED_ASSET_FIELDS=Lt.UNPREFIXED_ASSET_FIELDS=void 0;Lt.canonicalYamlKey=WJ;Lt.isPosixBracketExpression=bk;Lt.normaliseExcludedFolders=_k;Lt.isPathExcluded=Sk;var BA=ct(),xr=Ti(),As=Le(),Mn=Ye(),gk=ir(),ar=Wt(),yk=ii(),BJ=jA(),VJ=Qp(),VA=gb(),Pi=$v(),GJ=_b();Lt.UNPREFIXED_ASSET_FIELDS=new Set(["draft","pinned","aliases"]);Lt.LEGACY_UNPREFIXED_ASSET_FIELDS=new Set(["archived"]);Lt.LEGACY_YAML_KEYS=new Map([...Lt.LEGACY_UNPREFIXED_ASSET_FIELDS].map(r=>[`exo__Asset_${r}`,[r]]));var qJ=/^exo__Asset_(.+)$/;function WJ(r){let e=qJ.exec(r);return e&&Lt.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(r)?`exo__Asset_${r}`:r}a(WJ,"canonicalYamlKey");function bk(r){return/^:[^\s[\]|]+:$/.test(r)}a(bk,"isPosixBracketExpression");function _k(r){return Array.isArray(r)?r.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(_k,"normaliseExcludedFolders");function Sk(r,e){if(e.length===0)return!1;let t=r.replace(/\\/g,"/");for(let n of e)if(t.startsWith(n))return!0;return!1}a(Sk,"isPathExcluded");function zJ(r){if(!r)return"";let e=r.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(zJ,"normaliseSubjectIriPrefix");var ql=GA=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=VJ.NullLogger,n={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.preResolvedTargetFm=new Map,this.vocabularyMapper=new BJ.RDFVocabularyMapper,this.subjectIriPrefix=zJ(n.subjectIriPrefix),this.emitInstanceClassAsUid=n.emitInstanceClassAsUid??!1}async convertNote(e){let t=this.vault.getFrontmatterWithFallback?await this.vault.getFrontmatterWithFallback(e):this.vault.getFrontmatter(e);return this.convertNoteFromFrontmatter(e,t)}async convertNoteFromFrontmatter(e,t){if(!t)return[];await this.preResolveWikilinkTargets(t);let n=this.notePathToIRI(e.path),i=ar.Namespace.EXO.term("Asset_filename"),s=new xr.Triple(n,i,new Mn.Literal(e.basename));if(Pi.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,n){this.pendingExtraTriples=[];let i=[n],s=this.notePathToIRI(e.path),o,c,l,u=!1,f=ar.Namespace.EXO.term("Statement").value;for(let[m,b]of Object.entries(t)){if(Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)&&Object.prototype.hasOwnProperty.call(t,`exo__Asset_${m}`))continue;let _=Lt.UNPREFIXED_ASSET_FIELDS.has(m)||Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)?`exo__Asset_${m}`:m;if(!this.isExocortexProperty(_))continue;let S=this.propertyKeyToIRI(_),I=Array.isArray(b)?b:[b];for(let E of I)if(!((m==="exo__Asset_label"||Lt.UNPREFIXED_ASSET_FIELDS.has(m)||Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m))&&(E==null||typeof E=="string"&&E.trim()==="")))if(m==="exo__Instance_class"){let w=this.valueToClassURI(E);i.push(new xr.Triple(s,S,w))}else{let w=await this.valueToRDFObject(E,e,S);if(_==="exo__Statement_subject"&&o===void 0){let R=w.find(x=>x instanceof As.IRI);R&&(o=R)}else if(_==="exo__Statement_predicate"&&c===void 0){let R=w.find(x=>x instanceof As.IRI);R&&(c=R)}else _==="exo__Statement_object"&&l===void 0&&(l=w[0]);for(let R of w)if(i.push(new xr.Triple(s,S,R)),this.vocabularyMapper.hasMappingFor(m)&&R instanceof As.IRI){let x=this.vocabularyMapper.generateMappedTriple(s,m,R);x&&i.push(x)}}if(m==="exo__Instance_class")for(let E of I){let w=this.valueToClassURI(E);if(w instanceof As.IRI){let R=ar.Namespace.RDF.term("type");i.push(new xr.Triple(s,R,w)),w.value===f&&(u=!0)}}if(m==="exo__Asset_label"){let E=ar.Namespace.RDFS.term("label");for(let w of I)typeof w=="string"&&w.length>0&&i.push(new xr.Triple(s,E,new Mn.Literal(w)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let m=ar.Namespace.RDFS.term("label"),b=ar.Namespace.EXO.term("Asset_label"),_=new Mn.Literal(e.basename);i.push(new xr.Triple(s,m,_)),i.push(new xr.Triple(s,b,_))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&c&&l&&i.push(new xr.Triple(o,c,l));let g=await this.convertBodyWikilinks(e,s);return i.push(...g),i}async convertExo003Note(e,t){let n=Pi.Exo003Parser.parse(t);if(!n.success||!n.metadata)return[];let i=n.metadata,s=[];switch(i.metadata){case Pi.Exo003MetadataType.Namespace:break;case Pi.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Pi.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Pi.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Pi.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let n=this.notePathToIRI(e.path),i=new As.IRI(t.uri);return[new xr.Triple(n,ar.Namespace.OWL.term("sameAs"),i),new xr.Triple(i,ar.Namespace.OWL.term("sameAs"),n)]}convertExo003BlankNode(e,t){let n=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new xr.Triple(n,ar.Namespace.OWL.term("sameAs"),new gk.BlankNode(i))]}convertExo003Statement(e,t){let n=[];try{let i=this.createExo003ReferenceResolver(e),s=Pi.Exo003Parser.toTriple(t,i);n.push(s);let o=this.notePathToIRI(e.path);n.push(new xr.Triple(o,ar.Namespace.RDF.term("value"),s.subject))}catch{}return n}async convertExo003Body(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new As.IRI(c.value):new gk.BlankNode(c.value),f=new As.IRI(l.value),d=Pi.Exo003Parser.toLiteral(t,s.trim());n.push(new xr.Triple(u,f,d));let p=this.notePathToIRI(e.path);n.push(new xr.Triple(p,ar.Namespace.RDF.term("value"),u))}catch{}return n}createExo003ReferenceResolver(e){return t=>{let n=this.extractWikilink(t),i=n||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.targetFrontmatter(s);if(o&&Pi.Exo003Parser.isExo003Format(o)){let c=Pi.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Pi.Exo003MetadataType.Anchor||l.metadata===Pi.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Pi.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!n&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders,onFileTriples:e.onFileTriples})).triples}async convertVaultWithValidation(e={}){let t=e.files??this.vault.getAllFiles(),n=[],i=[],s=e.strict??!1,o=0,c=0,l=e.fileSpacePrefixes?{prefixes:e.fileSpacePrefixes,declarationPaths:[],warnings:[]}:(0,GJ.discoverFileSpaceExclusions)(this.vault);for(let m of l.warnings)this.logger.warn(`FileSpace discovery: ${m}`);let u=[..._k(e.excludedFolders),...l.prefixes],f=u.length===0?t:t.filter(m=>!Sk(m.path,u)),d=e.onProgress,p=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:GA.INDEX_PROGRESS_INTERVAL,h=f.length,g=0;for(let m of f){if(g++,d&&g%p===0&&g<h)try{d(g,h)}catch{}try{let b=this.vault.getFrontmatter(m),_=b?this.validateExocortexAsset(b,m.basename):null;if(_){if(s)throw new Error(`Invariant violation in "${m.path}": ${_.message}`);i.push({path:m.path,reason:`Invariant violation: ${_.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${m.path}`,{code:_.code,property:_.property,reason:_.message});continue}let S=await this.convertNote(m);if(n.push(...S),e.onFileTriples)try{e.onFileTriples(m,S)}catch{}}catch(b){let _=b instanceof Error?b.message:String(b);if(s)throw new Error(`Invalid IRI for file "${m.path}": ${_}`);i.push({path:m.path,reason:`Invalid IRI: ${_}`}),c++,this.logger.info(`Skipping file with invalid IRI: ${m.path}`,{reason:_})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),c>0&&this.logger.warn(`Skipped ${c} file${c===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:c}),{triples:n,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length},fileSpaces:l}}static inferLabelFromBasename(e){return ar.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let n=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(n):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(n(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&n(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let p=this.removeQuotes(d),g=(this.extractWikilink(p)??p).trim();/^[a-z][a-zA-Z0-9]*__/.test(g)&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let n of e){let i=(0,VA.vaultPathToIRI)(n.path);As.IRI.isValidIRI(i)||t.push({path:n.path,reason:`Path "${n.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new As.IRI((0,VA.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new As.IRI((0,VA.vaultPathToIRI)(e))}isExocortexProperty(e){return ar.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=ar.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let n=this.targetFrontmatter(t);if(!n)return;let i=n.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof As.IRI&&(this.pendingExtraTriples.push(new xr.Triple(e,ar.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new xr.Triple(e,ar.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,n){if(typeof e=="string"){let i=this.removeQuotes(e);if(n?.value.endsWith("#TokenInvocation_parameter"))return[new Mn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new Mn.Literal(u);if(n?.value.endsWith("#Grounding_targetValueRef")||n?.value.endsWith("#Grounding_targetValueSubstitution")||n?.value.endsWith("#Grounding_targetClass")||n?.value.endsWith("#Grounding_type")||n?.value.endsWith("#PropertyDefault_value"))return[l];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let g=this.targetFrontmatter(o);if(g){let I=g.exo__Asset_label;if(typeof I=="string"){let E=this.expandClassValue(I);if(E)return this.emitTypeTripleForEnumInstance(E,o),[E]}}let m=n?.value.endsWith("#Asset_prototype")||n?.value.endsWith("/Asset_prototype"),_=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(I=>I.trim()).filter(Boolean),S=_.length>0&&_.some(I=>n?.value.endsWith(`#${I}`));return m||S?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new Mn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new Mn.Literal(i,ar.Namespace.XSD.term("dateTime"))]:[new Mn.Literal(i)]}return typeof e=="boolean"?[new Mn.Literal(e.toString())]:typeof e=="number"?[new Mn.Literal(e.toString(),Number.isInteger(e)?ar.Namespace.XSD.term("integer"):ar.Namespace.XSD.term("decimal"))]:e instanceof Date?[new Mn.Literal(e.toISOString(),ar.Namespace.XSD.term("dateTime"))]:[new Mn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1];return n.includes("|")?n.split("|")[0]:n}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1],i=n.indexOf("|");return i>=0?n.substring(i+1).trim():null}targetFrontmatter(e){return this.vault.getFrontmatter(e)??this.preResolvedTargetFm.get(e.path)??null}async preResolveWikilinkTargets(e){let t=this.vault.getFrontmatterWithFallback?.bind(this.vault);if(t)for(let n of Object.values(e)){let i=Array.isArray(n)?n:n==null?[]:[n];for(let s of i){if(typeof s!="string")continue;let o=this.removeQuotes(s),c=this.extractWikilink(o);if(!c||!this.isUUID(c))continue;let l=this.vault.getFirstLinkpathDest(c,"");!l||this.preResolvedTargetFm.has(l.path)||this.vault.getFrontmatter(l)||this.preResolvedTargetFm.set(l.path,await t(l))}}}valueToClassURI(e){if(typeof e!="string")return new Mn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):l;let u=this.targetFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):d}}return this.notePathToIRI(c.path)}}return new Mn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:ar.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),n=ar.Namespace.fromPropertyKey(t);return!n||/[\s()]/.test(n.localName)?null:n.namespace.term(n.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,n,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(n=i.exec(e))!==null;)n[1]&&!bk(n[1].trim())&&t.add(n[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=ar.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);n.push(new xr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?n.push(new xr.Triple(t,c,f)):n.push(new xr.Triple(t,c,new Mn.Literal(l)))}else n.push(new xr.Triple(t,c,new Mn.Literal(l)))}}catch{}return n}};Lt.NoteToRDFConverter=ql;ql.INDEX_PROGRESS_INTERVAL=200;ql.SkippedFileInfo=class{constructor(r,e){this.path=r,this.reason=e}};ql.VaultValidationResult=class{constructor(r,e,t){this.triples=r,this.skippedFiles=e,this.summary=t}};ql.VaultValidationOptions=class{constructor(r=!1){this.strict=r}};Lt.NoteToRDFConverter=ql=GA=$J([(0,BA.injectable)(),mk(0,(0,BA.inject)(yk.DI_TOKENS.IVaultAdapter)),mk(1,(0,BA.inject)(yk.DI_TOKENS.ILogger)),UJ("design:paramtypes",[Object,Object,Object])],ql)});var zl=T(wb=>{"use strict";Object.defineProperty(wb,"__esModule",{value:!0});wb.FrontmatterService=void 0;var wk=pb(),qA=Fl(),$f=Wl(),HJ=oa(),Sb=class r{static{a(this,"FrontmatterService")}parse(e){let t=e.match(r.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let n={},i=t.content.split(/\r?\n/),s=null,o=null,c=a(()=>{s!==null&&o!==null&&(n[s]=o),s=null,o=null},"flushArray");for(let l of i){let u=/^ {2}- (.*)$/.exec(l);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}c();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(l);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(s=d,o=[]):n[d]=p}return c(),n}updateProperty(e,t,n){t=(0,$f.canonicalYamlKey)(r.normalizeIRI(t)),typeof n=="string"&&(n=r.normalizeIRIValue(n));let i=this.parse(e),s=this.serializeValue(t,n);if(!i.exists)return`---
|
|
116
|
+
${n}}`}generateValuesTerm(e){if(e.type==="iri")return`<${e.value}>`;let n=`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;return e.language?n+=`@${e.language}`:e.datatype&&(n+=`^^<${e.datatype}>`),n}generateExpression(e){switch(e.type){case"variable":return`?${e.name}`;case"literal":return typeof e.value=="string"?`"${e.value.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:typeof e.value=="boolean"?e.value?"true":"false":String(e.value);case"comparison":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"logical":return e.operator==="!"?`!(${this.generateExpression(e.operands[0])})`:`(${e.operands.map(t=>this.generateExpression(t)).join(` ${e.operator} `)})`;case"arithmetic":return`(${this.generateExpression(e.left)} ${e.operator} ${this.generateExpression(e.right)})`;case"function":return`${e.function.toUpperCase()}(${e.args.map(t=>this.generateExpression(t)).join(", ")})`;case"functionCall":return`${(typeof e.function=="string"?e.function:e.function.value).toUpperCase()}(${e.args.map(n=>this.generateExpression(n)).join(", ")})`;case"exists":return`${e.negated?"NOT EXISTS":"EXISTS"} { ${this.generateWhereClause(e.pattern,0)} }`;case"in":{let t=this.generateExpression(e.expression),n=e.list.map(i=>this.generateExpression(i)).join(", ");return e.negated?`${t} NOT IN (${n})`:`${t} IN (${n})`}default:throw new Df(`Unknown expression type: ${e.type}`)}}collectVariablesFromOperation(e,t){switch(e.type){case"bgp":for(let n of e.triples)this.collectVariablesFromTriple(n,t);break;case"filter":this.collectVariablesFromOperation(e.input,t),this.collectVariablesFromExpression(e.expression,t);break;case"join":case"leftjoin":case"union":case"minus":this.collectVariablesFromOperation(e.left,t),this.collectVariablesFromOperation(e.right,t);break;case"values":for(let n of e.variables)t.add(n);break;case"project":for(let n of e.variables)t.add(n);this.collectVariablesFromOperation(e.input,t);break;case"extend":t.add(e.variable),this.collectVariablesFromOperation(e.input,t);break;case"orderby":case"slice":case"distinct":case"reduced":this.collectVariablesFromOperation(e.input,t);break;case"group":for(let n of e.variables)t.add(n);for(let n of e.aggregates)t.add(n.variable);this.collectVariablesFromOperation(e.input,t);break;case"subquery":this.collectVariablesFromOperation(e.query,t);break}}collectVariablesFromTriple(e,t){e.subject.type==="variable"&&t.add(e.subject.value),"type"in e.predicate&&e.predicate.type==="variable"&&t.add(e.predicate.value),e.object.type==="variable"&&t.add(e.object.value)}collectVariablesFromExpression(e,t){switch(e.type){case"variable":t.add(e.name);break;case"comparison":case"arithmetic":this.collectVariablesFromExpression(e.left,t),this.collectVariablesFromExpression(e.right,t);break;case"logical":for(let n of e.operands)this.collectVariablesFromExpression(n,t);break;case"function":case"functionCall":for(let n of e.args)this.collectVariablesFromExpression(n,t);break;case"exists":this.collectVariablesFromOperation(e.pattern,t);break;case"in":this.collectVariablesFromExpression(e.expression,t);for(let n of e.list)this.collectVariablesFromExpression(n,t);break}}};Lf.SPARQLGenerator=IA});var kf=T(Oi=>{"use strict";var aQ=Oi&&Oi.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var i=Object.getOwnPropertyDescriptor(e,t);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:a(function(){return e[t]},"get")}),Object.defineProperty(r,n,i)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),cQ=Oi&&Oi.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),YN=Oi&&Oi.__importStar||(function(){var r=a(function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[n.length]=i);return n},r(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),i=0;i<n.length;i++)n[i]!=="default"&&aQ(t,e,n[i]);return cQ(t,e),t}})();Object.defineProperty(Oi,"__esModule",{value:!0});Oi.QueryExecutor=Oi.ExoQLQueryExecutor=Oi.QueryExecutorError=void 0;var lQ=KT(),uQ=G0(),fQ=pA(),dQ=mA(),pQ=LN(),hQ=kN(),mQ=UN(),gQ=vA(),yQ=VN(),bQ=qN(),_Q=HN(),SQ=KN(),wQ=Le(),EQ=Ye(),vQ=k0(),wn="http://www.w3.org/2001/XMLSchema#",TQ=new Set([`${wn}integer`,`${wn}decimal`,`${wn}float`,`${wn}double`,`${wn}nonPositiveInteger`,`${wn}negativeInteger`,`${wn}long`,`${wn}int`,`${wn}short`,`${wn}byte`,`${wn}nonNegativeInteger`,`${wn}unsignedLong`,`${wn}unsignedInt`,`${wn}unsignedShort`,`${wn}unsignedByte`,`${wn}positiveInteger`]),Nf=class extends Error{static{a(this,"QueryExecutorError")}constructor(e,t){super(e,t?{cause:t}:void 0),this.name="QueryExecutorError"}};Oi.QueryExecutorError=Nf;var Q0=class{static{a(this,"ExoQLQueryExecutor")}constructor(e,t={}){let n=t.resolveClassHierarchy===!1?e:new _Q.ClassHierarchyResolvingStore(e);this.tripleStore=n,this.bgpExecutor=new lQ.BGPExecutor(n),this.filterExecutor=new uQ.FilterExecutor,this.optionalExecutor=new fQ.OptionalExecutor,this.unionExecutor=new dQ.UnionExecutor,this.minusExecutor=new pQ.MinusExecutor,this.valuesExecutor=new hQ.ValuesExecutor,this.aggregateExecutor=new mQ.AggregateExecutor,this.constructExecutor=new gQ.ConstructExecutor,this.serviceExecutor=new yQ.ServiceExecutor(t.serviceConfig),this.graphExecutor=new bQ.GraphExecutor(n),this.sparqlGenerator=new SQ.SPARQLGenerator,this.filterExecutor.setExistsEvaluator(async(i,s)=>this.evaluateExistsPattern(i,s)),this.filterExecutor.setTripleStore(n)}async evaluateExistsPattern(e,t){let n=this.substituteVariables(e,t);for await(let i of this.execute(n))if(t.merge(i)!==null)return!0;return!1}async executeAll(e){let t=[];for await(let n of this.execute(e))t.push(n);return t}async*execute(e){switch(e.type){case"bgp":yield*this.executeBGP(e);break;case"filter":yield*this.executeFilter(e);break;case"join":yield*this.executeJoin(e);break;case"leftjoin":yield*this.executeLeftJoin(e);break;case"union":yield*this.executeUnion(e);break;case"minus":yield*this.executeMinus(e);break;case"values":yield*this.executeValues(e);break;case"project":yield*this.executeProject(e);break;case"orderby":yield*this.executeOrderBy(e);break;case"slice":yield*this.executeSlice(e);break;case"distinct":yield*this.executeDistinct(e);break;case"reduced":yield*this.executeReduced(e);break;case"group":yield*this.executeGroup(e);break;case"extend":yield*this.executeExtend(e);break;case"subquery":yield*this.executeSubquery(e);break;case"lateraljoin":yield*this.executeLateralJoin(e);break;case"service":yield*this.executeService(e);break;case"graph":yield*this.executeGraph(e);break;default:throw new Nf(`Unknown operation type: ${e.type}`)}}async*executeBGP(e){yield*this.bgpExecutor.execute(e)}async*executeFilter(e){let t=this.execute(e.input);yield*this.filterExecutor.execute(e,t)}async*executeJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);if(t.length===0)return;let n=new Set;for(let o of t)for(let c of o.variables())n.add(c);let i=this.collectOperationVariables(e.right);if([...n].some(o=>i.has(o)))for(let o of t){let c=this.substituteVariables(e.right,o);for await(let l of this.execute(c)){let u=o.merge(l);u!==null&&(yield u)}}else{let o=[];for await(let c of this.execute(e.right))o.push(c);for(let c of t)for(let l of o){let u=c.merge(l);u!==null&&(yield u)}}}async*executeLeftJoin(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.optionalExecutor.execute(i(),s())}async*executeUnion(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.unionExecutor.execute(i(),s())}async*executeMinus(e){let t=[];for await(let o of this.execute(e.left))t.push(o);let n=[];for await(let o of this.execute(e.right))n.push(o);async function*i(){for(let o of t)yield o}a(i,"leftGen");async function*s(){for(let o of n)yield o}a(s,"rightGen"),yield*this.minusExecutor.execute(i(),s())}async*executeValues(e){yield*this.valuesExecutor.execute(e)}async*executeProject(e){let{SolutionMapping:t}=await Promise.resolve().then(()=>YN(ua())),n=new Set(e.variables);for await(let i of this.execute(e.input)){let s=new t;for(let o of i.variables())if(n.has(o)){let c=i.get(o);c!==void 0&&s.set(o,c)}yield s}}async*executeOrderBy(e){let t=[];for await(let n of this.execute(e.input))t.push(n);t.sort((n,i)=>{for(let s of e.comparators){let o=this.getExpressionValue(s.expression,n),c=this.getExpressionValue(s.expression,i),l=0;if(o===void 0&&c===void 0?l=0:o===void 0?l=1:c===void 0?l=-1:typeof o=="number"&&typeof c=="number"?l=o-c:l=String(o).localeCompare(String(c)),s.descending&&(l=-l),l!==0)return l}return 0});for(let n of t)yield n}async*executeSlice(e){let t=0,n=e.offset??0,i=e.limit;for await(let s of this.execute(e.input)){if(t>=n){if(i!==void 0&&t-n>=i)break;yield s}t++}}async*executeDistinct(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeReduced(e){let t=new Set;for await(let n of this.execute(e.input)){let i=this.getSolutionKey(n);t.has(i)||(t.add(i),yield n)}}async*executeGroup(e){let t=[];for await(let i of this.execute(e.input))t.push(i);let n=this.aggregateExecutor.execute(e,t);if(e.having&&e.having.length>0)for(let i of n)e.having.every(o=>this.filterExecutor.evaluateExpression(o,i)===!0)&&(yield i);else for(let i of n)yield i}async*executeExtend(e){let t=e.expression.type!=="aggregate"&&this.filterExecutor.expressionContainsExists(e.expression);for await(let n of this.execute(e.input)){let i=n.clone(),s=t?await this.evaluateExtendExpressionAsync(e.expression,n):this.evaluateExtendExpression(e.expression,n);s!==void 0&&i.set(e.variable,s),yield i}}async*executeSubquery(e){yield*this.execute(e.query)}async*executeLateralJoin(e){let t=[];for await(let n of this.execute(e.left))t.push(n);for(let n of t){let i=this.substituteVariables(e.right,n);for await(let s of this.execute(i)){let o=n.merge(s);o!==null&&(yield o)}}}substituteVariables(e,t){let n=JSON.parse(JSON.stringify(e));return this.substituteInOperation(n,t)}substituteInOperation(e,t){if(!e||typeof e!="object")return e;let n=e;return e.type==="bgp"&&e.triples?(e.triples=e.triples.map(i=>this.substituteInTriple(i,t)),e):(n.input&&(n.input=this.substituteInOperation(n.input,t)),n.left&&(n.left=this.substituteInOperation(n.left,t)),n.right&&(n.right=this.substituteInOperation(n.right,t)),n.pattern&&(n.pattern=this.substituteInOperation(n.pattern,t)),n.query&&(n.query=this.substituteInOperation(n.query,t)),n.where&&(n.where=this.substituteInOperation(n.where,t)),n.expression&&this.substituteInExpression(n.expression,t),e)}substituteInExpression(e,t){if(!(!e||typeof e!="object")){if(e.type==="exists"&&e.pattern&&(e.pattern=this.substituteInOperation(e.pattern,t)),e.type==="variable"&&typeof e.name=="string"){let n=this.termToAlgebraNode(t.get(e.name));if(n!==null){delete e.name;for(let[i,s]of Object.entries(n))e[i]=s}}if(e.left&&this.substituteInExpression(e.left,t),e.right&&this.substituteInExpression(e.right,t),e.operands)for(let n of e.operands)this.substituteInExpression(n,t);if(e.args)for(let n of e.args)this.substituteInExpression(n,t);if(e.expression&&this.substituteInExpression(e.expression,t),e.list)for(let n of e.list)this.substituteInExpression(n,t)}}substituteInTriple(e,t){return{subject:this.substituteInTripleElement(e.subject,t),predicate:e.predicate,object:this.substituteInTripleElement(e.object,t)}}substituteInTripleElement(e,t){if(e&&e.type==="variable"){let n=this.termToAlgebraNode(t.get(e.value));if(n!==null)return n}return e}termToAlgebraNode(e){if(e==null)return null;let t=e;return e instanceof wQ.IRI||t.termType==="NamedNode"?{type:"iri",value:e.value}:t.termType==="Literal"||typeof t.value=="string"?{type:"literal",value:t.value,datatype:t.datatype?.value??t._datatype?.value,language:t.language??t._language}:null}async*executeService(e){yield*this.serviceExecutor.execute(e,t=>this.sparqlGenerator.generateSelect(t))}async*executeGraph(e){let t=async function*(n,i){let s=this.currentGraphContext;this.currentGraphContext=i;try{n.type==="bgp"&&i&&this.tripleStore.matchInGraph?yield*this.executeBGPInGraph(n,i):yield*this.execute(n)}finally{this.currentGraphContext=s}}.bind(this);yield*this.graphExecutor.execute(e,t)}async*executeBGPInGraph(e,t){if(e.triples.length===0){let{SolutionMapping:n}=await Promise.resolve().then(()=>YN(ua()));yield new n;return}yield*this.bgpExecutor.executeInGraph(e,t)}evaluateExtendExpression(e,t){if(e.type!=="aggregate")try{return this.filterExecutor.evaluateExpression(e,t)}catch{return}}async evaluateExtendExpressionAsync(e,t){if(e.type!=="aggregate")try{return await this.filterExecutor.evaluateExpressionAsync(e,t)}catch{return}}getExpressionValue(e,t){if(e.type==="variable"){let n=t.get(e.name);if(!n)return;if(n instanceof EQ.Literal){let i=n.datatype?.value;if(i===`${wn}dayTimeDuration`)try{return vQ.DateTimeFunctions.parseDayTimeDuration(n.value)}catch{return n.value}if(i&&TQ.has(i)){let s=parseFloat(n.value);if(!Number.isNaN(s))return s}return n.value}return n.value??n.id??String(n)}if(e.type==="literal")return e.value}collectOperationVariables(e){let t=new Set;return this.collectVarsFromOperation(e,t),t}collectVarsFromOperation(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="bgp"&&n.triples)for(let i of n.triples)this.collectVarsFromElement(i.subject,t),i.predicate?.type!=="path"&&this.collectVarsFromElement(i.predicate,t),this.collectVarsFromElement(i.object,t);if(n.type==="values"&&n.variables)for(let i of n.variables)t.add(i);n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.type==="extend"&&n.variable&&t.add(n.variable),n.input&&this.collectVarsFromOperation(n.input,t),n.left&&this.collectVarsFromOperation(n.left,t),n.right&&this.collectVarsFromOperation(n.right,t),n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.query&&this.collectVarsFromOperation(n.query,t),n.where&&this.collectVarsFromOperation(n.where,t)}collectVarsFromElement(e,t){if(!e||typeof e!="object")return;let n=e;n.type==="variable"&&t.add(n.value),n.type==="quoted"&&(this.collectVarsFromElement(n.subject,t),this.collectVarsFromElement(n.predicate,t),this.collectVarsFromElement(n.object,t))}collectVarsFromExpressionTree(e,t){if(!e||typeof e!="object")return;let n=e;if(n.type==="variable"&&n.name&&t.add(n.name),n.type==="exists"&&n.pattern&&this.collectVarsFromOperation(n.pattern,t),n.left&&this.collectVarsFromExpressionTree(n.left,t),n.right&&this.collectVarsFromExpressionTree(n.right,t),n.operands)for(let i of n.operands)this.collectVarsFromExpressionTree(i,t);if(n.args)for(let i of n.args)this.collectVarsFromExpressionTree(i,t);if(n.expression&&this.collectVarsFromExpressionTree(n.expression,t),n.list)for(let i of n.list)this.collectVarsFromExpressionTree(i,t)}getSolutionKey(e){let t=e.toJSON();return Object.keys(t).sort().map(i=>`${i}=${t[i]}`).join("|")}isConstructQuery(e){return e.type==="construct"}async executeConstruct(e){if(e.type!=="construct")throw new Nf("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 Nf("executeAsk requires an ASK operation");for await(let t of this.execute(e.where))return!0;return!1}};Oi.ExoQLQueryExecutor=Q0;Oi.QueryExecutor=Q0});var sk=T(fa=>{"use strict";var AQ=fa&&fa.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},IQ=fa&&fa.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(fa,"__esModule",{value:!0});fa.CommandResolver=void 0;var RQ=ct(),CQ=Qp(),xQ=Fl(),hr=Le(),Jt=Ye(),q=Wt(),XN=cc(),QN=Pp(),OQ=ef(),JN=oa(),PQ=/^[a-z][a-z0-9+.-]*:\/\//i,Mf=tv(),ZN=$L(),FQ=ff(),DQ=yf(),LQ=kf(),Gl=10,J0="exo__Asset",NQ=Gl+1,ek="08cec529-90eb-4d43-88de-ceecccea12b0",kQ=q.Namespace.EXOCMD.term("SubstitutionToken").value,tk=new Set(["today","tomorrow","todayStart","targetFolder","target","randomUUIDv4","nowTimestamp","nowDate","nowYear","nowMonth","userInputLabel","userInput","targetProperty","targetRefProperty","labelAsArray","groundingTargetClass","targetClassSelf"]);function MQ(r,e){return`__SUBSTITUTE__${r}__${e}__`}a(MQ,"buildSubstitutionMarker");function jQ(r,e,t){let n=(0,OQ.utf8ToBase64)(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`__SUBSTITUTE_P__${r}__${e}__${n}__`}a(jQ,"buildParameterisedMarker");var rk="3f28af98-c031-4718-8ba2-44ad0b012c52",$Q=q.Namespace.EXOCMD.term("TokenInvocation").value,nk="29e2c8f8-2d27-4e58-b467-2e85d46f8122",ik="universal-default-template",RA=class{static{a(this,"CommandResolver")}clearUniversalCache(){this._universalCacheReady=!1,this._universalCacheValue=null}constructor(e,t=CQ.NullLogger){this.tripleStore=e,this.logger=t,this.cache=new Map,this.multiCache=new Map,this._ancestorDepthCache=new Map,this._legacyPropertyDefaultsWarnedGroundings=new Set,this._fallbackWarnedKeys=new Set,this._universalCacheReady=!1,this._universalCacheValue=null}async resolveForAssetMulti(e,t,n){if(t.length===0)return[];let i=[...t].sort().join(","),s=`${e}::${i}::${n??""}`,o=this.multiCache.get(s);if(o)return o;let c=n?await this.expandPrototypeChain(n):void 0,l=await this.expandClassHierarchy(t),u=new Map;for(let[h,g]of l){let m=await this.resolveForAsset(e,h,c);for(let b of m){let _=this.getBindingPriority(b.binding)===2?g:0,S=u.get(b.binding.id);(!S||_<S.depth)&&u.set(b.binding.id,{rc:b,depth:_})}}let f=new Set;for(let{rc:h}of u.values())if(h.binding.overrides)for(let g of h.binding.overrides)f.add(g);let d=Array.from(u.entries()).filter(([h])=>!f.has(h)).map(([,h])=>h);d.sort((h,g)=>{let m=this.getBindingPriority(h.rc.binding),b=this.getBindingPriority(g.rc.binding);return m!==b?m-b:h.depth!==g.depth?h.depth-g.depth:(h.rc.binding.order??100)-(g.rc.binding.order??100)});let p=d.map(h=>h.rc);return this.multiCache.set(s,p),p}async expandClassHierarchy(e){let t=new Map;for(let c of e){if(c===J0){t.set(c,new Set);continue}let l=[];try{l=await this.getClassAncestors(c)}catch{l=[]}t.set(c,new Set(l))}let n=a(c=>{for(let l of e)if(l!==c&&t.get(l)?.has(c)&&!t.get(c)?.has(l))return!0;return!1},"isAncestorOfSibling"),i=e.filter(c=>!n(c)),s=new Map,o=a((c,l)=>{let u=s.get(c);(u===void 0||l<u)&&s.set(c,l)},"setMin");for(let c of i){if(o(c,0),this.looksLikeUUID(c))try{let u=await this.resolveLabelByUID(c);u&&o(u,0)}catch{}if(c===J0)continue;let l=[];try{l=await this.getClassAncestorsWithDepth(c)}catch{l=[]}for(let{ref:u,depth:f}of l)o(u,f)}return s.has(J0)||s.set(J0,NQ),s}async resolveForAsset(e,t,n){let i=typeof n=="string"?`s:${n}`:n?`c:${n.join("\0")}`:"",s=`${e}:${t}:${i}`,o=this.cache.get(s);if(o)return o;let c=typeof n=="string"?await this.expandPrototypeChain(n):n,l=await this.findBindings(t,c,e),u=[];for(let f of l){let d=await this.loadCommand(f.commandRef,{targetClass:f.targetClass});if(!d)continue;let p=f.precondition?{...d,precondition:f.precondition}:d;u.push({command:p,binding:f})}return u.sort((f,d)=>{let p=this.getBindingPriority(f.binding),h=this.getBindingPriority(d.binding);return p!==h?p-h:(f.binding.order??100)-(d.binding.order??100)}),this.cache.set(s,u),u}async loadCommand(e,t){let n=await this.findSubjectByUID(e);if(!n||(await this.tripleStore.match(n,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command"))).length===0)return null;let s=await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_label"))??"Unknown Command",o=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_labelTemplate")),c=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_icon")),l=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_confirmMessage")),u=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_successMessage")),f=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_category")),d=await this.getLiteralValue(n,q.Namespace.EXOCMD.term("Command_openInSameTab")),p=d!==null&&String(d).trim().toLowerCase()==="true",h=await this.loadLinkedPrecondition(n),g=await this.loadLinkedGrounding(n,0,t);return g?{id:e,name:s,labelTemplate:o??void 0,icon:c??void 0,precondition:h??void 0,grounding:g,confirmMessage:l??void 0,successMessage:u??void 0,category:f??void 0,openInSameTab:p||void 0}:null}async findBindings(e,t,n){let i=typeof t=="string"?await this.expandPrototypeChain(t):t,s=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("CommandBinding")),o=[];for(let c of s){let l=c.subject,u=await this.loadBindingDefinition(l);u&&this.bindingMatches(u,e,i,n)&&o.push(u)}return o}async findPaletteEnabledCommands(){let e=await this.tripleStore.match(void 0,q.Namespace.RDF.term("type"),q.Namespace.EXOCMD.term("Command")),t=[],n=new Set;for(let i of e){let s=i.subject;if((await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteEnabled")))?.toLowerCase()!=="true")continue;let c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));if(!c){this.logger.warn(`[CommandResolver] paletteEnabled command at ${s.value} has no exo__Asset_uid \u2014 skipped`);continue}let l=await this.loadCommand(c);if(!l){this.logger.warn(`[CommandResolver] paletteEnabled command ${c} could not be loaded (missing grounding?) \u2014 skipped`);continue}let u=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_paletteId")),f=await this.getLiteralValue(s,q.Namespace.EXOCMD.term("Command_cliName")),d=u??f??c;if(n.has(d)){this.logger.warn(`[CommandResolver] duplicate paletteId "${d}" \u2014 first registration wins, dropping ${c}`);continue}n.add(d),t.push({command:l,paletteId:d})}return t}invalidateCache(){this.cache.clear(),this.multiCache.clear(),this._ancestorDepthCache.clear(),this.clearUniversalCache()}async resolveLabel(e,t){if(!e.labelTemplate)return e.name;let n=e.labelTemplate,i=this.extractPlaceholders(e.labelTemplate);for(let{full:s,body:o}of i){let c=await this.evaluateSelectSnippet(o,t);n=n.replace(s,c)}return n}extractPlaceholders(e){let t=[],n=0;for(;n<e.length;)if(e[n]==="{"){let i=1,s=n+1;for(;s<e.length&&i>0;)e[s]==="{"?i++:e[s]==="}"&&i--,s++;if(i===0){let o=e.slice(n,s),c=e.slice(n+1,s-1);t.push({full:o,body:c})}n=s}else n++;return t}async evaluateSelectSnippet(e,t){try{let n=e.replace(/\$target/g,`<${t}>`),s=new FQ.ExoQLParser().parse(n),c=new DQ.ExoQLAlgebraTranslator().translate(s),u=await new LQ.ExoQLQueryExecutor(this.tripleStore).executeAll(c);if(u.length===0)return"";let f=u[0],d=f.variables();if(d.length===0)return"";let p=f.get(d[0]);return p?p instanceof Jt.Literal||p instanceof hr.IRI?p.value:String(p):""}catch{return""}}async loadBindingDefinition(e){let t=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLinkedUID(e,q.Namespace.EXOCMD.term("CommandBinding_command"));if(!i)return null;let s=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetClass")),o=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetPrototype")),c=await this.getLinkedValue(e,q.Namespace.EXOCMD.term("CommandBinding_targetAsset"));if(!s&&!o&&!c)return null;let l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_position")),u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_order")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_variant")),d=f!==null?this.coerceVariant(f,t):void 0,p=await this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("CommandBinding_precondition")),h=await this.loadLinkedStyle(e,t),g=await this.getLinkedUIDs(e,q.Namespace.EXOCMD.term("CommandBinding_overrides"));return{id:t,label:n,commandRef:i,targetClass:s??void 0,targetPrototype:o??void 0,targetAsset:c??void 0,position:l??void 0,order:u?parseInt(u,10):void 0,variant:d,precondition:p??void 0,style:h??void 0,overrides:g.length>0?g:void 0}}async loadLinkedStyle(e,t){let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("CommandBinding_style"),void 0);if(n.length>0){let s=n[0].object,o=null;if(s instanceof hr.IRI)o=s;else if(s instanceof Jt.Literal){let c=this.normalizeWikilink(s.value);o=await this.findSubjectByUID(c)}if(o){let c=await this.loadStyleAsset(o);if(c)return c}this.logger.warn(this.capWarning(`CommandBinding ${t}: style reference unresolved, falling back to inline variant`))}let i=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBinding_variant"));if(i!==null){let s=this.coerceVariant(i,t);if(s!==void 0)return{id:`inline:${t}`,label:"",variant:s,inline:!0}}return null}async loadStyleAsset(e){let t=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!t)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",i=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_variant")),s=i!==null?this.coerceVariant(i,t):void 0,o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_showIcon")),c=this.coerceBoolean(o),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_labelClass")),u=l!==null?this.coerceLabelClass(l,t):void 0,f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_ariaLabel")),d=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_tooltip")),p=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_keyboardShortcut")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("CommandBindingStyle_source")),g=h!==null?this.coerceStyleSource(h,t):void 0;return{id:t,label:n,variant:s,showIcon:c,labelClass:u,ariaLabel:f??void 0,tooltip:d??void 0,keyboardShortcut:p??void 0,source:g,inline:!1}}coerceVariant(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Mf.COMMAND_VARIANT_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle variant "${n}" not in whitelist [${Mf.COMMAND_VARIANT_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceLabelClass(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Mf.LABEL_CLASS_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle labelClass "${n}" not in whitelist [${Mf.LABEL_CLASS_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceStyleSource(e,t){if(e==null)return;let n=String(e).trim().toLowerCase();if(n!==""){if(Mf.STYLE_SOURCE_VALUES.includes(n))return n;this.logger.warn(this.capWarning(`CommandBindingStyle source "${n}" not in whitelist [${Mf.STYLE_SOURCE_VALUES.join(",")}]; dropped (asset ${t})`))}}coerceBoolean(e){if(e===null)return;let t=e.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1}capWarning(e){return e.length<=200?e:e.slice(0,197)+"..."}bindingMatches(e,t,n,i){if(e.targetAsset&&i&&this.matchesReference(e.targetAsset,i))return!0;if(e.targetPrototype&&n){for(let s of n)if(this.matchesReference(e.targetPrototype,s))return!0}return!!(e.targetClass&&t&&this.matchesReference(e.targetClass,t))}matchesReference(e,t){let n=this.normalizeWikilink(e),i=this.normalizeWikilink(t);if(n===i)return!0;let s=this.extractPathBasename(i);if(s&&s===n)return!0;let o=this.extractPathBasename(n);if(o&&o===i)return!0;let c=this.extractAlias(t);if(c&&n===c)return!0;let l=this.extractAlias(e);return!!(l&&l===i)}extractPathBasename(e){let t=e.match(/\/([^/]+)\.md$/);return t?t[1]:null}extractAlias(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(n+1).trim():null}getBindingPriority(e){return e.targetAsset?0:e.targetPrototype?1:2}async loadLinkedPrecondition(e){return this.loadLinkedPreconditionFromProperty(e,q.Namespace.EXOCMD.term("Command_precondition"))}async loadLinkedPreconditionFromProperty(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=await this.resolvePreconditionRef(n[0].object);return i?this.loadPreconditionSubject(i,new Set,0):null}async resolvePreconditionRef(e){if(e instanceof hr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadPreconditionSubject(e,t,n){let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid")),s=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"";if(i&&t.has(i))return this.brokenPreconditionNode(i,s);if(n>=Gl)return this.brokenPreconditionNode(i??"",s);let o=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AllPrecondition_preconditions"),void 0),c=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("AnyPrecondition_preconditions"),void 0),l=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("NotPrecondition_precondition"),void 0);if(o.length>0||c.length>0||l.length>0){let p=new Set(t);if(i&&p.add(i),o.length>0||c.length>0){let g=o.length>0?"all":"any",m=o.length>0?o:c,b=[];for(let _ of m)b.push(await this.loadChildPrecondition(_.object,p,n+1));return{id:i??"",label:s,composite:{op:g,children:b}}}let h=await this.loadChildPrecondition(l[0].object,p,n+1);return{id:i??"",label:s,not:h}}let u=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_sparqlAsk")),f=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Precondition_hostFunction")),d=await this.loadPreconditionQueryRef(e);return!i||!u&&!f&&!d?null:{id:i,label:s,...u&&{sparqlAsk:u},...f&&{hostFunction:f},...d&&{query:d}}}async loadChildPrecondition(e,t,n){let i=await this.resolvePreconditionRef(e);if(!i){let c=e instanceof Jt.Literal?this.normalizeWikilink(e.value):"";return this.brokenPreconditionNode(c,"")}let s=await this.loadPreconditionSubject(i,t,n);if(s)return s;let o=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_uid"));return this.brokenPreconditionNode(o??"","")}async loadPreconditionQueryRef(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Precondition_query"),void 0);if(t.length===0)return;let n=t[0].object;if(n instanceof hr.IRI)return await this.getLiteralValue(n,q.Namespace.EXO.term("Asset_uid"))??void 0;if(n instanceof Jt.Literal)return this.normalizeWikilink(n.value)}brokenPreconditionNode(e,t){return{id:e,label:t,broken:!0}}async loadLinkedGrounding(e,t,n){if(t>=Gl)return null;let i=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Command_grounding"),void 0);if(i.length===0)return null;if(i.length===1||!n?.targetClass){let o=await this.resolveGroundingRef(i[0].object);return o?this.loadGroundingDefinition(o,t):null}for(let o of i){let c=await this.resolveGroundingRef(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("Grounding_targetPrototype"));if(l&&this.matchesReference(l,n.targetClass))return this.loadGroundingDefinition(c,t)}this.logger.warn(`Command ${e.value}: ${i.length} groundings declared, none matched context.targetClass='${n.targetClass}' via Grounding_targetPrototype \u2014 falling back to first grounding by iteration order (legacy behaviour). Check that one grounding's Grounding_targetPrototype references this targetClass.`);let s=await this.resolveGroundingRef(i[0].object);return s?this.loadGroundingDefinition(s,t):null}async resolveGroundingRef(e){if(e instanceof hr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return await this.findSubjectByUID(t)}return null}async loadGroundingByUid(e){let t=await this.findSubjectByUID(e);return t?this.loadGroundingDefinition(t,0):null}async loadGroundingDefinition(e,t){if(t>=Gl)return null;let n=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_uid"));if(!n)return null;let i=await this.getLiteralValue(e,q.Namespace.EXO.term("Asset_label"))??"",s=await this.resolveGroundingTypeReference(e);if(!s)return null;let o=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetProperty"));if(o&&this.looksLikeUUID(o)){let ie=await this.resolveLabelByUID(o);if(!ie)return this.logger.warn(`Grounding ${n}: targetProperty wikilink UID '${o}' is not resolvable to exo__Asset_label \u2014 grounding skipped (would otherwise write a UUID-named frontmatter key).`),null;o=ie}if(s===XN.GroundingType.SERVICE_CALL){let ie=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceId"));ie&&(o=ie)}let c=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueRef")),l=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetValueLiteral")),u=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueSubstitution")),f=null;if(u&&this.looksLikeUUID(u)){let ie=await this.resolveLabelByUID(u);if(!ie)return this.logger.warn(`Grounding ${n}: targetValueSubstitution UID '${u}' is not resolvable to exo__Asset_label (SubstitutionToken instance missing or unlabelled) \u2014 grounding skipped.`),null;f=ie}else u&&(f=u);let d=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetValueQuery")),p=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetQuery")),h=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_serviceCallPayload")),g=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_appendExpression")),m=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_replaceFromExpression")),b=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_replaceToExpression")),_=await this.getObsidianWikilinkValue(e,q.Namespace.EXOCMD.term("Grounding_isDefinedBy")),S=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_sparqlUpdate")),I=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetClass"));if(I&&!this.looksLikeUUID(I)){let ie=await this.findUidByLabel(I);ie&&(I=ie)}let E=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_targetPrototype")),w=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetFolder")),R=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_linkBackProperty")),x=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_inputSchema")),P=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_incrementBy")),k=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_shiftDelta")),B;if(P!=null&&P!==""){let ie=Number.parseInt(String(P),10);Number.isFinite(ie)&&(B=ie)}let D=await this.resolvePropertyDefaults(e,n),Q=await this.resolveInheritanceRules(e,n),fe=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_propertyDefaults"));fe!==null&&fe!==""&&!this._legacyPropertyDefaultsWarnedGroundings.has(n)&&(this.logger.warn(`Grounding ${n}: deprecated exocmd__Grounding_propertyDefaults (plural) JSON predicate detected \u2014 the parser was removed in RFC v2 Phase 5 (#3167); value is ignored. Migrate to ref-form exocmd__Grounding_propertyDefault (singular) pointing to exocmd__PropertyDefault assets. See vault TBox c8f87363-d39c-45cb-9d4d-1be96d70f892 for the canonical replacement.`),this._legacyPropertyDefaultsWarnedGroundings.add(n));let j;s===XN.GroundingType.COMPOSITE&&(j=await this.loadCompositeSteps(e,t+1));let ce;if(x)try{let ie=JSON.parse(x);ie?.properties&&(ce=Object.entries(ie.properties).map(([Ae,ye])=>{let ve=ye.type,Re=ve==="string"?ye.format==="asset-reference"?"assetRef":"text":ve,pe=ye.defaultValue!==void 0?ye.defaultValue:ye.default,U={name:Ae,type:Re,label:ye.title??Ae,required:Array.isArray(ie.required)&&ie.required.includes(Ae)};return pe!=null&&(U.defaultValue=String(pe)),typeof ye.targetClassUid=="string"&&(U.targetClassUid=ye.targetClassUid),U}))}catch{}let V=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_prefillLabelWithDate")),oe=V!==null&&String(V).trim().toLowerCase()==="true",K=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_labelTemplate")),z=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_direction")),Z;if(z!=null){let ie=String(z).trim().toLowerCase();ie==="forward"||ie==="rollback"?Z=ie:ie!==""&&this.logger.warn(`Grounding ${n}: exocmd__Grounding_direction value '${z}' is not 'forward' or 'rollback' \u2014 treating as undefined (will default to 'forward' at dispatch).`)}let Ie=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_bodyTemplate")),ee=await this.getObsidianName(e,q.Namespace.EXOCMD.term("Grounding_templateRef")),Y=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_cloneTargetBody")),se=Y!==null&&String(Y).trim().toLowerCase()==="true",X=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_targetsCreatedInstance")),le=X!==null&&String(X).trim().toLowerCase()==="true",Ue=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("Grounding_omitLabel")),$=Ue!==null&&String(Ue).trim().toLowerCase()==="true",de={id:n,label:i,type:s,targetProperty:o??void 0,targetValueRef:c??void 0,targetValueLiteral:l??void 0,targetValueSubstitution:f??void 0,targetValueQuery:d??void 0,targetQuery:p??void 0,serviceCallPayload:h??void 0,appendExpression:g??void 0,replaceFromExpression:m??void 0,replaceToExpression:b??void 0,sparqlUpdate:S??void 0,steps:j,targetClass:I??void 0,targetPrototype:E??void 0,targetFolder:w??void 0,linkBackProperty:R??void 0,incrementBy:B,shiftDelta:k??void 0,propertyDefault:D.length>0?D:void 0,inheritanceRule:Q.length>0?Q:void 0,isDefinedBy:_??void 0,prefillLabelWithDate:oe||void 0,labelTemplate:K??void 0,direction:Z,bodyTemplate:Ie??void 0,templateRef:ee??void 0,cloneTargetBody:se||void 0,targetsCreatedInstance:le||void 0,omitLabel:$||void 0};return ce&&(de.inputSchema=ce),de}async loadCompositeSteps(e,t){if(t>=Gl)return[];let n=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_steps"),void 0),i=[];for(let s of n){let o=null;if(s.object instanceof hr.IRI)o=s.object;else if(s.object instanceof Jt.Literal){let l=this.normalizeWikilink(s.object.value);o=await this.findSubjectByUID(l)}if(!o)continue;let c=await this.loadGroundingDefinition(o,t);c&&i.push(c)}return i}async resolvePropertyDefaults(e,t){let n=await this.resolvePropertyDefaultsForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_propertyDefault")),i=await this.getUniversalCache();return i&&i.propertyDefaults.length>0?(0,ZN.mergePropertyDefaults)(i.propertyDefaults,n):n}async resolvePropertyDefaultsForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[];for(let o of i){let c=await this.resolveRefTripleObject(o.object);if(!c)continue;let l=await this.getObsidianName(c,q.Namespace.EXOCMD.term("PropertyDefault_property"));if(!l){this.logger.warn(`Grounding ${t}: PropertyDefault asset missing exocmd__PropertyDefault_property \u2014 entry skipped.`);continue}let u=this.looksLikeUUID(l)?await this.resolveLabelByUID(l):l;if(!u){this.logger.warn(`Grounding ${t}: PropertyDefault property UID '${l}' is not resolvable to exo__Asset_label \u2014 entry skipped.`);continue}let f=await this.getObsidianName(c,q.Namespace.EXOCMD.term("PropertyDefault_value"));if(!f){this.logger.warn(`Grounding ${t}: PropertyDefault '${u}' missing exocmd__PropertyDefault_value \u2014 entry skipped.`);continue}let d=await this.resolvePropertyDefaultValue(f,t,u);d!==null&&s.push({propertyName:u,value:d})}return s}async getUniversalCache(){if(this._universalCacheReady)return this._universalCacheValue;this._universalCacheReady=!0;let e=await this.findUniversalSingleton();if(!e)return this.logger.debug("[CommandResolver] No exocmd__UniversalDefaultTemplate instance found in the store; universal property-defaults and inheritance-rules will not be applied. This verdict is cached until invalidateCache() is called \u2014 if the store was still warming up, the next invalidation re-resolves it."),this._universalCacheValue=null,null;let t=await this.resolvePropertyDefaultsForSubject(e,ik,q.Namespace.EXOCMD.term("Template_propertyDefault")),n=await this.resolveInheritanceRulesForSubject(e,ik,q.Namespace.EXOCMD.term("Template_inheritanceRule"));return this._universalCacheValue={propertyDefaults:t,inheritanceRules:n},this._universalCacheValue}async findUniversalSingleton(){let e=q.Namespace.EXOCMD.term("UniversalDefaultTemplate"),t=e.value,i=(await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),e)).map(c=>c.subject).filter(c=>c instanceof hr.IRI);if(i.length>0)return this.pickUniversalSingleton(i);let s=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Instance_class"),void 0),o=[];for(let c of s){let l=!1;if(c.object instanceof hr.IRI)l=c.object.value===t||c.object.value.includes(nk);else if(c.object instanceof Jt.Literal){let u=this.unwrapWikilink(c.object.value);l=u==="exocmd__UniversalDefaultTemplate"||u===nk}l&&c.subject instanceof hr.IRI&&o.push(c.subject)}return this.pickUniversalSingleton(o)}pickUniversalSingleton(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=[...e].sort((n,i)=>n.value.localeCompare(i.value));return this.logger.warn(`Multiple UniversalDefaultTemplate singletons found (${t.length}); selecting deterministically by lexicographic UID order: ${t[0].value}`),t[0]}async resolveInheritanceRules(e,t){let n=await this.resolveInheritanceRulesForSubject(e,t,q.Namespace.EXOCMD.term("Grounding_inheritanceRule")),i=await this.getUniversalCache();return i&&i.inheritanceRules.length>0?(0,ZN.mergeInheritanceRules)(i.inheritanceRules,n):n}async resolveInheritanceRulesForSubject(e,t,n){let i=await this.tripleStore.match(e,n,void 0),s=[],o=t;for(let c of i){let l=await this.resolveRefTripleObject(c.object);if(!l)continue;let u=await this.resolveLabelRef(l,q.Namespace.EXOCMD.term("InheritanceRule_sourceProperty"));if(!u){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_sourceProperty \u2014 entry skipped.`);continue}let f=await this.resolveLabelRef(l,q.Namespace.EXOCMD.term("InheritanceRule_targetProperty"));if(!f){this.logger.warn(`Grounding ${o}: InheritanceRule missing/unresolvable exocmd__InheritanceRule_targetProperty \u2014 entry skipped.`);continue}let d=await this.tripleStore.match(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"),void 0),p,h;if(d.length>0){let E=await this.getObsidianName(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassCondition"));if(!E||!E.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(E)?(h=E,p=await this.resolveLabelByUID(E)??void 0):p=E}let g=await this.tripleStore.match(l,q.Namespace.EXOCMD.term("InheritanceRule_targetClassExclusion"),void 0),m=[],b=[],_=!1;for(let E of g){let w=null;if(E.object instanceof hr.IRI?w=this.iriToObsidianName(E.object.value)??E.object.value:E.object instanceof Jt.Literal&&(w=this.unwrapWikilink(E.object.value)),!w){_=!0;continue}if(this.looksLikeUUID(w)){b.push(w);let R=await this.resolveLabelByUID(w);R&&m.push(R)}else m.push(w)}if(_){this.logger.warn(`Grounding ${o}: InheritanceRule has unresolvable exocmd__InheritanceRule_targetClassExclusion entry \u2014 entire rule skipped (would otherwise expand scope by silently dropping the excluded class).`);continue}let S=await this.getLiteralValue(l,q.Namespace.EXOCMD.term("InheritanceRule_priority")),I=50;if(S!==null&&S!==""){let E=Number.parseInt(String(S),10);Number.isFinite(E)&&(I=E)}s.push({sourcePropertyName:u,targetPropertyName:f,targetClassCondition:p,targetClassConditionUid:h,targetClassExclusion:m,targetClassExclusionUids:b,priority:I})}return s}async resolveRefTripleObject(e){if(e instanceof hr.IRI)return e;if(e instanceof Jt.Literal){let t=this.normalizeWikilink(e.value);return t?this.findSubjectByUID(t):null}return null}async resolveLabelRef(e,t){let n=await this.getObsidianName(e,t);return n?this.looksLikeUUID(n)?this.resolveLabelByUID(n):n:null}async resolvePropertyDefaultValue(e,t,n){if(!this.looksLikeUUID(e))return`"[[${e}]]"`;let i=await this.findSubjectByUID(e);if(!i){let c=`${t}|${e}`;return this._fallbackWarnedKeys.has(c)||(this._fallbackWarnedKeys.add(c),this.logger.warn(this.capWarning(`Grounding ${t}: PropertyDefault '${n}' \u2192 value asset ${e} not in store; SKIPPING the property (the executor's own default applies). Previously this emitted a wikilink, i.e. a link written where a value belongs.`))),xQ.STRING_SCALAR_PROPERTIES.has(n)?null:`"[[${e}]]"`}return await this.assetIsTokenInvocation(i)?this.resolveTokenInvocation(i,e,t,n):await this.assetIsSubstitutionToken(i)?this.dispatchSubstitutionToken(i,e,t,n,void 0):(this.logger.debug(`Grounding ${t}: PropertyDefault '${n}' value '${e}' is not a SubstitutionToken \u2014 emitting wikilink form.`),`"[[${e}]]"`)}async dispatchSubstitutionToken(e,t,n,i,s){let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"));if(!o||!o.trim())return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' references SubstitutionToken '${t}' with no exocmd__SubstitutionToken_resolver \u2014 falling back to wikilink form.`),`"[[${t}]]"`;let c=o.trim();return tk.has(c)?s!==void 0?jQ(c,t,s):MQ(c,t):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' SubstitutionToken '${t}' declares unknown resolver-id '${c}' \u2014 falling back to wikilink form. Known ids: ${Array.from(tk).join(", ")}.`),`"[[${t}]]"`)}async resolveTokenInvocation(e,t,n,i){let s=await this.getObsidianName(e,q.Namespace.EXOCMD.term("TokenInvocation_token"));if(!s)return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' missing exocmd__TokenInvocation_token \u2014 entry skipped.`),null;let o=await this.getLiteralValue(e,q.Namespace.EXOCMD.term("TokenInvocation_parameter"))??"";if(!this.looksLikeUUID(s))return this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' references non-UUID token '${s}' \u2014 entry skipped.`),null;let c=await this.findSubjectByUID(s);return c?this.dispatchSubstitutionToken(c,s,n,i,o):(this.logger.warn(`Grounding ${n}: PropertyDefault '${i}' TokenInvocation '${t}' token ref '${s}' not found in store \u2014 entry skipped.`),null)}async assetIsTokenInvocation(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof hr.IRI){if(i.object.value===$Q||i.object.value.includes(rk))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__TokenInvocation"||s===rk)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("TokenInvocation_token"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as TokenInvocation via its exocmd__TokenInvocation_token property; exo__Instance_class was absent or unresolved.`),!0):!1}async assetIsSubstitutionToken(e){let t=await this.tripleStore.match(e,q.Namespace.EXO.term("Instance_class"),void 0);for(let i of t)if(i.object instanceof hr.IRI){if(i.object.value===kQ||i.object.value.includes(ek))return!0}else if(i.object instanceof Jt.Literal){let s=this.unwrapWikilink(i.object.value);if(s==="exocmd__SubstitutionToken"||s===ek)return!0}return(await this.tripleStore.match(e,q.Namespace.EXOCMD.term("SubstitutionToken_resolver"),void 0)).length>0?(this.logger.debug(`Asset ${e.value} classified as SubstitutionToken via its resolver property; exo__Instance_class was absent or unresolved.`),!0):!1}async resolveGroundingTypeReference(e){let t=await this.tripleStore.match(e,q.Namespace.EXOCMD.term("Grounding_type"),void 0);if(t.length===0)return null;let n=t[0].object;if(n instanceof hr.IRI)return(0,QN.resolveGroundingTypeFromIRI)(n.value);if(n instanceof Jt.Literal){let i=n.value,s=i.match(/^\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]$/i);return s?(0,QN.resolveGroundingTypeFromIRI)(`obsidian://vault/${s[1].toLowerCase()}.md`):(this.logger.warn(`[exocmd-grounding-type-literal-form] legacy literal-string form '${i}' for exocmd__Grounding_type on <${e.value}>. Migrate to wikilink form per RFC 9d20c91f Phase 3.`),null)}return null}async expandPrototypeChain(e){if(!e||!this.normalizeWikilink(e))return[];let t=[e],n=new Set([this.normalizeWikilink(e).toLowerCase()]),i=e;for(let s=0;s<Gl;s++){let o=this.extractUuidFromRef(i);if(!o)break;let c=null;try{let u=await this.findSubjectByUID(o);if(!u)break;c=await this.getLinkedValue(u,q.Namespace.EXO.term("Asset_prototype"))}catch(u){this.logger.debug(this.capWarning(`[expandPrototypeChain] store lookup failed at hop ${s} for '${i}': ${String(u)}`));break}if(!c)break;let l=this.normalizeWikilink(c).toLowerCase();if(n.has(l))break;n.add(l),t.push(c),i=c}return t}extractUuidFromRef(e){let t=this.normalizeWikilink(e);if(this.looksLikeUUID(t))return t;let n=this.extractPathBasename(t);return n&&this.looksLikeUUID(n)?n:null}async findSubjectByUID(e){if(this.tripleStore.findSubjectsByUUID){let n=await this.tripleStore.findSubjectsByUUID(e);if(n.length>0)return n[0]}let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_uid"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e)return n.subject;return null}async getLiteralValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal||i instanceof hr.IRI?i.value:null}looksLikeUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async resolveLabelByUID(e){let t=await this.findSubjectByUID(e);if(!t)return null;let n=await this.getLiteralValue(t,q.Namespace.EXO.term("Asset_label"));return n===null?null:PQ.test(n)?(0,JN.iriToObsidianName)(n)??n:n}async getClassAncestors(e){return(await this.getClassAncestorsWithDepth(e)).map(n=>n.ref)}async getClassAncestorsWithDepth(e){let t=this._ancestorDepthCache.get(e);if(t)return t;let n=new Map,i=new Set,s=await this.resolveClassFileIRI(e);if(!s)return[];let o=new Set([e]),c=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_uid"));c&&o.add(c);let l=await this.getLiteralValue(s,q.Namespace.EXO.term("Asset_label"));l&&o.add(l);let u=a((p,h)=>{if(o.has(p))return;let g=n.get(p);(g===void 0||h<g)&&n.set(p,h)},"setMin"),f=[{fileIRI:s,depth:0}];for(;f.length>0;){let p=f.shift();if(!p)break;let{fileIRI:h,depth:g}=p;if(g>=Gl||i.has(h.value))continue;i.add(h.value);let m=await this.tripleStore.match(h,q.Namespace.EXO.term("Class_superClass"),void 0);for(let b of m){let _=b.object;if(!(_ instanceof hr.IRI))continue;let S=g+1,I=_.value.startsWith("obsidian://vault/"),E=this.iriToObsidianName(_.value);E&&u(E,S);let w=null;if(I?w=_:E&&(w=await this.resolveClassFileIRI(E)),!w)continue;let R=await this.getLiteralValue(w,q.Namespace.EXO.term("Asset_uid"));R&&u(R,S),i.has(w.value)||f.push({fileIRI:w,depth:S})}}let d=Array.from(n.entries()).map(([p,h])=>({ref:p,depth:h}));return this._ancestorDepthCache.set(e,d),d}async resolveClassFileIRI(e){if(this.looksLikeUUID(e))return this.findSubjectByUID(e);let t=await this.findUidByLabel(e);return t?this.findSubjectByUID(t):null}async findUidByLabel(e){let t=await this.tripleStore.match(void 0,q.Namespace.EXO.term("Asset_label"),void 0);for(let n of t)if(n.object instanceof Jt.Literal&&n.object.value===e&&n.subject instanceof hr.IRI){let i=await this.tripleStore.match(n.subject,q.Namespace.EXO.term("Asset_uid"),void 0);if(i.length>0&&i[0].object instanceof Jt.Literal)return i[0].object.value}return null}async getLinkedUID(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof hr.IRI){let s=await this.tripleStore.match(i,q.Namespace.EXO.term("Asset_uid"),void 0);return s.length>0&&s[0].object instanceof Jt.Literal?s[0].object.value:i.value.split("/").pop()?.replace(".md","")??null}return i instanceof Jt.Literal?this.normalizeWikilink(i.value):null}async getLinkedUIDs(e,t){let n=await this.tripleStore.match(e,t,void 0),i=[];for(let s of n){let o=s.object;if(o instanceof hr.IRI){let c=await this.tripleStore.match(o,q.Namespace.EXO.term("Asset_uid"),void 0);if(c.length>0&&c[0].object instanceof Jt.Literal)i.push(c[0].object.value);else{let l=o.value.split("/").pop()?.replace(".md","");l&&i.push(l)}}else if(o instanceof Jt.Literal){let c=this.normalizeWikilink(o.value);c&&i.push(c)}}return i}async getLinkedValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.normalizeWikilink(i.value):i instanceof hr.IRI?this.iriToObsidianName(i.value)??i.value:null}async getObsidianName(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;return i instanceof Jt.Literal?this.unwrapWikilink(i.value):i instanceof hr.IRI?this.iriToObsidianName(i.value)??i.value:null}unwrapWikilink(e){if(!e)return e;let t=e.trim().replace(/^"|"$/g,"");if(t.startsWith("http://")||t.startsWith("https://"))return this.iriToObsidianName(t)??t;let n=t.match(/^\[\[([^\]|]+)\|([^\]]+)\]\]$/);if(n)return n[2].trim();let i=t.match(/^\[\[([^\]|]+)\]\]$/);if(i){let s=i[1].trim();return s.startsWith("http://")||s.startsWith("https://")?this.iriToObsidianName(s)??s:s}return t}async getObsidianWikilinkValue(e,t){let n=await this.tripleStore.match(e,t,void 0);if(n.length===0)return null;let i=n[0].object;if(i instanceof Jt.Literal)return this.resolveWikilinkAlias(i.value);if(i instanceof hr.IRI){let s=this.iriToObsidianName(i.value);return s?`"[[${s}]]"`:i.value}return null}async resolveWikilinkAlias(e){let t=e.match(/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]\]/);if(!t)return e;let n=t[1],i=await this.findSubjectByUID(n);if(!i)return e;let s=await this.getLiteralValue(i,q.Namespace.EXO.term("Asset_label"));return s?e.replace(`[[${n}]]`,`[[${n}|${s}]]`):e}iriToObsidianName(e){return(0,JN.iriToObsidianName)(e)}normalizeWikilink(e){let t=e.replace(/["'[\]]/g,"").trim(),n=t.indexOf("|");return n>=0?t.substring(0,n):t}};fa.CommandResolver=RA;fa.CommandResolver=RA=AQ([(0,RQ.injectable)(),IQ("design:paramtypes",[Object,Object])],RA)});var xA=T(CA=>{"use strict";Object.defineProperty(CA,"__esModule",{value:!0});CA.validateExoQLAllowlist=UQ;var Z0=yh();function UQ(r){if(!r||typeof r!="object")return;let e=r;if(e.type==="update"){let t=r.updates??[];for(let n of t)if(n?.type==="load")throw new Z0.ExoQLForbiddenKeywordError("LOAD");throw new Z0.ExoQLForbiddenKeywordError("UPDATE")}if(e.type==="query"){if(e.from){let t=Array.isArray(e.from.default)&&e.from.default.length>0,n=Array.isArray(e.from.named)&&e.from.named.length>0;if(t||n)throw new Z0.ExoQLForbiddenKeywordError("FROM")}if(Array.isArray(e.where))for(let t of e.where)eb(t);if(Array.isArray(e.template))for(let t of e.template)eb(t)}}a(UQ,"validateExoQLAllowlist");function eb(r){if(!r||typeof r!="object")return;if(r.type==="service")throw new Z0.ExoQLForbiddenKeywordError("SERVICE");if(Array.isArray(r.patterns))for(let t of r.patterns)eb(t);let e=r.where;if(Array.isArray(e))for(let t of e)eb(t)}a(eb,"walkPatternForBannedKeywords")});var OA=T(tb=>{"use strict";Object.defineProperty(tb,"__esModule",{value:!0});tb.DEFAULT_EVAL_CONFIG=void 0;tb.DEFAULT_EVAL_CONFIG=Object.freeze({enabled:!0,maxNestedEvalCount:100,maxAggregateEvalMillis:1e4})});var rb=T(PA=>{"use strict";Object.defineProperty(PA,"__esModule",{value:!0});PA.evaluateWithExoEval=HQ;var BQ=ff(),VQ=yf(),GQ=kf(),qQ=xA(),WQ=OA(),zQ=yh();async function HQ(r,e={}){if(typeof r!="string")throw new TypeError("evaluateWithExoEval: sparql must be a string");let n=new BQ.ExoQLParser().parse(r);if((0,qQ.validateExoQLAllowlist)(n),!{...WQ.DEFAULT_EVAL_CONFIG,...e.config??{}}.enabled)throw new zQ.ExoQLEvalDisabledError;let s="queryType"in n&&typeof n.queryType=="string"?n.queryType:"SELECT";if(!e.store)return s==="ASK"?{kind:"ask",result:!1}:s==="CONSTRUCT"?{kind:"construct",triples:[]}:{kind:"select",rows:[]};let c=new VQ.ExoQLAlgebraTranslator().translate(n),l=new GQ.ExoQLQueryExecutor(e.store);return l.isAskQuery(c)?{kind:"ask",result:await l.executeAsk(c)}:l.isConstructQuery(c)?{kind:"construct",triples:await l.executeConstruct(c)}:{kind:"select",rows:await l.executeAll(c)}}a(HQ,"evaluateWithExoEval")});var vs=T(nb=>{"use strict";Object.defineProperty(nb,"__esModule",{value:!0});nb.DateFormatter=void 0;var FA=class r{static{a(this,"DateFormatter")}static toISOTimestamp(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}static toLocalTimestamp(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${i}T${s}:${o}:${c}`}static toDateWikilink(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`"[[${t}-${n}-${i}]]"`}static getTodayWikilink(){return r.toDateWikilink(new Date)}static toDateString(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}static parseWikilink(e){let n=e.replace(/^["']|["']$/g,"").match(/\[\[(\d{4}-\d{2}-\d{2})\]\]/);return n?n[1]:null}static addDays(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}static isSameDay(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}static getTodayStartTimestamp(){let e=new Date;return e.setHours(0,0,0,0),r.toLocalTimestamp(e)}static toTimestampAtStartOfDay(e){let t=e.split("-").map(Number);if(t.length!==3||t.some(isNaN))throw new Error(`Invalid date format: ${e}. Expected YYYY-MM-DD`);let[n,i,s]=t,o=new Date(n,i-1,s,0,0,0,0);if(isNaN(o.getTime()))throw new Error(`Invalid date values: ${e}`);return r.toLocalTimestamp(o)}static normalizeTimestamp(e){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e))return e;let t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid timestamp format: ${e}`);return r.toISOTimestamp(t)}static isISOTimestamp(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(e)}};nb.DateFormatter=FA});var _h=T(ib=>{"use strict";Object.defineProperty(ib,"__esModule",{value:!0});ib.liveClock=KQ;ib.frozenClock=YQ;function KQ(){return{now:a(()=>new Date,"now")}}a(KQ,"liveClock");function YQ(r){let e=new Date(r);return{now:a(()=>new Date(e.getTime()),"now")}}a(YQ,"frozenClock")});var ak=T(da=>{"use strict";var XQ=da&&da.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},QQ=da&&da.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},wh;Object.defineProperty(da,"__esModule",{value:!0});da.PreconditionEvaluator=void 0;var JQ=ct(),ZQ=ff(),eJ=yf(),ok=kf(),tJ=rb(),Sh=vs(),rJ=_h(),Eh=wh=class{static{a(this,"PreconditionEvaluator")}constructor(e,t,n){this.hostFunctions=new Map,this.askCache=new Map,this.tripleStore=e,this.queryBodyResolver=t,this.clock=n?.clock??(0,rJ.liveClock)()}async evaluate(e,t,n){if(!e)return!0;let i=new Map;return await this.evaluateNode(e,t,n,i)==="yes"}async evaluateNode(e,t,n,i){if(e.broken)return"unknown";if(e.composite){let{op:s,children:o}=e.composite;if(o.length===0)return"unknown";let c=await Promise.all(o.map(l=>this.evaluateNode(l,t,n,i)));return s==="all"?c.includes("no")?"no":c.includes("unknown")?"unknown":"yes":c.includes("yes")?"yes":c.includes("unknown")?"unknown":"no"}if(e.not){let s=await this.evaluateNode(e.not,t,n,i);return s==="unknown"?"unknown":s==="yes"?"no":"yes"}return e.sparqlAsk?await this.evaluateSparqlAskMemoized(e.sparqlAsk,t,i)?"yes":"no":e.query?await this.evaluateQueryRef(e.query,t)?"yes":"no":e.hostFunction?this.evaluateHostFunction(e.hostFunction,t,n)?"yes":"no":"yes"}evaluateSparqlAskMemoized(e,t,n){let i=n.get(e);if(i!==void 0)return i;let s=this.evaluateSparqlAsk(e,t);return n.set(e,s),s}async evaluateQueryRef(e,t){if(!this.queryBodyResolver)return!1;try{let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return!1;let i=this.substituteVariables(n,t),s=await(0,tJ.evaluateWithExoEval)(i,{store:this.tripleStore});return s.kind!=="ask"?!1:s.result}catch{return!1}}registerHostFunction(e,t){this.hostFunctions.set(e,t)}hasHostFunction(e){return this.hostFunctions.has(e)}evaluateHostFunctionSync(e,t,n){return this.hostFunctions.has(e)?this.evaluateHostFunction(e,t,n):null}invalidateCache(){this.askCache.clear()}compileAsk(e){let t=this.substituteVariables(e,wh.SENTINEL_IRI),i=new ZQ.ExoQLParser().parse(t),o=new eJ.ExoQLAlgebraTranslator().translate(i);return new ok.ExoQLQueryExecutor(this.tripleStore).isAskQuery(o)?o:null}evaluateHostFunction(e,t,n){let i=this.hostFunctions.get(e);if(!i)return!0;let s=n?{...n,targetIRI:t}:{targetIRI:t};try{return i(s)}catch{return!1}}async evaluateSparqlAsk(e,t){try{let n=wh.TEMPORAL_TOKEN.test(e),i=n?Sh.DateFormatter.toDateString(this.clock.now()):null,s=this.askCache.get(e);if(s===void 0||n&&s.day!==i){let l=this.compileAsk(e);if(!l)return!1;s={day:i,compiled:l},this.askCache.set(e,s)}let o=JSON.parse(JSON.stringify(s.compiled).replaceAll(wh.SENTINEL_IRI,t));return await new ok.ExoQLQueryExecutor(this.tripleStore).executeAsk(o)}catch{return!1}}substituteVariables(e,t){let n=this.clock.now(),i=n.toISOString(),s=n.getFullYear(),o=n.getMonth(),c=n.getDate(),l=n.getDay(),u=Sh.DateFormatter.toDateString(n),f=Sh.DateFormatter.toDateString(new Date(s,o,c-1)),d=(l+6)%7,p=Sh.DateFormatter.toDateString(new Date(s,o,c-d)),h=Sh.DateFormatter.toDateString(new Date(s,o,c-d-7)),g=`${s}-${String(o+1).padStart(2,"0")}-01`,m=o===0?11:o-1,_=`${o===0?s-1:s}-${String(m+1).padStart(2,"0")}-01`,S=`${s}-01-01`;return e.replace(/\$target\b/g,`<${t}>`).replace(/\$now\b/g,`"${i}"^^xsd:dateTime`).replace(/\$yesterday\b/g,`"${f}"^^xsd:date`).replace(/\$thisWeekStart\b/g,`"${p}"^^xsd:date`).replace(/\$lastWeekStart\b/g,`"${h}"^^xsd:date`).replace(/\$thisMonthStart\b/g,`"${g}"^^xsd:date`).replace(/\$lastMonthStart\b/g,`"${_}"^^xsd:date`).replace(/\$thisYearStart\b/g,`"${S}"^^xsd:date`).replace(/\$today\b/g,`"${u}"^^xsd:date`)}};da.PreconditionEvaluator=Eh;Eh.SENTINEL_IRI="urn:exocortex:cache-sentinel:target";Eh.TEMPORAL_TOKEN=/\$(?:now|today|yesterday|thisWeekStart|lastWeekStart|thisMonthStart|lastMonthStart|thisYearStart)\b/;da.PreconditionEvaluator=Eh=wh=XQ([(0,JQ.injectable)(),QQ("design:paramtypes",[Object,Object,Object])],Eh)});var ck=T(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.hasUidFilename=pa.hasNonUidFilename=void 0;pa.registerDefaultHostFunctions=sJ;var nJ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t!==e},"hasNonUidFilename");pa.hasNonUidFilename=nJ;var iJ=a(r=>{let e=r.assetUid;if(typeof e!="string"||e.trim()==="")return!1;let t=r.fileBasename;return typeof t!="string"?!1:t===e},"hasUidFilename");pa.hasUidFilename=iJ;function sJ(r){r.registerHostFunction("hasNonUidFilename",pa.hasNonUidFilename),r.registerHostFunction("hasUidFilename",pa.hasUidFilename)}a(sJ,"registerDefaultHostFunctions")});var ob=T(sb=>{"use strict";Object.defineProperty(sb,"__esModule",{value:!0});sb.liveUidGenerator=oJ;sb.seededUidGenerator=cJ;var DA=Sl();function oJ(){return{next:a(()=>(0,DA.v4)(),"next")}}a(oJ,"liveUidGenerator");var aJ="6ba7b810-9dad-11d1-80b4-00c04fd430c8";function cJ(r){let e=0,t=(0,DA.v5)(r,aJ);return{next:a(()=>{let n=`${r}#${e}`;return e+=1,(0,DA.v5)(n,t)},"next")}}a(cJ,"seededUidGenerator")});var lb=T(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.registerResolver=br;wc.getResolver=uJ;wc.isResolverModifierAware=fJ;wc.getRegisteredResolverIds=dJ;wc.clearResolvers=pJ;wc.installDefaultResolvers=vJ;var lJ=vs(),cb=new Map,LA=new Set;function br(r,e,t=!1){cb.set(r,e),t&&LA.add(r)}a(br,"registerResolver");function uJ(r){return cb.get(r)}a(uJ,"getResolver");function fJ(r){return LA.has(r)}a(fJ,"isResolverModifierAware");function dJ(){return Array.from(cb.keys())}a(dJ,"getRegisteredResolverIds");function pJ(){cb.clear(),LA.clear()}a(pJ,"clearResolvers");function En(r){return r<10?`0${r}`:String(r)}a(En,"pad2");var hJ=["January","February","March","April","May","June","July","August","September","October","November","December"],mJ=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],gJ=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],yJ=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function bJ(r){let e=["th","st","nd","rd"],t=r%100;return`${r}${e[(t-20)%10]||e[t]||e[0]}`}a(bJ,"ordinalDay");var _J=/YYYY|YY|MMMM|MMM|MM|M|Do|DD|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|A|a/g;function SJ(r,e){let t=(r.getHours()+11)%12+1;return e.replace(_J,n=>{switch(n){case"YYYY":return String(r.getFullYear());case"YY":return En(r.getFullYear()%100);case"MMMM":return hJ[r.getMonth()];case"MMM":return mJ[r.getMonth()];case"MM":return En(r.getMonth()+1);case"M":return String(r.getMonth()+1);case"Do":return bJ(r.getDate());case"DD":return En(r.getDate());case"D":return String(r.getDate());case"dddd":return gJ[r.getDay()];case"ddd":return yJ[r.getDay()];case"HH":return En(r.getHours());case"H":return String(r.getHours());case"hh":return En(t);case"h":return String(t);case"mm":return En(r.getMinutes());case"m":return String(r.getMinutes());case"ss":return En(r.getSeconds());case"s":return String(r.getSeconds());case"A":return r.getHours()<12?"AM":"PM";case"a":return r.getHours()<12?"am":"pm";default:return n}})}a(SJ,"formatDate");function lk(r,e,t){let n=r.getDate(),i=new Date(r.getTime());i.setDate(1),t==="M"?i.setMonth(i.getMonth()+e):i.setFullYear(i.getFullYear()+e);let s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(n,s)),i}a(lk,"addMonthsClamped");function wJ(r,e){if(!e)return r;let t=e.match(/^([+-])(\d+)([dwMy])?$/);if(!t)return r;let n=(t[1]==="-"?-1:1)*parseInt(t[2],10),i=t[3]??"d",s=new Date(r.getTime());switch(i){case"d":s.setDate(s.getDate()+n);break;case"w":s.setDate(s.getDate()+n*7);break;case"M":s=lk(s,n,"M");break;case"y":s=lk(s,n,"y");break}return isNaN(s.getTime())?r:s}a(wJ,"applyDateOffset");function EJ(r){if(!r)return{offset:null,format:null};let e=r.indexOf(":");if(e<0)return{offset:r,format:null};let t=r.slice(0,e),n=r.slice(e+1);return{offset:t||null,format:n||null}}a(EJ,"parseDateModifier");function ab(r,e){return(t,n)=>{let{offset:i,format:s}=EJ(n),o=new Date;return r!==0&&o.setDate(o.getDate()+r),o=wJ(o,i),SJ(o,s??e)}}a(ab,"makeDateResolver");function vJ(){br("today",()=>{let r=new Date;return`${r.getFullYear()}-${En(r.getMonth()+1)}-${En(r.getDate())}`}),br("todayStart",()=>lJ.DateFormatter.getTodayStartTimestamp()),br("date",ab(0,"YYYY-MM-DD"),!0),br("now",ab(0,"YYYY-MM-DDTHH:mm:ss"),!0),br("tomorrow",ab(1,"YYYY-MM-DD"),!0),br("yesterday",ab(-1,"YYYY-MM-DD"),!0),br("target",r=>r.targetIRI?`"[[${r.targetIRI}]]"`:""),br("targetFolder",r=>{if(!r.targetFilePath)return"";let e=r.targetFilePath.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}),br("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.")}),br("nowTimestamp",()=>{let r=new Date;return`${r.getFullYear()}-${En(r.getMonth()+1)}-${En(r.getDate())}T${En(r.getHours())}:${En(r.getMinutes())}:${En(r.getSeconds())}`}),br("nowDate",()=>{let r=new Date;return`${r.getFullYear()}-${En(r.getMonth()+1)}-${En(r.getDate())}`}),br("nowYear",()=>String(new Date().getFullYear())),br("nowMonth",()=>En(new Date().getMonth()+1)),br("userInputLabel",r=>{let e=r.userInput?.label;return typeof e=="string"?e:""}),br("userInput",(r,e)=>{if(!e)return null;let t=r.userInput?.[e];return typeof t=="string"?t:t==null?null:String(t)}),br("targetProperty",(r,e)=>{if(!e||!r.targetFm)return null;let t=r.targetFm[e];return t==null?null:Array.isArray(t)?t.map(String):String(t)}),br("targetRefProperty",(r,e)=>{if(!e)return null;let t=e.indexOf("|");if(t<0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!n||!i)return null;let s=r.targetRefFm?.[n];if(!s)return null;let o=s[i];return o==null?null:Array.isArray(o)?o.length>0?String(o[0]):null:String(o)}),br("labelAsArray",r=>{let e=r.userInput?.label;return typeof e=="string"&&e.length>0?[e]:[]}),br("groundingTargetClass",r=>r.groundingTargetClassUid?`"[[${r.groundingTargetClassUid}]]"`:null),br("targetClassSelf",r=>{if(!r.targetFilePath)return null;let e=r.targetFilePath.replace(/^\/+/,""),n=e.slice(e.lastIndexOf("/")+1).replace(/\.md$/i,"");return n.length>0?`"[[${n}]]"`:null})}a(vJ,"installDefaultResolvers")});var kA=T(ub=>{"use strict";Object.defineProperty(ub,"__esModule",{value:!0});ub.resolveTemplateBody=AJ;ub.stripTemplateFrontmatter=IJ;var NA=lb();(0,NA.installDefaultResolvers)();var TJ=/\$([A-Za-z][A-Za-z0-9_]*)((?:[+-]\d+[dwMy])?(?::[A-Za-z0-9:./-]+)?)/g;function AJ(r,e={}){return r.replace(TJ,(t,n,i)=>{let s=(0,NA.getResolver)(n);if(s===void 0)return t;let o=s(e,i.length>0?i:void 0);return typeof o!="string"||o.length===0?t:(0,NA.isResolverModifierAware)(n)?o:o+i})}a(AJ,"resolveTemplateBody");function IJ(r){let e=r.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return e?r.slice(e[0].length):r}a(IJ,"stripTemplateFrontmatter")});var pb=T(jf=>{"use strict";Object.defineProperty(jf,"__esModule",{value:!0});jf.registerOrderSpecLoader=RJ;jf.clearOrderSpecLoader=CJ;jf.loadDefaultSpec=xJ;jf.orderProperties=OJ;var fb=null,Ec,db=!1;function RJ(r){fb=r,Ec=void 0,db=!1}a(RJ,"registerOrderSpecLoader");function CJ(){fb=null,Ec=void 0,db=!1}a(CJ,"clearOrderSpecLoader");function xJ(){if(Ec!==void 0)return Ec;if(!fb)return Ec=null,null;try{Ec=fb()}catch(r){db||(console.warn("[OrderSpecResolver] loader threw, falling back to insertion order:",r),db=!0),Ec=null}return Ec}a(xJ,"loadDefaultSpec");function OJ(r,e){if(!e||e.head.length===0&&e.tail.length===0)return r;let t=Object.keys(r),n=new Set(e.head),i=new Set(e.tail),s=e.head.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),o=e.tail.filter(u=>Object.prototype.hasOwnProperty.call(r,u)),c=t.filter(u=>!n.has(u)&&!i.has(u));e.middleStrategy==="alphabetical"&&c.sort((u,f)=>u.localeCompare(f));let l={};for(let u of s)l[u]=r[u];for(let u of c)l[u]=r[u];for(let u of o)l[u]=r[u];return l}a(OJ,"orderProperties")});var ii=T(hb=>{"use strict";Object.defineProperty(hb,"__esModule",{value:!0});hb.DI_TOKENS=void 0;hb.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 jA=T(mb=>{"use strict";Object.defineProperty(mb,"__esModule",{value:!0});mb.RDFVocabularyMapper=void 0;var Cr=Ti(),uk=Le(),Te=Wt(),MA=class{static{a(this,"RDFVocabularyMapper")}constructor(){this.propertyMappings=new Map([["exo__Instance_class",Te.Namespace.RDF.term("type")],["exo__Asset_isDefinedBy",Te.Namespace.RDFS.term("isDefinedBy")],["exo__Class_superClass",Te.Namespace.RDFS.term("subClassOf")],["exo__Property_range",Te.Namespace.RDFS.term("range")],["exo__Property_domain",Te.Namespace.RDFS.term("domain")],["exo__Property_superProperty",Te.Namespace.RDFS.term("subPropertyOf")]])}generateClassHierarchyTriples(){let e=[];return e.push(new Cr.Triple(Te.Namespace.EXO.term("Asset"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.RDFS.term("Resource"))),e.push(new Cr.Triple(Te.Namespace.EXO.term("Class"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.RDFS.term("Class"))),e.push(new Cr.Triple(Te.Namespace.EXO.term("Property"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.RDF.term("Property"))),e.push(new Cr.Triple(Te.Namespace.EMS.term("Task"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EMS.term("Project"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EMS.term("Area"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EMS.term("Workflow"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EMS.term("WorkflowState"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EMS.term("WorkflowTransition"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EXOCMD.term("Command"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EXOCMD.term("Precondition"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EXOCMD.term("Grounding"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e.push(new Cr.Triple(Te.Namespace.EXOCMD.term("CommandBinding"),Te.Namespace.RDFS.term("subClassOf"),Te.Namespace.EXO.term("Asset"))),e}generatePropertyHierarchyTriples(){let e=[];return e.push(new Cr.Triple(Te.Namespace.EXO.term("Instance_class"),Te.Namespace.RDFS.term("subPropertyOf"),Te.Namespace.RDF.term("type"))),e.push(new Cr.Triple(Te.Namespace.EXO.term("Asset_isDefinedBy"),Te.Namespace.RDFS.term("subPropertyOf"),Te.Namespace.RDFS.term("isDefinedBy"))),e.push(new Cr.Triple(Te.Namespace.EXO.term("Class_superClass"),Te.Namespace.RDFS.term("subPropertyOf"),Te.Namespace.RDFS.term("subClassOf"))),e.push(new Cr.Triple(Te.Namespace.EXO.term("Property_range"),Te.Namespace.RDFS.term("subPropertyOf"),Te.Namespace.RDFS.term("range"))),e.push(new Cr.Triple(Te.Namespace.EXO.term("Property_domain"),Te.Namespace.RDFS.term("subPropertyOf"),Te.Namespace.RDFS.term("domain"))),e.push(new Cr.Triple(Te.Namespace.EXO.term("Property_superProperty"),Te.Namespace.RDFS.term("subPropertyOf"),Te.Namespace.RDFS.term("subPropertyOf"))),e}generateMappedTriple(e,t,n){let i=this.propertyMappings.get(t);if(!i)return null;let s;if(n instanceof uk.IRI)s=n;else{let o=Te.Namespace.fromPropertyKey(n);s=o?o.namespace.term(o.localName):new uk.IRI(n)}return new Cr.Triple(e,i,s)}hasMappingFor(e){return this.propertyMappings.has(e)}};mb.RDFVocabularyMapper=MA});var gb=T(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.OBSIDIAN_VAULT_SCHEME=void 0;ha.vaultPathToIRI=PJ;ha.iriToVaultPath=FJ;ha.OBSIDIAN_VAULT_SCHEME="obsidian://vault/";function PJ(r){let e=r.startsWith("./")?r.slice(2):r;return`${ha.OBSIDIAN_VAULT_SCHEME}${encodeURI(e)}`}a(PJ,"vaultPathToIRI");function FJ(r){if(!r.startsWith(ha.OBSIDIAN_VAULT_SCHEME))return null;let e=r.slice(ha.OBSIDIAN_VAULT_SCHEME.length);try{return decodeURI(e)}catch{return null}}a(FJ,"iriToVaultPath")});var bb=T(vh=>{"use strict";Object.defineProperty(vh,"__esModule",{value:!0});vh.derivePath=fk;vh.deriveUrl=DJ;vh.deriveLegacyFlatPath=LJ;var $A="assetspaces",yb=/^[A-Za-z0-9._-]+$/;function fk(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0||/^file:\/\//i.test(e))return null;e=e.replace(/\/+$/,""),e=e.replace(/\.git$/i,"");let t=null;if(!e.includes("://")){let o=/^[^/@\s]+@[^/:\s]+:(.+)$/.exec(e);o&&(t=o[1])}if(t===null){let o=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"");o=o.replace(/^[^/@]+@/,"");let c=o.indexOf("/");if(c<0)return null;t=o.slice(c+1)}let n=t.split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!yb.test(i)||!yb.test(s)?null:`${$A}/${i}/${s}`}a(fk,"derivePath");function DJ(r){if(typeof r!="string")return null;let e=r.trim();if(e.length===0)return null;e=e.replace(/^\/+/,"").replace(/\/+$/,"");let t=`${$A}/`;if(!e.startsWith(t))return null;let n=e.slice(t.length).split("/").filter(o=>o.length>0);if(n.length<2)return null;let i=n[0],s=n[1];return i==="."||i===".."||s==="."||s===".."||!yb.test(i)||!yb.test(s)?null:`https://github.com/${i}/${s}`}a(DJ,"deriveUrl");function LJ(r){let e=fk(r);if(e===null)return null;let t=e.split("/")[2];if(t===void 0||t.length===0)return null;let n=t.startsWith("exoas-")?t.slice(6):t;return n.length===0?null:`${$A}/${n}`}a(LJ,"deriveLegacyFlatPath")});var _b=T(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.FILE_SPACE_CLASS_UID=void 0;Ts.frontmatterDeclaresFileSpace=kJ;Ts.discoverFileSpaceExclusions=jJ;var NJ=bb();Ts.FILE_SPACE_CLASS_UID="aad8913e-5e9f-4047-879d-93cc46befd52";var dk=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,UA=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function hk(r){let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;dk.lastIndex=0;let i;for(;(i=dk.exec(n))!==null;)t.push(i[1].trim())}return t}a(hk,"wikilinkTargets");function kJ(r){return r?hk(r.exo__Instance_class).some(e=>UA.test(e)&&e.toLowerCase()===Ts.FILE_SPACE_CLASS_UID):!1}a(kJ,"frontmatterDeclaresFileSpace");function pk(r,e){try{return r.getFrontmatter(e)}catch{return null}}a(pk,"readFrontmatterSafe");function MJ(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(MJ,"readSource");function jJ(r){let e=[],t=[],n=[],i=new Map,s=a((c,l)=>{if(UA.test(c))return c.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;let u=r.getFirstLinkpathDest(c,l);if(u==null)return!1;let f=i.get(u.path);if(f!==void 0)return f;let p=pk(r,u)?.exo__Asset_uid,h=typeof p=="string"&&p.toLowerCase()===Ts.FILE_SPACE_CLASS_UID;return i.set(u.path,h),h},"isFileSpaceClassRef"),o=a(c=>c.some(l=>UA.test(l)&&l.toLowerCase()===Ts.FILE_SPACE_CLASS_UID),"hasUuidFormRef");for(let c of r.getAllFiles()){let l=pk(r,c);if(!l)continue;let u=hk(l.exo__Instance_class);if(!u.some(h=>s(h,c.path)))continue;t.push(c.path),o(u)||n.push(`FileSpace declaration ${c.path} references the class via a label-form link only \u2014 the sync layer will not pick it up; use the UUID-form wikilink [[${Ts.FILE_SPACE_CLASS_UID}]] (UID-canon)`);let f=MJ(l);if(f===null){n.push(`FileSpace declaration ${c.path} has no exo__AssetSpace_source/_git \u2014 mount path underivable, content NOT excluded from the index`);continue}let d=(0,NJ.derivePath)(f);if(d===null){n.push(`FileSpace declaration ${c.path}: cannot derive mount path from source "${f}" \u2014 content NOT excluded from the index`);continue}let p=`${d}/`;c.path.startsWith(p)&&n.push(`FileSpace declaration ${c.path} lies INSIDE its own mount ${p} \u2014 it will be excluded from the index together with the content; move the declaration outside the mount folder`),e.push(p)}return{prefixes:e,declarationPaths:t,warnings:n}}a(jJ,"discoverFileSpaceExclusions")});var Wl=T(Lt=>{"use strict";var $J=Lt&&Lt.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},UJ=Lt&&Lt.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},mk=Lt&&Lt.__param||function(r,e){return function(t,n){e(t,n,r)}},GA;Object.defineProperty(Lt,"__esModule",{value:!0});Lt.NoteToRDFConverter=Lt.LEGACY_YAML_KEYS=Lt.LEGACY_UNPREFIXED_ASSET_FIELDS=Lt.UNPREFIXED_ASSET_FIELDS=void 0;Lt.canonicalYamlKey=WJ;Lt.isPosixBracketExpression=bk;Lt.normaliseExcludedFolders=_k;Lt.isPathExcluded=Sk;var BA=ct(),xr=Ti(),As=Le(),Mn=Ye(),gk=ir(),ar=Wt(),yk=ii(),BJ=jA(),VJ=Qp(),VA=gb(),Pi=$v(),GJ=_b();Lt.UNPREFIXED_ASSET_FIELDS=new Set(["draft","pinned","aliases"]);Lt.LEGACY_UNPREFIXED_ASSET_FIELDS=new Set(["archived"]);Lt.LEGACY_YAML_KEYS=new Map([...Lt.LEGACY_UNPREFIXED_ASSET_FIELDS].map(r=>[`exo__Asset_${r}`,[r]]));var qJ=/^exo__Asset_(.+)$/;function WJ(r){let e=qJ.exec(r);return e&&Lt.UNPREFIXED_ASSET_FIELDS.has(e[1])?e[1]:Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(r)?`exo__Asset_${r}`:r}a(WJ,"canonicalYamlKey");function bk(r){return/^:[^\s[\]|]+:$/.test(r)}a(bk,"isPosixBracketExpression");function _k(r){return Array.isArray(r)?r.map(e=>String(e).replace(/\\/g,"/").trim()).filter(e=>e.length>0).map(e=>e.endsWith("/")?e:`${e}/`):[]}a(_k,"normaliseExcludedFolders");function Sk(r,e){if(e.length===0)return!1;let t=r.replace(/\\/g,"/");for(let n of e)if(t.startsWith(n))return!0;return!1}a(Sk,"isPathExcluded");function zJ(r){if(!r)return"";let e=r.replace(/\\/g,"/");for(;e.startsWith("/");)e=e.slice(1);for(;e.endsWith("/");)e=e.slice(0,-1);return e.length>0?`${e}/`:""}a(zJ,"normaliseSubjectIriPrefix");var ql=GA=class{static{a(this,"NoteToRDFConverter")}constructor(e,t=VJ.NullLogger,n={}){this.vault=e,this.logger=t,this.BODY_WIKILINK_PATTERN=/(?<!!)\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g,this.pendingExtraTriples=[],this.preResolvedTargetFm=new Map,this.vocabularyMapper=new BJ.RDFVocabularyMapper,this.subjectIriPrefix=zJ(n.subjectIriPrefix),this.emitInstanceClassAsUid=n.emitInstanceClassAsUid??!1}async convertNote(e){let t=this.vault.getFrontmatterWithFallback?await this.vault.getFrontmatterWithFallback(e):this.vault.getFrontmatter(e);return this.convertNoteFromFrontmatter(e,t)}async convertNoteFromFrontmatter(e,t){if(!t)return[];await this.preResolveWikilinkTargets(t);let n=this.notePathToIRI(e.path),i=ar.Namespace.EXO.term("Asset_filename"),s=new xr.Triple(n,i,new Mn.Literal(e.basename));if(Pi.Exo003Parser.isExo003Format(t)){let o=await this.convertExo003Note(e,t);return[s,...o]}return this.convertLegacyNote(e,t,s)}async convertLegacyNote(e,t,n){this.pendingExtraTriples=[];let i=[n],s=this.notePathToIRI(e.path),o,c,l,u=!1,f=ar.Namespace.EXO.term("Statement").value;for(let[m,b]of Object.entries(t)){if(Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)&&Object.prototype.hasOwnProperty.call(t,`exo__Asset_${m}`))continue;let _=Lt.UNPREFIXED_ASSET_FIELDS.has(m)||Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m)?`exo__Asset_${m}`:m;if(!this.isExocortexProperty(_))continue;let S=this.propertyKeyToIRI(_),I=Array.isArray(b)?b:[b];for(let E of I)if(!((m==="exo__Asset_label"||Lt.UNPREFIXED_ASSET_FIELDS.has(m)||Lt.LEGACY_UNPREFIXED_ASSET_FIELDS.has(m))&&(E==null||typeof E=="string"&&E.trim()==="")))if(m==="exo__Instance_class"){let w=this.valueToClassURI(E);i.push(new xr.Triple(s,S,w))}else{let w=await this.valueToRDFObject(E,e,S);if(_==="exo__Statement_subject"&&o===void 0){let R=w.find(x=>x instanceof As.IRI);R&&(o=R)}else if(_==="exo__Statement_predicate"&&c===void 0){let R=w.find(x=>x instanceof As.IRI);R&&(c=R)}else _==="exo__Statement_object"&&l===void 0&&(l=w[0]);for(let R of w)if(i.push(new xr.Triple(s,S,R)),this.vocabularyMapper.hasMappingFor(m)&&R instanceof As.IRI){let x=this.vocabularyMapper.generateMappedTriple(s,m,R);x&&i.push(x)}}if(m==="exo__Instance_class")for(let E of I){let w=this.valueToClassURI(E);if(w instanceof As.IRI){let R=ar.Namespace.RDF.term("type");i.push(new xr.Triple(s,R,w)),w.value===f&&(u=!0)}}if(m==="exo__Asset_label"){let E=ar.Namespace.RDFS.term("label");for(let w of I)typeof w=="string"&&w.length>0&&i.push(new xr.Triple(s,E,new Mn.Literal(w)))}}let d="exo__Instance_class"in t||"exo__Asset_uid"in t,p=t.exo__Asset_label,h="exo__Asset_label"in t&&p!==null&&p!==void 0&&!(typeof p=="string"&&p.trim()==="")&&!(Array.isArray(p)&&p.length===0);if(d&&!h){let m=ar.Namespace.RDFS.term("label"),b=ar.Namespace.EXO.term("Asset_label"),_=new Mn.Literal(e.basename);i.push(new xr.Triple(s,m,_)),i.push(new xr.Triple(s,b,_))}i.push(...this.pendingExtraTriples),this.pendingExtraTriples=[],u&&o&&c&&l&&i.push(new xr.Triple(o,c,l));let g=await this.convertBodyWikilinks(e,s);return i.push(...g),i}async convertExo003Note(e,t){let n=Pi.Exo003Parser.parse(t);if(!n.success||!n.metadata)return[];let i=n.metadata,s=[];switch(i.metadata){case Pi.Exo003MetadataType.Namespace:break;case Pi.Exo003MetadataType.Anchor:s.push(...this.convertExo003Anchor(e,i));break;case Pi.Exo003MetadataType.BlankNode:s.push(...this.convertExo003BlankNode(e,i));break;case Pi.Exo003MetadataType.Statement:s.push(...this.convertExo003Statement(e,i));break;case Pi.Exo003MetadataType.Body:s.push(...await this.convertExo003Body(e,i));break}return s}convertExo003Anchor(e,t){let n=this.notePathToIRI(e.path),i=new As.IRI(t.uri);return[new xr.Triple(n,ar.Namespace.OWL.term("sameAs"),i),new xr.Triple(i,ar.Namespace.OWL.term("sameAs"),n)]}convertExo003BlankNode(e,t){let n=this.notePathToIRI(e.path),i=t.uri.replace(/[^a-zA-Z0-9_-]/g,"_");return[new xr.Triple(n,ar.Namespace.OWL.term("sameAs"),new gk.BlankNode(i))]}convertExo003Statement(e,t){let n=[];try{let i=this.createExo003ReferenceResolver(e),s=Pi.Exo003Parser.toTriple(t,i);n.push(s);let o=this.notePathToIRI(e.path);n.push(new xr.Triple(o,ar.Namespace.RDF.term("value"),s.subject))}catch{}return n}async convertExo003Body(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.createExo003ReferenceResolver(e),c=o(t.subject),l=o(t.predicate);if(c.type==="literal")throw new Error("Body subject cannot be a literal");if(l.type!=="iri")throw new Error("Body predicate must be an IRI");let u=c.type==="iri"?new As.IRI(c.value):new gk.BlankNode(c.value),f=new As.IRI(l.value),d=Pi.Exo003Parser.toLiteral(t,s.trim());n.push(new xr.Triple(u,f,d));let p=this.notePathToIRI(e.path);n.push(new xr.Triple(p,ar.Namespace.RDF.term("value"),u))}catch{}return n}createExo003ReferenceResolver(e){return t=>{let n=this.extractWikilink(t),i=n||t,s=this.vault.getFirstLinkpathDest(i,e.path);if(s){let o=this.targetFrontmatter(s);if(o&&Pi.Exo003Parser.isExo003Format(o)){let c=Pi.Exo003Parser.parse(o);if(c.success&&c.metadata){let l=c.metadata;if(l.metadata===Pi.Exo003MetadataType.Anchor||l.metadata===Pi.Exo003MetadataType.Namespace)return{type:"iri",value:l.uri};if(l.metadata===Pi.Exo003MetadataType.BlankNode)return{type:"blank",value:l.uri.replace(/[^a-zA-Z0-9_-]/g,"_")}}}return{type:"iri",value:this.notePathToIRI(s.path).value}}return!n&&t.includes("://")?{type:"iri",value:t}:{type:"literal",value:t}}}async convertVault(e={}){return(await this.convertVaultWithValidation({strict:!1,excludedFolders:e.excludedFolders,onFileTriples:e.onFileTriples})).triples}async convertVaultWithValidation(e={}){let t=e.files??this.vault.getAllFiles(),n=[],i=[],s=e.strict??!1,o=0,c=0,l=e.fileSpacePrefixes?{prefixes:e.fileSpacePrefixes,declarationPaths:[],warnings:[]}:(0,GJ.discoverFileSpaceExclusions)(this.vault);for(let m of l.warnings)this.logger.warn(`FileSpace discovery: ${m}`);let u=[..._k(e.excludedFolders),...l.prefixes],f=u.length===0?t:t.filter(m=>!Sk(m.path,u)),d=e.onProgress,p=e.progressIntervalFiles&&e.progressIntervalFiles>0?e.progressIntervalFiles:GA.INDEX_PROGRESS_INTERVAL,h=f.length,g=0;for(let m of f){if(g++,d&&g%p===0&&g<h)try{d(g,h)}catch{}try{let b=this.vault.getFrontmatter(m),_=b?this.validateExocortexAsset(b,m.basename):null;if(_){if(s)throw new Error(`Invariant violation in "${m.path}": ${_.message}`);i.push({path:m.path,reason:`Invariant violation: ${_.message}`}),o++,this.logger.info(`Skipping file with invariant violation: ${m.path}`,{code:_.code,property:_.property,reason:_.message});continue}let S=await this.convertNote(m);if(n.push(...S),e.onFileTriples)try{e.onFileTriples(m,S)}catch{}}catch(b){let _=b instanceof Error?b.message:String(b);if(s)throw new Error(`Invalid IRI for file "${m.path}": ${_}`);i.push({path:m.path,reason:`Invalid IRI: ${_}`}),c++,this.logger.info(`Skipping file with invalid IRI: ${m.path}`,{reason:_})}}return o>0&&this.logger.warn(`Skipped ${o} file${o===1?"":"s"} with invariant violations during indexing (paths in developer console)`,{count:o}),c>0&&this.logger.warn(`Skipped ${c} file${c===1?"":"s"} with invalid IRI during indexing (paths in developer console)`,{count:c}),{triples:n,skippedFiles:i,summary:{total:f.length,indexed:f.length-i.length,skipped:i.length},fileSpaces:l}}static inferLabelFromBasename(e){return ar.Namespace.fromPropertyKey(e)!==null?e:null}validateExocortexAsset(e,t){let n=a(d=>d==null?!0:typeof d=="string"?d.trim()==="":Array.isArray(d)?d.length===0||d.every(n):!1,"isEmpty");if(!("exo__Instance_class"in e||"exo__Asset_uid"in e))return null;let s=["exo__Asset_uid","exo__Instance_class"];for(let d of s){if(!(d in e))return{code:"MISSING_PROPERTY",property:d,message:`Required property "${d}" is missing`};if(n(e[d]))return{code:"EMPTY_PROPERTY",property:d,message:`Required property "${d}" is empty`}}let o=["ems__Effort_status","ems__Effort_parent","ems__Effort_lockedBy","ems__Effort_lockExpires","exo__Asset_updatedAt","ems__Effort_startTimestamp"];for(let d of o)if(d in e&&n(e[d]))return{code:"EMPTY_OPTIONAL_PROPERTY",property:d,message:`Optional property "${d}" is present but empty`};let c=e.exo__Instance_class,l=Array.isArray(c)?c:[c],u=null,f=!1;for(let d of l){if(typeof d!="string")continue;let p=this.removeQuotes(d),g=(this.extractWikilink(p)??p).trim();/^[a-z][a-zA-Z0-9]*__/.test(g)&&/[\s()]/.test(g)?u||(u={candidate:d}):f=!0}return u&&!f?{code:"INVALID_INSTANCE_CLASS_IRI",property:"exo__Instance_class",message:`Invalid Instance_class IRI: "${u.candidate}"`}:null}async validateVault(){let e=this.vault.getAllFiles(),t=[];for(let n of e){let i=(0,VA.vaultPathToIRI)(n.path);As.IRI.isValidIRI(i)||t.push({path:n.path,reason:`Path "${n.path}" cannot be converted to a valid IRI`})}return t}notePathToIRI(e){return new As.IRI((0,VA.vaultPathToIRI)(`${this.subjectIriPrefix}${e}`))}synthesizeWikilinkTargetIRI(e){return new As.IRI((0,VA.vaultPathToIRI)(e))}isExocortexProperty(e){return ar.Namespace.fromPropertyKey(e)!==null}propertyKeyToIRI(e){let t=ar.Namespace.fromPropertyKey(e);if(!t)throw new Error(`Invalid property key: ${e}`);return t.namespace.term(t.localName)}emitTypeTripleForEnumInstance(e,t){let n=this.targetFrontmatter(t);if(!n)return;let i=n.exo__Instance_class,s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return;let o=this.valueToClassURI(s);o instanceof As.IRI&&(this.pendingExtraTriples.push(new xr.Triple(e,ar.Namespace.RDF.term("type"),o)),this.pendingExtraTriples.push(new xr.Triple(e,ar.Namespace.EXO.term("Instance_class"),o)))}async valueToRDFObject(e,t,n){if(typeof e=="string"){let i=this.removeQuotes(e);if(n?.value.endsWith("#TokenInvocation_parameter"))return[new Mn.Literal(i)];let s=this.extractWikilink(i);if(s){let o=this.vault.getFirstLinkpathDest(s,t.path);if(o){let l=this.notePathToIRI(o.path),u=s.includes("|")?s.split("|")[0]:s;if(this.isUUID(u)){let d=new Mn.Literal(u);if(n?.value.endsWith("#Grounding_targetValueRef")||n?.value.endsWith("#Grounding_targetValueSubstitution")||n?.value.endsWith("#Grounding_targetClass")||n?.value.endsWith("#Grounding_type")||n?.value.endsWith("#PropertyDefault_value"))return[l];let h=this.expandClassValue(o.basename);if(h)return this.emitTypeTripleForEnumInstance(h,o),[h];let g=this.targetFrontmatter(o);if(g){let I=g.exo__Asset_label;if(typeof I=="string"){let E=this.expandClassValue(I);if(E)return this.emitTypeTripleForEnumInstance(E,o),[E]}}let m=n?.value.endsWith("#Asset_prototype")||n?.value.endsWith("/Asset_prototype"),_=((typeof process<"u"?process.env:void 0)?.EXOCORTEX_DUAL_STORAGE_PREDICATES??"").split(",").map(I=>I.trim()).filter(Boolean),S=_.length>0&&_.some(I=>n?.value.endsWith(`#${I}`));return m||S?[l,d]:[l]}let f=this.expandClassValue(o.basename);return f?(this.emitTypeTripleForEnumInstance(f,o),[f]):[l]}if(this.isClassReference(s)){let l=this.expandClassValue(s);if(l)return[l]}let c=s.includes("|")?s.split("|")[0]:s;return this.isUUID(c)?[this.synthesizeWikilinkTargetIRI(`${c}.md`)]:[new Mn.Literal(i)]}if(this.isClassReference(i)){let o=this.expandClassValue(i);if(o)return[o]}return this.isISO8601DateTime(i)?[new Mn.Literal(i,ar.Namespace.XSD.term("dateTime"))]:[new Mn.Literal(i)]}return typeof e=="boolean"?[new Mn.Literal(e.toString())]:typeof e=="number"?[new Mn.Literal(e.toString(),Number.isInteger(e)?ar.Namespace.XSD.term("integer"):ar.Namespace.XSD.term("decimal"))]:e instanceof Date?[new Mn.Literal(e.toISOString(),ar.Namespace.XSD.term("dateTime"))]:[new Mn.Literal(String(e))]}isISO8601DateTime(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?(Z|[+-]\d{2}:\d{2})?$/.test(e)}removeQuotes(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.substring(1,t.length-1):e}extractWikilink(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1];return n.includes("|")?n.split("|")[0]:n}extractWikilinkAlias(e){let t=e.match(/^\[\[([^\]]+)\]\]$/);if(!t)return null;let n=t[1],i=n.indexOf("|");return i>=0?n.substring(i+1).trim():null}targetFrontmatter(e){return this.vault.getFrontmatter(e)??this.preResolvedTargetFm.get(e.path)??null}async preResolveWikilinkTargets(e){let t=this.vault.getFrontmatterWithFallback?.bind(this.vault);if(t)for(let n of Object.values(e)){let i=Array.isArray(n)?n:n==null?[]:[n];for(let s of i){if(typeof s!="string")continue;let o=this.removeQuotes(s),c=this.extractWikilink(o);if(!c||!this.isUUID(c))continue;let l=this.vault.getFirstLinkpathDest(c,"");!l||this.preResolvedTargetFm.has(l.path)||this.vault.getFrontmatter(l)||this.preResolvedTargetFm.set(l.path,await t(l))}}}valueToClassURI(e){if(typeof e!="string")return new Mn.Literal(String(e));let t=this.removeQuotes(e),i=this.extractWikilink(t)||t,s=this.expandClassValue(i);if(s)return s;let o=this.extractWikilinkAlias(t);if(o){let c=this.expandClassValue(o);if(c)return c}if(this.isUUID(i)){let c=this.vault.getFirstLinkpathDest(i,"");if(c){let l=this.expandClassValue(c.basename);if(l)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):l;let u=this.targetFrontmatter(c);if(u){let f=u.exo__Asset_label;if(typeof f=="string"){let d=this.expandClassValue(f);if(d)return this.emitInstanceClassAsUid?this.notePathToIRI(c.path):d}}return this.notePathToIRI(c.path)}}return new Mn.Literal(t)}isClassReference(e){return/\s/.test(e)?!1:ar.Namespace.fromPropertyKey(e)!==null}isUUID(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}expandClassValue(e){let t=this.removeQuotes(e),n=ar.Namespace.fromPropertyKey(t);return!n||/[\s()]/.test(n.localName)?null:n.namespace.term(n.localName)}extractBodyContent(e){let t=/^---\r?\n[\s\S]*?\r?\n---\r?\n?/;return e.replace(t,"")}extractBodyWikilinks(e){let t=new Set,n,i=new RegExp(this.BODY_WIKILINK_PATTERN.source,"g");for(;(n=i.exec(e))!==null;)n[1]&&!bk(n[1].trim())&&t.add(n[1]);return Array.from(t)}async convertBodyWikilinks(e,t){let n=[];try{let i=await this.vault.read(e),s=this.extractBodyContent(i),o=this.extractBodyWikilinks(s),c=ar.Namespace.EXO.term("Asset_bodyLink");for(let l of o){let u=this.vault.getFirstLinkpathDest(l,e.path);if(u){let f=this.notePathToIRI(u.path);n.push(new xr.Triple(t,c,f))}else if(this.isClassReference(l)){let f=this.expandClassValue(l);f?n.push(new xr.Triple(t,c,f)):n.push(new xr.Triple(t,c,new Mn.Literal(l)))}else n.push(new xr.Triple(t,c,new Mn.Literal(l)))}}catch{}return n}};Lt.NoteToRDFConverter=ql;ql.INDEX_PROGRESS_INTERVAL=200;ql.SkippedFileInfo=class{constructor(r,e){this.path=r,this.reason=e}};ql.VaultValidationResult=class{constructor(r,e,t){this.triples=r,this.skippedFiles=e,this.summary=t}};ql.VaultValidationOptions=class{constructor(r=!1){this.strict=r}};Lt.NoteToRDFConverter=ql=GA=$J([(0,BA.injectable)(),mk(0,(0,BA.inject)(yk.DI_TOKENS.IVaultAdapter)),mk(1,(0,BA.inject)(yk.DI_TOKENS.ILogger)),UJ("design:paramtypes",[Object,Object,Object])],ql)});var zl=T(wb=>{"use strict";Object.defineProperty(wb,"__esModule",{value:!0});wb.FrontmatterService=void 0;var wk=pb(),qA=Fl(),$f=Wl(),HJ=oa(),Sb=class r{static{a(this,"FrontmatterService")}parse(e){let t=e.match(r.FRONTMATTER_REGEX);return t?{exists:!0,content:t[1],originalContent:e}:{exists:!1,content:"",originalContent:e}}parseObject(e){let t=this.parse(e);if(!t.exists)return null;let n={},i=t.content.split(/\r?\n/),s=null,o=null,c=a(()=>{s!==null&&o!==null&&(n[s]=o),s=null,o=null},"flushArray");for(let l of i){let u=/^ {2}- (.*)$/.exec(l);if(u){s!==null&&o!==null&&o.push(u[1].trim());continue}c();let f=/^([^:\s][^:]*):\s*(.*)$/.exec(l);if(!f)continue;let d=f[1].trim(),p=f[2].trim();p===""?(s=d,o=[]):n[d]=p}return c(),n}updateProperty(e,t,n){t=(0,$f.canonicalYamlKey)(r.normalizeIRI(t)),typeof n=="string"&&(n=r.normalizeIRIValue(n));let i=this.parse(e),s=this.serializeValue(t,n);if(!i.exists)return`---
|
|
117
117
|
${s}
|
|
118
118
|
---
|
|
119
119
|
${e}`;let o=i.content,c=o.split(`
|
|
@@ -136,8 +136,8 @@ ${Object.entries(o).map(([f,d])=>this.serializeValue(f,d,!0,n?.(s[f]??f))).join(
|
|
|
136
136
|
${c}`}let o=n?(0,qA.serializeYamlScalar)(t,s,i):String(t);return`${e}: ${o}`}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}static findPropertyLineSpan(e,t){let n=`${t}:`,i=e.findIndex(o=>o.startsWith(n));if(i===-1)return null;let s=i+1;for(let o=i+1;o<e.length;o++){let c=e[o];if(/^[ \t]/.test(c)){s=o+1;continue}if(c.trim()!=="")break}return{start:i,end:s}}};wb.FrontmatterService=Sb;Sb.FRONTMATTER_REGEX=/^---\n([\s\S]*?)\n---/});var Hl=T(WA=>{"use strict";Object.defineProperty(WA,"__esModule",{value:!0});WA.extractAssetReference=KJ;function KJ(r){if(typeof r!="string")return null;let e=r.trim().replace(/^["']|["']$/g,"");e=e.replace(/^\[\[|\]\]$/g,"");let t=e.indexOf("|");return t!==-1&&(e=e.slice(0,t).trim()),e||null}a(KJ,"extractAssetReference")});var Kl=T(Eb=>{"use strict";Object.defineProperty(Eb,"__esModule",{value:!0});Eb.LoggingService=void 0;var Th=class{static{a(this,"LoggingService")}static setVerbose(e){this.isVerbose=e}static setDevelopmentMode(e){this.isDevelopment=e}static checkIsDevelopment(){return this.isDevelopment!==void 0?this.isDevelopment:typeof process<"u"?(this.isDevelopment=!1,this.isDevelopment):(this.isDevelopment=!1,this.isDevelopment)}static debug(e,t){this.isVerbose&&console.debug(`[Exocortex] ${e}`,t??"")}static info(e,t){console.log(`[Exocortex] ${e}`,t??"")}static warn(e,t){console.warn(`[Exocortex] ${e}`,t??"")}static error(e,t,n){let i=this.checkIsDevelopment(),s=n?` [${n}]`:"";if(i){let o=t?.stack?`
|
|
137
137
|
Stack trace:
|
|
138
138
|
${t.stack}`:"";console.error(`[Exocortex ERROR]${s} ${e}${o}`,t??"")}else{let o=t?.message?`
|
|
139
|
-
Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${o}`)}}};Eb.LoggingService=Th;Th.isVerbose=!1;Th.isDevelopment=void 0});var HA=T(vb=>{"use strict";Object.defineProperty(vb,"__esModule",{value:!0});vb.CLASS_UID_TO_LABEL=void 0;var zA=ml();vb.CLASS_UID_TO_LABEL=Object.freeze({"1b20a8f0-d745-4e93-91db-4531b3df120e":zA.AssetClass.TASK,"7db5eeff-718a-49b0-8d2b-39b084a356e3":zA.AssetClass.PROJECT,"1b0a5e34-dd7f-4ead-b43a-6c7c5a5ecaca":zA.AssetClass.MEETING})});var xk=T(Br=>{"use strict";var YJ=Br&&Br.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},XJ=Br&&Br.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},qt;Object.defineProperty(Br,"__esModule",{value:!0});Br.GroundingExecutor=Br.ServiceRegistry=Br.CLASS_UID_TO_LABEL=Br.STATUS_UID_BY_ENUM=void 0;Br.missingInputHint=QA;Br.missingInputError=Ck;Br.findMissingInput=aZ;var QJ=ct(),JJ=_h(),ZJ=ob(),jn=cc(),eZ=kA(),tZ=ef(),Rk=Gu(),rZ=Le(),KA=zl(),Fi=Fl(),YA=Wl(),nZ=Hl(),iZ=oa(),Ek=gb(),Ah=vs(),vk=hh(),Is=Kl();Br.STATUS_UID_BY_ENUM=Rk.EFFORT_STATUS_UID;var sZ=HA();Object.defineProperty(Br,"CLASS_UID_TO_LABEL",{enumerable:!0,get:a(function(){return sZ.CLASS_UID_TO_LABEL},"get")});var XA=lb();(0,XA.installDefaultResolvers)();function oZ(r){if(r){if(r==="1b20a8f0-d745-4e93-91db-4531b3df120e")return"ems__Task";if(r==="7db5eeff-718a-49b0-8d2b-39b084a356e3")return"ems__Project";if(r==="ems__Task"||r==="ems__Project")return r}}a(oZ,"resolveClassFlipTarget");function QA(r,e){let t=e??{},n=a(c=>c!=null,"isProvided"),i=[...r.matchAll(/\$input\.([A-Za-z_]\w*)/g)].map(c=>c[1]),s=/\$input\b(?!\.)/.test(r)||/\$value\b/.test(r),o=i.find(c=>!n(t[c]));return o!==void 0?`--input '{"${o}":...}'`:s&&!n(t.value)?`--input '{"value":...}'`:null}a(QA,"missingInputHint");function Ck(r){return`property_set: value template references an input that was not provided (${r} required)`}a(Ck,"missingInputError");function aZ(r,e){let t=a(i=>{if(i.type===jn.GroundingType.PROPERTY_SET){if(i.targetValueRef!==void 0)return`"[[${i.targetValueRef}]]"`;if(i.targetValueLiteral!==void 0)return i.targetValueLiteral;if(i.targetValueSubstitution!==void 0)return i.targetValueSubstitution}},"staticTemplate"),n=a(i=>{let s=t(i);if(s!==void 0){let o=QA(s,e);if(o!==null)return o}for(let o of i.steps??[]){let c=n(o);if(c!==null)return c}return null},"visit");return n(r)}a(aZ,"findMissingInput");var cZ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Tk=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,lZ=/^__SUBSTITUTE__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__$/,Ak=/^__SUBSTITUTE_P__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__([A-Za-z0-9_-]*)__$/,Tb=class{static{a(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};Br.ServiceRegistry=Tb;var Ik=20;function uZ(r){return/^\[\[[\s\S]*\]\]$/.test(r.trim())}a(uZ,"isUnquotedWikilink");var Uf=qt=class{static{a(this,"GroundingExecutor")}constructor(e,t,n,i,s){this.frontmatterService=new KA.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=n,this.classLabelToUid=i,this.refToFolder=s?.refToFolder,this.refToFrontmatter=s?.refToFrontmatter,this.workflowResolver=s?.workflowResolver,this.groundingLoader=s?.groundingLoader,this.templateLoader=s?.templateLoader,this.namedQueryRunner=s?.namedQueryRunner,this.declaredRanges=s?.declaredRanges,this.clock=s?.clock??(0,JJ.liveClock)(),this.uidGen=s?.uidGenerator??(0,ZJ.liveUidGenerator)()}async execute(e,t,n,i){try{switch(e.type){case jn.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,n,i);case jn.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,n);case jn.GroundingType.PROPERTY_REPLACE:return await this.executePropertyReplace(e,t,n,i);case jn.GroundingType.COMPOSITE:return await this.executeComposite(e,t,n,i,0);case jn.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,n,i);case jn.GroundingType.CREATE_INSTANCE:return await this.executeCreateInstance(e,t,n,i);case jn.GroundingType.PROPERTY_APPEND:return await this.executePropertyAppend(e,t,n,i);case jn.GroundingType.PROPERTY_INCREMENT:return await this.executePropertyIncrement(e,n);case jn.GroundingType.PROPERTY_SHIFT:return await this.executePropertyShift(e,n);case jn.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};case jn.GroundingType.WORKFLOW_TRANSITION:return await this.executeWorkflowTransition(e,t,n,i);case jn.GroundingType.BODY_TEMPLATE:return await this.executeBodyTemplate(e,t,n,i);default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}stampUpdatedAt(e,t,n){return t===e||n!==void 0&&(0,YA.canonicalYamlKey)(KA.FrontmatterService.normalizeIRI(n))==="exo__Asset_updatedAt"||!this.frontmatterService.parse(t).exists?t:this.frontmatterService.updateProperty(t,"exo__Asset_updatedAt",Ah.DateFormatter.toLocalTimestamp(this.clock.now()))}async executePropertySet(e,t,n,i){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};if(e.targetQuery!==void 0&&e.targetsCreatedInstance===!0)return{success:!1,error:"property_set: targetQuery and targetsCreatedInstance are mutually exclusive (both address the step's TARGET \u2014 pick one)."};let s;if([e.targetValueRef!==void 0,e.targetValueLiteral!==void 0,e.targetValueSubstitution!==void 0,e.targetValueQuery!==void 0].filter(Boolean).length>1)return{success:!1,error:"property_set: more than one of targetValueRef/targetValueLiteral/targetValueSubstitution/targetValueQuery set (cardinality 0..1 each, mutually exclusive)"};if(e.targetValueRef!==void 0)s=`"[[${e.targetValueRef}]]"`;else if(e.targetValueLiteral!==void 0)s=e.targetValueLiteral;else if(e.targetValueSubstitution!==void 0)s=e.targetValueSubstitution;else if(e.targetValueQuery!==void 0){let I=await this.resolveTargetValueQuery(e.targetValueQuery,t);if(!I.success)return I;s=I.value}else return{success:!1,error:"property_set requires one of targetValueRef/targetValueLiteral/targetValueSubstitution/targetValueQuery"};let c=QA(s,i);if(c!==null)return{success:!1,error:Ck(c)};let l=e.targetValueRef!==void 0&&/\$/.test(e.targetValueRef),u;if(l){let I=this.substituteVariables(e.targetValueRef,t,i),E=I.trim().replace(/^["']|["']$/g,"").replace(/^\[\[|\]\]$/g,""),w=/\[\[|\]\]/.test(E)?null:(0,nZ.extractAssetReference)(I)?.trim()||null;if(w===null)return{success:!1,error:`property_set: asset-reference value ${JSON.stringify(I)} for ${e.targetProperty} is not a single reference \u2014 pass a BARE uid (or one [[uid]] / [[uid|alias]] wikilink, which is unwrapped); nested brackets, a link inside prose or an empty value would be written as a broken link.`};u=`"[[${w}]]"`}else u=this.substituteVariables(s,t,i);let f=KA.FrontmatterService.normalizeIRI(e.targetProperty),d=(0,YA.canonicalYamlKey)(f),p=(0,iZ.iriToObsidianName)(e.targetProperty)??f,h=this.declaredRanges?(await this.declaredRanges([p])).get(p):void 0,g=Fi.STRING_SCALAR_PROPERTIES.has(d),m=(0,Fi.scalarTypingForRange)(h)!==void 0?(0,Fi.serializeYamlScalar)(u,g,h):g?(0,Fi.serializeYamlScalar)(u,!0):u;if(uZ(m))return{success:!1,error:`property_set: value ${m} is an UNQUOTED wikilink \u2014 YAML reads it as a flow sequence, so the graph would receive a literal instead of a link (silent data loss). Pass the QUOTED form for a substituted reference (the quotes are part of the string, e.g. --input '{"<key>":"\\"[[<uid>]]\\""}'), or use targetValueRef, which takes a BARE uid and wraps it itself.`};let b=n;if(e.targetQuery!==void 0){let I=await this.resolveTargetQuery(e.targetQuery,t);if(!I.success)return I;b=I.path}let _=await this.fileReader.readFile(b),S=this.stampUpdatedAt(_,this.frontmatterService.updateProperty(_,e.targetProperty,m),e.targetProperty);return await this.fileWriter.updateFile(b,S),{success:!0}}async resolveTargetQuery(e,t){if(!this.namedQueryRunner)return{success:!1,error:"property_set targetQuery requires NamedQueryRunner injection (options.namedQueryRunner). Wire the plugin/CLI before using this target-source."};let n;try{n=await this.namedQueryRunner.runScalar(e,{currentAsset:t})}catch(s){return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' failed \u2014 ${s instanceof Error?s.message:String(s)}`}}if(n===null)return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' matched no asset (empty result set) \u2014 refusing to fall back to the click-target.`};if(n.kind!=="iri")return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' returned a literal ('${n.value}'), not an asset reference \u2014 a target must be an asset.`};if(n.iri===void 0)return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' returned an asset reference without its source IRI, so its file path cannot be resolved.`};let i=(0,Ek.iriToVaultPath)(n.iri);return i===null?{success:!1,error:`property_set targetQuery: NamedQuery '${e}' matched '${n.iri}', which is not a vault asset IRI (no resolvable file path).`}:{success:!0,path:i}}async resolveTargetValueQuery(e,t){if(!this.namedQueryRunner)return{success:!1,error:"property_set targetValueQuery requires NamedQueryRunner injection (options.namedQueryRunner). Wire the plugin/CLI before using this value-source."};let n;try{n=await this.namedQueryRunner.runScalar(e,{currentAsset:t})}catch(s){return{success:!1,error:`property_set targetValueQuery: NamedQuery '${e}' failed \u2014 ${s instanceof Error?s.message:String(s)}`}}return n===null?{success:!1,error:`property_set targetValueQuery: NamedQuery '${e}' returned no scalar value (empty result set or non-scalar shape).`}:{success:!0,value:n.kind==="iri"?`"[[${n.value}]]"`:n.value}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let n=await this.fileReader.readFile(t),i=this.stampUpdatedAt(n,this.frontmatterService.removeProperty(n,e.targetProperty),e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,n,i,s){if(s>=Ik)return{success:!1,error:`Composite grounding exceeded maximum depth of ${Ik}`};let o=e.steps??[];if(o.length===0)return{success:!0};let c;try{c=await this.fileReader.readFile(n)}catch{}let l=[],u,f=[];try{for(let d=0;d<o.length;d++){let p=o[d],g=(p.type===jn.GroundingType.BODY_TEMPLATE||p.targetsCreatedInstance===!0)&&u?u:n,m=await this.executeStep(p,t,g,i,s+1);if(!m.success)return await this.rollback(c,n,l,f),{success:!1,error:`Composite step ${d} failed: ${m.error}`};m.openPath&&(u=m.openPath),m.openPath&&f.push(m.openPath),m.createdPaths&&m.createdPaths.length>0&&f.push(...m.createdPaths),l.push(d)}return{success:!0,...f.length>0?{createdPaths:f}:{}}}catch(d){return await this.rollback(c,n,l,f),{success:!1,error:`Composite execution failed: ${d instanceof Error?d.message:String(d)}`}}}async executeServiceCall(e,t,n,i){let s=e.targetProperty;if(!s)return{success:!1,error:"service_call requires targetProperty as serviceId"};if(e.targetQuery!==void 0&&e.targetsCreatedInstance===!0)return{success:!1,error:"service_call: targetQuery and targetsCreatedInstance are mutually exclusive (both address the step's TARGET \u2014 pick one)."};if(s==="convertToTask")return await this.executeConvertToTask(n);if(s==="updateProperty"){let f=oZ(e.targetValueRef);if(f==="ems__Task")return await this.executeConvertToTask(n);if(f==="ems__Project")return await this.executeConvertToProject(n)}let o=this.serviceRegistry.get(s);if(!o)return{success:!1,error:`Service not found: "${s}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`};let c=i;if(e.isDefinedBy&&(c={isDefinedBy:e.isDefinedBy,...c??{}}),e.serviceCallPayload)try{let f=this.substituteVariables(e.serviceCallPayload,t,i),d=JSON.parse(f);typeof d=="object"&&d!==null&&(c={...d,...c??{}})}catch{}let l=e.targetsCreatedInstance===!0&&n?(0,Ek.vaultPathToIRI)(n):t,u=await this.readServiceCallSnapshot(n);return await o.execute(l,c),await this.stampServiceCallTarget(n,u,c),{success:!0}}async readServiceCallSnapshot(e){if(!e||!await this.fileReader.fileExists(e))return;let t=await this.fileReader.readFile(e),n=this.frontmatterService.parseObject(t)?.exo__Asset_uid,i=typeof n=="string"?n.trim().replace(/^"|"$/g,""):"";if(!cZ.test(i))return{bytes:t};let s=e.lastIndexOf("/"),c=`${s>=0?e.slice(0,s+1):""}${i}.md`;return c===e?{bytes:t}:await this.fileReader.fileExists(c)?{bytes:t}:{bytes:t,canon:c}}async stampServiceCallTarget(e,t,n){if(t===void 0)return;let i=await this.locateServiceCallTarget(e,t);if(i===void 0)return;let s=t.bytes,o=await this.fileReader.readFile(i);if(o===s)return;let c=typeof n?.property=="string"?n.property:void 0,l=this.stampUpdatedAt(s,o,c);l!==o&&await this.fileWriter.updateFile(i,l)}async locateServiceCallTarget(e,t){if(await this.fileReader.fileExists(e))return e;if(t.canon!==void 0&&await this.fileReader.fileExists(t.canon))return t.canon}async executeConvertToTask(e){let t=await this.fileReader.readFile(e),n=await this.resolveClassRefToUid("ems__Task"),i=this.stampUpdatedAt(t,this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${n}]]"]`),"exo__Instance_class");return await this.fileWriter.updateFile(e,i),{success:!0}}async executeConvertToProject(e){let t=await this.fileReader.readFile(e),n=await this.resolveClassRefToUid("ems__Project"),i=this.stampUpdatedAt(t,this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${n}]]"]`),"exo__Instance_class");return await this.fileWriter.updateFile(e,i),{success:!0}}async executeBodyTemplate(e,t,n,i){let s=null;if(e.templateRef)if(this.templateLoader){if(s=await this.templateLoader(e.templateRef),s===null)return{success:!1,error:`body_template: templateRef "${e.templateRef}" did not resolve to a template body (asset missing or empty).`}}else{if(e.bodyTemplate===void 0)return{success:!1,error:`body_template: templateRef "${e.templateRef}" set but no TemplateLoaderPort is wired (and no inline bodyTemplate fallback).`};s=e.bodyTemplate}else if(e.bodyTemplate!==void 0)s=e.bodyTemplate;else return{success:!1,error:"body_template requires bodyTemplate or templateRef"};let o=(0,eZ.resolveTemplateBody)(s,{userInput:i,targetIRI:t,targetFilePath:n}),c;try{c=await this.fileReader.readFile(n)}catch(u){return{success:!1,error:`body_template: failed to read target file "${n}": ${u instanceof Error?u.message:String(u)}`}}let l=this.stampUpdatedAt(c,qt.replaceBody(c,o));return await this.fileWriter.updateFile(n,l),{success:!0}}static replaceBody(e,t){let n=e.match(/^---\r?\n[\s\S]*?\r?\n---/);return n?`${n[0]}
|
|
140
|
-
${t}`:t}static extractBody(e){let t=e.match(/^---\r?\n[\s\S]*?\r?\n---/);return t?e.slice(t[0].length).replace(/^\r?\n/,""):e}async executeCreateInstance(e,t,n,i){if(!e.targetFolder)return{success:!1,error:"create_instance requires targetFolder"};let s={},o=null,c=null;if((e.inheritanceRule&&e.inheritanceRule.length>0||e.propertyDefault&&e.propertyDefault.some(E=>typeof E.value=="string"&&E.value.includes("__SUBSTITUTE"))||e.labelTemplate!==void 0&&/\$target\./.test(e.labelTemplate)||e.cloneTargetBody===!0)&&t&&n){let E;try{E=await this.fileReader.readFile(n)}catch(w){return{success:!1,error:`create_instance: failed to read $target file "${n}": ${w instanceof Error?w.message:String(w)}`}}o=this.frontmatterService.parseObject(E)??null,e.cloneTargetBody&&(c=qt.extractBody(E))}let u;e.targetClass&&(u=await this.resolveClassRefToUid(e.targetClass));let f=await this.preResolveTargetRefs(e.propertyDefault,o),d={userInput:i,targetIRI:t,targetFilePath:n,targetFm:o??void 0,targetRefFm:f,groundingTargetClassUid:u};if(e.propertyDefault&&e.propertyDefault.length>0&&this.applyPropertyDefaultStep(s,e.propertyDefault,d),this.applyMissingScalarPrimitives(s,i,u,e,t,o,n),i)for(let[E,w]of Object.entries(i))E!=="label"&&E!=="body"&&E!=="plannedDate"&&w!=null&&(s[E]=w);if(e.inheritanceRule&&e.inheritanceRule.length>0&&o&&await this.applyInheritanceRuleStep(s,e.inheritanceRule,o),await this.applyMissingBacklinkTopUp(s,e,t,n,o),t&&e.linkBackProperty&&s[e.linkBackProperty]===void 0){let E=qt.extractBacklinkTarget(t,n);s[e.linkBackProperty]=`"[[${E}]]"`}this.applyPrototypeTimePropagation(s,o,i);let p=s.exo__Asset_uid,h=this.declaredRanges?await this.declaredRanges(Object.keys(s)):void 0,g=this.frontmatterService.createFrontmatter("",s,h===void 0?void 0:E=>h.get(E)),m=e.targetFolder.includes("$isDefinedByFolder")?await this.resolveIsDefinedByFolder(s,n):this.substituteVariables(e.targetFolder,t,i,void 0,n),b=m?`${m}/${p}.md`:`${p}.md`,_=i?.body,S=typeof _=="string"&&_.length>0?_:e.cloneTargetBody&&typeof c=="string"&&c.length>0?c:null,I=S!==null?qt.replaceBody(g,S):g;return await this.fileWriter.createFile(b,I),{success:!0,openPath:b}}resolveInstanceDate(e,t){let n=qt.firstScalar(e?.plannedDate);return n&&/^\d{4}-\d{2}-\d{2}$/.test(n)?n:Ah.DateFormatter.toDateString(t??this.clock.now())}applyPrototypeTimePropagation(e,t,n){if(!t)return;let i=qt.firstScalar(t.ems__EffortPrototype_startTime),s=qt.firstScalar(t.ems__EffortPrototype_endTime);if(!i&&!s)return;let o=this.resolveInstanceDate(n);if(i&&e.ems__Effort_plannedStartTimestamp===void 0){let c=qt.combineDateAndTime(o,i);c!==null?e.ems__Effort_plannedStartTimestamp=c:Is.LoggingService.warn(`[GroundingExecutor] prototype ems__EffortPrototype_startTime "${i}" is not a valid HH:MM[:SS] time-of-day \u2014 skipping plannedStartTimestamp stamp.`)}if(s&&e.ems__Effort_plannedEndTimestamp===void 0){let c=qt.combineDateAndTime(o,s);c!==null?e.ems__Effort_plannedEndTimestamp=c:Is.LoggingService.warn(`[GroundingExecutor] prototype ems__EffortPrototype_endTime "${s}" is not a valid HH:MM[:SS] time-of-day \u2014 skipping plannedEndTimestamp stamp.`)}}static firstScalar(e){if(e==null)return null;let t=Array.isArray(e)?e[0]:e;if(typeof t!="string")return null;let n=t.trim().replace(/^["'](.*)["']$/,"$1").trim();return n.length>0?n:null}static combineDateAndTime(e,t){if(!/^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/.test(t))return null;let n=/^\d{2}:\d{2}$/.test(t)?`${t}:00`:t;return`${e}T${n}`}async resolveIsDefinedByFolder(e,t){let n=qt.parentFolderOf(t),i=e.exo__Asset_isDefinedBy,s=qt.extractBareRef(i);if(s&&this.refToFolder)try{let o=await this.refToFolder(s);if(o!=null)return o}catch(o){Is.LoggingService.error(`[GroundingExecutor] $isDefinedByFolder resolution failed for ref "${s}" \u2014 falling back to host folder.`,o instanceof Error?o:new Error(String(o)))}return n}static parentFolderOf(e){let t=e.replace(/^\/+/,""),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}static extractBareRef(e){if(typeof e!="string")return null;let t=e.trim();t=t.replace(/^["']|["']$/g,"").trim(),t=t.replace(/^\[\[/,"").replace(/\]\]$/,"");let n=t.indexOf("|");return n>=0&&(t=t.slice(0,n)),t=t.trim(),t.length>0?t:null}async preResolveTargetRefs(e,t){if(!e||!this.refToFrontmatter||!t)return;let n=new Set;for(let{value:s}of e){if(typeof s!="string")continue;let o=qt.extractTargetRefPropertyRefKey(s);o&&n.add(o)}if(n.size===0)return;let i={};for(let s of n){let o=t[s],c=Array.isArray(o)?o[0]:o,l=qt.extractBareRef(c);if(!l){i[s]=null;continue}try{i[s]=await this.refToFrontmatter(l)}catch(u){Is.LoggingService.error(`[GroundingExecutor] targetRefProperty second-hop resolution failed for ref "${l}" (refKey "${s}") \u2014 routing skipped, instance co-locates with the click-target.`,u instanceof Error?u:new Error(String(u))),i[s]=null}}return i}static extractTargetRefPropertyRefKey(e){let t=e.match(Ak);if(!t||t[1]!=="targetRefProperty")return null;let n=qt.decodeBase64UrlSafe(t[2]),i=n.indexOf("|");if(i<0)return null;let s=n.slice(0,i);return s.length>0?s:null}async resolveClassRefToUid(e){if(Tk.test(e)||!this.classLabelToUid)return e;try{let t=await this.classLabelToUid(e);return t&&t.length>0?t:e}catch{return e}}applyPropertyDefaultStep(e,t,n){for(let{propertyName:i,value:s}of t){if(e[i]!==void 0)continue;let o=this.resolveSubstitutionMarker(s,n);if(o!=null){if(Array.isArray(o)){if(o.length===0)continue;e[i]=o;continue}if(i==="exo__Instance_class"&&typeof o=="string"){e[i]=[o];continue}e[i]=o}}}applyMissingScalarPrimitives(e,t,n,i,s,o,c){let l=[];e.exo__Asset_uid===void 0&&(e.exo__Asset_uid=this.uidGen.next(),l.push("exo__Asset_uid")),e.exo__Asset_createdAt===void 0&&(e.exo__Asset_createdAt=Ah.DateFormatter.toLocalTimestamp(this.clock.now()),l.push("exo__Asset_createdAt")),e.exo__Asset_updatedAt===void 0&&(e.exo__Asset_updatedAt=e.exo__Asset_createdAt);let u=typeof e.exo__Asset_label=="string"&&e.exo__Asset_label.trim().length===0;if(e.exo__Asset_label===void 0||u){let f=t?.label;if(f===void 0&&i?.labelTemplate)try{let p=this.substituteVariables(i.labelTemplate,s??"",t,o??void 0,c);p.trim().length>0&&(f=p)}catch(p){Is.LoggingService.error(`[GroundingExecutor] labelTemplate substitution failed: ${p instanceof Error?p.message:String(p)}. Falling back to "Untitled".`)}if(i?.omitLabel===!0&&(f===void 0||f.trim().length===0))delete e.exo__Asset_label;else{let p=f!==void 0&&f.trim().length>0?f:"Untitled";e.exo__Asset_label=p;let h=Object.keys(e).some(g=>(0,YA.canonicalYamlKey)(g)==="aliases");p!=="Untitled"&&!h&&(e.aliases=[p]),p==="Untitled"&&l.push("exo__Asset_label")}}e.exo__Instance_class===void 0&&n&&(e.exo__Instance_class=[`"[[${n}]]"`],l.push("exo__Instance_class")),l.length>0&&Is.LoggingService.error(`[GroundingExecutor] Universal Default Template did not cover essential scalar primitives: ${l.join(", ")}. Filled from legacy TS fallback. Vault may be in an unhealthy state \u2014 verify UniversalDefaultTemplate singleton is present and complete.`)}async applyMissingBacklinkTopUp(e,t,n,i,s){if(!n||t.linkBackProperty||e.exo__Asset_prototype!==void 0||e.ems__Effort_parent!==void 0)return;let o=qt.extractBacklinkTarget(n,i);if(qt.propertiesReferenceTarget(e,o))return;let c=s??await this.readTargetFrontmatter(n,i);if(!await this.targetIsPrototype(c))return;let l=c?.exo__Asset_uid,u=typeof l=="string"?l.trim().replace(/^['"]+|['"]+$/g,"").trim():"",f=u.length>0?u:o;e.exo__Asset_prototype=`"[[${f}]]"`,Is.LoggingService.error("[GroundingExecutor] No backlink rule fired (Universal IRs absent or no class match). Falling back to legacy exo__Asset_prototype default \u2014 the target is a prototype, so the link is valid.")}async readTargetFrontmatter(e,t){let n=t;if(!n){let i=qt.resolveTargetPath(e,"");if(!i)return null;n=/\.md$/i.test(i)?i:`${i}.md`}try{let i=await this.fileReader.readFile(n);return this.frontmatterService.parseObject(i)??null}catch{return null}}async targetIsPrototype(e){if(!e)return!1;let t=this.resolveClassRefsFromFrontmatter(e),n=new Set;for(let i of t)if(await this.classRefReachesPrototype(i,0,n))return!0;return!1}async classRefReachesPrototype(e,t,n){if(t>qt.MAX_PROTOTYPE_CLASS_WALK_DEPTH)return!1;let i=e.trim();if(!i||n.has(i))return!1;n.add(i);let s=i.split("|"),o=s[0].trim();if((s[1]??s[0]).trim()===qt.PROTOTYPE_CLASS_LABEL)return!0;if(!this.refToFrontmatter||!o)return!1;let l;try{l=await this.refToFrontmatter(o)}catch{return!1}if(!l)return!1;if(String(l.exo__Asset_label??"").trim()===qt.PROTOTYPE_CLASS_LABEL)return!0;let u=l.exo__Class_superClass,f=Array.isArray(u)?u:u==null?[]:[u];for(let d of f){let p=this.extractWikilinkInner(String(d));if(p&&await this.classRefReachesPrototype(p,t+1,n))return!0}return!1}static propertiesReferenceTarget(e,t){if(!t)return!1;let n=`[[${t}]]`,i=a(s=>typeof s=="string"&&s.includes(n),"refs");for(let s of Object.values(e))if(i(s)||Array.isArray(s)&&s.some(i))return!0;return!1}resolveSubstitutionMarker(e,t){let n=e.match(Ak);if(n){let c=n[1],l=n[2],u=qt.decodeBase64UrlSafe(l),f=(0,XA.getResolver)(c);return f?f(t,u):(Is.LoggingService.warn(`[GroundingExecutor] Parameterised marker references unknown resolver '${c}' \u2014 value left as marker.`),e)}let i=e.match(lZ);if(!i)return e;let s=i[1];if(s==="target"){let c=t.targetIRI??"",l=t.targetFilePath??"";return`"[[${qt.extractBacklinkTarget(c,l)}]]"`}if(s==="targetFolder"){let c=t.targetFilePath??"";if(!c)return"";let l=c.replace(/^\/+/,""),u=l.lastIndexOf("/");return u>=0?l.slice(0,u):""}let o=(0,XA.getResolver)(s);return o?o(t):(Is.LoggingService.warn(`[GroundingExecutor] Marker references unknown resolver '${s}' \u2014 value left as marker.`),e)}static decodeBase64UrlSafe(e){return(0,tZ.base64ToUtf8)(e.replace(/-/g,"+").replace(/_/g,"/"))}async applyInheritanceRuleStep(e,t,n){let i=this.extractTargetClassNames(n),s=[];for(let o of t)!await this.inheritanceConditionMatches(o.targetClassCondition,o.targetClassConditionUid,i)||await this.inheritanceExclusionMatches(o.targetClassExclusion,o.targetClassExclusionUids,i)||s.push(o);s.sort((o,c)=>c.priority-o.priority);for(let o of s){if(e[o.targetPropertyName]!==void 0)continue;let c=n[o.sourcePropertyName];c!=null&&(e[o.targetPropertyName]=this.formatInheritedValue(c))}}async inheritanceConditionMatches(e,t,n){return!e&&!t?!0:this.classRefMatchesAny(e,t,n)}async inheritanceExclusionMatches(e,t,n){for(let i of t??[])if(i&&n.includes(i))return!0;for(let i of e)if(await this.classRefMatchesAny(i,void 0,n))return!0;return!1}async classRefMatchesAny(e,t,n){if(t&&n.includes(t)||e&&n.includes(e))return!0;if(e&&this.classLabelToUid)try{let i=await this.classLabelToUid(e);if(i&&i.length>0&&n.includes(i))return!0}catch{}return!1}extractTargetClassNames(e){let t=e.exo__Instance_class;if(t==null)return[];let n=Array.isArray(t)?t:[t],i=[];for(let s of n){let o=this.extractWikilinkInner(String(s));o&&i.push(o)}return i}extractWikilinkInner(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/);return t?t[1].trim():e.replace(/^["']|["']$/g,"").trim()}formatInheritedValue(e){return Array.isArray(e)?e.map(t=>this.formatInheritedScalar(String(t))):this.formatInheritedScalar(String(e))}formatInheritedScalar(e){return/^"?\[\[.+\]\]"?$/.test(e)?this.reformatWikilink(e):Tk.test(e)?`"[[${e}]]"`:e}reformatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:e}async executeStep(e,t,n,i,s){return e.type===jn.GroundingType.COMPOSITE?this.executeComposite(e,t,n,i,s):this.execute(e,t,n,i)}async rollback(e,t,n,i=[]){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(s){Is.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,s instanceof Error?s:new Error(String(s)))}for(let s of i)try{await this.fileWriter.deleteFile(s)}catch(o){Is.LoggingService.error(`[GroundingExecutor] Rollback: failed to delete orphaned created asset ${s}`,o instanceof Error?o:new Error(String(o)))}}substituteVariables(e,t,n,i,s){let o=this.clock.now(),c=o.toISOString(),l=Ah.DateFormatter.toLocalTimestamp(o),u=this.resolveInstanceDate(n,o),f=`${u}T00:00:00`,d=`${l.slice(0,10)}-${l.slice(11,13)}-${l.slice(14,16)}`,p=e.replace(/\$target\.([A-Za-z_][\w]*)/g,(h,g)=>{if(!i)throw new Error(`$target.${g} substitution requires target frontmatter context; none was supplied (asset IRI: ${t})`);let m=i[g];if(m==null)throw new Error(`$target.${g} is undefined on asset ${t}`);if(Array.isArray(m))throw new Error(`$target.${g} resolved to an array on asset ${t}; only scalar properties are supported for substitution`);return(0,Fi.decodeYamlQuotedScalar)(String(m))});if(/\$targetFolder\b/.test(p)){if(!s)throw new Error("$targetFolder substitution requires targetFilePath context; none was supplied (asset IRI: "+t+")");let h=s.replace(/^\/+/,""),g=h.lastIndexOf("/"),m=g>=0?h.slice(0,g):"";p=p.replace(/\$targetFolder\b/g,m)}if(p=p.replace(/\$target/g,t).replace(/\$nowCompact\b/g,d).replace(/\$nowLocal/g,l).replace(/\$now/g,c).replace(/\$todayStart\b/g,f).replace(/\$today/g,u),n){let h=n;p=p.replace(/\$input\.([A-Za-z_]\w*)|\$(?:input|value)\b/g,(g,m)=>{let b=m!==void 0?h[m]:h.value;return b==null?g:String(b)})}return p}async executePropertyAppend(e,t,n,i){if(!e.targetProperty)return{success:!1,error:"property_append requires targetProperty"};if(e.appendExpression===void 0)return{success:!1,error:"property_append requires appendExpression"};let s=await this.fileReader.readFile(n),o=this.frontmatterService.parseObject(s)??{},c=this.substituteVariables(e.appendExpression,t,i,o),l=o[e.targetProperty],u=Array.isArray(l)?l:l!==void 0?[String(l)]:[],f=(0,Fi.isCompleteDoubleQuotedScalar)(c)?(0,Fi.decodeYamlQuotedScalar)(c):c,d=new Set(u.map(Fi.decodeYamlQuotedScalar)),p;d.has(f)?p=u:p=[...u,(0,Fi.quoteYamlString)(f)];let h=this.stampUpdatedAt(s,this.frontmatterService.updateProperty(s,e.targetProperty,p),e.targetProperty);return await this.fileWriter.updateFile(n,h),{success:!0}}async executePropertyReplace(e,t,n,i){if(!e.targetProperty)return{success:!1,error:"property_replace requires targetProperty"};if(e.replaceFromExpression===void 0)return{success:!1,error:"property_replace requires replaceFromExpression"};if(e.replaceToExpression===void 0)return{success:!1,error:"property_replace requires replaceToExpression"};let s=await this.fileReader.readFile(n),o=this.frontmatterService.parseObject(s)??{},c=o[e.targetProperty];if(!Array.isArray(c))return{success:!1,error:`property_replace: <${e.targetProperty}> is not a list on this asset (replacing one element of a scalar is identical to property_set \u2014 use that instead)`};let l=c,u=a(b=>{let _=this.substituteVariables(b,t,i,o);return(0,Fi.isCompleteDoubleQuotedScalar)(_)?(0,Fi.decodeYamlQuotedScalar)(_):_},"plainOf"),f=u(e.replaceFromExpression),d=u(e.replaceToExpression),p=l.findIndex(b=>(0,Fi.decodeYamlQuotedScalar)(b)===f);if(p===-1)return{success:!1,error:`property_replace: "${f}" is not a value of <${e.targetProperty}> on this asset \u2014 refusing rather than appending`};let g=l.findIndex((b,_)=>_!==p&&(0,Fi.decodeYamlQuotedScalar)(b)===d)===-1?l.map((b,_)=>_===p?(0,Fi.quoteYamlString)(d):b):l.filter((b,_)=>_!==p),m=this.stampUpdatedAt(s,this.frontmatterService.updateProperty(s,e.targetProperty,g),e.targetProperty);return await this.fileWriter.updateFile(n,m),{success:!0}}async executePropertyIncrement(e,t){if(!e.targetProperty)return{success:!1,error:"property_increment requires targetProperty"};let n=e.incrementBy??1;if(!Number.isFinite(n)||!Number.isInteger(n))return{success:!1,error:`property_increment: incrementBy must be an integer (got ${String(e.incrementBy)})`};let i=await this.fileReader.readFile(t),o=(this.frontmatterService.parseObject(i)??{})[e.targetProperty],c;if(o==null||o==="")c=0;else{if(Array.isArray(o))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" is an array, expected integer`};{let f=String(o).replace(/^["'](.*)["']$/,"$1").trim();if(!/^-?\d+$/.test(f))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" current value "${String(o)}" is not a valid integer`};c=Number.parseInt(f,10)}}let l=c+n,u=this.stampUpdatedAt(i,this.frontmatterService.updateProperty(i,e.targetProperty,l),e.targetProperty);return await this.fileWriter.updateFile(t,u),{success:!0}}async executePropertyShift(e,t){if(!e.targetProperty)return{success:!1,error:"property_shift requires targetProperty"};if(!e.shiftDelta)return{success:!1,error:"property_shift requires shiftDelta (ISO-8601 duration literal)"};let n=await this.fileReader.readFile(t),s=(this.frontmatterService.parseObject(n)??{})[e.targetProperty];if(s==null||s==="")return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is not set on target asset`};if(Array.isArray(s))return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is an array, expected single datetime`};let o=String(s).replace(/^["'](.*)["']$/,"$1").trim(),c=new Date(o);if(Number.isNaN(c.getTime()))return{success:!1,error:`property_shift: current value "${o}" is not a valid datetime`};let l;try{l=qt.applyIsoDuration(c,e.shiftDelta)}catch(d){return{success:!1,error:`property_shift: invalid shiftDelta "${e.shiftDelta}": ${d instanceof Error?d.message:String(d)}`}}let u=Ah.DateFormatter.toLocalTimestamp(l),f=this.stampUpdatedAt(n,this.frontmatterService.updateProperty(n,e.targetProperty,u),e.targetProperty);return await this.fileWriter.updateFile(t,f),{success:!0}}async executeWorkflowTransition(e,t,n,i){if(!this.workflowResolver)return{success:!1,error:"workflow_transition requires WorkflowResolver injection (options.workflowResolver). Wire the plugin/CLI before using this grounding type."};let s=await this.fileReader.readFile(n),o=this.frontmatterService.parseObject(s)??{},c=this.resolveClassRefsFromFrontmatter(o);if(c.length===0)return{success:!1,notApplicable:!0,error:"workflow_transition: target asset has no exo__Instance_class \u2014 status transitions are not available for it."};let l;try{l=new rZ.IRI(t)}catch(I){return{success:!1,error:`workflow_transition: invalid targetIRI "${t}" \u2014 ${I instanceof Error?I.message:String(I)}`}}let u=await this.workflowResolver.resolveForAssetOrNull(l,c);if(!u)return{success:!1,notApplicable:!0,error:"workflow_transition: this asset's class has no status workflow \u2014 status transitions are not available for it."};let f=this.resolveStatusFromFrontmatter(o);if(!f)return{success:!1,error:"workflow_transition: target asset has no parseable ems__Effort_status value (need wikilink to an ems__EffortStatus* asset)."};let d=e.direction??"forward",p=d==="rollback",h=u.transitions.find(I=>I.from===f&&I.isRollback===p);if(!h)return{success:!1,error:`workflow_transition: no ${d} transition from "${f}" defined in workflow "${u.name}" (target class: ${u.targetClass}).`};let g=Br.STATUS_UID_BY_ENUM[h.to];if(!g)return{success:!1,error:`workflow_transition: no UID mapping for destination status "${h.to}" (transition target unreachable).`};let m={id:`${e.id}.statusMutation`,label:`workflow_transition: ${h.from} \u2192 ${h.to}`,type:jn.GroundingType.PROPERTY_SET,targetProperty:"ems__Effort_status",targetValueRef:g},b=await this.executePropertySet(m,t,n,i);if(!b.success)return{success:!1,error:`workflow_transition: status mutation failed \u2014 ${b.error}`};let _=h.postActions??[],S=this.groundingLoader;if(_.length>0&&S===void 0)return{success:!1,error:"workflow_transition: transition has postActions but no GroundingLoader injected (options.groundingLoader). Wire commandResolver.loadGroundingByUid in plugin/CLI."};for(let I of _){if(S===void 0)break;let E=await S(I);if(!E)return{success:!1,error:`workflow_transition: postAction grounding UID "${I}" could not be loaded (asset missing or invalid Grounding shape).`};let w=await this.execute(E,t,n,i);if(!w.success)return{success:!1,error:`workflow_transition: postAction "${E.label}" (UID ${I}) failed \u2014 ${w.error}`}}return{success:!0}}resolveClassRefsFromFrontmatter(e){let t=e.exo__Instance_class;if(t==null)return[];let n=Array.isArray(t)?t:[t],i=[];for(let s of n){if(typeof s!="string")continue;let o=s.replace(/^\s*"?\[\[/,"").replace(/\]\]"?\s*$/,"").trim();o.length>0&&i.push(o)}return i}resolveStatusFromFrontmatter(e){return(0,Rk.normalizeEffortStatus)(e.ems__Effort_status)}static applyIsoDuration(e,t){let n=t.trim();if(/^-?P(\d+Y)(\d+M)?$|^-?P\d+M$/.test(n)){let o=vk.DateTimeParsing.parseYearMonthDuration(n),c=new Date(e.getTime());return c.setMonth(c.getMonth()+o),c}let s=vk.DateTimeParsing.parseDayTimeDuration(n);return new Date(e.getTime()+s)}static extractBacklinkTarget(e,t){let n=qt.resolveTargetPath(e,t),i=n.split("/").pop()??n;return qt.UUID_BASENAME_RE.test(i)?i:n}static resolveTargetPath(e,t){if(t)return t.replace(/\.md$/i,"").replace(/^\/+/,"");if(e){let n=e.match(/^obsidian:\/\/vault\/(.+?)(?:\.md)?(?:\?|#|$)/i);if(n&&n[1])try{return decodeURIComponent(n[1])}catch{return n[1]}}return e}};Br.GroundingExecutor=Uf;Uf.UUID_BASENAME_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Uf.PROTOTYPE_CLASS_LABEL="exo__Prototype";Uf.MAX_PROTOTYPE_CLASS_WALK_DEPTH=6;Br.GroundingExecutor=Uf=qt=YJ([(0,QJ.injectable)(),XJ("design:paramtypes",[Object,Object,Tb,Function,Object])],Uf)});var Ok=T(JA=>{"use strict";Object.defineProperty(JA,"__esModule",{value:!0});JA.createVaultFrontmatterClassLabelResolver=fZ;function fZ(r){return async e=>{if(!e)return null;let t=await r.findFilesByMetadata({exo__Asset_label:e});if(t.length>0){let s=(await r.getFileMetadata(t[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}let n=await r.findFilesByMetadata({aliases:e});if(n.length>0){let s=(await r.getFileMetadata(n[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}return null}}a(fZ,"createVaultFrontmatterClassLabelResolver")});var Pk=T(ZA=>{"use strict";Object.defineProperty(ZA,"__esModule",{value:!0});ZA.createVaultFrontmatterRefToFolderResolver=dZ;function dZ(r){return async e=>{if(!e)return null;let t=await r.findFilesByMetadata({exo__Asset_uid:e});return t.length===0?null:pZ(t[0])}}a(dZ,"createVaultFrontmatterRefToFolderResolver");function pZ(r){let e=r.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}a(pZ,"parentFolderOf")});var Fk=T(e2=>{"use strict";Object.defineProperty(e2,"__esModule",{value:!0});e2.createVaultFrontmatterRefToFrontmatterResolver=hZ;function hZ(r){return async e=>{if(!e)return null;let t=await r.findFilesByMetadata({exo__Asset_uid:e});return t.length===0?null:r.getFileMetadata(t[0])}}a(hZ,"createVaultFrontmatterRefToFrontmatterResolver")});var Lk=T(ma=>{"use strict";var mZ=ma&&ma.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},gZ=ma&&ma.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Bf;Object.defineProperty(ma,"__esModule",{value:!0});ma.NamedQueryRunner=void 0;var yZ=ct(),bZ=Le(),_Z=Ye(),Dk=rb(),SZ=oa(),t2=Bf=class{static{a(this,"NamedQueryRunner")}constructor(e,t){this.queryBodyResolver=e,this.tripleStore=t}async run(e,t={}){if(!e)return null;let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return null;let i=this.substitute(n,t);return(0,Dk.evaluateWithExoEval)(i,{store:this.tripleStore})}async runScalar(e,t={},n){if(!e)throw new Error("NamedQueryRunner.runScalar: empty queryUid");let i=await this.queryBodyResolver.resolveSparql(e);if(!i)throw new Error(`NamedQueryRunner: query__NamedQuery '${e}' has no resolvable SPARQL body (asset missing or no \`\`\`sparql block).`);let s=this.substitute(i,t),o=await(0,Dk.evaluateWithExoEval)(s,{store:this.tripleStore});if(o.kind==="ask")return{value:o.result?"true":"false",kind:"literal"};if(o.kind==="construct")return null;let c=o.rows[0];if(!c)return null;let l=c.variables(),u=n??l[0];if(!u)return null;let f=c.get(u);return f===void 0?null:f instanceof bZ.IRI?{value:(0,SZ.iriToObsidianName)(f.value)??f.value,kind:"iri",iri:f.value}:f instanceof _Z.Literal?{value:f.value,kind:"literal"}:null}substitute(e,t){let n=e;t.currentAsset&&(n=n.replace(/\$currentAsset\b/g,Bf.formatIri(t.currentAsset))),t.currentClass&&(n=n.replace(/\$currentClass\b/g,Bf.formatIri(t.currentClass)));let i=t.params;if(i){let s=Object.keys(i).sort((o,c)=>c.length-o.length);for(let o of s){let c=i[o],l=c.kind==="iri"?Bf.formatIri(c.value):`"${Bf.escapeLiteral(c.value)}"`,u=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(`\\$${u}\\b`,"g"),l)}}return n}static formatIri(e){if(/[\s<>"{}|\\^`]/.test(e))throw new Error(`NamedQueryRunner: refusing to inject malformed IRI "${e}" \u2014 contains a character illegal in a SPARQL IRIREF (would break out of <...>). Pass a percent-encoded IRI.`);return`<${e}>`}static escapeLiteral(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}};ma.NamedQueryRunner=t2;ma.NamedQueryRunner=t2=Bf=mZ([(0,yZ.injectable)(),gZ("design:paramtypes",[Object,Object])],t2)});var Nk=T(Ab=>{"use strict";Object.defineProperty(Ab,"__esModule",{value:!0});Ab.extractSparqlBlock=wZ;Ab.stripFrontmatter=EZ;function wZ(r){let e=r.match(/```sparql\s*\n([\s\S]*?)\n```/);if(!e)return null;let t=e[1].trim();return t.length>0?t:null}a(wZ,"extractSparqlBlock");function EZ(r){if(!r.startsWith("---"))return r;let e=r.indexOf(`
|
|
139
|
+
Details: ${t.message}`:"";console.error(`[Exocortex ERROR]${s} ${e}${o}`)}}};Eb.LoggingService=Th;Th.isVerbose=!1;Th.isDevelopment=void 0});var HA=T(vb=>{"use strict";Object.defineProperty(vb,"__esModule",{value:!0});vb.CLASS_UID_TO_LABEL=void 0;var zA=ml();vb.CLASS_UID_TO_LABEL=Object.freeze({"1b20a8f0-d745-4e93-91db-4531b3df120e":zA.AssetClass.TASK,"7db5eeff-718a-49b0-8d2b-39b084a356e3":zA.AssetClass.PROJECT,"1b0a5e34-dd7f-4ead-b43a-6c7c5a5ecaca":zA.AssetClass.MEETING})});var xk=T(Br=>{"use strict";var YJ=Br&&Br.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},XJ=Br&&Br.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},qt;Object.defineProperty(Br,"__esModule",{value:!0});Br.GroundingExecutor=Br.ServiceRegistry=Br.CLASS_UID_TO_LABEL=Br.STATUS_UID_BY_ENUM=void 0;Br.missingInputHint=QA;Br.missingInputError=Ck;Br.findMissingInput=aZ;var QJ=ct(),JJ=_h(),ZJ=ob(),jn=cc(),eZ=kA(),tZ=ef(),Rk=Gu(),rZ=Le(),KA=zl(),Fi=Fl(),YA=Wl(),nZ=Hl(),iZ=oa(),Ek=gb(),Ah=vs(),vk=hh(),Is=Kl();Br.STATUS_UID_BY_ENUM=Rk.EFFORT_STATUS_UID;var sZ=HA();Object.defineProperty(Br,"CLASS_UID_TO_LABEL",{enumerable:!0,get:a(function(){return sZ.CLASS_UID_TO_LABEL},"get")});var XA=lb();(0,XA.installDefaultResolvers)();function oZ(r){if(r){if(r==="1b20a8f0-d745-4e93-91db-4531b3df120e")return"ems__Task";if(r==="7db5eeff-718a-49b0-8d2b-39b084a356e3")return"ems__Project";if(r==="ems__Task"||r==="ems__Project")return r}}a(oZ,"resolveClassFlipTarget");function QA(r,e){let t=e??{},n=a(c=>c!=null,"isProvided"),i=[...r.matchAll(/\$input\.([A-Za-z_]\w*)/g)].map(c=>c[1]),s=/\$input\b(?!\.)/.test(r)||/\$value\b/.test(r),o=i.find(c=>!n(t[c]));return o!==void 0?`--input '{"${o}":...}'`:s&&!n(t.value)?`--input '{"value":...}'`:null}a(QA,"missingInputHint");function Ck(r){return`property_set: value template references an input that was not provided (${r} required)`}a(Ck,"missingInputError");function aZ(r,e){let t=a(i=>{if(i.type===jn.GroundingType.PROPERTY_SET){if(i.targetValueRef!==void 0)return`"[[${i.targetValueRef}]]"`;if(i.targetValueLiteral!==void 0)return i.targetValueLiteral;if(i.targetValueSubstitution!==void 0)return i.targetValueSubstitution}},"staticTemplate"),n=a(i=>{let s=t(i);if(s!==void 0){let o=QA(s,e);if(o!==null)return o}for(let o of i.steps??[]){let c=n(o);if(c!==null)return c}return null},"visit");return n(r)}a(aZ,"findMissingInput");var cZ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Tk=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,lZ=/^__SUBSTITUTE__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__$/,Ak=/^__SUBSTITUTE_P__([a-zA-Z][a-zA-Z0-9_]*)__[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}__([A-Za-z0-9_-]*)__$/,Tb=class{static{a(this,"ServiceRegistry")}constructor(){this.services=new Map}register(e,t){this.services.set(e,t)}get(e){return this.services.get(e)}has(e){return this.services.has(e)}getRegisteredIds(){return Array.from(this.services.keys())}};Br.ServiceRegistry=Tb;var Ik=20;function uZ(r){return/^\[\[[\s\S]*\]\]$/.test(r.trim())}a(uZ,"isUnquotedWikilink");var Uf=qt=class{static{a(this,"GroundingExecutor")}constructor(e,t,n,i,s){this.frontmatterService=new KA.FrontmatterService,this.fileReader=e,this.fileWriter=t,this.serviceRegistry=n,this.classLabelToUid=i,this.refToFolder=s?.refToFolder,this.refToFrontmatter=s?.refToFrontmatter,this.workflowResolver=s?.workflowResolver,this.groundingLoader=s?.groundingLoader,this.templateLoader=s?.templateLoader,this.namedQueryRunner=s?.namedQueryRunner,this.declaredRanges=s?.declaredRanges,this.clock=s?.clock??(0,JJ.liveClock)(),this.uidGen=s?.uidGenerator??(0,ZJ.liveUidGenerator)()}async execute(e,t,n,i){try{switch(e.type){case jn.GroundingType.PROPERTY_SET:return await this.executePropertySet(e,t,n,i);case jn.GroundingType.PROPERTY_DELETE:return await this.executePropertyDelete(e,n);case jn.GroundingType.PROPERTY_REPLACE:return await this.executePropertyReplace(e,t,n,i);case jn.GroundingType.COMPOSITE:return await this.executeComposite(e,t,n,i,0);case jn.GroundingType.SERVICE_CALL:return await this.executeServiceCall(e,t,n,i);case jn.GroundingType.CREATE_INSTANCE:return await this.executeCreateInstance(e,t,n,i);case jn.GroundingType.PROPERTY_APPEND:return await this.executePropertyAppend(e,t,n,i);case jn.GroundingType.PROPERTY_INCREMENT:return await this.executePropertyIncrement(e,n);case jn.GroundingType.PROPERTY_SHIFT:return await this.executePropertyShift(e,n);case jn.GroundingType.SPARQL_UPDATE:return{success:!1,error:"sparql_update grounding not yet implemented. Use property_set/property_delete instead."};case jn.GroundingType.WORKFLOW_TRANSITION:return await this.executeWorkflowTransition(e,t,n,i);case jn.GroundingType.BODY_TEMPLATE:return await this.executeBodyTemplate(e,t,n,i);default:return{success:!1,error:`Unknown grounding type: ${e.type}`}}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}stampUpdatedAt(e,t,n){return t===e||n!==void 0&&(0,YA.canonicalYamlKey)(KA.FrontmatterService.normalizeIRI(n))==="exo__Asset_updatedAt"||!this.frontmatterService.parse(t).exists?t:this.frontmatterService.updateProperty(t,"exo__Asset_updatedAt",Ah.DateFormatter.toLocalTimestamp(this.clock.now()))}async executePropertySet(e,t,n,i){if(!e.targetProperty)return{success:!1,error:"property_set requires targetProperty"};if(e.targetQuery!==void 0&&e.targetsCreatedInstance===!0)return{success:!1,error:"property_set: targetQuery and targetsCreatedInstance are mutually exclusive (both address the step's TARGET \u2014 pick one)."};let s;if([e.targetValueRef!==void 0,e.targetValueLiteral!==void 0,e.targetValueSubstitution!==void 0,e.targetValueQuery!==void 0].filter(Boolean).length>1)return{success:!1,error:"property_set: more than one of targetValueRef/targetValueLiteral/targetValueSubstitution/targetValueQuery set (cardinality 0..1 each, mutually exclusive)"};if(e.targetValueRef!==void 0)s=`"[[${e.targetValueRef}]]"`;else if(e.targetValueLiteral!==void 0)s=e.targetValueLiteral;else if(e.targetValueSubstitution!==void 0)s=e.targetValueSubstitution;else if(e.targetValueQuery!==void 0){let I=await this.resolveTargetValueQuery(e.targetValueQuery,t);if(!I.success)return I;s=I.value}else return{success:!1,error:"property_set requires one of targetValueRef/targetValueLiteral/targetValueSubstitution/targetValueQuery"};let c=QA(s,i);if(c!==null)return{success:!1,error:Ck(c)};let l=e.targetValueRef!==void 0&&/\$/.test(e.targetValueRef),u;if(l){let I=this.substituteVariables(e.targetValueRef,t,i),E=I.trim().replace(/^["']|["']$/g,"").replace(/^\[\[|\]\]$/g,""),w=/\[\[|\]\]/.test(E)?null:(0,nZ.extractAssetReference)(I)?.trim()||null;if(w===null)return{success:!1,error:`property_set: asset-reference value ${JSON.stringify(I)} for ${e.targetProperty} is not a single reference \u2014 pass a BARE uid (or one [[uid]] / [[uid|alias]] wikilink, which is unwrapped); nested brackets, a link inside prose or an empty value would be written as a broken link.`};u=`"[[${w}]]"`}else u=this.substituteVariables(s,t,i);let f=KA.FrontmatterService.normalizeIRI(e.targetProperty),d=(0,YA.canonicalYamlKey)(f),p=(0,iZ.iriToObsidianName)(e.targetProperty)??f,h=this.declaredRanges?(await this.declaredRanges([p])).get(p):void 0,g=Fi.STRING_SCALAR_PROPERTIES.has(d),m=(0,Fi.scalarTypingForRange)(h)!==void 0?(0,Fi.serializeYamlScalar)(u,g,h):g?(0,Fi.serializeYamlScalar)(u,!0):u;if(uZ(m))return{success:!1,error:`property_set: value ${m} is an UNQUOTED wikilink \u2014 YAML reads it as a flow sequence, so the graph would receive a literal instead of a link (silent data loss). Pass the QUOTED form for a substituted reference (the quotes are part of the string, e.g. --input '{"<key>":"\\"[[<uid>]]\\""}'), or use targetValueRef, which takes a BARE uid and wraps it itself.`};let b=n;if(e.targetQuery!==void 0){let I=await this.resolveTargetQuery(e.targetQuery,t);if(!I.success)return I;b=I.path}let _=await this.fileReader.readFile(b),S=this.stampUpdatedAt(_,this.frontmatterService.updateProperty(_,e.targetProperty,m),e.targetProperty);return await this.fileWriter.updateFile(b,S),{success:!0}}async resolveTargetQuery(e,t){if(!this.namedQueryRunner)return{success:!1,error:"property_set targetQuery requires NamedQueryRunner injection (options.namedQueryRunner). Wire the plugin/CLI before using this target-source."};let n;try{n=await this.namedQueryRunner.runScalar(e,{currentAsset:t})}catch(s){return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' failed \u2014 ${s instanceof Error?s.message:String(s)}`}}if(n===null)return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' matched no asset (empty result set) \u2014 refusing to fall back to the click-target.`};if(n.kind!=="iri")return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' returned a literal ('${n.value}'), not an asset reference \u2014 a target must be an asset.`};if(n.iri===void 0)return{success:!1,error:`property_set targetQuery: NamedQuery '${e}' returned an asset reference without its source IRI, so its file path cannot be resolved.`};let i=(0,Ek.iriToVaultPath)(n.iri);return i===null?{success:!1,error:`property_set targetQuery: NamedQuery '${e}' matched '${n.iri}', which is not a vault asset IRI (no resolvable file path).`}:{success:!0,path:i}}async resolveTargetValueQuery(e,t){if(!this.namedQueryRunner)return{success:!1,error:"property_set targetValueQuery requires NamedQueryRunner injection (options.namedQueryRunner). Wire the plugin/CLI before using this value-source."};let n;try{n=await this.namedQueryRunner.runScalar(e,{currentAsset:t})}catch(s){return{success:!1,error:`property_set targetValueQuery: NamedQuery '${e}' failed \u2014 ${s instanceof Error?s.message:String(s)}`}}return n===null?{success:!1,error:`property_set targetValueQuery: NamedQuery '${e}' returned no scalar value (empty result set or non-scalar shape).`}:{success:!0,value:n.kind==="iri"?`"[[${n.value}]]"`:n.value}}async executePropertyDelete(e,t){if(!e.targetProperty)return{success:!1,error:"property_delete requires targetProperty"};let n=await this.fileReader.readFile(t),i=this.stampUpdatedAt(n,this.frontmatterService.removeProperty(n,e.targetProperty),e.targetProperty);return await this.fileWriter.updateFile(t,i),{success:!0}}async executeComposite(e,t,n,i,s){if(s>=Ik)return{success:!1,error:`Composite grounding exceeded maximum depth of ${Ik}`};let o=e.steps??[];if(o.length===0)return{success:!0};let c;try{c=await this.fileReader.readFile(n)}catch{}let l=[],u,f=[];try{for(let d=0;d<o.length;d++){let p=o[d],g=(p.type===jn.GroundingType.BODY_TEMPLATE||p.targetsCreatedInstance===!0)&&u?u:n,m=await this.executeStep(p,t,g,i,s+1);if(!m.success)return await this.rollback(c,n,l,f),{success:!1,error:`Composite step ${d} failed: ${m.error}`};m.openPath&&(u=m.openPath),m.openPath&&f.push(m.openPath),m.createdPaths&&m.createdPaths.length>0&&f.push(...m.createdPaths),l.push(d)}return{success:!0,...f.length>0?{createdPaths:await this.resolveCreatedPaths(f)}:{}}}catch(d){return await this.rollback(c,n,l,f),{success:!1,error:`Composite execution failed: ${d instanceof Error?d.message:String(d)}`}}}async executeServiceCall(e,t,n,i){let s=e.targetProperty;if(!s)return{success:!1,error:"service_call requires targetProperty as serviceId"};if(e.targetQuery!==void 0&&e.targetsCreatedInstance===!0)return{success:!1,error:"service_call: targetQuery and targetsCreatedInstance are mutually exclusive (both address the step's TARGET \u2014 pick one)."};if(s==="convertToTask")return await this.executeConvertToTask(n);if(s==="updateProperty"){let f=oZ(e.targetValueRef);if(f==="ems__Task")return await this.executeConvertToTask(n);if(f==="ems__Project")return await this.executeConvertToProject(n)}let o=this.serviceRegistry.get(s);if(!o)return{success:!1,error:`Service not found: "${s}". Registered services: ${this.serviceRegistry.getRegisteredIds().join(", ")||"none"}`};let c=i;if(e.isDefinedBy&&(c={isDefinedBy:e.isDefinedBy,...c??{}}),e.serviceCallPayload)try{let f=this.substituteVariables(e.serviceCallPayload,t,i),d=JSON.parse(f);typeof d=="object"&&d!==null&&(c={...d,...c??{}})}catch{}let l=e.targetsCreatedInstance===!0&&n?(0,Ek.vaultPathToIRI)(n):t,u=await this.readServiceCallSnapshot(n);return await o.execute(l,c),await this.stampServiceCallTarget(n,u,c),{success:!0}}async readServiceCallSnapshot(e){if(!e||!await this.fileReader.fileExists(e))return;let t=await this.fileReader.readFile(e),n=this.frontmatterService.parseObject(t)?.exo__Asset_uid,i=typeof n=="string"?n.trim().replace(/^"|"$/g,""):"";if(!cZ.test(i))return{bytes:t};let s=e.lastIndexOf("/"),c=`${s>=0?e.slice(0,s+1):""}${i}.md`;return c===e?{bytes:t}:await this.fileReader.fileExists(c)?{bytes:t}:{bytes:t,canon:c}}async stampServiceCallTarget(e,t,n){if(t===void 0)return;let i=await this.locateServiceCallTarget(e,t);if(i===void 0)return;let s=t.bytes,o=await this.fileReader.readFile(i);if(o===s)return;let c=typeof n?.property=="string"?n.property:void 0,l=this.stampUpdatedAt(s,o,c);l!==o&&await this.fileWriter.updateFile(i,l)}async locateServiceCallTarget(e,t){if(await this.fileReader.fileExists(e))return e;if(t.canon!==void 0&&await this.fileReader.fileExists(t.canon))return t.canon}async executeConvertToTask(e){let t=await this.fileReader.readFile(e),n=await this.resolveClassRefToUid("ems__Task"),i=this.stampUpdatedAt(t,this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${n}]]"]`),"exo__Instance_class");return await this.fileWriter.updateFile(e,i),{success:!0}}async executeConvertToProject(e){let t=await this.fileReader.readFile(e),n=await this.resolveClassRefToUid("ems__Project"),i=this.stampUpdatedAt(t,this.frontmatterService.updateProperty(t,"exo__Instance_class",`["[[${n}]]"]`),"exo__Instance_class");return await this.fileWriter.updateFile(e,i),{success:!0}}async executeBodyTemplate(e,t,n,i){let s=null;if(e.templateRef)if(this.templateLoader){if(s=await this.templateLoader(e.templateRef),s===null)return{success:!1,error:`body_template: templateRef "${e.templateRef}" did not resolve to a template body (asset missing or empty).`}}else{if(e.bodyTemplate===void 0)return{success:!1,error:`body_template: templateRef "${e.templateRef}" set but no TemplateLoaderPort is wired (and no inline bodyTemplate fallback).`};s=e.bodyTemplate}else if(e.bodyTemplate!==void 0)s=e.bodyTemplate;else return{success:!1,error:"body_template requires bodyTemplate or templateRef"};let o=(0,eZ.resolveTemplateBody)(s,{userInput:i,targetIRI:t,targetFilePath:n}),c;try{c=await this.fileReader.readFile(n)}catch(u){return{success:!1,error:`body_template: failed to read target file "${n}": ${u instanceof Error?u.message:String(u)}`}}let l=this.stampUpdatedAt(c,qt.replaceBody(c,o));return await this.fileWriter.updateFile(n,l),{success:!0}}static replaceBody(e,t){let n=e.match(/^---\r?\n[\s\S]*?\r?\n---/);return n?`${n[0]}
|
|
140
|
+
${t}`:t}static extractBody(e){let t=e.match(/^---\r?\n[\s\S]*?\r?\n---/);return t?e.slice(t[0].length).replace(/^\r?\n/,""):e}async executeCreateInstance(e,t,n,i){if(!e.targetFolder)return{success:!1,error:"create_instance requires targetFolder"};let s={},o=null,c=null;if((e.inheritanceRule&&e.inheritanceRule.length>0||e.propertyDefault&&e.propertyDefault.some(E=>typeof E.value=="string"&&E.value.includes("__SUBSTITUTE"))||e.labelTemplate!==void 0&&/\$target\./.test(e.labelTemplate)||e.cloneTargetBody===!0)&&t&&n){let E;try{E=await this.fileReader.readFile(n)}catch(w){return{success:!1,error:`create_instance: failed to read $target file "${n}": ${w instanceof Error?w.message:String(w)}`}}o=this.frontmatterService.parseObject(E)??null,e.cloneTargetBody&&(c=qt.extractBody(E))}let u;e.targetClass&&(u=await this.resolveClassRefToUid(e.targetClass));let f=await this.preResolveTargetRefs(e.propertyDefault,o),d={userInput:i,targetIRI:t,targetFilePath:n,targetFm:o??void 0,targetRefFm:f,groundingTargetClassUid:u};if(e.propertyDefault&&e.propertyDefault.length>0&&this.applyPropertyDefaultStep(s,e.propertyDefault,d),this.applyMissingScalarPrimitives(s,i,u,e,t,o,n),i)for(let[E,w]of Object.entries(i))E!=="label"&&E!=="body"&&E!=="plannedDate"&&w!=null&&(s[E]=w);if(e.inheritanceRule&&e.inheritanceRule.length>0&&o&&await this.applyInheritanceRuleStep(s,e.inheritanceRule,o),await this.applyMissingBacklinkTopUp(s,e,t,n,o),t&&e.linkBackProperty&&s[e.linkBackProperty]===void 0){let E=qt.extractBacklinkTarget(t,n);s[e.linkBackProperty]=`"[[${E}]]"`}this.applyPrototypeTimePropagation(s,o,i);let p=s.exo__Asset_uid,h=this.declaredRanges?await this.declaredRanges(Object.keys(s)):void 0,g=this.frontmatterService.createFrontmatter("",s,h===void 0?void 0:E=>h.get(E)),m=e.targetFolder.includes("$isDefinedByFolder")?await this.resolveIsDefinedByFolder(s,n):this.substituteVariables(e.targetFolder,t,i,void 0,n),b=m?`${m}/${p}.md`:`${p}.md`,_=i?.body,S=typeof _=="string"&&_.length>0?_:e.cloneTargetBody&&typeof c=="string"&&c.length>0?c:null,I=S!==null?qt.replaceBody(g,S):g;return await this.fileWriter.createFile(b,I),{success:!0,openPath:b}}resolveInstanceDate(e,t){let n=qt.firstScalar(e?.plannedDate);return n&&/^\d{4}-\d{2}-\d{2}$/.test(n)?n:Ah.DateFormatter.toDateString(t??this.clock.now())}applyPrototypeTimePropagation(e,t,n){if(!t)return;let i=qt.firstScalar(t.ems__EffortPrototype_startTime),s=qt.firstScalar(t.ems__EffortPrototype_endTime);if(!i&&!s)return;let o=this.resolveInstanceDate(n);if(i&&e.ems__Effort_plannedStartTimestamp===void 0){let c=qt.combineDateAndTime(o,i);c!==null?e.ems__Effort_plannedStartTimestamp=c:Is.LoggingService.warn(`[GroundingExecutor] prototype ems__EffortPrototype_startTime "${i}" is not a valid HH:MM[:SS] time-of-day \u2014 skipping plannedStartTimestamp stamp.`)}if(s&&e.ems__Effort_plannedEndTimestamp===void 0){let c=qt.combineDateAndTime(o,s);c!==null?e.ems__Effort_plannedEndTimestamp=c:Is.LoggingService.warn(`[GroundingExecutor] prototype ems__EffortPrototype_endTime "${s}" is not a valid HH:MM[:SS] time-of-day \u2014 skipping plannedEndTimestamp stamp.`)}}static firstScalar(e){if(e==null)return null;let t=Array.isArray(e)?e[0]:e;if(typeof t!="string")return null;let n=t.trim().replace(/^["'](.*)["']$/,"$1").trim();return n.length>0?n:null}static combineDateAndTime(e,t){if(!/^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/.test(t))return null;let n=/^\d{2}:\d{2}$/.test(t)?`${t}:00`:t;return`${e}T${n}`}async resolveIsDefinedByFolder(e,t){let n=qt.parentFolderOf(t),i=e.exo__Asset_isDefinedBy,s=qt.extractBareRef(i);if(s&&this.refToFolder)try{let o=await this.refToFolder(s);if(o!=null)return o}catch(o){Is.LoggingService.error(`[GroundingExecutor] $isDefinedByFolder resolution failed for ref "${s}" \u2014 falling back to host folder.`,o instanceof Error?o:new Error(String(o)))}return n}static parentFolderOf(e){let t=e.replace(/^\/+/,""),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}static extractBareRef(e){if(typeof e!="string")return null;let t=e.trim();t=t.replace(/^["']|["']$/g,"").trim(),t=t.replace(/^\[\[/,"").replace(/\]\]$/,"");let n=t.indexOf("|");return n>=0&&(t=t.slice(0,n)),t=t.trim(),t.length>0?t:null}async preResolveTargetRefs(e,t){if(!e||!this.refToFrontmatter||!t)return;let n=new Set;for(let{value:s}of e){if(typeof s!="string")continue;let o=qt.extractTargetRefPropertyRefKey(s);o&&n.add(o)}if(n.size===0)return;let i={};for(let s of n){let o=t[s],c=Array.isArray(o)?o[0]:o,l=qt.extractBareRef(c);if(!l){i[s]=null;continue}try{i[s]=await this.refToFrontmatter(l)}catch(u){Is.LoggingService.error(`[GroundingExecutor] targetRefProperty second-hop resolution failed for ref "${l}" (refKey "${s}") \u2014 routing skipped, instance co-locates with the click-target.`,u instanceof Error?u:new Error(String(u))),i[s]=null}}return i}static extractTargetRefPropertyRefKey(e){let t=e.match(Ak);if(!t||t[1]!=="targetRefProperty")return null;let n=qt.decodeBase64UrlSafe(t[2]),i=n.indexOf("|");if(i<0)return null;let s=n.slice(0,i);return s.length>0?s:null}async resolveClassRefToUid(e){if(Tk.test(e)||!this.classLabelToUid)return e;try{let t=await this.classLabelToUid(e);return t&&t.length>0?t:e}catch{return e}}applyPropertyDefaultStep(e,t,n){for(let{propertyName:i,value:s}of t){if(e[i]!==void 0)continue;let o=this.resolveSubstitutionMarker(s,n);if(o!=null){if(Array.isArray(o)){if(o.length===0)continue;e[i]=o;continue}if(i==="exo__Instance_class"&&typeof o=="string"){e[i]=[o];continue}e[i]=o}}}applyMissingScalarPrimitives(e,t,n,i,s,o,c){let l=[];e.exo__Asset_uid===void 0&&(e.exo__Asset_uid=this.uidGen.next(),l.push("exo__Asset_uid")),e.exo__Asset_createdAt===void 0&&(e.exo__Asset_createdAt=Ah.DateFormatter.toLocalTimestamp(this.clock.now()),l.push("exo__Asset_createdAt")),e.exo__Asset_updatedAt===void 0&&(e.exo__Asset_updatedAt=e.exo__Asset_createdAt);let u=typeof e.exo__Asset_label=="string"&&e.exo__Asset_label.trim().length===0;if(e.exo__Asset_label===void 0||u){let f=t?.label;if(f===void 0&&i?.labelTemplate)try{let p=this.substituteVariables(i.labelTemplate,s??"",t,o??void 0,c);p.trim().length>0&&(f=p)}catch(p){Is.LoggingService.error(`[GroundingExecutor] labelTemplate substitution failed: ${p instanceof Error?p.message:String(p)}. Falling back to "Untitled".`)}if(i?.omitLabel===!0&&(f===void 0||f.trim().length===0))delete e.exo__Asset_label;else{let p=f!==void 0&&f.trim().length>0?f:"Untitled";e.exo__Asset_label=p;let h=Object.keys(e).some(g=>(0,YA.canonicalYamlKey)(g)==="aliases");p!=="Untitled"&&!h&&(e.aliases=[p]),p==="Untitled"&&l.push("exo__Asset_label")}}e.exo__Instance_class===void 0&&n&&(e.exo__Instance_class=[`"[[${n}]]"`],l.push("exo__Instance_class")),l.length>0&&Is.LoggingService.error(`[GroundingExecutor] Universal Default Template did not cover essential scalar primitives: ${l.join(", ")}. Filled from legacy TS fallback. Vault may be in an unhealthy state \u2014 verify UniversalDefaultTemplate singleton is present and complete.`)}async applyMissingBacklinkTopUp(e,t,n,i,s){if(!n||t.linkBackProperty||e.exo__Asset_prototype!==void 0||e.ems__Effort_parent!==void 0)return;let o=qt.extractBacklinkTarget(n,i);if(qt.propertiesReferenceTarget(e,o))return;let c=s??await this.readTargetFrontmatter(n,i);if(!await this.targetIsPrototype(c))return;let l=c?.exo__Asset_uid,u=typeof l=="string"?l.trim().replace(/^['"]+|['"]+$/g,"").trim():"",f=u.length>0?u:o;e.exo__Asset_prototype=`"[[${f}]]"`,Is.LoggingService.error("[GroundingExecutor] No backlink rule fired (Universal IRs absent or no class match). Falling back to legacy exo__Asset_prototype default \u2014 the target is a prototype, so the link is valid.")}async readTargetFrontmatter(e,t){let n=t;if(!n){let i=qt.resolveTargetPath(e,"");if(!i)return null;n=/\.md$/i.test(i)?i:`${i}.md`}try{let i=await this.fileReader.readFile(n);return this.frontmatterService.parseObject(i)??null}catch{return null}}async targetIsPrototype(e){if(!e)return!1;let t=this.resolveClassRefsFromFrontmatter(e),n=new Set;for(let i of t)if(await this.classRefReachesPrototype(i,0,n))return!0;return!1}async classRefReachesPrototype(e,t,n){if(t>qt.MAX_PROTOTYPE_CLASS_WALK_DEPTH)return!1;let i=e.trim();if(!i||n.has(i))return!1;n.add(i);let s=i.split("|"),o=s[0].trim();if((s[1]??s[0]).trim()===qt.PROTOTYPE_CLASS_LABEL)return!0;if(!this.refToFrontmatter||!o)return!1;let l;try{l=await this.refToFrontmatter(o)}catch{return!1}if(!l)return!1;if(String(l.exo__Asset_label??"").trim()===qt.PROTOTYPE_CLASS_LABEL)return!0;let u=l.exo__Class_superClass,f=Array.isArray(u)?u:u==null?[]:[u];for(let d of f){let p=this.extractWikilinkInner(String(d));if(p&&await this.classRefReachesPrototype(p,t+1,n))return!0}return!1}static propertiesReferenceTarget(e,t){if(!t)return!1;let n=`[[${t}]]`,i=a(s=>typeof s=="string"&&s.includes(n),"refs");for(let s of Object.values(e))if(i(s)||Array.isArray(s)&&s.some(i))return!0;return!1}resolveSubstitutionMarker(e,t){let n=e.match(Ak);if(n){let c=n[1],l=n[2],u=qt.decodeBase64UrlSafe(l),f=(0,XA.getResolver)(c);return f?f(t,u):(Is.LoggingService.warn(`[GroundingExecutor] Parameterised marker references unknown resolver '${c}' \u2014 value left as marker.`),e)}let i=e.match(lZ);if(!i)return e;let s=i[1];if(s==="target"){let c=t.targetIRI??"",l=t.targetFilePath??"";return`"[[${qt.extractBacklinkTarget(c,l)}]]"`}if(s==="targetFolder"){let c=t.targetFilePath??"";if(!c)return"";let l=c.replace(/^\/+/,""),u=l.lastIndexOf("/");return u>=0?l.slice(0,u):""}let o=(0,XA.getResolver)(s);return o?o(t):(Is.LoggingService.warn(`[GroundingExecutor] Marker references unknown resolver '${s}' \u2014 value left as marker.`),e)}static decodeBase64UrlSafe(e){return(0,tZ.base64ToUtf8)(e.replace(/-/g,"+").replace(/_/g,"/"))}async applyInheritanceRuleStep(e,t,n){let i=this.extractTargetClassNames(n),s=[];for(let o of t)!await this.inheritanceConditionMatches(o.targetClassCondition,o.targetClassConditionUid,i)||await this.inheritanceExclusionMatches(o.targetClassExclusion,o.targetClassExclusionUids,i)||s.push(o);s.sort((o,c)=>c.priority-o.priority);for(let o of s){if(e[o.targetPropertyName]!==void 0)continue;let c=n[o.sourcePropertyName];c!=null&&(e[o.targetPropertyName]=this.formatInheritedValue(c))}}async inheritanceConditionMatches(e,t,n){return!e&&!t?!0:this.classRefMatchesAny(e,t,n)}async inheritanceExclusionMatches(e,t,n){for(let i of t??[])if(i&&n.includes(i))return!0;for(let i of e)if(await this.classRefMatchesAny(i,void 0,n))return!0;return!1}async classRefMatchesAny(e,t,n){if(t&&n.includes(t)||e&&n.includes(e))return!0;if(e&&this.classLabelToUid)try{let i=await this.classLabelToUid(e);if(i&&i.length>0&&n.includes(i))return!0}catch{}return!1}extractTargetClassNames(e){let t=e.exo__Instance_class;if(t==null)return[];let n=Array.isArray(t)?t:[t],i=[];for(let s of n){let o=this.extractWikilinkInner(String(s));o&&i.push(o)}return i}extractWikilinkInner(e){let t=e.match(/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/);return t?t[1].trim():e.replace(/^["']|["']$/g,"").trim()}formatInheritedValue(e){return Array.isArray(e)?e.map(t=>this.formatInheritedScalar(String(t))):this.formatInheritedScalar(String(e))}formatInheritedScalar(e){return/^"?\[\[.+\]\]"?$/.test(e)?this.reformatWikilink(e):Tk.test(e)?`"[[${e}]]"`:e}reformatWikilink(e){return e.startsWith('"[[')&&e.endsWith(']]"')?e:e.startsWith("[[")&&e.endsWith("]]")?`"${e}"`:e}async executeStep(e,t,n,i,s){return e.type===jn.GroundingType.COMPOSITE?this.executeComposite(e,t,n,i,s):this.execute(e,t,n,i)}async resolveCreatedPaths(e){let t=[],n;for(let i of e){if(await this.fileReader.fileExists(i)){t.push(i);continue}let s=i.slice(i.lastIndexOf("/")+1);if(s.length===0){t.push(i);continue}try{n??(n=await this.fileReader.getMarkdownFiles())}catch{t.push(i);continue}let o=n.filter(c=>c.slice(c.lastIndexOf("/")+1)===s);t.push(o.length===1?o[0]:i)}return t}async rollback(e,t,n,i=[]){if(e!==void 0)try{await this.fileWriter.updateFile(t,e)}catch(s){Is.LoggingService.error(`[GroundingExecutor] Rollback failed for ${t}`,s instanceof Error?s:new Error(String(s)))}for(let s of i)try{await this.fileWriter.deleteFile(s)}catch(o){Is.LoggingService.error(`[GroundingExecutor] Rollback: failed to delete orphaned created asset ${s}`,o instanceof Error?o:new Error(String(o)))}}substituteVariables(e,t,n,i,s){let o=this.clock.now(),c=o.toISOString(),l=Ah.DateFormatter.toLocalTimestamp(o),u=this.resolveInstanceDate(n,o),f=`${u}T00:00:00`,d=`${l.slice(0,10)}-${l.slice(11,13)}-${l.slice(14,16)}`,p=e.replace(/\$target\.([A-Za-z_][\w]*)/g,(h,g)=>{if(!i)throw new Error(`$target.${g} substitution requires target frontmatter context; none was supplied (asset IRI: ${t})`);let m=i[g];if(m==null)throw new Error(`$target.${g} is undefined on asset ${t}`);if(Array.isArray(m))throw new Error(`$target.${g} resolved to an array on asset ${t}; only scalar properties are supported for substitution`);return(0,Fi.decodeYamlQuotedScalar)(String(m))});if(/\$targetFolder\b/.test(p)){if(!s)throw new Error("$targetFolder substitution requires targetFilePath context; none was supplied (asset IRI: "+t+")");let h=s.replace(/^\/+/,""),g=h.lastIndexOf("/"),m=g>=0?h.slice(0,g):"";p=p.replace(/\$targetFolder\b/g,m)}if(p=p.replace(/\$target/g,t).replace(/\$nowCompact\b/g,d).replace(/\$nowLocal/g,l).replace(/\$now/g,c).replace(/\$todayStart\b/g,f).replace(/\$today/g,u),n){let h=n;p=p.replace(/\$input\.([A-Za-z_]\w*)|\$(?:input|value)\b/g,(g,m)=>{let b=m!==void 0?h[m]:h.value;return b==null?g:String(b)})}return p}async executePropertyAppend(e,t,n,i){if(!e.targetProperty)return{success:!1,error:"property_append requires targetProperty"};if(e.appendExpression===void 0)return{success:!1,error:"property_append requires appendExpression"};let s=await this.fileReader.readFile(n),o=this.frontmatterService.parseObject(s)??{},c=this.substituteVariables(e.appendExpression,t,i,o),l=o[e.targetProperty],u=Array.isArray(l)?l:l!==void 0?[String(l)]:[],f=(0,Fi.isCompleteDoubleQuotedScalar)(c)?(0,Fi.decodeYamlQuotedScalar)(c):c,d=new Set(u.map(Fi.decodeYamlQuotedScalar)),p;d.has(f)?p=u:p=[...u,(0,Fi.quoteYamlString)(f)];let h=this.stampUpdatedAt(s,this.frontmatterService.updateProperty(s,e.targetProperty,p),e.targetProperty);return await this.fileWriter.updateFile(n,h),{success:!0}}async executePropertyReplace(e,t,n,i){if(!e.targetProperty)return{success:!1,error:"property_replace requires targetProperty"};if(e.replaceFromExpression===void 0)return{success:!1,error:"property_replace requires replaceFromExpression"};if(e.replaceToExpression===void 0)return{success:!1,error:"property_replace requires replaceToExpression"};let s=await this.fileReader.readFile(n),o=this.frontmatterService.parseObject(s)??{},c=o[e.targetProperty];if(!Array.isArray(c))return{success:!1,error:`property_replace: <${e.targetProperty}> is not a list on this asset (replacing one element of a scalar is identical to property_set \u2014 use that instead)`};let l=c,u=a(b=>{let _=this.substituteVariables(b,t,i,o);return(0,Fi.isCompleteDoubleQuotedScalar)(_)?(0,Fi.decodeYamlQuotedScalar)(_):_},"plainOf"),f=u(e.replaceFromExpression),d=u(e.replaceToExpression),p=l.findIndex(b=>(0,Fi.decodeYamlQuotedScalar)(b)===f);if(p===-1)return{success:!1,error:`property_replace: "${f}" is not a value of <${e.targetProperty}> on this asset \u2014 refusing rather than appending`};let g=l.findIndex((b,_)=>_!==p&&(0,Fi.decodeYamlQuotedScalar)(b)===d)===-1?l.map((b,_)=>_===p?(0,Fi.quoteYamlString)(d):b):l.filter((b,_)=>_!==p),m=this.stampUpdatedAt(s,this.frontmatterService.updateProperty(s,e.targetProperty,g),e.targetProperty);return await this.fileWriter.updateFile(n,m),{success:!0}}async executePropertyIncrement(e,t){if(!e.targetProperty)return{success:!1,error:"property_increment requires targetProperty"};let n=e.incrementBy??1;if(!Number.isFinite(n)||!Number.isInteger(n))return{success:!1,error:`property_increment: incrementBy must be an integer (got ${String(e.incrementBy)})`};let i=await this.fileReader.readFile(t),o=(this.frontmatterService.parseObject(i)??{})[e.targetProperty],c;if(o==null||o==="")c=0;else{if(Array.isArray(o))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" is an array, expected integer`};{let f=String(o).replace(/^["'](.*)["']$/,"$1").trim();if(!/^-?\d+$/.test(f))return{success:!1,error:`property_increment: targetProperty "${e.targetProperty}" current value "${String(o)}" is not a valid integer`};c=Number.parseInt(f,10)}}let l=c+n,u=this.stampUpdatedAt(i,this.frontmatterService.updateProperty(i,e.targetProperty,l),e.targetProperty);return await this.fileWriter.updateFile(t,u),{success:!0}}async executePropertyShift(e,t){if(!e.targetProperty)return{success:!1,error:"property_shift requires targetProperty"};if(!e.shiftDelta)return{success:!1,error:"property_shift requires shiftDelta (ISO-8601 duration literal)"};let n=await this.fileReader.readFile(t),s=(this.frontmatterService.parseObject(n)??{})[e.targetProperty];if(s==null||s==="")return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is not set on target asset`};if(Array.isArray(s))return{success:!1,error:`property_shift: targetProperty "${e.targetProperty}" is an array, expected single datetime`};let o=String(s).replace(/^["'](.*)["']$/,"$1").trim(),c=new Date(o);if(Number.isNaN(c.getTime()))return{success:!1,error:`property_shift: current value "${o}" is not a valid datetime`};let l;try{l=qt.applyIsoDuration(c,e.shiftDelta)}catch(d){return{success:!1,error:`property_shift: invalid shiftDelta "${e.shiftDelta}": ${d instanceof Error?d.message:String(d)}`}}let u=Ah.DateFormatter.toLocalTimestamp(l),f=this.stampUpdatedAt(n,this.frontmatterService.updateProperty(n,e.targetProperty,u),e.targetProperty);return await this.fileWriter.updateFile(t,f),{success:!0}}async executeWorkflowTransition(e,t,n,i){if(!this.workflowResolver)return{success:!1,error:"workflow_transition requires WorkflowResolver injection (options.workflowResolver). Wire the plugin/CLI before using this grounding type."};let s=await this.fileReader.readFile(n),o=this.frontmatterService.parseObject(s)??{},c=this.resolveClassRefsFromFrontmatter(o);if(c.length===0)return{success:!1,notApplicable:!0,error:"workflow_transition: target asset has no exo__Instance_class \u2014 status transitions are not available for it."};let l;try{l=new rZ.IRI(t)}catch(I){return{success:!1,error:`workflow_transition: invalid targetIRI "${t}" \u2014 ${I instanceof Error?I.message:String(I)}`}}let u=await this.workflowResolver.resolveForAssetOrNull(l,c);if(!u)return{success:!1,notApplicable:!0,error:"workflow_transition: this asset's class has no status workflow \u2014 status transitions are not available for it."};let f=this.resolveStatusFromFrontmatter(o);if(!f)return{success:!1,error:"workflow_transition: target asset has no parseable ems__Effort_status value (need wikilink to an ems__EffortStatus* asset)."};let d=e.direction??"forward",p=d==="rollback",h=u.transitions.find(I=>I.from===f&&I.isRollback===p);if(!h)return{success:!1,error:`workflow_transition: no ${d} transition from "${f}" defined in workflow "${u.name}" (target class: ${u.targetClass}).`};let g=Br.STATUS_UID_BY_ENUM[h.to];if(!g)return{success:!1,error:`workflow_transition: no UID mapping for destination status "${h.to}" (transition target unreachable).`};let m={id:`${e.id}.statusMutation`,label:`workflow_transition: ${h.from} \u2192 ${h.to}`,type:jn.GroundingType.PROPERTY_SET,targetProperty:"ems__Effort_status",targetValueRef:g},b=await this.executePropertySet(m,t,n,i);if(!b.success)return{success:!1,error:`workflow_transition: status mutation failed \u2014 ${b.error}`};let _=h.postActions??[],S=this.groundingLoader;if(_.length>0&&S===void 0)return{success:!1,error:"workflow_transition: transition has postActions but no GroundingLoader injected (options.groundingLoader). Wire commandResolver.loadGroundingByUid in plugin/CLI."};for(let I of _){if(S===void 0)break;let E=await S(I);if(!E)return{success:!1,error:`workflow_transition: postAction grounding UID "${I}" could not be loaded (asset missing or invalid Grounding shape).`};let w=await this.execute(E,t,n,i);if(!w.success)return{success:!1,error:`workflow_transition: postAction "${E.label}" (UID ${I}) failed \u2014 ${w.error}`}}return{success:!0}}resolveClassRefsFromFrontmatter(e){let t=e.exo__Instance_class;if(t==null)return[];let n=Array.isArray(t)?t:[t],i=[];for(let s of n){if(typeof s!="string")continue;let o=s.replace(/^\s*"?\[\[/,"").replace(/\]\]"?\s*$/,"").trim();o.length>0&&i.push(o)}return i}resolveStatusFromFrontmatter(e){return(0,Rk.normalizeEffortStatus)(e.ems__Effort_status)}static applyIsoDuration(e,t){let n=t.trim();if(/^-?P(\d+Y)(\d+M)?$|^-?P\d+M$/.test(n)){let o=vk.DateTimeParsing.parseYearMonthDuration(n),c=new Date(e.getTime());return c.setMonth(c.getMonth()+o),c}let s=vk.DateTimeParsing.parseDayTimeDuration(n);return new Date(e.getTime()+s)}static extractBacklinkTarget(e,t){let n=qt.resolveTargetPath(e,t),i=n.split("/").pop()??n;return qt.UUID_BASENAME_RE.test(i)?i:n}static resolveTargetPath(e,t){if(t)return t.replace(/\.md$/i,"").replace(/^\/+/,"");if(e){let n=e.match(/^obsidian:\/\/vault\/(.+?)(?:\.md)?(?:\?|#|$)/i);if(n&&n[1])try{return decodeURIComponent(n[1])}catch{return n[1]}}return e}};Br.GroundingExecutor=Uf;Uf.UUID_BASENAME_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;Uf.PROTOTYPE_CLASS_LABEL="exo__Prototype";Uf.MAX_PROTOTYPE_CLASS_WALK_DEPTH=6;Br.GroundingExecutor=Uf=qt=YJ([(0,QJ.injectable)(),XJ("design:paramtypes",[Object,Object,Tb,Function,Object])],Uf)});var Ok=T(JA=>{"use strict";Object.defineProperty(JA,"__esModule",{value:!0});JA.createVaultFrontmatterClassLabelResolver=fZ;function fZ(r){return async e=>{if(!e)return null;let t=await r.findFilesByMetadata({exo__Asset_label:e});if(t.length>0){let s=(await r.getFileMetadata(t[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}let n=await r.findFilesByMetadata({aliases:e});if(n.length>0){let s=(await r.getFileMetadata(n[0])).exo__Asset_uid;if(typeof s=="string"&&s.length>0)return s}return null}}a(fZ,"createVaultFrontmatterClassLabelResolver")});var Pk=T(ZA=>{"use strict";Object.defineProperty(ZA,"__esModule",{value:!0});ZA.createVaultFrontmatterRefToFolderResolver=dZ;function dZ(r){return async e=>{if(!e)return null;let t=await r.findFilesByMetadata({exo__Asset_uid:e});return t.length===0?null:pZ(t[0])}}a(dZ,"createVaultFrontmatterRefToFolderResolver");function pZ(r){let e=r.replace(/^\/+/,""),t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}a(pZ,"parentFolderOf")});var Fk=T(e2=>{"use strict";Object.defineProperty(e2,"__esModule",{value:!0});e2.createVaultFrontmatterRefToFrontmatterResolver=hZ;function hZ(r){return async e=>{if(!e)return null;let t=await r.findFilesByMetadata({exo__Asset_uid:e});return t.length===0?null:r.getFileMetadata(t[0])}}a(hZ,"createVaultFrontmatterRefToFrontmatterResolver")});var Lk=T(ma=>{"use strict";var mZ=ma&&ma.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},gZ=ma&&ma.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Bf;Object.defineProperty(ma,"__esModule",{value:!0});ma.NamedQueryRunner=void 0;var yZ=ct(),bZ=Le(),_Z=Ye(),Dk=rb(),SZ=oa(),t2=Bf=class{static{a(this,"NamedQueryRunner")}constructor(e,t){this.queryBodyResolver=e,this.tripleStore=t}async run(e,t={}){if(!e)return null;let n=await this.queryBodyResolver.resolveSparql(e);if(!n)return null;let i=this.substitute(n,t);return(0,Dk.evaluateWithExoEval)(i,{store:this.tripleStore})}async runScalar(e,t={},n){if(!e)throw new Error("NamedQueryRunner.runScalar: empty queryUid");let i=await this.queryBodyResolver.resolveSparql(e);if(!i)throw new Error(`NamedQueryRunner: query__NamedQuery '${e}' has no resolvable SPARQL body (asset missing or no \`\`\`sparql block).`);let s=this.substitute(i,t),o=await(0,Dk.evaluateWithExoEval)(s,{store:this.tripleStore});if(o.kind==="ask")return{value:o.result?"true":"false",kind:"literal"};if(o.kind==="construct")return null;let c=o.rows[0];if(!c)return null;let l=c.variables(),u=n??l[0];if(!u)return null;let f=c.get(u);return f===void 0?null:f instanceof bZ.IRI?{value:(0,SZ.iriToObsidianName)(f.value)??f.value,kind:"iri",iri:f.value}:f instanceof _Z.Literal?{value:f.value,kind:"literal"}:null}substitute(e,t){let n=e;t.currentAsset&&(n=n.replace(/\$currentAsset\b/g,Bf.formatIri(t.currentAsset))),t.currentClass&&(n=n.replace(/\$currentClass\b/g,Bf.formatIri(t.currentClass)));let i=t.params;if(i){let s=Object.keys(i).sort((o,c)=>c.length-o.length);for(let o of s){let c=i[o],l=c.kind==="iri"?Bf.formatIri(c.value):`"${Bf.escapeLiteral(c.value)}"`,u=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(`\\$${u}\\b`,"g"),l)}}return n}static formatIri(e){if(/[\s<>"{}|\\^`]/.test(e))throw new Error(`NamedQueryRunner: refusing to inject malformed IRI "${e}" \u2014 contains a character illegal in a SPARQL IRIREF (would break out of <...>). Pass a percent-encoded IRI.`);return`<${e}>`}static escapeLiteral(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}};ma.NamedQueryRunner=t2;ma.NamedQueryRunner=t2=Bf=mZ([(0,yZ.injectable)(),gZ("design:paramtypes",[Object,Object])],t2)});var Nk=T(Ab=>{"use strict";Object.defineProperty(Ab,"__esModule",{value:!0});Ab.extractSparqlBlock=wZ;Ab.stripFrontmatter=EZ;function wZ(r){let e=r.match(/```sparql\s*\n([\s\S]*?)\n```/);if(!e)return null;let t=e[1].trim();return t.length>0?t:null}a(wZ,"extractSparqlBlock");function EZ(r){if(!r.startsWith("---"))return r;let e=r.indexOf(`
|
|
141
141
|
---`,3);return e<0?r:r.slice(e+4)}a(EZ,"stripFrontmatter")});var Mk=T(ga=>{"use strict";var vZ=ga&&ga.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},TZ=ga&&ga.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Ih;Object.defineProperty(ga,"__esModule",{value:!0});ga.CommandExecutionFlow=void 0;var AZ=ct(),kk=cc(),IZ=Le(),RZ=Ye(),CZ=Wt(),xZ=vs(),Ib=Ih=class{static{a(this,"CommandExecutionFlow")}constructor(e,t,n,i,s,o,c){this.groundingExecutor=e,this.notificationService=t,this.logger=n,this.prompts=i,this.tripleStore=s,this.fileOpener=o,this.requiredPropertyResolver=c}async run(e,t){let{command:n}=e;if(n.confirmMessage&&!await this.prompts.confirm(n.confirmMessage))return;let i=t.injectedUserInput,s=Ih.extractInputSchema(e);if(s!==null&&s.length>0){let l=await this.applyLabelDatePrefill(s,n.grounding,t.targetIRI);l=await this.applyRequiredPropertyFields(l,n.grounding,t);let u=await this.prompts.promptInputSchema(l);if(u===null)return;i={...t.injectedUserInput??{},...u}}let o=await this.groundingExecutor.execute(n.grounding,t.targetIRI??"",t.filePath??"",i),c=t.filePath??"<no-file>";if(o.success){if(n.successMessage&&this.notificationService.success(n.successMessage),await new Promise(l=>setTimeout(l,100)),t.onComplete&&await t.onComplete(),o.openPath&&this.fileOpener)try{await this.fileOpener.open(o.openPath,{sameTab:n.openInSameTab})}catch(l){this.logger.info(`[CommandExecutionFlow] Failed to open created file "${o.openPath}": ${l instanceof Error?l.message:String(l)}`)}this.logger.info(`[CommandExecutionFlow] Executed "${n.name}" on ${c}`)}else o.notApplicable?(this.notificationService.info(o.error??"This command is not available for this asset."),this.logger.info(`[CommandExecutionFlow] Not applicable "${n.name}": ${o.error}`)):(this.notificationService.error(`Command failed: ${o.error??"unknown error"}`),this.logger.info(`[CommandExecutionFlow] Failed "${n.name}": ${o.error}`))}static extractInputSchema(e){let n=e.command.grounding.inputSchema;return!n||!Array.isArray(n)?null:n}async applyLabelDatePrefill(e,t,n){if(t.type!==kk.GroundingType.CREATE_INSTANCE||!t.prefillLabelWithDate||!n||!this.tripleStore)return e;let i=await this.resolveAssetLabel(n);if(!i)return e;let s=xZ.DateFormatter.toDateString(new Date),o=`${i} ${s}`;return e.map(c=>{if(typeof c!="object"||c===null)return c;let l=c;if(l.name!=="label")return c;let u=l.defaultValue;return typeof u=="string"&&u.length>0?c:{...l,defaultValue:o}})}async applyRequiredPropertyFields(e,t,n){if(t.type!==kk.GroundingType.CREATE_INSTANCE||t.targetClass||!this.requiredPropertyResolver||!n.filePath)return e;let i=Ih.basenameUid(n.filePath);if(!i)return e;let s;try{s=await this.requiredPropertyResolver(i)}catch(l){return this.logger.info(`[CommandExecutionFlow] required-property resolution failed for "${i}": ${l instanceof Error?l.message:String(l)}`),e}if(s.length===0)return e;let o=new Set(Ih.ALWAYS_COVERED);for(let l of e)l&&typeof l=="object"&&typeof l.name=="string"&&o.add(l.name);let c=s.filter(l=>!o.has(l.propertyKey)).map(l=>{let u={name:l.propertyKey,type:l.fieldType,label:l.label,required:!0};return l.targetClassUid&&(u.targetClassUid=l.targetClassUid),l.fieldType==="boolean"&&(u.defaultValue="false"),u});return c.length===0?e:[...e,...c]}static basenameUid(e){let t=e.replace(/^\/+/,"").split("/").pop()?.replace(/\.md$/i,"");return t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)?t.toLowerCase():null}async resolveAssetLabel(e){if(!this.tripleStore)return;let t=new IZ.IRI(e),n=await this.tripleStore.match(t,CZ.Namespace.EXO.term("Asset_label"),void 0);if(n.length===0)return;let i=n[0].object;if(i instanceof RZ.Literal)return i.value.length>0?i.value:void 0}};ga.CommandExecutionFlow=Ib;Ib.ALWAYS_COVERED=["exo__Asset_uid","exo__Asset_createdAt","exo__Asset_updatedAt","exo__Asset_label","exo__Asset_createdBy","exo__Instance_class","exo__Asset_isDefinedBy"];ga.CommandExecutionFlow=Ib=Ih=vZ([(0,AZ.injectable)(),TZ("design:paramtypes",[Function,Object,Object,Object,Object,Object,Function])],Ib)});var n2=T(r2=>{"use strict";Object.defineProperty(r2,"__esModule",{value:!0});r2.parseMinCount=jk;var OZ=Ye();function jk(r){if(Array.isArray(r)){let e;for(let t of r){let n=jk(t);n!==void 0&&(e===void 0||n>e)&&(e=n)}return e}if(r instanceof OZ.Literal){let e=parseInt(r.value,10);return Number.isNaN(e)?void 0:e}if(typeof r=="string"){let e=parseInt(r.trim().replace(/^["']|["']$/g,""),10);return Number.isNaN(e)?void 0:e}}a(jk,"parseMinCount")});var Gk=T(Cb=>{"use strict";Object.defineProperty(Cb,"__esModule",{value:!0});Cb.createTripleStoreRequiredPropertyResolver=NZ;Cb.createTripleStoreClassPropertyResolver=kZ;var si=Le(),Vf=Ye(),Gf=Wt(),i2=oa(),Uk=n2(),PZ=Yy(),FZ=/\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.md$/i,DZ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Rb(r){let e=FZ.exec(r);return e?e[1].toLowerCase():DZ.test(r.trim())?r.trim().toLowerCase():null}a(Rb,"uidFrom");function LZ(r){let e=(0,PZ.xsdDatatypeLocalName)(r);return e===null?null:e.toLowerCase()}a(LZ,"xsdLocalName");function Bk(r){for(let e of r){let t=e.value,n=LZ(t);if(n!==null)return n==="date"||n==="datetime"?{fieldType:"date"}:n==="boolean"?{fieldType:"boolean"}:["integer","int","long","short","decimal","float","double","nonnegativeinteger","positiveinteger"].includes(n)?{fieldType:"number"}:{fieldType:"text"};if(e.iri){let i=Rb(t)??(0,i2.iriToObsidianName)(t);return i?{fieldType:"assetRef",targetClassUid:i}:{fieldType:"assetRef"}}}return{fieldType:"text"}}a(Bk,"fieldTypeFromRange");function Rh(r){let e=Rb(r);if(e)return e;let t=(0,i2.iriToObsidianName)(r);return t?t.trim().toLowerCase():null}a(Rh,"classKeyOf");function $k(r){let t=(r instanceof Vf.Literal?r.value:r instanceof si.IRI?(0,i2.iriToObsidianName)(r.value)??"":"").trim().toLowerCase();return t.length>0?t:null}a($k,"labelKeyOf");async function Vk(r,e){let t=Gf.Namespace.EXO,n=Gf.Namespace.RDFS,i=Rh(e)??e.trim().toLowerCase();if(!i)return new Set;let s=new Map,o=a((h,g)=>{let m=s.get(h);m||(m=new Set,s.set(h,m)),m.add(g)},"rememberIRI"),c=new Map,l=a(async h=>{let g=c.get(h);if(g)return g;let m=new Set;for(let _ of s.get(h)??[])if(Rb(_))for(let S of[t.term("Asset_label"),n.term("label")])for(let I of await r.match(new si.IRI(_),S,void 0)){let E=$k(I.object);E&&E!==h&&m.add(E)}else for(let S of await r.match(void 0,t.term("Asset_label"),new si.IRI(_))){let I=S.subject instanceof si.IRI?Rb(S.subject.value):null;I&&I!==h&&m.add(I)}if(h===i){for(let _ of await r.match(void 0,t.term("Asset_uid"),new Vf.Literal(i)))if(_.subject instanceof si.IRI)for(let S of[t.term("Asset_label"),n.term("label")])for(let I of await r.match(_.subject,S,void 0)){let E=$k(I.object);E&&E!==h&&m.add(E)}}let b=[...m];return c.set(h,b),b},"twinsOf"),u=await r.match(void 0,t.term("Class_superClass"),void 0),f=new Map;for(let h of u){let g=h.subject instanceof si.IRI?Rh(h.subject.value):null,m=h.object instanceof si.IRI?Rh(h.object.value):null;if(!g||!m)continue;h.subject instanceof si.IRI&&o(g,h.subject.value),h.object instanceof si.IRI&&o(m,h.object.value);let b=f.get(g);b||(b=new Set,f.set(g,b)),b.add(m)}let d=new Set([i]),p=[i];for(;p.length>0;){let h=p.shift();if(h===void 0)break;let g=[...f.get(h)??[],...await l(h)];for(let m of g)d.has(m)||(d.add(m),p.push(m))}return d}a(Vk,"resolveClassKeyClosure");function NZ(r){let e=Gf.Namespace.EXO,t=Gf.Namespace.RDFS;return async n=>{let i=await Vk(r,n);if(i.size===0)return[];let s=await r.match(void 0,e.term("Property_minCount"),void 0),o=[],c=new Set;for(let l of s){let u=(0,Uk.parseMinCount)(l.object);if(u===void 0||u<=0)continue;let f=l.subject;if(!(f instanceof si.IRI)||!(await r.match(f,e.term("Property_domain"),void 0)).map(S=>S.object instanceof si.IRI?Rh(S.object.value):null).filter(S=>S!==null).some(S=>i.has(S)))continue;let h=null;for(let S of[e.term("Asset_label"),t.term("label")]){let I=await r.match(f,S,void 0);for(let E of I)if(E.object instanceof Vf.Literal&&E.object.value.trim().length>0){h=E.object.value.trim();break}if(h)break}if(!h||c.has(h))continue;c.add(h);let m=(await r.match(f,e.term("Property_range"),void 0)).map(S=>S.object instanceof si.IRI?{iri:!0,value:S.object.value}:S.object instanceof Vf.Literal?{iri:!1,value:S.object.value}:null).filter(S=>S!==null),{fieldType:b,targetClassUid:_}=Bk(m);o.push({propertyKey:h,label:h,fieldType:b,targetClassUid:_})}return o.sort((l,u)=>l.propertyKey.localeCompare(u.propertyKey)),o}}a(NZ,"createTripleStoreRequiredPropertyResolver");function kZ(r){let e=Gf.Namespace.EXO,t=Gf.Namespace.RDFS;return async n=>{let i=await Vk(r,n);if(i.size===0)return[];let s=await r.match(void 0,e.term("Property_domain"),void 0),o=[],c=new Set;for(let l of s){let u=l.object instanceof si.IRI?Rh(l.object.value):null;if(!u||!i.has(u))continue;let f=l.subject;if(!(f instanceof si.IRI))continue;let d=null;for(let S of[e.term("Asset_label"),t.term("label")]){let I=await r.match(f,S,void 0);for(let E of I)if(E.object instanceof Vf.Literal&&E.object.value.trim().length>0){d=E.object.value.trim();break}if(d)break}if(!d||c.has(d))continue;c.add(d);let p=(0,Uk.parseMinCount)((await r.match(f,e.term("Property_minCount"),void 0)).map(S=>S.object)),h=p!==void 0&&p>0,m=(await r.match(f,e.term("Property_range"),void 0)).map(S=>S.object instanceof si.IRI?{iri:!0,value:S.object.value}:S.object instanceof Vf.Literal?{iri:!1,value:S.object.value}:null).filter(S=>S!==null),{fieldType:b,targetClassUid:_}=Bk(m);o.push({propertyKey:d,label:d,fieldType:b,targetClassUid:_,required:h})}return o.sort((l,u)=>l.propertyKey.localeCompare(u.propertyKey)),o}}a(kZ,"createTripleStoreClassPropertyResolver")});var zk=T(s2=>{"use strict";Object.defineProperty(s2,"__esModule",{value:!0});s2.createTripleStoreDeclaredRanges=jZ;var xb=Le(),qk=Ye(),Wk=Wt(),MZ=oa();function jZ(r){let e=Wk.Namespace.EXO,t=Wk.Namespace.RDFS;return async()=>{let n=await r.match(void 0,e.term("Property_range"),void 0),i=await r.match(void 0,e.term("Asset_label"),void 0),s=await r.match(void 0,t.term("label"),void 0),o=new Map,c=new Map;for(let f of[...i,...s]){if(!(f.subject instanceof xb.IRI))continue;let d=f.subject.value;if(f.object instanceof qk.Literal){let p=f.object.value.trim();p.length>0&&!o.has(d)&&o.set(d,p)}else f.object instanceof xb.IRI&&!c.has(d)&&c.set(d,f.object.value)}let l=new Map,u=new Map;for(let f of n){if(!(f.subject instanceof xb.IRI))continue;let d=f.object instanceof xb.IRI||f.object instanceof qk.Literal?f.object.value:null;if(d===null)continue;let p=f.subject.value,h=u.get(p);h?h.push(d):u.set(p,[d])}for(let[f,d]of u){let p=o.get(f),h=c.get(f),g=p??(h===void 0?null:(0,MZ.iriToObsidianName)(h));g==null||g.length===0||l.has(g)||l.set(g,d)}return l}}a(jZ,"createTripleStoreDeclaredRanges")});var Ch=T(ya=>{"use strict";var $Z=ya&&ya.__decorate||function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},UZ=ya&&ya.__metadata||function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)};Object.defineProperty(ya,"__esModule",{value:!0});ya.WorkflowEngine=void 0;var BZ=ct(),o2=class{static{a(this,"WorkflowEngine")}constructor(e){this.definition=e}getAvailableTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&!t.isRollback)}getRollbackTransitions(e){return this.definition.transitions.filter(t=>t.from===e&&t.isRollback)}getAllTransitions(e){return this.definition.transitions.filter(t=>t.from===e)}canTransition(e,t){return this.definition.transitions.some(n=>n.from===e&&n.to===t)}getPreviousStatus(e){return this.definition.transitions.find(n=>n.from===e&&n.isRollback)?.to??null}getNextStates(e){return this.getAvailableTransitions(e).map(t=>t.to)}isTerminalState(e){return this.definition.terminalStates.includes(e)}isInitialState(e){return this.definition.initialState===e}getTimestampsForStatus(e){return this.definition.states.find(n=>n.status===e)?.timestampOnEnter??[]}getTransition(e,t){return this.definition.transitions.find(n=>n.from===e&&n.to===t)}getOrderedStates(){return this.definition.states.map(e=>e.status)}getDefinition(){return this.definition}validate(){let e=[],t=new Set(this.definition.states.map(i=>i.status));this.definition.states.length===0&&e.push("Workflow must have at least one state"),t.has(this.definition.initialState)||e.push(`Initial state "${this.definition.initialState}" is not in the states list`);for(let i of this.definition.terminalStates)t.has(i)||e.push(`Terminal state "${i}" is not in the states list`);for(let i of this.definition.transitions)t.has(i.from)||e.push(`Transition "${i.label}" references unknown source state "${i.from}"`),t.has(i.to)||e.push(`Transition "${i.label}" references unknown target state "${i.to}"`);for(let i of this.definition.states){if(this.definition.terminalStates.includes(i.status))continue;this.definition.transitions.filter(o=>o.from===i.status&&!o.isRollback).length===0&&e.push(`State "${i.status}" has no outgoing forward transitions (dead end)`)}let n=new Set;for(let i of this.definition.transitions){let s=`${i.from}\u2192${i.to}`;n.has(s)&&e.push(`Duplicate transition: ${s}`),n.add(s)}return{valid:e.length===0,errors:e}}};ya.WorkflowEngine=o2;ya.WorkflowEngine=o2=$Z([(0,BZ.injectable)(),UZ("design:paramtypes",[Object])],o2)});var Hk=T(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.EFFORT_WORKFLOW_PROPERTY=_o.WorkflowTransitionProperty=_o.WorkflowStateProperty=_o.WorkflowProperty=void 0;_o.WorkflowProperty={TARGET_CLASS:"ems__Workflow_targetClass",INITIAL_STATE:"ems__Workflow_initialState",TERMINAL_STATES:"ems__Workflow_terminalStates",IS_DEFAULT:"ems__Workflow_isDefault"};_o.WorkflowStateProperty={WORKFLOW:"ems__WorkflowState_workflow",STATUS:"ems__WorkflowState_status",ORDER:"ems__WorkflowState_order",OPTIONAL:"ems__WorkflowState_optional",TIMESTAMP_ON_ENTER:"ems__WorkflowState_timestampOnEnter",BADGE_COLOR:"ems__WorkflowState_badgeColor"};_o.WorkflowTransitionProperty={WORKFLOW:"ems__WorkflowTransition_workflow",FROM:"ems__WorkflowTransition_from",TO:"ems__WorkflowTransition_to",LABEL:"ems__WorkflowTransition_label",ICON:"ems__WorkflowTransition_icon",IS_ROLLBACK:"ems__WorkflowTransition_isRollback"};_o.EFFORT_WORKFLOW_PROPERTY="ems__Effort_workflow"});var ba=T(Pb=>{"use strict";Object.defineProperty(Pb,"__esModule",{value:!0});Pb.MetadataHelpers=void 0;var Kk=pb(),VZ=Wl(),a2=Fl(),Ob=class r{static{a(this,"MetadataHelpers")}static findAllReferencingProperties(e,t){let n=[];for(let[i,s]of Object.entries(e))this.containsReference(s,t)&&n.push(i);return n}static findReferencingProperty(e,t){for(let[n,i]of Object.entries(e))if(this.containsReference(i,t))return n}static containsReference(e,t){if(!e)return!1;let n=t.replace(/\.md$/,"");if(typeof e=="string"){let i=/\[\[([^[\]]+)\]\]/g,s;for(;(s=i.exec(e))!==null;){let c=s[1].split("|")[0].trim();if(c===n||c.endsWith(`/${n}`))return!0}return!1}return Array.isArray(e)?e.some(i=>this.containsReference(i,t)):!1}static isAssetArchived(e){for(let t of r.ARCHIVED_FLAG_KEYS){let n=e?.[t];if(n!=null)return r.isTruthyFlag(n)}return!1}static isTruthyFlag(e){let t=Array.isArray(e)?e.length===1?e[0]:void 0:e;if(typeof t=="boolean")return t;if(typeof t=="number")return t!==0;if(typeof t=="string"){let n=t.toLowerCase().trim();return n==="true"||n==="yes"||n==="1"}return!1}static getPropertyValue(e,t){return t==="Name"||t==="title"?e.title:t==="created"?e.created:t==="modified"?e.modified:t==="path"?e.path:e.metadata?.[t]}static ensureQuoted(e){return!e||e==='""'?'""':e.startsWith('"')&&e.endsWith('"')?e:`"${e}"`}static buildFileContent(e,t,n){let i={},s={};for(let[f,d]of Object.entries(e)){let p=(0,VZ.canonicalYamlKey)(f);i[p]=d,s[p]=f}let o=(0,Kk.orderProperties)(i,(0,Kk.loadDefaultSpec)()),c=Object.entries(o).map(([f,d])=>{let p=a2.STRING_SCALAR_PROPERTIES.has(f),h=n?.(s[f]??f);if(Array.isArray(d)){let g=d.map(m=>` - ${(0,a2.serializeYamlScalar)(m,p,h)}`).join(`
|
|
142
142
|
`);return`${f}:
|
|
143
143
|
${g}`}return`${f}: ${(0,a2.serializeYamlScalar)(d,p,h)}`}).join(`
|
|
@@ -333,7 +333,7 @@ To resolve:
|
|
|
333
333
|
path = ${e}
|
|
334
334
|
url = ${t}
|
|
335
335
|
`;return{content:r+i+s,added:!0}}a(gse,"appendGitmodulesEntry");function yse(r,e){let t=r.split(/\r?\n/),n=[],i=!1,s=new RegExp(`^\\[submodule\\s+"${SR(e)}"\\]\\s*$`);for(let l of t){if(i){if(/^\[.+\]\s*$/.test(l)){i=!1,n.push(l);continue}continue}if(s.test(l)){i=!0;continue}n.push(l)}let o=[],c=!1;for(let l of n){let u=l.trim().length===0;u&&c||(o.push(l),c=u)}return o.join(`
|
|
336
|
-
`)}a(yse,"stripGitmodulesEntry")});var cd=T(wR=>{"use strict";Object.defineProperty(wR,"__esModule",{value:!0});wR.gitBlobSha=bse;async function bse(r,e){let t=new TextEncoder,n=typeof r=="string"?t.encode(r):r,i=t.encode(`blob ${n.byteLength}\0`),s=new Uint8Array(i.byteLength+n.byteLength);return s.set(i,0),s.set(n,i.byteLength),e(s)}a(bse,"gitBlobSha")});var zh=T(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});G_.extractAssetUid=Zj;G_.detectChanges=Sse;var _se=cd();function Zj(r){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(r);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(Zj,"extractAssetUid");async function Sse(r){let{localFiles:e,cachedEntries:t,watermark:n,actualBaseTreeSha:i,sha1:s}=r;if(n===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${n.lastSyncedSha} not resolvable on remote`};if(i!==n.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${n.rootTreeSha} != actual ${i} at ${n.lastSyncedSha}`};let o=[],c=new Map;for(let[E,w]of e){let R=await(0,_se.gitBlobSha)(w,s);c.set(E,R),o.push({path:E,blobSha:R,uid:typeof w=="string"?Zj(w):void 0})}if(t!==void 0)for(let[E,w]of t)c.set(E,w.blobSha),o.push({path:E,blobSha:w.blobSha,uid:w.uid});let l=[],u=[],f=[],d=[],p=new Map;for(let E of o){if(E.uid===void 0)continue;let w=p.get(E.uid)??[];w.push(E.path),p.set(E.uid,w)}let h=new Map;for(let E of n.files){if(E.uid===void 0)continue;let w=h.get(E.uid)??[];w.push(E.path),h.set(E.uid,w)}let g=new Set;for(let[E,w]of p)w.length>1&&g.add(E);for(let[E,w]of h)w.length>1&&g.add(E);for(let E of[...g].sort()){let w=p.get(E)??[],R=w.length>1?`on disk (${w.join(", ")})`:`in the sync base (${(h.get(E)??[]).join(", ")})`;d.push(`duplicate uid ${E} ${R} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let m=new Map,b=[];for(let E of n.files)E.uid!==void 0&&!g.has(E.uid)?m.set(E.uid,E):b.push(E);let _=[],S=new Set;for(let E of o){let w=E.uid!==void 0&&!g.has(E.uid)?m.get(E.uid):void 0;E.uid!==void 0&&w!==void 0?(S.add(E.uid),(w.blobSha!==E.blobSha||w.path!==E.path)&&u.push({path:E.path,uid:E.uid,blobSha:E.blobSha,...w.path!==E.path?{basePath:w.path}:{}})):_.push(E)}let I=new Map;for(let E of b)I.set(E.path,E);for(let[E,w]of m)S.has(E)||I.set(w.path,w);for(let E of _){let w=I.get(E.path);w!==void 0?(I.delete(E.path),w.blobSha!==E.blobSha&&u.push({path:E.path,uid:E.uid,blobSha:E.blobSha})):l.push({path:E.path,uid:E.uid,blobSha:E.blobSha})}for(let E of I.values())f.push({path:E.path,uid:E.uid,blobSha:E.blobSha});return{kind:"changes",added:l,modified:u,deleted:f,warnings:d,diskBlobShas:c,duplicateUids:g}}a(Sse,"detectChanges")});var r$=T(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});Hh.rewriteAssetUid=e$;Hh.findDuplicateUidGroups=t$;Hh.planDuplicateUidFix=Ese;var wse=zh();function e$(r,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(r);if(t===null)return r;let n=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return n===t[2]?r:r.slice(0,t.index)+t[1]+n+t[3]+r.slice(t.index+t[0].length)}a(e$,"rewriteAssetUid");function t$(r){let e=new Map;for(let t of r){let n=(0,wse.extractAssetUid)(t.content);if(n===void 0)continue;let i=e.get(n)??[];i.push(t.path),e.set(n,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>({uid:t,paths:n}))}a(t$,"findDuplicateUidGroups");function Ese(r,e){let t=new Map(r.map(i=>[i.path,i.content])),n=[];for(let i of t$(r)){let s=[...i.paths].sort((o,c)=>o.localeCompare(c));for(let o of s.slice(1)){let c=t.get(o);if(c===void 0)continue;let l=e(),u=e$(c,l);u!==c&&n.push({path:o,fromUid:i.uid,toUid:l,content:u})}}return n}a(Ese,"planDuplicateUidFix")});var ld=T(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.EMPTY_TREE_SHA=void 0;xo.getHeadSha=Tse;xo.getCommitInfo=Ase;xo.getTree=Ise;xo.getBlobText=Rse;xo.getBlobBytes=Cse;var n$=ef(),vse="https://api.github.com";function Kh(r){return(r??vse).replace(/\/$/,"")}a(Kh,"api");function tu(r){return r!==null&&typeof r=="object"?r:void 0}a(tu,"asRecord");function Co(r,e){let n=tu(r)?.[e];return typeof n=="string"?n:void 0}a(Co,"readString");async function Tse(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(n)}`}),o=Co(tu(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${n}`);return o}a(Tse,"getHeadSha");async function Ase(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(n)}`}),o=tu(s?.json),c=Co(o,"sha"),l=Co(o?.tree,"sha");if(!c||!l)throw new Error(`ExoSync: malformed commit response for ${n}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>Co(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:c,treeSha:l,parents:f}}a(Ase,"getCommitInfo");xo.EMPTY_TREE_SHA="4b825dc642cb6eb9a060e54bf8d69288fbee4904";async function Ise(r,e,t,n,i){if(n===xo.EMPTY_TREE_SHA)return[];let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(n)}?recursive=1`}),o=tu(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${n} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let c=o?.tree;if(!Array.isArray(c))throw new Error(`ExoSync: malformed tree response for ${n}`);let l=[];for(let u of c){let f=tu(u);if(f?.type!=="blob")continue;let d=Co(f,"path"),p=Co(f,"sha"),h=typeof f.size=="number"?f.size:void 0;d&&p&&l.push({path:d,blobSha:p,...h!==void 0?{size:h}:{}})}return l}a(Ise,"getTree");async function Rse(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=tu(s?.json),c=Co(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return Co(o,"encoding")==="utf-8"?c:(0,n$.base64ToUtf8)(c)}a(Rse,"getBlobText");async function Cse(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=tu(s?.json),c=Co(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return Co(o,"encoding")==="utf-8"?new TextEncoder().encode(c):(0,n$.base64ToBytes)(c)}a(Cse,"getBlobBytes")});var s$=T(ER=>{"use strict";Object.defineProperty(ER,"__esModule",{value:!0});ER.checkParkedStaleness=Ose;var xse=ld();async function Ose(r,e){let t={repoKey:r.repoKey,localPath:r.localPath},n=e.redact??(o=>o),i=null;try{let c=(await e.watermarks.get(r.repoKey))?.lastSyncedSha??"";c.length>0&&(i=c)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:`watermark unreadable: ${n(i$(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,xse.getHeadSha)(e.transport,r.owner,r.repo,r.branch,e.baseURL)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:i,remoteHeadSha:null,reason:`remote unreachable: ${n(i$(o))}`}}return{...t,freshness:s===i?"current":"behind",lastSyncedSha:i,remoteHeadSha:s}}a(Ose,"checkParkedStaleness");function i$(r){return r instanceof Error?r.message:String(r)}a(i$,"errorText")});var AR=T(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.SyncPhaseTimer=mr.SYNC_PHASES=void 0;mr.classifyRestPhase=Pse;mr.emptyTimings=a$;mr.totalMs=q_;mr.addTimings=c$;mr.aggregateTimings=Fse;mr.dominantPhase=Dse;mr.fmtMs=Yh;mr.formatTimingsLine=Lse;mr.formatRepoTimings=Nse;mr.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function TR(){let r={};for(let e of mr.SYNC_PHASES)r[e]=0;return r}a(TR,"zeroDurations");function o$(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(o$,"zeroCounts");function Pse(r){if(r.method!=="GET")return"restPush";let e=r.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(Pse,"classifyRestPhase");var vR=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=TR(),this.counts=o$()}async time(e,t){let n=this.now();try{return await t()}finally{this.durations[e]+=this.now()-n}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};mr.SyncPhaseTimer=vR;function a$(){return{durations:TR(),counts:o$()}}a(a$,"emptyTimings");function q_(r){let e=0;for(let t of mr.SYNC_PHASES)e+=r.durations[t];return e}a(q_,"totalMs");function c$(r,e){let t=TR();for(let n of mr.SYNC_PHASES)t[n]=r.durations[n]+e.durations[n];return{durations:t,counts:{filesRead:r.counts.filesRead+e.counts.filesRead,filesHashed:r.counts.filesHashed+e.counts.filesHashed,filesWritten:r.counts.filesWritten+e.counts.filesWritten,restCalls:r.counts.restCalls+e.counts.restCalls}}}a(c$,"addTimings");function Fse(r){let e=a$();for(let t of r)t.timings!==void 0&&(e=c$(e,t.timings));return e}a(Fse,"aggregateTimings");function Dse(r){let e=q_(r);if(e<=0)return null;let t=mr.SYNC_PHASES[0],n=-1;for(let i of mr.SYNC_PHASES)r.durations[i]>n&&(n=r.durations[i],t=i);return{phase:t,ms:n,pct:n/e*100}}a(Dse,"dominantPhase");function Yh(r){return r>=1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`}a(Yh,"fmtMs");function Lse(r){let e=q_(r);if(e<=0)return"";let t=mr.SYNC_PHASES.filter(n=>r.durations[n]>0).sort((n,i)=>r.durations[i]-r.durations[n]).map(n=>`${n} ${Yh(r.durations[n])} ${Math.round(r.durations[n]/e*100)}%`);return`\u23F1 ExoSync ${Yh(e)} \u2014 ${t.join(" \xB7 ")} (${r.counts.filesHashed} hashed, ${r.counts.filesRead} read, ${r.counts.restCalls} REST)`}a(Lse,"formatTimingsLine");function Nse(r,e){let t=mr.SYNC_PHASES.map(n=>`${n}=${Yh(e.durations[n])}`);return`[ExoSync timings] ${r}: total ${Yh(q_(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(Nse,"formatRepoTimings")});var W_=T(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.LocalOutboxStore=Rc.OUTBOX_REMOTE_ABSENT=Rc.OUTBOX_STORE_FILENAME=void 0;Rc.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";Rc.OUTBOX_REMOTE_ABSENT=" absent";function IR(r,e){return`${r}\0${e}`}a(IR,"outboxKey");function l$(r){if(r===null||typeof r!="object")return!1;let e=r;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(l$,"isEntry");var RR=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[IR(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(n=>{delete n.entries[IR(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(l$)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[IR(e,t)];return i!==void 0&&l$(i)}async mutate(e){let t=this.writeChain.then(async()=>{let n=await this.read();e(n),await this.io.writeAtomic(JSON.stringify(n,null,2))});return this.writeChain=t.catch(()=>{}),t}async read(){try{let e=await this.io.read();if(e===null)return{version:1,entries:{}};let t=JSON.parse(e);if(t===null||typeof t!="object")return{version:1,entries:{}};let n=t.entries;return n===null||typeof n!="object"?{version:1,entries:{}}:{version:1,entries:{...n}}}catch{return{version:1,entries:{}}}}};Rc.LocalOutboxStore=RR});var z_=T(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.SpaceSpecAccumulator=Bn.SYNC_BRANCH=Bn.ASSET_SPACE_CLASS_UID=void 0;Bn.isAssetSpaceFrontmatter=d$;Bn.isFileSpaceFrontmatter=p$;Bn.readSpaceSource=h$;Bn.parseStrictGitHubRepoURL=m$;Bn.classifySpaceDeclaration=$se;var kse=_b(),Mse=bb();Bn.ASSET_SPACE_CLASS_UID="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb";Bn.SYNC_BRANCH="main";var u$=/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]/gi;function f$(r,e){let t=r.exo__Instance_class,n=Array.isArray(t)?t:[t];for(let i of n){if(typeof i!="string")continue;u$.lastIndex=0;let s;for(;(s=u$.exec(i))!==null;)if(s[1].toLowerCase()===e)return!0}return!1}a(f$,"instanceClassHasUid");function d$(r){return f$(r,Bn.ASSET_SPACE_CLASS_UID)}a(d$,"isAssetSpaceFrontmatter");function p$(r){return f$(r,kse.FILE_SPACE_CLASS_UID)}a(p$,"isFileSpaceFrontmatter");function h$(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(h$,"readSpaceSource");var jse=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/;function m$(r){if(typeof r!="string"||r.length===0||r.length>256||!jse.test(r))return null;let e=r.slice(19),[t,n,...i]=e.split("/");if(i.length>0||t===".."||n===".."||n.startsWith("."))return null;let s=n.replace(/\.git$/,"");return s.length===0?null:{owner:t,repo:s}}a(m$,"parseStrictGitHubRepoURL");function $se(r,e){let t=d$(r),n=p$(r);if(!t&&!n)return{kind:"not-space"};let i;t&&n&&(i=`declaration at ${e} carries BOTH exo__AssetSpace and exo__FileSpace classes (disjoint) \u2014 treating as AssetSpace (conservative)`);let s=t?"asset":"file",o=h$(r);if(o===null)return s==="file"?{kind:"skip",warning:`skipped FileSpace at ${e}: no exo__AssetSpace_source/_git \u2014 mount path underivable`}:{kind:"skip"};let c=o.replace(/\.git$/i,""),l=m$(c);if(l===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: source is not a plain https://github.com/<owner>/<repo> URL`};let u=(0,Mse.derivePath)(c);if(u===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: cannot derive mount path from source`};let f=`${l.owner}/${l.repo}#${Bn.SYNC_BRANCH}`,d=r.exo__Asset_uid,p=typeof d=="string"&&d.trim().length>0?d.trim():void 0;return{kind:"candidate",candidate:{spec:{owner:l.owner,repo:l.repo,branch:Bn.SYNC_BRANCH,repoKey:f,localPath:u,...s==="file"?{spaceKind:s}:{}},spaceKind:s,...p!==void 0?{asUid:p}:{}},...i!==void 0?{warning:i}:{}}}a($se,"classifySpaceDeclaration");var CR=class{static{a(this,"SpaceSpecAccumulator")}constructor(){this.specs=[],this.warnings=[],this.asUidByRepoKey=new Map,this.seen=new Set,this.kindByRepoKey=new Map}offer(e){let{spec:t,spaceKind:n}=e;if(this.seen.has(t.repoKey)){let i=this.kindByRepoKey.get(t.repoKey);if(i!==void 0&&i!==n&&(this.warnings.push(`repo ${t.repoKey} is declared as BOTH AssetSpace and FileSpace by different assets \u2014 treating as AssetSpace (deterministic, conservative); fix the vault (disjoint subtypes)`),i==="file")){this.kindByRepoKey.set(t.repoKey,"asset");let s=this.specs.find(o=>o.repoKey===t.repoKey);s!==void 0&&delete s.spaceKind}return null}return this.seen.add(t.repoKey),this.kindByRepoKey.set(t.repoKey,n),t}commit(e){this.specs.push(e.spec),e.asUid!==void 0&&this.asUidByRepoKey.set(e.spec.repoKey,e.asUid)}};Bn.SpaceSpecAccumulator=CR});var H_=T(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:!0});ud.REF_NOT_FOUND_HINT=void 0;ud.isAuthError=Use;ud.isRefNotFoundError=Bse;var g$=z_();function Use(r){let e=r instanceof Error?r.message:String(r);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(Use,"isAuthError");function Bse(r){let e=r instanceof Error?r.message:String(r);return/\/git\/refs\/heads\/\S* → HTTP 404\b/.test(e)}a(Bse,"isRefNotFoundError");ud.REF_NOT_FOUND_HINT=`GitHub answers 404 for a private repo outside a fine-grained PAT's repository allowlist (existence-hiding), for a deleted/renamed repo, and for a visible repo that has no \`${g$.SYNC_BRANCH}\` branch (ExoSync syncs \`${g$.SYNC_BRANCH}\` only) \u2014 check the token's repository allowlist first (R8)`});var xR=T(K_=>{"use strict";Object.defineProperty(K_,"__esModule",{value:!0});K_.scanForSecrets=Vse;K_.redactSecrets=Gse;var y$=[{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 Vse(r){let e=[];for(let[t,n]of r)for(let{kind:i,re:s}of y$)s.test(n)&&e.push({path:t,kind:i});return e}a(Vse,"scanForSecrets");function Gse(r){let e=r;for(let{kind:t,re:n}of y$)e=e.replace(new RegExp(n.source,"g"),`[REDACTED:${t}]`);return e}a(Gse,"redactSecrets")});var FR=T(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});Cc.caseInsensitiveHeaderGetter=qse;Cc.parseRetryAfterMs=b$;Cc.extractRateLimitFields=_$;Cc.getRateLimitFields=Wse;Cc.attachRateLimitFields=S$;Cc.enrichRateLimitError=zse;function qse(r){let e=new Map;if(r&&typeof r=="object")for(let[t,n]of Object.entries(r))typeof n=="string"&&e.set(t.toLowerCase(),n);return t=>e.get(t.toLowerCase())}a(qse,"caseInsensitiveHeaderGetter");function PR(r){if(r==null)return;let e=r.trim();if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0}a(PR,"parseIntHeader");function b$(r,e=Date.now){if(r==null)return;let t=r.trim();if(t.length===0)return;let n=PR(t);if(n!==void 0)return Math.max(0,n*1e3);let i=Date.parse(t);if(!Number.isNaN(i))return Math.max(0,i-e())}a(b$,"parseRetryAfterMs");function _$(r,e=Date.now){let t={},n=b$(r("retry-after"),e);n!==void 0&&(t.retryAfterMs=n);let i=PR(r("x-ratelimit-reset"));i!==void 0&&(t.rateLimitReset=i);let s=PR(r("x-ratelimit-remaining"));return s!==void 0&&(t.rateLimitRemaining=s),t}a(_$,"extractRateLimitFields");function Wse(r){if(r===null||typeof r!="object")return{};let e=r,t={};return typeof e.retryAfterMs=="number"&&(t.retryAfterMs=e.retryAfterMs),typeof e.rateLimitReset=="number"&&(t.rateLimitReset=e.rateLimitReset),typeof e.rateLimitRemaining=="number"&&(t.rateLimitRemaining=e.rateLimitRemaining),t}a(Wse,"getRateLimitFields");function OR(r,e,t){Object.defineProperty(r,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}a(OR,"defineHidden");function S$(r,e){return e.retryAfterMs!==void 0&&OR(r,"retryAfterMs",e.retryAfterMs),e.rateLimitReset!==void 0&&OR(r,"rateLimitReset",e.rateLimitReset),e.rateLimitRemaining!==void 0&&OR(r,"rateLimitRemaining",e.rateLimitRemaining),r}a(S$,"attachRateLimitFields");function zse(r,e,t=Date.now){return S$(r,_$(e,t))}a(zse,"enrichRateLimitError")});var Y_=T(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.DEFAULT_MAX_RETRIES=as.MIN_RATE_LIMIT_WAIT_MS=void 0;as.isRateLimitError=w$;as.createRateLimitBudget=Kse;as.withRateLimitBackoff=Qse;var Hse=FR();function w$(r){let e=r instanceof Error?r.message:String(r);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(w$,"isRateLimitError");as.MIN_RATE_LIMIT_WAIT_MS=6e4;as.DEFAULT_MAX_RETRIES=6;function Kse(r){let e=!(r>0),t=e?Number.POSITIVE_INFINITY:r;return{reset(){t=e?Number.POSITIVE_INFINITY:r},tryReserve(n){return n<=0?!0:n<=t?(t-=n,!0):!1}}}a(Kse,"createRateLimitBudget");var Yse=a(r=>new Promise(e=>setTimeout(e,r)),"defaultSleep");function Xse(r,e,t,n,i,s){let o=(0,Hse.getRateLimitFields)(r);if(typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0)return o.retryAfterMs;if(o.rateLimitRemaining===0&&typeof o.rateLimitReset=="number"){let l=o.rateLimitReset*1e3-s();if(l>0)return l}let c=t*2**e*(1+i());return Math.max(n,c)}a(Xse,"computeRateLimitDelay");function Qse(r,e={}){let t=e.maxRetries??as.DEFAULT_MAX_RETRIES,n=e.baseDelayMs??1e3,i=Math.max(as.MIN_RATE_LIMIT_WAIT_MS,e.minRateLimitWaitMs??as.MIN_RATE_LIMIT_WAIT_MS),s=e.budget,o=e.sleep??Yse,c=e.random??Math.random,l=e.now??(()=>Date.now());return async u=>{let f=0;for(;;)try{return await r(u)}catch(d){if(!w$(d)||f>=t)throw d;let p=Xse(d,f,n,i,c,l);if(s!==void 0&&!s.tryReserve(p))throw d;f++,await o(p)}}}a(Qse,"withRateLimitBackoff")});var X_=T(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.DEFAULT_MAX_FILE_BYTES=La.InMemoryQuarantineStore=void 0;La.contentEquals=Jse;La.isSyncablePath=Zse;La.isFileSpaceSyncablePath=eoe;function Jse(r,e){if(r===void 0||e===void 0||typeof r=="string"&&typeof e=="string")return r===e;if(typeof r=="string"||typeof e=="string"||r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}a(Jse,"contentEquals");var DR=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};La.InMemoryQuarantineStore=DR;function Zse(r){return r.endsWith(".md")&&!r.includes(".local.")&&!r.includes(".conflict.")}a(Zse,"isSyncablePath");function eoe(r){return!r.includes(".local.")&&!r.includes(".conflict.")}a(eoe,"isFileSpaceSyncablePath");La.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var P$=T(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.SyncEngine=Tn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=Tn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=Tn.DEFAULT_MAX_PUSH_RETRIES=void 0;Tn.syncProgressPhaseText=roe;Tn.isNonFastForwardError=O$;Tn.orderChildrenFirst=uoe;var E$=B_(),v$=AR(),dt=ld(),Oo=zh(),toe=ef(),ru=cd(),LR=W_(),NR=H_(),T$=xR(),A$=Y_(),Po=X_();Tn.DEFAULT_MAX_PUSH_RETRIES=3;Tn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=3e5;Tn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function roe(r){switch(r.phase){case"reading-local":return r.detail!==void 0?`reading local files ${r.detail.done}\u2026`:"reading local files\u2026";case"detecting":return"detecting changes\u2026";case"pulling-remote":return"pulling remote tree\u2026";case"fetching-blobs":return r.detail!==void 0?`fetching remote files ${r.detail.done}/${r.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return r.detail!==void 0?`writing files ${r.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return r.phase}}a(roe,"syncProgressPhaseText");var I$=25,noe=10,ioe=6,soe=500,ooe=25;function aoe(r){try{return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{return null}}a(aoe,"decodeUtf8Strict");function coe(r){return typeof r=="string"?r:{base64:(0,toe.bytesToBase64)(r)}}a(coe,"toCommitContent");async function R$(r,e){if(r.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return r.readBinary(e)}a(R$,"readBinaryStrict");async function loe(r,e,t){if(r.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return r.writeBinary(e,t)}a(loe,"writeBinaryStrict");function C$(r){return r.length===0||r.startsWith("/")||r.includes("\\")?!1:r.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(C$,"isSafeRepoRelativePath");function O$(r){let e=r instanceof Error?r.message:String(r);return/HTTP 422/.test(e)&&/git\/refs/.test(e)||/ref update mismatch/.test(e)||/HTTP 422/.test(e)&&/git\/trees/.test(e)&&/BadObjectState/.test(e)}a(O$,"isNonFastForwardError");function uoe(r){let e=a(t=>t.split("/").filter(n=>n.length>0).length,"depth");return[...r].sort((t,n)=>e(n.localPath)-e(t.localPath))}a(uoe,"orderChildrenFirst");function x$(r,e){let t=new Map(r.map(o=>[o.path,o])),n=new Set,i=[];for(let o of e){n.add(o.path);let c=t.get(o.path);(c===void 0||c.blobSha!==o.blobSha)&&i.push(o)}let s=r.filter(o=>!n.has(o.path));return{changed:i,deleted:s}}a(x$,"diffTrees");function foe(r){let e=r instanceof Error?r.message:String(r);return/→ HTTP (?:404|422)\b/.test(e)}a(foe,"isCommitUnknownError");function Na(r){return r instanceof Error?r.message:String(r)}a(Na,"errMsg");function doe(r,e,t){if(t.size===0)return r;let n=new Map(e.files.map(o=>[o.path,o])),i=new Set(r.map(o=>o.path)),s=[];for(let o of r){if(!t.has(o.path)){s.push(o);continue}let c=n.get(o.path);c!==void 0&&s.push(c)}for(let o of t){if(i.has(o))continue;let c=n.get(o);c!==void 0&&s.push(c)}return s}a(doe,"applyWatermarkPins");var kR={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function MR(r){return new Map(r.map(e=>[e.path,e.blobSha]))}a(MR,"treeByPath");function Q_(r){return[...r.quarantineEntries.map(e=>e.path),...r.resolvedQuarantineEntries.map(e=>e.path)]}a(Q_,"quarantinedPathsOf");var jR=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,A$.createRateLimitBudget)(e.backoff?.maxTotalRateLimitWaitMs??Tn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS),this.transport=this.instrumentTransport((0,A$.withRateLimitBackoff)(e.transport,{...e.backoff,budget:this.rateLimitBudget,now:this.now})),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpRest(),n.time((0,v$.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpHashed(),n.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((c,l)=>{let u=this.activeTimer;return u===null?l():u.time(c,l)},"timed"),n={list:a(()=>t("localList",()=>e.list()),"list"),read:a(c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(c))),"read"),write:a((c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(c,l))),"write"),delete:a(c=>e.delete(c),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(n.readBinary=c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(c))));let s=e.writeBinary?.bind(e);s!==void 0&&(n.writeBinary=(c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(c,l))));let o=e.stat?.bind(e);return o!==void 0&&(n.stat=c=>t("localList",()=>o(c))),n}busyResult(e){return{repoKey:e.repoKey,status:"busy",pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:[],deferredDeletes:[],detail:"another sync operation is in progress (D11 guard) \u2014 retry after it finishes"}}modeOps(e){let t=e.spaceKind==="file",n=t?Po.isFileSpaceSyncablePath:Po.isSyncablePath,i=this.deps.maxFileBytes??Po.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:n,treeFilter:a(s=>n(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,dt.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(n.treeFilter),l=[];for(let u of c){let f=t.get(u.path);f!==void 0&&await(0,ru.gitBlobSha)(f,this.sha1)===u.blobSha&&l.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${l.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:l,spaceKind:"file"}}async syncAll(e,t="sync",n){if(this.opInProgress)return e.map(i=>this.busyResult(i));this.opInProgress=!0,this.rateLimitBudget.reset();try{let i=[];for(let s of e)i.push(await this.syncLocked(s,t,n));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",n){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0,this.rateLimitBudget.reset();try{return await this.syncLocked(e,t,n)}finally{this.opInProgress=!1}}emitProgress(e,t,n,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:n}:{repoKey:t,phase:n,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%soe===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%ooe===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",n){let i=new v$.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=n!==void 0?{emit:n,repoKey:e.repoKey,reads:0,writes:0}:null;let c=[],l=[],u=0,f=0,d=[],p=a((h,g={})=>({repoKey:e.repoKey,status:h,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:c,deferredDeletes:l,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),...g}),"result");try{let h=await this.deps.materializationCheck.check(e);if(!h.fullyMaterialized)return c.push(`skipped: repo not fully materialized${h.reason?` (${h.reason})`:""} \u2014 deletes NOT inferred (D19)`),p("skipped-not-materialized");let g=this.modeOps(e),m=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(g.fileMode&&(m.readBinary===void 0||m.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(g.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??Po.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let U=await this.flushOutbox(e,c);u=U.pushed,f=U.reconflicted}let _=await this.deps.watermarkStore.get(e.repoKey);if(_?.spaceKind==="file"&&!g.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)"});_!==null&&g.fileMode&&_.spaceKind!=="file"&&(c.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),_=null);let S=this.deps.localManifestStore!==void 0?m.stat?.bind(m):void 0,I=S!==void 0&&_!==null&&!g.fileMode,E=I&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,w=this.deps.localManifestFullRehashMs??Tn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,R=I&&(E===null||this.now()-E.lastFullRehashMs>=w),x=new Map,P=new Set,k=new Map,B=new Map,D=new Map,Q=!1,fe=new Map;if(I&&_!==null)for(let U of _.files)fe.set(U.path,U.blobSha);for(let U of(await m.list()).filter(g.syncable)){if(g.fileMode){let ae=await R$(m,U);if(ae.byteLength>b){P.add(U),c.push(`skipped oversized file ${U} (${ae.byteLength} bytes > ${b} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}x.set(U,ae);continue}if(!I||S===void 0){x.set(U,await m.read(U));continue}let F=await S(U),H=!R&&F!==null?E?.files[U]:void 0;if(F!==null&&H!==void 0&&H.mtimeMs===F.mtimeMs&&H.size===F.size&&H.blobSha===fe.get(U)){k.set(U,{blobSha:H.blobSha,...H.uid!==void 0?{uid:H.uid}:{}}),B.set(U,H.blobSha),D.set(U,F);continue}Q=!0,x.set(U,await m.read(U)),F!==null&&D.set(U,F)}let j=!1;if(_===null)if(g.fileMode)j=!0,_=await this.buildFileModeFirstSyncBase(e,x,g,c);else{let U=await this.bootstrapWatermark(e,x,c,p);if(U.kind==="settled")return U.outcome;j=!0,_=U.base}let ce=_;g.fileMode&&P.size>0&&(_={..._,files:_.files.filter(U=>!P.has(U.path))});let V,oe;I&&!R?(V=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),oe=V===_.lastSyncedSha?_.rootTreeSha:await this.resolveBaseTreeSha(e,_,{headReachable:!0})):oe=await this.resolveBaseTreeSha(e,_),this.emitProgress(n,e.repoKey,"detecting");let K=await(0,Oo.detectChanges)({localFiles:x,...I?{cachedEntries:k}:{},watermark:_,actualBaseTreeSha:oe,sha1:this.sha1});if(K.kind==="full-conflict")return p("full-conflict",{detail:`${K.reason}${K.detail?`: ${K.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(c.push(...K.warnings),I&&this.deps.localManifestStore!==void 0){let U={};for(let[F,H]of x){let ae=D.get(F),Se=K.diskBlobShas.get(F);if(ae===void 0||Se===void 0)continue;let Ce=typeof H=="string"?(0,Oo.extractAssetUid)(H):void 0;U[F]={mtimeMs:ae.mtimeMs,size:ae.size,blobSha:Se,...Ce!==void 0?{uid:Ce}:{}}}for(let[F,H]of k){let ae=D.get(F);ae!==void 0&&(U[F]={mtimeMs:ae.mtimeMs,size:ae.size,blobSha:H.blobSha,...H.uid!==void 0?{uid:H.uid}:{}})}if(E!==null&&Object.keys(E.files).some(F=>!(F in U))&&(Q=!0),Q||R||E===null){let F={version:1,files:U,lastFullRehashMs:R||E===null?this.now():E.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,F)}}let z=this.pinLocalChanges(K,x,c,l,t);d=[...z.pushDeletionsAll.keys()];let Z=await this.runPushLoop(e,_,z,x,c,g,j,P,t,n,V);if(d=[],Z.kind!=="done"&&z.pushDeletionsAll.size>0&&l.push(...z.pushDeletionsAll.keys()),Z.kind==="conflict")return p("conflict",{detail:Z.detail});if(Z.kind==="retry-exhausted"){c.push(...Z.merge.warnings);let U=await this.buildTerminalQuarantineEntries(e,_,Z.pushFiles,Z.merge.quarantineEntries,x),F=[...Z.merge.quarantineEntries,...Z.merge.resolvedQuarantineEntries,...U];return await this.flushQuarantine(F,c),p("retry-exhausted",{detail:Z.detail,quarantinedCount:F.length,...F.length>0?{quarantinedPaths:F.map(H=>H.path)}:{}})}let{examinedHead:Ie,pushedSha:ee,applyWrites:Y,applyDeletes:se,pushFiles:X}=Z,le=Z.merge;c.push(...le.warnings),c.push(...Z.deferredWarnings),l.push(...Z.withheldDeletions);let Ue=Z.deferredPaths.size>0?{deferredPaths:[...Z.deferredPaths]}:{},$=Z.pushedDeletions.length>0?{pushedDeletes:Z.pushedDeletions}:{},de=await this.flushQuarantine([...le.quarantineEntries,...le.resolvedQuarantineEntries],c);Z.secretQuarantineEntries.length>0&&await this.flushQuarantine(Z.secretQuarantineEntries,c);let ie=new Set;if(!de&&le.resolvedQuarantineEntries.length>0){for(let U of le.resolvedQuarantineEntries)ie.add(U.path);c.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${ie.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(ee===void 0&&Ie===_.lastSyncedSha&&Y.length===0&&se.length===0&&le.mergedWrites.length===0&&le.quarantineEntries.length===0&&le.resolvedQuarantineEntries.length===0&&(_.pinnedPaths?.length??0)===0&&Z.alreadyInHead.length===0&&Z.deferredPaths.size===0&&!j)return p("synced");let Ae=ee??Ie,ye=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,Ae,this.deps.baseURL);if(ee!==void 0&&ye.parents[0]!==Ie)return await this.checkRaceWindow(e,_,Ie,ye.parents[0],X,new Set(Z.pushedDeletions),c,g),c.push(`race-window: watermark NOT advanced (pushed commit's parent ${ye.parents[0]} != examined head ${Ie}) \u2014 next sync reconciles the concurrent change`),p("synced",{pushedSha:ee,pushedCount:X.size,mergedCount:le.mergedCount,quarantinedCount:le.quarantineEntries.length+le.resolvedQuarantineEntries.length,...le.mergedPaths.length>0?{mergedPaths:le.mergedPaths}:{},...Q_(le).length>0?{quarantinedPaths:Q_(le)}:{},...Ue,...$});let{pulledCount:Te,pinnedPaths:Re,pulledPaths:pe}=await this.applyRemoteChanges(m,x,[...Y,...le.mergedWrites].filter(U=>!ie.has(U.path)),se.filter(U=>!ie.has(U.path)),c,B);for(let U of le.quarantineEntries)Re.add(U.path);for(let U of Z.deferredPaths)Re.add(U);for(let U of ie)Re.add(U);if(g.fileMode){for(let U of P)Re.add(U);for(let U of Z.remoteOversized)Re.add(U)}return await this.advanceWatermark(e,Ae,ye.treeSha,x,[...Y,...le.mergedWrites,...Z.deferredRemoteChanges],ce,Re,K.diskBlobShas,g,P),await this.resolveClearedPins(e,ce,Re,c,new Set(le.resolvedQuarantineEntries.map(U=>U.path))),p("synced",{pushedSha:ee,pulledCount:Te,pushedCount:X.size,mergedCount:le.mergedCount,quarantinedCount:le.quarantineEntries.length+le.resolvedQuarantineEntries.length,...le.mergedPaths.length>0?{mergedPaths:le.mergedPaths}:{},...pe.length>0?{pulledPaths:pe}:{},...Q_(le).length>0?{quarantinedPaths:Q_(le)}:{},...Ue,...$})}catch(h){let g=this.deps.redact??(m=>m);if(d.length>0&&l.push(...d),(0,NR.isAuthError)(h))return p("auth-required",{detail:g(`authentication failed: ${Na(h)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)});if((0,NR.isRefNotFoundError)(h)){let m=g(`${e.owner}/${e.repo}@${e.branch} is not reachable: ${Na(h)} \u2014 ${NR.REF_NOT_FOUND_HINT}`);return c.push(`sync failed: ${m}`),p("error",{detail:m})}return c.push(`sync failed: ${g(Na(h))}`),p("error",{detail:g(Na(h))})}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let n=this.deps.redact??(s=>s);for(let s of e)t.push(n(`quarantined ${s.path}: ${s.reason}`));let i=this.deps.quarantine;if(i===void 0)return!1;try{if(i.quarantineAll!==void 0)await i.quarantineAll(e);else for(let s of e)await i.quarantine(s);return!0}catch(s){let o=this.deps.redact??(c=>c);return t.push(`quarantine sink failed: ${o(Na(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let n=this.deps.outbox;if(n===void 0)return{pushed:0,reconflicted:0};let i=await n.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(g=>g),o,c;try{({head:o,shaByPath:c}=await this.outboxHeadTreeShas(e))}catch(g){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(Na(g))}`),{pushed:0,reconflicted:0}}let l=0,u=[];for(let g of i){let m=c.get(g.path)??LR.OUTBOX_REMOTE_ABSENT,b=m===LR.OUTBOX_REMOTE_ABSENT&&g.baseRemoteSha!==LR.OUTBOX_REMOTE_ABSENT?[...c].filter(([_,S])=>_!==g.path&&S===g.baseRemoteSha).map(([_])=>_):[];if(m!==g.baseRemoteSha&&b.length===0){await n.remove(g.repoKey,g.path),l++,t.push(s(`outbox: remote moved for ${g.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:g,stalePaths:b})}if(u.length===0)return{pushed:0,reconflicted:l};let f=new Map;for(let{entry:g}of u)f.set(g.path,g.chosenContent);let d=new Set;for(let{stalePaths:g}of u)for(let m of g)f.has(m)||d.add(m);let p=[...d];try{await(0,E$.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(g){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(Na(g))}`),{pushed:0,reconflicted:l}}let h=0;for(let{entry:g,stalePaths:m}of u){let b=m.filter(_=>!f.has(_));await this.snapOutboxWatermark(e,g.path,g.chosenContent,b),await this.deps.quarantine?.markResolved?.(g.repoKey,g.path);for(let _ of b)await this.deps.quarantine?.markResolved?.(g.repoKey,_);await n.remove(g.repoKey,g.path),h++,b.length>0&&t.push(`consolidated cross-path conflict for ${g.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:l}}async outboxHeadTreeShas(e){let t=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,dt.getTree)(this.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return{head:t,shaByPath:s}}async snapOutboxWatermark(e,t,n,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),c=(s.pinnedPaths??[]).filter(m=>!o.has(m)),l=await(0,ru.gitBlobSha)(n,this.sha1),u=(0,Oo.extractAssetUid)(n),f={path:t,blobSha:l,...u!==void 0?{uid:u}:{}},d=new Set(i),p=s.files.filter(m=>!d.has(m.path)),h=p.findIndex(m=>m.path===t),g=h>=0?p.map((m,b)=>b===h?f:m):[...p,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:g,...c.length>0?{pinnedPaths:c}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,n,i,s){let o=new Set(i.map(u=>u.path)),c=new Map;try{let u=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>n.has(d.path));for(let d of f)c.set(d.path,await(0,dt.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let l=[];for(let[u,f]of n){if(o.has(u))continue;let d=s.get(u),p=d??f,h=d!==void 0&&!(0,Po.contentEquals)(d,f),g=typeof p=="string"?(0,Oo.extractAssetUid)(p):void 0,m=c.get(u);l.push({repoKey:e.repoKey,path:u,...g!==void 0?{uid:g}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??Tn.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},...m!==void 0?{remoteContent:m}:{}})}return l}async resolveClearedPins(e,t,n,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let c=(t.pinnedPaths??[]).filter(l=>!n.has(l)&&!s.has(l));for(let l of c)try{await o.markResolved?.(e.repoKey,l)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${l}: ${f(Na(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t,n={}){try{return(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch(i){if(!foe(i))throw i;return n.headReachable===!0||await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),null}}pinLocalChanges(e,t,n,i,s){let o=e.modified.filter(p=>p.basePath!==void 0),c=[...e.added,...e.modified.filter(p=>p.basePath===void 0)],l=new Map;if(s==="pull"){for(let p of o)p.basePath!==void 0&&i.push(p.basePath),n.push(`pull-only: rename (uid ${p.uid??"?"}) ${p.basePath} \u2192 ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`);for(let p of e.deleted)i.push(p.path),n.push(`pull-only: delete of ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`)}else{for(let p of o)p.basePath!==void 0&&l.set(p.basePath,p.path);for(let p of e.deleted)l.set(p.path,p.path)}let u=[...c,...o,...e.deleted.map(p=>({...p}))],f=new Set(e.deleted.map(p=>p.path)),d=new Map;for(let p of[...c,...s==="pull"?[]:o]){let h=t.get(p.path);h!==void 0&&d.set(p.path,h)}return{localChanges:u,localDeletedPaths:f,pushFilesAll:d,pushDeletionsAll:l,dupUids:e.duplicateUids}}async runPushLoop(e,t,n,i,s,o,c=!1,l=new Set,u="sync",f,d){let{localChanges:p,localDeletedPaths:h,pushFilesAll:g,pushDeletionsAll:m,dupUids:b}=n,_=this.deps.maxPushRetries??Tn.DEFAULT_MAX_PUSH_RETRIES,S=0,I="",E,w=[],R=[],x=new Map,P=new Set,k=[],B=kR,D=[],Q=new Set,fe=[],j=[],ce=new Set,V=[],oe=new Set;for(;;){I=S===0&&d!==void 0&&g.size===0&&m.size===0?d:await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),w=[],R=[],B=kR,D=[],Q=new Set,fe=[],j=[];let K,z=new Set,Z=(t.pinnedPaths?.length??0)>0;if(I!==t.lastSyncedSha||Z||c){this.emitProgress(f,e.repoKey,"pulling-remote");let Y=await this.collectRemoteChanges(e,t,I,o,l,s,ce,f);K=Y.headTreeByPath;let se=this.matchLocalVsRemote(p,h,i,Y.changes,z,b,Y.headTreeByPath);if(se.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let X of se.conflicts){Q.add(X.local.path),X.local.basePath!==void 0&&Q.add(X.local.basePath);for(let le of X.remotes)Q.add(le.path),le.kind==="change"&&fe.push(le)}j.push(`${u}-only: ${se.conflicts.length} conflict(s) deferred to a full Sync (${se.conflicts.map(X=>X.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)B=this.resolveFileModeConflicts(e,se.conflicts,i,se.applyWrites,se.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${se.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};B=await this.resolveMergeConflicts(e,t,se.conflicts,i)}if(u==="sync")for(let X of se.conflicts)for(let le of X.remotes)le.path!==X.local.path&&(Q.add(le.path),le.kind==="change"&&fe.push(le),j.push(`conflict group ${X.desc}: remote change at ${le.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(w=se.applyWrites,R=se.applyDeletes,u==="push"&&(w.length>0||R.length>0)){for(let X of w)Q.add(X.path),fe.push(X);for(let X of R)Q.add(X.path);j.push(`push-only: ${w.length+R.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),w=[],R=[]}}x=u==="pull"?new Map:new Map([...[...g].filter(([Y])=>!z.has(Y)),...B.mergedFiles]),P=new Set,k=[];for(let[Y,se]of m){if(z.has(se)){k.push(Y);continue}x.has(Y)||P.add(Y)}if((x.size>0||P.size>0)&&K===void 0&&(K=MR(await(0,dt.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),x.size>0&&K!==void 0){for(let[Y,se]of x){let X=K.get(Y);X!==void 0&&X===await(0,ru.gitBlobSha)(se,this.sha1)&&(x.delete(Y),D.push(Y))}D.length>0&&s.push(`phantom push skipped: ${D.length} file(s) already identical in remote HEAD (${D.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(P.size>0&&K!==void 0){for(let Y of[...P])K.has(Y)||P.delete(Y);x.size===0&&P.size>=K.size&&(k.push(...P),j.push(`deletion of ALL ${P.size} remaining file(s) deferred \u2014 GitHub cannot create an empty tree; the deletes re-derive and propagate once the repo has at least one surviving file`),P.clear())}if(x.size===0&&P.size===0)break;let Ie=new Map;for(let[Y,se]of x)if(typeof se=="string")Ie.set(Y,se);else{let X=aoe(se);X!==null&&Ie.set(Y,X)}let ee=(0,T$.scanForSecrets)(Ie);if(ee.length>0){let Y=new Map;for(let se of ee){let X=Y.get(se.path);X===void 0?Y.set(se.path,[se.kind]):X.includes(se.kind)||X.push(se.kind)}for(let[se,X]of Y){if(!oe.has(se)){oe.add(se);let le=Ie.get(se),Ue=le!==void 0?(0,T$.redactSecrets)(le):void 0,$=Ue!==void 0?(0,Oo.extractAssetUid)(Ue):void 0;V.push({repoKey:e.repoKey,path:se,...$!==void 0?{uid:$}:{},reason:`secret-scan (R5): detected ${X.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.`,...Ue!==void 0?{localContent:Ue}:{}})}x.delete(se)}s.push(`secret-scan (R5): skipped ${Y.size} file(s) with a detected secret from the push \u2014 the rest of the changeset shipped; REVOKE the credential(s): ${[...Y].map(([se,X])=>`${se} (${X.join(", ")})`).join(", ")}`);for(let[se,X]of m)oe.has(X)&&P.has(se)&&(P.delete(se),k.push(se));if(x.size===0&&P.size===0)break}try{E=await(0,E$.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...x].map(([Y,se])=>[Y,coe(se)])),deletions:[...P],message:this.deps.commitMessage?.(e,x.size,P.size)??`chore(exosync): sync ${x.size} file(s)${P.size>0?`, ${P.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(Y){if(!O$(Y))throw Y;if(S++,S>_)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${_} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:x,merge:B};s.push(`non-fast-forward push (attempt ${S}/${_}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:I,pushedSha:E,applyWrites:w,applyDeletes:R,pushFiles:x,pushedDeletions:E!==void 0?[...P]:[],withheldDeletions:k,merge:B,remoteOversized:ce,alreadyInHead:D,deferredPaths:Q,deferredRemoteChanges:fe,deferredWarnings:j,secretQuarantineEntries:V}}async resolveMergeConflicts(e,t,n,i){let s=this.deps.mergeLayer;if(s===void 0)return kR;let o=new Map(t.files.map(m=>[m.path,m])),c=new Map,l=[],u=[],f=[],d=[],p=0,h=a(m=>typeof m=="string"?m:void 0,"asText"),g=a((m,b,_)=>{let S=h(i.get(m.local.path)),I=h(m.remotes[0]?.content);return{repoKey:e.repoKey,path:m.local.path,...m.local.uid!==void 0?{uid:m.local.uid}:{},reason:b,..._!==void 0?{baseContent:_}:{},...S!==void 0?{localContent:S}:{},...I!==void 0?{remoteContent:I}:{}}},"entry");for(let m of n){let b=o.get(m.local.basePath??m.local.path)??o.get(m.remotes[0]?.path??""),_;if(b!==void 0&&(_=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,b.blobSha,this.deps.baseURL)),m.remotes.length>1){u.push(g(m,`ambiguous conflict: local change overlaps ${m.remotes.length} remote changes (${m.remotes.map(R=>R.path).join(", ")})`,_));continue}let S=m.remotes[0],I=h(i.get(m.local.path)),E=await s.resolve({path:m.local.path,...m.local.uid!==void 0?{uid:m.local.uid}:{},..._!==void 0?{base:_}:{},...I!==void 0?{local:I}:{},...S.kind==="change"&&typeof S.content=="string"?{remote:S.content}:{}});if(E.action==="quarantine"){u.push(g(m,E.reason,_));continue}p++,d.push(m.local.path);for(let R of E.warnings??[])f.push(`merge(${m.local.path}): ${R}`);let w=S.kind==="change"?S.content:void 0;if(E.content!==w&&c.set(m.local.path,E.content),E.content!==i.get(m.local.path)){let R=(0,Oo.extractAssetUid)(E.content)??m.local.uid;l.push({path:m.local.path,kind:"change",content:E.content,blobSha:await(0,ru.gitBlobSha)(E.content,this.sha1),...R!==void 0?{uid:R}:{}})}}return{mergedFiles:c,mergedWrites:l,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:p,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,n,i,s){let o=[],c=[];for(let l of t){l.remotes.length>1&&c.push(`file-mode conflict on ${l.local.path} unexpectedly overlaps ${l.remotes.length} remote changes \u2014 resolving against the first`);let u=l.remotes[0],f=n.get(l.local.path);u.kind==="change"?i.push(u):s.push(u),!(l.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:l.local.path,reason:`file-mode remote-wins (D18): remote ${u.kind==="change"?`version ${u.blobSha}`:"delete"} wins; this is the losing LOCAL version, preserved byte-exact`,...typeof f=="string"?{localContent:f}:{localContentBytes:f}})}return{mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:o,mergedCount:0,mergedPaths:[],warnings:c}}async applyRemoteChanges(e,t,n,i,s,o=new Map){let c=0,l=new Set,u=[],f=a(async(h,g)=>{try{return g?await R$(e,h):await e.read(h)}catch{return}},"tryRead"),d=a(async(h,g)=>{typeof g=="string"?await e.write(h,g):await loe(e,h,g)},"writeContent"),p=a(async h=>{let g=await f(h,!1);return g===void 0?!0:await(0,ru.gitBlobSha)(g,this.sha1)===o.get(h)},"cacheHitUnchanged");for(let h of n){if(h.content===void 0)continue;if(!C$(h.path)){s.push(`unsafe remote path skipped on pull-apply: ${h.path}`),l.add(h.path);continue}let g=t.get(h.path);if(g===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path);continue}let m=await f(h.path,typeof(g??h.content)!="string");if(!(0,Po.contentEquals)(m,g)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path)}for(let h of i){if(!C$(h.path)){s.push(`unsafe remote path skipped on pull-delete: ${h.path}`),l.add(h.path);continue}let g=t.get(h.path);if(g===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path);continue}if(g!==void 0){let m=await f(h.path,typeof g!="string");if(m!==void 0&&!(0,Po.contentEquals)(m,g)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path)}}return{pulledCount:c,pinnedPaths:l,pulledPaths:u}}async advanceWatermark(e,t,n,i,s,o,c,l,u,f=new Set){let d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).filter(h=>u.treeFilter(h)&&!f.has(h.path)),p=doe(await this.buildWatermarkFiles(e,d,i,s,o,l,u),o,c);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:n,files:p,...c.size>0?{pinnedPaths:[...c]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,n,i,s){let o=this.deps.mountBaseStore,c=null;if(o!==void 0)try{c=await o.get(e.repoKey)}catch{return null}let l=!1;if(c===null&&this.deps.localBaseShaProvider!==void 0)try{let b=await this.deps.localBaseShaProvider(e);typeof b=="string"&&b.length>0&&(c=b,l=!0)}catch{}if(c===null||t.startsWith(c))return null;let u=300,f=null;try{let b=t;for(let _=0;_<u;_++){let S=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,b,this.deps.baseURL);if(S.sha===c||S.sha.startsWith(c)){f=S;break}if(S.parents.length===0)break;b=S.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(b=>(0,Po.isSyncablePath)(b.path))}catch{return null}let p;try{let b=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);p=MR((await(0,dt.getTree)(this.transport,e.owner,e.repo,b.treeSha,this.deps.baseURL)).filter(_=>(0,Po.isSyncablePath)(_.path)))}catch{return null}let h=d.filter(b=>!n.has(b.path)&&p.get(b.path)===b.blobSha);if(h.length>0){let b=h.slice(0,3).map(_=>_.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 g=d.map(b=>({path:b.path,blobSha:b.blobSha})),m={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:g};if(l&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(l?`first-sync (asset mode): BACKFILLED the 3-way base from the locally checked-out commit ${f.sha} (no recorded mount base) \u2014 remote head ${t} advanced since; local edits 3-way merge against it instead of false-conflicting (#3590)`:`first-sync (asset mode): reconciling against the recorded mount base ${f.sha} \u2014 remote head ${t} advanced since mount; local edits 3-way merge against it instead of false-conflicting (#3590)`),{kind:"additive-base",base:m}}async bootstrapWatermark(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,n,i);if(o!==null)return o;let c=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,dt.getTree)(this.transport,e.owner,e.repo,c.treeSha,this.deps.baseURL)).filter(p=>(0,Po.isSyncablePath)(p.path)),u=[],f;for(let p of l){let h=t.get(p.path);if(h===void 0||await(0,ru.gitBlobSha)(h,this.sha1)!==p.blobSha){f===void 0&&(f=p.path);continue}let g=typeof h=="string"?(0,Oo.extractAssetUid)(h):void 0;u.push({path:p.path,blobSha:p.blobSha,...g?{uid:g}:{}})}let d={lastSyncedSha:s,rootTreeSha:c.treeSha,files:u};return f!==void 0?this.deps.mergeLayer===void 0?{kind:"settled",outcome:i("full-conflict",{detail:`first-sync: no watermark and local content diverges from remote head at ${f} \u2014 A2/A3 scope`})}:(n.push(`first-sync (asset mode): no 3-way merge base and local diverges from remote head (first at ${f}) \u2014 reconciling ZERO-LOSS against ${u.length} byte-identical file(s) as a synthetic base: remote-only files pull, local-only files push, overlapping divergences route to the merge/quarantine layer (both versions preserved), never a silent overwrite or delete`),{kind:"additive-base",base:d}):t.size===l.length?(await this.deps.watermarkStore.set(e.repoKey,d),n.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(n.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${l.length} files) \u2014 ${t.size-l.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,n,i,s=new Set,o=[],c=new Set,l){let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL),f=await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let P of f)i.syncable(P.path)&&!i.treeFilter(P)&&!c.has(P.path)&&(c.add(P.path),o.push(`skipped oversized REMOTE file ${P.path} (${P.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(P=>i.treeFilter(P)&&!s.has(P.path)),p=t.files.filter(P=>!c.has(P.path)&&!s.has(P.path)),{changed:h,deleted:g}=x$(p,d),m=h.length;m>=I$&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:0,total:m});let b=new Array(h.length),_=0,S=0,I,E=a(async P=>{if(i.fileMode){let B=await(0,dt.getBlobBytes)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:B}}let k=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:k,uid:(0,Oo.extractAssetUid)(k)}},"fetchOne"),w=a(async()=>{for(;;){if(I!==void 0)return;let P=_++;if(P>=h.length)return;try{b[P]=await E(h[P])}catch(k){I===void 0&&(I=k);return}S+=1,m>=I$&&S%noe===0&&S<m&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:S,total:m})}},"worker"),R=Math.min(ioe,h.length);if(await Promise.all(Array.from({length:R},()=>w())),I!==void 0)throw I instanceof Error?I:new Error(String(I));let x=b;for(let P of g)x.push({path:P.path,kind:"delete",uid:P.uid});return{changes:x,headTreeByPath:MR(f)}}matchLocalVsRemote(e,t,n,i,s,o=new Set,c){let l=new Set,u=[],f=new Map;for(let m of i)m.kind==="change"&&m.uid!==void 0&&f.set(m.uid,(f.get(m.uid)??0)+1);let d=new Set(o);for(let[m,b]of f)b>1&&d.add(m);let p=new Map,h=new Map;for(let m of i){if(m.uid!==void 0&&!d.has(m.uid)){let b=p.get(m.uid)??[];b.push(m),p.set(m.uid,b)}h.set(m.path,m)}for(let m of e){let b=new Set;if(m.uid!==void 0&&!d.has(m.uid))for(let E of p.get(m.uid)??[])E.kind==="change"&&E.path!==m.path&&(c?.has(m.path)===!0||m.basePath!==void 0&&c?.has(m.basePath)===!0)||b.add(E);let _=h.get(m.path);if(_!==void 0&&b.add(_),m.basePath!==void 0){let E=h.get(m.basePath);E!==void 0&&b.add(E)}let S=[],I=!1;for(let E of b){if(I=t.has(m.path)&&!n.has(m.path),I&&E.kind==="delete"){l.add(E);continue}if(!I&&E.kind==="change"&&E.path===m.path&&E.blobSha===m.blobSha){l.add(E),s.add(m.path);continue}if(E.kind==="delete"&&m.basePath!==void 0&&E.path===m.basePath){let w=h.get(m.path);if(w!==void 0&&w.kind==="change"&&(w.blobSha===m.blobSha||w.uid!==void 0&&w.uid===m.uid)){l.add(E);continue}}if(E.kind==="delete"&&E.path!==m.path&&E.path!==m.basePath&&!n.has(E.path)&&c?.has(E.path)!==!0){l.add(E);continue}S.push(E),l.add(E)}S.length>0&&(u.push({local:m,localIsDelete:I,remotes:S,desc:`${m.uid!==void 0&&!d.has(m.uid)?m.uid:m.path} (local ${I?"delete":"change"} vs remote ${S[0].kind} at ${S[0].path})`}),s.add(m.path))}let g=i.filter(m=>!l.has(m));return{conflicts:u,applyWrites:g.filter(m=>m.kind==="change"),applyDeletes:g.filter(m=>m.kind==="delete")}}async checkRaceWindow(e,t,n,i,s,o,c,l){try{let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(l.treeFilter),d=n===t.lastSyncedSha?t.files:(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(l.treeFilter),{changed:p,deleted:h}=x$(d,f);for(let g of p)s.has(g.path)&&c.push(`race-window: concurrent commit ${i} changed ${g.path} between conflict check (head ${n}) and push \u2014 local version won; previous version recoverable from git history`),o.has(g.path)&&c.push(`race-window: concurrent commit ${i} changed ${g.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let g of h)s.has(g.path)&&c.push(`race-window: concurrent commit ${i} deleted ${g.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);c.push(`race-window check failed: ${f(Na(u))}`)}}async buildWatermarkFiles(e,t,n,i,s,o,c){if(c.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let l=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&l.set(f.blobSha,f.uid);for(let[f,d]of n){let p=o?.get(f)??await(0,ru.gitBlobSha)(d,this.sha1);l.set(p,typeof d=="string"?(0,Oo.extractAssetUid)(d):void 0)}for(let f of s.files)l.has(f.blobSha)||l.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(l.has(f.blobSha))d=l.get(f.blobSha);else{let p=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,Oo.extractAssetUid)(p)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};Tn.SyncEngine=jR});var D$=T(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});Jh.QuarantineResolver=void 0;Jh.backupPathFor=F$;var poe=B_(),J_=ld(),Xh=cd(),Qh=zh(),hoe=W_(),Fo="\0absent",$R=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let n of e)t.push(...await this.listRepoConflicts(n));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),n=t?.pinnedPaths??[];if(n.length===0)return[];if(this.deps.outbox!==void 0){let h=await this.deps.outbox.listForRepo(e.repoKey);if(h.length>0){let g=new Set(h.map(m=>m.path));if(n=n.filter(m=>!g.has(m)),n.length===0)return[]}}let i=new Map;for(let h of t?.files??[])i.set(h.path,h.blobSha);let s=this.deps.conflictCache!==void 0,o=await this.cachedRecordsFor(e,n),c=n.some(h=>!o.has(h)),l=new Map,u=!0;if(c)if(s)try{l=await this.remoteTreeShas(e)}catch{u=!1}else l=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),p=[];for(let h of n){let g=o.get(h),m,b;if(g!==void 0)b=g.remoteContent!==void 0?await(0,Xh.gitBlobSha)(g.remoteContent,this.deps.sha1):Fo,m=g.baseContent!==void 0?await(0,Xh.gitBlobSha)(g.baseContent,this.deps.sha1):i.get(h)??Fo;else{if(!u)continue;b=l.get(h)??Fo,m=i.get(h)??Fo}let _=Fo,S;if(d.has(h)&&(S=await f.read(h),_=await(0,Xh.gitBlobSha)(S,this.deps.sha1)),!(_!==b&&_!==m&&b!==m))continue;let E=(S!==void 0?(0,Qh.extractAssetUid)(S):void 0)??g?.uid;p.push({repoKey:e.repoKey,path:h,...E!==void 0?{uid:E}:{},hasLocal:_!==Fo,hasRemote:b!==Fo})}return p}async cachedRecordsFor(e,t){let n=new Map,i=this.deps.conflictCache;if(i===void 0)return n;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&n.set(s,o)}return n}async detectDuplicateUids(e){let t=new Map;for(let i of e){let s=this.deps.localFilesFor(i);for(let o of await s.list()){if(!o.endsWith(".md"))continue;let c;try{c=await s.read(o)}catch{continue}let l=(0,Qh.extractAssetUid)(c);l!==void 0&&t.set(l,(t.get(l)??0)+1)}}let n=0;for(let i of t.values())i>1&&n++;return n}async loadConflict(e,t){let n=this.deps.localFilesFor(e),s=new Set(await n.list()).has(t)?await n.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,c,l;if(o!==null)c=o.remoteContent,l=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);c=d!==void 0?await this.blobText(e,d):void 0;let h=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(g=>g.path===t)?.blobSha;if(h!==void 0)try{l=await this.blobText(e,h)}catch{l=void 0}}let u=(s!==void 0?(0,Qh.extractAssetUid)(s):void 0)??(c!==void 0?(0,Qh.extractAssetUid)(c):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:c!==void 0,...l!==void 0?{base:l}:{},...s!==void 0?{local:s}:{},...c!==void 0?{remote:c}:{}}}async resolve(e,t,n){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,c=this.deps.outbox!==void 0,{remote:l,remoteSha:u}=c?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(n,o,l),d;n.take!=="local"&&o!==void 0&&o!==f&&(d=F$(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let h=f===void 0&&l===void 0||f===l;if(c&&this.deps.outbox!==void 0&&!h&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:n.take==="merged"?"merged":"local",baseRemoteSha:u===Fo?hoe.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:n.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let g;return h||(g=await this.commitChoice(e,t,f)),await this.snapWatermark(e,t,f),this.deps.quarantine?.markResolved!==void 0&&await this.deps.quarantine.markResolved(e.repoKey,t),{repoKey:e.repoKey,path:t,resolvedTo:n.take,...g!==void 0?{pushedSha:g}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let n=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(n!==null){let i=n.remoteContent,s=i!==void 0?await(0,Xh.gitBlobSha)(i,this.deps.sha1):Fo;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??Fo}}chosenContent(e,t,n){switch(e.take){case"local":if(t===void 0)throw new Error("resolve: cannot keep local \u2014 no local version exists on disk");return t;case"remote":return n;case"merged":return e.content}}async commitChoice(e,t,n){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(n===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,poe.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,n]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,n){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(c=>c!==t),o=i.files;if(n===void 0)o=o.filter(c=>c.path!==t);else{let c=await(0,Xh.gitBlobSha)(n,this.deps.sha1),l=(0,Qh.extractAssetUid)(n),u={path:t,blobSha:c,...l!==void 0?{uid:l}:{}},f=o.findIndex(d=>d.path===t);o=f>=0?o.map((d,p)=>p===f?u:d):[...o,u]}await this.deps.watermarkStore.set(e.repoKey,{...i,files:o,...s.length>0?{pinnedPaths:s}:{pinnedPaths:void 0}})}async remoteTreeShas(e){let t=await(0,J_.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,J_.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,J_.getTree)(this.deps.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return s}async blobText(e,t){return(0,J_.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};Jh.QuarantineResolver=$R;function F$(r){return`${r}.conflict.local.txt`}a(F$,"backupPathFor")});var L$=T(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:!0});fd.FileLocalManifestStore=fd.LOCAL_MANIFEST_STORE_FILENAME=void 0;fd.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function moe(r){if(r===null||typeof r!="object")return!1;let e=r;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(moe,"isLocalManifestRecord");var UR=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let n=(await this.readRepos())[e];return moe(n)?n:null}async set(e,t){let n=this.writeChain.then(async()=>{let i=await this.readRepos();i[e]=t;let s={version:1,repos:i};await this.io.writeAtomic(JSON.stringify(s))});return this.writeChain=n.catch(()=>{}),n}async readRepos(){try{let e=await this.io.read();if(e===null)return{};let t=JSON.parse(e);if(t===null||typeof t!="object")return{};let n=t.repos;return n===null||typeof n!="object"?{}:{...n}}catch{return{}}}};fd.FileLocalManifestStore=UR});var GR=T(VR=>{"use strict";Object.defineProperty(VR,"__esModule",{value:!0});VR.diff3=goe;function N$(r,e){let t=r.length,n=e.length,i=Array.from({length:t+1},()=>new Int32Array(n+1));for(let l=t-1;l>=0;l--)for(let u=n-1;u>=0;u--)i[l][u]=r[l]===e[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);let s=new Map,o=0,c=0;for(;o<t&&c<n;)r[o]===e[c]?(s.set(o,c),o++,c++):i[o+1][c]>=i[o][c+1]?o++:c++;return s}a(N$,"lcsMatch");function BR(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}a(BR,"sliceEq");function goe(r,e,t){let n=N$(r,e),i=N$(r,t),s=[],o=0,c=0,l=0;for(;;){let u=o;for(;u<r.length&&!(n.has(u)&&i.has(u));)u++;let f=u<r.length?n.get(u):e.length,d=u<r.length?i.get(u):t.length,p=r.slice(o,u),h=e.slice(c,f),g=t.slice(l,d),m=!BR(h,p),b=!BR(g,p);if(!m&&!b)s.push(...p);else if(!m)s.push(...g);else if(!b)s.push(...h);else if(BR(h,g))s.push(...h);else return{ok:!1,conflict:{base:p,local:h,remote:g}};if(u>=r.length)break;s.push(r[u]),o=u+1,c=f+1,l=d+1}return{ok:!0,merged:s}}a(goe,"diff3")});var M$=T(tm=>{"use strict";Object.defineProperty(tm,"__esModule",{value:!0});tm.StructuredMerger=void 0;tm.splitSections=Z_;var k$=GR(),yoe=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,Zh="exo__Instance_class";function em(r){if(r===null||typeof r!="object")return!0;if(Array.isArray(r))return r.every(em);let e=Object.getPrototypeOf(r);return e!==Object.prototype&&e!==null?!1:Object.values(r).every(em)}a(em,"isPlainValue");function xc(r,e){if(r===e)return!0;if(r===null||e===null||r===void 0||e===void 0||typeof r!="object"||typeof e!="object"||Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)&&Array.isArray(e))return r.length!==e.length?!1:r.every((s,o)=>xc(s,e[o]));let t=r,n=e,i=Object.keys(t);return i.length!==Object.keys(n).length?!1:i.every(s=>xc(t[s],n[s]))}a(xc,"deepEqual");function nu(r){return typeof r=="string"?`s:${r}`:`j:${JSON.stringify(r)}`}a(nu,"setKey");function cs(r){return r==null?[]:Array.isArray(r)?r:[r]}a(cs,"toElements");function boe(r,e,t){let n=new Set(cs(r).map(nu)),i=cs(e),s=cs(t),o=new Set(i.map(nu)),c=new Set(s.map(nu)),l=a(d=>o.has(d)&&c.has(d)||o.has(d)&&!n.has(d)||c.has(d)&&!n.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let p=nu(d);f.has(p)||!l(p)||(f.add(p),u.push(d))}return u}a(boe,"mergeSet");function _oe(r,e,t){let n=[],i=[],s=new Set;for(let c of[...Object.keys(r),...Object.keys(e),...Object.keys(t)])s.has(c)||(s.add(c),i.push(c));let o={};for(let c of i){let l=r[c],u=e[c],f=t[c];if(!em(l)||!em(u)||!em(f))return{ok:!1,reason:`frontmatter key "${c}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(l)||Array.isArray(u)||Array.isArray(f)){if(!(c in e)&&!(c in t))continue;let d=boe(l,u,f),p=new Set(cs(l).map(nu)),h=cs(u).some(m=>!p.has(nu(m))),g=cs(f).some(m=>!p.has(nu(m)));h&&g&&!xc(cs(u),cs(f))&&n.push(`both sides added values to multi-valued key "${c}" \u2014 union kept (D20)`),d.length>0&&(o[c]=d);continue}if(xc(u,f)){u!==void 0&&(o[c]=u);continue}if(xc(u,l)){f!==void 0&&(o[c]=f);continue}if(xc(f,l)){u!==void 0&&(o[c]=u);continue}return{ok:!1,reason:`frontmatter key "${c}" changed differently on both sides`}}return{ok:!0,value:o,warnings:n}}a(_oe,"mergeFrontmatter");var Soe=/^(```|~~~)/,woe=/^#{1,6}\s/;function Z_(r){let e=r.split(`
|
|
336
|
+
`)}a(yse,"stripGitmodulesEntry")});var cd=T(wR=>{"use strict";Object.defineProperty(wR,"__esModule",{value:!0});wR.gitBlobSha=bse;async function bse(r,e){let t=new TextEncoder,n=typeof r=="string"?t.encode(r):r,i=t.encode(`blob ${n.byteLength}\0`),s=new Uint8Array(i.byteLength+n.byteLength);return s.set(i,0),s.set(n,i.byteLength),e(s)}a(bse,"gitBlobSha")});var zh=T(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});G_.extractAssetUid=Zj;G_.detectChanges=Sse;var _se=cd();function Zj(r){let e=/^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/.exec(r);if(!e)return;let t=/^exo__Asset_uid:[ \t]*["']?([^\s"']+)["']?[ \t]*$/m.exec(e[1]);return t?t[1]:void 0}a(Zj,"extractAssetUid");async function Sse(r){let{localFiles:e,cachedEntries:t,watermark:n,actualBaseTreeSha:i,sha1:s}=r;if(n===null)return{kind:"full-conflict",reason:"first-sync"};if(i===null)return{kind:"full-conflict",reason:"base-mismatch",detail:`watermark commit ${n.lastSyncedSha} not resolvable on remote`};if(i!==n.rootTreeSha)return{kind:"full-conflict",reason:"base-mismatch",detail:`stored root tree ${n.rootTreeSha} != actual ${i} at ${n.lastSyncedSha}`};let o=[],c=new Map;for(let[E,w]of e){let R=await(0,_se.gitBlobSha)(w,s);c.set(E,R),o.push({path:E,blobSha:R,uid:typeof w=="string"?Zj(w):void 0})}if(t!==void 0)for(let[E,w]of t)c.set(E,w.blobSha),o.push({path:E,blobSha:w.blobSha,uid:w.uid});let l=[],u=[],f=[],d=[],p=new Map;for(let E of o){if(E.uid===void 0)continue;let w=p.get(E.uid)??[];w.push(E.path),p.set(E.uid,w)}let h=new Map;for(let E of n.files){if(E.uid===void 0)continue;let w=h.get(E.uid)??[];w.push(E.path),h.set(E.uid,w)}let g=new Set;for(let[E,w]of p)w.length>1&&g.add(E);for(let[E,w]of h)w.length>1&&g.add(E);for(let E of[...g].sort()){let w=p.get(E)??[],R=w.length>1?`on disk (${w.join(", ")})`:`in the sync base (${(h.get(E)??[]).join(", ")})`;d.push(`duplicate uid ${E} ${R} \u2014 uid identity suppressed for the group; every path matched by path identity (#3477)`)}let m=new Map,b=[];for(let E of n.files)E.uid!==void 0&&!g.has(E.uid)?m.set(E.uid,E):b.push(E);let _=[],S=new Set;for(let E of o){let w=E.uid!==void 0&&!g.has(E.uid)?m.get(E.uid):void 0;E.uid!==void 0&&w!==void 0?(S.add(E.uid),(w.blobSha!==E.blobSha||w.path!==E.path)&&u.push({path:E.path,uid:E.uid,blobSha:E.blobSha,...w.path!==E.path?{basePath:w.path}:{}})):_.push(E)}let I=new Map;for(let E of b)I.set(E.path,E);for(let[E,w]of m)S.has(E)||I.set(w.path,w);for(let E of _){let w=I.get(E.path);w!==void 0?(I.delete(E.path),w.blobSha!==E.blobSha&&u.push({path:E.path,uid:E.uid,blobSha:E.blobSha})):l.push({path:E.path,uid:E.uid,blobSha:E.blobSha})}for(let E of I.values())f.push({path:E.path,uid:E.uid,blobSha:E.blobSha});return{kind:"changes",added:l,modified:u,deleted:f,warnings:d,diskBlobShas:c,duplicateUids:g}}a(Sse,"detectChanges")});var r$=T(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});Hh.rewriteAssetUid=e$;Hh.findDuplicateUidGroups=t$;Hh.planDuplicateUidFix=Ese;var wse=zh();function e$(r,e){let t=/^(---\r?\n)([\s\S]*?)(\r?\n---(?=\r?\n|$))/.exec(r);if(t===null)return r;let n=t[2].replace(/^(exo__Asset_uid:[ \t]*["']?)[^\s"']+(["']?[ \t]*)$/m,`$1${e}$2`);return n===t[2]?r:r.slice(0,t.index)+t[1]+n+t[3]+r.slice(t.index+t[0].length)}a(e$,"rewriteAssetUid");function t$(r){let e=new Map;for(let t of r){let n=(0,wse.extractAssetUid)(t.content);if(n===void 0)continue;let i=e.get(n)??[];i.push(t.path),e.set(n,i)}return[...e.entries()].filter(([,t])=>t.length>1).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>({uid:t,paths:n}))}a(t$,"findDuplicateUidGroups");function Ese(r,e){let t=new Map(r.map(i=>[i.path,i.content])),n=[];for(let i of t$(r)){let s=[...i.paths].sort((o,c)=>o.localeCompare(c));for(let o of s.slice(1)){let c=t.get(o);if(c===void 0)continue;let l=e(),u=e$(c,l);u!==c&&n.push({path:o,fromUid:i.uid,toUid:l,content:u})}}return n}a(Ese,"planDuplicateUidFix")});var ld=T(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.EMPTY_TREE_SHA=void 0;xo.getHeadSha=Tse;xo.getCommitInfo=Ase;xo.getTree=Ise;xo.getBlobText=Rse;xo.getBlobBytes=Cse;var n$=ef(),vse="https://api.github.com";function Kh(r){return(r??vse).replace(/\/$/,"")}a(Kh,"api");function tu(r){return r!==null&&typeof r=="object"?r:void 0}a(tu,"asRecord");function Co(r,e){let n=tu(r)?.[e];return typeof n=="string"?n:void 0}a(Co,"readString");async function Tse(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/refs/heads/${encodeURIComponent(n)}`}),o=Co(tu(s?.json)?.object,"sha");if(typeof o!="string"||o.length===0)throw new Error(`ExoSync: missing object.sha for ref heads/${n}`);return o}a(Tse,"getHeadSha");async function Ase(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/commits/${encodeURIComponent(n)}`}),o=tu(s?.json),c=Co(o,"sha"),l=Co(o?.tree,"sha");if(!c||!l)throw new Error(`ExoSync: malformed commit response for ${n}`);let u=o?.parents,f=Array.isArray(u)?u.map(d=>Co(d,"sha")).filter(d=>typeof d=="string"):[];return{sha:c,treeSha:l,parents:f}}a(Ase,"getCommitInfo");xo.EMPTY_TREE_SHA="4b825dc642cb6eb9a060e54bf8d69288fbee4904";async function Ise(r,e,t,n,i){if(n===xo.EMPTY_TREE_SHA)return[];let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/trees/${encodeURIComponent(n)}?recursive=1`}),o=tu(s?.json);if(o?.truncated===!0)throw new Error(`ExoSync: tree ${n} is truncated by GitHub (repo too large for recursive listing) \u2014 refusing to diff`);let c=o?.tree;if(!Array.isArray(c))throw new Error(`ExoSync: malformed tree response for ${n}`);let l=[];for(let u of c){let f=tu(u);if(f?.type!=="blob")continue;let d=Co(f,"path"),p=Co(f,"sha"),h=typeof f.size=="number"?f.size:void 0;d&&p&&l.push({path:d,blobSha:p,...h!==void 0?{size:h}:{}})}return l}a(Ise,"getTree");async function Rse(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=tu(s?.json),c=Co(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return Co(o,"encoding")==="utf-8"?c:(0,n$.base64ToUtf8)(c)}a(Rse,"getBlobText");async function Cse(r,e,t,n,i){let s=await r({method:"GET",url:`${Kh(i)}/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}/git/blobs/${encodeURIComponent(n)}`}),o=tu(s?.json),c=Co(o,"content");if(typeof c!="string")throw new Error(`ExoSync: malformed blob response for ${n}`);return Co(o,"encoding")==="utf-8"?new TextEncoder().encode(c):(0,n$.base64ToBytes)(c)}a(Cse,"getBlobBytes")});var s$=T(ER=>{"use strict";Object.defineProperty(ER,"__esModule",{value:!0});ER.checkParkedStaleness=Ose;var xse=ld();async function Ose(r,e){let t={repoKey:r.repoKey,localPath:r.localPath},n=e.redact??(o=>o),i=null;try{let c=(await e.watermarks.get(r.repoKey))?.lastSyncedSha??"";c.length>0&&(i=c)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:null,remoteHeadSha:null,reason:`watermark unreadable: ${n(i$(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,xse.getHeadSha)(e.transport,r.owner,r.repo,r.branch,e.baseURL)}catch(o){return{...t,freshness:"unknown",lastSyncedSha:i,remoteHeadSha:null,reason:`remote unreachable: ${n(i$(o))}`}}return{...t,freshness:s===i?"current":"behind",lastSyncedSha:i,remoteHeadSha:s}}a(Ose,"checkParkedStaleness");function i$(r){return r instanceof Error?r.message:String(r)}a(i$,"errorText")});var AR=T(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.SyncPhaseTimer=mr.SYNC_PHASES=void 0;mr.classifyRestPhase=Pse;mr.emptyTimings=a$;mr.totalMs=q_;mr.addTimings=c$;mr.aggregateTimings=Fse;mr.dominantPhase=Dse;mr.fmtMs=Yh;mr.formatTimingsLine=Lse;mr.formatRepoTimings=Nse;mr.SYNC_PHASES=["localList","localRead","localWrite","hash","restHead","restCommit","restTree","restBlob","restPush"];function TR(){let r={};for(let e of mr.SYNC_PHASES)r[e]=0;return r}a(TR,"zeroDurations");function o$(){return{filesRead:0,filesHashed:0,filesWritten:0,restCalls:0}}a(o$,"zeroCounts");function Pse(r){if(r.method!=="GET")return"restPush";let e=r.url;return e.includes("/git/blobs/")?"restBlob":e.includes("/git/trees/")?"restTree":e.includes("/git/commits/")?"restCommit":e.includes("/git/refs/")?"restHead":"restCommit"}a(Pse,"classifyRestPhase");var vR=class{static{a(this,"SyncPhaseTimer")}constructor(e){this.now=e,this.durations=TR(),this.counts=o$()}async time(e,t){let n=this.now();try{return await t()}finally{this.durations[e]+=this.now()-n}}bumpRead(){this.counts.filesRead++}bumpHashed(){this.counts.filesHashed++}bumpWritten(){this.counts.filesWritten++}bumpRest(){this.counts.restCalls++}snapshot(){return{durations:{...this.durations},counts:{...this.counts}}}};mr.SyncPhaseTimer=vR;function a$(){return{durations:TR(),counts:o$()}}a(a$,"emptyTimings");function q_(r){let e=0;for(let t of mr.SYNC_PHASES)e+=r.durations[t];return e}a(q_,"totalMs");function c$(r,e){let t=TR();for(let n of mr.SYNC_PHASES)t[n]=r.durations[n]+e.durations[n];return{durations:t,counts:{filesRead:r.counts.filesRead+e.counts.filesRead,filesHashed:r.counts.filesHashed+e.counts.filesHashed,filesWritten:r.counts.filesWritten+e.counts.filesWritten,restCalls:r.counts.restCalls+e.counts.restCalls}}}a(c$,"addTimings");function Fse(r){let e=a$();for(let t of r)t.timings!==void 0&&(e=c$(e,t.timings));return e}a(Fse,"aggregateTimings");function Dse(r){let e=q_(r);if(e<=0)return null;let t=mr.SYNC_PHASES[0],n=-1;for(let i of mr.SYNC_PHASES)r.durations[i]>n&&(n=r.durations[i],t=i);return{phase:t,ms:n,pct:n/e*100}}a(Dse,"dominantPhase");function Yh(r){return r>=1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`}a(Yh,"fmtMs");function Lse(r){let e=q_(r);if(e<=0)return"";let t=mr.SYNC_PHASES.filter(n=>r.durations[n]>0).sort((n,i)=>r.durations[i]-r.durations[n]).map(n=>`${n} ${Yh(r.durations[n])} ${Math.round(r.durations[n]/e*100)}%`);return`\u23F1 ExoSync ${Yh(e)} \u2014 ${t.join(" \xB7 ")} (${r.counts.filesHashed} hashed, ${r.counts.filesRead} read, ${r.counts.restCalls} REST)`}a(Lse,"formatTimingsLine");function Nse(r,e){let t=mr.SYNC_PHASES.map(n=>`${n}=${Yh(e.durations[n])}`);return`[ExoSync timings] ${r}: total ${Yh(q_(e))} \u2014 ${t.join(" ")} | hashed ${e.counts.filesHashed} read ${e.counts.filesRead} written ${e.counts.filesWritten} REST ${e.counts.restCalls}`}a(Nse,"formatRepoTimings")});var W_=T(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.LocalOutboxStore=Rc.OUTBOX_REMOTE_ABSENT=Rc.OUTBOX_STORE_FILENAME=void 0;Rc.OUTBOX_STORE_FILENAME="exosync-outbox.local.json";Rc.OUTBOX_REMOTE_ABSENT=" absent";function IR(r,e){return`${r}\0${e}`}a(IR,"outboxKey");function l$(r){if(r===null||typeof r!="object")return!1;let e=r;return typeof e.repoKey=="string"&&typeof e.path=="string"&&typeof e.chosenContent=="string"&&typeof e.baseRemoteSha=="string"}a(l$,"isEntry");var RR=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[IR(e.repoKey,e.path)]={version:1,...e,resolvedAt:e.resolvedAt.length>0?e.resolvedAt:this.now()}})}async remove(e,t){await this.mutate(n=>{delete n.entries[IR(e,t)]})}async list(){let e=await this.read();return Object.values(e.entries).filter(l$)}async listForRepo(e){return(await this.list()).filter(t=>t.repoKey===e)}async has(e,t){let i=(await this.read()).entries[IR(e,t)];return i!==void 0&&l$(i)}async mutate(e){let t=this.writeChain.then(async()=>{let n=await this.read();e(n),await this.io.writeAtomic(JSON.stringify(n,null,2))});return this.writeChain=t.catch(()=>{}),t}async read(){try{let e=await this.io.read();if(e===null)return{version:1,entries:{}};let t=JSON.parse(e);if(t===null||typeof t!="object")return{version:1,entries:{}};let n=t.entries;return n===null||typeof n!="object"?{version:1,entries:{}}:{version:1,entries:{...n}}}catch{return{version:1,entries:{}}}}};Rc.LocalOutboxStore=RR});var z_=T(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.SpaceSpecAccumulator=Bn.SYNC_BRANCH=Bn.ASSET_SPACE_CLASS_UID=void 0;Bn.isAssetSpaceFrontmatter=d$;Bn.isFileSpaceFrontmatter=p$;Bn.readSpaceSource=h$;Bn.parseStrictGitHubRepoURL=m$;Bn.classifySpaceDeclaration=$se;var kse=_b(),Mse=bb();Bn.ASSET_SPACE_CLASS_UID="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb";Bn.SYNC_BRANCH="main";var u$=/\[\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\|[^\]]*)?\]\]/gi;function f$(r,e){let t=r.exo__Instance_class,n=Array.isArray(t)?t:[t];for(let i of n){if(typeof i!="string")continue;u$.lastIndex=0;let s;for(;(s=u$.exec(i))!==null;)if(s[1].toLowerCase()===e)return!0}return!1}a(f$,"instanceClassHasUid");function d$(r){return f$(r,Bn.ASSET_SPACE_CLASS_UID)}a(d$,"isAssetSpaceFrontmatter");function p$(r){return f$(r,kse.FILE_SPACE_CLASS_UID)}a(p$,"isFileSpaceFrontmatter");function h$(r){let e=r.exo__AssetSpace_source;if(typeof e=="string"&&e.length>0)return e;let t=r.exo__AssetSpace_git;return typeof t=="string"&&t.length>0?t:null}a(h$,"readSpaceSource");var jse=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/;function m$(r){if(typeof r!="string"||r.length===0||r.length>256||!jse.test(r))return null;let e=r.slice(19),[t,n,...i]=e.split("/");if(i.length>0||t===".."||n===".."||n.startsWith("."))return null;let s=n.replace(/\.git$/,"");return s.length===0?null:{owner:t,repo:s}}a(m$,"parseStrictGitHubRepoURL");function $se(r,e){let t=d$(r),n=p$(r);if(!t&&!n)return{kind:"not-space"};let i;t&&n&&(i=`declaration at ${e} carries BOTH exo__AssetSpace and exo__FileSpace classes (disjoint) \u2014 treating as AssetSpace (conservative)`);let s=t?"asset":"file",o=h$(r);if(o===null)return s==="file"?{kind:"skip",warning:`skipped FileSpace at ${e}: no exo__AssetSpace_source/_git \u2014 mount path underivable`}:{kind:"skip"};let c=o.replace(/\.git$/i,""),l=m$(c);if(l===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: source is not a plain https://github.com/<owner>/<repo> URL`};let u=(0,Mse.derivePath)(c);if(u===null)return{kind:"skip",warning:`skipped AssetSpace at ${e}: cannot derive mount path from source`};let f=`${l.owner}/${l.repo}#${Bn.SYNC_BRANCH}`,d=r.exo__Asset_uid,p=typeof d=="string"&&d.trim().length>0?d.trim():void 0;return{kind:"candidate",candidate:{spec:{owner:l.owner,repo:l.repo,branch:Bn.SYNC_BRANCH,repoKey:f,localPath:u,...s==="file"?{spaceKind:s}:{}},spaceKind:s,...p!==void 0?{asUid:p}:{}},...i!==void 0?{warning:i}:{}}}a($se,"classifySpaceDeclaration");var CR=class{static{a(this,"SpaceSpecAccumulator")}constructor(){this.specs=[],this.warnings=[],this.asUidByRepoKey=new Map,this.seen=new Set,this.kindByRepoKey=new Map}offer(e){let{spec:t,spaceKind:n}=e;if(this.seen.has(t.repoKey)){let i=this.kindByRepoKey.get(t.repoKey);if(i!==void 0&&i!==n&&(this.warnings.push(`repo ${t.repoKey} is declared as BOTH AssetSpace and FileSpace by different assets \u2014 treating as AssetSpace (deterministic, conservative); fix the vault (disjoint subtypes)`),i==="file")){this.kindByRepoKey.set(t.repoKey,"asset");let s=this.specs.find(o=>o.repoKey===t.repoKey);s!==void 0&&delete s.spaceKind}return null}return this.seen.add(t.repoKey),this.kindByRepoKey.set(t.repoKey,n),t}commit(e){this.specs.push(e.spec),e.asUid!==void 0&&this.asUidByRepoKey.set(e.spec.repoKey,e.asUid)}};Bn.SpaceSpecAccumulator=CR});var H_=T(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:!0});ud.REF_NOT_FOUND_HINT=void 0;ud.isAuthError=Use;ud.isRefNotFoundError=Bse;var g$=z_();function Use(r){let e=r instanceof Error?r.message:String(r);return/HTTP 401/.test(e)?!0:/HTTP 403/.test(e)&&!/rate limit/i.test(e)&&!/abuse detection/i.test(e)}a(Use,"isAuthError");function Bse(r){let e=r instanceof Error?r.message:String(r);return/\/git\/refs\/heads\/\S* → HTTP 404\b/.test(e)}a(Bse,"isRefNotFoundError");ud.REF_NOT_FOUND_HINT=`GitHub answers 404 for a private repo outside a fine-grained PAT's repository allowlist (existence-hiding), for a deleted/renamed repo, and for a visible repo that has no \`${g$.SYNC_BRANCH}\` branch (ExoSync syncs \`${g$.SYNC_BRANCH}\` only) \u2014 check the token's repository allowlist first (R8)`});var xR=T(K_=>{"use strict";Object.defineProperty(K_,"__esModule",{value:!0});K_.scanForSecrets=Vse;K_.redactSecrets=Gse;var y$=[{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 Vse(r){let e=[];for(let[t,n]of r)for(let{kind:i,re:s}of y$)s.test(n)&&e.push({path:t,kind:i});return e}a(Vse,"scanForSecrets");function Gse(r){let e=r;for(let{kind:t,re:n}of y$)e=e.replace(new RegExp(n.source,"g"),`[REDACTED:${t}]`);return e}a(Gse,"redactSecrets")});var FR=T(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});Cc.caseInsensitiveHeaderGetter=qse;Cc.parseRetryAfterMs=b$;Cc.extractRateLimitFields=_$;Cc.getRateLimitFields=Wse;Cc.attachRateLimitFields=S$;Cc.enrichRateLimitError=zse;function qse(r){let e=new Map;if(r&&typeof r=="object")for(let[t,n]of Object.entries(r))typeof n=="string"&&e.set(t.toLowerCase(),n);return t=>e.get(t.toLowerCase())}a(qse,"caseInsensitiveHeaderGetter");function PR(r){if(r==null)return;let e=r.trim();if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0}a(PR,"parseIntHeader");function b$(r,e=Date.now){if(r==null)return;let t=r.trim();if(t.length===0)return;let n=PR(t);if(n!==void 0)return Math.max(0,n*1e3);let i=Date.parse(t);if(!Number.isNaN(i))return Math.max(0,i-e())}a(b$,"parseRetryAfterMs");function _$(r,e=Date.now){let t={},n=b$(r("retry-after"),e);n!==void 0&&(t.retryAfterMs=n);let i=PR(r("x-ratelimit-reset"));i!==void 0&&(t.rateLimitReset=i);let s=PR(r("x-ratelimit-remaining"));return s!==void 0&&(t.rateLimitRemaining=s),t}a(_$,"extractRateLimitFields");function Wse(r){if(r===null||typeof r!="object")return{};let e=r,t={};return typeof e.retryAfterMs=="number"&&(t.retryAfterMs=e.retryAfterMs),typeof e.rateLimitReset=="number"&&(t.rateLimitReset=e.rateLimitReset),typeof e.rateLimitRemaining=="number"&&(t.rateLimitRemaining=e.rateLimitRemaining),t}a(Wse,"getRateLimitFields");function OR(r,e,t){Object.defineProperty(r,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}a(OR,"defineHidden");function S$(r,e){return e.retryAfterMs!==void 0&&OR(r,"retryAfterMs",e.retryAfterMs),e.rateLimitReset!==void 0&&OR(r,"rateLimitReset",e.rateLimitReset),e.rateLimitRemaining!==void 0&&OR(r,"rateLimitRemaining",e.rateLimitRemaining),r}a(S$,"attachRateLimitFields");function zse(r,e,t=Date.now){return S$(r,_$(e,t))}a(zse,"enrichRateLimitError")});var Y_=T(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.DEFAULT_MAX_RETRIES=as.MIN_RATE_LIMIT_WAIT_MS=void 0;as.isRateLimitError=w$;as.createRateLimitBudget=Kse;as.withRateLimitBackoff=Qse;var Hse=FR();function w$(r){let e=r instanceof Error?r.message:String(r);return/HTTP 429/.test(e)?!0:/HTTP 403/.test(e)&&(/rate limit/i.test(e)||/abuse detection/i.test(e))}a(w$,"isRateLimitError");as.MIN_RATE_LIMIT_WAIT_MS=6e4;as.DEFAULT_MAX_RETRIES=6;function Kse(r){let e=!(r>0),t=e?Number.POSITIVE_INFINITY:r;return{reset(){t=e?Number.POSITIVE_INFINITY:r},tryReserve(n){return n<=0?!0:n<=t?(t-=n,!0):!1}}}a(Kse,"createRateLimitBudget");var Yse=a(r=>new Promise(e=>setTimeout(e,r)),"defaultSleep");function Xse(r,e,t,n,i,s){let o=(0,Hse.getRateLimitFields)(r);if(typeof o.retryAfterMs=="number"&&o.retryAfterMs>=0)return o.retryAfterMs;if(o.rateLimitRemaining===0&&typeof o.rateLimitReset=="number"){let l=o.rateLimitReset*1e3-s();if(l>0)return l}let c=t*2**e*(1+i());return Math.max(n,c)}a(Xse,"computeRateLimitDelay");function Qse(r,e={}){let t=e.maxRetries??as.DEFAULT_MAX_RETRIES,n=e.baseDelayMs??1e3,i=Math.max(as.MIN_RATE_LIMIT_WAIT_MS,e.minRateLimitWaitMs??as.MIN_RATE_LIMIT_WAIT_MS),s=e.budget,o=e.sleep??Yse,c=e.random??Math.random,l=e.now??(()=>Date.now());return async u=>{let f=0;for(;;)try{return await r(u)}catch(d){if(!w$(d)||f>=t)throw d;let p=Xse(d,f,n,i,c,l);if(s!==void 0&&!s.tryReserve(p))throw d;f++,await o(p)}}}a(Qse,"withRateLimitBackoff")});var X_=T(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.DEFAULT_MAX_FILE_BYTES=La.InMemoryQuarantineStore=void 0;La.contentEquals=Jse;La.isSyncablePath=Zse;La.isFileSpaceSyncablePath=eoe;function Jse(r,e){if(r===void 0||e===void 0||typeof r=="string"&&typeof e=="string")return r===e;if(typeof r=="string"||typeof e=="string"||r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}a(Jse,"contentEquals");var DR=class{static{a(this,"InMemoryQuarantineStore")}constructor(){this.entries=[]}async quarantine(e){this.entries.push(e)}};La.InMemoryQuarantineStore=DR;function Zse(r){return r.endsWith(".md")&&!r.includes(".local.")&&!r.includes(".conflict.")}a(Zse,"isSyncablePath");function eoe(r){return!r.includes(".local.")&&!r.includes(".conflict.")}a(eoe,"isFileSpaceSyncablePath");La.DEFAULT_MAX_FILE_BYTES=30*1024*1024});var P$=T(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.SyncEngine=Tn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=Tn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=Tn.DEFAULT_MAX_PUSH_RETRIES=void 0;Tn.syncProgressPhaseText=roe;Tn.isNonFastForwardError=O$;Tn.orderChildrenFirst=uoe;var E$=B_(),v$=AR(),dt=ld(),Oo=zh(),toe=ef(),ru=cd(),LR=W_(),NR=H_(),T$=xR(),A$=Y_(),Po=X_();Tn.DEFAULT_MAX_PUSH_RETRIES=3;Tn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS=3e5;Tn.DEFAULT_LOCAL_MANIFEST_REHASH_MS=720*60*1e3;function roe(r){switch(r.phase){case"reading-local":return r.detail!==void 0?`reading local files ${r.detail.done}\u2026`:"reading local files\u2026";case"detecting":return"detecting changes\u2026";case"pulling-remote":return"pulling remote tree\u2026";case"fetching-blobs":return r.detail!==void 0?`fetching remote files ${r.detail.done}/${r.detail.total}\u2026`:"fetching remote files\u2026";case"writing-files":return r.detail!==void 0?`writing files ${r.detail.done}\u2026`:"writing files\u2026";case"merging":return"merge layer firing\u2026";default:return r.phase}}a(roe,"syncProgressPhaseText");var I$=25,noe=10,ioe=6,soe=500,ooe=25;function aoe(r){try{return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{return null}}a(aoe,"decodeUtf8Strict");function coe(r){return typeof r=="string"?r:{base64:(0,toe.bytesToBase64)(r)}}a(coe,"toCommitContent");async function R$(r,e){if(r.readBinary===void 0)throw new Error("LocalFilesPort.readBinary is required for file-mode sync (Phase C)");return r.readBinary(e)}a(R$,"readBinaryStrict");async function loe(r,e,t){if(r.writeBinary===void 0)throw new Error("LocalFilesPort.writeBinary is required for file-mode sync (Phase C)");return r.writeBinary(e,t)}a(loe,"writeBinaryStrict");function C$(r){return r.length===0||r.startsWith("/")||r.includes("\\")?!1:r.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}a(C$,"isSafeRepoRelativePath");function O$(r){let e=r instanceof Error?r.message:String(r);return/HTTP 422/.test(e)&&/git\/refs/.test(e)||/ref update mismatch/.test(e)||/HTTP 422/.test(e)&&/git\/trees/.test(e)&&/BadObjectState/.test(e)}a(O$,"isNonFastForwardError");function uoe(r){let e=a(t=>t.split("/").filter(n=>n.length>0).length,"depth");return[...r].sort((t,n)=>e(n.localPath)-e(t.localPath))}a(uoe,"orderChildrenFirst");function x$(r,e){let t=new Map(r.map(o=>[o.path,o])),n=new Set,i=[];for(let o of e){n.add(o.path);let c=t.get(o.path);(c===void 0||c.blobSha!==o.blobSha)&&i.push(o)}let s=r.filter(o=>!n.has(o.path));return{changed:i,deleted:s}}a(x$,"diffTrees");function foe(r){let e=r instanceof Error?r.message:String(r);return/→ HTTP (?:404|422)\b/.test(e)}a(foe,"isCommitUnknownError");function Na(r){return r instanceof Error?r.message:String(r)}a(Na,"errMsg");function doe(r,e,t){if(t.size===0)return r;let n=new Map(e.files.map(o=>[o.path,o])),i=new Set(r.map(o=>o.path)),s=[];for(let o of r){if(!t.has(o.path)){s.push(o);continue}let c=n.get(o.path);c!==void 0&&s.push(c)}for(let o of t){if(i.has(o))continue;let c=n.get(o);c!==void 0&&s.push(c)}return s}a(doe,"applyWatermarkPins");var kR={mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:[],mergedCount:0,mergedPaths:[],warnings:[]};function MR(r){return new Map(r.map(e=>[e.path,e.blobSha]))}a(MR,"treeByPath");function Q_(r){return[...r.quarantineEntries.map(e=>e.path),...r.resolvedQuarantineEntries.map(e=>e.path)]}a(Q_,"quarantinedPathsOf");var jR=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,A$.createRateLimitBudget)(e.backoff?.maxTotalRateLimitWaitMs??Tn.DEFAULT_MAX_TOTAL_RATELIMIT_WAIT_MS),this.transport=this.instrumentTransport((0,A$.withRateLimitBackoff)(e.transport,{...e.backoff,budget:this.rateLimitBudget,now:this.now})),this.sha1=this.instrumentSha1(e.sha1)}instrumentTransport(e){return async t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpRest(),n.time((0,v$.classifyRestPhase)(t),()=>e(t)))}}instrumentSha1(e){return t=>{let n=this.activeTimer;return n===null?e(t):(n.bumpHashed(),n.time("hash",()=>e(t)))}}instrumentLocalFiles(e){let t=a((c,l)=>{let u=this.activeTimer;return u===null?l():u.time(c,l)},"timed"),n={list:a(()=>t("localList",()=>e.list()),"list"),read:a(c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>e.read(c))),"read"),write:a((c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),e.write(c,l))),"write"),delete:a(c=>e.delete(c),"delete")},i=e.readBinary?.bind(e);i!==void 0&&(n.readBinary=c=>(this.activeTimer?.bumpRead(),this.bumpReadProgress(),t("localRead",()=>i(c))));let s=e.writeBinary?.bind(e);s!==void 0&&(n.writeBinary=(c,l)=>t("localWrite",()=>(this.activeTimer?.bumpWritten(),this.bumpWriteProgress(),s(c,l))));let o=e.stat?.bind(e);return o!==void 0&&(n.stat=c=>t("localList",()=>o(c))),n}busyResult(e){return{repoKey:e.repoKey,status:"busy",pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:[],deferredDeletes:[],detail:"another sync operation is in progress (D11 guard) \u2014 retry after it finishes"}}modeOps(e){let t=e.spaceKind==="file",n=t?Po.isFileSpaceSyncablePath:Po.isSyncablePath,i=this.deps.maxFileBytes??Po.DEFAULT_MAX_FILE_BYTES;return{fileMode:t,syncable:n,treeFilter:a(s=>n(s.path)&&(!t||s.size===void 0||s.size<=i),"treeFilter")}}async buildFileModeFirstSyncBase(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),c=(await(0,dt.getTree)(this.transport,e.owner,e.repo,o.treeSha,this.deps.baseURL)).filter(n.treeFilter),l=[];for(let u of c){let f=t.get(u.path);f!==void 0&&await(0,ru.gitBlobSha)(f,this.sha1)===u.blobSha&&l.push({path:u.path,blobSha:u.blobSha})}return i.push(`first-sync (file mode): synthetic base from ${l.length} already-identical file(s) at head ${s} \u2014 divergence resolves through the remote-wins layer (D22)`),{lastSyncedSha:s,rootTreeSha:o.treeSha,files:l,spaceKind:"file"}}async syncAll(e,t="sync",n){if(this.opInProgress)return e.map(i=>this.busyResult(i));this.opInProgress=!0,this.rateLimitBudget.reset();try{let i=[];for(let s of e)i.push(await this.syncLocked(s,t,n));return i}finally{this.opInProgress=!1}}async sync(e,t="sync",n){if(this.opInProgress)return this.busyResult(e);this.opInProgress=!0,this.rateLimitBudget.reset();try{return await this.syncLocked(e,t,n)}finally{this.opInProgress=!1}}emitProgress(e,t,n,i){if(e!==void 0)try{e(i===void 0?{repoKey:t,phase:n}:{repoKey:t,phase:n,detail:i})}catch{}}bumpReadProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.reads+=1,e.reads%soe===0&&this.emitProgress(e.emit,e.repoKey,"reading-local",{done:e.reads}))}bumpWriteProgress(){let e=this.activeLocalIoProgress;e!==null&&(e.writes+=1,e.writes%ooe===0&&this.emitProgress(e.emit,e.repoKey,"writing-files",{done:e.writes}))}async syncLocked(e,t="sync",n){let i=new v$.SyncPhaseTimer(this.now),s=this.activeTimer;this.activeTimer=i;let o=this.activeLocalIoProgress;this.activeLocalIoProgress=n!==void 0?{emit:n,repoKey:e.repoKey,reads:0,writes:0}:null;let c=[],l=[],u=0,f=0,d=[],p=a((h,g={})=>({repoKey:e.repoKey,status:h,pulledCount:0,pushedCount:0,mergedCount:0,quarantinedCount:0,warnings:c,deferredDeletes:l,...u>0?{outboxPushedCount:u}:{},...f>0?{outboxReconflictedCount:f}:{},timings:i.snapshot(),...g}),"result");try{let h=await this.deps.materializationCheck.check(e);if(!h.fullyMaterialized)return c.push(`skipped: repo not fully materialized${h.reason?` (${h.reason})`:""} \u2014 deletes NOT inferred (D19)`),p("skipped-not-materialized");let g=this.modeOps(e),m=this.instrumentLocalFiles(this.deps.localFilesFor(e));if(g.fileMode&&(m.readBinary===void 0||m.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(g.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??Po.DEFAULT_MAX_FILE_BYTES;if(t!=="pull"&&this.deps.outbox!==void 0){let U=await this.flushOutbox(e,c);u=U.pushed,f=U.reconflicted}let _=await this.deps.watermarkStore.get(e.repoKey);if(_?.spaceKind==="file"&&!g.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)"});_!==null&&g.fileMode&&_.spaceKind!=="file"&&(c.push("watermark was written by an ASSET-mode sync \u2014 rebuilding the base through the file-mode first-sync layer (kind flip)"),_=null);let S=this.deps.localManifestStore!==void 0?m.stat?.bind(m):void 0,I=S!==void 0&&_!==null&&!g.fileMode,E=I&&this.deps.localManifestStore!==void 0?await this.deps.localManifestStore.get(e.repoKey):null,w=this.deps.localManifestFullRehashMs??Tn.DEFAULT_LOCAL_MANIFEST_REHASH_MS,R=I&&(E===null||this.now()-E.lastFullRehashMs>=w),x=new Map,P=new Set,k=new Map,B=new Map,D=new Map,Q=!1,fe=new Map;if(I&&_!==null)for(let U of _.files)fe.set(U.path,U.blobSha);for(let U of(await m.list()).filter(g.syncable)){if(g.fileMode){let ae=await R$(m,U);if(ae.byteLength>b){P.add(U),c.push(`skipped oversized file ${U} (${ae.byteLength} bytes > ${b} cap) \u2014 excluded from sync symmetrically (Phase C size cap)`);continue}x.set(U,ae);continue}if(!I||S===void 0){x.set(U,await m.read(U));continue}let F=await S(U),H=!R&&F!==null?E?.files[U]:void 0;if(F!==null&&H!==void 0&&H.mtimeMs===F.mtimeMs&&H.size===F.size&&H.blobSha===fe.get(U)){k.set(U,{blobSha:H.blobSha,...H.uid!==void 0?{uid:H.uid}:{}}),B.set(U,H.blobSha),D.set(U,F);continue}Q=!0,x.set(U,await m.read(U)),F!==null&&D.set(U,F)}let j=!1;if(_===null)if(g.fileMode)j=!0,_=await this.buildFileModeFirstSyncBase(e,x,g,c);else{let U=await this.bootstrapWatermark(e,x,c,p);if(U.kind==="settled")return U.outcome;j=!0,_=U.base}let ce=_;g.fileMode&&P.size>0&&(_={..._,files:_.files.filter(U=>!P.has(U.path))});let V,oe;I&&!R?(V=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),oe=V===_.lastSyncedSha?_.rootTreeSha:await this.resolveBaseTreeSha(e,_,{headReachable:!0})):oe=await this.resolveBaseTreeSha(e,_),this.emitProgress(n,e.repoKey,"detecting");let K=await(0,Oo.detectChanges)({localFiles:x,...I?{cachedEntries:k}:{},watermark:_,actualBaseTreeSha:oe,sha1:this.sha1});if(K.kind==="full-conflict")return p("full-conflict",{detail:`${K.reason}${K.detail?`: ${K.detail}`:""} \u2014 divergence must go through merge/quarantine (A2/A3), not overwrite`});if(c.push(...K.warnings),I&&this.deps.localManifestStore!==void 0){let U={};for(let[F,H]of x){let ae=D.get(F),Se=K.diskBlobShas.get(F);if(ae===void 0||Se===void 0)continue;let Ce=typeof H=="string"?(0,Oo.extractAssetUid)(H):void 0;U[F]={mtimeMs:ae.mtimeMs,size:ae.size,blobSha:Se,...Ce!==void 0?{uid:Ce}:{}}}for(let[F,H]of k){let ae=D.get(F);ae!==void 0&&(U[F]={mtimeMs:ae.mtimeMs,size:ae.size,blobSha:H.blobSha,...H.uid!==void 0?{uid:H.uid}:{}})}if(E!==null&&Object.keys(E.files).some(F=>!(F in U))&&(Q=!0),Q||R||E===null){let F={version:1,files:U,lastFullRehashMs:R||E===null?this.now():E.lastFullRehashMs};await this.deps.localManifestStore.set(e.repoKey,F)}}let z=this.pinLocalChanges(K,x,c,l,t);d=[...z.pushDeletionsAll.keys()];let Z=await this.runPushLoop(e,_,z,x,c,g,j,P,t,n,V);if(d=[],Z.kind!=="done"&&z.pushDeletionsAll.size>0&&l.push(...z.pushDeletionsAll.keys()),Z.kind==="conflict")return p("conflict",{detail:Z.detail});if(Z.kind==="retry-exhausted"){c.push(...Z.merge.warnings);let U=await this.buildTerminalQuarantineEntries(e,_,Z.pushFiles,Z.merge.quarantineEntries,x),F=[...Z.merge.quarantineEntries,...Z.merge.resolvedQuarantineEntries,...U];return await this.flushQuarantine(F,c),p("retry-exhausted",{detail:Z.detail,quarantinedCount:F.length,...F.length>0?{quarantinedPaths:F.map(H=>H.path)}:{}})}let{examinedHead:Ie,pushedSha:ee,applyWrites:Y,applyDeletes:se,pushFiles:X}=Z,le=Z.merge;c.push(...le.warnings),c.push(...Z.deferredWarnings),l.push(...Z.withheldDeletions);let Ue=Z.deferredPaths.size>0?{deferredPaths:[...Z.deferredPaths]}:{},$=Z.pushedDeletions.length>0?{pushedDeletes:Z.pushedDeletions}:{},de=await this.flushQuarantine([...le.quarantineEntries,...le.resolvedQuarantineEntries],c);Z.secretQuarantineEntries.length>0&&await this.flushQuarantine(Z.secretQuarantineEntries,c);let ie=new Set;if(!de&&le.resolvedQuarantineEntries.length>0){for(let U of le.resolvedQuarantineEntries)ie.add(U.path);c.push(`quarantine flush failed \u2014 remote-wins apply withheld for ${ie.size} path(s); local files untouched, conflict re-derives next sync (D18 durability gate)`)}if(ee===void 0&&Ie===_.lastSyncedSha&&Y.length===0&&se.length===0&&le.mergedWrites.length===0&&le.quarantineEntries.length===0&&le.resolvedQuarantineEntries.length===0&&(_.pinnedPaths?.length??0)===0&&Z.alreadyInHead.length===0&&Z.deferredPaths.size===0&&!j)return p("synced");let Ae=ee??Ie,ye=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,Ae,this.deps.baseURL);if(ee!==void 0&&ye.parents[0]!==Ie)return await this.checkRaceWindow(e,_,Ie,ye.parents[0],X,new Set(Z.pushedDeletions),c,g),c.push(`race-window: watermark NOT advanced (pushed commit's parent ${ye.parents[0]} != examined head ${Ie}) \u2014 next sync reconciles the concurrent change`),p("synced",{pushedSha:ee,pushedCount:X.size,mergedCount:le.mergedCount,quarantinedCount:le.quarantineEntries.length+le.resolvedQuarantineEntries.length,...le.mergedPaths.length>0?{mergedPaths:le.mergedPaths}:{},...Q_(le).length>0?{quarantinedPaths:Q_(le)}:{},...Ue,...$});let{pulledCount:ve,pinnedPaths:Re,pulledPaths:pe}=await this.applyRemoteChanges(m,x,[...Y,...le.mergedWrites].filter(U=>!ie.has(U.path)),se.filter(U=>!ie.has(U.path)),c,B);for(let U of le.quarantineEntries)Re.add(U.path);for(let U of Z.deferredPaths)Re.add(U);for(let U of ie)Re.add(U);if(g.fileMode){for(let U of P)Re.add(U);for(let U of Z.remoteOversized)Re.add(U)}return await this.advanceWatermark(e,Ae,ye.treeSha,x,[...Y,...le.mergedWrites,...Z.deferredRemoteChanges],ce,Re,K.diskBlobShas,g,P),await this.resolveClearedPins(e,ce,Re,c,new Set(le.resolvedQuarantineEntries.map(U=>U.path))),p("synced",{pushedSha:ee,pulledCount:ve,pushedCount:X.size,mergedCount:le.mergedCount,quarantinedCount:le.quarantineEntries.length+le.resolvedQuarantineEntries.length,...le.mergedPaths.length>0?{mergedPaths:le.mergedPaths}:{},...pe.length>0?{pulledPaths:pe}:{},...Q_(le).length>0?{quarantinedPaths:Q_(le)}:{},...Ue,...$})}catch(h){let g=this.deps.redact??(m=>m);if(d.length>0&&l.push(...d),(0,NR.isAuthError)(h))return p("auth-required",{detail:g(`authentication failed: ${Na(h)} \u2014 the PAT is expired, revoked or under-scoped; update it in the per-device secure storage (R8). Never treated as success.`)});if((0,NR.isRefNotFoundError)(h)){let m=g(`${e.owner}/${e.repo}@${e.branch} is not reachable: ${Na(h)} \u2014 ${NR.REF_NOT_FOUND_HINT}`);return c.push(`sync failed: ${m}`),p("error",{detail:m})}return c.push(`sync failed: ${g(Na(h))}`),p("error",{detail:g(Na(h))})}finally{this.activeTimer=s,this.activeLocalIoProgress=o}}async flushQuarantine(e,t){if(e.length===0)return!0;let n=this.deps.redact??(s=>s);for(let s of e)t.push(n(`quarantined ${s.path}: ${s.reason}`));let i=this.deps.quarantine;if(i===void 0)return!1;try{if(i.quarantineAll!==void 0)await i.quarantineAll(e);else for(let s of e)await i.quarantine(s);return!0}catch(s){let o=this.deps.redact??(c=>c);return t.push(`quarantine sink failed: ${o(Na(s))} \u2014 files untouched on disk; the conflict re-derives next sync (D17 degradation)`),!1}}async flushOutbox(e,t){let n=this.deps.outbox;if(n===void 0)return{pushed:0,reconflicted:0};let i=await n.listForRepo(e.repoKey);if(i.length===0)return{pushed:0,reconflicted:0};let s=this.deps.redact??(g=>g),o,c;try{({head:o,shaByPath:c}=await this.outboxHeadTreeShas(e))}catch(g){return t.push(`outbox flush deferred (${i.length} resolution(s) awaiting push): ${s(Na(g))}`),{pushed:0,reconflicted:0}}let l=0,u=[];for(let g of i){let m=c.get(g.path)??LR.OUTBOX_REMOTE_ABSENT,b=m===LR.OUTBOX_REMOTE_ABSENT&&g.baseRemoteSha!==LR.OUTBOX_REMOTE_ABSENT?[...c].filter(([_,S])=>_!==g.path&&S===g.baseRemoteSha).map(([_])=>_):[];if(m!==g.baseRemoteSha&&b.length===0){await n.remove(g.repoKey,g.path),l++,t.push(s(`outbox: remote moved for ${g.path} since you resolved it \u2014 NOT pushed; resolve again (your choice is preserved on disk)`));continue}u.push({entry:g,stalePaths:b})}if(u.length===0)return{pushed:0,reconflicted:l};let f=new Map;for(let{entry:g}of u)f.set(g.path,g.chosenContent);let d=new Set;for(let{stalePaths:g}of u)for(let m of g)f.has(m)||d.add(m);let p=[...d];try{await(0,E$.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(g){return t.push(`outbox: batch push deferred for ${u.length} resolution(s), will retry next sync: ${s(Na(g))}`),{pushed:0,reconflicted:l}}let h=0;for(let{entry:g,stalePaths:m}of u){let b=m.filter(_=>!f.has(_));await this.snapOutboxWatermark(e,g.path,g.chosenContent,b),await this.deps.quarantine?.markResolved?.(g.repoKey,g.path);for(let _ of b)await this.deps.quarantine?.markResolved?.(g.repoKey,_);await n.remove(g.repoKey,g.path),h++,b.length>0&&t.push(`consolidated cross-path conflict for ${g.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:l}}async outboxHeadTreeShas(e){let t=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,dt.getTree)(this.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return{head:t,shaByPath:s}}async snapOutboxWatermark(e,t,n,i=[]){let s=await this.deps.watermarkStore.get(e.repoKey);if(s===null)return;let o=new Set([t,...i]),c=(s.pinnedPaths??[]).filter(m=>!o.has(m)),l=await(0,ru.gitBlobSha)(n,this.sha1),u=(0,Oo.extractAssetUid)(n),f={path:t,blobSha:l,...u!==void 0?{uid:u}:{}},d=new Set(i),p=s.files.filter(m=>!d.has(m.path)),h=p.findIndex(m=>m.path===t),g=h>=0?p.map((m,b)=>b===h?f:m):[...p,f];await this.deps.watermarkStore.set(e.repoKey,{...s,files:g,...c.length>0?{pinnedPaths:c}:{pinnedPaths:void 0}})}async buildTerminalQuarantineEntries(e,t,n,i,s){let o=new Set(i.map(u=>u.path)),c=new Map;try{let u=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,u,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(d=>n.has(d.path));for(let d of f)c.set(d.path,await(0,dt.getBlobText)(this.transport,e.owner,e.repo,d.blobSha,this.deps.baseURL))}catch{}let l=[];for(let[u,f]of n){if(o.has(u))continue;let d=s.get(u),p=d??f,h=d!==void 0&&!(0,Po.contentEquals)(d,f),g=typeof p=="string"?(0,Oo.extractAssetUid)(p):void 0,m=c.get(u);l.push({repoKey:e.repoKey,path:u,...g!==void 0?{uid:g}:{},reason:`non-fast-forward push failed after ${this.deps.maxPushRetries??Tn.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},...m!==void 0?{remoteContent:m}:{}})}return l}async resolveClearedPins(e,t,n,i,s=new Set){let o=this.deps.quarantine;if(o===void 0||o.markResolved===void 0)return;let c=(t.pinnedPaths??[]).filter(l=>!n.has(l)&&!s.has(l));for(let l of c)try{await o.markResolved?.(e.repoKey,l)}catch(u){let f=this.deps.redact??(d=>d);i.push(`quarantine markResolved failed for ${l}: ${f(Na(u))} \u2014 unresolved-count may overcount until the resolver UI reconciles (CQ4)`)}}async resolveBaseTreeSha(e,t,n={}){try{return(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t.lastSyncedSha,this.deps.baseURL)).treeSha}catch(i){if(!foe(i))throw i;return n.headReachable===!0||await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),null}}pinLocalChanges(e,t,n,i,s){let o=e.modified.filter(p=>p.basePath!==void 0),c=[...e.added,...e.modified.filter(p=>p.basePath===void 0)],l=new Map;if(s==="pull"){for(let p of o)p.basePath!==void 0&&i.push(p.basePath),n.push(`pull-only: rename (uid ${p.uid??"?"}) ${p.basePath} \u2192 ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`);for(let p of e.deleted)i.push(p.path),n.push(`pull-only: delete of ${p.path} not pushed \u2014 propagates on the next push/Sync (#3473)`)}else{for(let p of o)p.basePath!==void 0&&l.set(p.basePath,p.path);for(let p of e.deleted)l.set(p.path,p.path)}let u=[...c,...o,...e.deleted.map(p=>({...p}))],f=new Set(e.deleted.map(p=>p.path)),d=new Map;for(let p of[...c,...s==="pull"?[]:o]){let h=t.get(p.path);h!==void 0&&d.set(p.path,h)}return{localChanges:u,localDeletedPaths:f,pushFilesAll:d,pushDeletionsAll:l,dupUids:e.duplicateUids}}async runPushLoop(e,t,n,i,s,o,c=!1,l=new Set,u="sync",f,d){let{localChanges:p,localDeletedPaths:h,pushFilesAll:g,pushDeletionsAll:m,dupUids:b}=n,_=this.deps.maxPushRetries??Tn.DEFAULT_MAX_PUSH_RETRIES,S=0,I="",E,w=[],R=[],x=new Map,P=new Set,k=[],B=kR,D=[],Q=new Set,fe=[],j=[],ce=new Set,V=[],oe=new Set;for(;;){I=S===0&&d!==void 0&&g.size===0&&m.size===0?d:await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),w=[],R=[],B=kR,D=[],Q=new Set,fe=[],j=[];let K,z=new Set,Z=(t.pinnedPaths?.length??0)>0;if(I!==t.lastSyncedSha||Z||c){this.emitProgress(f,e.repoKey,"pulling-remote");let Y=await this.collectRemoteChanges(e,t,I,o,l,s,ce,f);K=Y.headTreeByPath;let se=this.matchLocalVsRemote(p,h,i,Y.changes,z,b,Y.headTreeByPath);if(se.conflicts.length>0){if(u==="sync"&&this.emitProgress(f,e.repoKey,"merging"),u!=="sync"){for(let X of se.conflicts){Q.add(X.local.path),X.local.basePath!==void 0&&Q.add(X.local.basePath);for(let le of X.remotes)Q.add(le.path),le.kind==="change"&&fe.push(le)}j.push(`${u}-only: ${se.conflicts.length} conflict(s) deferred to a full Sync (${se.conflicts.map(X=>X.desc).join("; ")}) \u2014 paths pinned, nothing merged`)}else if(o.fileMode)B=this.resolveFileModeConflicts(e,se.conflicts,i,se.applyWrites,se.applyDeletes);else{if(this.deps.mergeLayer===void 0)return{kind:"conflict",detail:`overlapping change on ${se.conflicts[0].desc} \u2014 merge layer (A2/A3) required; nothing pushed, nothing written`};B=await this.resolveMergeConflicts(e,t,se.conflicts,i)}if(u==="sync")for(let X of se.conflicts)for(let le of X.remotes)le.path!==X.local.path&&(Q.add(le.path),le.kind==="change"&&fe.push(le),j.push(`conflict group ${X.desc}: remote change at ${le.path} NOT applied \u2014 pinned to re-derive on the next sync (#3477)`))}if(w=se.applyWrites,R=se.applyDeletes,u==="push"&&(w.length>0||R.length>0)){for(let X of w)Q.add(X.path),fe.push(X);for(let X of R)Q.add(X.path);j.push(`push-only: ${w.length+R.length} remote change(s) NOT applied \u2014 pinned to re-derive on the next pull/Sync`),w=[],R=[]}}x=u==="pull"?new Map:new Map([...[...g].filter(([Y])=>!z.has(Y)),...B.mergedFiles]),P=new Set,k=[];for(let[Y,se]of m){if(z.has(se)){k.push(Y);continue}x.has(Y)||P.add(Y)}if((x.size>0||P.size>0)&&K===void 0&&(K=MR(await(0,dt.getTree)(this.transport,e.owner,e.repo,t.rootTreeSha,this.deps.baseURL))),x.size>0&&K!==void 0){for(let[Y,se]of x){let X=K.get(Y);X!==void 0&&X===await(0,ru.gitBlobSha)(se,this.sha1)&&(x.delete(Y),D.push(Y))}D.length>0&&s.push(`phantom push skipped: ${D.length} file(s) already identical in remote HEAD (${D.join(", ")}) \u2014 excluded from the commit (#3475)`)}if(P.size>0&&K!==void 0){for(let Y of[...P])K.has(Y)||P.delete(Y);x.size===0&&P.size>=K.size&&(k.push(...P),j.push(`deletion of ALL ${P.size} remaining file(s) deferred \u2014 GitHub cannot create an empty tree; the deletes re-derive and propagate once the repo has at least one surviving file`),P.clear())}if(x.size===0&&P.size===0)break;let Ie=new Map;for(let[Y,se]of x)if(typeof se=="string")Ie.set(Y,se);else{let X=aoe(se);X!==null&&Ie.set(Y,X)}let ee=(0,T$.scanForSecrets)(Ie);if(ee.length>0){let Y=new Map;for(let se of ee){let X=Y.get(se.path);X===void 0?Y.set(se.path,[se.kind]):X.includes(se.kind)||X.push(se.kind)}for(let[se,X]of Y){if(!oe.has(se)){oe.add(se);let le=Ie.get(se),Ue=le!==void 0?(0,T$.redactSecrets)(le):void 0,$=Ue!==void 0?(0,Oo.extractAssetUid)(Ue):void 0;V.push({repoKey:e.repoKey,path:se,...$!==void 0?{uid:$}:{},reason:`secret-scan (R5): detected ${X.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.`,...Ue!==void 0?{localContent:Ue}:{}})}x.delete(se)}s.push(`secret-scan (R5): skipped ${Y.size} file(s) with a detected secret from the push \u2014 the rest of the changeset shipped; REVOKE the credential(s): ${[...Y].map(([se,X])=>`${se} (${X.join(", ")})`).join(", ")}`);for(let[se,X]of m)oe.has(X)&&P.has(se)&&(P.delete(se),k.push(se));if(x.size===0&&P.size===0)break}try{E=await(0,E$.restCreateCommit)(this.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([...x].map(([Y,se])=>[Y,coe(se)])),deletions:[...P],message:this.deps.commitMessage?.(e,x.size,P.size)??`chore(exosync): sync ${x.size} file(s)${P.size>0?`, ${P.size} deletion(s)`:""}`,baseURL:this.deps.baseURL,redact:this.deps.redact});break}catch(Y){if(!O$(Y))throw Y;if(S++,S>_)return{kind:"retry-exhausted",detail:`non-fast-forward push failed after ${_} retries (D16 cap) \u2014 contended files routed to quarantine (D17)`,pushFiles:x,merge:B};s.push(`non-fast-forward push (attempt ${S}/${_}) \u2014 re-pulling and retrying (D16)`)}}return{kind:"done",examinedHead:I,pushedSha:E,applyWrites:w,applyDeletes:R,pushFiles:x,pushedDeletions:E!==void 0?[...P]:[],withheldDeletions:k,merge:B,remoteOversized:ce,alreadyInHead:D,deferredPaths:Q,deferredRemoteChanges:fe,deferredWarnings:j,secretQuarantineEntries:V}}async resolveMergeConflicts(e,t,n,i){let s=this.deps.mergeLayer;if(s===void 0)return kR;let o=new Map(t.files.map(m=>[m.path,m])),c=new Map,l=[],u=[],f=[],d=[],p=0,h=a(m=>typeof m=="string"?m:void 0,"asText"),g=a((m,b,_)=>{let S=h(i.get(m.local.path)),I=h(m.remotes[0]?.content);return{repoKey:e.repoKey,path:m.local.path,...m.local.uid!==void 0?{uid:m.local.uid}:{},reason:b,..._!==void 0?{baseContent:_}:{},...S!==void 0?{localContent:S}:{},...I!==void 0?{remoteContent:I}:{}}},"entry");for(let m of n){let b=o.get(m.local.basePath??m.local.path)??o.get(m.remotes[0]?.path??""),_;if(b!==void 0&&(_=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,b.blobSha,this.deps.baseURL)),m.remotes.length>1){u.push(g(m,`ambiguous conflict: local change overlaps ${m.remotes.length} remote changes (${m.remotes.map(R=>R.path).join(", ")})`,_));continue}let S=m.remotes[0],I=h(i.get(m.local.path)),E=await s.resolve({path:m.local.path,...m.local.uid!==void 0?{uid:m.local.uid}:{},..._!==void 0?{base:_}:{},...I!==void 0?{local:I}:{},...S.kind==="change"&&typeof S.content=="string"?{remote:S.content}:{}});if(E.action==="quarantine"){u.push(g(m,E.reason,_));continue}p++,d.push(m.local.path);for(let R of E.warnings??[])f.push(`merge(${m.local.path}): ${R}`);let w=S.kind==="change"?S.content:void 0;if(E.content!==w&&c.set(m.local.path,E.content),E.content!==i.get(m.local.path)){let R=(0,Oo.extractAssetUid)(E.content)??m.local.uid;l.push({path:m.local.path,kind:"change",content:E.content,blobSha:await(0,ru.gitBlobSha)(E.content,this.sha1),...R!==void 0?{uid:R}:{}})}}return{mergedFiles:c,mergedWrites:l,quarantineEntries:u,resolvedQuarantineEntries:[],mergedCount:p,mergedPaths:d,warnings:f}}resolveFileModeConflicts(e,t,n,i,s){let o=[],c=[];for(let l of t){l.remotes.length>1&&c.push(`file-mode conflict on ${l.local.path} unexpectedly overlaps ${l.remotes.length} remote changes \u2014 resolving against the first`);let u=l.remotes[0],f=n.get(l.local.path);u.kind==="change"?i.push(u):s.push(u),!(l.localIsDelete||f===void 0)&&o.push({repoKey:e.repoKey,path:l.local.path,reason:`file-mode remote-wins (D18): remote ${u.kind==="change"?`version ${u.blobSha}`:"delete"} wins; this is the losing LOCAL version, preserved byte-exact`,...typeof f=="string"?{localContent:f}:{localContentBytes:f}})}return{mergedFiles:new Map,mergedWrites:[],quarantineEntries:[],resolvedQuarantineEntries:o,mergedCount:0,mergedPaths:[],warnings:c}}async applyRemoteChanges(e,t,n,i,s,o=new Map){let c=0,l=new Set,u=[],f=a(async(h,g)=>{try{return g?await R$(e,h):await e.read(h)}catch{return}},"tryRead"),d=a(async(h,g)=>{typeof g=="string"?await e.write(h,g):await loe(e,h,g)},"writeContent"),p=a(async h=>{let g=await f(h,!1);return g===void 0?!0:await(0,ru.gitBlobSha)(g,this.sha1)===o.get(h)},"cacheHitUnchanged");for(let h of n){if(h.content===void 0)continue;if(!C$(h.path)){s.push(`unsafe remote path skipped on pull-apply: ${h.path}`),l.add(h.path);continue}let g=t.get(h.path);if(g===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path);continue}let m=await f(h.path,typeof(g??h.content)!="string");if(!(0,Po.contentEquals)(m,g)){s.push(`pull-apply skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 remote change re-derives next sync`),l.add(h.path);continue}await d(h.path,h.content),c++,u.push(h.path)}for(let h of i){if(!C$(h.path)){s.push(`unsafe remote path skipped on pull-delete: ${h.path}`),l.add(h.path);continue}let g=t.get(h.path);if(g===void 0&&o.has(h.path)){if(!await p(h.path)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path);continue}if(g!==void 0){let m=await f(h.path,typeof g!="string");if(m!==void 0&&!(0,Po.contentEquals)(m,g)){s.push(`pull-delete skipped: ${h.path} changed on disk mid-sync (TOCTOU) \u2014 delete-vs-modify re-derives next sync`),l.add(h.path);continue}await e.delete(h.path),c++,u.push(h.path)}}return{pulledCount:c,pinnedPaths:l,pulledPaths:u}}async advanceWatermark(e,t,n,i,s,o,c,l,u,f=new Set){let d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).filter(h=>u.treeFilter(h)&&!f.has(h.path)),p=doe(await this.buildWatermarkFiles(e,d,i,s,o,l,u),o,c);await this.deps.watermarkStore.set(e.repoKey,{lastSyncedSha:t,rootTreeSha:n,files:p,...c.size>0?{pinnedPaths:[...c]}:{},...u.fileMode?{spaceKind:"file"}:{}})}async tryMountBaseBootstrap(e,t,n,i,s){let o=this.deps.mountBaseStore,c=null;if(o!==void 0)try{c=await o.get(e.repoKey)}catch{return null}let l=!1;if(c===null&&this.deps.localBaseShaProvider!==void 0)try{let b=await this.deps.localBaseShaProvider(e);typeof b=="string"&&b.length>0&&(c=b,l=!0)}catch{}if(c===null||t.startsWith(c))return null;let u=300,f=null;try{let b=t;for(let _=0;_<u;_++){let S=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,b,this.deps.baseURL);if(S.sha===c||S.sha.startsWith(c)){f=S;break}if(S.parents.length===0)break;b=S.parents[0]}}catch{return null}if(f===null)return null;let d;try{d=(await(0,dt.getTree)(this.transport,e.owner,e.repo,f.treeSha,this.deps.baseURL)).filter(b=>(0,Po.isSyncablePath)(b.path))}catch{return null}let p;try{let b=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,t,this.deps.baseURL);p=MR((await(0,dt.getTree)(this.transport,e.owner,e.repo,b.treeSha,this.deps.baseURL)).filter(_=>(0,Po.isSyncablePath)(_.path)))}catch{return null}let h=d.filter(b=>!n.has(b.path)&&p.get(b.path)===b.blobSha);if(h.length>0){let b=h.slice(0,3).map(_=>_.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 g=d.map(b=>({path:b.path,blobSha:b.blobSha})),m={lastSyncedSha:f.sha,rootTreeSha:f.treeSha,files:g};if(l&&o!==void 0)try{await o.set(e.repoKey,f.sha)}catch{}return i.push(l?`first-sync (asset mode): BACKFILLED the 3-way base from the locally checked-out commit ${f.sha} (no recorded mount base) \u2014 remote head ${t} advanced since; local edits 3-way merge against it instead of false-conflicting (#3590)`:`first-sync (asset mode): reconciling against the recorded mount base ${f.sha} \u2014 remote head ${t} advanced since mount; local edits 3-way merge against it instead of false-conflicting (#3590)`),{kind:"additive-base",base:m}}async bootstrapWatermark(e,t,n,i){let s=await(0,dt.getHeadSha)(this.transport,e.owner,e.repo,e.branch,this.deps.baseURL),o=await this.tryMountBaseBootstrap(e,s,t,n,i);if(o!==null)return o;let c=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,s,this.deps.baseURL),l=(await(0,dt.getTree)(this.transport,e.owner,e.repo,c.treeSha,this.deps.baseURL)).filter(p=>(0,Po.isSyncablePath)(p.path)),u=[],f;for(let p of l){let h=t.get(p.path);if(h===void 0||await(0,ru.gitBlobSha)(h,this.sha1)!==p.blobSha){f===void 0&&(f=p.path);continue}let g=typeof h=="string"?(0,Oo.extractAssetUid)(h):void 0;u.push({path:p.path,blobSha:p.blobSha,...g?{uid:g}:{}})}let d={lastSyncedSha:s,rootTreeSha:c.treeSha,files:u};return f!==void 0?this.deps.mergeLayer===void 0?{kind:"settled",outcome:i("full-conflict",{detail:`first-sync: no watermark and local content diverges from remote head at ${f} \u2014 A2/A3 scope`})}:(n.push(`first-sync (asset mode): no 3-way merge base and local diverges from remote head (first at ${f}) \u2014 reconciling ZERO-LOSS against ${u.length} byte-identical file(s) as a synthetic base: remote-only files pull, local-only files push, overlapping divergences route to the merge/quarantine layer (both versions preserved), never a silent overwrite or delete`),{kind:"additive-base",base:d}):t.size===l.length?(await this.deps.watermarkStore.set(e.repoKey,d),n.push(`watermark bootstrapped from head ${s} (local tree identical to remote)`),{kind:"settled",outcome:i("synced")}):(n.push(`first-sync (asset mode): local tree (${t.size} files) is a pure superset of remote head ${s} (${l.length} files) \u2014 ${t.size-l.length} local-only addition(s) derive as pushable adds (#3565)`),{kind:"additive-base",base:d})}async collectRemoteChanges(e,t,n,i,s=new Set,o=[],c=new Set,l){let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL),f=await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL);if(i.fileMode)for(let P of f)i.syncable(P.path)&&!i.treeFilter(P)&&!c.has(P.path)&&(c.add(P.path),o.push(`skipped oversized REMOTE file ${P.path} (${P.size??"?"} bytes over cap) \u2014 excluded from sync symmetrically (Phase C size cap)`));let d=f.filter(P=>i.treeFilter(P)&&!s.has(P.path)),p=t.files.filter(P=>!c.has(P.path)&&!s.has(P.path)),{changed:h,deleted:g}=x$(p,d),m=h.length;m>=I$&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:0,total:m});let b=new Array(h.length),_=0,S=0,I,E=a(async P=>{if(i.fileMode){let B=await(0,dt.getBlobBytes)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:B}}let k=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,P.blobSha,this.deps.baseURL);return{path:P.path,kind:"change",blobSha:P.blobSha,content:k,uid:(0,Oo.extractAssetUid)(k)}},"fetchOne"),w=a(async()=>{for(;;){if(I!==void 0)return;let P=_++;if(P>=h.length)return;try{b[P]=await E(h[P])}catch(k){I===void 0&&(I=k);return}S+=1,m>=I$&&S%noe===0&&S<m&&this.emitProgress(l,e.repoKey,"fetching-blobs",{done:S,total:m})}},"worker"),R=Math.min(ioe,h.length);if(await Promise.all(Array.from({length:R},()=>w())),I!==void 0)throw I instanceof Error?I:new Error(String(I));let x=b;for(let P of g)x.push({path:P.path,kind:"delete",uid:P.uid});return{changes:x,headTreeByPath:MR(f)}}matchLocalVsRemote(e,t,n,i,s,o=new Set,c){let l=new Set,u=[],f=new Map;for(let m of i)m.kind==="change"&&m.uid!==void 0&&f.set(m.uid,(f.get(m.uid)??0)+1);let d=new Set(o);for(let[m,b]of f)b>1&&d.add(m);let p=new Map,h=new Map;for(let m of i){if(m.uid!==void 0&&!d.has(m.uid)){let b=p.get(m.uid)??[];b.push(m),p.set(m.uid,b)}h.set(m.path,m)}for(let m of e){let b=new Set;if(m.uid!==void 0&&!d.has(m.uid))for(let E of p.get(m.uid)??[])E.kind==="change"&&E.path!==m.path&&(c?.has(m.path)===!0||m.basePath!==void 0&&c?.has(m.basePath)===!0)||b.add(E);let _=h.get(m.path);if(_!==void 0&&b.add(_),m.basePath!==void 0){let E=h.get(m.basePath);E!==void 0&&b.add(E)}let S=[],I=!1;for(let E of b){if(I=t.has(m.path)&&!n.has(m.path),I&&E.kind==="delete"){l.add(E);continue}if(!I&&E.kind==="change"&&E.path===m.path&&E.blobSha===m.blobSha){l.add(E),s.add(m.path);continue}if(E.kind==="delete"&&m.basePath!==void 0&&E.path===m.basePath){let w=h.get(m.path);if(w!==void 0&&w.kind==="change"&&(w.blobSha===m.blobSha||w.uid!==void 0&&w.uid===m.uid)){l.add(E);continue}}if(E.kind==="delete"&&E.path!==m.path&&E.path!==m.basePath&&!n.has(E.path)&&c?.has(E.path)!==!0){l.add(E);continue}S.push(E),l.add(E)}S.length>0&&(u.push({local:m,localIsDelete:I,remotes:S,desc:`${m.uid!==void 0&&!d.has(m.uid)?m.uid:m.path} (local ${I?"delete":"change"} vs remote ${S[0].kind} at ${S[0].path})`}),s.add(m.path))}let g=i.filter(m=>!l.has(m));return{conflicts:u,applyWrites:g.filter(m=>m.kind==="change"),applyDeletes:g.filter(m=>m.kind==="delete")}}async checkRaceWindow(e,t,n,i,s,o,c,l){try{let u=await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,i,this.deps.baseURL),f=(await(0,dt.getTree)(this.transport,e.owner,e.repo,u.treeSha,this.deps.baseURL)).filter(l.treeFilter),d=n===t.lastSyncedSha?t.files:(await(0,dt.getTree)(this.transport,e.owner,e.repo,(await(0,dt.getCommitInfo)(this.transport,e.owner,e.repo,n,this.deps.baseURL)).treeSha,this.deps.baseURL)).filter(l.treeFilter),{changed:p,deleted:h}=x$(d,f);for(let g of p)s.has(g.path)&&c.push(`race-window: concurrent commit ${i} changed ${g.path} between conflict check (head ${n}) and push \u2014 local version won; previous version recoverable from git history`),o.has(g.path)&&c.push(`race-window: concurrent commit ${i} changed ${g.path} which this push DELETED \u2014 the delete won; the concurrent version is recoverable from git history`);for(let g of h)s.has(g.path)&&c.push(`race-window: concurrent commit ${i} deleted ${g.path}; push re-created it`)}catch(u){let f=this.deps.redact??(d=>d);c.push(`race-window check failed: ${f(Na(u))}`)}}async buildWatermarkFiles(e,t,n,i,s,o,c){if(c.fileMode)return t.map(f=>({path:f.path,blobSha:f.blobSha}));let l=new Map;for(let f of i)f.kind==="change"&&f.blobSha!==void 0&&l.set(f.blobSha,f.uid);for(let[f,d]of n){let p=o?.get(f)??await(0,ru.gitBlobSha)(d,this.sha1);l.set(p,typeof d=="string"?(0,Oo.extractAssetUid)(d):void 0)}for(let f of s.files)l.has(f.blobSha)||l.set(f.blobSha,f.uid);let u=[];for(let f of t){let d;if(l.has(f.blobSha))d=l.get(f.blobSha);else{let p=await(0,dt.getBlobText)(this.transport,e.owner,e.repo,f.blobSha,this.deps.baseURL);d=(0,Oo.extractAssetUid)(p)}u.push({path:f.path,blobSha:f.blobSha,...d?{uid:d}:{}})}return u}};Tn.SyncEngine=jR});var D$=T(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0});Jh.QuarantineResolver=void 0;Jh.backupPathFor=F$;var poe=B_(),J_=ld(),Xh=cd(),Qh=zh(),hoe=W_(),Fo="\0absent",$R=class{static{a(this,"QuarantineResolver")}constructor(e){this.deps=e}async listOpenConflicts(e){let t=[];for(let n of e)t.push(...await this.listRepoConflicts(n));return t}async listRepoConflicts(e){if(e.spaceKind==="file")return[];let t=await this.deps.watermarkStore.get(e.repoKey),n=t?.pinnedPaths??[];if(n.length===0)return[];if(this.deps.outbox!==void 0){let h=await this.deps.outbox.listForRepo(e.repoKey);if(h.length>0){let g=new Set(h.map(m=>m.path));if(n=n.filter(m=>!g.has(m)),n.length===0)return[]}}let i=new Map;for(let h of t?.files??[])i.set(h.path,h.blobSha);let s=this.deps.conflictCache!==void 0,o=await this.cachedRecordsFor(e,n),c=n.some(h=>!o.has(h)),l=new Map,u=!0;if(c)if(s)try{l=await this.remoteTreeShas(e)}catch{u=!1}else l=await this.remoteTreeShas(e);let f=this.deps.localFilesFor(e),d=new Set(await f.list()),p=[];for(let h of n){let g=o.get(h),m,b;if(g!==void 0)b=g.remoteContent!==void 0?await(0,Xh.gitBlobSha)(g.remoteContent,this.deps.sha1):Fo,m=g.baseContent!==void 0?await(0,Xh.gitBlobSha)(g.baseContent,this.deps.sha1):i.get(h)??Fo;else{if(!u)continue;b=l.get(h)??Fo,m=i.get(h)??Fo}let _=Fo,S;if(d.has(h)&&(S=await f.read(h),_=await(0,Xh.gitBlobSha)(S,this.deps.sha1)),!(_!==b&&_!==m&&b!==m))continue;let E=(S!==void 0?(0,Qh.extractAssetUid)(S):void 0)??g?.uid;p.push({repoKey:e.repoKey,path:h,...E!==void 0?{uid:E}:{},hasLocal:_!==Fo,hasRemote:b!==Fo})}return p}async cachedRecordsFor(e,t){let n=new Map,i=this.deps.conflictCache;if(i===void 0)return n;for(let s of t){let o=await i.get(e.repoKey,s);o!==null&&n.set(s,o)}return n}async detectDuplicateUids(e){let t=new Map;for(let i of e){let s=this.deps.localFilesFor(i);for(let o of await s.list()){if(!o.endsWith(".md"))continue;let c;try{c=await s.read(o)}catch{continue}let l=(0,Qh.extractAssetUid)(c);l!==void 0&&t.set(l,(t.get(l)??0)+1)}}let n=0;for(let i of t.values())i>1&&n++;return n}async loadConflict(e,t){let n=this.deps.localFilesFor(e),s=new Set(await n.list()).has(t)?await n.read(t):void 0,o=await this.deps.conflictCache?.get(e.repoKey,t)??null,c,l;if(o!==null)c=o.remoteContent,l=o.baseContent;else{let d=(await this.remoteTreeShas(e)).get(t);c=d!==void 0?await this.blobText(e,d):void 0;let h=((await this.deps.watermarkStore.get(e.repoKey))?.files??[]).find(g=>g.path===t)?.blobSha;if(h!==void 0)try{l=await this.blobText(e,h)}catch{l=void 0}}let u=(s!==void 0?(0,Qh.extractAssetUid)(s):void 0)??(c!==void 0?(0,Qh.extractAssetUid)(c):void 0)??o?.uid;return{repoKey:e.repoKey,path:t,...u!==void 0?{uid:u}:{},hasLocal:s!==void 0,hasRemote:c!==void 0,...l!==void 0?{base:l}:{},...s!==void 0?{local:s}:{},...c!==void 0?{remote:c}:{}}}async resolve(e,t,n){let i=this.deps.localFilesFor(e),o=new Set(await i.list()).has(t)?await i.read(t):void 0,c=this.deps.outbox!==void 0,{remote:l,remoteSha:u}=c?await this.remoteForResolve(e,t):await this.liveRemoteForResolve(e,t),f=this.chosenContent(n,o,l),d;n.take!=="local"&&o!==void 0&&o!==f&&(d=F$(t),await i.write(d,o)),f===void 0?await i.delete(t):await i.write(t,f);let h=f===void 0&&l===void 0||f===l;if(c&&this.deps.outbox!==void 0&&!h&&f!==void 0)return await this.deps.outbox.enqueue({repoKey:e.repoKey,path:t,chosenContent:f,resolvedTo:n.take==="merged"?"merged":"local",baseRemoteSha:u===Fo?hoe.OUTBOX_REMOTE_ABSENT:u,resolvedAt:""}),{repoKey:e.repoKey,path:t,resolvedTo:n.take,awaitingPush:!0,...d!==void 0?{discardedLocalBackupPath:d}:{}};let g;return h||(g=await this.commitChoice(e,t,f)),await this.snapWatermark(e,t,f),this.deps.quarantine?.markResolved!==void 0&&await this.deps.quarantine.markResolved(e.repoKey,t),{repoKey:e.repoKey,path:t,resolvedTo:n.take,...g!==void 0?{pushedSha:g}:{},...d!==void 0?{discardedLocalBackupPath:d}:{}}}async remoteForResolve(e,t){let n=await this.deps.conflictCache?.get(e.repoKey,t)??null;if(n!==null){let i=n.remoteContent,s=i!==void 0?await(0,Xh.gitBlobSha)(i,this.deps.sha1):Fo;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??Fo}}chosenContent(e,t,n){switch(e.take){case"local":if(t===void 0)throw new Error("resolve: cannot keep local \u2014 no local version exists on disk");return t;case"remote":return n;case"merged":return e.content}}async commitChoice(e,t,n){let i=this.deps.commitMessage?.(e,t)??`chore(exosync): resolve conflict for ${t}`;if(n===void 0)throw new Error(`resolve: cannot push an empty resolution for ${t}`);return(0,poe.restCreateCommit)(this.deps.transport,{owner:e.owner,repo:e.repo,branch:e.branch,files:new Map([[t,n]]),message:i,...this.deps.baseURL!==void 0?{baseURL:this.deps.baseURL}:{},...this.deps.redact!==void 0?{redact:this.deps.redact}:{}})}async snapWatermark(e,t,n){let i=await this.deps.watermarkStore.get(e.repoKey);if(i===null)return;let s=(i.pinnedPaths??[]).filter(c=>c!==t),o=i.files;if(n===void 0)o=o.filter(c=>c.path!==t);else{let c=await(0,Xh.gitBlobSha)(n,this.deps.sha1),l=(0,Qh.extractAssetUid)(n),u={path:t,blobSha:c,...l!==void 0?{uid:l}:{}},f=o.findIndex(d=>d.path===t);o=f>=0?o.map((d,p)=>p===f?u:d):[...o,u]}await this.deps.watermarkStore.set(e.repoKey,{...i,files:o,...s.length>0?{pinnedPaths:s}:{pinnedPaths:void 0}})}async remoteTreeShas(e){let t=await(0,J_.getHeadSha)(this.deps.transport,e.owner,e.repo,e.branch,this.deps.baseURL),n=await(0,J_.getCommitInfo)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL),i=await(0,J_.getTree)(this.deps.transport,e.owner,e.repo,n.treeSha,this.deps.baseURL),s=new Map;for(let o of i)s.set(o.path,o.blobSha);return s}async blobText(e,t){return(0,J_.getBlobText)(this.deps.transport,e.owner,e.repo,t,this.deps.baseURL)}};Jh.QuarantineResolver=$R;function F$(r){return`${r}.conflict.local.txt`}a(F$,"backupPathFor")});var L$=T(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:!0});fd.FileLocalManifestStore=fd.LOCAL_MANIFEST_STORE_FILENAME=void 0;fd.LOCAL_MANIFEST_STORE_FILENAME="exosync-localmanifest.local.json";function moe(r){if(r===null||typeof r!="object")return!1;let e=r;return e.version===1&&typeof e.lastFullRehashMs=="number"&&e.files!==null&&typeof e.files=="object"}a(moe,"isLocalManifestRecord");var UR=class{static{a(this,"FileLocalManifestStore")}constructor(e){this.io=e,this.writeChain=Promise.resolve()}async get(e){let n=(await this.readRepos())[e];return moe(n)?n:null}async set(e,t){let n=this.writeChain.then(async()=>{let i=await this.readRepos();i[e]=t;let s={version:1,repos:i};await this.io.writeAtomic(JSON.stringify(s))});return this.writeChain=n.catch(()=>{}),n}async readRepos(){try{let e=await this.io.read();if(e===null)return{};let t=JSON.parse(e);if(t===null||typeof t!="object")return{};let n=t.repos;return n===null||typeof n!="object"?{}:{...n}}catch{return{}}}};fd.FileLocalManifestStore=UR});var GR=T(VR=>{"use strict";Object.defineProperty(VR,"__esModule",{value:!0});VR.diff3=goe;function N$(r,e){let t=r.length,n=e.length,i=Array.from({length:t+1},()=>new Int32Array(n+1));for(let l=t-1;l>=0;l--)for(let u=n-1;u>=0;u--)i[l][u]=r[l]===e[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);let s=new Map,o=0,c=0;for(;o<t&&c<n;)r[o]===e[c]?(s.set(o,c),o++,c++):i[o+1][c]>=i[o][c+1]?o++:c++;return s}a(N$,"lcsMatch");function BR(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}a(BR,"sliceEq");function goe(r,e,t){let n=N$(r,e),i=N$(r,t),s=[],o=0,c=0,l=0;for(;;){let u=o;for(;u<r.length&&!(n.has(u)&&i.has(u));)u++;let f=u<r.length?n.get(u):e.length,d=u<r.length?i.get(u):t.length,p=r.slice(o,u),h=e.slice(c,f),g=t.slice(l,d),m=!BR(h,p),b=!BR(g,p);if(!m&&!b)s.push(...p);else if(!m)s.push(...g);else if(!b)s.push(...h);else if(BR(h,g))s.push(...h);else return{ok:!1,conflict:{base:p,local:h,remote:g}};if(u>=r.length)break;s.push(r[u]),o=u+1,c=f+1,l=d+1}return{ok:!0,merged:s}}a(goe,"diff3")});var M$=T(tm=>{"use strict";Object.defineProperty(tm,"__esModule",{value:!0});tm.StructuredMerger=void 0;tm.splitSections=Z_;var k$=GR(),yoe=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,Zh="exo__Instance_class";function em(r){if(r===null||typeof r!="object")return!0;if(Array.isArray(r))return r.every(em);let e=Object.getPrototypeOf(r);return e!==Object.prototype&&e!==null?!1:Object.values(r).every(em)}a(em,"isPlainValue");function xc(r,e){if(r===e)return!0;if(r===null||e===null||r===void 0||e===void 0||typeof r!="object"||typeof e!="object"||Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)&&Array.isArray(e))return r.length!==e.length?!1:r.every((s,o)=>xc(s,e[o]));let t=r,n=e,i=Object.keys(t);return i.length!==Object.keys(n).length?!1:i.every(s=>xc(t[s],n[s]))}a(xc,"deepEqual");function nu(r){return typeof r=="string"?`s:${r}`:`j:${JSON.stringify(r)}`}a(nu,"setKey");function cs(r){return r==null?[]:Array.isArray(r)?r:[r]}a(cs,"toElements");function boe(r,e,t){let n=new Set(cs(r).map(nu)),i=cs(e),s=cs(t),o=new Set(i.map(nu)),c=new Set(s.map(nu)),l=a(d=>o.has(d)&&c.has(d)||o.has(d)&&!n.has(d)||c.has(d)&&!n.has(d),"keep"),u=[],f=new Set;for(let d of[...i,...s]){let p=nu(d);f.has(p)||!l(p)||(f.add(p),u.push(d))}return u}a(boe,"mergeSet");function _oe(r,e,t){let n=[],i=[],s=new Set;for(let c of[...Object.keys(r),...Object.keys(e),...Object.keys(t)])s.has(c)||(s.add(c),i.push(c));let o={};for(let c of i){let l=r[c],u=e[c],f=t[c];if(!em(l)||!em(u)||!em(f))return{ok:!1,reason:`frontmatter key "${c}" contains a non-plain value (Date?) \u2014 the codec must round-trip scalars as strings (CORE_SCHEMA contract)`};if(Array.isArray(l)||Array.isArray(u)||Array.isArray(f)){if(!(c in e)&&!(c in t))continue;let d=boe(l,u,f),p=new Set(cs(l).map(nu)),h=cs(u).some(m=>!p.has(nu(m))),g=cs(f).some(m=>!p.has(nu(m)));h&&g&&!xc(cs(u),cs(f))&&n.push(`both sides added values to multi-valued key "${c}" \u2014 union kept (D20)`),d.length>0&&(o[c]=d);continue}if(xc(u,f)){u!==void 0&&(o[c]=u);continue}if(xc(u,l)){f!==void 0&&(o[c]=f);continue}if(xc(f,l)){u!==void 0&&(o[c]=u);continue}return{ok:!1,reason:`frontmatter key "${c}" changed differently on both sides`}}return{ok:!0,value:o,warnings:n}}a(_oe,"mergeFrontmatter");var Soe=/^(```|~~~)/,woe=/^#{1,6}\s/;function Z_(r){let e=r.split(`
|
|
337
337
|
`),t=[],n=null,i="",s=!1,o=a(()=>{n!==null&&t.push({heading:i,text:n.join(`
|
|
338
338
|
`)})},"flush");for(let c of e){if(Soe.test(c.trimStart())&&(s=!s),!s&&woe.test(c)){o(),n=[c],i=c.trim();continue}n===null&&(n=[],i=""),n.push(c)}return o(),t}a(Z_,"splitSections");function qR(r){return r.split(/\n{2,}/)}a(qR,"splitParagraphs");function Eoe(r){return r.join(`
|
|
339
339
|
|
|
@@ -611,7 +611,7 @@ ${g}
|
|
|
611
611
|
`);let l=new Oe.InMemoryTripleStore;await l.addAll(c.triples);let u=new tE(n,{explicitTriples:c.triples.slice(0,c.explicitCount),zeroTriplePaths:c.zeroTriplePaths}),f=new Oe.WorkflowResolver(l),d;if(pbe.test(r))d=r;else{let _=await mbe(l,r);_||(console.error(`\u274C No command found with UUID or cliName "${r}".`),process.exit(3)),d=_}let p;if(e)p=[e];else if(p=await hbe(),p.length===0)throw new Ke("No target path provided and stdin is empty.","exocortex apply <uuid> <path> OR exocortex find ... | exocortex apply <uuid>");let h=0,g=0,m=!1,b=[];for(let _ of p){let S=await ybe(n,l,f,u,d,_,t,i,s);S.ok?h++:g++,S.executed&&(m=!0),b.push(...S.created)}if(o&&t.writeThrough&&m&&c.cacheManager){let _=await EO(c.cacheManager);process.stderr.write(`${vO(_)}
|
|
612
612
|
`)}if(p.length>1&&!t.json&&console.log(`
|
|
613
613
|
\u{1F4CA} Applied to ${h}/${p.length} target(s) (${g} failed).`),t.json){let _={command:r,created:b};e?_.target=e:_.targets=p,process.stdout.write(JSON.stringify(_)+`
|
|
614
|
-
`)}g>0&&process.exit(5)}catch(n){ue.handle(n),process.exit(5)}})}a(y7,"applyCommand");at();at();var up=require("fs"),FP=require("path"),dE=te(Me());var sE=te(Ua()),oE=te(require("path")),rl=te(Me()),cE=te(Me());var bbe=rl.SDK_FLOOR_ASSETSPACE_UIDS,Tu="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb",RP="3de846cd-1f0e-4f98-8613-b8587aa15174",_be=5,aE=class{static{a(this,"CliProfileResolver")}constructor(e){this.vaultPaths=[oE.default.resolve(e.vaultPath)],this.maxExtendsDepth=e.maxExtendsDepth??_be,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,rl.transitiveDependsOnClosure)(i,t.dependsOn),o=new Set(t.folderMap.values()),c=new Set,l=[];for(let f of s){if(o.has(f)){c.add(f);continue}l.push(f)}for(let f of bbe)c.add(f);if(!Array.from(c).some(f=>o.has(f))){let f=`[CliProfileResolver] profileUid=${e} produced effective set with zero AssetSpace folder overlap (${c.size} AS UIDs incl. floor; ${t.folderMap.size} folders known). Likely cause: profile declares AssetSpace UIDs not present as descriptors, or vault has no scanned AssetSpaces. Falling back to no-filter (full vault indexed).`;return this.warn(f),{outcome:"degraded",reason:f}}return{outcome:"engaged",result:{effective:c,folderMap:t.folderMap,declaredOntologies:s,untranslated:l}}}walkProfileChain(e,t,n,i,s){if(s>this.maxExtendsDepth)throw new Error(`Profile chain exceeds max depth ${this.maxExtendsDepth} at ${e} \u2014 possible cycle`);if(i.has(e))return;i.add(e);let o=t.get(e);if(o!==void 0){for(let c of o.includes)n.add(c);typeof o.extends=="string"&&o.extends.length>0&&this.walkProfileChain(o.extends,t,n,i,s+1)}}async scanAllVaults(){let e=new Map,t=new Map,n=new Map;for(let i of this.vaultPaths){if(!await sE.default.pathExists(i)){this.warn(`[CliProfileResolver] vault path does not exist: ${i} \u2014 skipping.`);continue}let s=await this.walkVault(i);for(let o of s){let c=Ji(o.frontmatter.exo__Instance_class);if(c.some(l=>l===Tu)){let l=wbe(o.filePath,o.vaultRoot);l.length>0&&!e.has(l)&&e.set(l,o.uid);let u=typeof o.frontmatter.exo__AssetSpace_source=="string"?o.frontmatter.exo__AssetSpace_source:typeof o.frontmatter.exo__AssetSpace_git=="string"?o.frontmatter.exo__AssetSpace_git:"";if(u.length>0){let d=(0,rl.derivePath)(u);d!==null&&e.set(d,o.uid)}let f=Ji(o.frontmatter.exo__AssetSpace_dependsOn);f.length>0&&n.set(o.uid,f)}if(c.some(l=>l===RP)){let l={uid:o.uid,label:typeof o.frontmatter.exo__Asset_label=="string"?o.frontmatter.exo__Asset_label:void 0,includes:Ji(o.frontmatter.exo__Profile_includes),extends:Ji(o.frontmatter.exo__Profile_imports)[0]??null};t.set(o.uid,l)}}}return{folderMap:e,profiles:t,dependsOn:n}}async walkVault(e){let t=[],n=[e];for(;n.length>0;){let i=n.pop(),s;try{s=await sE.default.readdir(i,{withFileTypes:!0})}catch{continue}for(let o of s){let c=oE.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules"||o.name===".obsidian"||o.name===".exocortex")continue;n.push(c);continue}if(!o.isFile()||!o.name.endsWith(".md"))continue;let l=await this.tryReadFrontmatter(c);if(l===null)continue;let u=l.exo__Asset_uid;typeof u!="string"||u.length===0||t.push({uid:u,filePath:c,vaultRoot:e,frontmatter:l})}}return t}async tryReadFrontmatter(e){let t;try{t=await sE.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,rl.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Ji(r){if(r==null)return[];let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=Sbe(n);i!==null&&t.push(i)}return t}a(Ji,"parseWikilinkArray");function Sbe(r){let e=r.trim().replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0].trim();return e.length===0?null:e}a(Sbe,"extractUidFromWikilink");function wbe(r,e){let t=oE.default.relative(e,r).replace(/\\/g,"/");if(!t.startsWith("assetspaces/"))return"";let n=t.slice(12),i=n.indexOf("/");return i<0?"":`assetspaces/${n.slice(0,i)}`}a(wbe,"parentFolderRelative");var lE=te(Ua()),CP=te(require("path")),lp=te(Me());var uE=class{static{a(this,"RegistryDependencyResolver")}constructor(e={}){this.warn=e.warn??(()=>{})}async resolve(e,t){let n=await this.scanRegistry(e),i=this.matchSelf(n,t);if(i===null)return{outcome:"self-not-found",selfIdentifier:t,descriptorCount:n.size};let s=new Map;for(let m of n.values())m.dependsOn.length>0&&s.set(m.uid,m.dependsOn);let o=(0,lp.transitiveDependsOnClosure)([i.uid],s);o.delete(i.uid);let c=[],l=new Set,u=new Set([i.uid]),f=[...i.dependsOn];for(;f.length>0;){let m=f.shift();if(m===void 0||u.has(m))continue;u.add(m),o.has(m)&&!l.has(m)&&(c.push(m),l.add(m));let b=n.get(m);if(b!==void 0)for(let _ of b.dependsOn)u.has(_)||f.push(_)}for(let m of o)l.has(m)||(c.push(m),l.add(m));let d=[],p=[];for(let m of c){let b=n.get(m);b===void 0?p.push(m):d.push(b)}let h=d.filter(m=>m.source===null||m.source.length===0),g=d.filter(m=>m.source!==null&&m.source.length>0&&!Ebe(m.source));return{outcome:"resolved",self:i,dependencies:d,missingDescriptors:p,sourceless:h,unsafeSources:g}}matchSelf(e,t){let n=cp(t);if(n!==null)for(let i of e.values()){if(i.source===null)continue;let s=cp(i.source);if(s!==null&&s===n)return i}for(let i of e.values())if(i.namespace!==null&&i.namespace===t)return i;return null}async scanRegistry(e){let t=new Map,n=CP.default.resolve(e);if(!await lE.default.pathExists(n))return this.warn(`[RegistryDependencyResolver] registry path does not exist: ${n}`),t;let i=[n];for(;i.length>0;){let s=i.pop(),o;try{o=await lE.default.readdir(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=CP.default.join(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||c.name==="node_modules"||c.name===".obsidian"||c.name===".exocortex")continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=await this.tryReadFrontmatter(l);if(u===null||!Ji(u.exo__Instance_class).some(m=>m===Tu))continue;let d=u.exo__Asset_uid;if(typeof d!="string"||d.length===0)continue;let p=typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:null,h=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:null,g=Ji(u.exo__AssetSpace_dependsOn);t.has(d)&&this.warn(`[RegistryDependencyResolver] duplicate AssetSpace descriptor for uid=${d} \u2014 last wins (${l})`),t.set(d,{uid:d,namespace:h,source:p,dependsOn:g})}}return t}async tryReadFrontmatter(e){let t;try{t=await lE.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,lp.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function cp(r){let e=r.trim();if(e.length===0)return null;let t=(0,lp.derivePath)(e);if(t!==null)return t.replace(/^assetspaces\//,"").toLowerCase();if(!e.includes("://")&&!e.includes("@")){let i=e.replace(/\.git$/i,"").replace(/\/+$/,"").split("/").filter(s=>s.length>0);if(i.length===2)return`${i[0]}/${i[1]}`.toLowerCase()}return null}a(cp,"ownerRepoSlug");function Ebe(r){return typeof r!="string"||r.length===0||/[\s\x00-\x1f]/.test(r)||r.startsWith("-")||/^(ext|file|fd|ftp|ftps)::/i.test(r)?!1:!!(/^https?:\/\/[^\s]+$/i.test(r)||/^ssh:\/\/[^\s]+$/i.test(r)||/^git:\/\/[^\s]+$/i.test(r)||/^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+:[^\s]+$/.test(r))}a(Ebe,"isSafeCloneUrl");var vbe=new Set(["templates","09 templates"]);function _i(r){return r.split("/").some(e=>vbe.has(e.toLowerCase()))}a(_i,"isTemplatesPath");function Zi(r){return r.split("/").includes("node_modules")}a(Zi,"isNodeModulesPath");Rt();Ut();var S7=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Tbe=/^[A-Za-z][A-Za-z0-9-]*__[A-Za-z0-9_-]+$/,Abe=/^assetspaces\/([^/]+)\/([^/]+)\//,w7=["exo__Ontology_imports","exo__Ontology_admits","exo__Property_range","exo__Property_domain","exo__Class_superClass","exo__Property_superProperty","exo__Property_cardinality","exo__Property_minCount"],Ibe="e1d7fb5c-d334-448d-935b-953b7b033e78",Rbe="fe529085-5370-4ac0-bbe4-1c7351242dee",Cbe=5,xP=200;function fE(r){let e=Abe.exec(r.replace(/\\/g,"/"));return e?`${e[1]}/${e[2]}`.toLowerCase():null}a(fE,"assetspaceOfPath");var PP=class{constructor(){this.assets=[];this.uidToPath=new Map;this.pathSet=new Set;this.labelToPaths=new Map;this.basenameToPaths=new Map}static{a(this,"VaultIndex")}add(e){let t=e.path.replace(/\\/g,"/");this.assets.push({...e,path:t}),this.pathSet.add(t);let n=e.metadata.exo__Asset_uid;for(let c of Array.isArray(n)?n:[n])if(typeof c=="string"){let l=c.trim().toLowerCase();l.length>0&&!this.uidToPath.has(l)&&this.uidToPath.set(l,t)}let i=t.slice(t.lastIndexOf("/")+1).replace(/\.md$/,"");OP(this.basenameToPaths,i,t);let s=e.metadata.exo__Asset_label;typeof s=="string"&&s.trim().length>0&&OP(this.labelToPaths,s.trim(),t);let o=e.metadata.aliases;for(let c of Array.isArray(o)?o:[o])typeof c=="string"&&c.trim().length>0&&OP(this.labelToPaths,c.trim(),t)}resolve(e){let t=this.candidates(e);return t.length===0?null:t.length===1?t[0]:"ambiguous"}candidates(e){let t=e;if(S7.test(t)){let i=this.uidToPath.get(t.toLowerCase());return i===void 0?[]:[i]}if(t.includes("/")){let i=t.replace(/^\//,""),s=i.endsWith(".md")?i:`${i}.md`;if(this.pathSet.has(s))return[s];t=i.slice(i.lastIndexOf("/")+1)}t.endsWith(".md")&&(t=t.slice(0,-3));let n=this.distinctByUid(this.labelToPaths.get(t));return n.length>0?n:this.distinctByUid(this.basenameToPaths.get(t))}distinctByUid(e){if(!e||e.size===0)return[];let t=new Set,n=[];for(let i of e){let s=this.assets.find(l=>l.path===i),o=s?s.metadata.exo__Asset_uid:void 0,c=typeof o=="string"?o.trim().toLowerCase():`path:${i}`;t.has(c)||(t.add(c),n.push(i))}return n}};function OP(r,e,t){let n=r.get(e);n?n.add(t):r.set(e,new Set([t]))}a(OP,"addTo");function bg(r){if(Array.isArray(r)){let e=r.find(t=>typeof t=="string");return typeof e=="string"?e:null}return typeof r=="string"?r:null}a(bg,"firstString");function xbe(r){let e=Ji(r);if(e.length===0)return"unkinded";let t=e[0].toLowerCase();return t===Ibe?"TBox":t===Rbe?"Reference":"unknown"}a(xbe,"kindOf");function Obe(r){return r==null?0:(Array.isArray(r)?r:[r]).filter(t=>typeof t=="object"&&t!==null).length}a(Obe,"countStructuredItems");function Pbe(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=n.trim().replace(/^["']|["']$/g,""),s=i.startsWith("[[")&&i.endsWith("]]"),o=(0,dE.extractAssetReference)(i);if(!o)continue;let c=o.split("#")[0].trim();c.length!==0&&(s||S7.test(c)||Tbe.test(c))&&t.push(c)}return t}a(Pbe,"referencesOf");function b7(r){let e=new Map;for(let t of r){if(Zi(t.path)||_i(t.path)||!Ji(t.metadata.exo__Instance_class).some(c=>c.toLowerCase()===Tu))continue;let i=bg(t.metadata.exo__Asset_uid);if(!i)continue;let s=i.trim().toLowerCase();if(e.has(s))continue;let o=bg(t.metadata.exo__AssetSpace_source)??bg(t.metadata.exo__AssetSpace_git);e.set(s,{uid:s,slug:o?cp(o):null,label:bg(t.metadata.exo__Asset_label)??t.path,path:t.path,dependsOn:Ji(t.metadata.exo__AssetSpace_dependsOn).map(c=>c.toLowerCase()),kind:xbe(t.metadata.exo__AssetSpace_dependsOnKind)})}return e}a(b7,"collectDescriptors");async function Fbe(r){let e=new PP,t=new Set,n=new Cn(r.vault,{cacheContent:!1});for(let F of await n.indexedAssets()){if(Zi(F.path)||_i(F.path))continue;let H=bg(F.metadata.exo__Asset_uid),ae=H?H.trim().toLowerCase():`path:${F.path}`;t.has(ae)||(t.add(ae),e.add(F))}let i,s;if(r.registry){let F=new Cn(r.registry,{cacheContent:!1});s=b7(await F.indexedAssets()),i=r.registry}else s=b7(e.assets),i="vault";let o=new Map,c=[],l=new Map;for(let F of s.values()){if(F.slug===null){c.push(F.label);continue}o.set(F.uid,F.slug);let H=l.get(F.slug);H?H.push(F.uid):l.set(F.slug,[F.uid])}let u=[...l.entries()].filter(([,F])=>F.length>1).map(([F,H])=>({slug:F,uids:H})),f=new Map;for(let F of s.values())F.slug&&f.set(F.slug,F.kind);let d=new Map,p=[],h=0,g=new Set;for(let F of s.values())if(F.slug!==null)for(let H of F.dependsOn){let ae=o.get(H);if(ae===void 0){p.push({source:F.slug,ref:H});continue}if(ae===F.slug)continue;let Se=d.get(F.slug);Se||(Se=[],d.set(F.slug,Se)),Se.includes(ae)||(Se.push(ae),h++,g.add(ae))}let m=null;r.self!==void 0&&(m=cp(r.self),m===null&&(m=r.self.trim().toLowerCase()));let b=new Map,_=a(F=>{let H=b.get(F);if(H!==void 0)return H;let ae=(0,dE.transitiveDependsOnClosure)([F],d);return b.set(F,ae),ae},"closureOf"),S=r.missingDeps??[];if(S.length>0&&m===null)throw new Ke("--missing-dep / --missing-deps-file require --self: in vault mode unresolved refs are already fail-open, so the inputs would be a silent no-op","Pass --self <owner/repo> (the per-repo CI mode) together with the missing deps");let I=[...new Set(S.map(F=>cp(F)??F.trim().toLowerCase()).filter(F=>F.length>0&&F!==m))].sort(),E=m!==null?_(m):new Set,w=new Set;for(let F of e.assets){let H=fE(F.path);H!==null&&w.add(H)}let R=I.filter(F=>w.has(F)),x=I.filter(F=>E.has(F)&&!w.has(F)),P=I.filter(F=>!E.has(F)&&!w.has(F)),k=r.strictUnresolved===!0,B=m!==null&&!k&&x.length>0,D=new Map,Q=[],fe=0,j=[],ce=0,V=0,oe=0,K=[],z=0,Z=0,Ie=0,ee=0;for(let F of e.assets){let H=fE(F.path);if(H!==null&&!(m!==null&&H!==m)){Ie++;for(let ae of w7){let Se=F.metadata[ae],Ce=Obe(Se);Ce>0&&(z+=Ce,K.length<xP&&K.push({sourcePath:F.path,predicate:ae}));let qe=Pbe(Se);for(let Fe of qe){let De=e.candidates(Fe);if(De.length===0){fe++,Q.length<xP&&Q.push({source:H,sourcePath:F.path,predicate:ae,ref:Fe,reason:"not-found"});continue}if(De.length>1){let nt=[...new Set(De.map(O=>fE(O)??"<outside assetspaces/>"))].sort(),et=_(H),C=nt.every(O=>O===H||et.has(O));ce++,C?V++:oe++,j.length<xP&&j.push({source:H,sourcePath:F.path,predicate:ae,ref:Fe,candidates:nt,coveredByClosure:C});continue}let We=De[0],xe=fE(We);if(xe===null){Z++;continue}if(xe===H)continue;ee++;let Be=`${H} ${xe}`,Ze=D.get(Be);Ze||(Ze={source:H,target:xe,occurrences:0,predicates:{},examples:[],coveredDirect:d.get(H)?.includes(xe)??!1,coveredByClosure:_(H).has(xe)},D.set(Be,Ze)),Ze.occurrences++,Ze.predicates[ae]=(Ze.predicates[ae]??0)+1,Ze.examples.length<Cbe&&Ze.examples.push(`${F.path} --${ae}--> ${Fe}`)}}}}let Y=[...D.values()].sort((F,H)=>Number(F.coveredByClosure)-Number(H.coveredByClosure)||Number(F.coveredDirect)-Number(H.coveredDirect)||F.source.localeCompare(H.source)||F.target.localeCompare(H.target)),se=Y.filter(F=>F.coveredByClosure).length,X=Y.filter(F=>!F.coveredDirect).length,le=m!==null,Ue=m!==null&&!B,$=B?fe:0,de=Y.filter(F=>!F.coveredByClosure).length+(le?oe:0)+(Ue?fe:0),ie=new Set(Y.map(F=>`${F.source} ${F.target}`)),Ae=[],ye={TBox:0,unkinded:0,unknown:0},Te=0;for(let[F,H]of d)if(!(m!==null&&F!==m))for(let ae of H){let Se=f.get(ae)??"unknown";if(Se==="Reference"){Te++;continue}let Ce=ie.has(`${F} ${ae}`);Ce||(Ae.push({source:F,target:ae,targetKind:Se,hasFact:Ce}),ye[Se]++)}Ae.sort((F,H)=>F.source.localeCompare(H.source)||F.target.localeCompare(H.target));let Re=[...g].filter(F=>(f.get(F)??"unknown")==="unkinded").sort(),pe,U=null;return s.size===0?(pe="BROKEN",U=`no exo__AssetSpace descriptor found (registry: ${i}) \u2014 nothing to judge against`):m!==null&&!l.has(m)?(pe="BROKEN",U=`--self '${r.self}' (${m}) is not a registered AssetSpace (${s.size} descriptor(s) scanned)`):m!==null&&Ie===0?(pe="BROKEN",U=`--self '${m}': no asset under assetspaces/${m}/ in the vault \u2014 the self content was not merged`):m===null&&Y.length===0?(pe="BROKEN",U="zero definition-tier cross-AssetSpace fact edges \u2014 an empty population cannot be declared covered"):pe=de===0?"OK":"FAIL",{vaultPath:r.vault,registrySource:i,self:m,verdict:pe,brokenReason:U,descriptors:{count:s.size,sourceless:c,duplicateSlugs:u,declaredEdgeCount:h,carriers:d.size,targets:g.size,danglingDeclarations:p},facts:{edgeCount:Y.length,occurrences:ee,sources:new Set(Y.map(F=>F.source)).size,targets:new Set(Y.map(F=>F.target)).size,coveredByClosure:se,uncoveredDirect:X,uncoveredByClosure:de,edges:Y},unresolved:{count:fe,countedAsUncovered:Ue,excusedWhileDepsMissing:$,refs:Q},degraded:{active:B,strict:k,missingDeps:I,missingDepsInClosure:x,missingDepsOutsideClosure:P,missingDepsPresentInVault:R,unresolvedExcused:$},ambiguous:{count:ce,coveredByClosure:V,uncovered:oe,countedAsUncovered:le,refs:j},nonStringValues:{count:z,sites:K},targetsOutsideAssetspaces:Z,scannedSources:Ie,declaredWithoutFact:{total:Ae.length,byKind:ye,edges:Ae},packaging:Te,targetsWithoutKind:Re,clean:pe==="OK"}}a(Fbe,"scanAssetSpaceDepends");function Dbe(r){return Object.entries(r).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>`${e.replace(/^exo__/,"")}\xD7${t}`).join(", ")}a(Dbe,"formatPredicates");function Lbe(r){let e=r.verdict==="OK"?console.log:console.error,n=`[${r.vaultPath.replace(/\/+$/,"").split("/").pop()??r.vaultPath}${r.self?`, self=${r.self}`:""}, tier=definitions]`,i=r.degraded.active?` (DEGRADED: declared deps absent from merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:"";e(`${r.verdict}${i} ${r.vaultPath}: assetspace-depends audit ${n} \u2014 uncovered by CLOSURE: ${r.facts.uncoveredByClosure} (verdict), uncovered DIRECTLY: ${r.facts.uncoveredDirect} (informational, not a criterion), ambiguous refs: ${r.ambiguous.count} (covered ${r.ambiguous.coveredByClosure} / uncovered ${r.ambiguous.uncovered}${r.ambiguous.countedAsUncovered?", counted in the verdict":", listed only"}), non-string values under definition-tier predicates: ${r.nonStringValues.count} (skipped, not judged)`),r.brokenReason&&e(`\u26D4 BROKEN: ${r.brokenReason}`),e(`Registry (${r.registrySource}): ${r.descriptors.count} descriptor(s), declared dependsOn edges: ${r.descriptors.declaredEdgeCount} (carriers ${r.descriptors.carriers} \u2192 targets ${r.descriptors.targets}), dangling: ${r.descriptors.danglingDeclarations.length}, sourceless: ${r.descriptors.sourceless.length}, duplicate owner/repo: ${r.descriptors.duplicateSlugs.length}`),e(`Facts (definition tier, ${w7.length} predicates): ${r.facts.edgeCount} cross-AssetSpace edge(s) / ${r.facts.occurrences} occurrence(s) (sources ${r.facts.sources} \u2192 targets ${r.facts.targets}, scanned ${r.scannedSources} source asset(s)); canary covered-by-closure = ${r.facts.coveredByClosure}`);let s=r.degraded.active?`(--self, DEGRADED: NOT counted \u2014 declared deps absent from the merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:r.unresolved.countedAsUncovered?r.degraded.strict&&r.degraded.missingDeps.length>0?`(--self --strict-unresolved: counted as uncovered despite declared missing deps ${r.degraded.missingDeps.join(", ")})`:"(--self: counted as uncovered \u2014 target absent from the merged vault)":"(fail-open, listed, NOT counted \u2014 validate-wikilinks territory)";e(`Unresolved definition-tier refs: ${r.unresolved.count} ${s}; targets outside assetspaces/: ${r.targetsOutsideAssetspaces}`),r.degraded.active&&e(`\u26A0 unresolved refs excused: ${r.degraded.unresolvedExcused} \u2014 may include refs into undeclared absent AssetSpaces; coverage NOT proven for them (DEGRADED \u2260 proven coverage)`),r.degraded.missingDepsOutsideClosure.length>0&&e(`\u26A0 --missing-dep outside closure(self) \u2014 excuses nothing: ${r.degraded.missingDepsOutsideClosure.join(", ")}`),r.degraded.missingDepsPresentInVault.length>0&&e(`\u26A0 --missing-dep named but PRESENT in the vault (assets found under its assetspaces/ folder) \u2014 ignored, excuses nothing: ${r.degraded.missingDepsPresentInVault.join(", ")}`),e(`Declared without a definition-tier fact (one-sided, never a violation; Reference-kind targets excluded): ${r.declaredWithoutFact.total} \u2014 TBox: ${r.declaredWithoutFact.byKind.TBox}, unkinded: ${r.declaredWithoutFact.byKind.unkinded}, unknown-kind: ${r.declaredWithoutFact.byKind.unknown}; packaging declarations (Reference-kind targets, frame p.4): ${r.packaging}`),e(`Declared targets without exo__AssetSpace_dependsOnKind: ${r.targetsWithoutKind.length}`+(r.targetsWithoutKind.length>0?` \u2014 ${r.targetsWithoutKind.join(", ")}`:"")),e("Declared-graph cycles are NOT judged by this verb (dependsOn = packaging, RFC 306dcb5c frame p.1); facts-graph acyclicity is the scheduled detector's job.");let o=r.facts.edges.filter(l=>!l.coveredByClosure);if(o.length>0){console.error(`
|
|
614
|
+
`)}g>0&&process.exit(5)}catch(n){ue.handle(n),process.exit(5)}})}a(y7,"applyCommand");at();at();var up=require("fs"),FP=require("path"),dE=te(Me());var sE=te(Ua()),oE=te(require("path")),rl=te(Me()),cE=te(Me());var bbe=rl.SDK_FLOOR_ASSETSPACE_UIDS,Tu="73bd00e4-ccc0-4f3f-b20d-c4388c4588fb",RP="3de846cd-1f0e-4f98-8613-b8587aa15174",_be=5,aE=class{static{a(this,"CliProfileResolver")}constructor(e){this.vaultPaths=[oE.default.resolve(e.vaultPath)],this.maxExtendsDepth=e.maxExtendsDepth??_be,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,rl.transitiveDependsOnClosure)(i,t.dependsOn),o=new Set(t.folderMap.values()),c=new Set,l=[];for(let f of s){if(o.has(f)){c.add(f);continue}l.push(f)}for(let f of bbe)c.add(f);if(!Array.from(c).some(f=>o.has(f))){let f=`[CliProfileResolver] profileUid=${e} produced effective set with zero AssetSpace folder overlap (${c.size} AS UIDs incl. floor; ${t.folderMap.size} folders known). Likely cause: profile declares AssetSpace UIDs not present as descriptors, or vault has no scanned AssetSpaces. Falling back to no-filter (full vault indexed).`;return this.warn(f),{outcome:"degraded",reason:f}}return{outcome:"engaged",result:{effective:c,folderMap:t.folderMap,declaredOntologies:s,untranslated:l}}}walkProfileChain(e,t,n,i,s){if(s>this.maxExtendsDepth)throw new Error(`Profile chain exceeds max depth ${this.maxExtendsDepth} at ${e} \u2014 possible cycle`);if(i.has(e))return;i.add(e);let o=t.get(e);if(o!==void 0){for(let c of o.includes)n.add(c);typeof o.extends=="string"&&o.extends.length>0&&this.walkProfileChain(o.extends,t,n,i,s+1)}}async scanAllVaults(){let e=new Map,t=new Map,n=new Map;for(let i of this.vaultPaths){if(!await sE.default.pathExists(i)){this.warn(`[CliProfileResolver] vault path does not exist: ${i} \u2014 skipping.`);continue}let s=await this.walkVault(i);for(let o of s){let c=Ji(o.frontmatter.exo__Instance_class);if(c.some(l=>l===Tu)){let l=wbe(o.filePath,o.vaultRoot);l.length>0&&!e.has(l)&&e.set(l,o.uid);let u=typeof o.frontmatter.exo__AssetSpace_source=="string"?o.frontmatter.exo__AssetSpace_source:typeof o.frontmatter.exo__AssetSpace_git=="string"?o.frontmatter.exo__AssetSpace_git:"";if(u.length>0){let d=(0,rl.derivePath)(u);d!==null&&e.set(d,o.uid)}let f=Ji(o.frontmatter.exo__AssetSpace_dependsOn);f.length>0&&n.set(o.uid,f)}if(c.some(l=>l===RP)){let l={uid:o.uid,label:typeof o.frontmatter.exo__Asset_label=="string"?o.frontmatter.exo__Asset_label:void 0,includes:Ji(o.frontmatter.exo__Profile_includes),extends:Ji(o.frontmatter.exo__Profile_imports)[0]??null};t.set(o.uid,l)}}}return{folderMap:e,profiles:t,dependsOn:n}}async walkVault(e){let t=[],n=[e];for(;n.length>0;){let i=n.pop(),s;try{s=await sE.default.readdir(i,{withFileTypes:!0})}catch{continue}for(let o of s){let c=oE.default.join(i,o.name);if(o.isDirectory()){if(o.name.startsWith(".")||o.name==="node_modules"||o.name===".obsidian"||o.name===".exocortex")continue;n.push(c);continue}if(!o.isFile()||!o.name.endsWith(".md"))continue;let l=await this.tryReadFrontmatter(c);if(l===null)continue;let u=l.exo__Asset_uid;typeof u!="string"||u.length===0||t.push({uid:u,filePath:c,vaultRoot:e,frontmatter:l})}}return t}async tryReadFrontmatter(e){let t;try{t=await sE.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,rl.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function Ji(r){if(r==null)return[];let e=Array.isArray(r)?r:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=Sbe(n);i!==null&&t.push(i)}return t}a(Ji,"parseWikilinkArray");function Sbe(r){let e=r.trim().replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0].trim();return e.length===0?null:e}a(Sbe,"extractUidFromWikilink");function wbe(r,e){let t=oE.default.relative(e,r).replace(/\\/g,"/");if(!t.startsWith("assetspaces/"))return"";let n=t.slice(12),i=n.indexOf("/");return i<0?"":`assetspaces/${n.slice(0,i)}`}a(wbe,"parentFolderRelative");var lE=te(Ua()),CP=te(require("path")),lp=te(Me());var uE=class{static{a(this,"RegistryDependencyResolver")}constructor(e={}){this.warn=e.warn??(()=>{})}async resolve(e,t){let n=await this.scanRegistry(e),i=this.matchSelf(n,t);if(i===null)return{outcome:"self-not-found",selfIdentifier:t,descriptorCount:n.size};let s=new Map;for(let m of n.values())m.dependsOn.length>0&&s.set(m.uid,m.dependsOn);let o=(0,lp.transitiveDependsOnClosure)([i.uid],s);o.delete(i.uid);let c=[],l=new Set,u=new Set([i.uid]),f=[...i.dependsOn];for(;f.length>0;){let m=f.shift();if(m===void 0||u.has(m))continue;u.add(m),o.has(m)&&!l.has(m)&&(c.push(m),l.add(m));let b=n.get(m);if(b!==void 0)for(let _ of b.dependsOn)u.has(_)||f.push(_)}for(let m of o)l.has(m)||(c.push(m),l.add(m));let d=[],p=[];for(let m of c){let b=n.get(m);b===void 0?p.push(m):d.push(b)}let h=d.filter(m=>m.source===null||m.source.length===0),g=d.filter(m=>m.source!==null&&m.source.length>0&&!Ebe(m.source));return{outcome:"resolved",self:i,dependencies:d,missingDescriptors:p,sourceless:h,unsafeSources:g}}matchSelf(e,t){let n=cp(t);if(n!==null)for(let i of e.values()){if(i.source===null)continue;let s=cp(i.source);if(s!==null&&s===n)return i}for(let i of e.values())if(i.namespace!==null&&i.namespace===t)return i;return null}async scanRegistry(e){let t=new Map,n=CP.default.resolve(e);if(!await lE.default.pathExists(n))return this.warn(`[RegistryDependencyResolver] registry path does not exist: ${n}`),t;let i=[n];for(;i.length>0;){let s=i.pop(),o;try{o=await lE.default.readdir(s,{withFileTypes:!0})}catch{continue}for(let c of o){let l=CP.default.join(s,c.name);if(c.isDirectory()){if(c.name.startsWith(".")||c.name==="node_modules"||c.name===".obsidian"||c.name===".exocortex")continue;i.push(l);continue}if(!c.isFile()||!c.name.endsWith(".md"))continue;let u=await this.tryReadFrontmatter(l);if(u===null||!Ji(u.exo__Instance_class).some(m=>m===Tu))continue;let d=u.exo__Asset_uid;if(typeof d!="string"||d.length===0)continue;let p=typeof u.exo__AssetSpace_source=="string"?u.exo__AssetSpace_source:typeof u.exo__AssetSpace_git=="string"?u.exo__AssetSpace_git:null,h=typeof u.exo__AssetSpace_namespace=="string"?u.exo__AssetSpace_namespace:null,g=Ji(u.exo__AssetSpace_dependsOn);t.has(d)&&this.warn(`[RegistryDependencyResolver] duplicate AssetSpace descriptor for uid=${d} \u2014 last wins (${l})`),t.set(d,{uid:d,namespace:h,source:p,dependsOn:g})}}return t}async tryReadFrontmatter(e){let t;try{t=await lE.default.readFile(e,"utf-8")}catch{return null}if(!t.startsWith("---"))return null;let n=t.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(n===null)return null;try{let i=(0,lp.parseYamlFrontmatterTolerant)(n[1],e);return i&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{return null}}};function cp(r){let e=r.trim();if(e.length===0)return null;let t=(0,lp.derivePath)(e);if(t!==null)return t.replace(/^assetspaces\//,"").toLowerCase();if(!e.includes("://")&&!e.includes("@")){let i=e.replace(/\.git$/i,"").replace(/\/+$/,"").split("/").filter(s=>s.length>0);if(i.length===2)return`${i[0]}/${i[1]}`.toLowerCase()}return null}a(cp,"ownerRepoSlug");function Ebe(r){return typeof r!="string"||r.length===0||/[\s\x00-\x1f]/.test(r)||r.startsWith("-")||/^(ext|file|fd|ftp|ftps)::/i.test(r)?!1:!!(/^https?:\/\/[^\s]+$/i.test(r)||/^ssh:\/\/[^\s]+$/i.test(r)||/^git:\/\/[^\s]+$/i.test(r)||/^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+:[^\s]+$/.test(r))}a(Ebe,"isSafeCloneUrl");var vbe=new Set(["templates","09 templates"]);function _i(r){return r.split("/").some(e=>vbe.has(e.toLowerCase()))}a(_i,"isTemplatesPath");function Zi(r){return r.split("/").includes("node_modules")}a(Zi,"isNodeModulesPath");Rt();Ut();var S7=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Tbe=/^[A-Za-z][A-Za-z0-9-]*__[A-Za-z0-9_-]+$/,Abe=/^assetspaces\/([^/]+)\/([^/]+)\//,w7=["exo__Ontology_imports","exo__Ontology_admits","exo__Property_range","exo__Property_domain","exo__Class_superClass","exo__Property_superProperty","exo__Property_cardinality","exo__Property_minCount"],Ibe="e1d7fb5c-d334-448d-935b-953b7b033e78",Rbe="fe529085-5370-4ac0-bbe4-1c7351242dee",Cbe=5,xP=200;function fE(r){let e=Abe.exec(r.replace(/\\/g,"/"));return e?`${e[1]}/${e[2]}`.toLowerCase():null}a(fE,"assetspaceOfPath");var PP=class{constructor(){this.assets=[];this.uidToPath=new Map;this.pathSet=new Set;this.labelToPaths=new Map;this.basenameToPaths=new Map}static{a(this,"VaultIndex")}add(e){let t=e.path.replace(/\\/g,"/");this.assets.push({...e,path:t}),this.pathSet.add(t);let n=e.metadata.exo__Asset_uid;for(let c of Array.isArray(n)?n:[n])if(typeof c=="string"){let l=c.trim().toLowerCase();l.length>0&&!this.uidToPath.has(l)&&this.uidToPath.set(l,t)}let i=t.slice(t.lastIndexOf("/")+1).replace(/\.md$/,"");OP(this.basenameToPaths,i,t);let s=e.metadata.exo__Asset_label;typeof s=="string"&&s.trim().length>0&&OP(this.labelToPaths,s.trim(),t);let o=e.metadata.aliases;for(let c of Array.isArray(o)?o:[o])typeof c=="string"&&c.trim().length>0&&OP(this.labelToPaths,c.trim(),t)}resolve(e){let t=this.candidates(e);return t.length===0?null:t.length===1?t[0]:"ambiguous"}candidates(e){let t=e;if(S7.test(t)){let i=this.uidToPath.get(t.toLowerCase());return i===void 0?[]:[i]}if(t.includes("/")){let i=t.replace(/^\//,""),s=i.endsWith(".md")?i:`${i}.md`;if(this.pathSet.has(s))return[s];t=i.slice(i.lastIndexOf("/")+1)}t.endsWith(".md")&&(t=t.slice(0,-3));let n=this.distinctByUid(this.labelToPaths.get(t));return n.length>0?n:this.distinctByUid(this.basenameToPaths.get(t))}distinctByUid(e){if(!e||e.size===0)return[];let t=new Set,n=[];for(let i of e){let s=this.assets.find(l=>l.path===i),o=s?s.metadata.exo__Asset_uid:void 0,c=typeof o=="string"?o.trim().toLowerCase():`path:${i}`;t.has(c)||(t.add(c),n.push(i))}return n}};function OP(r,e,t){let n=r.get(e);n?n.add(t):r.set(e,new Set([t]))}a(OP,"addTo");function bg(r){if(Array.isArray(r)){let e=r.find(t=>typeof t=="string");return typeof e=="string"?e:null}return typeof r=="string"?r:null}a(bg,"firstString");function xbe(r){let e=Ji(r);if(e.length===0)return"unkinded";let t=e[0].toLowerCase();return t===Ibe?"TBox":t===Rbe?"Reference":"unknown"}a(xbe,"kindOf");function Obe(r){return r==null?0:(Array.isArray(r)?r:[r]).filter(t=>typeof t=="object"&&t!==null).length}a(Obe,"countStructuredItems");function Pbe(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){if(typeof n!="string")continue;let i=n.trim().replace(/^["']|["']$/g,""),s=i.startsWith("[[")&&i.endsWith("]]"),o=(0,dE.extractAssetReference)(i);if(!o)continue;let c=o.split("#")[0].trim();c.length!==0&&(s||S7.test(c)||Tbe.test(c))&&t.push(c)}return t}a(Pbe,"referencesOf");function b7(r){let e=new Map;for(let t of r){if(Zi(t.path)||_i(t.path)||!Ji(t.metadata.exo__Instance_class).some(c=>c.toLowerCase()===Tu))continue;let i=bg(t.metadata.exo__Asset_uid);if(!i)continue;let s=i.trim().toLowerCase();if(e.has(s))continue;let o=bg(t.metadata.exo__AssetSpace_source)??bg(t.metadata.exo__AssetSpace_git);e.set(s,{uid:s,slug:o?cp(o):null,label:bg(t.metadata.exo__Asset_label)??t.path,path:t.path,dependsOn:Ji(t.metadata.exo__AssetSpace_dependsOn).map(c=>c.toLowerCase()),kind:xbe(t.metadata.exo__AssetSpace_dependsOnKind)})}return e}a(b7,"collectDescriptors");async function Fbe(r){let e=new PP,t=new Set,n=new Cn(r.vault,{cacheContent:!1});for(let F of await n.indexedAssets()){if(Zi(F.path)||_i(F.path))continue;let H=bg(F.metadata.exo__Asset_uid),ae=H?H.trim().toLowerCase():`path:${F.path}`;t.has(ae)||(t.add(ae),e.add(F))}let i,s;if(r.registry){let F=new Cn(r.registry,{cacheContent:!1});s=b7(await F.indexedAssets()),i=r.registry}else s=b7(e.assets),i="vault";let o=new Map,c=[],l=new Map;for(let F of s.values()){if(F.slug===null){c.push(F.label);continue}o.set(F.uid,F.slug);let H=l.get(F.slug);H?H.push(F.uid):l.set(F.slug,[F.uid])}let u=[...l.entries()].filter(([,F])=>F.length>1).map(([F,H])=>({slug:F,uids:H})),f=new Map;for(let F of s.values())F.slug&&f.set(F.slug,F.kind);let d=new Map,p=[],h=0,g=new Set;for(let F of s.values())if(F.slug!==null)for(let H of F.dependsOn){let ae=o.get(H);if(ae===void 0){p.push({source:F.slug,ref:H});continue}if(ae===F.slug)continue;let Se=d.get(F.slug);Se||(Se=[],d.set(F.slug,Se)),Se.includes(ae)||(Se.push(ae),h++,g.add(ae))}let m=null;r.self!==void 0&&(m=cp(r.self),m===null&&(m=r.self.trim().toLowerCase()));let b=new Map,_=a(F=>{let H=b.get(F);if(H!==void 0)return H;let ae=(0,dE.transitiveDependsOnClosure)([F],d);return b.set(F,ae),ae},"closureOf"),S=r.missingDeps??[];if(S.length>0&&m===null)throw new Ke("--missing-dep / --missing-deps-file require --self: in vault mode unresolved refs are already fail-open, so the inputs would be a silent no-op","Pass --self <owner/repo> (the per-repo CI mode) together with the missing deps");let I=[...new Set(S.map(F=>cp(F)??F.trim().toLowerCase()).filter(F=>F.length>0&&F!==m))].sort(),E=m!==null?_(m):new Set,w=new Set;for(let F of e.assets){let H=fE(F.path);H!==null&&w.add(H)}let R=I.filter(F=>w.has(F)),x=I.filter(F=>E.has(F)&&!w.has(F)),P=I.filter(F=>!E.has(F)&&!w.has(F)),k=r.strictUnresolved===!0,B=m!==null&&!k&&x.length>0,D=new Map,Q=[],fe=0,j=[],ce=0,V=0,oe=0,K=[],z=0,Z=0,Ie=0,ee=0;for(let F of e.assets){let H=fE(F.path);if(H!==null&&!(m!==null&&H!==m)){Ie++;for(let ae of w7){let Se=F.metadata[ae],Ce=Obe(Se);Ce>0&&(z+=Ce,K.length<xP&&K.push({sourcePath:F.path,predicate:ae}));let qe=Pbe(Se);for(let Fe of qe){let De=e.candidates(Fe);if(De.length===0){fe++,Q.length<xP&&Q.push({source:H,sourcePath:F.path,predicate:ae,ref:Fe,reason:"not-found"});continue}if(De.length>1){let nt=[...new Set(De.map(O=>fE(O)??"<outside assetspaces/>"))].sort(),et=_(H),C=nt.every(O=>O===H||et.has(O));ce++,C?V++:oe++,j.length<xP&&j.push({source:H,sourcePath:F.path,predicate:ae,ref:Fe,candidates:nt,coveredByClosure:C});continue}let We=De[0],xe=fE(We);if(xe===null){Z++;continue}if(xe===H)continue;ee++;let Be=`${H} ${xe}`,Ze=D.get(Be);Ze||(Ze={source:H,target:xe,occurrences:0,predicates:{},examples:[],coveredDirect:d.get(H)?.includes(xe)??!1,coveredByClosure:_(H).has(xe)},D.set(Be,Ze)),Ze.occurrences++,Ze.predicates[ae]=(Ze.predicates[ae]??0)+1,Ze.examples.length<Cbe&&Ze.examples.push(`${F.path} --${ae}--> ${Fe}`)}}}}let Y=[...D.values()].sort((F,H)=>Number(F.coveredByClosure)-Number(H.coveredByClosure)||Number(F.coveredDirect)-Number(H.coveredDirect)||F.source.localeCompare(H.source)||F.target.localeCompare(H.target)),se=Y.filter(F=>F.coveredByClosure).length,X=Y.filter(F=>!F.coveredDirect).length,le=m!==null,Ue=m!==null&&!B,$=B?fe:0,de=Y.filter(F=>!F.coveredByClosure).length+(le?oe:0)+(Ue?fe:0),ie=new Set(Y.map(F=>`${F.source} ${F.target}`)),Ae=[],ye={TBox:0,unkinded:0,unknown:0},ve=0;for(let[F,H]of d)if(!(m!==null&&F!==m))for(let ae of H){let Se=f.get(ae)??"unknown";if(Se==="Reference"){ve++;continue}let Ce=ie.has(`${F} ${ae}`);Ce||(Ae.push({source:F,target:ae,targetKind:Se,hasFact:Ce}),ye[Se]++)}Ae.sort((F,H)=>F.source.localeCompare(H.source)||F.target.localeCompare(H.target));let Re=[...g].filter(F=>(f.get(F)??"unknown")==="unkinded").sort(),pe,U=null;return s.size===0?(pe="BROKEN",U=`no exo__AssetSpace descriptor found (registry: ${i}) \u2014 nothing to judge against`):m!==null&&!l.has(m)?(pe="BROKEN",U=`--self '${r.self}' (${m}) is not a registered AssetSpace (${s.size} descriptor(s) scanned)`):m!==null&&Ie===0?(pe="BROKEN",U=`--self '${m}': no asset under assetspaces/${m}/ in the vault \u2014 the self content was not merged`):m===null&&Y.length===0?(pe="BROKEN",U="zero definition-tier cross-AssetSpace fact edges \u2014 an empty population cannot be declared covered"):pe=de===0?"OK":"FAIL",{vaultPath:r.vault,registrySource:i,self:m,verdict:pe,brokenReason:U,descriptors:{count:s.size,sourceless:c,duplicateSlugs:u,declaredEdgeCount:h,carriers:d.size,targets:g.size,danglingDeclarations:p},facts:{edgeCount:Y.length,occurrences:ee,sources:new Set(Y.map(F=>F.source)).size,targets:new Set(Y.map(F=>F.target)).size,coveredByClosure:se,uncoveredDirect:X,uncoveredByClosure:de,edges:Y},unresolved:{count:fe,countedAsUncovered:Ue,excusedWhileDepsMissing:$,refs:Q},degraded:{active:B,strict:k,missingDeps:I,missingDepsInClosure:x,missingDepsOutsideClosure:P,missingDepsPresentInVault:R,unresolvedExcused:$},ambiguous:{count:ce,coveredByClosure:V,uncovered:oe,countedAsUncovered:le,refs:j},nonStringValues:{count:z,sites:K},targetsOutsideAssetspaces:Z,scannedSources:Ie,declaredWithoutFact:{total:Ae.length,byKind:ye,edges:Ae},packaging:ve,targetsWithoutKind:Re,clean:pe==="OK"}}a(Fbe,"scanAssetSpaceDepends");function Dbe(r){return Object.entries(r).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>`${e.replace(/^exo__/,"")}\xD7${t}`).join(", ")}a(Dbe,"formatPredicates");function Lbe(r){let e=r.verdict==="OK"?console.log:console.error,n=`[${r.vaultPath.replace(/\/+$/,"").split("/").pop()??r.vaultPath}${r.self?`, self=${r.self}`:""}, tier=definitions]`,i=r.degraded.active?` (DEGRADED: declared deps absent from merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:"";e(`${r.verdict}${i} ${r.vaultPath}: assetspace-depends audit ${n} \u2014 uncovered by CLOSURE: ${r.facts.uncoveredByClosure} (verdict), uncovered DIRECTLY: ${r.facts.uncoveredDirect} (informational, not a criterion), ambiguous refs: ${r.ambiguous.count} (covered ${r.ambiguous.coveredByClosure} / uncovered ${r.ambiguous.uncovered}${r.ambiguous.countedAsUncovered?", counted in the verdict":", listed only"}), non-string values under definition-tier predicates: ${r.nonStringValues.count} (skipped, not judged)`),r.brokenReason&&e(`\u26D4 BROKEN: ${r.brokenReason}`),e(`Registry (${r.registrySource}): ${r.descriptors.count} descriptor(s), declared dependsOn edges: ${r.descriptors.declaredEdgeCount} (carriers ${r.descriptors.carriers} \u2192 targets ${r.descriptors.targets}), dangling: ${r.descriptors.danglingDeclarations.length}, sourceless: ${r.descriptors.sourceless.length}, duplicate owner/repo: ${r.descriptors.duplicateSlugs.length}`),e(`Facts (definition tier, ${w7.length} predicates): ${r.facts.edgeCount} cross-AssetSpace edge(s) / ${r.facts.occurrences} occurrence(s) (sources ${r.facts.sources} \u2192 targets ${r.facts.targets}, scanned ${r.scannedSources} source asset(s)); canary covered-by-closure = ${r.facts.coveredByClosure}`);let s=r.degraded.active?`(--self, DEGRADED: NOT counted \u2014 declared deps absent from the merged vault: ${r.degraded.missingDepsInClosure.join(", ")})`:r.unresolved.countedAsUncovered?r.degraded.strict&&r.degraded.missingDeps.length>0?`(--self --strict-unresolved: counted as uncovered despite declared missing deps ${r.degraded.missingDeps.join(", ")})`:"(--self: counted as uncovered \u2014 target absent from the merged vault)":"(fail-open, listed, NOT counted \u2014 validate-wikilinks territory)";e(`Unresolved definition-tier refs: ${r.unresolved.count} ${s}; targets outside assetspaces/: ${r.targetsOutsideAssetspaces}`),r.degraded.active&&e(`\u26A0 unresolved refs excused: ${r.degraded.unresolvedExcused} \u2014 may include refs into undeclared absent AssetSpaces; coverage NOT proven for them (DEGRADED \u2260 proven coverage)`),r.degraded.missingDepsOutsideClosure.length>0&&e(`\u26A0 --missing-dep outside closure(self) \u2014 excuses nothing: ${r.degraded.missingDepsOutsideClosure.join(", ")}`),r.degraded.missingDepsPresentInVault.length>0&&e(`\u26A0 --missing-dep named but PRESENT in the vault (assets found under its assetspaces/ folder) \u2014 ignored, excuses nothing: ${r.degraded.missingDepsPresentInVault.join(", ")}`),e(`Declared without a definition-tier fact (one-sided, never a violation; Reference-kind targets excluded): ${r.declaredWithoutFact.total} \u2014 TBox: ${r.declaredWithoutFact.byKind.TBox}, unkinded: ${r.declaredWithoutFact.byKind.unkinded}, unknown-kind: ${r.declaredWithoutFact.byKind.unknown}; packaging declarations (Reference-kind targets, frame p.4): ${r.packaging}`),e(`Declared targets without exo__AssetSpace_dependsOnKind: ${r.targetsWithoutKind.length}`+(r.targetsWithoutKind.length>0?` \u2014 ${r.targetsWithoutKind.join(", ")}`:"")),e("Declared-graph cycles are NOT judged by this verb (dependsOn = packaging, RFC 306dcb5c frame p.1); facts-graph acyclicity is the scheduled detector's job.");let o=r.facts.edges.filter(l=>!l.coveredByClosure);if(o.length>0){console.error(`
|
|
615
615
|
UNCOVERED by closure (src \u2192 tgt, occurrences, predicates):`);for(let l of o){console.error(` ${l.source} \u2192 ${l.target}: ${l.occurrences} [${Dbe(l.predicates)}]`);for(let u of l.examples)console.error(` ${u}`)}}if(r.unresolved.refs.length>0){let l=r.unresolved.countedAsUncovered?console.error:e;l(`
|
|
616
616
|
Unresolved definition-tier references (${r.unresolved.count}${r.degraded.active?"; excused \u2014 DEGRADED, coverage NOT proven":""}):`);for(let u of r.unresolved.refs.slice(0,50))l(` ${u.source}: ${u.sourcePath} --${u.predicate}--> ${u.ref} (${u.reason})`);r.unresolved.count>50&&l(` \u2026 ${r.unresolved.count-50} more`)}if(r.ambiguous.refs.length>0){let l=r.ambiguous.countedAsUncovered?console.error:e;l(`
|
|
617
617
|
Ambiguous definition-tier references (${r.ambiguous.count}; \u22652 distinct UIDs under one label \u2014 covered only when EVERY candidate's AssetSpace is in the source's closure):`);for(let u of r.ambiguous.refs.slice(0,50))l(` ${u.coveredByClosure?"covered ":"UNCOVERED"} ${u.source}: ${u.sourcePath} --${u.predicate}--> ${u.ref} \u2192 {${u.candidates.join(", ")}}`);r.ambiguous.count>50&&l(` \u2026 ${r.ambiguous.count-50} more`)}if(r.nonStringValues.sites.length>0){e(`
|
|
@@ -622,7 +622,7 @@ Dangling dependsOn declarations (no descriptor for the target UID):`);for(let l
|
|
|
622
622
|
isDefinedBy=${s.isDefinedBy} expected=${s.expectedFolder}/ actual=${s.actualFolder}/`)}console.error(`
|
|
623
623
|
Skipped (fail-open, NOT verified): ${i} \u2014 empty-isDefinedBy=${n.skips["empty-isDefinedBy"]}, bang-prefix=${n.skips["bang-prefix"]}, unresolvable(cross-vault/missing)=${n.skips.unresolvable}`)}n.violations.length>0&&(process.exitCode=1)}catch(t){ue.handle(t)}})}a(A7,"auditCoLocationCommand");at();var mE=require("fs"),k7=require("path"),MP=te(Me());function I7(r,e){let t=new Map,n=new Map,i=new Set,s=[],o=[],c=0;for(let l of r){if(t.has(l))continue;let u=[],f=a(d=>{t.set(d,c),n.set(d,c),c++,s.push(d),i.add(d),u.push([d,(e.get(d)??new Set).values()])},"pushNode");for(f(l);u.length>0;){let[d,p]=u[u.length-1],h=p.next();if(h.done){if(u.pop(),u.length>0){let g=u[u.length-1][0];n.set(g,Math.min(n.get(g),n.get(d)))}if(n.get(d)===t.get(d)){let g=[],m;do m=s.pop(),i.delete(m),g.push(m);while(m!==d);o.push(g)}}else{let g=h.value;t.has(g)?i.has(g)&&n.set(d,Math.min(n.get(d),t.get(g))):f(g)}}}return o}a(I7,"stronglyConnectedComponents");function R7(r,e){return I7(r,e).filter(t=>t.length>=2)}a(R7,"tarjanSCC");function hE(r,e){let t=new Map;for(let n of r){let i=new Set,s=[...e.get(n)??[]];for(;s.length>0;){let o=s.shift();if(!i.has(o)){i.add(o);for(let c of e.get(o)??[])i.has(c)||s.push(c)}}t.set(n,i)}return t}a(hE,"transitiveClosure");function C7(r,e){let t=I7(r,e),n=new Map;t.forEach((s,o)=>{for(let c of s)n.set(c,o)});let i=new Map;for(let[s,o]of e){let c=n.get(s);if(c!==void 0)for(let l of o){let u=n.get(l);if(u===void 0||c===u)continue;let f=i.get(c);f||(f=new Set,i.set(c,f)),f.add(u)}}return{components:t,componentOf:n,condensedEdges:i}}a(C7,"condense");function x7(r,e){let t=hE(r,e),n=new Map;for(let[i,s]of e)for(let o of s){let c=!1;for(let l of s)if(l!==o&&t.get(l)?.has(o)){c=!0;break}if(!c){let l=n.get(i);l||(l=new Set,n.set(i,l)),l.add(o)}}return n}a(x7,"transitiveReduction");function O7(r,e){let t=new Map,n=new Map;for(let p of r)t.set(p,new Map),n.set(p,new Map);for(let p of e){if(p.source===p.target)continue;let h=t.get(p.source),g=n.get(p.target);!h||!g||(h.set(p.target,(h.get(p.target)??0)+p.weight),g.set(p.source,(g.get(p.source)??0)+p.weight))}let i=new Set(r),s=[],o=[],c=a(p=>{i.delete(p);for(let h of t.get(p).keys())n.get(h)?.delete(p);for(let h of n.get(p).keys())t.get(h)?.delete(p);t.get(p).clear(),n.get(p).clear()},"removeNode"),l=a(p=>{let h=0;for(let g of p.values())h+=g;return h},"sumWeights"),u=a(()=>[...i].sort(),"sortedRemaining");for(;i.size>0;){let p=!0;for(;p;){p=!1;for(let h of u())i.has(h)&&t.get(h).size===0&&(o.unshift(h),c(h),p=!0);for(let h of u())i.has(h)&&n.get(h).size===0&&(s.push(h),c(h),p=!0)}if(i.size>0){let h=null,g=-1/0;for(let m of u()){let b=l(t.get(m))-l(n.get(m));b>g&&(g=b,h=m)}h!==null&&(s.push(h),c(h))}}let f=[...s,...o],d=new Map(f.map((p,h)=>[p,h]));return e.filter(p=>{if(p.source===p.target)return!1;let h=d.get(p.source),g=d.get(p.target);return h===void 0||g===void 0?!1:h>g})}a(O7,"greedyFeedbackArcSet");var P7=/\[\[([^\]]+)\]\]/g;function jbe(r){let e=r.split(`
|
|
624
624
|
`),t=[],n=null;for(let i of e){let s=i.match(/^[ \t]*(`{3,}|~{3,})/),o=s&&(s[1][0]==="~"||!i.slice(i.indexOf(s[1])+s[1].length).includes("`"));n===null?o?n=s[1]:t.push(i):s&&s[1][0]===n[0]&&s[1].length>=n.length&&/^[ \t]*(?:`{3,}|~{3,})[ \t]*$/.test(i)&&(n=null)}return t.join(`
|
|
625
|
-
`)}a(jbe,"stripFencedCodeBlocks");function F7(r){let e=[],t;for(P7.lastIndex=0;(t=P7.exec(r))!==null;){let n=t[1],i=n.indexOf("|");i!==-1&&(n=n.slice(0,i));let s=n.indexOf("#");s!==-1&&(n=n.slice(0,s));let o=n.trim();o.length>0&&e.push(o)}return e}a(F7,"extractWikilinkTargets");function NP(r){return typeof r=="string"?[r]:Array.isArray(r)?r.flatMap(NP):r!==null&&typeof r=="object"?Object.values(r).flatMap(NP):[]}a(NP,"collectFrontmatterStrings");function $be(r){let e=r.match(/^---\n[\s\S]*?\n---/);return e?r.slice(e[0].length):r}a($be,"bodyOf");function D7(r,e,t){let n=[];for(let[s,o]of Object.entries(r))if(!t?.has(s))for(let c of NP(o))for(let l of F7(c))n.push(l);let i=F7(jbe($be(e)));return[...n,...i]}a(D7,"extractFileWikilinkTargets");var Ube=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function L7(r,e){if(e.includes("/")){let n=e.replace(/^\//,""),i=n.endsWith(".md")?n:`${n}.md`;if(await r.hasIndexedPath(i))return i;e=n.slice(n.lastIndexOf("/")+1)}if(e.endsWith(".md")&&(e=e.slice(0,-3)),Ube.test(e)){let n=await r.findFileByUID(e);if(n)return n}let t=await r.findPathsByBasename(e);return t.length===1?t[0]:t.length>1?new Set(t).size===1?t[0]:"ambiguous":null}a(L7,"resolveTargetPath");Rt();Ut();var Bbe="\0",Vbe="829b9b3b-6fc3-4276-be6a-27d3398c012e",Gbe=["exo__Asset_relates","concept__Concept_related","concept__Concept_broader","concept__Concept_synonym","exo__Asset_createdBy"],qbe=5,Wbe=10,zbe=new Set(["png","jpg","jpeg","gif","svg","webp","bmp","ico","avif","pdf","mp3","wav","m4a","ogg","flac","mp4","mov","webm","avi","mkv","zip","gz","tar","canvas","base","json","css","js","ts","html"]);function Hbe(r){let e=r.lastIndexOf(".");if(e===-1||e===r.length-1)return!1;let t=r.slice(e+1).toLowerCase();return zbe.has(t)}a(Hbe,"nonMarkdownExtension");function kP(r){if(Array.isArray(r)){let e=r.filter(t=>typeof t=="string");return{value:e[0]??null,multiple:e.length>1}}return{value:typeof r=="string"?r:null,multiple:!1}}a(kP,"firstString");function N7(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){let i=(0,MP.extractAssetReference)(n);i&&t.push(i)}return t}a(N7,"asRefList");function _g(r,e,t=qbe){r.length<t&&r.push(e)}a(_g,"pushExample");async function Kbe(r,e={}){let t=new Cn(r,{cacheContent:!0}),n=await t.indexedAssets(),i=new Set(e.excludePredicates??[]),s=new Map,o=new Map,c=new Map,l=[];for(let $ of n){if(Zi($.path)||_i($.path)||!N7($.metadata.exo__Instance_class).includes(Vbe))continue;let{value:ie}=kP($.metadata.exo__Asset_uid);if(!ie){l.push($.path);continue}let{value:Ae}=kP($.metadata.exo__Asset_label),ye=Ae??$.path,
|
|
625
|
+
`)}a(jbe,"stripFencedCodeBlocks");function F7(r){let e=[],t;for(P7.lastIndex=0;(t=P7.exec(r))!==null;){let n=t[1],i=n.indexOf("|");i!==-1&&(n=n.slice(0,i));let s=n.indexOf("#");s!==-1&&(n=n.slice(0,s));let o=n.trim();o.length>0&&e.push(o)}return e}a(F7,"extractWikilinkTargets");function NP(r){return typeof r=="string"?[r]:Array.isArray(r)?r.flatMap(NP):r!==null&&typeof r=="object"?Object.values(r).flatMap(NP):[]}a(NP,"collectFrontmatterStrings");function $be(r){let e=r.match(/^---\n[\s\S]*?\n---/);return e?r.slice(e[0].length):r}a($be,"bodyOf");function D7(r,e,t){let n=[];for(let[s,o]of Object.entries(r))if(!t?.has(s))for(let c of NP(o))for(let l of F7(c))n.push(l);let i=F7(jbe($be(e)));return[...n,...i]}a(D7,"extractFileWikilinkTargets");var Ube=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function L7(r,e){if(e.includes("/")){let n=e.replace(/^\//,""),i=n.endsWith(".md")?n:`${n}.md`;if(await r.hasIndexedPath(i))return i;e=n.slice(n.lastIndexOf("/")+1)}if(e.endsWith(".md")&&(e=e.slice(0,-3)),Ube.test(e)){let n=await r.findFileByUID(e);if(n)return n}let t=await r.findPathsByBasename(e);return t.length===1?t[0]:t.length>1?new Set(t).size===1?t[0]:"ambiguous":null}a(L7,"resolveTargetPath");Rt();Ut();var Bbe="\0",Vbe="829b9b3b-6fc3-4276-be6a-27d3398c012e",Gbe=["exo__Asset_relates","concept__Concept_related","concept__Concept_broader","concept__Concept_synonym","exo__Asset_createdBy"],qbe=5,Wbe=10,zbe=new Set(["png","jpg","jpeg","gif","svg","webp","bmp","ico","avif","pdf","mp3","wav","m4a","ogg","flac","mp4","mov","webm","avi","mkv","zip","gz","tar","canvas","base","json","css","js","ts","html"]);function Hbe(r){let e=r.lastIndexOf(".");if(e===-1||e===r.length-1)return!1;let t=r.slice(e+1).toLowerCase();return zbe.has(t)}a(Hbe,"nonMarkdownExtension");function kP(r){if(Array.isArray(r)){let e=r.filter(t=>typeof t=="string");return{value:e[0]??null,multiple:e.length>1}}return{value:typeof r=="string"?r:null,multiple:!1}}a(kP,"firstString");function N7(r){let e=Array.isArray(r)?r:r==null?[]:[r],t=[];for(let n of e){let i=(0,MP.extractAssetReference)(n);i&&t.push(i)}return t}a(N7,"asRefList");function _g(r,e,t=qbe){r.length<t&&r.push(e)}a(_g,"pushExample");async function Kbe(r,e={}){let t=new Cn(r,{cacheContent:!0}),n=await t.indexedAssets(),i=new Set(e.excludePredicates??[]),s=new Map,o=new Map,c=new Map,l=[];for(let $ of n){if(Zi($.path)||_i($.path)||!N7($.metadata.exo__Instance_class).includes(Vbe))continue;let{value:ie}=kP($.metadata.exo__Asset_uid);if(!ie){l.push($.path);continue}let{value:Ae}=kP($.metadata.exo__Asset_label),ye=Ae??$.path,ve=c.get(ie);ve?ve.push($.path):c.set(ie,[$.path]),s.set($.path,ie),o.has(ie)||o.set(ie,{uid:ie,label:ye,path:$.path,metadata:$.metadata})}let u=[...c.entries()].filter(([,$])=>$.length>1).map(([$,de])=>({uid:$,paths:de})),f=new Map,d={"empty-isDefinedBy":0,"bang-prefix":0,unresolvable:0,"not-an-ontology":0},p=[],h=0,g=0,m=new Map,b=0,_=a(($,de)=>{f.set($,null),d[de]++,h++,_g(p,`${$} (${de})`,Wbe)},"markNoOntology");for(let $ of n){if(Zi($.path)||_i($.path))continue;b++;let de=$.metadata.exo__Asset_isDefinedBy,{value:ie,multiple:Ae}=kP(de);Ae&&g++;let ye=(0,MP.extractAssetReference)(ie);if(!ye){_($.path,"empty-isDefinedBy");continue}if(ye.startsWith("!")){_($.path,"bang-prefix");continue}let ve=await Qc(t,ye,$.path);if(!ve){_($.path,"unresolvable");continue}let Re=s.get(ve);if(!Re){_($.path,"not-an-ontology");continue}f.set($.path,Re),m.set(Re,(m.get(Re)??0)+1)}let S=[...o.keys()],I=new Map,E=[],w=new Map,R=new Map,x=0;for(let $ of S){let de=o.get($),ie=N7(de.metadata.exo__Ontology_imports),Ae=[],ye=[],ve=!1;for(let Re of ie){let pe=null;if(o.has(Re))pe=Re;else{let U=await Qc(t,Re,de.path);pe=U?s.get(U)??null:null}if(pe===null)ye.push(Re);else if(pe===$)ve=!0;else{Ae.push(pe);let U=I.get($);U||(U=new Set,I.set($,U)),U.has(pe)||(U.add(pe),x++)}}w.set($,Ae),R.set($,ye),ve&&E.push($)}let P=R7(S,I),k=hE(S,I),B={total:0,internal:0,crossOntologyValid:0,crossOntologyViolation:0,crossVault:0,noOntology:0},D={broken:0,"dup-basename":0,"non-markdown":0},Q={broken:[],"dup-basename":[],"non-markdown":[]},fe=new Map,j=new Map,ce=new Map,V=new Map,oe=new Map,K=new Map,z=a($=>{let de=o.get($);return de?{uid:de.uid,label:de.label,path:de.path}:{uid:$,label:$,path:""}},"toRef");for(let $ of n){if(Zi($.path)||_i($.path))continue;let de=f.get($.path)??null,ie=D7($.metadata,$.content??"",i);for(let Ae of ie){if(B.total++,Hbe(Ae)){D["non-markdown"]++,_g(Q["non-markdown"],`${$.path} \u2192 ${Ae}`);continue}let ye=await L7(t,Ae);if(ye==="ambiguous"){D["dup-basename"]++,_g(Q["dup-basename"],`${$.path} \u2192 ${Ae}`);continue}if(ye===null){D.broken++,_g(Q.broken,`${$.path} \u2192 ${Ae}`);continue}let ve=f.get(ye)??s.get(ye)??null;if(de===null||ve===null){B.noOntology++;continue}if(de===ve){B.internal++,ce.set(de,(ce.get(de)??0)+1);continue}let Re=k.get(de)?.has(ve)??!1,pe=`${de}${Bbe}${ve}`,U=fe.get(pe);if(U?U.occurrences++:fe.set(pe,{source:de,target:ve,occurrences:1,valid:Re}),V.set(de,(V.get(de)??0)+1),oe.set(ve,(oe.get(ve)??0)+1),Re)B.crossOntologyValid++;else{B.crossOntologyViolation++,K.set(de,(K.get(de)??0)+1);let F=j.get(pe);F?(F.occurrences++,_g(F.examples,$.path)):j.set(pe,{source:de,target:ve,occurrences:1,examples:[$.path]})}}}let Z=[...fe.values()].sort(($,de)=>de.occurrences-$.occurrences),Ie=new Map,ee=new Map;for(let $ of Z)ee.set($.source,(ee.get($.source)??0)+1),Ie.set($.target,(Ie.get($.target)??0)+1);let Y=S.map($=>({...z($),declaredImports:w.get($)??[],unresolvedImports:R.get($)??[],selfImport:E.includes($),assetCount:m.get($)??0,inDegree:Ie.get($)??0,outDegree:ee.get($)??0,internalLinks:ce.get($)??0,externalLinksOut:V.get($)??0,externalLinksIn:oe.get($)??0,violatingOut:K.get($)??0})).sort(($,de)=>$.label.localeCompare(de.label)),se=[...j.values()].map($=>({source:z($.source),target:z($.target),occurrences:$.occurrences,examples:$.examples})).sort(($,de)=>de.occurrences-$.occurrences),X=[],le=P.length===0,Ue=se.length===0&&B.crossVault===0&&le&&u.length===0;return{vaultPath:r,totalFiles:n.length,scannedFiles:b,ontologies:Y,duplicateOntologyUids:u,declared:{edgeCount:x,sccs:P,acyclic:le},derivedEdges:Z,violations:se,crossVault:X,linkCounts:B,skips:D,skipExamples:Q,noOntologyAssets:{count:h,byReason:d,examples:p},warnings:{selfImports:E,multipleIsDefinedBy:g,ontologiesWithoutUid:l},clean:Ue,...i.size>0?{excludedPredicates:[...i]}:{}}}a(Kbe,"scanVaultForOntologyImports");function Ybe(r){let e=r.ontologies.map(w=>w.uid),t=new Map;for(let w of r.ontologies)t.set(w.uid,{uid:w.uid,label:w.label,path:w.path});let n=a(w=>t.get(w)??{uid:w,label:w,path:""},"refOf"),i=new Map;for(let w of r.ontologies)w.declaredImports.length>0&&i.set(w.uid,new Set(w.declaredImports));let s=new Map,o=new Map;for(let w of r.derivedEdges){let R=s.get(w.source);R||(R=new Set,s.set(w.source,R)),R.add(w.target),o.set(`${w.source} ${w.target}`,w.occurrences)}let{components:c,componentOf:l}=C7(e,s),u=[],f=new Map,d=0;for(let w of r.derivedEdges){let R=l.get(w.source),x=l.get(w.target);if(R!==void 0&&x!==void 0&&R===x){let k=f.get(R);k||(k=[],f.set(R,k)),k.push({source:w.source,target:w.target,weight:w.occurrences})}else u.push({source:w.source,target:w.target,occurrences:w.occurrences}),w.valid&&d++}let p=a((w,R,x)=>{if(w===R)return!0;let P=[...x.get(w)??[]],k=new Set;for(;P.length>0;){let B=P.shift();if(B===R)return!0;if(!k.has(B)){k.add(B);for(let D of x.get(B)??[])P.push(D)}}return!1},"reaches"),h=new Map;for(let[w,R]of i)h.set(w,new Set(R));let g=[],m=[...u].sort((w,R)=>w.source===R.source?w.target.localeCompare(R.target):w.source.localeCompare(R.source));for(let w of m)if(p(w.target,w.source,h))g.push({source:n(w.source),target:n(w.target),occurrences:w.occurrences});else{let R=h.get(w.source);R||(R=new Set,h.set(w.source,R)),R.add(w.target)}let b=x7(e,h),_=[];for(let[w,R]of b)for(let x of R)i.get(w)?.has(x)||_.push({source:n(w),target:n(x),occurrences:o.get(`${w} ${x}`)??0});_.sort((w,R)=>R.occurrences-w.occurrences||w.source.uid.localeCompare(R.source.uid)||w.target.uid.localeCompare(R.target.uid));let S=[];for(let[w,R]of f){let x=c[w],k=O7(x,R).map(B=>({source:n(B.source),target:n(B.target),occurrences:B.weight})).sort((B,D)=>B.occurrences-D.occurrences||B.source.uid.localeCompare(D.source.uid)||B.target.uid.localeCompare(D.target.uid));S.push({ontologies:x.map(n).sort((B,D)=>B.label.localeCompare(D.label)),edgeCount:R.length,occurrenceCount:R.reduce((B,D)=>B+D.weight,0),suggestedCuts:k})}S.sort((w,R)=>R.ontologies.length-w.ontologies.length||R.occurrenceCount-w.occurrenceCount);let I=hE(e,i),E=[];for(let[w,R]of i)for(let x of R){let P=!1;for(let k of R)if(k!==x&&I.get(k)?.has(x)){P=!0;break}P&&E.push({source:n(w),target:n(x),occurrences:o.get(`${w} ${x}`)??0})}return{additions:_,acyclicEdgeCount:u.length,alreadyCovered:d,conflicts:g,intraScc:S,redundantDeclared:E}}a(Ybe,"computeImportProposal");function ro(r){return`${r.uid}|${r.label}|${r.path}`}a(ro,"formatRef");function Xbe(r){let e=r.ontologies.filter(i=>i.declaredImports.length>0||i.unresolvedImports.length>0).length,t=r.clean?console.log:console.error;if(t(`${r.clean?"OK":"FAIL"} ${r.vaultPath}: ontology-imports audit \u2014 ${r.linkCounts.crossOntologyViolation} violating occurrence(s) in ${r.violations.length} pair(s)`),t(`Ontologies: ${r.ontologies.length} (${e} with imports declared), declared graph: ${r.declared.edgeCount} edge(s), `+(r.declared.acyclic?"acyclic":`NOT ACYCLIC \u2014 ${r.declared.sccs.length} SCC(s)`)),r.excludedPredicates&&r.excludedPredicates.length>0&&t(`Structural-only mode (VL#30): excluded ${r.excludedPredicates.length} associative predicate(s) from edge extraction \u2014 ${r.excludedPredicates.join(", ")}`),r.duplicateOntologyUids.length>0){console.error(`
|
|
626
626
|
HARD ERRORS \u2014 duplicate ontology UIDs (R7):`);for(let i of r.duplicateOntologyUids)console.error(` ${i.uid}: ${i.paths.join(", ")}`)}if(!r.declared.acyclic){console.error(`
|
|
627
627
|
Declared-graph cycles (must be a DAG):`);for(let i of r.declared.sccs)console.error(` SCC[${i.length}]: ${i.map(s=>ro(Qbe(r,s))).join(" \u21C4 ")}`)}if(r.violations.length>0){console.error(`
|
|
628
628
|
Violating pairs (src \u2192 tgt, occurrences desc):`);for(let i of r.violations)console.error(` ${ro(i.source)} \u2192 ${ro(i.target)}: ${i.occurrences}`)}let n=r.ontologies.reduce((i,s)=>i+s.unresolvedImports.length,0);t(`
|
|
@@ -685,7 +685,7 @@ Next steps:
|
|
|
685
685
|
`).map(n=>n.trim()).filter(n=>n.length>0),t=e[e.length-1];if(t!==void 0)try{return JSON.parse(t)}catch{return}}a(Z_e,"parseLastJsonLine");function vV(r,e){return e.filter(t=>{let n=r[t];return typeof n!="string"||n.trim().length===0})}a(vV,"missingStringFields");var AE=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:EV,message:"Invalid request: expected a JSON-RPC object"}};let t=e.id,n=t===void 0;if(typeof e.method!="string")return n?null:{jsonrpc:"2.0",id:t??null,error:{code:EV,message:"Invalid request: missing method"}};if(n)return null;let i=t??null;switch(e.method){case"initialize":return{jsonrpc:"2.0",id:i,result:{protocolVersion:Q_e,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:wV}};case"tools/call":return{jsonrpc:"2.0",id:i,result:await this.callTool(e.params??{})};default:return{jsonrpc:"2.0",id:i,error:{code:J_e,message:`Method not found: ${e.method}`}}}}async callTool(e){let t=e.name,n=e.arguments??{},i;if(t==="create_asset"){let c=vV(n,["vault","class","label"]);if(c.length>0)return mp(`create_asset: missing required argument(s): ${c.join(", ")}`,!0);let l=bV(n);if(l!==null)return mp(`create_asset: ${l}`,!0);i=_V(n)}else if(t==="create_effort"){let c=vV(n,["vault","command","target"]);if(c.length>0)return mp(`create_effort: missing required argument(s): ${c.join(", ")}`,!0);i=SV(n)}else return mp(`Unknown tool: ${String(t)}`,!0);let s=await this.deps.runCli(i);if(s.exitCode!==0){let c=s.stderr.trim()||s.stdout.trim()||"(no diagnostic output)";return mp(`exocortex-cli exited ${s.exitCode}
|
|
686
686
|
${c}`,!0)}let o=Z_e(s.stdout);return mp(o===void 0?s.stdout.trim():JSON.stringify(o))}};var IV=require("child_process");var eSe=32*1024*1024;function RV(r){return e=>new Promise(t=>{(0,IV.execFile)(process.execPath,[r,...e],{maxBuffer:eSe},(n,i,s)=>{let o=0;if(n){let c=n.code;o=typeof c=="number"?c:1}t({stdout:i,stderr:s,exitCode:o})})})}a(RV,"createSelfCliRunner");async function tSe(r,e,t){let n=(0,CV.createInterface)({input:e,crlfDelay:1/0});for await(let i of n){let s=i.trim();if(s.length===0)continue;let o;try{o=JSON.parse(s)}catch{t(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:TV,message:"Parse error: invalid JSON"}})+`
|
|
687
687
|
`);continue}let c;try{c=await r.handle(o)}catch(l){c={jsonrpc:"2.0",id:typeof o?.id=="string"||typeof o?.id=="number"?o.id:null,error:{code:AV,message:`Internal error: ${l instanceof Error?l.message:String(l)}`}}}c!==null&&t(JSON.stringify(c)+`
|
|
688
|
-
`)}}a(tSe,"runStdioServer");function xV(r){return new he("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new AE({runCli:RV(t),version:r??"unknown"});await tSe(n,process.stdin,i=>process.stdout.write(i))})}a(xV,"mcpCommand");function IE(r){let e=new he;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"16.248.
|
|
688
|
+
`)}}a(tSe,"runStdioServer");function xV(r){return new he("mcp").description("Run an MCP (Model Context Protocol) stdio server exposing create_asset / create_effort tools backed by this CLI").option("--entry <path>","Path to the CLI entry script the tools invoke (defaults to this process's script)").action(async e=>{let t=e.entry??process.argv[1],n=new AE({runCli:RV(t),version:r??"unknown"});await tSe(n,process.stdin,i=>process.stdout.write(i))})}a(xV,"mcpCommand");function IE(r){let e=new he;return e.name("exocortex").description("CLI tool for Exocortex knowledge management system - SPARQL queries, task management, and more").version(r??"16.248.6"),e.addCommand(c7()),e.addCommand(y7()),e.addCommand(e8()),e.addCommand(i8()),e.addCommand(I8()),e.addCommand(s8()),e.addCommand(f8()),e.addCommand(d8()),e.addCommand(L8()),e.addCommand($8()),e.addCommand(J8()),e.addCommand(t7()),e.addCommand(r7()),e.addCommand(i7()),e.addCommand(s7()),e.addCommand(V7()),e.addCommand(W7()),e.addCommand(oV()),e.addCommand(cV()),e.addCommand(fV()),e.addCommand(dV()),e.addCommand(mV()),e.addCommand(Q7()),e.addCommand(nV()),e.addCommand(gV()),e.addCommand(xV(r??"16.248.6")),e}a(IE,"createProgram");IE().parse();0&&(module.exports={createProgram});
|
|
689
689
|
/*! Bundled license information:
|
|
690
690
|
|
|
691
691
|
reflect-metadata/Reflect.js:
|